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/vulkan_command_buffer.h" 13 #include "flutter/vulkan/vulkan_handle.h" 14 #include "third_party/skia/include/core/SkSize.h" 15 #include "third_party/skia/include/core/SkSurface.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 FML_WARN_UNUSED_RESULT 30 bool WaitFences(); 31 32 FML_WARN_UNUSED_RESULT 33 bool ResetFences(); 34 35 const VulkanHandle<VkFence>& GetUsageFence() const; 36 37 const VulkanHandle<VkFence>& GetRenderFence() const; 38 39 const VulkanHandle<VkSemaphore>& GetUsageSemaphore() const; 40 41 const VulkanHandle<VkSemaphore>& GetRenderSemaphore() const; 42 43 VulkanCommandBuffer& GetUsageCommandBuffer(); 44 45 VulkanCommandBuffer& GetRenderCommandBuffer(); 46 47 private: 48 const VulkanProcTable& vk; 49 const VulkanHandle<VkDevice>& device_; 50 std::array<VulkanHandle<VkSemaphore>, 2> semaphores_; 51 std::array<VulkanHandle<VkFence>, 2> use_fences_; 52 VulkanCommandBuffer usage_command_buffer_; 53 VulkanCommandBuffer render_command_buffer_; 54 bool valid_; 55 56 bool CreateSemaphores(); 57 58 bool CreateFences(); 59 60 FML_DISALLOW_COPY_AND_ASSIGN(VulkanBackbuffer); 61 }; 62 63 } // namespace vulkan 64 65 #endif // FLUTTER_VULKAN_VULKAN_BACKBUFFER_H_ 66