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 CCVideoLayerImpl_h | 5 #ifndef CCVideoLayerImpl_h |
6 #define CCVideoLayerImpl_h | 6 #define CCVideoLayerImpl_h |
7 | 7 |
8 #include "IntSize.h" | 8 #include "IntSize.h" |
| 9 #include "base/callback.h" |
9 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
10 #include "cc/layer_impl.h" | 11 #include "cc/layer_impl.h" |
| 12 #include "media/base/video_frame.h" |
11 #include "third_party/khronos/GLES2/gl2.h" | 13 #include "third_party/khronos/GLES2/gl2.h" |
12 #include <public/WebTransformationMatrix.h> | 14 #include <public/WebTransformationMatrix.h> |
13 #include <public/WebVideoFrameProvider.h> | 15 #include <public/WebVideoFrameProvider.h> |
14 | 16 |
15 namespace WebKit { | 17 namespace WebKit { |
16 class WebVideoFrame; | 18 class WebVideoFrame; |
17 } | 19 } |
18 | 20 |
| 21 namespace media { |
| 22 class SkCanvasVideoRenderer; |
| 23 } |
| 24 |
19 namespace cc { | 25 namespace cc { |
20 | 26 |
21 class LayerTreeHostImpl; | 27 class LayerTreeHostImpl; |
22 class VideoLayerImpl; | 28 class VideoLayerImpl; |
23 | 29 |
24 class VideoLayerImpl : public LayerImpl | 30 class VideoLayerImpl : public LayerImpl |
25 , public WebKit::WebVideoFrameProvider::Client { | 31 , public WebKit::WebVideoFrameProvider::Client { |
26 public: | 32 public: |
27 static scoped_ptr<VideoLayerImpl> create(int id, WebKit::WebVideoFrameProvid
er* provider) | 33 typedef base::Callback<media::VideoFrame* (WebKit::WebVideoFrame*)> FrameUnw
rapper; |
| 34 |
| 35 static scoped_ptr<VideoLayerImpl> create(int id, WebKit::WebVideoFrameProvid
er* provider, |
| 36 const FrameUnwrapper& unwrapper) |
28 { | 37 { |
29 return make_scoped_ptr(new VideoLayerImpl(id, provider)); | 38 return make_scoped_ptr(new VideoLayerImpl(id, provider, unwrapper)); |
30 } | 39 } |
31 virtual ~VideoLayerImpl(); | 40 virtual ~VideoLayerImpl(); |
32 | 41 |
33 virtual void willDraw(ResourceProvider*) OVERRIDE; | 42 virtual void willDraw(ResourceProvider*) OVERRIDE; |
34 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; | 43 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; |
35 virtual void didDraw(ResourceProvider*) OVERRIDE; | 44 virtual void didDraw(ResourceProvider*) OVERRIDE; |
36 | 45 |
37 virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; | 46 virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; |
38 | 47 |
39 // WebKit::WebVideoFrameProvider::Client implementation. | 48 // WebKit::WebVideoFrameProvider::Client implementation. |
(...skipping 11 matching lines...) Expand all Loading... |
51 GLenum format; | 60 GLenum format; |
52 IntSize visibleSize; | 61 IntSize visibleSize; |
53 | 62 |
54 FramePlane() : resourceId(0) { } | 63 FramePlane() : resourceId(0) { } |
55 | 64 |
56 bool allocateData(ResourceProvider*); | 65 bool allocateData(ResourceProvider*); |
57 void freeData(ResourceProvider*); | 66 void freeData(ResourceProvider*); |
58 }; | 67 }; |
59 | 68 |
60 private: | 69 private: |
61 VideoLayerImpl(int, WebKit::WebVideoFrameProvider*); | 70 VideoLayerImpl(int, WebKit::WebVideoFrameProvider*, const FrameUnwrapper&); |
62 | 71 |
63 static IntSize computeVisibleSize(const WebKit::WebVideoFrame&, unsigned pla
ne); | |
64 virtual const char* layerTypeAsString() const OVERRIDE; | 72 virtual const char* layerTypeAsString() const OVERRIDE; |
65 | 73 |
66 void willDrawInternal(ResourceProvider*); | 74 void willDrawInternal(ResourceProvider*); |
67 bool allocatePlaneData(ResourceProvider*); | 75 bool allocatePlaneData(ResourceProvider*); |
68 bool copyPlaneData(ResourceProvider*); | 76 bool copyPlaneData(ResourceProvider*); |
69 void freePlaneData(ResourceProvider*); | 77 void freePlaneData(ResourceProvider*); |
70 void freeUnusedPlaneData(ResourceProvider*); | 78 void freeUnusedPlaneData(ResourceProvider*); |
| 79 size_t numPlanes() const; |
71 | 80 |
72 // Guards the destruction of m_provider and the frame that it provides | 81 // Guards the destruction of m_provider and the frame that it provides |
73 base::Lock m_providerLock; | 82 base::Lock m_providerLock; |
74 WebKit::WebVideoFrameProvider* m_provider; | 83 WebKit::WebVideoFrameProvider* m_provider; |
75 | 84 |
76 WebKit::WebTransformationMatrix m_streamTextureMatrix; | 85 WebKit::WebTransformationMatrix m_streamTextureMatrix; |
77 | 86 |
78 WebKit::WebVideoFrame* m_frame; | 87 FrameUnwrapper m_unwrapper; |
| 88 WebKit::WebVideoFrame *m_webFrame; |
| 89 media::VideoFrame* m_frame; |
79 GLenum m_format; | 90 GLenum m_format; |
| 91 bool m_convertYUV; |
80 ResourceProvider::ResourceId m_externalTextureResource; | 92 ResourceProvider::ResourceId m_externalTextureResource; |
| 93 scoped_ptr<media::SkCanvasVideoRenderer> m_videoRenderer; |
81 | 94 |
82 // Each index in this array corresponds to a plane in WebKit::WebVideoFrame. | 95 // Each index in this array corresponds to a plane in media::VideoFrame. |
83 FramePlane m_framePlanes[WebKit::WebVideoFrame::maxPlanes]; | 96 FramePlane m_framePlanes[media::VideoFrame::kMaxPlanes]; |
84 }; | 97 }; |
85 | 98 |
86 } // namespace cc | 99 } // namespace cc |
87 | 100 |
88 #endif // CCVideoLayerImpl_h | 101 #endif // CCVideoLayerImpl_h |
OLD | NEW |