7 #include "flutter/fml/trace_event.h"
13 KHRSwapchainVK::KHRSwapchainVK(
const std::shared_ptr<Context>& context,
14 vk::UniqueSurfaceKHR surface,
17 : size_(size), enable_msaa_(enable_msaa) {
23 if (!impl || !impl->IsValid()) {
27 impl_ = std::move(impl);
30 KHRSwapchainVK::~KHRSwapchainVK() =
default;
32 bool KHRSwapchainVK::IsValid()
const {
33 return impl_ ? impl_->IsValid() :
false;
36 void KHRSwapchainVK::UpdateSurfaceSize(
const ISize& size) {
42 void KHRSwapchainVK::AddFinalCommandBuffer(
43 std::shared_ptr<CommandBuffer> cmd_buffer)
const {
44 impl_->AddFinalCommandBuffer(std::move(cmd_buffer));
47 std::unique_ptr<Surface> KHRSwapchainVK::AcquireNextDrawable() {
52 TRACE_EVENT0(
"impeller", __FUNCTION__);
54 auto result = impl_->AcquireNextDrawable();
55 if (!result.out_of_date && size_ == impl_->GetSize()) {
56 return std::move(result.surface);
59 TRACE_EVENT0(
"impeller",
"RecreateSwapchain");
63 auto context = impl_->GetContext();
64 auto [surface, old_swapchain] = impl_->DestroySwapchain();
72 if (!new_impl || !new_impl->IsValid()) {
79 impl_ = std::move(new_impl);
84 return AcquireNextDrawable();
87 vk::Format KHRSwapchainVK::GetSurfaceFormat()
const {
88 return IsValid() ? impl_->GetSurfaceFormat() : vk::Format::eUndefined;
ScopedObject< Object > Create(CtorArgs &&... args)