[M120 Migration][MM][WebRTC] Base implementation for webrtc video hole stream
[platform/framework/web/chromium-efl.git] / cc / layers / video_layer.cc
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.
4
5 #include "cc/layers/video_layer.h"
6
7 #include "cc/layers/video_layer_impl.h"
8
9 namespace cc {
10
11 scoped_refptr<VideoLayer> VideoLayer::Create(
12     VideoFrameProvider* provider,
13     media::VideoTransformation transform
14 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
15     ,
16     absl::optional<int> player_id
17 #endif
18 ) {
19   return base::WrapRefCounted(new VideoLayer(provider, transform
20 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
21                                              ,
22                                              player_id
23 #endif
24                                              ));
25 }
26
27 VideoLayer::VideoLayer(VideoFrameProvider* provider,
28                        media::VideoTransformation transform
29 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
30                        ,
31                        absl::optional<int> player_id
32 #endif
33                        )
34     : provider_(provider),
35       transform_(transform)
36 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
37       ,
38       player_id_(player_id)
39 #endif
40 {
41   SetMayContainVideo(true);
42   DCHECK(provider_.Read(*this));
43 }
44
45 VideoLayer::~VideoLayer() = default;
46
47 std::unique_ptr<LayerImpl> VideoLayer::CreateLayerImpl(
48     LayerTreeImpl* tree_impl) const {
49   return VideoLayerImpl::Create(tree_impl, id(), provider_.Read(*this),
50                                 transform_
51 #if defined(TIZEN_VIDEO_HOLE) && BUILDFLAG(IS_TIZEN_TV)
52                                 ,
53                                 player_id_
54 #endif
55   );
56 }
57
58 bool VideoLayer::RequiresSetNeedsDisplayOnHdrHeadroomChange() const {
59   // TODO(https://crbug.com/1450807): Only return true if the contents of the
60   // video are HDR.
61   return true;
62 }
63
64 bool VideoLayer::Update() {
65   bool updated = Layer::Update();
66
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.
69   //
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();
73
74   return updated;
75 }
76
77 void VideoLayer::StopUsingProvider() {
78   provider_.Write(*this) = nullptr;
79 }
80
81 }  // namespace cc