HardwareBuffer
class HardwareBuffer : AutoCloseable, Parcelable
| kotlin.Any | |
| ↳ | android.hardware.HardwareBuffer |
HardwareBuffer wraps a native AHardwareBuffer object, which is a low-level object representing a memory buffer accessible by various hardware units. HardwareBuffer allows sharing buffers across different application processes. In particular, HardwareBuffers may be mappable to memory accessible to various hardware systems, such as the GPU, a sensor or context hub, or other auxiliary processing units. For more information, see the NDK documentation for AHardwareBuffer.
Summary
| Constants | |
|---|---|
| static Int |
32-bit packed format that has 2-bit A, 10-bit R, G, and B components, in that order, from the most-significant bits to the least-significant bits. |
| static Int |
32-bit packed format that has 2-bit unused, 10-bit R, G, and B components, in that order, from the most-significant bits to the least-significant bits. |
| static Int |
Format: opaque format used for raw data transfer; must have a height of 1 |
| static Int |
Format: 24 bits depth, 8 bits stencil |
| static Int |
Format: 32 bits depth, 8 bits stencil |
| static Int |
Format: 16 bits depth |
| static Int |
Format: 24 bits depth |
| static Int |
Format: 32 bits depth |
| static Int |
Format: 10 bits each red, green, blue, alpha |
| static Int |
Format: 10 bits each red, green, blue, 2 bits alpha |
| static Int |
64-bit format that has 12-bit R, G, B, and A components, in that order, from the lowest memory address to the highest memory address. |
| static Int |
64-bit format that has 14-bit R, G, B, and A components, in that order, from the lowest memory address to the highest memory address. |
| static Int |
Format: 8 bits each red, green, blue, alpha. |
| static Int |
Format: 16 bits each red, green, blue, alpha |
| static Int |
Format: 8 bits each red, green, blue, alpha, alpha is always 0xFF |
| static Int |
Format: 5 bits each red and blue, 6 bits green, no alpha |
| static Int |
Format: 8 bits each red, green, blue, no alpha |
| static Int |
32-bit format that has 12-bit R and G components, in that order, from the lowest memory address to the highest memory address. |
| static Int |
32-bit format that has 14-bit R and G components, in that order, from the lowest memory address to the highest memory address. |
| static Int |
Format: 16 bits each red, green. |
| static Int |
16 bit format with a single 12-bit component. |
| static Int |
16 bit format with a single 14-bit component. |
| static Int |
Format: 16 bits red. |
| static Int |
Format: 8 bits red |
| static Int |
Format: 8 bits stencil |
| static Long |
The buffer will be used as a hardware composer overlay layer. |
| static Long |
Usage: The buffer will often be read by the CPU |
| static Long |
Usage: The buffer will sometimes be read by the CPU. |
| static Long |
Usage: The buffer will often be written to by the CPU |
| static Long |
Usage: The buffer will sometimes be written to by the CPU |
| static Long |
Usage: The buffer is used for front-buffer rendering. |
| static Long |
Usage: The buffer will be written to by the GPU |
| static Long |
Usage: The buffer will be used as a cube map texture |
| static Long |
Usage: The buffer will be used as a shader storage or uniform buffer object |
| static Long |
Usage: The buffer contains a complete mipmap hierarchy |
| static Long |
Usage: The buffer will be read from by the GPU |
| static Long |
Usage: The buffer must not be used outside of a protected hardware path |
| static Long |
Usage: The buffer will be used for sensor direct data |
| static Long |
Usage: The buffer will be read by a hardware video encoder |
| static Int |
Format: Planar YCbCr 420; must have an even width and height |
| static Int |
Android YUV P010 format. |
| static Int |
Android YUV P210 format. |
| Inherited constants | |
|---|---|
| Public methods | |
|---|---|
| Unit |
close()Destroys this buffer immediately. |
| static HardwareBuffer |
Creates a new |
| Int |
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| Int |
Returns the @Format of this buffer. |
| Int |
Returns the height of this buffer in pixels. |
| Long |
getId()Returns the system-wide unique id for this buffer This can be useful as a cache key for associating additional objects with a given HardwareBuffer, such as associating an imported EGLImage with the target HardwareBuffer when processing a stream of buffers from ImageReader. |
| Int |
Returns the number of layers in this buffer. |
| Long |
getUsage()Returns the usage flags of the usage hints set on this buffer. |
| Int |
getWidth()Returns the width of this buffer in pixels. |
| Boolean |
isClosed()Indicates whether this buffer has been closed. |
| static Boolean |
Queries whether the given buffer description is supported by the system. |
| Unit |
writeToParcel(dest: Parcel, flags: Int)Flatten this object in to a Parcel. |
| Protected methods | |
|---|---|
| Unit |
finalize()Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
| Properties | |
|---|---|
| static Parcelable.Creator<HardwareBuffer!> | |
Constants
BGRA_1010102
static val BGRA_1010102: Int
32-bit packed format that has 2-bit A, 10-bit R, G, and B components, in that order, from the most-significant bits to the least-significant bits. The component values are unsigned normalized to the range [0, 1], whose interpretation is defined by the dataspace.
Value: 67BGRX_1010102
static val BGRX_1010102: Int
32-bit packed format that has 2-bit unused, 10-bit R, G, and B components, in that order, from the most-significant bits to the least-significant bits. The component values are unsigned normalized to the range [0, 1], whose interpretation is defined by the dataspace.
Value: 68BLOB
static val BLOB: Int
Format: opaque format used for raw data transfer; must have a height of 1
Value: 33DS_24UI8
static val DS_24UI8: Int
Format: 24 bits depth, 8 bits stencil
Value: 50DS_FP32UI8
static val DS_FP32UI8: Int
Format: 32 bits depth, 8 bits stencil
Value: 52RGBA_10101010
static val RGBA_10101010: Int
Format: 10 bits each red, green, blue, alpha
Value: 59RGBA_1010102
static val RGBA_1010102: Int
Format: 10 bits each red, green, blue, 2 bits alpha
Value: 43RGBA_12121212
static val RGBA_12121212: Int
64-bit format that has 12-bit R, G, B, and A components, in that order, from the lowest memory address to the highest memory address. The format is 64-bit unsigned integer that has a 12-bit R component in the top 12 bits of the word in bytes 0..1, a 12-bit G component in the top 12 bits of the word in bytes 2..3, a 12-bit B component in the top 12 bits of the word in bytes 4..5, and a 12-bit A component in the top 12 bits of the word in bytes 6..7, with the bottom 4 bits of each word unused.
Value: 65RGBA_14141414
static val RGBA_14141414: Int
64-bit format that has 14-bit R, G, B, and A components, in that order, from the lowest memory address to the highest memory address. The format is 64-bit unsigned integer that has a 14-bit R component in the top 14 bits of the word in bytes 0..1, a 14-bit G component in the top 14 bits of the word in bytes 2..3, a 14-bit B component in the top 14 bits of the word in bytes 4..5, and a 14-bit A component in the top 14 bits of the word in bytes 6..7, with the bottom 2 bits of each word unused.
Value: 66RGBA_8888
static val RGBA_8888: Int
Format: 8 bits each red, green, blue, alpha.
Value is one of the following:
RGBA_8888RGBA_FP16RGBA_1010102RGBX_8888RGB_888RGB_565BLOBYCBCR_420_888D_16D_24DS_24UI8D_FP32DS_FP32UI8S_UI8YCBCR_P010YCBCR_P210R_8R_16RG_1616RGBA_10101010R_12R_14RG_1212RG_1414RGBA_12121212RGBA_14141414BGRA_1010102BGRX_1010102
Value: 1RGBA_FP16
static val RGBA_FP16: Int
Format: 16 bits each red, green, blue, alpha
Value: 22RGBX_8888
static val RGBX_8888: Int
Format: 8 bits each red, green, blue, alpha, alpha is always 0xFF
Value: 2RGB_565
static val RGB_565: Int
Format: 5 bits each red and blue, 6 bits green, no alpha
Value: 4RGB_888
static val RGB_888: Int
Format: 8 bits each red, green, blue, no alpha
Value: 3RG_1212
static val RG_1212: Int
32-bit format that has 12-bit R and G components, in that order, from the lowest memory address to the highest memory address. The format is 32-bit unsigned integer that has a 12-bit R component in the top 12 bits of the word in bytes 0..1, and a 12-bit G component in the top 12 bits of the word in bytes 2..3, with the bottom 4 bits of each word unused.
Value: 63RG_1414
static val RG_1414: Int
32-bit format that has 14-bit R and G components, in that order, from the lowest memory address to the highest memory address. The format is 32-bit unsigned integer that has a 14-bit R component in the top 14 bits of the word in bytes 0..1, and a 14-bit G component in the top 14 bits of the word in bytes 2..3, with the bottom 2 bits of each word unused.
Value: 64RG_1616
static val RG_1616: Int
Format: 16 bits each red, green. When sampled on the GPU this is represented as an unsigned integer instead of implicit unsigned normalize. For more information see https://www.khronos.org/opengl/wiki/Normalized_Integer
Value: 58R_12
static val R_12: Int
16 bit format with a single 12-bit component. The format is 16 bits unsigned integer that has 12 bits of R component in the top 12 bits of the 16-bit word with the bottom 4 bits unused.
Value: 61R_14
static val R_14: Int
16 bit format with a single 14-bit component. The format is 16-bit unsigned integer that has 14 bits of R component in the top 14 bits of the 16-bit word with the bottom 2 bits unused.
Value: 62R_16
static val R_16: Int
Format: 16 bits red. When sampled on the GPU this is represented as an unsigned integer instead of implicit unsigned normalize. For more information see https://www.khronos.org/opengl/wiki/Normalized_Integer
Value: 57USAGE_COMPOSER_OVERLAY
static val USAGE_COMPOSER_OVERLAY: Long
The buffer will be used as a hardware composer overlay layer. That is, it will be displayed using the system compositor via SurfaceControl This flag is currently only needed when using android.view.SurfaceControl.Transaction.setBuffer(SurfaceControl,HardwareBuffer) to set a buffer. In all other cases, the framework adds this flag internally to buffers that could be presented in a composer overlay.
Value: 2048LUSAGE_CPU_READ_OFTEN
static val USAGE_CPU_READ_OFTEN: Long
Usage: The buffer will often be read by the CPU
Value: 3LUSAGE_CPU_READ_RARELY
static val USAGE_CPU_READ_RARELY: Long
Usage: The buffer will sometimes be read by the CPU.
Value is either 0 or a combination of the following:
USAGE_CPU_READ_RARELYUSAGE_CPU_READ_OFTENUSAGE_CPU_WRITE_RARELYUSAGE_CPU_WRITE_OFTENUSAGE_GPU_SAMPLED_IMAGEUSAGE_GPU_COLOR_OUTPUTUSAGE_COMPOSER_OVERLAYUSAGE_PROTECTED_CONTENTUSAGE_VIDEO_ENCODEUSAGE_GPU_DATA_BUFFERUSAGE_SENSOR_DIRECT_DATAUSAGE_GPU_CUBE_MAPUSAGE_GPU_MIPMAP_COMPLETEUSAGE_FRONT_BUFFER
Value: 2LUSAGE_CPU_WRITE_OFTEN
static val USAGE_CPU_WRITE_OFTEN: Long
Usage: The buffer will often be written to by the CPU
Value: 48LUSAGE_CPU_WRITE_RARELY
static val USAGE_CPU_WRITE_RARELY: Long
Usage: The buffer will sometimes be written to by the CPU
Value: 32LUSAGE_FRONT_BUFFER
static val USAGE_FRONT_BUFFER: Long
Usage: The buffer is used for front-buffer rendering. When front-buffering rendering is specified, different usages may adjust their behavior as a result. For example, when used as USAGE_GPU_COLOR_OUTPUT the buffer will behave similar to a single-buffered window. When used with USAGE_COMPOSER_OVERLAY, the system will try to prioritize the buffer receiving an overlay plane & avoid caching it in intermediate composition buffers.
Value: 4294967296LUSAGE_GPU_COLOR_OUTPUT
static val USAGE_GPU_COLOR_OUTPUT: Long
Usage: The buffer will be written to by the GPU
Value: 512LUSAGE_GPU_CUBE_MAP
static val USAGE_GPU_CUBE_MAP: Long
Usage: The buffer will be used as a cube map texture
Value: 33554432LUSAGE_GPU_DATA_BUFFER
static val USAGE_GPU_DATA_BUFFER: Long
Usage: The buffer will be used as a shader storage or uniform buffer object
Value: 16777216LUSAGE_GPU_MIPMAP_COMPLETE
static val USAGE_GPU_MIPMAP_COMPLETE: Long
Usage: The buffer contains a complete mipmap hierarchy
Value: 67108864LUSAGE_GPU_SAMPLED_IMAGE
static val USAGE_GPU_SAMPLED_IMAGE: Long
Usage: The buffer will be read from by the GPU
Value: 256LUSAGE_PROTECTED_CONTENT
static val USAGE_PROTECTED_CONTENT: Long
Usage: The buffer must not be used outside of a protected hardware path
Value: 16384L