• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef RS_ENABLE_VK
11 #include "flutter/fml/compiler_specific.h"
12 #include "flutter/fml/macros.h"
13 #endif
14 #include "flutter/vulkan/vulkan_command_buffer.h"
15 #include "flutter/vulkan/vulkan_handle.h"
16 #include "third_party/skia/include/core/SkSize.h"
17 #include "third_party/skia/include/core/SkSurface.h"
18 
19 namespace vulkan {
20 
21 class VulkanBackbuffer {
22  public:
23   VulkanBackbuffer(const VulkanProcTable& vk,
24                    const VulkanHandle<VkDevice>& device,
25                    const VulkanHandle<VkCommandPool>& pool);
26 
27   ~VulkanBackbuffer();
28 
29   bool IsValid() const;
30 
31 #ifndef RS_ENABLE_VK
32   FML_WARN_UNUSED_RESULT
33 #endif
34   bool WaitFences();
35 
36 #ifndef RS_ENABLE_VK
37   FML_WARN_UNUSED_RESULT
38 #endif
39   bool ResetFences();
40 
41   const VulkanHandle<VkFence>& GetUsageFence() const;
42 
43   const VulkanHandle<VkFence>& GetRenderFence() const;
44 
45   const VulkanHandle<VkSemaphore>& GetUsageSemaphore() const;
46 
47   const VulkanHandle<VkSemaphore>& GetRenderSemaphore() const;
48 
49   VulkanCommandBuffer& GetUsageCommandBuffer();
50 
51   VulkanCommandBuffer& GetRenderCommandBuffer();
52 
53 #ifdef RS_ENABLE_VK
SetMultiThreading()54   void SetMultiThreading() { multi_threading_ = true; }
55 
UnsetMultiThreading()56   void UnsetMultiThreading() { multi_threading_ = false; }
57 
IsMultiThreading()58   bool IsMultiThreading() { return multi_threading_; }
59 #endif
60 
61  private:
62   const VulkanProcTable& vk;
63   const VulkanHandle<VkDevice>& device_;
64   std::array<VulkanHandle<VkSemaphore>, 2> semaphores_;
65   std::array<VulkanHandle<VkFence>, 2> use_fences_;
66   VulkanCommandBuffer usage_command_buffer_;
67   VulkanCommandBuffer render_command_buffer_;
68   bool valid_;
69 
70   bool CreateSemaphores();
71 
72   bool CreateFences();
73 
74 #ifdef RS_ENABLE_VK
75   bool multi_threading_ = false;
76 #endif
77 
78 #ifndef RS_ENABLE_VK
79   FML_DISALLOW_COPY_AND_ASSIGN(VulkanBackbuffer);
80 #endif
81 };
82 
83 }  // namespace vulkan
84 
85 #endif  // FLUTTER_VULKAN_VULKAN_BACKBUFFER_H_
86