[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" |
danakj | e5805be | 2017-09-15 19:24:55 | [diff] [blame] | 14 | #include "components/viz/common/quads/surface_draw_quad.h" |
Fady Samuel | 644df1d | 2017-07-13 01:13:02 | [diff] [blame] | 15 | #include "components/viz/common/surfaces/surface_id.h" |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 16 | #include "components/viz/common/surfaces/surface_info.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 | |
Fady Samuel | 4584abd | 2018-01-17 07:06:37 | [diff] [blame^] | 28 | void SetPrimarySurfaceId(const viz::SurfaceId& surface_id, |
| 29 | base::Optional<uint32_t> deadline_in_frames); |
Fady Samuel | 1cc0522 | 2017-11-17 10:42:26 | [diff] [blame] | 30 | const viz::SurfaceId& primary_surface_id() const { |
| 31 | return primary_surface_id_; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 32 | } |
| 33 | |
fsamuel | 3ca7863 | 2017-05-04 21:48:53 | [diff] [blame] | 34 | // A fallback Surface is a Surface that is already known to exist in the |
| 35 | // display compositor. If surface synchronization is enabled, the display |
| 36 | // compositor will use the fallback if the primary surface is unavailable |
| 37 | // at the time of surface aggregation. If surface synchronization is not |
Fady Samuel | 926ed77 | 2017-09-19 00:51:55 | [diff] [blame] | 38 | // enabled, then the primary and fallback surfaces will always match. |
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame] | 39 | void SetFallbackSurfaceId(const viz::SurfaceId& surface_id); |
| 40 | const viz::SurfaceId& fallback_surface_id() const { |
| 41 | return fallback_surface_id_; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 42 | } |
| 43 | |
Fady Samuel | 4584abd | 2018-01-17 07:06:37 | [diff] [blame^] | 44 | base::Optional<uint32_t> deadline_in_frames() const { |
| 45 | return deadline_in_frames_; |
| 46 | } |
| 47 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 48 | void SetStretchContentToFillBounds(bool stretch_content); |
Fady Samuel | 926ed77 | 2017-09-19 00:51:55 | [diff] [blame] | 49 | bool stretch_content_to_fill_bounds() const { |
| 50 | return stretch_content_to_fill_bounds_; |
| 51 | } |
| 52 | |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 53 | // LayerImpl overrides. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 54 | std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 55 | void PushPropertiesTo(LayerImpl* layer) override; |
danakj | e5805be | 2017-09-15 19:24:55 | [diff] [blame] | 56 | void AppendQuads(viz::RenderPass* render_pass, |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 57 | AppendQuadsData* append_quads_data) override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 58 | |
| 59 | protected: |
| 60 | SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id); |
| 61 | |
| 62 | private: |
danakj | e5805be | 2017-09-15 19:24:55 | [diff] [blame] | 63 | viz::SurfaceDrawQuad* CreateSurfaceDrawQuad( |
| 64 | viz::RenderPass* render_pass, |
Fady Samuel | 1cc0522 | 2017-11-17 10:42:26 | [diff] [blame] | 65 | const viz::SurfaceId& surface_id, |
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame] | 66 | const base::Optional<viz::SurfaceId>& fallback_surface_id); |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 67 | |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 68 | void GetDebugBorderProperties(SkColor* color, float* width) const override; |
danakj | e5805be | 2017-09-15 19:24:55 | [diff] [blame] | 69 | void AppendRainbowDebugBorder(viz::RenderPass* render_pass); |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 70 | void AsValueInto(base::trace_event::TracedValue* dict) const override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 71 | const char* LayerTypeAsString() const override; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 72 | |
Fady Samuel | 1cc0522 | 2017-11-17 10:42:26 | [diff] [blame] | 73 | viz::SurfaceId primary_surface_id_; |
Fady Samuel | b47442d | 2017-10-13 04:17:34 | [diff] [blame] | 74 | viz::SurfaceId fallback_surface_id_; |
Fady Samuel | 4584abd | 2018-01-17 07:06:37 | [diff] [blame^] | 75 | base::Optional<uint32_t> deadline_in_frames_; |
fsamuel | 1d3252c | 2017-02-15 20:56:37 | [diff] [blame] | 76 | |
xlai | 5e87e71 | 2016-12-16 02:10:25 | [diff] [blame] | 77 | bool stretch_content_to_fill_bounds_ = false; |
[email protected] | c1ae8294 | 2014-01-17 23:17:04 | [diff] [blame] | 78 | |
| 79 | DISALLOW_COPY_AND_ASSIGN(SurfaceLayerImpl); |
| 80 | }; |
| 81 | |
| 82 | } // namespace cc |
| 83 | |
| 84 | #endif // CC_LAYERS_SURFACE_LAYER_IMPL_H_ |