Skip to main content

OH_NativeImage_AcquireLatestNativeWindowBuffer

Function OH_NativeImage_AcquireLatestNativeWindowBuffer 

Source
pub unsafe extern "C" fn OH_NativeImage_AcquireLatestNativeWindowBuffer(
    image: *mut OH_NativeImage,
    nativeWindowBuffer: *mut *mut NativeWindowBuffer,
    fenceFd: *mut i32,
) -> i32
Available on crate features native_image and api-22 only.
Expand description

Acquire a latest OHNativeWindowBuffer through an OH_NativeImage instance for content consumer.

This method can get the latest OHNativeWindowBuffer and drop other OHNativeWindowBuffers, but consumer can receive the callbacks of all available buffers.

This method can not be used at the same time with OH_NativeImage_UpdateSurfaceImage.

This method will create an OHNativeWindowBuffer.

If there is a situation when OHNativeWindowBuffer is still used after calling OH_NativeImage_ReleaseNativeWindowBuffer, you must pay attention to the following two points.

  1. When using OHNativeWindowBuffer, need to increase its reference count by OH_NativeWindow_NativeObjectReference.

  2. When the OHNativeWindowBuffer is used up, its reference count needs to be decremented by OH_NativeWindow_NativeObjectUnreference.

This interface needs to be used in conjunction with OH_NativeImage_ReleaseNativeWindowBuffer, otherwise memory leaks will occur.

When the fenceFd is used up, you need to close it.

Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage

§Arguments

  • image - Indicates the pointer to a OH_NativeImage instance.

  • nativeWindowBuffer - Indicates the pointer to an OHNativeWindowBuffer point.

  • fenceFd - Indicates the pointer to a file descriptor handle.

§Returns

  • [NATIVE_ERROR_OK] 0 - Success. [NATIVE_ERROR_INVALID_ARGUMENTS] 40001000 - image, nativeWindowBuffer, fenceFd is NULL. [NATIVE_ERROR_NO_BUFFER] 40601000 - No buffer for consume.

Available since API-level: 22

Version: 1.0