| Flutter Impeller |

Public Member Functions | List of all members
impeller::interop::SwapchainVK Class Referencefinal

`#include <swapchain_vk.h>`

Inheritance diagram for impeller::interop::SwapchainVK:

## Public Member Functions
| SwapchainVK (Context &context, VkSurfaceKHR surface)
| ~SwapchainVK ()
bool | IsValid () const
| SwapchainVK (const SwapchainVK &)=delete
SwapchainVK & | operator= (const SwapchainVK &)=delete
ScopedObject< SurfaceVK > | AcquireNextSurface ()
Public Member Functions inherited from impeller::interop::ObjectBase
| ObjectBase ()=default
virtual | ~ObjectBase ()=default
| ObjectBase (const ObjectBase &)=delete
| ObjectBase (ObjectBase &&)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
ObjectBase & | operator= (ObjectBase &&)=delete
void | Retain ()
void | Release ()
uint64_t | GetRefCountForTests () const

## Additional Inherited Members
Public Types inherited from impeller::interop::Object< SwapchainVK, IMPELLER_INTERNAL_HANDLE_NAME(ImpellerVulkanSwapchain)>
using | InteropClass = SwapchainVK
using | InteropCSibling = IMPELLER_INTERNAL_HANDLE_NAME(ImpellerVulkanSwapchain)
Static Public Member Functions inherited from impeller::interop::ObjectBase
static void | SafeRetain (void *ptr)
static void | SafeRelease (void *ptr)

## Detailed Description

Definition at line 16 of file swapchain_vk.h.

## Constructor & Destructor Documentation

## ◆ SwapchainVK() [1/2]

impeller::interop::SwapchainVK::SwapchainVK | ( | Context & | context,
|  | VkSurfaceKHR | surface
| ) |  |

Definition at line 11 of file swapchain_vk.cc.

12 : context_(Ref(&context)) {
13 if (!context.IsVulkan()) {
14 VALIDATION_LOG << "Context is not Vulkan.";
15 return;
16 }
17
18 if (!c_surface) {
19 VALIDATION_LOG << "Invalid surface.";
20 return;
21 }
22
23 // Creating a unique object from a raw handle requires fetching the owner
24 // manually.
25 auto surface = vk::UniqueSurfaceKHR(
26 vk::SurfaceKHR{c_surface},
27 impeller::ContextVK::Cast(*context_->GetContext()).GetInstance());
28 auto swapchain = impeller::SwapchainVK::Create(context.GetContext(), //
29 std::move(surface), //
30 ISize::MakeWH(1, 1) //
31 );
32 if (!swapchain) {
33 VALIDATION_LOG << "Could not create Vulkan swapchain.";
34 return;
35 }
36 swapchain_ = std::move(swapchain);
37 }
impeller::BackendCast< ContextVK, Context >::Cast
static ContextVK & Cast(Context &base)
Definition: backend_cast.h:13
impeller::ContextVK::GetInstance
vk::Instance GetInstance() const
Definition: context_vk.cc:588
impeller::SwapchainVK::Create
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
Definition: swapchain_vk.cc:18
impeller::interop::Ref
ScopedObject< Object > Ref(Object *object)
Definition: object.h:146
impeller::TSize::MakeWH
static constexpr TSize MakeWH(Type width, Type height)
Definition: size.h:43
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::BackendCast< ContextVK, Context >::Cast(), impeller::SwapchainVK::Create(), impeller::interop::Context::GetContext(), impeller::ContextVK::GetInstance(), impeller::interop::Context::IsVulkan(), impeller::TSize< T >::MakeWH(), and VALIDATION_LOG.

## ◆ ~SwapchainVK()

impeller::interop::SwapchainVK::~SwapchainVK | ( |  | ) |
| default

## ◆ SwapchainVK() [2/2]

impeller::interop::SwapchainVK::SwapchainVK | ( | const SwapchainVK & |  | ) |
| delete

## Member Function Documentation

## ◆ AcquireNextSurface()

ScopedObject< SurfaceVK > impeller::interop::SwapchainVK::AcquireNextSurface | ( |  | ) |

Definition at line 45 of file swapchain_vk.cc.

45 {
46 if (!IsValid()) {
47 return nullptr;
48 }
49
50 auto impeller_surface = swapchain_->AcquireNextDrawable();
51 if (!impeller_surface) {
52 VALIDATION_LOG << "Could not acquire next drawable.";
53 return nullptr;
54 }
55
56 auto surface = Create<SurfaceVK>(*context_, std::move(impeller_surface));
57 if (!surface || !surface->IsValid()) {
58 VALIDATION_LOG << "Could not create valid surface.";
59 return nullptr;
60 }
61
62 return surface;
63 }
impeller::interop::SwapchainVK::IsValid
bool IsValid() const
Definition: swapchain_vk.cc:41

References IsValid(), and VALIDATION_LOG.

## ◆ IsValid()

bool impeller::interop::SwapchainVK::IsValid | ( |  | ) | const

Definition at line 41 of file swapchain_vk.cc.

41 {
42 return swapchain_ && swapchain_->IsValid();
43 }

Referenced by AcquireNextSurface().

## ◆ operator=()

SwapchainVK& impeller::interop::SwapchainVK::operator= | ( | const SwapchainVK & |  | ) |
| delete

The documentation for this class was generated from the following files:

- impeller/toolkit/interop/backend/vulkan/swapchain_vk.h
- impeller/toolkit/interop/backend/vulkan/swapchain_vk.cc