HardwareBufferJni


@RequiresApi(value = 26)
@ExperimentalApi
public final class HardwareBufferJni implements HardwareBufferJniWrapper


JNI methods for HardwareBuffer interaction.

Summary

Constants

static final HardwareBufferJni

Public methods

native boolean
nativeBindEGLImage(int target, long eglImageHandle)

Binds an EGLImage to the specified texture target.

native boolean

Copies a Bitmap to a HardwareBuffer.

native boolean

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

native long
nativeCreateEglImageFromHardwareBuffer(
    long displayHandle,
    HardwareBuffer hardwareBuffer
)

Creates an EGLImage from a HardwareBuffer.

native boolean
nativeDestroyEGLImage(long displayHandle, long imageHandle)

Destroys an EGLImage.

Inherited methods

From androidx.media3.common.video.HardwareBufferNativeHelpers
abstract boolean

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

Constants

INSTANCE

public static final HardwareBufferJni INSTANCE

Public methods

nativeBindEGLImage

native public boolean nativeBindEGLImage(int target, long eglImageHandle)

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

nativeCopyBitmapToHardwareBuffer

native public boolean nativeCopyBitmapToHardwareBuffer(Bitmap bitmap, HardwareBuffer hb)

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

The destination HardwareBuffer must have USAGE_CPU_WRITE_OFTEN usage.

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

nativeCopyHardwareBufferToHardwareBuffer

native public boolean nativeCopyHardwareBufferToHardwareBuffer(
    HardwareBuffer srcHb,
    HardwareBuffer dstHb
)

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

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

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

nativeCreateEglImageFromHardwareBuffer

native public long nativeCreateEglImageFromHardwareBuffer(
    long displayHandle,
    HardwareBuffer hardwareBuffer
)

Creates an EGLImage from a HardwareBuffer.

nativeDestroyEGLImage

native public boolean nativeDestroyEGLImage(long displayHandle, long imageHandle)

Destroys an EGLImage. Returns whether the deletion is successful.