Mohsen Izadi | 1bcbf25 | 2019-06-27 01:26:29 | [diff] [blame] | 1 | // Copyright 2019 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_MIRROR_LAYER_H_ |
| 6 | #define CC_LAYERS_MIRROR_LAYER_H_ |
| 7 | |
Stefan Zager | 40f911d | 2021-10-28 21:30:21 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
Mohsen Izadi | 1bcbf25 | 2019-06-27 01:26:29 | [diff] [blame] | 10 | #include "base/memory/scoped_refptr.h" |
| 11 | #include "cc/cc_export.h" |
| 12 | #include "cc/layers/layer.h" |
| 13 | |
| 14 | namespace cc { |
| 15 | |
| 16 | // A layer that can mirror contents of another Layer. |
| 17 | class CC_EXPORT MirrorLayer : public Layer { |
| 18 | public: |
| 19 | static scoped_refptr<MirrorLayer> Create(scoped_refptr<Layer> mirrored_layer); |
| 20 | |
| 21 | MirrorLayer(const MirrorLayer&) = delete; |
| 22 | MirrorLayer& operator=(const MirrorLayer&) = delete; |
| 23 | |
| 24 | Layer* mirrored_layer() const { return mirrored_layer_.get(); } |
| 25 | |
| 26 | // Layer overrides. |
| 27 | std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
Stefan Zager | 40f911d | 2021-10-28 21:30:21 | [diff] [blame] | 28 | void PushPropertiesTo(LayerImpl* layer, |
Stefan Zager | 4c030c7 | 2021-12-07 22:50:21 | [diff] [blame] | 29 | const CommitState& commit_state, |
| 30 | const ThreadUnsafeCommitState& unsafe_state) override; |
Mohsen Izadi | 1bcbf25 | 2019-06-27 01:26:29 | [diff] [blame] | 31 | void SetLayerTreeHost(LayerTreeHost* host) override; |
| 32 | |
| 33 | protected: |
| 34 | explicit MirrorLayer(scoped_refptr<Layer> mirrored_layer); |
| 35 | |
| 36 | private: |
| 37 | ~MirrorLayer() override; |
| 38 | |
| 39 | // A reference to a layer that is mirrored by this layer. |mirrored_layer_| |
| 40 | // cannot be an ancestor of |this|. |
| 41 | scoped_refptr<Layer> mirrored_layer_; |
| 42 | }; |
| 43 | |
| 44 | } // namespace cc |
| 45 | |
| 46 | #endif // CC_LAYERS_MIRROR_LAYER_H_ |