HardwareBufferNativeHelpers


@RequiresApi(value = 26)
@ExperimentalApi
public interface HardwareBufferNativeHelpers


Wrapper for HardwareBuffer JNI methods.

Summary

Public methods

abstract boolean

Copies a Bitmap to a HardwareBuffer.

abstract boolean

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

Public methods

nativeCopyBitmapToHardwareBuffer

abstract boolean nativeCopyBitmapToHardwareBuffer(Bitmap bitmap, HardwareBuffer hb)

Copies a Bitmap to a HardwareBuffer.

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.

Parameters
Bitmap bitmap

The source bitmap.

HardwareBuffer hb

The destination hardware buffer.

Returns
boolean

Whether the copy is successful.

nativeCopyHardwareBufferToHardwareBuffer

abstract boolean nativeCopyHardwareBufferToHardwareBuffer(
    HardwareBuffer srcHb,
    HardwareBuffer dstHb
)

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

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.

Parameters
HardwareBuffer srcHb

The source hardware buffer.

HardwareBuffer dstHb

The destination hardware buffer.

Returns
boolean

Whether the copy is successful.