1e41f4b71Sopenharmony_ci# NativeWindow 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## 概述 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci提供NativeWindow功能,作为数据生产者,可用来和egl对接。 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**起始版本:** 8 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## 汇总 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci### 文件 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| 名称 | 描述 | 19e41f4b71Sopenharmony_ci| -------- | -------- | 20e41f4b71Sopenharmony_ci| [external_window.h](external__window_8h.md) | 定义获取和使用NativeWindow的相关函数。 | 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci### 结构体 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| 名称 | 描述 | 26e41f4b71Sopenharmony_ci| -------- | -------- | 27e41f4b71Sopenharmony_ci| struct [Region](_region.md) | 表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区)。 | 28e41f4b71Sopenharmony_ci| struct [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | HDR元数据结构体定义。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 29e41f4b71Sopenharmony_ci| struct [OHExtDataHandle](_o_h_ext_data_handle.md) | 扩展数据句柄结构体定义。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci### 类型定义 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci| 名称 | 描述 | 35e41f4b71Sopenharmony_ci| -------- | -------- | 36e41f4b71Sopenharmony_ci| typedef struct [OHIPCParcel](#ohipcparcel) [OHIPCParcel](#ohipcparcel) | 提供对IPC序列化对象的访问功能。 | 37e41f4b71Sopenharmony_ci| typedef struct NativeWindow [OHNativeWindow](#ohnativewindow) | 提供对OHNativeWindow的访问功能。 | 38e41f4b71Sopenharmony_ci| typedef struct NativeWindowBuffer [OHNativeWindowBuffer](#ohnativewindowbuffer) | 提供对OHNativeWindowBuffer的访问功能。 | 39e41f4b71Sopenharmony_ci| typedef struct [Region](_region.md) [Region](#region) | 表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区)。 | 40e41f4b71Sopenharmony_ci| typedef enum [OHNativeErrorCode](#ohnativeerrorcode) [OHNativeErrorCode](#ohnativeerrorcode) | 接口错误码说明(仅用于查询)。 | 41e41f4b71Sopenharmony_ci| typedef enum [NativeWindowOperation](#nativewindowoperation) [NativeWindowOperation](#nativewindowoperation) | OH_NativeWindow_NativeWindowHandleOpt函数中的操作码。 | 42e41f4b71Sopenharmony_ci| typedef enum [OHScalingModeV2](#ohscalingmodev2) [OHScalingModeV2](#ohscalingmodev2) | 渲染缩放模式枚举。 | 43e41f4b71Sopenharmony_ci| typedef enum [OHSurfaceSource](#ohsurfacesource) [OHSurfaceSource](#ohsurfacesource) | 本地窗口内容来源类型枚举。 | 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci### 枚举 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci| 名称 | 描述 | 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/>} | OH_NativeWindow_NativeWindowHandleOpt函数中的操作码。 | 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 } | 缩放模式Scaling Mode。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 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/>} | 渲染缩放模式枚举。 | 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/>} | 枚举HDR元数据关键字。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 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/>} | 接口错误码说明(仅用于查询)。 | 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/>} | 本地窗口内容来源类型枚举。 | 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci### 函数 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci| 名称 | 描述 | 59e41f4b71Sopenharmony_ci| -------- | -------- | 60e41f4b71Sopenharmony_ci| [OHNativeWindow](#ohnativewindow) \* [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | 创建OHNativeWindow实例,每次调用都会产生一个新的OHNativeWindow实例。 说明:此接口不可用,可通过**OH_NativeImage_AcquireNativeWindow**创建,或通过XComponent创建。 | 61e41f4b71Sopenharmony_ci| void [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) ([OHNativeWindow](#ohnativewindow) \*window) | 将OHNativeWindow对象的引用计数减1,当引用计数为0的时候,该OHNativeWindow对象会被析构掉。 | 62e41f4b71Sopenharmony_ci| [OHNativeWindowBuffer](#ohnativewindowbuffer) \* [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | 创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例。 此接口从API version 12开始废弃,使用[OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer)替代。 | 63e41f4b71Sopenharmony_ci| [OHNativeWindowBuffer](#ohnativewindowbuffer) \* [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer) (OH_NativeBuffer \*nativeBuffer) | 创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例。 | 64e41f4b71Sopenharmony_ci| void [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) ([OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | 将OHNativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该OHNativeWindowBuffer对象会被析构掉。 | 65e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd) | 通过OHNativeWindow对象申请一块OHNativeWindowBuffer,用以内容生产。 | 66e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer, int fenceFd, [Region](_region.md) region) | 通过OHNativeWindow将生产好内容的OHNativeWindowBuffer放回到Buffer队列中,用以内容消费。 | 67e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetLastFlushedBuffer](#oh_nativewindow_getlastflushedbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd, float matrix[16]) | 从OHNativeWindow获取上次送回到buffer队列中的OHNativeWindowBuffer。 | 68e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | 通过OHNativeWindow将之前申请出来的OHNativeWindowBuffer返还到Buffer队列中,供下次再申请。 | 69e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) ([OHNativeWindow](#ohnativewindow) \*window, int code,...) | 设置/获取OHNativeWindow的属性,包括设置/获取宽高、内容格式等。 | 70e41f4b71Sopenharmony_ci| BufferHandle \* [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) ([OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | 通过OHNativeWindowBuffer获取该buffer的BufferHandle指针。 | 71e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | 增加一个NativeObject的引用计数。 | 72e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉。 | 73e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | 获取NativeObject的MagicId。 | 74e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode) ([OHNativeWindow](#ohnativewindow) \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | 设置OHNativeWindow的ScalingMode。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 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) | 设置OHNativeWindow的元数据。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 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) | 设置OHNativeWindow的元数据集。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 77e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetTunnelHandle](#oh_nativewindow_nativewindowsettunnelhandle) ([OHNativeWindow](#ohnativewindow) \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | 设置OHNativeWindow的TunnelHandle。<br/>**弃用:** 从API version 10开始废弃,不再提供替代接口。 | 78e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowAttachBuffer](#oh_nativewindow_nativewindowattachbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | 将OHNativeWindowBuffer添加进OHNativeWindow中。 | 79e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowDetachBuffer](#oh_nativewindow_nativewindowdetachbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | 将OHNativeWindowBuffer从OHNativeWindow中分离。 | 80e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetSurfaceId](#oh_nativewindow_getsurfaceid) ([OHNativeWindow](#ohnativewindow) \*window, uint64_t \*surfaceId) | 通过OHNativeWindow获取对应的surfaceId。 | 81e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_CreateNativeWindowFromSurfaceId](#oh_nativewindow_createnativewindowfromsurfaceid) (uint64_t surfaceId, [OHNativeWindow](#ohnativewindow) \*\*window) | 通过surfaceId创建对应的OHNativeWindow。 | 82e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_NativeWindowSetScalingModeV2](#oh_nativewindow_nativewindowsetscalingmodev2) ([OHNativeWindow](#ohnativewindow) \*window, [OHScalingModeV2](#ohscalingmodev2) scalingMode) | 设置OHNativeWindow的渲染缩放模式。 | 83e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_GetLastFlushedBufferV2](#oh_nativewindow_getlastflushedbufferv2) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd, float matrix[16]) | 从OHNativeWindow获取上次送回到buffer队列中的OHNativeWindowBuffer, 与OH_NativeWindow_GetLastFlushedBuffer的差异在于matrix不同。 | 84e41f4b71Sopenharmony_ci| void [OH_NativeWindow_SetBufferHold](#oh_nativewindow_setbufferhold) ([OHNativeWindow](#ohnativewindow) \*window) | 提前缓存一帧buffer,且缓存的这一帧延迟一帧上屏显示,以此抵消后续一次超长帧丢帧。 | 85e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_WriteToParcel](#oh_nativewindow_writetoparcel) ([OHNativeWindow](#ohnativewindow) \*window, [OHIPCParcel](#ohipcparcel) \*parcel) | 将窗口对象写入IPC序列化对象中。 | 86e41f4b71Sopenharmony_ci| int32_t [OH_NativeWindow_ReadFromParcel](#oh_nativewindow_readfromparcel) ([OHIPCParcel](#ohipcparcel) \*parcel, [OHNativeWindow](#ohnativewindow) \*\*window) | 从IPC序列化对象中读取窗口对象。 | 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) | 为OHNativeWindow设置颜色空间属性。 | 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) | 获取OHNativeWindow颜色空间属性。 | 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) | 为OHNativeWindow设置元数据属性值。 | 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) | 获取OHNativeWindow元数据属性值。 | 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci## 类型定义说明 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci### OHSurfaceSource 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci``` 97e41f4b71Sopenharmony_citypedef enum OHSurfaceSource OHSurfaceSource 98e41f4b71Sopenharmony_ci``` 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci**描述** 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci本地窗口内容来源类型枚举。 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci**起始版本:** 12 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci### OHIPCParcel 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci``` 109e41f4b71Sopenharmony_citypedef struct OHIPCParcel OHIPCParcel 110e41f4b71Sopenharmony_ci``` 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**描述** 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci提供对IPC序列化对象的访问功能。 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**起始版本:** 12 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci### NativeWindowOperation 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci``` 121e41f4b71Sopenharmony_citypedef enum NativeWindowOperation NativeWindowOperation 122e41f4b71Sopenharmony_ci``` 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci**描述** 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ciOH_NativeWindow_NativeWindowHandleOpt函数中的操作码。 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**起始版本:** 8 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci### OHNativeErrorCode 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci``` 133e41f4b71Sopenharmony_citypedef enum OHNativeErrorCode OHNativeErrorCode 134e41f4b71Sopenharmony_ci``` 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**描述** 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci接口错误码说明(仅用于查询)。 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**起始版本:** 12 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci### OHNativeWindow 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci``` 146e41f4b71Sopenharmony_citypedef struct NativeWindow OHNativeWindow 147e41f4b71Sopenharmony_ci``` 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci**描述** 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci提供对OHNativeWindow的访问功能。 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci**起始版本:** 8 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci### OHNativeWindowBuffer 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci``` 159e41f4b71Sopenharmony_citypedef struct NativeWindowBuffer OHNativeWindowBuffer 160e41f4b71Sopenharmony_ci``` 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci**描述** 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci提供对OHNativeWindowBuffer的访问功能。 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci**起始版本:** 8 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci### OHScalingModeV2 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci``` 171e41f4b71Sopenharmony_citypedef enum OHScalingModeV2 OHScalingModeV2 172e41f4b71Sopenharmony_ci``` 173e41f4b71Sopenharmony_ci**描述** 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ci渲染缩放模式枚举。 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci**起始版本:** 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**描述** 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区)。 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci**起始版本:** 8 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci## 枚举类型说明 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci### OHSurfaceSource 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci``` 199e41f4b71Sopenharmony_cienum OHSurfaceSource 200e41f4b71Sopenharmony_ci``` 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**描述** 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci本地窗口内容来源类型枚举。 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**起始版本:** 12 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 209e41f4b71Sopenharmony_ci| -------- | -------- | 210e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_DEFAULT | 窗口内容默认来源。 | 211e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_UI | 窗口内容来自于UI。 | 212e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_GAME | 窗口内容来自于游戏。 | 213e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_CAMERA | 窗口内容来自于相机。 | 214e41f4b71Sopenharmony_ci| OH_SURFACE_SOURCE_VIDEO | 窗口内容来自于视频。 | 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci### OHNativeErrorCode 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci``` 219e41f4b71Sopenharmony_cienum OHNativeErrorCode 220e41f4b71Sopenharmony_ci``` 221e41f4b71Sopenharmony_ci**描述** 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci接口错误码说明(仅用于查询)。 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**起始版本:** 12 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 228e41f4b71Sopenharmony_ci| -------- | -------- | 229e41f4b71Sopenharmony_ci| NATIVE_ERROR_OK | 成功 | 230e41f4b71Sopenharmony_ci| NATIVE_ERROR_INVALID_ARGUMENTS | 入参无效 | 231e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_PERMISSION | 无权限操作 | 232e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_BUFFER | 无空闲可用的buffer | 233e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_CONSUMER | 消费端不存在 | 234e41f4b71Sopenharmony_ci| NATIVE_ERROR_NOT_INIT | 未初始化 | 235e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_CONNECTED | 消费端已经被连接 | 236e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_STATE_INVALID | buffer状态不符合预期 | 237e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_IN_CACHE | buffer已在缓存队列中 | 238e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_QUEUE_FULL | 队列已满 | 239e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_NOT_IN_CACHE | buffer不在缓存队列中 | 240e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_DISCONNECTED | 消费端已经被断开连接 | 241e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED | 消费端未注册listener回调函数 | 242e41f4b71Sopenharmony_ci| NATIVE_ERROR_UNSUPPORTED | 当前设备或平台不支持 | 243e41f4b71Sopenharmony_ci| NATIVE_ERROR_UNKNOWN | 未知错误,请查看日志 | 244e41f4b71Sopenharmony_ci| NATIVE_ERROR_HDI_ERROR | HDI接口调用失败 | 245e41f4b71Sopenharmony_ci| NATIVE_ERROR_BINDER_ERROR | 跨进程通信失败 | 246e41f4b71Sopenharmony_ci| NATIVE_ERROR_EGL_STATE_UNKNOWN | egl环境状态异常 | 247e41f4b71Sopenharmony_ci| NATIVE_ERROR_EGL_API_FAILED | egl接口调用失败 | 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci### NativeWindowOperation 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci``` 253e41f4b71Sopenharmony_cienum NativeWindowOperation 254e41f4b71Sopenharmony_ci``` 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci**描述** 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ciOH_NativeWindow_NativeWindowHandleOpt函数中的操作码。 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci**起始版本:** 8 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 263e41f4b71Sopenharmony_ci| -------- | -------- | 264e41f4b71Sopenharmony_ci| SET_BUFFER_GEOMETRY | 设置本地窗口缓冲区几何图形, 函数中的可变参数是 [输入] int32_t width,[输入] int32_t height。 | 265e41f4b71Sopenharmony_ci| GET_BUFFER_GEOMETRY | 获取本地窗口缓冲区几何图形, 函数中的可变参数是 [输出] int32_t \*height, [输出] int32_t \*width。 | 266e41f4b71Sopenharmony_ci| GET_FORMAT | 获取本地窗口缓冲区格式, 函数中的可变参数是 [输出] int32_t \*format,取值具体可见[OH_NativeBuffer_Format](_o_h___native_buffer.md#oh_nativebuffer_format-1)枚举值。 | 267e41f4b71Sopenharmony_ci| SET_FORMAT | 设置本地窗口缓冲区格式, 函数中的可变参数是 [输入] int32_t format,取值具体可见[OH_NativeBuffer_Format](_o_h___native_buffer.md#oh_nativebuffer_format-1)枚举值。 | 268e41f4b71Sopenharmony_ci| GET_USAGE | 获取本地窗口读写方式, 函数中的可变参数是 [输出] uint64_t \*usage,取值具体可见[OH_NativeBuffer_Usage](_o_h___native_buffer.md#oh_nativebuffer_usage-1)枚举值。 | 269e41f4b71Sopenharmony_ci| SET_USAGE | 设置本地窗口缓冲区读写方式, 函数中的可变参数是 [输入] uint64_t usage,取值具体可见[OH_NativeBuffer_Usage](_o_h___native_buffer.md#oh_nativebuffer_usage-1)枚举值。 | 270e41f4b71Sopenharmony_ci| SET_STRIDE | 设置本地窗口缓冲区步幅, 函数中的可变参数是 [输入] int32_t stride。 | 271e41f4b71Sopenharmony_ci| GET_STRIDE | 获取本地窗口缓冲区步幅, 函数中的可变参数是 [输出] int32_t \*stride。 | 272e41f4b71Sopenharmony_ci| SET_SWAP_INTERVAL | 设置本地窗口缓冲区交换间隔, 函数中的可变参数是 [输入] int32_t interval。 | 273e41f4b71Sopenharmony_ci| GET_SWAP_INTERVAL | 获取本地窗口缓冲区交换间隔, 函数中的可变参数是 [输出] int32_t \*interval。 | 274e41f4b71Sopenharmony_ci| SET_TIMEOUT | 设置请求本地窗口缓冲区的超时等待时间, 函数中的可变参数是 [输入] int32_t timeout。 | 275e41f4b71Sopenharmony_ci| GET_TIMEOUT | 获取请求本地窗口缓冲区的超时等待时间, 函数中的可变参数是 [输出] int32_t \*timeout。 | 276e41f4b71Sopenharmony_ci| SET_COLOR_GAMUT | 设置本地窗口缓冲区色彩空间, 函数中的可变参数是 [输入] int32_t colorGamut,取值具体可见[OH_NativeBuffer_ColorGamut](_o_h___native_buffer.md#oh_nativebuffer_colorgamut-1)枚举值。 | 277e41f4b71Sopenharmony_ci| GET_COLOR_GAMUT | 获取本地窗口缓冲区色彩空间, 函数中的可变参数是 [out int32_t \*colorGamut],取值具体可见[OH_NativeBuffer_ColorGamut](_o_h___native_buffer.md#oh_nativebuffer_colorgamut-1)枚举值。 | 278e41f4b71Sopenharmony_ci| SET_TRANSFORM | 设置本地窗口缓冲区变换, 函数中的可变参数是 [输入] int32_t transform,取值具体可见[OH_NativeBuffer_TransformType](_o_h___native_buffer.md#oh_nativebuffer_transformtype-1)枚举值。 | 279e41f4b71Sopenharmony_ci| GET_TRANSFORM | 获取本地窗口缓冲区变换, 函数中的可变参数是 [输出] int32_t \*transform,取值具体可见[OH_NativeBuffer_TransformType](_o_h___native_buffer.md#oh_nativebuffer_transformtype-1)枚举值。 | 280e41f4b71Sopenharmony_ci| SET_UI_TIMESTAMP | 设置本地窗口缓冲区UI时间戳, 函数中的可变参数是 [输入] uint64_t uiTimestamp。 | 281e41f4b71Sopenharmony_ci| GET_BUFFERQUEUE_SIZE<sup>12+</sup> | 获取内存队列大小, 函数中的可变参数是 [输出] int32_t \*size. | 282e41f4b71Sopenharmony_ci| SET_SOURCE_TYPE<sup>12+</sup> | 设置本地窗口内容来源, 函数中的可变参数是 [输入] int32_t sourceType, 取值具体可见[OHSurfaceSource](#ohsurfacesource)枚举值。 | 283e41f4b71Sopenharmony_ci| GET_SOURCE_TYPE<sup>12+</sup> | 获取本地窗口内容来源, 函数中的可变参数是 [输出] int32_t \*sourceType, 取值具体可见[OHSurfaceSource](#ohsurfacesource)枚举值。 | 284e41f4b71Sopenharmony_ci| SET_APP_FRAMEWORK_TYPE<sup>12+</sup> | 设置本地窗口应用框架名称, 函数中的可变参数是 [输入] char\* frameworkType, 最大支持64字节。 | 285e41f4b71Sopenharmony_ci| GET_APP_FRAMEWORK_TYPE<sup>12+</sup> | 获取本地窗口应用框架名称, 函数中的可变参数是 [输出] char\* frameworkType。 | 286e41f4b71Sopenharmony_ci| SET_HDR_WHITE_POINT_BRIGHTNESS<sup>12+</sup> | 设置HDR白点亮度, 函数中的可变参数是 [输入] float brightness. 取值范围为[0.0f, 1.0f]。 | 287e41f4b71Sopenharmony_ci| SET_SDR_WHITE_POINT_BRIGHTNESS<sup>12+</sup> | 设置SDR白点亮度, 函数中的可变参数是 [输入] float brightness. 取值范围为[0.0f, 1.0f]。 | 288e41f4b71Sopenharmony_ci| SET_DESIRED_PRESENT_TIMESTAMP<sup>14+</sup> | 设置本地窗口缓冲区期望上屏时间的时间戳。 当且仅当RenderService为本地窗口的消费者时,该时间戳生效。 本操作执行后需要配合调用[OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer)生效。 生产者下一次放入队列的buffer,达到该期望上屏时间后,才会被RenderService消费并上屏。 如果buffer队列中存在多个生产者放入的buffer,都设置了desiredPresentTimestamp并已达到期望上屏时间,则较早入队的buffer将被消费者丢弃回队列。 如果期望上屏时间大于消费者提供的时间 1 秒以上,则该期望上屏时间戳将被忽略。 函数中的可变参数是 [输入] int64_t desiredPresentTimestamp,取值范围大于0,应由std::chrono::steady_clock标准库时钟生成,且单位为纳秒。 | 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci### OHHDRMetadataKey 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci``` 293e41f4b71Sopenharmony_cienum OHHDRMetadataKey 294e41f4b71Sopenharmony_ci``` 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci**描述** 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci枚举HDR元数据关键字。 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**起始版本:** 9 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci**弃用:** 从API version 10开始废弃,不再提供替代接口。 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 305e41f4b71Sopenharmony_ci| -------- | -------- | 306e41f4b71Sopenharmony_ci| OH_METAKEY_RED_PRIMARY_X | 红基色X坐标。 | 307e41f4b71Sopenharmony_ci| OH_METAKEY_RED_PRIMARY_Y | 红基色Y坐标。 | 308e41f4b71Sopenharmony_ci| OH_METAKEY_GREEN_PRIMARY_X | 绿基色X坐标。 | 309e41f4b71Sopenharmony_ci| OH_METAKEY_GREEN_PRIMARY_Y | 绿基色Y坐标。 | 310e41f4b71Sopenharmony_ci| OH_METAKEY_BLUE_PRIMARY_X | 蓝基色X坐标。 | 311e41f4b71Sopenharmony_ci| OH_METAKEY_BLUE_PRIMARY_Y | 蓝基色Y坐标。 | 312e41f4b71Sopenharmony_ci| OH_METAKEY_WHITE_PRIMARY_X | 白点X坐标。 | 313e41f4b71Sopenharmony_ci| OH_METAKEY_WHITE_PRIMARY_Y | 白点Y坐标。 | 314e41f4b71Sopenharmony_ci| OH_METAKEY_MAX_LUMINANCE | 最大的光亮度。 | 315e41f4b71Sopenharmony_ci| OH_METAKEY_MIN_LUMINANCE | 最小的光亮度。 | 316e41f4b71Sopenharmony_ci| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | 最大的内容亮度水平。 | 317e41f4b71Sopenharmony_ci| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | 最大的帧平均亮度水平。 | 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**描述** 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci缩放模式 Scaling Mode。 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**起始版本:** 9 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci**弃用:** 从API version 10开始废弃,不再提供替代接口。 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 337e41f4b71Sopenharmony_ci| -------- | -------- | 338e41f4b71Sopenharmony_ci| OH_SCALING_MODE_FREEZE | 在接收到窗口大小的缓冲区之前,不可以更新窗口内容。 | 339e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_TO_WINDOW | 缓冲区在二维中缩放以匹配窗口大小。 | 340e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_CROP | 缓冲区被统一缩放,使得缓冲区的较小尺寸与窗口大小匹配。 | 341e41f4b71Sopenharmony_ci| OH_SCALING_MODE_NO_SCALE_CROP | 窗口被裁剪为缓冲区裁剪矩形的大小,裁剪矩形之外的像素被视为完全透明。 | 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci### OHScalingModeV2 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci``` 347e41f4b71Sopenharmony_cienum OHScalingModeV2 348e41f4b71Sopenharmony_ci``` 349e41f4b71Sopenharmony_ci**描述** 350e41f4b71Sopenharmony_ci渲染缩放模式枚举。 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci**起始版本:** 12 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 355e41f4b71Sopenharmony_ci| -------- | -------- | 356e41f4b71Sopenharmony_ci| OH_SCALING_MODE_FREEZE_V2 | 冻结窗口,在接收到和窗口大小相等的缓冲区之前,窗口内容不进行更新。 | 357e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_TO_WINDOW_V2 | 缓冲区进行拉伸缩放以匹配窗口大小。| 358e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_CROP_V2 | 缓冲区按原比例缩放,使得缓冲区的较小边与窗口匹配, 较长边超出窗口部分被视为透明。 | 359e41f4b71Sopenharmony_ci| OH_SCALING_MODE_NO_SCALE_CROP_V2 | 按窗口大小将缓冲区裁剪,裁剪矩形之外的像素被视为完全透明。 | 360e41f4b71Sopenharmony_ci| OH_SCALING_MODE_SCALE_FIT_V2 | 缓冲区按原比例缩放。优先显示所有缓冲区内容。 如果比例与窗口比例不同,用背景颜色填充窗口的未填充区域。<!--Del-->开发板和<!--DelEnd-->模拟器不支持该模式。| 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci## 函数说明 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci### OH_NativeWindow_SetColorSpace() 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ci``` 368e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_SetColorSpace (OHNativeWindow *window, OH_NativeBuffer_ColorSpace colorSpace ) 369e41f4b71Sopenharmony_ci``` 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci**描述** 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci为OHNativeWindow设置颜色空间属性。 374e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci**起始版本:** 12 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ci**参数:** 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci| 名称 | 描述 | 383e41f4b71Sopenharmony_ci| -------- | -------- | 384e41f4b71Sopenharmony_ci| window | 一个指向[OHNativeWindow](#ohnativewindow)的结构体实例的指针。 | 385e41f4b71Sopenharmony_ci| colorSpace | 为OHNativeWindow设置的颜色空间,其值从[OH_NativeBuffer_ColorSpace](_o_h___native_buffer.md#oh_nativebuffer_colorspace)获取。 | 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ci**返回:** 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode)。 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci### OH_NativeWindow_SetMetadataValue() 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci``` 395e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_SetMetadataValue (OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey, int32_t size, uint8_t * metaData ) 396e41f4b71Sopenharmony_ci``` 397e41f4b71Sopenharmony_ci 398e41f4b71Sopenharmony_ci**描述** 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci为OHNativeWindow设置元数据属性值。 401e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci**起始版本:** 12 406e41f4b71Sopenharmony_ci 407e41f4b71Sopenharmony_ci**参数:** 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci| 名称 | 描述 | 410e41f4b71Sopenharmony_ci| -------- | -------- | 411e41f4b71Sopenharmony_ci| window | 一个指向[OHNativeWindow](#ohnativewindow)的结构体实例的指针。 | 412e41f4b71Sopenharmony_ci| metadataKey | OHNativeWindow的元数据类型,其值从[OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey)获取。 | 413e41f4b71Sopenharmony_ci| size | uint8_t向量的大小,其取值范围见[OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey)。 | 414e41f4b71Sopenharmony_ci| metaDate | 指向uint8_t向量的指针。 | 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci**返回:** 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode)。 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ci### OH_NativeWindow_GetColorSpace() 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci``` 423e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetColorSpace (OHNativeWindow *window, OH_NativeBuffer_ColorSpace *colorSpace ) 424e41f4b71Sopenharmony_ci``` 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci**描述** 427e41f4b71Sopenharmony_ci 428e41f4b71Sopenharmony_ci获取OHNativeWindow颜色空间属性。 429e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci**起始版本:** 12 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci**参数:** 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci| 名称 | 描述 | 438e41f4b71Sopenharmony_ci| -------- | -------- | 439e41f4b71Sopenharmony_ci| window | 一个指向[OHNativeWindow](#ohnativewindow)的结构体实例的指针。 | 440e41f4b71Sopenharmony_ci| colorSpace | 为OHNativeWindow设置的颜色空间,其值从[OH_NativeBuffer_ColorSpace](_o_h___native_buffer.md#oh_nativebuffer_colorspace)获取。 | 441e41f4b71Sopenharmony_ci 442e41f4b71Sopenharmony_ci**返回:** 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode)。 445e41f4b71Sopenharmony_ci 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci### OH_NativeWindow_GetMetadataValue() 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci``` 450e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetMetadataValue (OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey, int32_t *size, uint8_t **metaData ) 451e41f4b71Sopenharmony_ci``` 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci**描述** 454e41f4b71Sopenharmony_ci 455e41f4b71Sopenharmony_ci获取OHNativeWindow元数据属性值。 456e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci**起始版本:** 12 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci**参数:** 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci| 名称 | 描述 | 465e41f4b71Sopenharmony_ci| -------- | -------- | 466e41f4b71Sopenharmony_ci| window | 一个指向[OHNativeWindow](#ohnativewindow)的结构体实例的指针。 | 467e41f4b71Sopenharmony_ci| metadataKey | OHNativeWindow的元数据类型,其值从[OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey)获取。 | 468e41f4b71Sopenharmony_ci| size | uint8_t向量的大小,其取值范围见[OH_NativeBuffer_MetadataKey](_o_h___native_buffer.md#oh_nativebuffer_metadatakey)。 | 469e41f4b71Sopenharmony_ci| metaDate | 指向uint8_t向量的二级指针。 | 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci**返回:** 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](_o_h___native_buffer.md#ohnativeerrorcode)。 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci### OH_NativeWindow_WriteToParcel() 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci``` 479e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_WriteToParcel (OHNativeWindow *window, OHIPCParcel *parcel ) 480e41f4b71Sopenharmony_ci``` 481e41f4b71Sopenharmony_ci 482e41f4b71Sopenharmony_ci**描述** 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci将窗口对象写入IPC序列化对象中。 485e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 488e41f4b71Sopenharmony_ci 489e41f4b71Sopenharmony_ci**起始版本:** 12 490e41f4b71Sopenharmony_ci 491e41f4b71Sopenharmony_ci**参数:** 492e41f4b71Sopenharmony_ci 493e41f4b71Sopenharmony_ci| 名称 | 描述 | 494e41f4b71Sopenharmony_ci| -------- | -------- | 495e41f4b71Sopenharmony_ci| window | 一个指向[OHNativeWindow](#ohnativewindow)的结构体实例的指针。 | 496e41f4b71Sopenharmony_ci| parcel | 一个指向[OHIPCParcel](#ohipcparcel)的结构体实例的指针。 | 497e41f4b71Sopenharmony_ci 498e41f4b71Sopenharmony_ci**返回:** 499e41f4b71Sopenharmony_ci 500e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 501e41f4b71Sopenharmony_ci 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci### OH_NativeWindow_ReadFromParcel() 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci``` 506e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_ReadFromParcel (OHIPCParcel *parcel, OHNativeWindow **window ) 507e41f4b71Sopenharmony_ci``` 508e41f4b71Sopenharmony_ci 509e41f4b71Sopenharmony_ci**描述** 510e41f4b71Sopenharmony_ci 511e41f4b71Sopenharmony_ci从IPC序列化对象中读取窗口对象。 512e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 513e41f4b71Sopenharmony_ci 514e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 515e41f4b71Sopenharmony_ci 516e41f4b71Sopenharmony_ci**起始版本:** 12 517e41f4b71Sopenharmony_ci 518e41f4b71Sopenharmony_ci**参数:** 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci| 名称 | 描述 | 521e41f4b71Sopenharmony_ci| -------- | -------- | 522e41f4b71Sopenharmony_ci| parcel | 一个指向[OHIPCParcel](#ohipcparcel)的结构体实例的指针。 | 523e41f4b71Sopenharmony_ci| window | 一个指向[OHNativeWindow](#ohnativewindow)的结构体实例的二级指针。 | 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**返回:** 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 528e41f4b71Sopenharmony_ci 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ci 531e41f4b71Sopenharmony_ci### OH_NativeWindow_GetLastFlushedBufferV2() 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci``` 534e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetLastFlushedBufferV2 (OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd, float matrix[16] ) 535e41f4b71Sopenharmony_ci``` 536e41f4b71Sopenharmony_ci 537e41f4b71Sopenharmony_ci**描述** 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci从OHNativeWindow获取上次送回到buffer队列中的OHNativeWindowBuffer, 与OH_NativeWindow_GetLastFlushedBuffer的差异在于matrix不同。 540e41f4b71Sopenharmony_ci本接口需要与OH_NativeWindow_NativeObjectUnreference接口配合使用,否则会存在内存泄露。 541e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 542e41f4b71Sopenharmony_ci 543e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 544e41f4b71Sopenharmony_ci 545e41f4b71Sopenharmony_ci**起始版本:** 12 546e41f4b71Sopenharmony_ci 547e41f4b71Sopenharmony_ci**参数:** 548e41f4b71Sopenharmony_ci 549e41f4b71Sopenharmony_ci| 名称 | 描述 | 550e41f4b71Sopenharmony_ci| -------- | -------- | 551e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 552e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer结构体指针的指针。 | 553e41f4b71Sopenharmony_ci| fenceFd | 一个文件描述符的指针。 | 554e41f4b71Sopenharmony_ci| matrix | 表示检索到的4\*4变换矩阵。 | 555e41f4b71Sopenharmony_ci 556e41f4b71Sopenharmony_ci**返回:** 557e41f4b71Sopenharmony_ci 558e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 559e41f4b71Sopenharmony_ci 560e41f4b71Sopenharmony_ci 561e41f4b71Sopenharmony_ci 562e41f4b71Sopenharmony_ci### OH_NativeWindow_SetBufferHold() 563e41f4b71Sopenharmony_ci 564e41f4b71Sopenharmony_ci``` 565e41f4b71Sopenharmony_civoid OH_NativeWindow_SetBufferHold (OHNativeWindow *window) 566e41f4b71Sopenharmony_ci``` 567e41f4b71Sopenharmony_ci**描述** 568e41f4b71Sopenharmony_ci提前缓存一帧buffer,且缓存的这一帧延迟一帧上屏显示,以此抵消后续一次超长帧丢帧。 569e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci**起始版本:** 12 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ci**参数:** 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ci| 名称 | 描述 | 578e41f4b71Sopenharmony_ci| -------- | -------- | 579e41f4b71Sopenharmony_ci| window | 一个[OHNativeWindow](_o_h___native_image.md#ohnativewindow)的结构体实例的指针。 | 580e41f4b71Sopenharmony_ci 581e41f4b71Sopenharmony_ci 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindow() 584e41f4b71Sopenharmony_ci 585e41f4b71Sopenharmony_ci``` 586e41f4b71Sopenharmony_ciOHNativeWindow* OH_NativeWindow_CreateNativeWindow (void* pSurface) 587e41f4b71Sopenharmony_ci``` 588e41f4b71Sopenharmony_ci 589e41f4b71Sopenharmony_ci**描述** 590e41f4b71Sopenharmony_ci 591e41f4b71Sopenharmony_ci创建OHNativeWindow实例,每次调用都会产生一个新的OHNativeWindow实例。 说明:此接口不可用,可通过**OH_NativeImage_AcquireNativeWindow**创建,或通过XComponent创建。 592e41f4b71Sopenharmony_ci 593e41f4b71Sopenharmony_ci**废弃版本:** 12 594e41f4b71Sopenharmony_ci 595e41f4b71Sopenharmony_ci**替代接口:** 不再提供替代接口。 596e41f4b71Sopenharmony_ci 597e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ci**起始版本:** 8 600e41f4b71Sopenharmony_ci 601e41f4b71Sopenharmony_ci**参数:** 602e41f4b71Sopenharmony_ci 603e41f4b71Sopenharmony_ci| 名称 | 描述 | 604e41f4b71Sopenharmony_ci| -------- | -------- | 605e41f4b71Sopenharmony_ci| pSurface | 一个指向生产者ProduceSurface的指针,类型为sptr<OHOS::Surface>。 | 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_ci**返回:** 608e41f4b71Sopenharmony_ci 609e41f4b71Sopenharmony_ci返回一个指针,指向OHNativeWindow的结构体实例。 610e41f4b71Sopenharmony_ci 611e41f4b71Sopenharmony_ci 612e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer() 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci``` 615e41f4b71Sopenharmony_ciOHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer (OH_NativeBuffer* nativeBuffer) 616e41f4b71Sopenharmony_ci``` 617e41f4b71Sopenharmony_ci 618e41f4b71Sopenharmony_ci**描述** 619e41f4b71Sopenharmony_ci 620e41f4b71Sopenharmony_ci创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例。 621e41f4b71Sopenharmony_ci本接口需要与OH_NativeWindow_DestroyNativeWindowBuffer接口配合使用,否则会存在内存泄露。 622e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 623e41f4b71Sopenharmony_ci 624e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 625e41f4b71Sopenharmony_ci 626e41f4b71Sopenharmony_ci**起始版本:** 11 627e41f4b71Sopenharmony_ci 628e41f4b71Sopenharmony_ci**参数:** 629e41f4b71Sopenharmony_ci 630e41f4b71Sopenharmony_ci| 名称 | 描述 | 631e41f4b71Sopenharmony_ci| -------- | -------- | 632e41f4b71Sopenharmony_ci| nativeBuffer | 一个指向OH_NativeBuffer的指针。 | 633e41f4b71Sopenharmony_ci 634e41f4b71Sopenharmony_ci**返回:** 635e41f4b71Sopenharmony_ci 636e41f4b71Sopenharmony_ci返回一个指针,指向OHNativeWindowBuffer的结构体实例。 637e41f4b71Sopenharmony_ci 638e41f4b71Sopenharmony_ci 639e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer() 640e41f4b71Sopenharmony_ci 641e41f4b71Sopenharmony_ci``` 642e41f4b71Sopenharmony_ciOHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void* pSurfaceBuffer) 643e41f4b71Sopenharmony_ci``` 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci**描述** 646e41f4b71Sopenharmony_ci 647e41f4b71Sopenharmony_ci创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例。 648e41f4b71Sopenharmony_ci 649e41f4b71Sopenharmony_ci**废弃版本:** 12 650e41f4b71Sopenharmony_ci 651e41f4b71Sopenharmony_ci**替代接口:** [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer) 652e41f4b71Sopenharmony_ci 653e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 654e41f4b71Sopenharmony_ci 655e41f4b71Sopenharmony_ci**起始版本:** 8 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci**参数:** 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci| 名称 | 描述 | 660e41f4b71Sopenharmony_ci| -------- | -------- | 661e41f4b71Sopenharmony_ci| pSurfaceBuffer | 一个指向生产者buffer的指针,类型为sptr<OHOS::SurfaceBuffer>。 | 662e41f4b71Sopenharmony_ci 663e41f4b71Sopenharmony_ci**返回:** 664e41f4b71Sopenharmony_ci 665e41f4b71Sopenharmony_ci返回一个指针,指向OHNativeWindowBuffer的结构体实例。 666e41f4b71Sopenharmony_ci 667e41f4b71Sopenharmony_ci 668e41f4b71Sopenharmony_ci### OH_NativeWindow_CreateNativeWindowFromSurfaceId() 669e41f4b71Sopenharmony_ci 670e41f4b71Sopenharmony_ci``` 671e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId (uint64_t surfaceId, OHNativeWindow **window ) 672e41f4b71Sopenharmony_ci``` 673e41f4b71Sopenharmony_ci 674e41f4b71Sopenharmony_ci**描述** 675e41f4b71Sopenharmony_ci 676e41f4b71Sopenharmony_ci通过surfaceId创建对应的OHNativeWindow。 677e41f4b71Sopenharmony_ci本接口需要与OH_NativeWindow_DestroyNativeWindow接口配合使用,否则会存在内存泄露。 678e41f4b71Sopenharmony_ci如果存在并发释放OHNativeWindow的情况,需要通过OH_NativeWindow_NativeObjectReference和 679e41f4b71Sopenharmony_ciOH_NativeWindow_NativeObjectUnreference对OHNativeWindow进行引用计数加一和减一。 680e41f4b71Sopenharmony_ci通过surfaceId获取的surface需要是在本进程中创建的,不能跨进程获取surface。 681e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 682e41f4b71Sopenharmony_ci 683e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 684e41f4b71Sopenharmony_ci 685e41f4b71Sopenharmony_ci**起始版本:** 12 686e41f4b71Sopenharmony_ci 687e41f4b71Sopenharmony_ci**参数:** 688e41f4b71Sopenharmony_ci 689e41f4b71Sopenharmony_ci| 名称 | 描述 | 690e41f4b71Sopenharmony_ci| -------- | -------- | 691e41f4b71Sopenharmony_ci| surfaceId | 一个surface对应的ID。 | 692e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的二级指针。 | 693e41f4b71Sopenharmony_ci 694e41f4b71Sopenharmony_ci**返回:** 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 697e41f4b71Sopenharmony_ci 698e41f4b71Sopenharmony_ci 699e41f4b71Sopenharmony_ci### OH_NativeWindow_DestroyNativeWindow() 700e41f4b71Sopenharmony_ci 701e41f4b71Sopenharmony_ci``` 702e41f4b71Sopenharmony_civoid OH_NativeWindow_DestroyNativeWindow (OHNativeWindow* window) 703e41f4b71Sopenharmony_ci``` 704e41f4b71Sopenharmony_ci 705e41f4b71Sopenharmony_ci**描述** 706e41f4b71Sopenharmony_ci 707e41f4b71Sopenharmony_ci将OHNativeWindow对象的引用计数减1,当引用计数为0的时候,该OHNativeWindow对象会被析构掉。 708e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 709e41f4b71Sopenharmony_ci 710e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 711e41f4b71Sopenharmony_ci 712e41f4b71Sopenharmony_ci**起始版本:** 8 713e41f4b71Sopenharmony_ci 714e41f4b71Sopenharmony_ci**参数:** 715e41f4b71Sopenharmony_ci 716e41f4b71Sopenharmony_ci| 名称 | 描述 | 717e41f4b71Sopenharmony_ci| -------- | -------- | 718e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 719e41f4b71Sopenharmony_ci 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_ci### OH_NativeWindow_DestroyNativeWindowBuffer() 722e41f4b71Sopenharmony_ci 723e41f4b71Sopenharmony_ci``` 724e41f4b71Sopenharmony_civoid OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer* buffer) 725e41f4b71Sopenharmony_ci``` 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci**描述** 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci将OHNativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该OHNativeWindowBuffer对象会被析构掉。 730e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 731e41f4b71Sopenharmony_ci 732e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 733e41f4b71Sopenharmony_ci 734e41f4b71Sopenharmony_ci**起始版本:** 8 735e41f4b71Sopenharmony_ci 736e41f4b71Sopenharmony_ci**参数:** 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci| 名称 | 描述 | 739e41f4b71Sopenharmony_ci| -------- | -------- | 740e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的指针。 | 741e41f4b71Sopenharmony_ci 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_ci### OH_NativeWindow_GetBufferHandleFromNative() 744e41f4b71Sopenharmony_ci 745e41f4b71Sopenharmony_ci``` 746e41f4b71Sopenharmony_ciBufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer* buffer) 747e41f4b71Sopenharmony_ci``` 748e41f4b71Sopenharmony_ci 749e41f4b71Sopenharmony_ci**描述** 750e41f4b71Sopenharmony_ci 751e41f4b71Sopenharmony_ci通过OHNativeWindowBuffer获取该buffer的BufferHandle指针。 752e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 753e41f4b71Sopenharmony_ci 754e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 755e41f4b71Sopenharmony_ci 756e41f4b71Sopenharmony_ci**起始版本:** 8 757e41f4b71Sopenharmony_ci 758e41f4b71Sopenharmony_ci**参数:** 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_ci| 名称 | 描述 | 761e41f4b71Sopenharmony_ci| -------- | -------- | 762e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的指针。 | 763e41f4b71Sopenharmony_ci 764e41f4b71Sopenharmony_ci**返回:** 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ciBufferHandle 返回一个指针,指向BufferHandle的结构体实例。 767e41f4b71Sopenharmony_ci 768e41f4b71Sopenharmony_ci 769e41f4b71Sopenharmony_ci### OH_NativeWindow_GetLastFlushedBuffer() 770e41f4b71Sopenharmony_ci 771e41f4b71Sopenharmony_ci``` 772e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetLastFlushedBuffer (OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd, float matrix[16] ) 773e41f4b71Sopenharmony_ci``` 774e41f4b71Sopenharmony_ci 775e41f4b71Sopenharmony_ci**描述** 776e41f4b71Sopenharmony_ci 777e41f4b71Sopenharmony_ci从OHNativeWindow获取上次送回到buffer队列中的OHNativeWindowBuffer。 778e41f4b71Sopenharmony_ci 779e41f4b71Sopenharmony_ci**废弃版本:** 12 780e41f4b71Sopenharmony_ci 781e41f4b71Sopenharmony_ci**替代接口:** [OH_NativeWindow_GetLastFlushedBufferV2](#oh_nativewindow_getlastflushedbufferv2) 782e41f4b71Sopenharmony_ci 783e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci**起始版本:** 11 786e41f4b71Sopenharmony_ci 787e41f4b71Sopenharmony_ci**参数:** 788e41f4b71Sopenharmony_ci 789e41f4b71Sopenharmony_ci| 名称 | 描述 | 790e41f4b71Sopenharmony_ci| -------- | -------- | 791e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 792e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer结构体指针的指针。 | 793e41f4b71Sopenharmony_ci| fenceFd | 一个文件描述符的指针。 | 794e41f4b71Sopenharmony_ci| matrix | 表示检索到的4\*4变换矩阵。 | 795e41f4b71Sopenharmony_ci 796e41f4b71Sopenharmony_ci**返回:** 797e41f4b71Sopenharmony_ci 798e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 799e41f4b71Sopenharmony_ci 800e41f4b71Sopenharmony_ci 801e41f4b71Sopenharmony_ci### OH_NativeWindow_GetNativeObjectMagic() 802e41f4b71Sopenharmony_ci 803e41f4b71Sopenharmony_ci``` 804e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetNativeObjectMagic (void *obj) 805e41f4b71Sopenharmony_ci``` 806e41f4b71Sopenharmony_ci 807e41f4b71Sopenharmony_ci**描述** 808e41f4b71Sopenharmony_ci 809e41f4b71Sopenharmony_ci获取NativeObject的MagicId。 810e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 811e41f4b71Sopenharmony_ci 812e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 813e41f4b71Sopenharmony_ci 814e41f4b71Sopenharmony_ci**起始版本:** 8 815e41f4b71Sopenharmony_ci 816e41f4b71Sopenharmony_ci**参数:** 817e41f4b71Sopenharmony_ci 818e41f4b71Sopenharmony_ci| 名称 | 描述 | 819e41f4b71Sopenharmony_ci| -------- | -------- | 820e41f4b71Sopenharmony_ci| obj | 一个OHNativeWindow或者OHNativeWindowBuffer的结构体实例的指针。 | 821e41f4b71Sopenharmony_ci 822e41f4b71Sopenharmony_ci**返回:** 823e41f4b71Sopenharmony_ci 824e41f4b71Sopenharmony_ciMagicId 返回值为魔鬼数字,每个NativeObject唯一。 825e41f4b71Sopenharmony_ci 826e41f4b71Sopenharmony_ci 827e41f4b71Sopenharmony_ci### OH_NativeWindow_GetSurfaceId() 828e41f4b71Sopenharmony_ci 829e41f4b71Sopenharmony_ci``` 830e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_GetSurfaceId (OHNativeWindow *window, uint64_t *surfaceId ) 831e41f4b71Sopenharmony_ci``` 832e41f4b71Sopenharmony_ci 833e41f4b71Sopenharmony_ci**描述** 834e41f4b71Sopenharmony_ci 835e41f4b71Sopenharmony_ci通过OHNativeWindow获取对应的surfaceId。 836e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 839e41f4b71Sopenharmony_ci 840e41f4b71Sopenharmony_ci**起始版本:** 12 841e41f4b71Sopenharmony_ci 842e41f4b71Sopenharmony_ci**参数:** 843e41f4b71Sopenharmony_ci 844e41f4b71Sopenharmony_ci| 名称 | 描述 | 845e41f4b71Sopenharmony_ci| -------- | -------- | 846e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 847e41f4b71Sopenharmony_ci| surfaceId | 一个surface对应ID的指针。 | 848e41f4b71Sopenharmony_ci 849e41f4b71Sopenharmony_ci**返回:** 850e41f4b71Sopenharmony_ci 851e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 852e41f4b71Sopenharmony_ci 853e41f4b71Sopenharmony_ci 854e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeObjectReference() 855e41f4b71Sopenharmony_ci 856e41f4b71Sopenharmony_ci``` 857e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeObjectReference (void *obj) 858e41f4b71Sopenharmony_ci``` 859e41f4b71Sopenharmony_ci 860e41f4b71Sopenharmony_ci**描述** 861e41f4b71Sopenharmony_ci 862e41f4b71Sopenharmony_ci增加一个NativeObject的引用计数。 863e41f4b71Sopenharmony_ci本接口需要与OH_NativeWindow_NativeObjectUnreference接口配合使用,否则会存在内存泄露。 864e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 865e41f4b71Sopenharmony_ci 866e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 867e41f4b71Sopenharmony_ci 868e41f4b71Sopenharmony_ci**起始版本:** 8 869e41f4b71Sopenharmony_ci 870e41f4b71Sopenharmony_ci**参数:** 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ci| 名称 | 描述 | 873e41f4b71Sopenharmony_ci| -------- | -------- | 874e41f4b71Sopenharmony_ci| obj | 一个OHNativeWindow或者OHNativeWindowBuffer的结构体实例的指针。 | 875e41f4b71Sopenharmony_ci 876e41f4b71Sopenharmony_ci**返回:** 877e41f4b71Sopenharmony_ci 878e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 879e41f4b71Sopenharmony_ci 880e41f4b71Sopenharmony_ci 881e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeObjectUnreference() 882e41f4b71Sopenharmony_ci 883e41f4b71Sopenharmony_ci``` 884e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeObjectUnreference (void *obj) 885e41f4b71Sopenharmony_ci``` 886e41f4b71Sopenharmony_ci 887e41f4b71Sopenharmony_ci**描述** 888e41f4b71Sopenharmony_ci 889e41f4b71Sopenharmony_ci减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉。 890e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 891e41f4b71Sopenharmony_ci 892e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 893e41f4b71Sopenharmony_ci 894e41f4b71Sopenharmony_ci**起始版本:** 8 895e41f4b71Sopenharmony_ci 896e41f4b71Sopenharmony_ci**参数:** 897e41f4b71Sopenharmony_ci 898e41f4b71Sopenharmony_ci| 名称 | 描述 | 899e41f4b71Sopenharmony_ci| -------- | -------- | 900e41f4b71Sopenharmony_ci| obj | 一个OHNativeWindow或者OHNativeWindowBuffer的结构体实例的指针。 | 901e41f4b71Sopenharmony_ci 902e41f4b71Sopenharmony_ci**返回:** 903e41f4b71Sopenharmony_ci 904e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 905e41f4b71Sopenharmony_ci 906e41f4b71Sopenharmony_ci 907e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowAbortBuffer() 908e41f4b71Sopenharmony_ci 909e41f4b71Sopenharmony_ci``` 910e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer ) 911e41f4b71Sopenharmony_ci``` 912e41f4b71Sopenharmony_ci 913e41f4b71Sopenharmony_ci**描述** 914e41f4b71Sopenharmony_ci 915e41f4b71Sopenharmony_ci通过OHNativeWindow将之前申请出来的OHNativeWindowBuffer返还到Buffer队列中,供下次再申请。 916e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 917e41f4b71Sopenharmony_ci 918e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 919e41f4b71Sopenharmony_ci 920e41f4b71Sopenharmony_ci**起始版本:** 8 921e41f4b71Sopenharmony_ci 922e41f4b71Sopenharmony_ci**参数:** 923e41f4b71Sopenharmony_ci 924e41f4b71Sopenharmony_ci| 名称 | 描述 | 925e41f4b71Sopenharmony_ci| -------- | -------- | 926e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 927e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的指针。 | 928e41f4b71Sopenharmony_ci 929e41f4b71Sopenharmony_ci**返回:** 930e41f4b71Sopenharmony_ci 931e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 932e41f4b71Sopenharmony_ci 933e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowAttachBuffer() 934e41f4b71Sopenharmony_ci 935e41f4b71Sopenharmony_ci``` 936e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowAttachBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer ) 937e41f4b71Sopenharmony_ci``` 938e41f4b71Sopenharmony_ci 939e41f4b71Sopenharmony_ci**描述** 940e41f4b71Sopenharmony_ci 941e41f4b71Sopenharmony_ci将OHNativeWindowBuffer添加进OHNativeWindow中。 942e41f4b71Sopenharmony_ci本接口需要与OH_NativeWindow_NativeWindowDetachBuffer接口配合使用,否则会存在内存管理混乱问题。 943e41f4b71Sopenharmony_ci本接口为非线程安全类型接口 944e41f4b71Sopenharmony_ci 945e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 946e41f4b71Sopenharmony_ci 947e41f4b71Sopenharmony_ci**起始版本:** 12 948e41f4b71Sopenharmony_ci 949e41f4b71Sopenharmony_ci**参数:** 950e41f4b71Sopenharmony_ci 951e41f4b71Sopenharmony_ci| 名称 | 描述 | 952e41f4b71Sopenharmony_ci| -------- | -------- | 953e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 954e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的指针。 | 955e41f4b71Sopenharmony_ci 956e41f4b71Sopenharmony_ci**返回:** 957e41f4b71Sopenharmony_ci 958e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 959e41f4b71Sopenharmony_ci 960e41f4b71Sopenharmony_ci 961e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowDetachBuffer() 962e41f4b71Sopenharmony_ci 963e41f4b71Sopenharmony_ci``` 964e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowDetachBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer ) 965e41f4b71Sopenharmony_ci``` 966e41f4b71Sopenharmony_ci 967e41f4b71Sopenharmony_ci**描述** 968e41f4b71Sopenharmony_ci 969e41f4b71Sopenharmony_ci将OHNativeWindowBuffer从OHNativeWindow中分离。 970e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 971e41f4b71Sopenharmony_ci 972e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 973e41f4b71Sopenharmony_ci 974e41f4b71Sopenharmony_ci**起始版本:** 12 975e41f4b71Sopenharmony_ci 976e41f4b71Sopenharmony_ci**参数:** 977e41f4b71Sopenharmony_ci 978e41f4b71Sopenharmony_ci| 名称 | 描述 | 979e41f4b71Sopenharmony_ci| -------- | -------- | 980e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 981e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的指针。 | 982e41f4b71Sopenharmony_ci 983e41f4b71Sopenharmony_ci**返回:** 984e41f4b71Sopenharmony_ci 985e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 986e41f4b71Sopenharmony_ci 987e41f4b71Sopenharmony_ci 988e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowFlushBuffer() 989e41f4b71Sopenharmony_ci 990e41f4b71Sopenharmony_ci``` 991e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow *window, OHNativeWindowBuffer *buffer, int fenceFd, Region region ) 992e41f4b71Sopenharmony_ci``` 993e41f4b71Sopenharmony_ci 994e41f4b71Sopenharmony_ci**描述** 995e41f4b71Sopenharmony_ci 996e41f4b71Sopenharmony_ci通过OHNativeWindow将生产好内容的OHNativeWindowBuffer放回到Buffer队列中,用以内容消费。 997e41f4b71Sopenharmony_ci系统会将fenFd关闭,无需用户close。 998e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 999e41f4b71Sopenharmony_ci 1000e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1001e41f4b71Sopenharmony_ci 1002e41f4b71Sopenharmony_ci**起始版本:** 8 1003e41f4b71Sopenharmony_ci 1004e41f4b71Sopenharmony_ci**参数:** 1005e41f4b71Sopenharmony_ci 1006e41f4b71Sopenharmony_ci| 名称 | 描述 | 1007e41f4b71Sopenharmony_ci| -------- | -------- | 1008e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1009e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的指针。 | 1010e41f4b71Sopenharmony_ci| fenceFd | 一个文件描述符句柄,用以同步时序。 | 1011e41f4b71Sopenharmony_ci| region | 表示一块脏区域,该区域有内容更新。 | 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci**返回:** 1014e41f4b71Sopenharmony_ci 1015e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1016e41f4b71Sopenharmony_ci 1017e41f4b71Sopenharmony_ci 1018e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowHandleOpt() 1019e41f4b71Sopenharmony_ci 1020e41f4b71Sopenharmony_ci``` 1021e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow *window, int code, ... ) 1022e41f4b71Sopenharmony_ci``` 1023e41f4b71Sopenharmony_ci 1024e41f4b71Sopenharmony_ci**描述** 1025e41f4b71Sopenharmony_ci 1026e41f4b71Sopenharmony_ci设置/获取OHNativeWindow的属性,包括设置/获取宽高、内容格式等。 1027e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 1028e41f4b71Sopenharmony_ci 1029e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1030e41f4b71Sopenharmony_ci 1031e41f4b71Sopenharmony_ci**起始版本:** 8 1032e41f4b71Sopenharmony_ci 1033e41f4b71Sopenharmony_ci**参数:** 1034e41f4b71Sopenharmony_ci 1035e41f4b71Sopenharmony_ci| 名称 | 描述 | 1036e41f4b71Sopenharmony_ci| -------- | -------- | 1037e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1038e41f4b71Sopenharmony_ci| code | 表示操作码,详见[NativeWindowOperation](#nativewindowoperation)。 | 1039e41f4b71Sopenharmony_ci| ... | 可变参数,必须与操作码对应的数据类型保持一致,且入参数量严格按照操作码提示传入,否则会存在未定义行为。 | 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_ci**返回:** 1042e41f4b71Sopenharmony_ci 1043e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1044e41f4b71Sopenharmony_ci 1045e41f4b71Sopenharmony_ci 1046e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowRequestBuffer() 1047e41f4b71Sopenharmony_ci 1048e41f4b71Sopenharmony_ci``` 1049e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow *window, OHNativeWindowBuffer **buffer, int *fenceFd ) 1050e41f4b71Sopenharmony_ci``` 1051e41f4b71Sopenharmony_ci 1052e41f4b71Sopenharmony_ci**描述** 1053e41f4b71Sopenharmony_ci 1054e41f4b71Sopenharmony_ci通过OHNativeWindow对象申请一块OHNativeWindowBuffer,用以内容生产。 1055e41f4b71Sopenharmony_ci在调用本接口前,需要通过SET_BUFFER_GEOMETRY对OHNativeWindow设置宽高。 1056e41f4b71Sopenharmony_ci本接口需要与OH_NativeWindow_NativeWindowFlushBuffer接口配合使用,否则内存会耗尽。 1057e41f4b71Sopenharmony_ci当fenceFd使用完,用户需要将其close。 1058e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 1059e41f4b71Sopenharmony_ci 1060e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1061e41f4b71Sopenharmony_ci 1062e41f4b71Sopenharmony_ci**起始版本:** 8 1063e41f4b71Sopenharmony_ci 1064e41f4b71Sopenharmony_ci**参数:** 1065e41f4b71Sopenharmony_ci 1066e41f4b71Sopenharmony_ci| 名称 | 描述 | 1067e41f4b71Sopenharmony_ci| -------- | -------- | 1068e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1069e41f4b71Sopenharmony_ci| buffer | 一个OHNativeWindowBuffer的结构体实例的二级指针。 | 1070e41f4b71Sopenharmony_ci| fenceFd | 一个文件描述符句柄。 | 1071e41f4b71Sopenharmony_ci 1072e41f4b71Sopenharmony_ci**返回:** 1073e41f4b71Sopenharmony_ci 1074e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1075e41f4b71Sopenharmony_ci 1076e41f4b71Sopenharmony_ci 1077e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetMetaData() 1078e41f4b71Sopenharmony_ci 1079e41f4b71Sopenharmony_ci``` 1080e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow *window, uint32_t sequence, int32_t size, const OHHDRMetaData *metaData ) 1081e41f4b71Sopenharmony_ci``` 1082e41f4b71Sopenharmony_ci 1083e41f4b71Sopenharmony_ci**描述** 1084e41f4b71Sopenharmony_ci 1085e41f4b71Sopenharmony_ci设置OHNativeWindow的元数据。 1086e41f4b71Sopenharmony_ci 1087e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1088e41f4b71Sopenharmony_ci 1089e41f4b71Sopenharmony_ci**起始版本:** 9 1090e41f4b71Sopenharmony_ci 1091e41f4b71Sopenharmony_ci**弃用:** 从API version 10开始废弃,不再提供替代接口。 1092e41f4b71Sopenharmony_ci 1093e41f4b71Sopenharmony_ci**参数:** 1094e41f4b71Sopenharmony_ci 1095e41f4b71Sopenharmony_ci| 名称 | 描述 | 1096e41f4b71Sopenharmony_ci| -------- | -------- | 1097e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1098e41f4b71Sopenharmony_ci| sequence | 生产缓冲区的序列。 | 1099e41f4b71Sopenharmony_ci| size | OHHDRMetaData数组的大小。 | 1100e41f4b71Sopenharmony_ci| metaDate | 指向OHHDRMetaData数组的指针。 | 1101e41f4b71Sopenharmony_ci 1102e41f4b71Sopenharmony_ci**返回:** 1103e41f4b71Sopenharmony_ci 1104e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1105e41f4b71Sopenharmony_ci 1106e41f4b71Sopenharmony_ci 1107e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetMetaDataSet() 1108e41f4b71Sopenharmony_ci 1109e41f4b71Sopenharmony_ci``` 1110e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t *metaData ) 1111e41f4b71Sopenharmony_ci``` 1112e41f4b71Sopenharmony_ci 1113e41f4b71Sopenharmony_ci**描述** 1114e41f4b71Sopenharmony_ci 1115e41f4b71Sopenharmony_ci设置OHNativeWindow的元数据集。 1116e41f4b71Sopenharmony_ci 1117e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1118e41f4b71Sopenharmony_ci 1119e41f4b71Sopenharmony_ci**起始版本:** 9 1120e41f4b71Sopenharmony_ci 1121e41f4b71Sopenharmony_ci**弃用:** 从API version 10开始废弃,不再提供替代接口。 1122e41f4b71Sopenharmony_ci 1123e41f4b71Sopenharmony_ci**参数:** 1124e41f4b71Sopenharmony_ci 1125e41f4b71Sopenharmony_ci| 名称 | 描述 | 1126e41f4b71Sopenharmony_ci| -------- | -------- | 1127e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1128e41f4b71Sopenharmony_ci| sequence | 生产缓冲区的序列。 | 1129e41f4b71Sopenharmony_ci| key | 枚举值OHHDRMetadataKey。 | 1130e41f4b71Sopenharmony_ci| size | uint8_t向量的大小。 | 1131e41f4b71Sopenharmony_ci| metaDate | 指向uint8_t向量的指针。 | 1132e41f4b71Sopenharmony_ci 1133e41f4b71Sopenharmony_ci**返回:** 1134e41f4b71Sopenharmony_ci 1135e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1136e41f4b71Sopenharmony_ci 1137e41f4b71Sopenharmony_ci 1138e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetScalingMode() 1139e41f4b71Sopenharmony_ci 1140e41f4b71Sopenharmony_ci``` 1141e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow *window, uint32_t sequence, OHScalingMode scalingMode ) 1142e41f4b71Sopenharmony_ci``` 1143e41f4b71Sopenharmony_ci 1144e41f4b71Sopenharmony_ci**描述** 1145e41f4b71Sopenharmony_ci 1146e41f4b71Sopenharmony_ci设置OHNativeWindow的ScalingMode。 1147e41f4b71Sopenharmony_ci 1148e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1149e41f4b71Sopenharmony_ci 1150e41f4b71Sopenharmony_ci**起始版本:** 9 1151e41f4b71Sopenharmony_ci 1152e41f4b71Sopenharmony_ci**弃用:** 从API version 10开始废弃,不再提供替代接口。 1153e41f4b71Sopenharmony_ci 1154e41f4b71Sopenharmony_ci**参数:** 1155e41f4b71Sopenharmony_ci 1156e41f4b71Sopenharmony_ci| 名称 | 描述 | 1157e41f4b71Sopenharmony_ci| -------- | -------- | 1158e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1159e41f4b71Sopenharmony_ci| sequence | 生产缓冲区的序列。 | 1160e41f4b71Sopenharmony_ci| scalingMode | 枚举值OHScalingMode。 | 1161e41f4b71Sopenharmony_ci 1162e41f4b71Sopenharmony_ci**返回:** 1163e41f4b71Sopenharmony_ci 1164e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1165e41f4b71Sopenharmony_ci 1166e41f4b71Sopenharmony_ci 1167e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetScalingModeV2() 1168e41f4b71Sopenharmony_ci 1169e41f4b71Sopenharmony_ci``` 1170e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetScalingModeV2 (OHNativeWindow* window, OHScalingModeV2 scalingMode ) 1171e41f4b71Sopenharmony_ci``` 1172e41f4b71Sopenharmony_ci**描述** 1173e41f4b71Sopenharmony_ci设置OHNativeWindow的渲染缩放模式。 1174e41f4b71Sopenharmony_ci本接口为非线程安全类型接口。 1175e41f4b71Sopenharmony_ci 1176e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1177e41f4b71Sopenharmony_ci 1178e41f4b71Sopenharmony_ci**起始版本:** 12 1179e41f4b71Sopenharmony_ci 1180e41f4b71Sopenharmony_ci**参数:** 1181e41f4b71Sopenharmony_ci 1182e41f4b71Sopenharmony_ci| 名称 | 描述 | 1183e41f4b71Sopenharmony_ci| -------- | -------- | 1184e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1185e41f4b71Sopenharmony_ci| scalingMode | 一个OHScalingModeV2类型的枚举值。 | 1186e41f4b71Sopenharmony_ci 1187e41f4b71Sopenharmony_ci**返回:** 1188e41f4b71Sopenharmony_ci 1189e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1190e41f4b71Sopenharmony_ci 1191e41f4b71Sopenharmony_ci### OH_NativeWindow_NativeWindowSetTunnelHandle() 1192e41f4b71Sopenharmony_ci 1193e41f4b71Sopenharmony_ci``` 1194e41f4b71Sopenharmony_ciint32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow *window, const OHExtDataHandle *handle ) 1195e41f4b71Sopenharmony_ci``` 1196e41f4b71Sopenharmony_ci 1197e41f4b71Sopenharmony_ci**描述** 1198e41f4b71Sopenharmony_ci 1199e41f4b71Sopenharmony_ci设置OHNativeWindow的TunnelHandle。 1200e41f4b71Sopenharmony_ci 1201e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Graphic.Graphic2D.NativeWindow 1202e41f4b71Sopenharmony_ci 1203e41f4b71Sopenharmony_ci**起始版本:** 9 1204e41f4b71Sopenharmony_ci 1205e41f4b71Sopenharmony_ci**弃用:** 从API version 10开始废弃,不再提供替代接口。 1206e41f4b71Sopenharmony_ci 1207e41f4b71Sopenharmony_ci**参数:** 1208e41f4b71Sopenharmony_ci 1209e41f4b71Sopenharmony_ci| 名称 | 描述 | 1210e41f4b71Sopenharmony_ci| -------- | -------- | 1211e41f4b71Sopenharmony_ci| window | 一个OHNativeWindow的结构体实例的指针。 | 1212e41f4b71Sopenharmony_ci| handle | 指向OHExtDataHandle的指针。 | 1213e41f4b71Sopenharmony_ci 1214e41f4b71Sopenharmony_ci**返回:** 1215e41f4b71Sopenharmony_ci 1216e41f4b71Sopenharmony_ci返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](#ohnativeerrorcode)。 1217