layer_tree_owner.h 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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
  3. // found in the LICENSE file.
  4. #ifndef UI_COMPOSITOR_LAYER_TREE_OWNER_H_
  5. #define UI_COMPOSITOR_LAYER_TREE_OWNER_H_
  6. #include <memory>
  7. #include "base/memory/raw_ptr.h"
  8. #include "ui/compositor/compositor_export.h"
  9. namespace ui {
  10. class Layer;
  11. // Scoping object that owns a Layer and all its descendants.
  12. class COMPOSITOR_EXPORT LayerTreeOwner {
  13. public:
  14. explicit LayerTreeOwner(std::unique_ptr<Layer> root);
  15. LayerTreeOwner(const LayerTreeOwner&) = delete;
  16. LayerTreeOwner& operator=(const LayerTreeOwner&) = delete;
  17. ~LayerTreeOwner();
  18. [[nodiscard]] Layer* release() {
  19. Layer* root = root_;
  20. root_ = nullptr;
  21. return root;
  22. }
  23. Layer* root() { return root_; }
  24. const Layer* root() const { return root_; }
  25. private:
  26. raw_ptr<Layer> root_;
  27. };
  28. } // namespace
  29. #endif // UI_COMPOSITOR_LAYER_TREE_OWNER_H_