[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" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 10 | #include "cc/layers/layer.h" |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 11 | #include "components/viz/common/surfaces/surface_info.h" |
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 12 | #include "components/viz/common/surfaces/surface_reference_factory.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: | ||||
jbauman | dbccae1ab | 2014-11-06 23:26:44 | [diff] [blame] | 22 | static scoped_refptr<SurfaceLayer> Create( |
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 23 | scoped_refptr<viz::SurfaceReferenceFactory> ref_factory); |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 24 | |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 25 | void SetPrimarySurfaceInfo(const viz::SurfaceInfo& surface_info); |
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); | ||||
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 31 | |
Fady Samuel | 926ed77 | 2017-09-19 00:51:55 | [diff] [blame] | 32 | // Specifies the |background_color| to use when a primary surface is |
33 | // specified, and a fallback surface is unavailable. | ||||
34 | void SetDefaultBackgroundColor(SkColor background_color); | ||||
35 | |||||
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 36 | // Layer overrides. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 37 | std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
jbauman | dbccae1ab | 2014-11-06 23:26:44 | [diff] [blame] | 38 | void SetLayerTreeHost(LayerTreeHost* host) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 39 | void PushPropertiesTo(LayerImpl* layer) override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 40 | |
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 41 | scoped_refptr<viz::SurfaceReferenceFactory> surface_reference_factory() |
42 | const { | ||||
samans | 72b2a28 | 2016-12-17 02:44:15 | [diff] [blame] | 43 | return ref_factory_; |
44 | } | ||||
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 45 | |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 46 | const viz::SurfaceInfo& primary_surface_info() const { |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 47 | return primary_surface_info_; |
48 | } | ||||
49 | |||||
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame^] | 50 | const viz::SurfaceId& fallback_surface_id() const { |
51 | return fallback_surface_id_; | ||||
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 52 | } |
domlaskowski | 4b33bfe | 2016-10-27 00:34:22 | [diff] [blame] | 53 | |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 54 | protected: |
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 55 | explicit SurfaceLayer( |
56 | scoped_refptr<viz::SurfaceReferenceFactory> ref_factory); | ||||
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; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 61 | void RemoveReference(base::Closure reference_returner); |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 62 | |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 63 | viz::SurfaceInfo primary_surface_info_; |
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame^] | 64 | viz::SurfaceId fallback_surface_id_; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 65 | base::Closure fallback_reference_returner_; |
66 | |||||
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 67 | scoped_refptr<viz::SurfaceReferenceFactory> ref_factory_; |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 68 | bool stretch_content_to_fill_bounds_ = false; |
Fady Samuel | 926ed77 | 2017-09-19 00:51:55 | [diff] [blame] | 69 | SkColor default_background_color_ = SK_ColorWHITE; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 70 | |
71 | DISALLOW_COPY_AND_ASSIGN(SurfaceLayer); | ||||
72 | }; | ||||
73 | |||||
74 | } // namespace cc | ||||
75 | |||||
76 | #endif // CC_LAYERS_SURFACE_LAYER_H_ |