| 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 "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
| 9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
| 10 #include "GraphicsContext3D.h" | 10 #include "GraphicsContext3D.h" |
| 11 #include "IntSize.h" | 11 #include "IntSize.h" |
| 12 #include <public/WebTransformationMatrix.h> | 12 #include <public/WebTransformationMatrix.h> |
| 13 #include <public/WebVideoFrameProvider.h> | 13 #include <public/WebVideoFrameProvider.h> |
| 14 #include <wtf/ThreadingPrimitives.h> | 14 #include <wtf/ThreadingPrimitives.h> |
| 15 | 15 |
| 16 namespace WebKit { | 16 namespace WebKit { |
| 17 class WebVideoFrame; | 17 class WebVideoFrame; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 | 21 |
| 22 class CCLayerTreeHostImpl; | 22 class LayerTreeHostImpl; |
| 23 class CCVideoLayerImpl; | 23 class VideoLayerImpl; |
| 24 | 24 |
| 25 class CCVideoLayerImpl : public CCLayerImpl | 25 class VideoLayerImpl : public LayerImpl |
| 26 , public WebKit::WebVideoFrameProvider::Client { | 26 , public WebKit::WebVideoFrameProvider::Client { |
| 27 public: | 27 public: |
| 28 static scoped_ptr<CCVideoLayerImpl> create(int id, WebKit::WebVideoFrameProv
ider* provider) | 28 static scoped_ptr<VideoLayerImpl> create(int id, WebKit::WebVideoFrameProvid
er* provider) |
| 29 { | 29 { |
| 30 return make_scoped_ptr(new CCVideoLayerImpl(id, provider)); | 30 return make_scoped_ptr(new VideoLayerImpl(id, provider)); |
| 31 } | 31 } |
| 32 virtual ~CCVideoLayerImpl(); | 32 virtual ~VideoLayerImpl(); |
| 33 | 33 |
| 34 virtual void willDraw(CCResourceProvider*) OVERRIDE; | 34 virtual void willDraw(ResourceProvider*) OVERRIDE; |
| 35 virtual void appendQuads(CCQuadSink&, CCAppendQuadsData&) OVERRIDE; | 35 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; |
| 36 virtual void didDraw(CCResourceProvider*) OVERRIDE; | 36 virtual void didDraw(ResourceProvider*) OVERRIDE; |
| 37 | 37 |
| 38 virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; | 38 virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; |
| 39 | 39 |
| 40 // WebKit::WebVideoFrameProvider::Client implementation. | 40 // WebKit::WebVideoFrameProvider::Client implementation. |
| 41 virtual void stopUsingProvider(); // Callable on any thread. | 41 virtual void stopUsingProvider(); // Callable on any thread. |
| 42 virtual void didReceiveFrame(); // Callable on impl thread. | 42 virtual void didReceiveFrame(); // Callable on impl thread. |
| 43 virtual void didUpdateMatrix(const float*); // Callable on impl thread. | 43 virtual void didUpdateMatrix(const float*); // Callable on impl thread. |
| 44 | 44 |
| 45 virtual void didLoseContext() OVERRIDE; | 45 virtual void didLoseContext() OVERRIDE; |
| 46 | 46 |
| 47 void setNeedsRedraw(); | 47 void setNeedsRedraw(); |
| 48 | 48 |
| 49 struct FramePlane { | 49 struct FramePlane { |
| 50 CCResourceProvider::ResourceId resourceId; | 50 ResourceProvider::ResourceId resourceId; |
| 51 IntSize size; | 51 IntSize size; |
| 52 GC3Denum format; | 52 GC3Denum format; |
| 53 IntSize visibleSize; | 53 IntSize visibleSize; |
| 54 | 54 |
| 55 FramePlane() : resourceId(0) { } | 55 FramePlane() : resourceId(0) { } |
| 56 | 56 |
| 57 bool allocateData(CCResourceProvider*); | 57 bool allocateData(ResourceProvider*); |
| 58 void freeData(CCResourceProvider*); | 58 void freeData(ResourceProvider*); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 CCVideoLayerImpl(int, WebKit::WebVideoFrameProvider*); | 62 VideoLayerImpl(int, WebKit::WebVideoFrameProvider*); |
| 63 | 63 |
| 64 static IntSize computeVisibleSize(const WebKit::WebVideoFrame&, unsigned pla
ne); | 64 static IntSize computeVisibleSize(const WebKit::WebVideoFrame&, unsigned pla
ne); |
| 65 virtual const char* layerTypeAsString() const OVERRIDE; | 65 virtual const char* layerTypeAsString() const OVERRIDE; |
| 66 | 66 |
| 67 void willDrawInternal(CCResourceProvider*); | 67 void willDrawInternal(ResourceProvider*); |
| 68 bool allocatePlaneData(CCResourceProvider*); | 68 bool allocatePlaneData(ResourceProvider*); |
| 69 bool copyPlaneData(CCResourceProvider*); | 69 bool copyPlaneData(ResourceProvider*); |
| 70 void freePlaneData(CCResourceProvider*); | 70 void freePlaneData(ResourceProvider*); |
| 71 void freeUnusedPlaneData(CCResourceProvider*); | 71 void freeUnusedPlaneData(ResourceProvider*); |
| 72 | 72 |
| 73 // Guards the destruction of m_provider and the frame that it provides | 73 // Guards the destruction of m_provider and the frame that it provides |
| 74 base::Lock m_providerLock; | 74 base::Lock m_providerLock; |
| 75 WebKit::WebVideoFrameProvider* m_provider; | 75 WebKit::WebVideoFrameProvider* m_provider; |
| 76 | 76 |
| 77 WebKit::WebTransformationMatrix m_streamTextureMatrix; | 77 WebKit::WebTransformationMatrix m_streamTextureMatrix; |
| 78 | 78 |
| 79 WebKit::WebVideoFrame* m_frame; | 79 WebKit::WebVideoFrame* m_frame; |
| 80 GC3Denum m_format; | 80 GC3Denum m_format; |
| 81 CCResourceProvider::ResourceId m_externalTextureResource; | 81 ResourceProvider::ResourceId m_externalTextureResource; |
| 82 | 82 |
| 83 // Each index in this array corresponds to a plane in WebKit::WebVideoFrame. | 83 // Each index in this array corresponds to a plane in WebKit::WebVideoFrame. |
| 84 FramePlane m_framePlanes[WebKit::WebVideoFrame::maxPlanes]; | 84 FramePlane m_framePlanes[WebKit::WebVideoFrame::maxPlanes]; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } | 87 } |
| 88 | 88 |
| 89 #endif // CCVideoLayerImpl_h | 89 #endif // CCVideoLayerImpl_h |
| OLD | NEW |