blob: 380e8b909c199b1a8f313d469a589f9c58af7640 [file] [log] [blame]
[email protected]c1ae82942014-01-17 23:17:041// 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
danakj60bc3bc2016-04-09 00:24:488#include <memory>
9
avi02a4d172015-12-21 06:14:3610#include "base/macros.h"
danakj60bc3bc2016-04-09 00:24:4811#include "base/memory/ptr_util.h"
chrishtrac41ff92017-03-17 05:07:3012#include "cc/cc_export.h"
[email protected]c1ae82942014-01-17 23:17:0413#include "cc/layers/layer_impl.h"
danakje5805be2017-09-15 19:24:5514#include "components/viz/common/quads/surface_draw_quad.h"
Fady Samuel644df1d2017-07-13 01:13:0215#include "components/viz/common/surfaces/surface_id.h"
Fady Samuel1a21156e2017-07-13 04:57:2916#include "components/viz/common/surfaces/surface_info.h"
[email protected]c1ae82942014-01-17 23:17:0417
18namespace cc {
19
20class CC_EXPORT SurfaceLayerImpl : public LayerImpl {
21 public:
danakj60bc3bc2016-04-09 00:24:4822 static std::unique_ptr<SurfaceLayerImpl> Create(LayerTreeImpl* tree_impl,
23 int id) {
24 return base::WrapUnique(new SurfaceLayerImpl(tree_impl, id));
[email protected]c1ae82942014-01-17 23:17:0425 }
dcheng716bedf2014-10-21 09:51:0826 ~SurfaceLayerImpl() override;
[email protected]c1ae82942014-01-17 23:17:0427
Fady Samuel4584abd2018-01-17 07:06:3728 void SetPrimarySurfaceId(const viz::SurfaceId& surface_id,
29 base::Optional<uint32_t> deadline_in_frames);
Fady Samuel1cc05222017-11-17 10:42:2630 const viz::SurfaceId& primary_surface_id() const {
31 return primary_surface_id_;
fsamuel1d3252c2017-02-15 20:56:3732 }
33
fsamuel3ca78632017-05-04 21:48:5334 // 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 Samuel926ed772017-09-19 00:51:5538 // enabled, then the primary and fallback surfaces will always match.
Fady Samuelb47442d2017-10-13 04:17:3439 void SetFallbackSurfaceId(const viz::SurfaceId& surface_id);
40 const viz::SurfaceId& fallback_surface_id() const {
41 return fallback_surface_id_;
fsamuel1d3252c2017-02-15 20:56:3742 }
43
Fady Samuel4584abd2018-01-17 07:06:3744 base::Optional<uint32_t> deadline_in_frames() const {
45 return deadline_in_frames_;
46 }
47
xlai5e87e712016-12-16 02:10:2548 void SetStretchContentToFillBounds(bool stretch_content);
Fady Samuel926ed772017-09-19 00:51:5549 bool stretch_content_to_fill_bounds() const {
50 return stretch_content_to_fill_bounds_;
51 }
52
[email protected]c1ae82942014-01-17 23:17:0453 // LayerImpl overrides.
danakj60bc3bc2016-04-09 00:24:4854 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
dcheng716bedf2014-10-21 09:51:0855 void PushPropertiesTo(LayerImpl* layer) override;
danakje5805be2017-09-15 19:24:5556 void AppendQuads(viz::RenderPass* render_pass,
dcheng716bedf2014-10-21 09:51:0857 AppendQuadsData* append_quads_data) override;
[email protected]c1ae82942014-01-17 23:17:0458
59 protected:
60 SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id);
61
62 private:
danakje5805be2017-09-15 19:24:5563 viz::SurfaceDrawQuad* CreateSurfaceDrawQuad(
64 viz::RenderPass* render_pass,
Fady Samuel1cc05222017-11-17 10:42:2665 const viz::SurfaceId& surface_id,
Fady Samuelb47442d2017-10-13 04:17:3466 const base::Optional<viz::SurfaceId>& fallback_surface_id);
fsamuel1d3252c2017-02-15 20:56:3767
dcheng716bedf2014-10-21 09:51:0868 void GetDebugBorderProperties(SkColor* color, float* width) const override;
danakje5805be2017-09-15 19:24:5569 void AppendRainbowDebugBorder(viz::RenderPass* render_pass);
ssid911e40e2015-02-09 17:55:2070 void AsValueInto(base::trace_event::TracedValue* dict) const override;
dcheng716bedf2014-10-21 09:51:0871 const char* LayerTypeAsString() const override;
[email protected]c1ae82942014-01-17 23:17:0472
Fady Samuel1cc05222017-11-17 10:42:2673 viz::SurfaceId primary_surface_id_;
Fady Samuelb47442d2017-10-13 04:17:3474 viz::SurfaceId fallback_surface_id_;
Fady Samuel4584abd2018-01-17 07:06:3775 base::Optional<uint32_t> deadline_in_frames_;
fsamuel1d3252c2017-02-15 20:56:3776
xlai5e87e712016-12-16 02:10:2577 bool stretch_content_to_fill_bounds_ = false;
[email protected]c1ae82942014-01-17 23:17:0478
79 DISALLOW_COPY_AND_ASSIGN(SurfaceLayerImpl);
80};
81
82} // namespace cc
83
84#endif // CC_LAYERS_SURFACE_LAYER_IMPL_H_