OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CC_VIDEO_LAYER_IMPL_H_ | |
6 #define CC_VIDEO_LAYER_IMPL_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/synchronization/lock.h" | |
10 #include "cc/base/cc_export.h" | |
11 #include "cc/layer_impl.h" | |
12 #include "cc/video_frame_provider.h" | |
13 #include "media/base/video_frame.h" | |
14 #include "third_party/khronos/GLES2/gl2.h" | |
15 #include "ui/gfx/size.h" | |
16 #include "ui/gfx/transform.h" | |
17 | |
18 namespace media { | |
19 class SkCanvasVideoRenderer; | |
20 } | |
21 | |
22 namespace cc { | |
23 class LayerTreeHostImpl; | |
24 class VideoFrameProviderClientImpl; | |
25 | |
26 class CC_EXPORT VideoLayerImpl : public LayerImpl { | |
27 public: | |
28 static scoped_ptr<VideoLayerImpl> Create(LayerTreeImpl* tree_impl, | |
29 int id, | |
30 VideoFrameProvider* provider); | |
31 virtual ~VideoLayerImpl(); | |
32 | |
33 // LayerImpl implementation. | |
34 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | |
35 OVERRIDE; | |
36 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | |
37 virtual void WillDraw(ResourceProvider* resource_provider) OVERRIDE; | |
38 virtual void AppendQuads(QuadSink* quad_sink, | |
39 AppendQuadsData* append_quads_data) OVERRIDE; | |
40 virtual void DidDraw(ResourceProvider* resource_provider) OVERRIDE; | |
41 virtual void DidBecomeActive() OVERRIDE; | |
42 virtual void DidLoseOutputSurface() OVERRIDE; | |
43 | |
44 void SetNeedsRedraw(); | |
45 | |
46 void SetProviderClientImpl( | |
47 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl); | |
48 | |
49 struct FramePlane { | |
50 ResourceProvider::ResourceId resource_id; | |
51 gfx::Size size; | |
52 GLenum format; | |
53 | |
54 FramePlane() : resource_id(0), format(GL_LUMINANCE) {} | |
55 | |
56 bool AllocateData(ResourceProvider* resource_provider); | |
57 void FreeData(ResourceProvider* resource_provider); | |
58 }; | |
59 | |
60 private: | |
61 VideoLayerImpl(LayerTreeImpl* tree_impl, int id); | |
62 | |
63 virtual const char* LayerTypeAsString() const OVERRIDE; | |
64 | |
65 void WillDrawInternal(ResourceProvider* resource_provider); | |
66 bool AllocatePlaneData(ResourceProvider* resource_provider); | |
67 bool CopyPlaneData(ResourceProvider* resource_provider); | |
68 void FreePlaneData(ResourceProvider* resource_provider); | |
69 void FreeUnusedPlaneData(ResourceProvider* resource_provider); | |
70 size_t NumPlanes() const; | |
71 | |
72 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl_; | |
73 | |
74 media::VideoFrame* frame_; | |
75 GLenum format_; | |
76 bool convert_yuv_; | |
77 ResourceProvider::ResourceId external_texture_resource_; | |
78 scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_; | |
79 | |
80 // Each index in this array corresponds to a plane in media::VideoFrame. | |
81 FramePlane frame_planes_[media::VideoFrame::kMaxPlanes]; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(VideoLayerImpl); | |
84 }; | |
85 | |
86 } // namespace cc | |
87 | |
88 #endif // CC_VIDEO_LAYER_IMPL_H_ | |
OLD | NEW |