mirror_layer.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef CC_LAYERS_MIRROR_LAYER_H_
  5. #define CC_LAYERS_MIRROR_LAYER_H_
  6. #include <memory>
  7. #include "base/memory/scoped_refptr.h"
  8. #include "cc/cc_export.h"
  9. #include "cc/layers/layer.h"
  10. namespace cc {
  11. // A layer that can mirror contents of another Layer.
  12. class CC_EXPORT MirrorLayer : public Layer {
  13. public:
  14. static scoped_refptr<MirrorLayer> Create(scoped_refptr<Layer> mirrored_layer);
  15. MirrorLayer(const MirrorLayer&) = delete;
  16. MirrorLayer& operator=(const MirrorLayer&) = delete;
  17. Layer* mirrored_layer() const { return mirrored_layer_.get(); }
  18. // Layer overrides.
  19. std::unique_ptr<LayerImpl> CreateLayerImpl(
  20. LayerTreeImpl* tree_impl) const override;
  21. void PushPropertiesTo(LayerImpl* layer,
  22. const CommitState& commit_state,
  23. const ThreadUnsafeCommitState& unsafe_state) override;
  24. void SetLayerTreeHost(LayerTreeHost* host) override;
  25. protected:
  26. explicit MirrorLayer(scoped_refptr<Layer> mirrored_layer);
  27. private:
  28. ~MirrorLayer() override;
  29. // A reference to a layer that is mirrored by this layer. |mirrored_layer_|
  30. // cannot be an ancestor of |this|.
  31. const scoped_refptr<Layer> mirrored_layer_;
  32. };
  33. } // namespace cc
  34. #endif // CC_LAYERS_MIRROR_LAYER_H_