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