1 // Copyright 2010 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/video_layer.h"
7 #include "cc/layers/video_layer_impl.h"
11 scoped_refptr<VideoLayer> VideoLayer::Create(
12 VideoFrameProvider* provider,
13 media::VideoTransformation transform
14 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
16 absl::optional<int> player_id
19 return base::WrapRefCounted(new VideoLayer(provider, transform
20 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
27 VideoLayer::VideoLayer(VideoFrameProvider* provider,
28 media::VideoTransformation transform
29 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
31 absl::optional<int> player_id
34 : provider_(provider),
36 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
41 SetMayContainVideo(true);
42 DCHECK(provider_.Read(*this));
45 VideoLayer::~VideoLayer() = default;
47 std::unique_ptr<LayerImpl> VideoLayer::CreateLayerImpl(
48 LayerTreeImpl* tree_impl) const {
49 return VideoLayerImpl::Create(tree_impl, id(), provider_.Read(*this),
51 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
58 bool VideoLayer::RequiresSetNeedsDisplayOnHdrHeadroomChange() const {
59 // TODO(https://crbug.com/1450807): Only return true if the contents of the
64 bool VideoLayer::Update() {
65 bool updated = Layer::Update();
67 // Video layer doesn't update any resources from the main thread side,
68 // but repaint rects need to be sent to the VideoLayerImpl via commit.
70 // This is the inefficient legacy redraw path for videos. It's better to
71 // communicate this directly to the VideoLayerImpl.
72 updated |= !update_rect().IsEmpty();
77 void VideoLayer::StopUsingProvider() {
78 provider_.Write(*this) = nullptr;