| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_LAYERS_SURFACE_LAYER_H_ | 5 #ifndef CC_LAYERS_SURFACE_LAYER_H_ |
| 6 #define CC_LAYERS_SURFACE_LAYER_H_ | 6 #define CC_LAYERS_SURFACE_LAYER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| 11 #include "cc/surfaces/surface_id.h" | 11 #include "cc/surfaces/surface_id.h" |
| 12 #include "cc/surfaces/surface_info.h" |
| 13 #include "cc/surfaces/surface_reference_base.h" |
| 14 #include "cc/surfaces/surface_reference_factory.h" |
| 12 #include "cc/surfaces/surface_sequence.h" | 15 #include "cc/surfaces/surface_sequence.h" |
| 13 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 14 | 17 |
| 15 namespace cc { | 18 namespace cc { |
| 16 | 19 |
| 17 // A layer that renders a surface referencing the output of another compositor | 20 // A layer that renders a surface referencing the output of another compositor |
| 18 // instance or client. | 21 // instance or client. |
| 19 class CC_EXPORT SurfaceLayer : public Layer { | 22 class CC_EXPORT SurfaceLayer : public Layer { |
| 20 public: | 23 public: |
| 21 // 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. | |
| 24 using SatisfyCallback = base::Callback<void(const SurfaceSequence&)>; | |
| 25 | |
| 26 // This callback is run to require that a specific SurfaceSequence is | |
| 27 // received before a SurfaceId is destroyed. | |
| 28 using RequireCallback = | |
| 29 base::Callback<void(const SurfaceId&, const SurfaceSequence&)>; | |
| 30 | |
| 31 static scoped_refptr<SurfaceLayer> Create( | 24 static scoped_refptr<SurfaceLayer> Create( |
| 32 const SatisfyCallback& satisfy_callback, | 25 scoped_refptr<SurfaceReferenceFactory> ref_factory); |
| 33 const RequireCallback& require_callback); | |
| 34 | 26 |
| 35 // When stretch_content_to_fill_bounds is true, scale is unused. | 27 // When stretch_content_to_fill_bounds is true, scale is unused. |
| 36 void SetSurfaceId(const SurfaceId& surface_id, | 28 void SetSurfaceInfo(const SurfaceInfo& surface_info, |
| 37 float scale, | 29 bool stretch_content_to_fill_bounds); |
| 38 const gfx::Size& size, | |
| 39 bool stretch_content_to_fill_bounds); | |
| 40 | 30 |
| 41 // Layer overrides. | 31 // Layer overrides. |
| 42 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 32 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
| 43 void SetLayerTreeHost(LayerTreeHost* host) override; | 33 void SetLayerTreeHost(LayerTreeHost* host) override; |
| 44 void PushPropertiesTo(LayerImpl* layer) override; | 34 void PushPropertiesTo(LayerImpl* layer) override; |
| 45 | 35 |
| 46 SurfaceId surface_id() const { return surface_id_; } | 36 scoped_refptr<SurfaceReferenceFactory> surface_reference_factory() const { |
| 47 const gfx::Size& surface_size() const { return surface_size_; } | 37 return ref_factory_; |
| 48 float surface_scale() const { return surface_scale_; } | 38 } |
| 49 | 39 const SurfaceInfo& surface_info() const { return surface_info_; } |
| 50 const SatisfyCallback& satisfy_callback() const { return satisfy_callback_; } | |
| 51 const RequireCallback& require_callback() const { return require_callback_; } | |
| 52 | 40 |
| 53 protected: | 41 protected: |
| 54 SurfaceLayer(const SatisfyCallback& satisfy_callback, | 42 explicit SurfaceLayer(scoped_refptr<SurfaceReferenceFactory> ref_factory); |
| 55 const RequireCallback& require_callback); | |
| 56 bool HasDrawableContent() const override; | 43 bool HasDrawableContent() const override; |
| 57 | 44 |
| 58 private: | 45 private: |
| 59 ~SurfaceLayer() override; | 46 ~SurfaceLayer() override; |
| 60 void CreateNewDestroySequence(); | 47 void RemoveCurrentReference(); |
| 61 void SatisfyDestroySequence(); | |
| 62 | 48 |
| 63 SurfaceId surface_id_; | 49 SurfaceInfo surface_info_; |
| 64 gfx::Size surface_size_; | 50 scoped_refptr<SurfaceReferenceFactory> ref_factory_; |
| 65 float surface_scale_ = 1.f; | 51 std::unique_ptr<SurfaceReferenceBase> current_ref_; |
| 66 bool stretch_content_to_fill_bounds_ = false; | 52 bool stretch_content_to_fill_bounds_ = false; |
| 67 SurfaceSequence destroy_sequence_; | |
| 68 SatisfyCallback satisfy_callback_; | |
| 69 RequireCallback require_callback_; | |
| 70 | 53 |
| 71 DISALLOW_COPY_AND_ASSIGN(SurfaceLayer); | 54 DISALLOW_COPY_AND_ASSIGN(SurfaceLayer); |
| 72 }; | 55 }; |
| 73 | 56 |
| 74 } // namespace cc | 57 } // namespace cc |
| 75 | 58 |
| 76 #endif // CC_LAYERS_SURFACE_LAYER_H_ | 59 #endif // CC_LAYERS_SURFACE_LAYER_H_ |
| OLD | NEW |