AHardwareBuffer
NameSpace: NativeWindow
Inherits from:
INullablePointer,
IDisposable
Public Fields
description
public Description description { get; set; }
Public Methods
void Acquire
public void Acquire()
void Dispose
public void Dispose()
bool IsSupported
public static bool IsSupported(
Description description
)
Parameters
Type | Name | Description |
---|---|---|
Description | description |
override string ToString
public override string ToString()
bool TryAllocate
public static bool TryAllocate(
Description description,
out AHardwareBuffer buffer
)
Parameters
Type | Name | Description |
---|---|---|
Description | description | |
out AHardwareBuffer | buffer |
unsafe bool TryLockData
public unsafe bool TryLockData(
Usage usageFlags,
out void * outAddress
)
Parameters
Type | Name | Description |
---|---|---|
Usage | usageFlags | |
out void * | outAddress |
bool TryLockPlaneData
public bool TryLockPlaneData(
Usage usageFlags,
out Planes planes
)
Parameters
Type | Name | Description |
---|---|---|
Usage | usageFlags | |
out Planes | planes |
bool TryUnlockData
public bool TryUnlockData()
Public Attributes
IsNull
public bool IsNull => value == IntPtr.Zero;
Public Enums
Format
Enumerator | Value | Description |
---|---|---|
R8G8B8A8UNorm | 1 | Corresponding formats: Vulkan: VK_FORMAT_R8G8B8A8_UNORM OpenGL ES: GL_RGBA8 |
R8G8B8X8UNorm | 2 | 32 bits per pixel, 8 bits per channel format where alpha values are ignored (always opaque). Corresponding formats: Vulkan: VK_FORMAT_R8G8B8A8_UNORM OpenGL ES: GL_RGB8 |
R8G8B8UNorm | 3 | Corresponding formats: Vulkan: VK_FORMAT_R8G8B8_UNORM OpenGL ES: GL_RGB8 |
R5G6B5UNorm | 4 | Corresponding formats: Vulkan: VK_FORMAT_R5G6B5_UNORM_PACK16 OpenGL ES: GL_RGB565 |
R16G16B16A16Float | 0x16 | Corresponding formats: Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT OpenGL ES: GL_RGBA16F |
R10G10B10A2UNorm | 0x2b | Corresponding formats: Vulkan: VK_FORMAT_A2B10G10R10_UNORM_PACK32 OpenGL ES: GL_RGB10_A2 |
Blob | 0x21 | Opaque binary blob format. Must have height 1 and one layer, with width equal to the buffer size in bytes. Corresponds to Vulkan buffers and OpenGL buffer objects. Can be bound to the latter using GL_EXT_external_buffer. |
D16UNorm | 0x30 | Corresponding formats: Vulkan: VK_FORMAT_D16_UNORM OpenGL ES: GL_DEPTH_COMPONENT16 |
D24UNorm | 0x31 | Corresponding formats: Vulkan: VK_FORMAT_X8_D24_UNORM_PACK32 OpenGL ES: GL_DEPTH_COMPONENT24 |
D24UNormS8UInt | 0x32 | Corresponding formats: Vulkan: VK_FORMAT_D24_UNORM_S8_UINT OpenGL ES: GL_DEPTH24_STENCIL8 |
D32Float | 0x33 | Corresponding formats: Vulkan: VK_FORMAT_D32_SFLOAT OpenGL ES: GL_DEPTH_COMPONENT32F |
D32FloatS8UInt | 0x34 | Corresponding formats: Vulkan: VK_FORMAT_D32_SFLOAT_S8_UINT OpenGL ES: GL_DEPTH32F_STENCIL8 |
S8UInt | 0x35 | Corresponding formats: Vulkan: VK_FORMAT_S8_UINT OpenGL ES: GL_STENCIL_INDEX8 |
Y8Cb8Cr8_420 | 0x23 | YUV 420 888 format. Must have an even width and height. Can be accessed in OpenGL shaders through an external sampler. Does not support mip-maps cube-maps or multi-layered textures. |
YCbCrP010 | 0x36 | YUV P010 format. Must have an even width and height. Can be accessed in OpenGL shaders through an external sampler. Does not support mip-maps cube-maps or multi-layered textures. |
R8UNorm | 0x38 | Corresponding formats: Vulkan: VK_FORMAT_R8_UNORM OpenGL ES: GR_GL_R8 |
Usage
Enumerator | Value | Description |
---|---|---|
CpuReadNever | 0UL | The buffer will never be locked for direct CPU reads using the AHardwareBuffer_lock() function. Note that reading the buffer using OpenGL or Vulkan functions or memory mappings is still allowed. |
CpuReadRarely | 2UL | The buffer will sometimes be locked for direct CPU reads using the AHardwareBuffer_lock() function. Note that reading the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag. |
CpuReadOften | 3UL | The buffer will often be locked for direct CPU reads using the AHardwareBuffer_lock() function. Note that reading the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag. |
CpuReadMask | 0xFUL | CPU read value mask. |
CpuWriteNever | 0UL << 4 | The buffer will never be locked for direct CPU writes using the AHardwareBuffer_lock() function. Note that writing the buffer using OpenGL or Vulkan functions or memory mappings is still allowed. |
CpuWriteRarely | 2UL << 4 | The buffer will sometimes be locked for direct CPU writes using the AHardwareBuffer_lock() function. Note that writing the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag. |
CpuWriteOften | 3UL << 4 | The buffer will often be locked for direct CPU writes using the AHardwareBuffer_lock() function. Note that writing the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag. |
CpuWriteMask | 0xFUL << 4 | CPU write value mask. |
GpuSampledImage | 1UL << 8 | The buffer will be read from by the GPU as a texture. |
GpuFramebuffer | 1UL << 9 | The buffer will be written to by the GPU as a framebuffer attachment. |
GpuColorOutput | GpuFramebuffer | The buffer will be written to by the GPU as a framebuffer attachment. Note that the name of this flag is somewhat misleading: it does not imply that the buffer contains a color format. A buffer with depth or stencil format that will be used as a framebuffer attachment should also have this flag. Use the equivalent flag AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER to avoid this confusion. |
ComposerOverlay | 1UL << 11 | The buffer will be used as a composer HAL overlay layer. This flag is currently only needed when using ASurfaceTransaction_setBuffer to set a buffer. In all other cases, the framework adds this flag internally to buffers that could be presented in a composer overlay. ASurfaceTransaction_setBuffer is special because it uses buffers allocated directly through AHardwareBuffer_allocate instead of buffers allocated by the framework. |
ProtectedContent | 1UL << 14 | The buffer is protected from direct CPU access or being read by non-secure hardware, such as video encoders. This flag is incompatible with CPU read and write flags. It is mainly used when handling DRM video. Refer to the EGL extension EGL_EXT_protected_content and GL extension GL_EXT_protected_textures for more information on how these buffers are expected to behave. |
VideoEncode | 1UL << 16 | The buffer will be read by a hardware video encoder. |
SensorDirectData | 1UL << 23 | The buffer will be used for direct writes from sensors. When this flag is present, the format must be AHARDWAREBUFFER_FORMAT_BLOB. |
GpuDataBuffer | 1UL << 24 | The buffer will be used as a shader storage or uniform buffer object. When this flag is present, the format must be AHARDWAREBUFFER_FORMAT_BLOB. |
GpuCubeMap | 1UL << 25 | The buffer will be used as a cube map texture. When this flag is present, the buffer must have a layer count that is a multiple of 6. Note that buffers with this flag must be bound to OpenGL textures using the extension GL_EXT_EGL_image_storage instead of GL_KHR_EGL_image. |
GpuMipmapComplete | 1UL << 26 | The buffer contains a complete mipmap hierarchy. Note that buffers with this flag must be bound to OpenGL textures using the extension GL_EXT_EGL_image_storage instead of GL_KHR_EGL_image. |
Vendor0 | 1UL << 28 | |
Vendor1 | 1UL << 29 | |
Vendor2 | 1UL << 30 | |
Vendor3 | 1UL << 31 | |
Vendor4 | 1UL << 48 | |
Vendor5 | 1UL << 49 | |
Vendor6 | 1UL << 50 | |
Vendor7 | 1UL << 51 | |
Vendor8 | 1UL << 52 | |
Vendor9 | 1UL << 53 | |
Vendor10 | 1UL << 54 | |
Vendor11 | 1UL << 55 | |
Vendor12 | 1UL << 56 | |
Vendor13 | 1UL << 57 | |
Vendor14 | 1UL << 58 | |
Vendor15 | 1UL << 59 | |
Vendor16 | 1UL << 60 | |
Vendor17 | 1UL << 61 | |
Vendor18 | 1UL << 62 | |
Vendor19 | 1UL << 63 |