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