Revert "[M120 Migration]Fix for crash during chrome exit"
[platform/framework/web/chromium-efl.git] / cc / slim / surface_layer.h
1 // Copyright 2023 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 #ifndef CC_SLIM_SURFACE_LAYER_H_
6 #define CC_SLIM_SURFACE_LAYER_H_
7
8 #include "base/component_export.h"
9 #include "cc/layers/deadline_policy.h"
10 #include "cc/slim/layer.h"
11 #include "components/viz/common/surfaces/surface_id.h"
12 #include "components/viz/common/surfaces/surface_range.h"
13 #include "third_party/abseil-cpp/absl/types/optional.h"
14
15 namespace cc {
16 class SurfaceLayer;
17 }
18
19 namespace cc::slim {
20
21 // A layer that embeds content from another viz client.
22 class COMPONENT_EXPORT(CC_SLIM) SurfaceLayer : public Layer {
23  public:
24   static scoped_refptr<SurfaceLayer> Create();
25
26   const viz::SurfaceId& surface_id() const;
27
28   // Set the surface id that this layer is embedding. `deadline_policy`
29   // specifies behavior and timeout for how long to wait for the surface to be
30   // ready to draw before giving up.
31   void SetSurfaceId(const viz::SurfaceId& surface_id,
32                     const cc::DeadlinePolicy& deadline_policy);
33
34   // When stretch_content_to_fill_bounds is true, the scale of the embedded
35   // surface is ignored and the content will be stretched to fill the bounds.
36   void SetStretchContentToFillBounds(bool stretch_content_to_fill_bounds);
37   bool stretch_content_to_fill_bounds() const;
38
39   void SetMayContainVideo(bool may_contain_video);
40
41   // Set the oldest surface id that can be used as fallback assuming current
42   // surface being embedded isn't ready to be drawn yet (before first frame is
43   // submitted).
44   void SetOldestAcceptableFallback(const viz::SurfaceId& surface_id);
45   const absl::optional<viz::SurfaceId>& oldest_acceptable_fallback() const;
46
47   void SetLayerTree(LayerTree* layer_tree) override;
48
49  private:
50   explicit SurfaceLayer(scoped_refptr<cc::SurfaceLayer> cc_layer);
51   ~SurfaceLayer() override;
52
53   cc::SurfaceLayer* cc_layer() const;
54   void SetSurfaceRange(const viz::SurfaceRange& surface_range);
55
56   // Layer implementation.
57   void AppendQuads(viz::CompositorRenderPass& render_pass,
58                    FrameData& data,
59                    const gfx::Transform& transform_to_root,
60                    const gfx::Transform& transform_to_target,
61                    const gfx::Rect* clip_in_target,
62                    const gfx::Rect& visible_rect,
63                    float opacity) override;
64
65   bool stretch_content_to_fill_bounds_ = false;
66   viz::SurfaceRange surface_range_;
67   absl::optional<uint32_t> deadline_in_frames_;
68 };
69
70 }  // namespace cc::slim
71
72 #endif  // CC_SLIM_SURFACE_LAYER_H_