[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 1 | // 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 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 10 | #include "base/bind.h" |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 11 | #include "base/memory/ptr_util.h" |
Vladimir Levin | 6abaaa8f | 2020-11-11 15:07:16 | [diff] [blame] | 12 | #include "base/synchronization/waitable_event.h" |
chrishtr | ac41ff9 | 2017-03-17 05:07:30 | [diff] [blame] | 13 | #include "cc/cc_export.h" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 14 | #include "cc/layers/layer_impl.h" |
danakj | e5805be | 2017-09-15 19:24:55 | [diff] [blame] | 15 | #include "components/viz/common/quads/surface_draw_quad.h" |
Fady Samuel | 644df1d | 2017-07-13 01:13:02 | [diff] [blame] | 16 | #include "components/viz/common/surfaces/surface_id.h" |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 17 | #include "components/viz/common/surfaces/surface_info.h" |
Fady Samuel | 120c7e2 | 2018-07-20 05:19:28 | [diff] [blame] | 18 | #include "components/viz/common/surfaces/surface_range.h" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 19 | |
| 20 | namespace cc { |
| 21 | |
Vladimir Levin | 6abaaa8f | 2020-11-11 15:07:16 | [diff] [blame] | 22 | // This must match surface_layer.h's UpdateSubmissionStateCB. |
| 23 | using UpdateSubmissionStateCB = |
| 24 | base::RepeatingCallback<void(bool is_visible, base::WaitableEvent*)>; |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 25 | |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 26 | class CC_EXPORT SurfaceLayerImpl : public LayerImpl { |
| 27 | public: |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 28 | static std::unique_ptr<SurfaceLayerImpl> Create( |
| 29 | LayerTreeImpl* tree_impl, |
| 30 | int id, |
Vladimir Levin | 6abaaa8f | 2020-11-11 15:07:16 | [diff] [blame] | 31 | UpdateSubmissionStateCB update_submission_state_callback); |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 32 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 33 | static std::unique_ptr<SurfaceLayerImpl> Create(LayerTreeImpl* tree_impl, |
Vladimir Levin | 6abaaa8f | 2020-11-11 15:07:16 | [diff] [blame] | 34 | int id); |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 35 | |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 36 | SurfaceLayerImpl(const SurfaceLayerImpl&) = delete; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 37 | ~SurfaceLayerImpl() override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 38 | |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 39 | SurfaceLayerImpl& operator=(const SurfaceLayerImpl&) = delete; |
| 40 | |
Fady Samuel | 120c7e2 | 2018-07-20 05:19:28 | [diff] [blame] | 41 | void SetRange(const viz::SurfaceRange& surface_range, |
| 42 | base::Optional<uint32_t> deadline_in_frames); |
| 43 | const viz::SurfaceRange& range() const { return surface_range_; } |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 44 | |
Fady Samuel | 4584abd | 2018-01-17 07:06:37 | [diff] [blame] | 45 | base::Optional<uint32_t> deadline_in_frames() const { |
| 46 | return deadline_in_frames_; |
| 47 | } |
| 48 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 49 | void SetStretchContentToFillBounds(bool stretch_content); |
Fady Samuel | 926ed77 | 2017-09-19 00:51:55 | [diff] [blame] | 50 | bool stretch_content_to_fill_bounds() const { |
| 51 | return stretch_content_to_fill_bounds_; |
| 52 | } |
| 53 | |
sunxd | 2869c92 | 2018-05-14 20:48:32 | [diff] [blame] | 54 | void SetSurfaceHitTestable(bool surface_hit_testable); |
Xianda Sun | 77632a54 | 2019-03-26 17:30:39 | [diff] [blame] | 55 | bool surface_hit_testable() const { return surface_hit_testable_; } |
sunxd | c02c0598 | 2018-09-12 18:27:22 | [diff] [blame] | 56 | |
| 57 | void SetHasPointerEventsNone(bool has_pointer_events_none); |
| 58 | bool has_pointer_events_none() const { return has_pointer_events_none_; } |
sunxd | 26e9bae | 2018-03-22 19:32:33 | [diff] [blame] | 59 | |
kylechar | 5f6f0ac | 2019-05-28 00:58:30 | [diff] [blame] | 60 | void SetIsReflection(bool is_reflection); |
| 61 | bool is_reflection() const { return is_reflection_; } |
| 62 | |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 63 | // LayerImpl overrides. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 64 | std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 65 | void PushPropertiesTo(LayerImpl* layer) override; |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 66 | bool WillDraw(DrawMode draw_mode, |
| 67 | viz::ClientResourceProvider* resource_provider) override; |
Vladimir Levin | 4f331b42 | 2020-08-31 18:38:47 | [diff] [blame] | 68 | void AppendQuads(viz::CompositorRenderPass* render_pass, |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 69 | AppendQuadsData* append_quads_data) override; |
sunxd | 26e9bae | 2018-03-22 19:32:33 | [diff] [blame] | 70 | bool is_surface_layer() const override; |
Mitsuru Oshima | 60cab6e | 2021-04-20 03:36:37 | [diff] [blame^] | 71 | gfx::Rect GetEnclosingVisibleRectInTargetSpace() const override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 72 | |
| 73 | protected: |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 74 | SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id, UpdateSubmissionStateCB); |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 75 | |
| 76 | private: |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 77 | void GetDebugBorderProperties(SkColor* color, float* width) const override; |
Vladimir Levin | 4f331b42 | 2020-08-31 18:38:47 | [diff] [blame] | 78 | void AppendRainbowDebugBorder(viz::CompositorRenderPass* render_pass); |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 79 | void AsValueInto(base::trace_event::TracedValue* dict) const override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 80 | const char* LayerTypeAsString() const override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 81 | |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 82 | UpdateSubmissionStateCB update_submission_state_callback_; |
Fady Samuel | 120c7e2 | 2018-07-20 05:19:28 | [diff] [blame] | 83 | viz::SurfaceRange surface_range_; |
Fady Samuel | 4584abd | 2018-01-17 07:06:37 | [diff] [blame] | 84 | base::Optional<uint32_t> deadline_in_frames_; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 85 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 86 | bool stretch_content_to_fill_bounds_ = false; |
sunxd | 2869c92 | 2018-05-14 20:48:32 | [diff] [blame] | 87 | bool surface_hit_testable_ = false; |
sunxd | c02c0598 | 2018-09-12 18:27:22 | [diff] [blame] | 88 | bool has_pointer_events_none_ = false; |
kylechar | 5f6f0ac | 2019-05-28 00:58:30 | [diff] [blame] | 89 | bool is_reflection_ = false; |
CJ DiMeglio | 3f2ddfe6 | 2018-07-17 23:03:37 | [diff] [blame] | 90 | bool will_draw_ = false; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace cc |
| 94 | |
| 95 | #endif // CC_LAYERS_SURFACE_LAYER_IMPL_H_ |