A wrapper for AHardwareBuffer https://developer.android.com/ndk/reference/group/a-hardware-buffer.
More...
#include <hardware_buffer.h>
A wrapper for AHardwareBuffer https://developer.android.com/ndk/reference/group/a-hardware-buffer.
This wrapper creates and owns a handle to a managed hardware buffer. That is, there is no ability to take a reference to an externally created hardware buffer.
This wrapper is only available on Android API 29 and above.
Definition at line 95 of file hardware_buffer.h.
◆ CPUAccessType
◆ HardwareBuffer() [1/2]
Definition at line 57 of file hardware_buffer.cc.
58 : descriptor_(descriptor),
61 VALIDATION_LOG <<
"The hardware buffer descriptor is not allocatable.";
62 return;
63 }
65
68 proc_table.AHardwareBuffer_allocate(&android_descriptor_, &
buffer);
71 return;
72 }
74 is_valid_ = true;
75}
struct AHardwareBuffer AHardwareBuffer
void reset(const T &value=Traits::InvalidValue())
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
const ProcTable & GetProcTable()
static AHardwareBuffer_Desc ToAHardwareBufferDesc(const HardwareBufferDescriptor &desc)
bool IsAllocatable() const
If hardware buffers can be created using this descriptor. Allocatable descriptors may still cause fai...
◆ ~HardwareBuffer()
impeller::android::HardwareBuffer::~HardwareBuffer |
( |
| ) |
|
|
default |
◆ HardwareBuffer() [2/2]
impeller::android::HardwareBuffer::HardwareBuffer |
( |
const HardwareBuffer & |
| ) |
|
|
delete |
◆ Describe()
std::optional< AHardwareBuffer_Desc > impeller::android::HardwareBuffer::Describe |
( |
AHardwareBuffer * |
buffer | ) |
|
|
static |
Definition at line 127 of file hardware_buffer.cc.
128 {
130 return std::nullopt;
131 }
132 AHardwareBuffer_Desc
desc = {};
135}
◆ GetAndroidDescriptor()
const AHardwareBuffer_Desc & impeller::android::HardwareBuffer::GetAndroidDescriptor |
( |
| ) |
const |
◆ GetDescriptor()
◆ GetHandle()
◆ GetSystemUniqueID() [1/2]
std::optional< uint64_t > impeller::android::HardwareBuffer::GetSystemUniqueID |
( |
| ) |
const |
Get the system wide unique ID of the hardware buffer if possible. This is only available on Android API 31 and above. Within the process, the handle are unique.
- Returns
- The system unique id if one can be obtained.
Definition at line 111 of file hardware_buffer.cc.
111 {
113}
AHardwareBuffer * GetHandle() const
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...
◆ GetSystemUniqueID() [2/2]
std::optional< uint64_t > impeller::android::HardwareBuffer::GetSystemUniqueID |
( |
AHardwareBuffer * |
buffer | ) |
|
|
static |
Get the system wide unique ID of the hardware buffer if possible. This is only available on Android API 31 and above. Within the process, the handle are unique.
- Returns
- The system unique id if one can be obtained.
Definition at line 115 of file hardware_buffer.cc.
116 {
118 return std::nullopt;
119 }
120 uint64_t out_id = 0u;
122 return std::nullopt;
123 }
124 return out_id;
125}
◆ IsAvailableOnPlatform()
bool impeller::android::HardwareBuffer::IsAvailableOnPlatform |
( |
| ) |
|
|
static |
Definition at line 107 of file hardware_buffer.cc.
107 {
109}
bool IsValid() const
If a valid proc table could be setup. This may fail in case of setup on non-Android platforms.
◆ IsValid()
bool impeller::android::HardwareBuffer::IsValid |
( |
| ) |
const |
◆ Lock()
void * impeller::android::HardwareBuffer::Lock |
( |
CPUAccessType |
type | ) |
const |
Lock the buffer for CPU access. This call may fail if the buffer was not created with one the usages that allow for CPU access.
- Parameters
-
- Returns
- A host-accessible buffer if there was no error related to usage or buffer validity.
Definition at line 137 of file hardware_buffer.cc.
137 {
138 if (!is_valid_ || !
GetProcTable().AHardwareBuffer_lock) {
139 return nullptr;
140 }
144 usage |= AHARDWAREBUFFER_USAGE_CPU_READ_MASK;
145 break;
147 usage |= AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK;
148 break;
149 }
154 -1,
155 nullptr,
157 );
159}
static void usage(char *argv0)
◆ operator=()
◆ Unlock()
bool impeller::android::HardwareBuffer::Unlock |
( |
| ) |
const |
Unlock a mapping previously locked for CPU access.
- Returns
- If the unlock was successful.
Definition at line 161 of file hardware_buffer.cc.
161 {
162 if (!is_valid_ || !
GetProcTable().AHardwareBuffer_unlock) {
163 return false;
164 }
168}
The documentation for this class was generated from the following files: