blob: 0ea274da1e19d398251a212ecb30c3549355f86d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_VIDEO_LAYER_IMPL_H_
#define CC_VIDEO_LAYER_IMPL_H_
#include "base/callback.h"
#include "base/synchronization/lock.h"
#include "cc/cc_export.h"
#include "cc/layer_impl.h"
#include "cc/video_frame_provider.h"
#include "media/base/video_frame.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/size.h"
#include "ui/gfx/transform.h"
namespace media {
class SkCanvasVideoRenderer;
}
namespace cc {
class LayerTreeHostImpl;
class CC_EXPORT VideoLayerImpl : public LayerImpl
, public VideoFrameProvider::Client {
public:
static scoped_ptr<VideoLayerImpl> create(LayerTreeImpl* treeImpl, int id, VideoFrameProvider* provider)
{
return make_scoped_ptr(new VideoLayerImpl(treeImpl, id, provider));
}
virtual ~VideoLayerImpl();
virtual void willDraw(ResourceProvider*) OVERRIDE;
virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
virtual void didDraw(ResourceProvider*) OVERRIDE;
// VideoFrameProvider::Client implementation.
virtual void StopUsingProvider() OVERRIDE; // Callable on any thread.
virtual void DidReceiveFrame() OVERRIDE; // Callable on impl thread.
virtual void DidUpdateMatrix(const float*) OVERRIDE; // Callable on impl thread.
virtual void didLoseOutputSurface() OVERRIDE;
void setNeedsRedraw();
struct FramePlane {
ResourceProvider::ResourceId resourceId;
gfx::Size size;
GLenum format;
FramePlane() : resourceId(0) { }
bool allocateData(ResourceProvider*);
void freeData(ResourceProvider*);
};
private:
VideoLayerImpl(LayerTreeImpl*, int, VideoFrameProvider*);
virtual const char* layerTypeAsString() const OVERRIDE;
void willDrawInternal(ResourceProvider*);
bool allocatePlaneData(ResourceProvider*);
bool copyPlaneData(ResourceProvider*);
void freePlaneData(ResourceProvider*);
void freeUnusedPlaneData(ResourceProvider*);
size_t numPlanes() const;
// Guards the destruction of m_provider and the frame that it provides
base::Lock m_providerLock;
VideoFrameProvider* m_provider;
gfx::Transform m_streamTextureMatrix;
media::VideoFrame* m_frame;
GLenum m_format;
bool m_convertYUV;
ResourceProvider::ResourceId m_externalTextureResource;
scoped_ptr<media::SkCanvasVideoRenderer> m_videoRenderer;
// Each index in this array corresponds to a plane in media::VideoFrame.
FramePlane m_framePlanes[media::VideoFrame::kMaxPlanes];
};
} // namespace cc
#endif // CC_VIDEO_LAYER_IMPL_H_
|