5 #ifndef FLUTTER_IMPELLER_TOOLKIT_ANDROID_HARDWARE_BUFFER_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_ANDROID_HARDWARE_BUFFER_H_
10 #include "flutter/fml/unique_fd.h"
11 #include "flutter/fml/unique_object.h"
115 static std::optional<AHardwareBuffer_Desc>
Describe(AHardwareBuffer* buffer);
159 struct UniqueAHardwareBufferTraits {
160 static AHardwareBuffer* InvalidValue() {
return nullptr; }
163 return value != InvalidValue();
166 static void Free(AHardwareBuffer*
value) {
171 const HardwareBufferDescriptor descriptor_;
172 const AHardwareBuffer_Desc android_descriptor_;
173 fml::UniqueObject<AHardwareBuffer*, UniqueAHardwareBufferTraits> buffer_;
174 bool is_valid_ =
false;
A wrapper for AHardwareBuffer https://developer.android.com/ndk/reference/group/a-hardware-buffer.
HardwareBuffer(HardwareBufferDescriptor descriptor)
static bool IsAvailableOnPlatform()
const HardwareBufferDescriptor & GetDescriptor() const
AHardwareBuffer * GetHandle() const
const AHardwareBuffer_Desc & GetAndroidDescriptor() const
HardwareBuffer & operator=(const HardwareBuffer &)=delete
bool Unlock() const
Unlock a mapping previously locked for CPU access.
static std::optional< AHardwareBuffer_Desc > Describe(AHardwareBuffer *buffer)
HardwareBuffer(const HardwareBuffer &)=delete
void * Lock(CPUAccessType type) const
Lock the buffer for CPU access. This call may fail if the buffer was not created with one the usages ...
std::optional< uint64_t > GetSystemUniqueID() const
Get the system wide unique ID of the hardware buffer if possible. This is only available on Android A...
const ProcTable & GetProcTable()
IMPELLER_ENUM_IS_MASK(MyMaskBits)
A descriptor use to specify hardware buffer allocations.
static HardwareBufferDescriptor MakeForSwapchainImage(const ISize &size)
Create a descriptor of the given size that is suitable for use as a swapchain image.
constexpr bool operator==(const HardwareBufferDescriptor &o) const
constexpr bool operator!=(const HardwareBufferDescriptor &o) const
HardwareBufferUsage usage
bool IsAllocatable() const
If hardware buffers can be created using this descriptor. Allocatable descriptors may still cause fai...
HardwareBufferFormat format