[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_H_ | ||||
6 | #define CC_LAYERS_SURFACE_LAYER_H_ | ||||
7 | |||||
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 8 | #include "base/macros.h" |
chrishtr | ac41ff9 | 2017-03-17 05:07:30 | [diff] [blame] | 9 | #include "cc/cc_export.h" |
Fady Samuel | b46e0ef | 2018-01-30 04:48:41 | [diff] [blame] | 10 | #include "cc/layers/deadline_policy.h" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 11 | #include "cc/layers/layer.h" |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 12 | #include "components/viz/common/surfaces/surface_info.h" |
Fady Samuel | 926ed77 | 2017-09-19 00:51:55 | [diff] [blame] | 13 | #include "third_party/skia/include/core/SkColor.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 14 | #include "ui/gfx/geometry/size.h" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 15 | |
16 | namespace cc { | ||||
17 | |||||
18 | // A layer that renders a surface referencing the output of another compositor | ||||
19 | // instance or client. | ||||
20 | class CC_EXPORT SurfaceLayer : public Layer { | ||||
21 | public: | ||||
kylechar | ee539faa0 | 2018-01-22 17:00:55 | [diff] [blame] | 22 | static scoped_refptr<SurfaceLayer> Create(); |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 23 | |
Fady Samuel | 4584abd | 2018-01-17 07:06:37 | [diff] [blame] | 24 | void SetPrimarySurfaceId(const viz::SurfaceId& surface_id, |
Fady Samuel | b46e0ef | 2018-01-30 04:48:41 | [diff] [blame] | 25 | const DeadlinePolicy& deadline_policy); |
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame] | 26 | void SetFallbackSurfaceId(const viz::SurfaceId& surface_id); |
samans | e8fd2e59 | 2017-01-10 00:23:13 | [diff] [blame] | 27 | |
28 | // When stretch_content_to_fill_bounds is true, the scale of the embedded | ||||
29 | // surface is ignored and the content will be stretched to fill the bounds. | ||||
30 | void SetStretchContentToFillBounds(bool stretch_content_to_fill_bounds); | ||||
Jennifer Apacible | ea38ede | 2018-03-15 02:41:55 | [diff] [blame] | 31 | bool stretch_content_to_fill_bounds() const { |
32 | return stretch_content_to_fill_bounds_; | ||||
33 | } | ||||
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 34 | |
sunxd | 26e9bae | 2018-03-22 19:32:33 | [diff] [blame] | 35 | void SetHitTestable(bool hit_testable); |
36 | bool hit_testable() const { return hit_testable_; } | ||||
37 | |||||
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 38 | // Layer overrides. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 39 | std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
jbauman | dbccae1ab | 2014-11-06 23:26:44 | [diff] [blame] | 40 | void SetLayerTreeHost(LayerTreeHost* host) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 41 | void PushPropertiesTo(LayerImpl* layer) override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 42 | |
Fady Samuel | 1cc0522 | 2017-11-17 10:42:26 | [diff] [blame] | 43 | const viz::SurfaceId& primary_surface_id() const { |
44 | return primary_surface_id_; | ||||
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 45 | } |
46 | |||||
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame] | 47 | const viz::SurfaceId& fallback_surface_id() const { |
48 | return fallback_surface_id_; | ||||
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 49 | } |
domlaskowski | 4b33bfe | 2016-10-27 00:34:22 | [diff] [blame] | 50 | |
Fady Samuel | b46e0ef | 2018-01-30 04:48:41 | [diff] [blame] | 51 | base::Optional<uint32_t> deadline_in_frames() const { |
52 | return deadline_in_frames_; | ||||
53 | } | ||||
54 | |||||
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 55 | protected: |
kylechar | ee539faa0 | 2018-01-22 17:00:55 | [diff] [blame] | 56 | SurfaceLayer(); |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 57 | bool HasDrawableContent() const override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 58 | |
59 | private: | ||||
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 60 | ~SurfaceLayer() override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 61 | |
Fady Samuel | 1cc0522 | 2017-11-17 10:42:26 | [diff] [blame] | 62 | viz::SurfaceId primary_surface_id_; |
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame] | 63 | viz::SurfaceId fallback_surface_id_; |
Fady Samuel | 875ccf44 | 2018-02-13 18:30:22 | [diff] [blame] | 64 | base::Optional<uint32_t> deadline_in_frames_ = 0u; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 65 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 66 | bool stretch_content_to_fill_bounds_ = false; |
sunxd | 26e9bae | 2018-03-22 19:32:33 | [diff] [blame] | 67 | bool hit_testable_ = false; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 68 | |
69 | DISALLOW_COPY_AND_ASSIGN(SurfaceLayer); | ||||
70 | }; | ||||
71 | |||||
72 | } // namespace cc | ||||
73 | |||||
74 | #endif // CC_LAYERS_SURFACE_LAYER_H_ |