[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 | |
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 10 | #include "base/macros.h" |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 11 | #include "base/memory/ptr_util.h" |
chrishtr | ac41ff9 | 2017-03-17 05:07:30 | [diff] [blame] | 12 | #include "cc/cc_export.h" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 13 | #include "cc/layers/layer_impl.h" |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 14 | #include "cc/quads/surface_draw_quad.h" |
samans | 72b2a28 | 2016-12-17 02:44:15 | [diff] [blame] | 15 | #include "cc/surfaces/surface_info.h" |
Fady Samuel | 644df1d | 2017-07-13 01:13:02 | [diff] [blame^] | 16 | #include "components/viz/common/surfaces/surface_id.h" |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 17 | |
| 18 | namespace cc { |
| 19 | |
| 20 | class CC_EXPORT SurfaceLayerImpl : public LayerImpl { |
| 21 | public: |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 22 | static std::unique_ptr<SurfaceLayerImpl> Create(LayerTreeImpl* tree_impl, |
| 23 | int id) { |
| 24 | return base::WrapUnique(new SurfaceLayerImpl(tree_impl, id)); |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 25 | } |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 26 | ~SurfaceLayerImpl() override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 27 | |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 28 | void SetPrimarySurfaceInfo(const SurfaceInfo& surface_info); |
| 29 | const SurfaceInfo& primary_surface_info() const { |
| 30 | return primary_surface_info_; |
| 31 | } |
| 32 | |
fsamuel | 3ca7863 | 2017-05-04 21:48:53 | [diff] [blame] | 33 | // A fallback Surface is a Surface that is already known to exist in the |
| 34 | // display compositor. If surface synchronization is enabled, the display |
| 35 | // compositor will use the fallback if the primary surface is unavailable |
| 36 | // at the time of surface aggregation. If surface synchronization is not |
| 37 | // enabled, then a fallback surface will not be specified. |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 38 | void SetFallbackSurfaceInfo(const SurfaceInfo& surface_info); |
| 39 | const SurfaceInfo& fallback_surface_info() const { |
| 40 | return fallback_surface_info_; |
| 41 | } |
| 42 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 43 | void SetStretchContentToFillBounds(bool stretch_content); |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 44 | |
| 45 | // LayerImpl overrides. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 46 | std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 47 | void PushPropertiesTo(LayerImpl* layer) override; |
| 48 | void AppendQuads(RenderPass* render_pass, |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 49 | AppendQuadsData* append_quads_data) override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 50 | |
| 51 | protected: |
| 52 | SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id); |
| 53 | |
| 54 | private: |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 55 | SurfaceDrawQuad* CreateSurfaceDrawQuad( |
| 56 | RenderPass* render_pass, |
| 57 | SurfaceDrawQuadType surface_draw_quad_type, |
fsamuel | a4f81d1f | 2017-04-07 18:32:38 | [diff] [blame] | 58 | const SurfaceInfo& surface_info, |
fsamuel | 9499e18 | 2017-05-04 15:12:29 | [diff] [blame] | 59 | SharedQuadState** common_shared_quad_state); |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 60 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 61 | void GetDebugBorderProperties(SkColor* color, float* width) const override; |
danakj | ddf4126 | 2015-08-26 01:09:07 | [diff] [blame] | 62 | void AppendRainbowDebugBorder(RenderPass* render_pass); |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 63 | void AsValueInto(base::trace_event::TracedValue* dict) const override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 64 | const char* LayerTypeAsString() const override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 65 | |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 66 | SurfaceInfo primary_surface_info_; |
| 67 | SurfaceInfo fallback_surface_info_; |
| 68 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 69 | bool stretch_content_to_fill_bounds_ = false; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 70 | |
| 71 | DISALLOW_COPY_AND_ASSIGN(SurfaceLayerImpl); |
| 72 | }; |
| 73 | |
| 74 | } // namespace cc |
| 75 | |
| 76 | #endif // CC_LAYERS_SURFACE_LAYER_IMPL_H_ |