1e41f4b71Sopenharmony_ci# NativeWindow 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe **NativeWindow** module provides the **NativeWindow** capability for connection to the EGL. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**Since**: 8 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Summary 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci### Files 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| Name| Description| 19e41f4b71Sopenharmony_ci| -------- | -------- | 20e41f4b71Sopenharmony_ci| [external_window.h](external__window_8h.md) | Declares the functions for obtaining and using **NativeWindow**.| 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci### Structs 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| Name| Description| 26e41f4b71Sopenharmony_ci| -------- | -------- | 27e41f4b71Sopenharmony_ci| struct [Region](_region.md) | Describes the rectangle (dirty region) where the content is to be updated in the local **OHNativeWindow**.| 28e41f4b71Sopenharmony_ci| struct [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | Describes the HDR metadata.<br>**Deprecated**: This struct is deprecated since API version 10. No substitute is provided.| 29e41f4b71Sopenharmony_ci| struct [OHExtDataHandle](_o_h_ext_data_handle.md) | Describes the extended data handle.<br>**Deprecated**: This struct is deprecated since API version 10. No substitute is provided.| 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci### Types 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci| Name| Description| 35e41f4b71Sopenharmony_ci| -------- | -------- | 36e41f4b71Sopenharmony_ci| typedef struct [OHIPCParcel](#ohipcparcel) [OHIPCParcel](#ohipcparcel) | Provides access to **OHIPCParcel**, which is an IPC parcelable object.| 37e41f4b71Sopenharmony_ci| typedef struct NativeWindow [OHNativeWindow](#ohnativewindow) | Provides the capability of accessing the **OHNativeWindow**.| 38e41f4b71Sopenharmony_ci| typedef struct NativeWindowBuffer [OHNativeWindowBuffer](#ohnativewindowbuffer) | Provides the capability of accessing the **OHNativeWindowBuffer**.| 39e41f4b71Sopenharmony_ci| typedef struct [Region](_region.md) [Region](#region) | Defines a struct for the rectangle (dirty region) where the content is to be updated in the local **OHNativeWindow**.| 40e41f4b71Sopenharmony_ci| typedef enum [OHNativeErrorCode](#ohnativeerrorcode) [OHNativeErrorCode](#ohnativeerrorcode) | Defines an enum for the error codes. | 41e41f4b71Sopenharmony_ci| typedef enum [NativeWindowOperation](#nativewindowoperation) [NativeWindowOperation](#nativewindowoperation) | Defines an enum for the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. | 42e41f4b71Sopenharmony_ci| typedef enum [OHScalingModeV2](#ohscalingmodev2) [OHScalingModeV2](#ohscalingmodev2) | Defines an enum for the rendering scaling modes. | 43e41f4b71Sopenharmony_ci| typedef enum [OHSurfaceSource](#ohsurfacesource) [OHSurfaceSource](#ohsurfacesource) | Defines an enum for the sources of content displayed in the local window.| 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci### Enums 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci| Name| Description| 48e41f4b71Sopenharmony_ci| -------- | -------- | 49e41f4b71Sopenharmony_ci| [NativeWindowOperation](#nativewindowoperation-1) {<br>SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT,<br>GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE,<br>SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT,<br>SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM,<br>SET_UI_TIMESTAMP, GET_BUFFERQUEUE_SIZE, SET_SOURCE_TYPE, GET_SOURCE_TYPE,<br>SET_APP_FRAMEWORK_TYPE, GET_APP_FRAMEWORK_TYPE, SET_HDR_WHITE_POINT_BRIGHTNESS, SET_SDR_WHITE_POINT_BRIGHTNESS,<br>SET_DESIRED_PRESENT_TIMESTAMP = 24<br>} | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function.| 50e41f4b71Sopenharmony_ci| [OHScalingMode](#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | Enumerates the scaling modes.<br>**Deprecated**: This enum is deprecated since API version 10. No substitute is provided.| 51e41f4b71Sopenharmony_ci| [OHScalingModeV2](#ohscalingmodev2-1) {<br>OH_SCALING_MODE_FREEZE_V2 = 0, OH_SCALING_MODE_SCALE_TO_WINDOW_V2, OH_SCALING_MODE_SCALE_CROP_V2, OH_SCALING_MODE_NO_SCALE_CROP_V2,<br>OH_SCALING_MODE_SCALE_FIT_V2<br>} | Enumerates the rendering scaling modes. | 52e41f4b71Sopenharmony_ci| [OHHDRMetadataKey](#ohhdrmetadatakey) {<br>OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3,<br>OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7,<br>OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,<br>OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13<br>} | Enumerates the HDR metadata keys.<br>**Deprecated**: This enum is deprecated since API version 10. No substitute is provided.| 53e41f4b71Sopenharmony_ci| [OHNativeErrorCode](#ohnativeerrorcode-1) {<br>NATIVE_ERROR_OK = 0, NATIVE_ERROR_INVALID_ARGUMENTS = 40001000, NATIVE_ERROR_NO_PERMISSION = 40301000, NATIVE_ERROR_NO_BUFFER = 40601000,<br>NATIVE_ERROR_NO_CONSUMER = 41202000, NATIVE_ERROR_NOT_INIT = 41203000, NATIVE_ERROR_CONSUMER_CONNECTED = 41206000, NATIVE_ERROR_BUFFER_STATE_INVALID = 41207000,<br>NATIVE_ERROR_BUFFER_IN_CACHE = 41208000, NATIVE_ERROR_BUFFER_QUEUE_FULL = 41209000, NATIVE_ERROR_BUFFER_NOT_IN_CACHE = 41210000,NATIVE_ERROR_CONSUMER_DISCONNECTED = 41211000,NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED = 41212000, NATIVE_ERROR_UNSUPPORTED = 50102000,<br>NATIVE_ERROR_UNKNOWN = 50002000, NATIVE_ERROR_HDI_ERROR = 50007000,NATIVE_ERROR_BINDER_ERROR = 50401000,NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, NATIVE_ERROR_EGL_API_FAILED = 60002000<br>} | Enumerates the error codes. | 54e41f4b71Sopenharmony_ci| [OHSurfaceSource](#ohsurfacesource-1) {<br>OH_SURFACE_SOURCE_DEFAULT = 0, OH_SURFACE_SOURCE_UI, OH_SURFACE_SOURCE_GAME, OH_SURFACE_SOURCE_CAMERA,OH_SURFACE_SOURCE_VIDEO<br>} | Enumerates the sources of content displayed in the local window.| 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci### Functions 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci| Name| Description| 59e41f4b71Sopenharmony_ci| -------- | -------- | 60e41f4b71Sopenharmony_ci| [OHNativeWindow](#ohnativewindow) \* [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | Creates an **OHNativeWindow** instance. A new **OHNativeWindow** instance is created each time this function is called. If this function is unavailable, you can create an **OHNativeWindow** instance by calling **OH_NativeImage_AcquireNativeWindow** or through the **XComponent**.| 61e41f4b71Sopenharmony_ci| void [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) ([OHNativeWindow](#ohnativewindow) \*window) | Decreases the reference count of an **OHNativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance.| 62e41f4b71Sopenharmony_ci| [OHNativeWindowBuffer](#ohnativewindowbuffer) \* [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | Creates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called. This function is deprecated since API version 12 and replaced by [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer).| 63e41f4b71Sopenharmony_ci| [OHNativeWindowBuffer](#ohnativewindowbuffer) \* [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer) (OH_NativeBuffer \*nativeBuffer) | Creates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called.| 64e41f4b71Sopenharmony_ci| void [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) ([OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | Decreases the reference count of an **OHNativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance.| 65e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd) | Requests an **OHNativeWindowBuffer** through an **OHNativeWindow** instance for content production.| 66e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **OHNativeWindowBuffer** filled with the produced content to the buffer queue through an **OHNativeWindow** instance for content consumption.| 67e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetLastFlushedBuffer](#oh_nativewindow_getlastflushedbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd, float matrix[16]) | Obtains the **OHNativeWindowBuffer** that was flushed to the buffer queue last time through an **OHNativeWindow** instance.| 68e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | Returns the **OHNativeWindowBuffer** to the buffer queue through an **OHNativeWindow** instance, without filling in any content. The **OHNativeWindowBuffer** can be used for a new request.| 69e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) ([OHNativeWindow](#ohnativewindow) \*window, int code,...) | Sets or obtains the attributes of an **OHNativeWindow** instance, including the width, height, and content format.| 70e41f4b71Sopenharmony_ci| BufferHandle \* [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) ([OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | Obtains the pointer to a **BufferHandle** of an **OHNativeWindowBuffer** instance.| 71e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | Adds the reference count of a native object.| 72e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | Decreases the reference count of a native object and, when the reference count reaches 0, destroys this object.| 73e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | Obtains the magic ID of a native object.| 74e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode) ([OHNativeWindow](#ohnativewindow) \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | Sets a scaling mode for an **OHNativeWindow**.<br>**Deprecated**: This function is deprecated since API version 10. No substitute is provided.| 75e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetMetaData](#oh_nativewindow_nativewindowsetmetadata) ([OHNativeWindow](#ohnativewindow) \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | Sets metadata for an **OHNativeWindow**.<br>**Deprecated**: This function is deprecated since API version 10. No substitute is provided.| 76e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetMetaDataSet](#oh_nativewindow_nativewindowsetmetadataset) ([OHNativeWindow](#ohnativewindow) \*window, uint32_t sequence, [OHHDRMetadataKey](#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets a metadata set for an **OHNativeWindow**.<br>**Deprecated**: This function is deprecated since API version 10. No substitute is provided.| 77e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetTunnelHandle](#oh_nativewindow_nativewindowsettunnelhandle) ([OHNativeWindow](#ohnativewindow) \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | Sets a tunnel handle to an **OHNativeWindow**.<br>**Deprecated**: This function is deprecated since API version 10. No substitute is provided.| 78e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowAttachBuffer](#oh_nativewindow_nativewindowattachbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | Attaches an **OHNativeWindowBuffer** to an **OHNativeWindow** instance.| 79e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowDetachBuffer](#oh_nativewindow_nativewindowdetachbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | Detaches an **OHNativeWindowBuffer** from an **OHNativeWindow** instance.| 80e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetSurfaceId](#oh_nativewindow_getsurfaceid) ([OHNativeWindow](#ohnativewindow) \*window, uint64_t \*surfaceId) | Obtains a surface ID through an **OHNativeWindow**.| 81e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_CreateNativeWindowFromSurfaceId](#oh_nativewindow_createnativewindowfromsurfaceid) (uint64_t surfaceId, [OHNativeWindow](#ohnativewindow) \*\*window) | Creates an **OHNativeWindow** instance based on a surface ID.| 82e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetScalingModeV2](#oh_nativewindow_nativewindowsetscalingmodev2) ([OHNativeWindow](#ohnativewindow) \*window, [OHScalingModeV2](#ohscalingmodev2) scalingMode) | Sets a rendering scaling mode for an **OHNativeWindow** instance. | 83e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetLastFlushedBufferV2](#oh_nativewindow_getlastflushedbufferv2) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd, float matrix[16]) | Obtains the **OHNativeWindowBuffer** that was flushed to the buffer queue last time through an **OHNativeWindow** instance. The difference between this function and **OH_NativeWindow_GetLastFlushedBuffer** lies in the matrix. | 84e41f4b71Sopenharmony_ci| void [OH_NativeWindow_SetBufferHold](#oh_nativewindow_setbufferhold) ([OHNativeWindow](#ohnativewindow) \*window) | Buffers a frame in advance and holds it for the interval of a frame to offset the possible loss of subsequent oversized frames. | 85e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_WriteToParcel](#oh_nativewindow_writetoparcel) ([OHNativeWindow](#ohnativewindow) \*window, [OHIPCParcel](#ohipcparcel) \*parcel) | Writes an **OHNativeWindow** instance to an **OHIPCParcel** instance.| 86e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_ReadFromParcel](#oh_nativewindow_readfromparcel) ([OHIPCParcel](#ohipcparcel) \*parcel, [OHNativeWindow](#ohnativewindow) \*\*window) | Reads an **OHNativeWindow** instance from an **OHIPCParcel** instance.| 87e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_SetColorSpace](#oh_nativewindow_setcolorspace) ([OHNativeWindow](#ohnativewindow) \*window, [OH_NativeBuffer_ColorSpace](_o_h___native_buffer.md#oh_nativebuffer_colorspace) colorSpace) | Sets the color space for an **OHNativeWindow** instance.| 88e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetColorSpace](#oh_nativewindow_getcolorspace) ([OHNativeWindow](#ohnativewindow) \*window, [OH_NativeBuffer_ColorSpace](_o_h___native_buffer.md#oh_nativebuffer_colorspace) \*colorSpace) | Obtains the color space of an **OHNativeWindow** instance.| 89e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_SetMetadataValue](#oh_nativewindow_setmetadatavalue) ([OHNativeWindow](#ohnativewindow) \*window, [OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey) metadataKey, int32_t size, uint8_t \*metaData) | Sets a metadata value for an **OHNativeWindow** instance.| 90e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetMetadataValue](#oh_nativewindow_getmetadatavalue) ([OHNativeWindow](#ohnativewindow) \*window, [OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey) metadataKey, int32_t \*size, uint8_t \*\*metaData) | Obtains the metadata value of an **OHNativeWindow** instance.| 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci## Type Description 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci### OHSurfaceSource 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci``` 97e41f4b71Sopenharmony_citypedef enum OHSurfaceSource OHSurfaceSource 98e41f4b71Sopenharmony_ci``` 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci**Description** 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ciDefines an enum for the sources of content displayed in the local window. 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci**Since**: 12 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci### OHIPCParcel 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci``` 109e41f4b71Sopenharmony_citypedef struct OHIPCParcel OHIPCParcel 110e41f4b71Sopenharmony_ci``` 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Description** 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ciProvides access to **OHIPCParcel**, which is an IPC parcelable object. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**Since**: 12 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci### NativeWindowOperation 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci``` 121e41f4b71Sopenharmony_citypedef enum NativeWindowOperation NativeWindowOperation 122e41f4b71Sopenharmony_ci``` 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci**Description** 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ciDefines an enum for the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**Since**: 8 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci### OHNativeErrorCode 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci``` 133e41f4b71Sopenharmony_citypedef enum OHNativeErrorCode OHNativeErrorCode 134e41f4b71Sopenharmony_ci``` 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**Description** 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ciDefines an enum for the error codes. 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**Since**: 12 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci### OHNativeWindow 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci``` 146e41f4b71Sopenharmony_citypedef struct NativeWindow OHNativeWindow 147e41f4b71Sopenharmony_ci``` 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci**Description** 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ciProvides the capability of accessing the **OHNativeWindow**. 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci**Since**: 8 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci### OHNativeWindowBuffer 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci``` 159e41f4b71Sopenharmony_citypedef struct NativeWindowBuffer OHNativeWindowBuffer 160e41f4b71Sopenharmony_ci``` 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci**Description** 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ciProvides the capability of accessing the **OHNativeWindowBuffer**. 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci**Since**: 8 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci### OHScalingModeV2 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci``` 171e41f4b71Sopenharmony_citypedef enum OHScalingModeV2 OHScalingModeV2 172e41f4b71Sopenharmony_ci``` 173e41f4b71Sopenharmony_ci**Description** 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ciDefines an enum for the rendering scaling modes. 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci**Since**: 12 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci### Region 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci``` 184e41f4b71Sopenharmony_citypedef struct Region Region 185e41f4b71Sopenharmony_ci``` 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci**Description** 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ciDefines the rectangle (dirty region) where the content is to be updated in the local **OHNativeWindow**. 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci**Since**: 8 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci## Enum Description 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci### OHSurfaceSource 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci``` 199e41f4b71Sopenharmony_cienum OHSurfaceSource 200e41f4b71Sopenharmony_ci``` 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**Description** 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ciEnumerates the sources of content displayed in the local window. 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**Since**: 12 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci| Value| Description| 209e41f4b71Sopenharmony_ci| -------- | -------- | 210e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_DEFAULT | Default source.| 211e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_UI | The window content comes from UIs.| 212e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_GAME | The window content comes from games.| 213e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_CAMERA | The window content comes from cameras.| 214e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_VIDEO | The window content comes from videos.| 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci### OHNativeErrorCode 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci``` 219e41f4b71Sopenharmony_cienum OHNativeErrorCode 220e41f4b71Sopenharmony_ci``` 221e41f4b71Sopenharmony_ci**Description** 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ciEnumerates the error codes. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**Since**: 12 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci| Value| Description| 228e41f4b71Sopenharmony_ci| -------- | -------- | 229e41f4b71Sopenharmony_ci| NATIVE_ERROR_OK | The operation is successful. | 230e41f4b71Sopenharmony_ci| NATIVE_ERROR_INVALID_ARGUMENTS | An input parameter is invalid. | 231e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_PERMISSION | You do not have the permission to perform the operation. | 232e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_BUFFER | No buffer is available. | 233e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_CONSUMER | The consumer does not exist. | 234e41f4b71Sopenharmony_ci| NATIVE_ERROR_NOT_INIT | Not initialized. | 235e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_CONNECTED | The consumer is connected. | 236e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_STATE_INVALID | The buffer status does not meet the expectation. | 237e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_IN_CACHE | The buffer is already in the buffer queue. | 238e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_QUEUE_FULL | The queue is full. | 239e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_NOT_IN_CACHE | The buffer is not in the buffer queue. | 240e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_DISCONNECTED | The consumer is disconnected.| 241e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED | No listener is registered on the consumer side.| 242e41f4b71Sopenharmony_ci| NATIVE_ERROR_UNSUPPORTED | The device or platform does not support the operation. | 243e41f4b71Sopenharmony_ci| NATIVE_ERROR_UNKNOWN | Unknown error. Check the log. | 244e41f4b71Sopenharmony_ci| NATIVE_ERROR_HDI_ERROR | Failed to call the HDI. | 245e41f4b71Sopenharmony_ci| NATIVE_ERROR_BINDER_ERROR | Cross-process communication failed. | 246e41f4b71Sopenharmony_ci| NATIVE_ERROR_EGL_STATE_UNKNOWN | The EGL environment is abnormal. | 247e41f4b71Sopenharmony_ci| NATIVE_ERROR_EGL_API_FAILED | Failed to call the EGL APIs. | 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci### NativeWindowOperation 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci``` 253e41f4b71Sopenharmony_cienum NativeWindowOperation 254e41f4b71Sopenharmony_ci``` 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci**Description** 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ciEnumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci**Since**: 8 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci| Value| Description| 263e41f4b71Sopenharmony_ci| -------- | -------- | 264e41f4b71Sopenharmony_ci| SET_BUFFER_GEOMETRY | Setting the geometry for the local window buffer.<br>Variable arguments in the function: [Input] int32_t width and [Input] int32_t height.| 265e41f4b71Sopenharmony_ci| GET_BUFFER_GEOMETRY | Obtaining the geometry of the local window buffer.<br>Variable arguments in the function: [Output] int32_t *height and [Output] int32_t *width.| 266e41f4b71Sopenharmony_ci| GET_FORMAT | Obtaining the format of the local window buffer.<br>Variable argument in the function: [Output] int32_t *format.| 267e41f4b71Sopenharmony_ci| SET_FORMAT | Setting the format for the local window buffer.<br>Variable argument in the function: [Input] int32_t format.| 268e41f4b71Sopenharmony_ci| GET_USAGE | Obtaining the usage mode of the local window buffer.<br>Variable argument in the function: [Output] uint64_t \*usage.| 269e41f4b71Sopenharmony_ci| SET_USAGE | Setting the usage mode for the local window buffer.<br>Variable argument in the function: [Input] uint64_t usage.| 270e41f4b71Sopenharmony_ci| SET_STRIDE | Setting the stride for the local window buffer.<br>Variable argument in the function: [Input] int32_t stride.| 271e41f4b71Sopenharmony_ci| GET_STRIDE | Obtaining the stride of the local window buffer.<br>Variable argument in the function: [Output] int32_t *stride.| 272e41f4b71Sopenharmony_ci| SET_SWAP_INTERVAL | Setting the swap interval for the local window buffer.<br>Variable argument in the function: [Input] int32_t interval.| 273e41f4b71Sopenharmony_ci| GET_SWAP_INTERVAL | Obtaining the swap interval of the local window buffer.<br>Variable argument in the function: [Output] int32_t *interval.| 274e41f4b71Sopenharmony_ci| SET_TIMEOUT | Setting the timeout duration for requesting the local window buffer.<br>Variable argument in the function: [Input] int32_t timeout.| 275e41f4b71Sopenharmony_ci| GET_TIMEOUT | Obtaining the timeout duration for requesting the local window buffer.<br>Variable argument in the function: [Output] int32_t *timeout.| 276e41f4b71Sopenharmony_ci| SET_COLOR_GAMUT | Setting the color gamut for the local window buffer.<br>Variable argument in the function: [Input] int32_t colorGamut.| 277e41f4b71Sopenharmony_ci| GET_COLOR_GAMUT | Obtaining the color gamut of the local window buffer.<br>Variable argument in the function: [Output] int32_t *colorGamut.| 278e41f4b71Sopenharmony_ci| SET_TRANSFORM | Setting the transform for the local window buffer.<br>Variable argument in the function: [Input] int32_t transform.| 279e41f4b71Sopenharmony_ci| GET_TRANSFORM | Obtaining the transform of the local window buffer.<br>Variable argument in the function: [Output] int32_t *transform.| 280e41f4b71Sopenharmony_ci| SET_UI_TIMESTAMP | Setting the UI timestamp for the local window buffer.<br>Variable argument in the function: [Input] uint64_t uiTimestamp.| 281e41f4b71Sopenharmony_ci| GET_BUFFERQUEUE_SIZE<sup>12+</sup> | Obtaining the memory queue size.<br>Variable argument in the function: [Output] int32_t \*size.| 282e41f4b71Sopenharmony_ci| SET_SOURCE_TYPE<sup>12+</sup> | Setting the source of content displayed in the local window.<br>Variable argument in the function: [Input] int32_t sourceType. For details about the available options, see [OHSurfaceSource](#ohsurfacesource).| 283e41f4b71Sopenharmony_ci| GET_SOURCE_TYPE<sup>12+</sup> | Obtaining the source of content displayed in the local window.<br>Variable argument in the function: [Output] int32_t \*sourceType. For details about the available options, see [OHSurfaceSource](#ohsurfacesource).| 284e41f4b71Sopenharmony_ci| SET_APP_FRAMEWORK_TYPE<sup>12+</sup> | Setting the application framework name of the local window.<br>Variable argument in the function: [Input] char\* frameworkType. A maximum of 64 bytes are supported.| 285e41f4b71Sopenharmony_ci| GET_APP_FRAMEWORK_TYPE<sup>12+</sup> | Obtaining the application framework name of the local window.<br>Variable argument in the function: [Output] char\* frameworkType.| 286e41f4b71Sopenharmony_ci| SET_HDR_WHITE_POINT_BRIGHTNESS<sup>12+</sup> | Setting the brightness of HDR white points.<br>Variable arguments in the function: [Input] float brightness. The value range is [0.0f, 1.0f].| 287e41f4b71Sopenharmony_ci| SET_SDR_WHITE_POINT_BRIGHTNESS<sup>12+</sup> | Setting the brightness of SDR white points.<br>Variable arguments in the function: [Input] float brightness. The value range is [0.0f, 1.0f].| 288e41f4b71Sopenharmony_ci| SET_DESIRED_PRESENT_TIMESTAMP<sup>14+</sup> | Setting a timestamp indicating when the local window buffer is expected to show on the screen. The timestamp takes effect only when RenderService is the consumer of the local window and after [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) is called. The next buffer added to the queue by the producer is consumed by RenderService and displayed on the screen only after the expected on-screen time arrives. If there are multiple buffers in the queue from various producers, all of them have set **desiredPresentTimestamp**, and the desired time arrives, the buffer that was enqueued earliest will be pushed back into the queue by the consumer. If the expected on-screen time exceeds the time provided by the consumer by over 1 second, the expected timestamp is ignored. Variable argument in the function: [Input] int64_t desiredPresentTimestamp. The value must be greater than 0 and should be generated by the standard library std::chrono::steady_clock, in nanoseconds.| 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci### OHHDRMetadataKey 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci``` 293e41f4b71Sopenharmony_cienum OHHDRMetadataKey 294e41f4b71Sopenharmony_ci``` 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci**Description** 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ciEnumerates the HDR metadata keys. 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**Since**: 9 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci**Deprecated**: This enum is deprecated since API version 10. No substitute is provided. 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci| Value| Description| 305e41f4b71Sopenharmony_ci| -------- | -------- | 306e41f4b71Sopenharmony_ci| OH_METAKEY_RED_PRIMARY_X | X coordinate of the red primary color.| 307e41f4b71Sopenharmony_ci| OH_METAKEY_RED_PRIMARY_Y | Y coordinate of the red primary color.| 308e41f4b71Sopenharmony_ci| OH_METAKEY_GREEN_PRIMARY_X | X coordinate of the green primary color.| 309e41f4b71Sopenharmony_ci| OH_METAKEY_GREEN_PRIMARY_Y | Y coordinate of the green primary color.| 310e41f4b71Sopenharmony_ci| OH_METAKEY_BLUE_PRIMARY_X | X coordinate of the blue primary color.| 311e41f4b71Sopenharmony_ci| OH_METAKEY_BLUE_PRIMARY_Y | Y coordinate of the blue primary color.| 312e41f4b71Sopenharmony_ci| OH_METAKEY_WHITE_PRIMARY_X | X coordinate of the white point.| 313e41f4b71Sopenharmony_ci| OH_METAKEY_WHITE_PRIMARY_Y | Y coordinate of the white point.| 314e41f4b71Sopenharmony_ci| OH_METAKEY_MAX_LUMINANCE | Maximum luminance.| 315e41f4b71Sopenharmony_ci| OH_METAKEY_MIN_LUMINANCE | Minimum luminance.| 316e41f4b71Sopenharmony_ci| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | Maximum content light level (MaxCLL).| 317e41f4b71Sopenharmony_ci| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | Maximum frame average light level (MaxFALLL).| 318e41f4b71Sopenharmony_ci| OH_METAKEY_HDR10_PLUS | HDR10 Plus.| 319e41f4b71Sopenharmony_ci| OH_METAKEY_HDR_VIVID | Vivid.| 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci### OHScalingMode 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci``` 325e41f4b71Sopenharmony_cienum OHScalingMode 326e41f4b71Sopenharmony_ci``` 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci**Description** 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ciEnumerates the scaling modes. 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**Since**: 9 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci**Deprecated**: This enum is deprecated since API version 10. No substitute is provided. 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci| Value| Description| 337e41f4b71Sopenharmony_ci| -------- | -------- | 338e41f4b71Sopenharmony_ci| OH_SCALING_MODE_FREEZE | The window content cannot be updated before the buffer of the window size is received.| 339e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_TO_WINDOW | The buffer is scaled in two dimensions to match the window size.| 340e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_CROP | The buffer is scaled uniformly so that its smaller size can match the window size.| 341e41f4b71Sopenharmony_ci| OH_SCALING_MODE_NO_SCALE_CROP | The window is cropped to the size of the buffer's cropping rectangle. Pixels outside the cropping rectangle are considered completely transparent.| 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci### OHScalingModeV2 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci``` 347e41f4b71Sopenharmony_cienum OHScalingModeV2 348e41f4b71Sopenharmony_ci``` 349e41f4b71Sopenharmony_ci**Description** 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ciEnumerates the rendering scaling modes. 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci**Since**: 12 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_ci| Value| Description| 356e41f4b71Sopenharmony_ci| -------- | -------- | 357e41f4b71Sopenharmony_ci| OH_SCALING_MODE_FREEZE_V2 | Freezes the window. The window content is not updated until a buffer with the same size as the window is received.| 358e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_TO_WINDOW_V2 | Scales the buffer to match the window size.| 359e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_CROP_V2 | Scales the buffer at the original aspect ratio to enable the smaller side of the buffer to match the window, while making the excess part transparent.| 360e41f4b71Sopenharmony_ci| OH_SCALING_MODE_NO_SCALE_CROP_V2 | Crops the buffer by window size. Pixels outside the cropping rectangle are considered completely transparent.| 361e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_FIT_V2 | Scales the buffer at the original aspect ratio to fully display the buffer content, while filling the unfilled area of the window with the background color. This mode is not available for the<!--Del--> development board and<!--DelEnd--> emulator.| 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci## Function Description 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci### OH_NativeWindow_SetColorSpace() 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci``` 369e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_SetColorSpace (OHNativeWindow *window, OH_NativeBuffer_ColorSpace colorSpace ) 370e41f4b71Sopenharmony_ci``` 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci**Description** 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ciSets the color space for an **OHNativeWindow** instance. 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ciThis function is not thread-safe. 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ci**Since**: 12 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci**Parameters** 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci| Name| Description| 385e41f4b71Sopenharmony_ci| -------- | -------- | 386e41f4b71Sopenharmony_ci| window | Pointer to an [OHNativeWindow](#ohnativewindow) instance.| 387e41f4b71Sopenharmony_ci| colorSpace | Color space. For details about the available options, see [OH_NativeBuffer_ColorSpace](_o_h___native_buffer.md#oh_nativebuffer_colorspace).| 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci**Returns** 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode) otherwise. 392e41f4b71Sopenharmony_ci 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci### OH_NativeWindow_SetMetadataValue() 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci``` 397e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_SetMetadataValue (OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey, int32_t size, uint8_t * metaData ) 398e41f4b71Sopenharmony_ci``` 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci**Description** 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ciSets a metadata value for an **OHNativeWindow** instance. 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_ciThis function is not thread-safe. 405e41f4b71Sopenharmony_ci 406e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci**Since**: 12 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ci**Parameters** 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci| Name| Description| 413e41f4b71Sopenharmony_ci| -------- | -------- | 414e41f4b71Sopenharmony_ci| window | Pointer to an [OHNativeWindow](#ohnativewindow) instance.| 415e41f4b71Sopenharmony_ci| metadataKey | Key of the metadata. For details about the available options, see [OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey).| 416e41f4b71Sopenharmony_ci| size | Size of the uint8_t vector. For details about the available options, see [OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey).| 417e41f4b71Sopenharmony_ci| metaData| Pointer to the uint8_t vector.| 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ci**Returns** 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode) otherwise. 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ci### OH_NativeWindow_GetColorSpace() 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci``` 426e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetColorSpace (OHNativeWindow *window, OH_NativeBuffer_ColorSpace *colorSpace ) 427e41f4b71Sopenharmony_ci``` 428e41f4b71Sopenharmony_ci 429e41f4b71Sopenharmony_ci**Description** 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ciObtains the color space of an **OHNativeWindow** instance. 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ciThis function is not thread-safe. 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci**Since**: 12 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci**Parameters** 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ci| Name| Description| 442e41f4b71Sopenharmony_ci| -------- | -------- | 443e41f4b71Sopenharmony_ci| window | Pointer to an [OHNativeWindow](#ohnativewindow) instance.| 444e41f4b71Sopenharmony_ci| colorSpace | Pointer to the color space. For details about the available options, see [OH_NativeBuffer_ColorSpace](_o_h___native_buffer.md#oh_nativebuffer_colorspace).| 445e41f4b71Sopenharmony_ci 446e41f4b71Sopenharmony_ci**Returns** 447e41f4b71Sopenharmony_ci 448e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode) otherwise. 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci 451e41f4b71Sopenharmony_ci### OH_NativeWindow_GetMetadataValue() 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci``` 454e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetMetadataValue (OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey, int32_t *size, uint8_t **metaData ) 455e41f4b71Sopenharmony_ci``` 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_ci**Description** 458e41f4b71Sopenharmony_ci 459e41f4b71Sopenharmony_ciObtains the metadata value of an **OHNativeWindow** instance. 460e41f4b71Sopenharmony_ci 461e41f4b71Sopenharmony_ciThis function is not thread-safe. 462e41f4b71Sopenharmony_ci 463e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ci**Since**: 12 466e41f4b71Sopenharmony_ci 467e41f4b71Sopenharmony_ci**Parameters** 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ci| Name| Description| 470e41f4b71Sopenharmony_ci| -------- | -------- | 471e41f4b71Sopenharmony_ci| window | Pointer to an [OHNativeWindow](#ohnativewindow) instance.| 472e41f4b71Sopenharmony_ci| metadataKey | Key of the metadata. For details about the available options, see [OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey).| 473e41f4b71Sopenharmony_ci| size | Pointer to the size of the uint8_t vector. For details about the available options, see [OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey).| 474e41f4b71Sopenharmony_ci| metaData| Double pointer to the uint8_t vector.| 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci**Returns** 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode) otherwise. 479e41f4b71Sopenharmony_ci 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ci### OH_NativeWindow_WriteToParcel() 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci``` 484e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_WriteToParcel (OHNativeWindow *window, OHIPCParcel *parcel ) 485e41f4b71Sopenharmony_ci``` 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ci**Description** 488e41f4b71Sopenharmony_ci 489e41f4b71Sopenharmony_ciWrites an **OHNativeWindow** instance to an **OHIPCParcel** instance. 490e41f4b71Sopenharmony_ci 491e41f4b71Sopenharmony_ciThis function is not thread-safe. 492e41f4b71Sopenharmony_ci 493e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ci**Since**: 12 496e41f4b71Sopenharmony_ci 497e41f4b71Sopenharmony_ci**Parameters** 498e41f4b71Sopenharmony_ci 499e41f4b71Sopenharmony_ci| Name| Description| 500e41f4b71Sopenharmony_ci| -------- | -------- | 501e41f4b71Sopenharmony_ci| window | Pointer to an [OHNativeWindow](#ohnativewindow) instance.| 502e41f4b71Sopenharmony_ci| parcel | Pointer to an [OHIPCParcel](#ohipcparcel) instance.| 503e41f4b71Sopenharmony_ci 504e41f4b71Sopenharmony_ci**Returns** 505e41f4b71Sopenharmony_ci 506e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 507e41f4b71Sopenharmony_ci 508e41f4b71Sopenharmony_ci 509e41f4b71Sopenharmony_ci### OH_NativeWindow_ReadFromParcel() 510e41f4b71Sopenharmony_ci 511e41f4b71Sopenharmony_ci``` 512e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_ReadFromParcel (OHIPCParcel *parcel, OHNativeWindow **window ) 513e41f4b71Sopenharmony_ci``` 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci**Description** 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_ciReads an **OHNativeWindow** instance from an **OHIPCParcel** instance. 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ciThis function is not thread-safe. 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci**Since**: 12 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**Parameters** 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci| Name| Description| 528e41f4b71Sopenharmony_ci| -------- | -------- | 529e41f4b71Sopenharmony_ci| parcel | Pointer to an [OHIPCParcel](#ohipcparcel) instance.| 530e41f4b71Sopenharmony_ci| window | Double pointer to an [OHNativeWindow](#ohnativewindow) instance.| 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci**Returns** 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 535e41f4b71Sopenharmony_ci 536e41f4b71Sopenharmony_ci 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci### OH_NativeWindow_GetLastFlushedBufferV2() 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ci``` 541e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetLastFlushedBufferV2 (OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd, float matrix[16] ) 542e41f4b71Sopenharmony_ci``` 543e41f4b71Sopenharmony_ci 544e41f4b71Sopenharmony_ci**Description** 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_ciObtains the **OHNativeWindowBuffer** that was flushed to the buffer queue last time through an **OHNativeWindow** instance. The difference between this function and **OH_NativeWindow_GetLastFlushedBuffer** lies in the matrix. 547e41f4b71Sopenharmony_ci 548e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeWindow_NativeObjectUnreference**. Otherwise, memory leak occurs. 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ciThis function is not thread-safe. 551e41f4b71Sopenharmony_ci 552e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_ci**Since**: 12 555e41f4b71Sopenharmony_ci 556e41f4b71Sopenharmony_ci**Parameters** 557e41f4b71Sopenharmony_ci 558e41f4b71Sopenharmony_ci| Name| Description| 559e41f4b71Sopenharmony_ci| -------- | -------- | 560e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance. | 561e41f4b71Sopenharmony_ci| buffer | Double pointer to an **OHNativeWindowBuffer** instance. | 562e41f4b71Sopenharmony_ci| fenceFd | Pointer to a file descriptor. | 563e41f4b71Sopenharmony_ci| matrix | Retrieved 4*4 transformation matrix. | 564e41f4b71Sopenharmony_ci 565e41f4b71Sopenharmony_ci**Returns** 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ci 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ci### OH_NativeWindow_SetBufferHold() 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci``` 574e41f4b71Sopenharmony_civoid OH_NativeWindow_SetBufferHold (OHNativeWindow *window) 575e41f4b71Sopenharmony_ci``` 576e41f4b71Sopenharmony_ci**Description** 577e41f4b71Sopenharmony_ciBuffers a frame in advance and holds it for the interval of a frame to offset the possible loss of subsequent oversized frames. 578e41f4b71Sopenharmony_ci 579e41f4b71Sopenharmony_ciThis function is not thread-safe. 580e41f4b71Sopenharmony_ci 581e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_ci**Since**: 12 584e41f4b71Sopenharmony_ci 585e41f4b71Sopenharmony_ci**Parameters** 586e41f4b71Sopenharmony_ci 587e41f4b71Sopenharmony_ci| Name| Description| 588e41f4b71Sopenharmony_ci| -------- | -------- | 589e41f4b71Sopenharmony_ci| window | Pointer to an [OHNativeWindow](_o_h___native_image.md#ohnativewindow) instance. | 590e41f4b71Sopenharmony_ci 591e41f4b71Sopenharmony_ci 592e41f4b71Sopenharmony_ci 593e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindow() 594e41f4b71Sopenharmony_ci 595e41f4b71Sopenharmony_ci``` 596e41f4b71Sopenharmony_ciOHNativeWindow* OH_NativeWindow_CreateNativeWindow (void* pSurface) 597e41f4b71Sopenharmony_ci``` 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ci**Description** 600e41f4b71Sopenharmony_ci 601e41f4b71Sopenharmony_ciCreates an **OHNativeWindow** instance. A new **OHNativeWindow** instance is created each time this function is called. If this function is unavailable, you can create an **OHNativeWindow** instance by calling **OH_NativeImage_AcquireNativeWindow** or through the **XComponent**. 602e41f4b71Sopenharmony_ci 603e41f4b71Sopenharmony_ci**Deprecated from**: 12 604e41f4b71Sopenharmony_ci 605e41f4b71Sopenharmony_ci**Substitute**: No substitute is provided. 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 608e41f4b71Sopenharmony_ci 609e41f4b71Sopenharmony_ci**Since**: 8 610e41f4b71Sopenharmony_ci 611e41f4b71Sopenharmony_ci**Parameters** 612e41f4b71Sopenharmony_ci 613e41f4b71Sopenharmony_ci| Name| Description| 614e41f4b71Sopenharmony_ci| -------- | -------- | 615e41f4b71Sopenharmony_ci| pSurface | Pointer to a **ProduceSurface**. The type is **sptr<OHOS::Surface>**.| 616e41f4b71Sopenharmony_ci 617e41f4b71Sopenharmony_ci**Returns** 618e41f4b71Sopenharmony_ci 619e41f4b71Sopenharmony_ciReturns the pointer to the **OHNativeWindow** instance created. 620e41f4b71Sopenharmony_ci 621e41f4b71Sopenharmony_ci 622e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer() 623e41f4b71Sopenharmony_ci 624e41f4b71Sopenharmony_ci``` 625e41f4b71Sopenharmony_ciOHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer (OH_NativeBuffer* nativeBuffer) 626e41f4b71Sopenharmony_ci``` 627e41f4b71Sopenharmony_ci 628e41f4b71Sopenharmony_ci**Description** 629e41f4b71Sopenharmony_ci 630e41f4b71Sopenharmony_ciCreates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called. 631e41f4b71Sopenharmony_ci 632e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeWindow_DestroyNativeWindowBuffer**. Otherwise, memory leak occurs. 633e41f4b71Sopenharmony_ci 634e41f4b71Sopenharmony_ciThis function is not thread-safe. 635e41f4b71Sopenharmony_ci 636e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 637e41f4b71Sopenharmony_ci 638e41f4b71Sopenharmony_ci**Since**: 11 639e41f4b71Sopenharmony_ci 640e41f4b71Sopenharmony_ci**Parameters** 641e41f4b71Sopenharmony_ci 642e41f4b71Sopenharmony_ci| Name| Description| 643e41f4b71Sopenharmony_ci| -------- | -------- | 644e41f4b71Sopenharmony_ci| nativeBuffer | Pointer to an **OH_NativeBuffer** instance.| 645e41f4b71Sopenharmony_ci 646e41f4b71Sopenharmony_ci**Returns** 647e41f4b71Sopenharmony_ci 648e41f4b71Sopenharmony_ciReturns the pointer to the **OHNativeWindowBuffer** instance created. 649e41f4b71Sopenharmony_ci 650e41f4b71Sopenharmony_ci 651e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer() 652e41f4b71Sopenharmony_ci 653e41f4b71Sopenharmony_ci``` 654e41f4b71Sopenharmony_ciOHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void* pSurfaceBuffer) 655e41f4b71Sopenharmony_ci``` 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci**Description** 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ciCreates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called. 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci**Deprecated from**: 12 662e41f4b71Sopenharmony_ci 663e41f4b71Sopenharmony_ci**Substitute**: [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer) 664e41f4b71Sopenharmony_ci 665e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 666e41f4b71Sopenharmony_ci 667e41f4b71Sopenharmony_ci**Since**: 8 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_ci**Parameters** 670e41f4b71Sopenharmony_ci 671e41f4b71Sopenharmony_ci| Name| Description| 672e41f4b71Sopenharmony_ci| -------- | -------- | 673e41f4b71Sopenharmony_ci| pSurfaceBuffer | Pointer to a **ProduceSurfaceBuffer**. The type is **sptr<OHOS::SurfaceBuffer>**.| 674e41f4b71Sopenharmony_ci 675e41f4b71Sopenharmony_ci**Returns** 676e41f4b71Sopenharmony_ci 677e41f4b71Sopenharmony_ciReturns the pointer to the **OHNativeWindowBuffer** instance created. 678e41f4b71Sopenharmony_ci 679e41f4b71Sopenharmony_ci 680e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindowFromSurfaceId() 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ci``` 683e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId (uint64_t surfaceId, OHNativeWindow **window ) 684e41f4b71Sopenharmony_ci``` 685e41f4b71Sopenharmony_ci 686e41f4b71Sopenharmony_ci**Description** 687e41f4b71Sopenharmony_ci 688e41f4b71Sopenharmony_ciCreates an **OHNativeWindow** instance based on a surface ID. 689e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeWindow_DestroyNativeWindow**. Otherwise, memory leak occurs. 690e41f4b71Sopenharmony_ci 691e41f4b71Sopenharmony_ciIf **OHNativeWindow** needs to be released concurrently, call **OH_NativeWindow_NativeObjectReference** and **OH_NativeWindow_NativeObjectUnreference** to increase or decrease the reference count by 1 for **OHNativeWindow**. 692e41f4b71Sopenharmony_ci 693e41f4b71Sopenharmony_ciThe surface obtained by using the surface ID must be created in the current process, but not in a different process. 694e41f4b71Sopenharmony_ci 695e41f4b71Sopenharmony_ciThis function is not thread-safe. 696e41f4b71Sopenharmony_ci 697e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 698e41f4b71Sopenharmony_ci 699e41f4b71Sopenharmony_ci**Since**: 12 700e41f4b71Sopenharmony_ci 701e41f4b71Sopenharmony_ci**Parameters** 702e41f4b71Sopenharmony_ci 703e41f4b71Sopenharmony_ci| Name| Description| 704e41f4b71Sopenharmony_ci| -------- | -------- | 705e41f4b71Sopenharmony_ci| surfaceId | Surface ID.| 706e41f4b71Sopenharmony_ci| window | Double pointer to an **OHNativeWindow** instance.| 707e41f4b71Sopenharmony_ci 708e41f4b71Sopenharmony_ci**Returns** 709e41f4b71Sopenharmony_ci 710e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 711e41f4b71Sopenharmony_ci 712e41f4b71Sopenharmony_ci 713e41f4b71Sopenharmony_ci### OH_NativeWindow_DestroyNativeWindow() 714e41f4b71Sopenharmony_ci 715e41f4b71Sopenharmony_ci``` 716e41f4b71Sopenharmony_civoid OH_NativeWindow_DestroyNativeWindow (OHNativeWindow* window) 717e41f4b71Sopenharmony_ci``` 718e41f4b71Sopenharmony_ci 719e41f4b71Sopenharmony_ci**Description** 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_ciDecreases the reference count of an **OHNativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. 722e41f4b71Sopenharmony_ci 723e41f4b71Sopenharmony_ciThis function is not thread-safe. 724e41f4b71Sopenharmony_ci 725e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci**Since**: 8 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci**Parameters** 730e41f4b71Sopenharmony_ci 731e41f4b71Sopenharmony_ci| Name| Description| 732e41f4b71Sopenharmony_ci| -------- | -------- | 733e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 734e41f4b71Sopenharmony_ci 735e41f4b71Sopenharmony_ci 736e41f4b71Sopenharmony_ci### OH_NativeWindow_DestroyNativeWindowBuffer() 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci``` 739e41f4b71Sopenharmony_civoid OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer* buffer) 740e41f4b71Sopenharmony_ci``` 741e41f4b71Sopenharmony_ci 742e41f4b71Sopenharmony_ci**Description** 743e41f4b71Sopenharmony_ci 744e41f4b71Sopenharmony_ciDecreases the reference count of an **OHNativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. 745e41f4b71Sopenharmony_ci 746e41f4b71Sopenharmony_ciThis function is not thread-safe. 747e41f4b71Sopenharmony_ci 748e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 749e41f4b71Sopenharmony_ci 750e41f4b71Sopenharmony_ci**Since**: 8 751e41f4b71Sopenharmony_ci 752e41f4b71Sopenharmony_ci**Parameters** 753e41f4b71Sopenharmony_ci 754e41f4b71Sopenharmony_ci| Name| Description| 755e41f4b71Sopenharmony_ci| -------- | -------- | 756e41f4b71Sopenharmony_ci| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 757e41f4b71Sopenharmony_ci 758e41f4b71Sopenharmony_ci 759e41f4b71Sopenharmony_ci### OH_NativeWindow_GetBufferHandleFromNative() 760e41f4b71Sopenharmony_ci 761e41f4b71Sopenharmony_ci``` 762e41f4b71Sopenharmony_ciBufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer* buffer) 763e41f4b71Sopenharmony_ci``` 764e41f4b71Sopenharmony_ci 765e41f4b71Sopenharmony_ci**Description** 766e41f4b71Sopenharmony_ci 767e41f4b71Sopenharmony_ciObtains the pointer to a **BufferHandle** of an **OHNativeWindowBuffer** instance. 768e41f4b71Sopenharmony_ci 769e41f4b71Sopenharmony_ciThis function is not thread-safe. 770e41f4b71Sopenharmony_ci 771e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 772e41f4b71Sopenharmony_ci 773e41f4b71Sopenharmony_ci**Since**: 8 774e41f4b71Sopenharmony_ci 775e41f4b71Sopenharmony_ci**Parameters** 776e41f4b71Sopenharmony_ci 777e41f4b71Sopenharmony_ci| Name| Description| 778e41f4b71Sopenharmony_ci| -------- | -------- | 779e41f4b71Sopenharmony_ci| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 780e41f4b71Sopenharmony_ci 781e41f4b71Sopenharmony_ci**Returns** 782e41f4b71Sopenharmony_ci 783e41f4b71Sopenharmony_ciReturns the pointer to the **BufferHandle** instance obtained. 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci 786e41f4b71Sopenharmony_ci### OH_NativeWindow_GetLastFlushedBuffer() 787e41f4b71Sopenharmony_ci 788e41f4b71Sopenharmony_ci``` 789e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetLastFlushedBuffer (OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd, float matrix[16] ) 790e41f4b71Sopenharmony_ci``` 791e41f4b71Sopenharmony_ci 792e41f4b71Sopenharmony_ci**Description** 793e41f4b71Sopenharmony_ci 794e41f4b71Sopenharmony_ciObtains the **OHNativeWindowBuffer** that was flushed to the buffer queue last time through an **OHNativeWindow** instance. 795e41f4b71Sopenharmony_ci 796e41f4b71Sopenharmony_ci**Deprecated from**: 12 797e41f4b71Sopenharmony_ci 798e41f4b71Sopenharmony_ci**Substitute**: [OH_NativeWindow_GetLastFlushedBufferV2](#oh_nativewindow_getlastflushedbufferv2) 799e41f4b71Sopenharmony_ci 800e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 801e41f4b71Sopenharmony_ci 802e41f4b71Sopenharmony_ci**Since**: 11 803e41f4b71Sopenharmony_ci 804e41f4b71Sopenharmony_ci**Parameters** 805e41f4b71Sopenharmony_ci 806e41f4b71Sopenharmony_ci| Name| Description| 807e41f4b71Sopenharmony_ci| -------- | -------- | 808e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 809e41f4b71Sopenharmony_ci| buffer | Double pointer to an **OHNativeWindowBuffer** instance.| 810e41f4b71Sopenharmony_ci| fenceFd | Pointer to a file descriptor.| 811e41f4b71Sopenharmony_ci| matrix | Retrieved 4*4 transformation matrix.| 812e41f4b71Sopenharmony_ci 813e41f4b71Sopenharmony_ci**Returns** 814e41f4b71Sopenharmony_ci 815e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 816e41f4b71Sopenharmony_ci 817e41f4b71Sopenharmony_ci 818e41f4b71Sopenharmony_ci### OH_NativeWindow_GetNativeObjectMagic() 819e41f4b71Sopenharmony_ci 820e41f4b71Sopenharmony_ci``` 821e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetNativeObjectMagic (void *obj) 822e41f4b71Sopenharmony_ci``` 823e41f4b71Sopenharmony_ci 824e41f4b71Sopenharmony_ci**Description** 825e41f4b71Sopenharmony_ci 826e41f4b71Sopenharmony_ciObtains the magic ID of a native object. 827e41f4b71Sopenharmony_ci 828e41f4b71Sopenharmony_ciThis function is not thread-safe. 829e41f4b71Sopenharmony_ci 830e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 831e41f4b71Sopenharmony_ci 832e41f4b71Sopenharmony_ci**Since**: 8 833e41f4b71Sopenharmony_ci 834e41f4b71Sopenharmony_ci**Parameters** 835e41f4b71Sopenharmony_ci 836e41f4b71Sopenharmony_ci| Name| Description| 837e41f4b71Sopenharmony_ci| -------- | -------- | 838e41f4b71Sopenharmony_ci| obj | Pointer to an **OHNativeWindow** or **OHNativeWindowBuffer** instance.| 839e41f4b71Sopenharmony_ci 840e41f4b71Sopenharmony_ci**Returns** 841e41f4b71Sopenharmony_ci 842e41f4b71Sopenharmony_ciReturns the magic ID, which is unique for each native object. 843e41f4b71Sopenharmony_ci 844e41f4b71Sopenharmony_ci 845e41f4b71Sopenharmony_ci### OH_NativeWindow_GetSurfaceId() 846e41f4b71Sopenharmony_ci 847e41f4b71Sopenharmony_ci``` 848e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetSurfaceId (OHNativeWindow *window, uint64_t *surfaceId ) 849e41f4b71Sopenharmony_ci``` 850e41f4b71Sopenharmony_ci 851e41f4b71Sopenharmony_ci**Description** 852e41f4b71Sopenharmony_ci 853e41f4b71Sopenharmony_ciObtains a surface ID through an **OHNativeWindow**. 854e41f4b71Sopenharmony_ci 855e41f4b71Sopenharmony_ciThis function is not thread-safe. 856e41f4b71Sopenharmony_ci 857e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 858e41f4b71Sopenharmony_ci 859e41f4b71Sopenharmony_ci**Since**: 12 860e41f4b71Sopenharmony_ci 861e41f4b71Sopenharmony_ci**Parameters** 862e41f4b71Sopenharmony_ci 863e41f4b71Sopenharmony_ci| Name| Description| 864e41f4b71Sopenharmony_ci| -------- | -------- | 865e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 866e41f4b71Sopenharmony_ci| surfaceId | Pointer to the surface ID.| 867e41f4b71Sopenharmony_ci 868e41f4b71Sopenharmony_ci**Returns** 869e41f4b71Sopenharmony_ci 870e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ci 873e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeObjectReference() 874e41f4b71Sopenharmony_ci 875e41f4b71Sopenharmony_ci``` 876e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeObjectReference (void *obj) 877e41f4b71Sopenharmony_ci``` 878e41f4b71Sopenharmony_ci 879e41f4b71Sopenharmony_ci**Description** 880e41f4b71Sopenharmony_ci 881e41f4b71Sopenharmony_ciAdds the reference count of a native object. 882e41f4b71Sopenharmony_ci 883e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeWindow_NativeObjectUnreference**. Otherwise, memory leak occurs. 884e41f4b71Sopenharmony_ci 885e41f4b71Sopenharmony_ciThis function is not thread-safe. 886e41f4b71Sopenharmony_ci 887e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 888e41f4b71Sopenharmony_ci 889e41f4b71Sopenharmony_ci**Since**: 8 890e41f4b71Sopenharmony_ci 891e41f4b71Sopenharmony_ci**Parameters** 892e41f4b71Sopenharmony_ci 893e41f4b71Sopenharmony_ci| Name| Description| 894e41f4b71Sopenharmony_ci| -------- | -------- | 895e41f4b71Sopenharmony_ci| obj | Pointer to an **OHNativeWindow** or **OHNativeWindowBuffer** instance.| 896e41f4b71Sopenharmony_ci 897e41f4b71Sopenharmony_ci**Returns** 898e41f4b71Sopenharmony_ci 899e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 900e41f4b71Sopenharmony_ci 901e41f4b71Sopenharmony_ci 902e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeObjectUnreference() 903e41f4b71Sopenharmony_ci 904e41f4b71Sopenharmony_ci``` 905e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeObjectUnreference (void *obj) 906e41f4b71Sopenharmony_ci``` 907e41f4b71Sopenharmony_ci 908e41f4b71Sopenharmony_ci**Description** 909e41f4b71Sopenharmony_ci 910e41f4b71Sopenharmony_ciDecreases the reference count of a native object and when the reference count reaches 0, destroys this object. 911e41f4b71Sopenharmony_ci 912e41f4b71Sopenharmony_ciThis function is not thread-safe. 913e41f4b71Sopenharmony_ci 914e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 915e41f4b71Sopenharmony_ci 916e41f4b71Sopenharmony_ci**Since**: 8 917e41f4b71Sopenharmony_ci 918e41f4b71Sopenharmony_ci**Parameters** 919e41f4b71Sopenharmony_ci 920e41f4b71Sopenharmony_ci| Name| Description| 921e41f4b71Sopenharmony_ci| -------- | -------- | 922e41f4b71Sopenharmony_ci| obj | Pointer to an **OHNativeWindow** or **OHNativeWindowBuffer** instance.| 923e41f4b71Sopenharmony_ci 924e41f4b71Sopenharmony_ci**Returns** 925e41f4b71Sopenharmony_ci 926e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 927e41f4b71Sopenharmony_ci 928e41f4b71Sopenharmony_ci 929e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowAbortBuffer() 930e41f4b71Sopenharmony_ci 931e41f4b71Sopenharmony_ci``` 932e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer ) 933e41f4b71Sopenharmony_ci``` 934e41f4b71Sopenharmony_ci 935e41f4b71Sopenharmony_ci**Description** 936e41f4b71Sopenharmony_ci 937e41f4b71Sopenharmony_ciReturns the **OHNativeWindowBuffer** to the buffer queue through an **OHNativeWindow** instance, without filling in any content. The **OHNativeWindowBuffer** can be used for a new request. 938e41f4b71Sopenharmony_ci 939e41f4b71Sopenharmony_ciThis function is not thread-safe. 940e41f4b71Sopenharmony_ci 941e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 942e41f4b71Sopenharmony_ci 943e41f4b71Sopenharmony_ci**Since**: 8 944e41f4b71Sopenharmony_ci 945e41f4b71Sopenharmony_ci**Parameters** 946e41f4b71Sopenharmony_ci 947e41f4b71Sopenharmony_ci| Name| Description| 948e41f4b71Sopenharmony_ci| -------- | -------- | 949e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 950e41f4b71Sopenharmony_ci| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 951e41f4b71Sopenharmony_ci 952e41f4b71Sopenharmony_ci**Returns** 953e41f4b71Sopenharmony_ci 954e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 955e41f4b71Sopenharmony_ci 956e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowAttachBuffer() 957e41f4b71Sopenharmony_ci 958e41f4b71Sopenharmony_ci``` 959e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowAttachBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer ) 960e41f4b71Sopenharmony_ci``` 961e41f4b71Sopenharmony_ci 962e41f4b71Sopenharmony_ci**Description** 963e41f4b71Sopenharmony_ci 964e41f4b71Sopenharmony_ciAttaches an **OHNativeWindowBuffer** to an **OHNativeWindow** instance. 965e41f4b71Sopenharmony_ci 966e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeWindow_NativeWindowDetachBuffer**. Otherwise, memory management disorder may occur. 967e41f4b71Sopenharmony_ci 968e41f4b71Sopenharmony_ciThis function is not thread-safe. 969e41f4b71Sopenharmony_ci 970e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 971e41f4b71Sopenharmony_ci 972e41f4b71Sopenharmony_ci**Since**: 12 973e41f4b71Sopenharmony_ci 974e41f4b71Sopenharmony_ci**Parameters** 975e41f4b71Sopenharmony_ci 976e41f4b71Sopenharmony_ci| Name| Description| 977e41f4b71Sopenharmony_ci| -------- | -------- | 978e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 979e41f4b71Sopenharmony_ci| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 980e41f4b71Sopenharmony_ci 981e41f4b71Sopenharmony_ci**Returns** 982e41f4b71Sopenharmony_ci 983e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 984e41f4b71Sopenharmony_ci 985e41f4b71Sopenharmony_ci 986e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowDetachBuffer() 987e41f4b71Sopenharmony_ci 988e41f4b71Sopenharmony_ci``` 989e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowDetachBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer ) 990e41f4b71Sopenharmony_ci``` 991e41f4b71Sopenharmony_ci 992e41f4b71Sopenharmony_ci**Description** 993e41f4b71Sopenharmony_ci 994e41f4b71Sopenharmony_ciDetaches an **OHNativeWindowBuffer** from an **OHNativeWindow** instance. 995e41f4b71Sopenharmony_ci 996e41f4b71Sopenharmony_ciThis function is not thread-safe. 997e41f4b71Sopenharmony_ci 998e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 999e41f4b71Sopenharmony_ci 1000e41f4b71Sopenharmony_ci**Since**: 12 1001e41f4b71Sopenharmony_ci 1002e41f4b71Sopenharmony_ci**Parameters** 1003e41f4b71Sopenharmony_ci 1004e41f4b71Sopenharmony_ci| Name| Description| 1005e41f4b71Sopenharmony_ci| -------- | -------- | 1006e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1007e41f4b71Sopenharmony_ci| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 1008e41f4b71Sopenharmony_ci 1009e41f4b71Sopenharmony_ci**Returns** 1010e41f4b71Sopenharmony_ci 1011e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci 1014e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowFlushBuffer() 1015e41f4b71Sopenharmony_ci 1016e41f4b71Sopenharmony_ci``` 1017e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer, int fenceFd, Region region ) 1018e41f4b71Sopenharmony_ci``` 1019e41f4b71Sopenharmony_ci 1020e41f4b71Sopenharmony_ci**Description** 1021e41f4b71Sopenharmony_ci 1022e41f4b71Sopenharmony_ciFlushes the **OHNativeWindowBuffer** filled with the produced content to the buffer queue through an **OHNativeWindow** instance for content consumption. 1023e41f4b71Sopenharmony_ci 1024e41f4b71Sopenharmony_ciThe system will close **fenFd**. You do not need to close it. 1025e41f4b71Sopenharmony_ci 1026e41f4b71Sopenharmony_ciThis function is not thread-safe. 1027e41f4b71Sopenharmony_ci 1028e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1029e41f4b71Sopenharmony_ci 1030e41f4b71Sopenharmony_ci**Since**: 8 1031e41f4b71Sopenharmony_ci 1032e41f4b71Sopenharmony_ci**Parameters** 1033e41f4b71Sopenharmony_ci 1034e41f4b71Sopenharmony_ci| Name| Description| 1035e41f4b71Sopenharmony_ci| -------- | -------- | 1036e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1037e41f4b71Sopenharmony_ci| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 1038e41f4b71Sopenharmony_ci| fenceFd | File descriptor handle, which is used for timing synchronization.| 1039e41f4b71Sopenharmony_ci| region | Dirty region where content is updated.| 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_ci**Returns** 1042e41f4b71Sopenharmony_ci 1043e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1044e41f4b71Sopenharmony_ci 1045e41f4b71Sopenharmony_ci 1046e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowHandleOpt() 1047e41f4b71Sopenharmony_ci 1048e41f4b71Sopenharmony_ci``` 1049e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow *window, int code, ... ) 1050e41f4b71Sopenharmony_ci``` 1051e41f4b71Sopenharmony_ci 1052e41f4b71Sopenharmony_ci**Description** 1053e41f4b71Sopenharmony_ci 1054e41f4b71Sopenharmony_ciSets or obtains the attributes of an **OHNativeWindow** instance, including the width, height, and content format. 1055e41f4b71Sopenharmony_ci 1056e41f4b71Sopenharmony_ciThis function is not thread-safe. 1057e41f4b71Sopenharmony_ci 1058e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1059e41f4b71Sopenharmony_ci 1060e41f4b71Sopenharmony_ci**Since**: 8 1061e41f4b71Sopenharmony_ci 1062e41f4b71Sopenharmony_ci**Parameters** 1063e41f4b71Sopenharmony_ci 1064e41f4b71Sopenharmony_ci| Name| Description| 1065e41f4b71Sopenharmony_ci| -------- | -------- | 1066e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1067e41f4b71Sopenharmony_ci| code | Operation code. For details, see [NativeWindowOperation](#nativewindowoperation).| 1068e41f4b71Sopenharmony_ci| ... | Variable argument, which must be the same as the data type corresponding to the operation code. The number of input parameters must be the same as that of the operation code. Otherwise, undefined behavior may occur.| 1069e41f4b71Sopenharmony_ci 1070e41f4b71Sopenharmony_ci**Returns** 1071e41f4b71Sopenharmony_ci 1072e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1073e41f4b71Sopenharmony_ci 1074e41f4b71Sopenharmony_ci 1075e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowRequestBuffer() 1076e41f4b71Sopenharmony_ci 1077e41f4b71Sopenharmony_ci``` 1078e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd ) 1079e41f4b71Sopenharmony_ci``` 1080e41f4b71Sopenharmony_ci 1081e41f4b71Sopenharmony_ci**Description** 1082e41f4b71Sopenharmony_ci 1083e41f4b71Sopenharmony_ciRequests an **OHNativeWindowBuffer** through an **OHNativeWindow** instance for content production. 1084e41f4b71Sopenharmony_ci 1085e41f4b71Sopenharmony_ciBefore calling this function, you must call **SET_BUFFER_GEOMETRY** to set the width and height of **OHNativeWindow**. 1086e41f4b71Sopenharmony_ci 1087e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeWindow_NativeWindowFlushBuffer**. Otherwise, memory leak occurs. 1088e41f4b71Sopenharmony_ci 1089e41f4b71Sopenharmony_ciWhen **fenceFd** is used up, you must close it. 1090e41f4b71Sopenharmony_ci 1091e41f4b71Sopenharmony_ciThis function is not thread-safe. 1092e41f4b71Sopenharmony_ci 1093e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1094e41f4b71Sopenharmony_ci 1095e41f4b71Sopenharmony_ci**Since**: 8 1096e41f4b71Sopenharmony_ci 1097e41f4b71Sopenharmony_ci**Parameters** 1098e41f4b71Sopenharmony_ci 1099e41f4b71Sopenharmony_ci| Name| Description| 1100e41f4b71Sopenharmony_ci| -------- | -------- | 1101e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1102e41f4b71Sopenharmony_ci| buffer | Double pointer to an **OHNativeWindowBuffer** instance.| 1103e41f4b71Sopenharmony_ci| fenceFd | Pointer to a file descriptor handle.| 1104e41f4b71Sopenharmony_ci 1105e41f4b71Sopenharmony_ci**Returns** 1106e41f4b71Sopenharmony_ci 1107e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1108e41f4b71Sopenharmony_ci 1109e41f4b71Sopenharmony_ci 1110e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetMetaData() 1111e41f4b71Sopenharmony_ci 1112e41f4b71Sopenharmony_ci``` 1113e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow *window, uint32_t sequence, int32_t size, const OHHDRMetaData *metaData ) 1114e41f4b71Sopenharmony_ci``` 1115e41f4b71Sopenharmony_ci 1116e41f4b71Sopenharmony_ci**Description** 1117e41f4b71Sopenharmony_ci 1118e41f4b71Sopenharmony_ciSets metadata for an **OHNativeWindow**. 1119e41f4b71Sopenharmony_ci 1120e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1121e41f4b71Sopenharmony_ci 1122e41f4b71Sopenharmony_ci**Since**: 9 1123e41f4b71Sopenharmony_ci 1124e41f4b71Sopenharmony_ci**Deprecated**: This function is deprecated since API version 10. No substitute is provided. 1125e41f4b71Sopenharmony_ci 1126e41f4b71Sopenharmony_ci**Parameters** 1127e41f4b71Sopenharmony_ci 1128e41f4b71Sopenharmony_ci| Name| Description| 1129e41f4b71Sopenharmony_ci| -------- | -------- | 1130e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1131e41f4b71Sopenharmony_ci| sequence | Sequence of the producer buffer.| 1132e41f4b71Sopenharmony_ci| size | Size of the **OHHDRMetaData** array.| 1133e41f4b71Sopenharmony_ci| metaData| Pointer to the **OHHDRMetaData** array.| 1134e41f4b71Sopenharmony_ci 1135e41f4b71Sopenharmony_ci**Returns** 1136e41f4b71Sopenharmony_ci 1137e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1138e41f4b71Sopenharmony_ci 1139e41f4b71Sopenharmony_ci 1140e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetMetaDataSet() 1141e41f4b71Sopenharmony_ci 1142e41f4b71Sopenharmony_ci``` 1143e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t *metaData ) 1144e41f4b71Sopenharmony_ci``` 1145e41f4b71Sopenharmony_ci 1146e41f4b71Sopenharmony_ci**Description** 1147e41f4b71Sopenharmony_ci 1148e41f4b71Sopenharmony_ciSets a metadata set for an **OHNativeWindow**. 1149e41f4b71Sopenharmony_ci 1150e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1151e41f4b71Sopenharmony_ci 1152e41f4b71Sopenharmony_ci**Since**: 9 1153e41f4b71Sopenharmony_ci 1154e41f4b71Sopenharmony_ci**Deprecated**: This function is deprecated since API version 10. No substitute is provided. 1155e41f4b71Sopenharmony_ci 1156e41f4b71Sopenharmony_ci**Parameters** 1157e41f4b71Sopenharmony_ci 1158e41f4b71Sopenharmony_ci| Name| Description| 1159e41f4b71Sopenharmony_ci| -------- | -------- | 1160e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1161e41f4b71Sopenharmony_ci| sequence | Sequence of the producer buffer.| 1162e41f4b71Sopenharmony_ci| key | Metadata key. For details, see [OHHDRMetadataKey](#ohhdrmetadatakey).| 1163e41f4b71Sopenharmony_ci| size | Size of the uint8_t vector.| 1164e41f4b71Sopenharmony_ci| metaData| Pointer to the uint8_t vector.| 1165e41f4b71Sopenharmony_ci 1166e41f4b71Sopenharmony_ci**Returns** 1167e41f4b71Sopenharmony_ci 1168e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1169e41f4b71Sopenharmony_ci 1170e41f4b71Sopenharmony_ci 1171e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetScalingMode() 1172e41f4b71Sopenharmony_ci 1173e41f4b71Sopenharmony_ci``` 1174e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow *window, uint32_t sequence, OHScalingMode scalingMode ) 1175e41f4b71Sopenharmony_ci``` 1176e41f4b71Sopenharmony_ci 1177e41f4b71Sopenharmony_ci**Description** 1178e41f4b71Sopenharmony_ci 1179e41f4b71Sopenharmony_ciSets a scaling mode for an **OHNativeWindow**. 1180e41f4b71Sopenharmony_ci 1181e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1182e41f4b71Sopenharmony_ci 1183e41f4b71Sopenharmony_ci**Since**: 9 1184e41f4b71Sopenharmony_ci 1185e41f4b71Sopenharmony_ci**Deprecated**: This function is deprecated since API version 10. No substitute is provided. 1186e41f4b71Sopenharmony_ci 1187e41f4b71Sopenharmony_ci**Parameters** 1188e41f4b71Sopenharmony_ci 1189e41f4b71Sopenharmony_ci| Name| Description| 1190e41f4b71Sopenharmony_ci| -------- | -------- | 1191e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1192e41f4b71Sopenharmony_ci| sequence | Sequence of the producer buffer.| 1193e41f4b71Sopenharmony_ci| scalingMode | Scaling mode to set. For details, see [OHScalingMode](#ohscalingmode).| 1194e41f4b71Sopenharmony_ci 1195e41f4b71Sopenharmony_ci**Returns** 1196e41f4b71Sopenharmony_ci 1197e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1198e41f4b71Sopenharmony_ci 1199e41f4b71Sopenharmony_ci 1200e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetScalingModeV2() 1201e41f4b71Sopenharmony_ci 1202e41f4b71Sopenharmony_ci``` 1203e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetScalingModeV2 (OHNativeWindow* window, OHScalingModeV2 scalingMode ) 1204e41f4b71Sopenharmony_ci``` 1205e41f4b71Sopenharmony_ci**Description** 1206e41f4b71Sopenharmony_ciSets a rendering scaling mode for an **OHNativeWindow** instance. 1207e41f4b71Sopenharmony_ci 1208e41f4b71Sopenharmony_ciThis function is not thread-safe. 1209e41f4b71Sopenharmony_ci 1210e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1211e41f4b71Sopenharmony_ci 1212e41f4b71Sopenharmony_ci**Since**: 12 1213e41f4b71Sopenharmony_ci 1214e41f4b71Sopenharmony_ci**Parameters** 1215e41f4b71Sopenharmony_ci 1216e41f4b71Sopenharmony_ci| Name| Description| 1217e41f4b71Sopenharmony_ci| -------- | -------- | 1218e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance. | 1219e41f4b71Sopenharmony_ci| scalingMode | Scaling mode. For details about the available options, see **OHScalingModeV2**. | 1220e41f4b71Sopenharmony_ci 1221e41f4b71Sopenharmony_ci**Returns** 1222e41f4b71Sopenharmony_ci 1223e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1224e41f4b71Sopenharmony_ci 1225e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetTunnelHandle() 1226e41f4b71Sopenharmony_ci 1227e41f4b71Sopenharmony_ci``` 1228e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow *window, const OHExtDataHandle *handle ) 1229e41f4b71Sopenharmony_ci``` 1230e41f4b71Sopenharmony_ci 1231e41f4b71Sopenharmony_ci**Description** 1232e41f4b71Sopenharmony_ci 1233e41f4b71Sopenharmony_ciSets a tunnel handle to an **OHNativeWindow**. 1234e41f4b71Sopenharmony_ci 1235e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 1236e41f4b71Sopenharmony_ci 1237e41f4b71Sopenharmony_ci**Since**: 9 1238e41f4b71Sopenharmony_ci 1239e41f4b71Sopenharmony_ci**Deprecated**: This function is deprecated since API version 10. No substitute is provided. 1240e41f4b71Sopenharmony_ci 1241e41f4b71Sopenharmony_ci**Parameters** 1242e41f4b71Sopenharmony_ci 1243e41f4b71Sopenharmony_ci| Name| Description| 1244e41f4b71Sopenharmony_ci| -------- | -------- | 1245e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance.| 1246e41f4b71Sopenharmony_ci| handle | Pointer to an [OHExtDataHandle](_o_h_ext_data_handle.md).| 1247e41f4b71Sopenharmony_ci 1248e41f4b71Sopenharmony_ci**Returns** 1249e41f4b71Sopenharmony_ci 1250e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 1251