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
3 // found in the LICENSE file.
5 #ifndef CCVideoLayerImpl_h
6 #define CCVideoLayerImpl_h
8 #include "CCLayerImpl.h"
9 #include "GraphicsContext3D.h"
11 #include <public/WebTransformationMatrix.h>
12 #include <public/WebVideoFrameProvider.h>
20 class CCLayerTreeHostImpl
;
21 class CCVideoLayerImpl
;
23 class CCVideoLayerImpl
: public CCLayerImpl
24 , public WebKit::WebVideoFrameProvider::Client
{
26 static PassOwnPtr
<CCVideoLayerImpl
> create(int id
, WebKit::WebVideoFrameProvider
* provider
)
28 return adoptPtr(new CCVideoLayerImpl(id
, provider
));
30 virtual ~CCVideoLayerImpl();
32 virtual void willDraw(CCResourceProvider
*) OVERRIDE
;
33 virtual void appendQuads(CCQuadSink
&, CCAppendQuadsData
&) OVERRIDE
;
34 virtual void didDraw(CCResourceProvider
*) OVERRIDE
;
36 virtual void dumpLayerProperties(std::string
*, int indent
) const OVERRIDE
;
38 Mutex
& providerMutex() { return m_providerMutex
; }
40 // WebKit::WebVideoFrameProvider::Client implementation.
41 virtual void stopUsingProvider(); // Callable on any thread.
42 virtual void didReceiveFrame(); // Callable on impl thread.
43 virtual void didUpdateMatrix(const float*); // Callable on impl thread.
45 virtual void didLoseContext() OVERRIDE
;
47 void setNeedsRedraw();
50 CCResourceProvider::ResourceId resourceId
;
55 FramePlane() : resourceId(0) { }
57 bool allocateData(CCResourceProvider
*);
58 void freeData(CCResourceProvider
*);
62 CCVideoLayerImpl(int, WebKit::WebVideoFrameProvider
*);
64 static IntSize
computeVisibleSize(const WebKit::WebVideoFrame
&, unsigned plane
);
65 virtual const char* layerTypeAsString() const OVERRIDE
;
67 void willDrawInternal(CCResourceProvider
*);
68 bool allocatePlaneData(CCResourceProvider
*);
69 bool copyPlaneData(CCResourceProvider
*);
70 void freePlaneData(CCResourceProvider
*);
71 void freeUnusedPlaneData(CCResourceProvider
*);
73 // Guards the destruction of m_provider and the frame that it provides
74 Mutex m_providerMutex
;
75 WebKit::WebVideoFrameProvider
* m_provider
;
77 WebKit::WebTransformationMatrix m_streamTextureMatrix
;
79 WebKit::WebVideoFrame
* m_frame
;
81 CCResourceProvider::ResourceId m_externalTextureResource
;
83 // Each index in this array corresponds to a plane in WebKit::WebVideoFrame.
84 FramePlane m_framePlanes
[WebKit::WebVideoFrame::maxPlanes
];
89 #endif // CCVideoLayerImpl_h