5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_AHB_SWAPCHAIN_IMPL_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_AHB_SWAPCHAIN_IMPL_VK_H_
10 #include "flutter/fml/closure.h"
11 #include "flutter/fml/synchronization/semaphore.h"
20 #include "vulkan/vulkan_handles.hpp"
31 :
public std::enable_shared_from_this<AHBSwapchainImplVK> {
51 static std::shared_ptr<AHBSwapchainImplVK>
Create(
52 const std::weak_ptr<Context>& context,
53 std::weak_ptr<android::SurfaceControl> surface_control,
56 size_t swapchain_image_count);
96 using AutoSemaSignaler = std::shared_ptr<fml::ScopedCleanupClosure>;
98 std::weak_ptr<android::SurfaceControl> surface_control_;
100 std::shared_ptr<AHBTexturePoolVK> pool_;
101 std::shared_ptr<SwapchainTransientsVK> transients_;
104 Mutex currently_displayed_texture_mutex_;
105 std::shared_ptr<AHBTextureSourceVK> currently_displayed_texture_
106 IPLR_GUARDED_BY(currently_displayed_texture_mutex_);
107 std::shared_ptr<fml::Semaphore> pending_presents_;
110 std::shared_ptr<CommandBuffer> command_buffer;
111 vk::UniqueSemaphore semaphore;
114 std::array<FrameData, 3> frame_data_;
115 size_t frame_index_ = 0;
116 bool is_valid_ =
false;
119 const std::weak_ptr<Context>& context,
120 std::weak_ptr<android::SurfaceControl> surface_control,
123 size_t swapchain_image_count);
125 bool Present(
const AutoSemaSignaler& signaler,
126 const std::shared_ptr<AHBTextureSourceVK>& texture);
128 vk::UniqueSemaphore CreateRenderReadySemaphore(
129 const std::shared_ptr<fml::UniqueFD>& fd)
const;
131 bool SubmitWaitForRenderReady(
132 const std::shared_ptr<fml::UniqueFD>& render_ready_fence,
133 const std::shared_ptr<AHBTextureSourceVK>& texture);
135 std::shared_ptr<ExternalFenceVK> SubmitSignalForPresentReady(
136 const std::shared_ptr<AHBTextureSourceVK>& texture)
const;
138 void OnTextureUpdatedOnSurfaceControl(
139 const AutoSemaSignaler& signaler,
140 std::shared_ptr<AHBTextureSourceVK> texture,
141 ASurfaceTransactionStats* stats);
The implementation of a swapchain at a specific size. Resizes to the surface will cause the instance ...
AHBSwapchainImplVK(const AHBSwapchainImplVK &)=delete
AHBSwapchainImplVK & operator=(const AHBSwapchainImplVK &)=delete
static std::shared_ptr< AHBSwapchainImplVK > Create(const std::weak_ptr< Context > &context, std::weak_ptr< android::SurfaceControl > surface_control, const ISize &size, bool enable_msaa, size_t swapchain_image_count)
Create a swapchain of a specific size whose images will be presented to the provided surface control.
std::unique_ptr< Surface > AcquireNextDrawable()
Acquire the next surface that can be used to present to the swapchain.
const android::HardwareBufferDescriptor & GetDescriptor() const
Get the descriptor used to create the hardware buffers that will be displayed on the surface control.
void AddFinalCommandBuffer(std::shared_ptr< CommandBuffer > cmd_buffer)
const ISize & GetSize() const
A descriptor use to specify hardware buffer allocations.