7 #include "flutter/fml/trace_event.h"
11 #include "third_party/vulkan-deps/vulkan-headers/src/include/vulkan/vulkan_enums.hpp"
21 ANativeWindow* window,
23 const vk::UniqueSurfaceKHR& surface,
28 std::make_shared<android::SurfaceControl>(window,
"ImpellerSurface")),
29 enable_msaa_(enable_msaa),
31 const auto [caps_result, surface_caps] =
34 if (caps_result == vk::Result::eSuccess) {
35 swapchain_image_count_ =
36 std::clamp(surface_caps.minImageCount + 1u,
37 surface_caps.minImageCount,
38 surface_caps.maxImageCount == 0u
39 ? surface_caps.minImageCount + 1u
40 : surface_caps.maxImageCount
51 return impl_ ? impl_->IsValid() :
false;
60 TRACE_EVENT0(
"impeller", __FUNCTION__);
61 return impl_->AcquireNextDrawable();
68 : vk::Format::eUndefined;
73 std::shared_ptr<CommandBuffer> cmd_buffer)
const {
74 return impl_->AddFinalCommandBuffer(cmd_buffer);
79 if (impl_ && impl_->GetSize() == size) {
82 TRACE_EVENT0(
"impeller", __FUNCTION__);
88 swapchain_image_count_
90 if (!impl || !impl->IsValid()) {
94 impl_ = std::move(impl);
static std::shared_ptr< AHBSwapchainImplVK > Create(const std::weak_ptr< Context > &context, std::weak_ptr< android::SurfaceControl > surface_control, const CreateTransactionCB &cb, 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.
static bool IsAvailableOnPlatform()
void UpdateSurfaceSize(const ISize &size) override
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
bool IsValid() const override
void AddFinalCommandBuffer(std::shared_ptr< CommandBuffer > cmd_buffer) const override
vk::Format GetSurfaceFormat() const override
~AHBSwapchainVK() override
std::unique_ptr< Surface > AcquireNextDrawable() override
AHBSwapchainVK(const AHBSwapchainVK &)=delete
static ContextVK & Cast(Context &base)
vk::PhysicalDevice GetPhysicalDevice() const
static bool IsAvailableOnPlatform()
static bool IsAvailableOnPlatform()
std::function< android::SurfaceTransaction()> CreateTransactionCB
constexpr PixelFormat ToPixelFormat(vk::Format format)
constexpr vk::Format ToVKImageFormat(PixelFormat format)