blob: 42c2bbf34e6b5d64b7ab521a941793c685a85fc5 [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_H_
6#define CC_LAYERS_SURFACE_LAYER_H_
7
avi02a4d172015-12-21 06:14:368#include "base/macros.h"
chrishtrac41ff92017-03-17 05:07:309#include "cc/cc_export.h"
[email protected]c1ae82942014-01-17 23:17:0410#include "cc/layers/layer.h"
Fady Samuel1a21156e2017-07-13 04:57:2911#include "components/viz/common/surfaces/surface_info.h"
Fady Samueldbd4b022017-07-14 02:06:4812#include "components/viz/common/surfaces/surface_reference_factory.h"
Fady Samuel926ed772017-09-19 00:51:5513#include "third_party/skia/include/core/SkColor.h"
tfarinaebe974f02015-01-03 04:25:3214#include "ui/gfx/geometry/size.h"
[email protected]c1ae82942014-01-17 23:17:0415
16namespace cc {
17
18// A layer that renders a surface referencing the output of another compositor
19// instance or client.
20class CC_EXPORT SurfaceLayer : public Layer {
21 public:
jbaumandbccae1ab2014-11-06 23:26:4422 static scoped_refptr<SurfaceLayer> Create(
Fady Samueldbd4b022017-07-14 02:06:4823 scoped_refptr<viz::SurfaceReferenceFactory> ref_factory);
[email protected]c1ae82942014-01-17 23:17:0424
Fady Samuel1a21156e2017-07-13 04:57:2925 void SetPrimarySurfaceInfo(const viz::SurfaceInfo& surface_info);
Fady Samuelb47442d2017-10-13 04:17:3426 void SetFallbackSurfaceId(const viz::SurfaceId& surface_id);
samanse8fd2e592017-01-10 00:23:1327
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]c1ae82942014-01-17 23:17:0431
Fady Samuel926ed772017-09-19 00:51:5532 // 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]c1ae82942014-01-17 23:17:0436 // Layer overrides.
danakj60bc3bc2016-04-09 00:24:4837 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
jbaumandbccae1ab2014-11-06 23:26:4438 void SetLayerTreeHost(LayerTreeHost* host) override;
dcheng716bedf2014-10-21 09:51:0839 void PushPropertiesTo(LayerImpl* layer) override;
[email protected]c1ae82942014-01-17 23:17:0440
Fady Samueldbd4b022017-07-14 02:06:4841 scoped_refptr<viz::SurfaceReferenceFactory> surface_reference_factory()
42 const {
samans72b2a282016-12-17 02:44:1543 return ref_factory_;
44 }
fsamuel1d3252c2017-02-15 20:56:3745
Fady Samuel1a21156e2017-07-13 04:57:2946 const viz::SurfaceInfo& primary_surface_info() const {
fsamuel1d3252c2017-02-15 20:56:3747 return primary_surface_info_;
48 }
49
Fady Samuelb47442d2017-10-13 04:17:3450 const viz::SurfaceId& fallback_surface_id() const {
51 return fallback_surface_id_;
fsamuel1d3252c2017-02-15 20:56:3752 }
domlaskowski4b33bfe2016-10-27 00:34:2253
[email protected]c1ae82942014-01-17 23:17:0454 protected:
Fady Samueldbd4b022017-07-14 02:06:4855 explicit SurfaceLayer(
56 scoped_refptr<viz::SurfaceReferenceFactory> ref_factory);
dcheng716bedf2014-10-21 09:51:0857 bool HasDrawableContent() const override;
[email protected]c1ae82942014-01-17 23:17:0458
59 private:
dcheng716bedf2014-10-21 09:51:0860 ~SurfaceLayer() override;
fsamuel1d3252c2017-02-15 20:56:3761 void RemoveReference(base::Closure reference_returner);
[email protected]c1ae82942014-01-17 23:17:0462
Fady Samuel1a21156e2017-07-13 04:57:2963 viz::SurfaceInfo primary_surface_info_;
Fady Samuelb47442d2017-10-13 04:17:3464 viz::SurfaceId fallback_surface_id_;
fsamuel1d3252c2017-02-15 20:56:3765 base::Closure fallback_reference_returner_;
66
Fady Samueldbd4b022017-07-14 02:06:4867 scoped_refptr<viz::SurfaceReferenceFactory> ref_factory_;
xlai5e87e712016-12-16 02:10:2568 bool stretch_content_to_fill_bounds_ = false;
Fady Samuel926ed772017-09-19 00:51:5569 SkColor default_background_color_ = SK_ColorWHITE;
[email protected]c1ae82942014-01-17 23:17:0470
71 DISALLOW_COPY_AND_ASSIGN(SurfaceLayer);
72};
73
74} // namespace cc
75
76#endif // CC_LAYERS_SURFACE_LAYER_H_