HardwareBufferJniWrapper


@ExperimentalApi
interface HardwareBufferJniWrapper : HardwareBufferNativeHelpers

Known direct subclasses
HardwareBufferJni

JNI methods for HardwareBuffer interaction and native ByteBuffer queries in libmedia3EffectJNI.


Wrapper for HardwareBuffer interaction and native ByteBuffer query JNI methods.

Summary

Public functions

Boolean
@RequiresApi(value = 26)
nativeBindEGLImage(target: Int, eglImageHandle: Long)

Binds an EGLImage to the specified texture target.

Boolean

Copies a Bitmap to a HardwareBuffer.

Boolean

Copies the contents of a source HardwareBuffer to a destination HardwareBuffer.

Long
@RequiresApi(value = 26)
nativeCreateEglImageFromHardwareBuffer(
    displayHandle: Long,
    hardwareBuffer: HardwareBuffer
)

Creates an EGLImage from a HardwareBuffer.

Boolean
@RequiresApi(value = 26)
nativeDestroyEGLImage(displayHandle: Long, imageHandle: Long)

Destroys an EGLImage.

open Boolean
nativeIsNv21(uBuffer: ByteBuffer, vBuffer: ByteBuffer)

Returns whether a semi-planar YUV frame's chroma planes are in NV21 order.

Public functions

nativeBindEGLImage

@RequiresApi(value = 26)
fun nativeBindEGLImage(target: Int, eglImageHandle: Long): Boolean

Binds an EGLImage to the specified texture target. Returns whether the binding is successful.

nativeCopyBitmapToHardwareBuffer

@RequiresApi(value = 26)
fun nativeCopyBitmapToHardwareBuffer(bitmap: Bitmap, hb: HardwareBuffer): Boolean

Copies a Bitmap to a HardwareBuffer. Returns whether the copy is successful.

The destination HardwareBuffer must have HardwareBuffer.USAGE_CPU_WRITE_OFTEN usage.

The source Bitmap.Config must match the destination HardwareBuffer.getFormat, and be either Bitmap.Config.ARGB_8888 and HardwareBuffer.RGBA_8888 or Bitmap.Config.RGBA_1010102 and HardwareBuffer.RGBA_1010102.

nativeCopyHardwareBufferToHardwareBuffer

@RequiresApi(value = 26)
fun nativeCopyHardwareBufferToHardwareBuffer(
    srcHb: HardwareBuffer,
    dstHb: HardwareBuffer
): Boolean

Copies the contents of a source HardwareBuffer to a destination HardwareBuffer. Returns whether the copy is successful.

The source HardwareBuffer must have HardwareBuffer.USAGE_CPU_READ_OFTEN usage, and the destination HardwareBuffer must have HardwareBuffer.USAGE_CPU_WRITE_OFTEN usage.

The formats of the source and destination buffers must match, and be either HardwareBuffer.RGBA_8888 or HardwareBuffer.RGBA_1010102.

nativeCreateEglImageFromHardwareBuffer

@RequiresApi(value = 26)
fun nativeCreateEglImageFromHardwareBuffer(
    displayHandle: Long,
    hardwareBuffer: HardwareBuffer
): Long

Creates an EGLImage from a HardwareBuffer.

nativeDestroyEGLImage

@RequiresApi(value = 26)
fun nativeDestroyEGLImage(displayHandle: Long, imageHandle: Long): Boolean

Destroys an EGLImage. Returns whether the deletion is successful.

nativeIsNv21

open fun nativeIsNv21(uBuffer: ByteBuffer, vBuffer: ByteBuffer): Boolean

Returns whether a semi-planar YUV frame's chroma planes are in NV21 order.

uBuffer and vBuffer must be direct ByteBuffer views of the same interleaved chroma memory, starting 1 byte apart (with uBuffer first for NV12 and vBuffer first for NV21). If either buffer is not a direct ByteBuffer or the buffers are not views of the same interleaved chroma memory, the return value is undefined.

The default implementation throws UnsupportedOperationException.