| 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_VULKAN_VULKAN_BACKBUFFER_H_ |
| 6 | #define FLUTTER_VULKAN_VULKAN_BACKBUFFER_H_ |
| 7 | |
| 8 | #include <array> |
| 9 | |
| 10 | #include "flutter/fml/compiler_specific.h" |
| 11 | #include "flutter/fml/macros.h" |
| 12 | #include "flutter/vulkan/procs/vulkan_handle.h" |
| 13 | #include "third_party/skia/include/core/SkSize.h" |
| 14 | #include "third_party/skia/include/core/SkSurface.h" |
| 15 | #include "vulkan_command_buffer.h" |
| 16 | |
| 17 | namespace vulkan { |
| 18 | |
| 19 | class VulkanBackbuffer { |
| 20 | public: |
| 21 | VulkanBackbuffer(const VulkanProcTable& vk, |
| 22 | const VulkanHandle<VkDevice>& device, |
| 23 | const VulkanHandle<VkCommandPool>& pool); |
| 24 | |
| 25 | ~VulkanBackbuffer(); |
| 26 | |
| 27 | bool IsValid() const; |
| 28 | |
| 29 | [[nodiscard]] bool WaitFences(); |
| 30 | |
| 31 | [[nodiscard]] bool ResetFences(); |
| 32 | |
| 33 | const VulkanHandle<VkFence>& GetUsageFence() const; |
| 34 | |
| 35 | const VulkanHandle<VkFence>& GetRenderFence() const; |
| 36 | |
| 37 | const VulkanHandle<VkSemaphore>& GetUsageSemaphore() const; |
| 38 | |
| 39 | const VulkanHandle<VkSemaphore>& GetRenderSemaphore() const; |
| 40 | |
| 41 | VulkanCommandBuffer& GetUsageCommandBuffer(); |
| 42 | |
| 43 | VulkanCommandBuffer& GetRenderCommandBuffer(); |
| 44 | |
| 45 | private: |
| 46 | const VulkanProcTable& vk; |
| 47 | const VulkanHandle<VkDevice>& device_; |
| 48 | std::array<VulkanHandle<VkSemaphore>, 2> semaphores_; |
| 49 | std::array<VulkanHandle<VkFence>, 2> use_fences_; |
| 50 | VulkanCommandBuffer usage_command_buffer_; |
| 51 | VulkanCommandBuffer render_command_buffer_; |
| 52 | bool valid_; |
| 53 | |
| 54 | bool CreateSemaphores(); |
| 55 | |
| 56 | bool CreateFences(); |
| 57 | |
| 58 | FML_DISALLOW_COPY_AND_ASSIGN(VulkanBackbuffer); |
| 59 | }; |
| 60 | |
| 61 | } // namespace vulkan |
| 62 | |
| 63 | #endif // FLUTTER_VULKAN_VULKAN_BACKBUFFER_H_ |
| 64 |
