Flutter Impeller
impeller::AHBSwapchainVK Class Referencefinal

The implementation of a swapchain that uses hardware buffers presented to a given surface control on Android. More...

#include <ahb_swapchain_vk.h>

Inheritance diagram for impeller::AHBSwapchainVK:
impeller::SwapchainVK

Public Member Functions

 ~AHBSwapchainVK () override
 
 AHBSwapchainVK (const AHBSwapchainVK &)=delete
 
AHBSwapchainVKoperator= (const AHBSwapchainVK &)=delete
 
bool IsValid () const override
 
std::unique_ptr< SurfaceAcquireNextDrawable () override
 
vk::Format GetSurfaceFormat () const override
 
void UpdateSurfaceSize (const ISize &size) override
 Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame. More...
 
- Public Member Functions inherited from impeller::SwapchainVK
virtual ~SwapchainVK ()
 
 SwapchainVK (const SwapchainVK &)=delete
 
SwapchainVKoperator= (const SwapchainVK &)=delete
 

Static Public Member Functions

static bool IsAvailableOnPlatform ()
 
- Static Public Member Functions inherited from impeller::SwapchainVK
static std::shared_ptr< SwapchainVKCreate (const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
 

Friends

class SwapchainVK
 

Additional Inherited Members

- Protected Member Functions inherited from impeller::SwapchainVK
 SwapchainVK ()
 

Detailed Description

The implementation of a swapchain that uses hardware buffers presented to a given surface control on Android.

Warning
This swapchain implementation is not available on all Android versions supported by Flutter. Perform the IsAvailableOnPlatform check and fallback to KHR swapchains if this type of swapchain cannot be created. The available building blocks for these kinds of swapchains are only available on Android API levels >= 29.

Definition at line 26 of file ahb_swapchain_vk.h.

Constructor & Destructor Documentation

◆ ~AHBSwapchainVK()

impeller::AHBSwapchainVK::~AHBSwapchainVK ( )
overridedefault

◆ AHBSwapchainVK()

impeller::AHBSwapchainVK::AHBSwapchainVK ( const AHBSwapchainVK )
delete

Member Function Documentation

◆ AcquireNextDrawable()

std::unique_ptr< Surface > impeller::AHBSwapchainVK::AcquireNextDrawable ( )
overridevirtual

Implements impeller::SwapchainVK.

Definition at line 53 of file ahb_swapchain_vk.cc.

53  {
54  if (!IsValid()) {
55  return nullptr;
56  }
57 
58  TRACE_EVENT0("impeller", __FUNCTION__);
59  return impl_->AcquireNextDrawable();
60 }

References IsValid().

◆ GetSurfaceFormat()

vk::Format impeller::AHBSwapchainVK::GetSurfaceFormat ( ) const
overridevirtual

Implements impeller::SwapchainVK.

Definition at line 63 of file ahb_swapchain_vk.cc.

63  {
64  return IsValid()
65  ? ToVKImageFormat(ToPixelFormat(impl_->GetDescriptor().format))
66  : vk::Format::eUndefined;
67 }

References IsValid(), impeller::ToPixelFormat(), and impeller::ToVKImageFormat().

◆ IsAvailableOnPlatform()

bool impeller::AHBSwapchainVK::IsAvailableOnPlatform ( )
static

◆ IsValid()

bool impeller::AHBSwapchainVK::IsValid ( ) const
overridevirtual

Implements impeller::SwapchainVK.

Definition at line 48 of file ahb_swapchain_vk.cc.

48  {
49  return impl_ ? impl_->IsValid() : false;
50 }

Referenced by AcquireNextDrawable(), and GetSurfaceFormat().

◆ operator=()

AHBSwapchainVK& impeller::AHBSwapchainVK::operator= ( const AHBSwapchainVK )
delete

◆ UpdateSurfaceSize()

void impeller::AHBSwapchainVK::UpdateSurfaceSize ( const ISize size)
overridevirtual

Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.

Implements impeller::SwapchainVK.

Definition at line 70 of file ahb_swapchain_vk.cc.

70  {
71  if (impl_ && impl_->GetSize() == size) {
72  return;
73  }
74  TRACE_EVENT0("impeller", __FUNCTION__);
75  auto impl = AHBSwapchainImplVK::Create(context_, //
76  surface_control_, //
77  size, //
78  enable_msaa_, //
79  swapchain_image_count_ //
80  );
81  if (!impl || !impl->IsValid()) {
82  VALIDATION_LOG << "Could not resize swapchain to size: " << size;
83  return;
84  }
85  impl_ = std::move(impl);
86 }

References impeller::AHBSwapchainImplVK::Create(), and VALIDATION_LOG.

Friends And Related Function Documentation

◆ SwapchainVK

friend class SwapchainVK
friend

Definition at line 50 of file ahb_swapchain_vk.h.


The documentation for this class was generated from the following files:
impeller::android::HardwareBuffer::IsAvailableOnPlatform
static bool IsAvailableOnPlatform()
Definition: hardware_buffer.cc:107
impeller::android::SurfaceControl::IsAvailableOnPlatform
static bool IsAvailableOnPlatform()
Definition: surface_control.cc:51
impeller::AHBSwapchainImplVK::Create
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.
Definition: ahb_swapchain_impl_vk.cc:43
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:133
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
impeller::AHBSwapchainVK::IsValid
bool IsValid() const override
Definition: ahb_swapchain_vk.cc:48
impeller::ToPixelFormat
static PixelFormat ToPixelFormat(AHardwareBuffer_Format format)
Definition: ahb_texture_source_vk.cc:221