blob: 58679d31a656099fdb5ee0de36996cd7993e4503 [file] [log] [blame]
[email protected]c1ae82942014-01-17 23:17:041// Copyright 2014 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_LAYERS_SURFACE_LAYER_IMPL_H_
6#define CC_LAYERS_SURFACE_LAYER_IMPL_H_
7
danakj60bc3bc2016-04-09 00:24:488#include <memory>
9
CJ DiMeglio3f2ddfe62018-07-17 23:03:3710#include "base/bind.h"
danakj60bc3bc2016-04-09 00:24:4811#include "base/memory/ptr_util.h"
Vladimir Levin6abaaa8f2020-11-11 15:07:1612#include "base/synchronization/waitable_event.h"
chrishtrac41ff92017-03-17 05:07:3013#include "cc/cc_export.h"
[email protected]c1ae82942014-01-17 23:17:0414#include "cc/layers/layer_impl.h"
danakje5805be2017-09-15 19:24:5515#include "components/viz/common/quads/surface_draw_quad.h"
Fady Samuel644df1d2017-07-13 01:13:0216#include "components/viz/common/surfaces/surface_id.h"
Fady Samuel1a21156e2017-07-13 04:57:2917#include "components/viz/common/surfaces/surface_info.h"
Fady Samuel120c7e22018-07-20 05:19:2818#include "components/viz/common/surfaces/surface_range.h"
[email protected]c1ae82942014-01-17 23:17:0419
20namespace cc {
21
Vladimir Levin6abaaa8f2020-11-11 15:07:1622// This must match surface_layer.h's UpdateSubmissionStateCB.
23using UpdateSubmissionStateCB =
24 base::RepeatingCallback<void(bool is_visible, base::WaitableEvent*)>;
CJ DiMeglio3f2ddfe62018-07-17 23:03:3725
[email protected]c1ae82942014-01-17 23:17:0426class CC_EXPORT SurfaceLayerImpl : public LayerImpl {
27 public:
CJ DiMeglio3f2ddfe62018-07-17 23:03:3728 static std::unique_ptr<SurfaceLayerImpl> Create(
29 LayerTreeImpl* tree_impl,
30 int id,
Vladimir Levin6abaaa8f2020-11-11 15:07:1631 UpdateSubmissionStateCB update_submission_state_callback);
CJ DiMeglio3f2ddfe62018-07-17 23:03:3732
danakj60bc3bc2016-04-09 00:24:4833 static std::unique_ptr<SurfaceLayerImpl> Create(LayerTreeImpl* tree_impl,
Vladimir Levin6abaaa8f2020-11-11 15:07:1634 int id);
CJ DiMeglio3f2ddfe62018-07-17 23:03:3735
Vladimir Levinf06d1cd72019-03-13 18:24:1036 SurfaceLayerImpl(const SurfaceLayerImpl&) = delete;
dcheng716bedf2014-10-21 09:51:0837 ~SurfaceLayerImpl() override;
[email protected]c1ae82942014-01-17 23:17:0438
Vladimir Levinf06d1cd72019-03-13 18:24:1039 SurfaceLayerImpl& operator=(const SurfaceLayerImpl&) = delete;
40
Fady Samuel120c7e22018-07-20 05:19:2841 void SetRange(const viz::SurfaceRange& surface_range,
Anton Bikineev1b060a72021-05-14 23:15:3442 absl::optional<uint32_t> deadline_in_frames);
Fady Samuel120c7e22018-07-20 05:19:2843 const viz::SurfaceRange& range() const { return surface_range_; }
fsamuel1d3252c2017-02-15 20:56:3744
Anton Bikineev1b060a72021-05-14 23:15:3445 absl::optional<uint32_t> deadline_in_frames() const {
Fady Samuel4584abd2018-01-17 07:06:3746 return deadline_in_frames_;
47 }
48
xlai5e87e712016-12-16 02:10:2549 void SetStretchContentToFillBounds(bool stretch_content);
Fady Samuel926ed772017-09-19 00:51:5550 bool stretch_content_to_fill_bounds() const {
51 return stretch_content_to_fill_bounds_;
52 }
53
sunxd2869c922018-05-14 20:48:3254 void SetSurfaceHitTestable(bool surface_hit_testable);
Xianda Sun77632a542019-03-26 17:30:3955 bool surface_hit_testable() const { return surface_hit_testable_; }
sunxdc02c05982018-09-12 18:27:2256
57 void SetHasPointerEventsNone(bool has_pointer_events_none);
58 bool has_pointer_events_none() const { return has_pointer_events_none_; }
sunxd26e9bae2018-03-22 19:32:3359
kylechar5f6f0ac2019-05-28 00:58:3060 void SetIsReflection(bool is_reflection);
61 bool is_reflection() const { return is_reflection_; }
62
[email protected]c1ae82942014-01-17 23:17:0463 // LayerImpl overrides.
danakj60bc3bc2016-04-09 00:24:4864 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
dcheng716bedf2014-10-21 09:51:0865 void PushPropertiesTo(LayerImpl* layer) override;
CJ DiMeglio3f2ddfe62018-07-17 23:03:3766 bool WillDraw(DrawMode draw_mode,
67 viz::ClientResourceProvider* resource_provider) override;
Vladimir Levin4f331b422020-08-31 18:38:4768 void AppendQuads(viz::CompositorRenderPass* render_pass,
dcheng716bedf2014-10-21 09:51:0869 AppendQuadsData* append_quads_data) override;
sunxd26e9bae2018-03-22 19:32:3370 bool is_surface_layer() const override;
Mitsuru Oshima60cab6e2021-04-20 03:36:3771 gfx::Rect GetEnclosingVisibleRectInTargetSpace() const override;
[email protected]c1ae82942014-01-17 23:17:0472
73 protected:
CJ DiMeglio3f2ddfe62018-07-17 23:03:3774 SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id, UpdateSubmissionStateCB);
[email protected]c1ae82942014-01-17 23:17:0475
76 private:
dcheng716bedf2014-10-21 09:51:0877 void GetDebugBorderProperties(SkColor* color, float* width) const override;
Vladimir Levin4f331b422020-08-31 18:38:4778 void AppendRainbowDebugBorder(viz::CompositorRenderPass* render_pass);
ssid911e40e2015-02-09 17:55:2079 void AsValueInto(base::trace_event::TracedValue* dict) const override;
dcheng716bedf2014-10-21 09:51:0880 const char* LayerTypeAsString() const override;
[email protected]c1ae82942014-01-17 23:17:0481
CJ DiMeglio3f2ddfe62018-07-17 23:03:3782 UpdateSubmissionStateCB update_submission_state_callback_;
Fady Samuel120c7e22018-07-20 05:19:2883 viz::SurfaceRange surface_range_;
Anton Bikineev1b060a72021-05-14 23:15:3484 absl::optional<uint32_t> deadline_in_frames_;
fsamuel1d3252c2017-02-15 20:56:3785
xlai5e87e712016-12-16 02:10:2586 bool stretch_content_to_fill_bounds_ = false;
sunxd2869c922018-05-14 20:48:3287 bool surface_hit_testable_ = false;
sunxdc02c05982018-09-12 18:27:2288 bool has_pointer_events_none_ = false;
kylechar5f6f0ac2019-05-28 00:58:3089 bool is_reflection_ = false;
CJ DiMeglio3f2ddfe62018-07-17 23:03:3790 bool will_draw_ = false;
[email protected]c1ae82942014-01-17 23:17:0491};
92
93} // namespace cc
94
95#endif // CC_LAYERS_SURFACE_LAYER_IMPL_H_