blob: 9f2838bfc995c68c581184e987095642232f3a23 [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"
[email protected]c1ae82942014-01-17 23:17:049#include "cc/base/cc_export.h"
10#include "cc/layers/layer.h"
[email protected]16a6af152014-06-13 04:20:1611#include "cc/surfaces/surface_id.h"
jbaumandbccae1ab2014-11-06 23:26:4412#include "cc/surfaces/surface_sequence.h"
tfarinaebe974f02015-01-03 04:25:3213#include "ui/gfx/geometry/size.h"
[email protected]c1ae82942014-01-17 23:17:0414
15namespace cc {
16
17// A layer that renders a surface referencing the output of another compositor
18// instance or client.
19class CC_EXPORT SurfaceLayer : public Layer {
20 public:
jbaumandbccae1ab2014-11-06 23:26:4421 // This callback is run when a SurfaceSequence needs to be satisfied, but
22 // the parent compositor is unable to. It can be called on either the main
23 // or impl threads.
xlai92e65342016-06-30 15:58:5724 using SatisfyCallback = base::Callback<void(const SurfaceSequence&)>;
jbaumandbccae1ab2014-11-06 23:26:4425
26 // This callback is run to require that a specific SurfaceSequence is
27 // received before a SurfaceId is destroyed.
xlai92e65342016-06-30 15:58:5728 using RequireCallback =
29 base::Callback<void(const SurfaceId&, const SurfaceSequence&)>;
jbaumandbccae1ab2014-11-06 23:26:4430
31 static scoped_refptr<SurfaceLayer> Create(
32 const SatisfyCallback& satisfy_callback,
33 const RequireCallback& require_callback);
[email protected]c1ae82942014-01-17 23:17:0434
xlai5e87e712016-12-16 02:10:2535 // When stretch_content_to_fill_bounds is true, scale is unused.
fsamuel278664272016-07-13 04:06:5936 void SetSurfaceId(const SurfaceId& surface_id,
37 float scale,
xlai5e87e712016-12-16 02:10:2538 const gfx::Size& size,
39 bool stretch_content_to_fill_bounds);
[email protected]c1ae82942014-01-17 23:17:0440
41 // Layer overrides.
danakj60bc3bc2016-04-09 00:24:4842 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
jbaumandbccae1ab2014-11-06 23:26:4443 void SetLayerTreeHost(LayerTreeHost* host) override;
dcheng716bedf2014-10-21 09:51:0844 void PushPropertiesTo(LayerImpl* layer) override;
[email protected]c1ae82942014-01-17 23:17:0445
domlaskowski4b33bfe2016-10-27 00:34:2246 SurfaceId surface_id() const { return surface_id_; }
47 const gfx::Size& surface_size() const { return surface_size_; }
48 float surface_scale() const { return surface_scale_; }
49
50 const SatisfyCallback& satisfy_callback() const { return satisfy_callback_; }
51 const RequireCallback& require_callback() const { return require_callback_; }
52
[email protected]c1ae82942014-01-17 23:17:0453 protected:
loyso0940d412016-03-14 01:30:3154 SurfaceLayer(const SatisfyCallback& satisfy_callback,
jbaumandbccae1ab2014-11-06 23:26:4455 const RequireCallback& require_callback);
dcheng716bedf2014-10-21 09:51:0856 bool HasDrawableContent() const override;
[email protected]c1ae82942014-01-17 23:17:0457
58 private:
dcheng716bedf2014-10-21 09:51:0859 ~SurfaceLayer() override;
jbaumandbccae1ab2014-11-06 23:26:4460 void CreateNewDestroySequence();
61 void SatisfyDestroySequence();
[email protected]c1ae82942014-01-17 23:17:0462
[email protected]16a6af152014-06-13 04:20:1663 SurfaceId surface_id_;
jbauman5a8f0ab2014-11-07 01:41:1664 gfx::Size surface_size_;
xlai5e87e712016-12-16 02:10:2565 float surface_scale_ = 1.f;
66 bool stretch_content_to_fill_bounds_ = false;
jbaumandbccae1ab2014-11-06 23:26:4467 SurfaceSequence destroy_sequence_;
68 SatisfyCallback satisfy_callback_;
69 RequireCallback require_callback_;
[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_