layer_util.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2020 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 ASH_UTILITY_LAYER_UTIL_H_
  5. #define ASH_UTILITY_LAYER_UTIL_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "base/callback.h"
  9. namespace ui {
  10. class Layer;
  11. }
  12. namespace gfx {
  13. class Size;
  14. }
  15. namespace viz {
  16. class CopyOutputResult;
  17. }
  18. namespace ash {
  19. // Creates the new layer with |layer_size| using the image in |copy_result|.
  20. ASH_EXPORT std::unique_ptr<ui::Layer> CreateLayerFromCopyOutputResult(
  21. std::unique_ptr<viz::CopyOutputResult> copy_result,
  22. const gfx::Size& layer_size);
  23. using LayerCopyCallback =
  24. base::OnceCallback<void(std::unique_ptr<ui::Layer> new_layer)>;
  25. // Creates a new layer that has a copy of the |layer|'s content. This is an
  26. // async API and a new layer will be passed to the |callback| when copy is done.
  27. ASH_EXPORT void CopyLayerContentToNewLayer(ui::Layer* layer,
  28. LayerCopyCallback callback);
  29. using GetTargetLayerCallback = base::OnceCallback<void(ui::Layer**)>;
  30. // Copy the content of |original_layer| to a new layer given via |callback|.
  31. // This is an async API and |callback| is called when the copy result is ready.
  32. ASH_EXPORT void CopyLayerContentToLayer(ui::Layer* original_layer,
  33. GetTargetLayerCallback callback);
  34. } // namespace ash
  35. #endif // ASH_UTILITY_LAYER_UTIL_H_