| 1 | // Copyright 2013 The Flutter 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 FLUTTER_TESTING_TEST_VULKAN_IMAGE_H_ |
| 6 | #define FLUTTER_TESTING_TEST_VULKAN_IMAGE_H_ |
| 7 | |
| 8 | #include "flutter/fml/macros.h" |
| 9 | |
| 10 | #include "flutter/fml/memory/ref_ptr.h" |
| 11 | #include "flutter/vulkan/procs/vulkan_handle.h" |
| 12 | #include "third_party/skia/include/core/SkSize.h" |
| 13 | |
| 14 | namespace flutter { |
| 15 | namespace testing { |
| 16 | |
| 17 | class TestVulkanContext; |
| 18 | |
| 19 | /// Captures the lifetime of a test VkImage along with its bound memory. |
| 20 | class TestVulkanImage { |
| 21 | public: |
| 22 | TestVulkanImage(TestVulkanImage&& other); |
| 23 | TestVulkanImage& operator=(TestVulkanImage&& other); |
| 24 | |
| 25 | ~TestVulkanImage(); |
| 26 | |
| 27 | VkImage GetImage(); |
| 28 | |
| 29 | private: |
| 30 | TestVulkanImage(); |
| 31 | |
| 32 | // The lifetime of the Vulkan state must exceed memory/image handles. |
| 33 | fml::RefPtr<TestVulkanContext> context_; |
| 34 | |
| 35 | vulkan::VulkanHandle<VkImage> image_; |
| 36 | vulkan::VulkanHandle<VkDeviceMemory> memory_; |
| 37 | |
| 38 | FML_DISALLOW_COPY_AND_ASSIGN(TestVulkanImage); |
| 39 | |
| 40 | friend TestVulkanContext; |
| 41 | }; |
| 42 | |
| 43 | } // namespace testing |
| 44 | } // namespace flutter |
| 45 | |
| 46 | #endif // FLUTTER_TESTING_TEST_VULKAN_IMAGE_H_ |
| 47 |
