Flutter Impeller
impeller::android::HardwareBufferDescriptor Struct Reference

A descriptor use to specify hardware buffer allocations. More...

#include <hardware_buffer.h>

Public Member Functions

bool IsAllocatable () const
 If hardware buffers can be created using this descriptor. Allocatable descriptors may still cause failing allocations in case of resource exhaustion. More...
 
constexpr bool operator== (const HardwareBufferDescriptor &o) const
 
constexpr bool operator!= (const HardwareBufferDescriptor &o) const
 

Static Public Member Functions

static HardwareBufferDescriptor MakeForSwapchainImage (const ISize &size)
 Create a descriptor of the given size that is suitable for use as a swapchain image. More...
 

Public Attributes

HardwareBufferFormat format = HardwareBufferFormat::kR8G8B8A8UNormInt
 
ISize size
 
HardwareBufferUsage usage = 0u
 

Detailed Description

A descriptor use to specify hardware buffer allocations.

Definition at line 40 of file hardware_buffer.h.

Member Function Documentation

◆ IsAllocatable()

bool impeller::android::HardwareBufferDescriptor::IsAllocatable ( ) const

If hardware buffers can be created using this descriptor. Allocatable descriptors may still cause failing allocations in case of resource exhaustion.

Returns
true if allocatable (unless resource exhaustion).

Definition at line 42 of file hardware_buffer.cc.

42  {
43  const auto desc = ToAHardwareBufferDesc(*this);
44  return GetProcTable().AHardwareBuffer_isSupported(&desc) != 0u;
45 }

References impeller::android::GetProcTable(), and impeller::android::ToAHardwareBufferDesc().

Referenced by impeller::android::HardwareBuffer::HardwareBuffer().

◆ MakeForSwapchainImage()

HardwareBufferDescriptor impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage ( const ISize size)
static

Create a descriptor of the given size that is suitable for use as a swapchain image.

Warning
Descriptors of zero size are not allocatable. The next best valid size is picked. So make sure to check the actual size of the descriptor after this call is made to determine the size of the allocated hardware buffer.
Parameters
[in]sizeThe size. See the restrictions about valid sizes above.
Returns
The hardware buffer descriptor.

Definition at line 77 of file hardware_buffer.cc.

78  {
79  HardwareBufferDescriptor desc;
81  // Zero sized hardware buffers cannot be allocated.
82  desc.size = size.Max(ISize{1u, 1u});
83  desc.usage =
84  static_cast<HardwareBufferUsage>(
86  static_cast<HardwareBufferUsage>(
89  return desc;
90 }

References format, impeller::android::kCompositorOverlay, impeller::android::kFrameBufferAttachment, impeller::android::kR8G8B8A8UNormInt, impeller::android::kSampledImage, impeller::TSize< T >::Max(), size, and usage.

Referenced by impeller::android::testing::TEST().

◆ operator!=()

constexpr bool impeller::android::HardwareBufferDescriptor::operator!= ( const HardwareBufferDescriptor o) const
inlineconstexpr

Definition at line 73 of file hardware_buffer.h.

73  {
74  return !(*this == o);
75  }

◆ operator==()

constexpr bool impeller::android::HardwareBufferDescriptor::operator== ( const HardwareBufferDescriptor o) const
inlineconstexpr

Definition at line 69 of file hardware_buffer.h.

69  {
70  return format == o.format && size == o.size && usage == o.usage;
71  }

References format, size, and usage.

Member Data Documentation

◆ format

HardwareBufferFormat impeller::android::HardwareBufferDescriptor::format = HardwareBufferFormat::kR8G8B8A8UNormInt

◆ size

ISize impeller::android::HardwareBufferDescriptor::size

◆ usage

HardwareBufferUsage impeller::android::HardwareBufferDescriptor::usage = 0u

The documentation for this struct was generated from the following files:
impeller::android::HardwareBufferUsage
uint8_t HardwareBufferUsage
Definition: hardware_buffer.h:29
impeller::android::HardwareBufferUsageFlags::kCompositorOverlay
@ kCompositorOverlay
impeller::android::ToAHardwareBufferDesc
static AHardwareBuffer_Desc ToAHardwareBufferDesc(const HardwareBufferDescriptor &desc)
Definition: hardware_buffer.cc:20
impeller::android::HardwareBufferUsageFlags::kSampledImage
@ kSampledImage
impeller::TSize::Max
constexpr TSize Max(const TSize &o) const
Definition: size.h:81
impeller::android::HardwareBufferFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::ISize
TSize< int64_t > ISize
Definition: size.h:138
impeller::android::HardwareBufferDescriptor::size
ISize size
Definition: hardware_buffer.h:42
impeller::android::HardwareBufferDescriptor::usage
HardwareBufferUsage usage
Definition: hardware_buffer.h:43
impeller::android::GetProcTable
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
impeller::android::HardwareBufferUsageFlags::kFrameBufferAttachment
@ kFrameBufferAttachment
impeller::android::HardwareBufferDescriptor::format
HardwareBufferFormat format
Definition: hardware_buffer.h:41