Support swap promises that are pinned to a particular layer tree.
[chromium-blink-merge.git] / cc / layers / video_layer_impl.h
blob6fab7f58dcb5df89413df656bbcd790faaaebd14
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 CC_LAYERS_VIDEO_LAYER_IMPL_H_
6 #define CC_LAYERS_VIDEO_LAYER_IMPL_H_
8 #include <vector>
10 #include "cc/base/cc_export.h"
11 #include "cc/layers/layer_impl.h"
12 #include "cc/resources/release_callback_impl.h"
13 #include "cc/resources/video_resource_updater.h"
14 #include "media/base/video_rotation.h"
16 namespace media {
17 class VideoFrame;
20 namespace cc {
21 class VideoFrameProvider;
22 class VideoFrameProviderClientImpl;
24 class CC_EXPORT VideoLayerImpl : public LayerImpl {
25 public:
26 // Must be called on the impl thread while the main thread is blocked. This is
27 // so that |provider| stays alive while this is being created.
28 static scoped_ptr<VideoLayerImpl> Create(LayerTreeImpl* tree_impl,
29 int id,
30 VideoFrameProvider* provider,
31 media::VideoRotation video_rotation);
32 ~VideoLayerImpl() override;
34 // LayerImpl implementation.
35 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
36 bool WillDraw(DrawMode draw_mode,
37 ResourceProvider* resource_provider) override;
38 void AppendQuads(RenderPass* render_pass,
39 AppendQuadsData* append_quads_data) override;
40 void DidDraw(ResourceProvider* resource_provider) override;
41 SimpleEnclosedRegion VisibleOpaqueRegion() const override;
42 void DidBecomeActive() override;
43 void ReleaseResources() override;
45 void SetNeedsRedraw();
46 media::VideoRotation video_rotation() const { return video_rotation_; }
48 private:
49 VideoLayerImpl(
50 LayerTreeImpl* tree_impl,
51 int id,
52 const scoped_refptr<VideoFrameProviderClientImpl>& provider_client_impl,
53 media::VideoRotation video_rotation);
55 const char* LayerTypeAsString() const override;
57 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl_;
59 scoped_refptr<media::VideoFrame> frame_;
61 media::VideoRotation video_rotation_;
63 scoped_ptr<VideoResourceUpdater> updater_;
64 VideoFrameExternalResources::ResourceType frame_resource_type_;
65 struct FrameResource {
66 FrameResource(ResourceId id, gfx::Size size_in_pixels, bool allow_overlay)
67 : id(id),
68 size_in_pixels(size_in_pixels),
69 allow_overlay(allow_overlay) {}
70 ResourceId id;
71 gfx::Size size_in_pixels;
72 bool allow_overlay;
74 std::vector<FrameResource> frame_resources_;
76 // TODO(danakj): Remove these, hide software path inside ResourceProvider and
77 // ExternalResource (aka TextureMailbox) classes.
78 std::vector<unsigned> software_resources_;
79 // Called once for each software resource.
80 ReleaseCallbackImpl software_release_callback_;
82 DISALLOW_COPY_AND_ASSIGN(VideoLayerImpl);
85 } // namespace cc
87 #endif // CC_LAYERS_VIDEO_LAYER_IMPL_H_