blob: 3ed0b9ad1403f2228d90ad3e07c035e6753b38f3 [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"
Fady Samuelb46e0ef2018-01-30 04:48:4110#include "cc/layers/deadline_policy.h"
[email protected]c1ae82942014-01-17 23:17:0411#include "cc/layers/layer.h"
Fady Samuel1a21156e2017-07-13 04:57:2912#include "components/viz/common/surfaces/surface_info.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:
kylecharee539faa02018-01-22 17:00:5522 static scoped_refptr<SurfaceLayer> Create();
[email protected]c1ae82942014-01-17 23:17:0423
Fady Samuel4584abd2018-01-17 07:06:3724 void SetPrimarySurfaceId(const viz::SurfaceId& surface_id,
Fady Samuelb46e0ef2018-01-30 04:48:4125 const DeadlinePolicy& deadline_policy);
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);
Jennifer Apacibleea38ede2018-03-15 02:41:5531 bool stretch_content_to_fill_bounds() const {
32 return stretch_content_to_fill_bounds_;
33 }
[email protected]c1ae82942014-01-17 23:17:0434
sunxd26e9bae2018-03-22 19:32:3335 void SetHitTestable(bool hit_testable);
36 bool hit_testable() const { return hit_testable_; }
37
[email protected]c1ae82942014-01-17 23:17:0438 // Layer overrides.
danakj60bc3bc2016-04-09 00:24:4839 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
jbaumandbccae1ab2014-11-06 23:26:4440 void SetLayerTreeHost(LayerTreeHost* host) override;
dcheng716bedf2014-10-21 09:51:0841 void PushPropertiesTo(LayerImpl* layer) override;
[email protected]c1ae82942014-01-17 23:17:0442
Fady Samuel1cc05222017-11-17 10:42:2643 const viz::SurfaceId& primary_surface_id() const {
44 return primary_surface_id_;
fsamuel1d3252c2017-02-15 20:56:3745 }
46
Fady Samuelb47442d2017-10-13 04:17:3447 const viz::SurfaceId& fallback_surface_id() const {
48 return fallback_surface_id_;
fsamuel1d3252c2017-02-15 20:56:3749 }
domlaskowski4b33bfe2016-10-27 00:34:2250
Fady Samuelb46e0ef2018-01-30 04:48:4151 base::Optional<uint32_t> deadline_in_frames() const {
52 return deadline_in_frames_;
53 }
54
[email protected]c1ae82942014-01-17 23:17:0455 protected:
kylecharee539faa02018-01-22 17:00:5556 SurfaceLayer();
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;
[email protected]c1ae82942014-01-17 23:17:0461
Fady Samuel1cc05222017-11-17 10:42:2662 viz::SurfaceId primary_surface_id_;
Fady Samuelb47442d2017-10-13 04:17:3463 viz::SurfaceId fallback_surface_id_;
Fady Samuel875ccf442018-02-13 18:30:2264 base::Optional<uint32_t> deadline_in_frames_ = 0u;
fsamuel1d3252c2017-02-15 20:56:3765
xlai5e87e712016-12-16 02:10:2566 bool stretch_content_to_fill_bounds_ = false;
sunxd26e9bae2018-03-22 19:32:3367 bool hit_testable_ = false;
[email protected]c1ae82942014-01-17 23:17:0468
69 DISALLOW_COPY_AND_ASSIGN(SurfaceLayer);
70};
71
72} // namespace cc
73
74#endif // CC_LAYERS_SURFACE_LAYER_H_