1# NativeWindow 2 3 4## Overview 5 6The **NativeWindow** module provides the **NativeWindow** capability for connection to the EGL. 7 8**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 9 10**Since**: 8 11 12 13## Summary 14 15 16### Files 17 18| Name| Description| 19| -------- | -------- | 20| [external_window.h](external__window_8h.md) | Declares the functions for obtaining and using **NativeWindow**.<br>**File to include**: <native_window/external_window.h><br>**Library**: libnative_window.so| 21 22 23### Structs 24 25| Name| Description| 26| -------- | -------- | 27| [Region](_region.md) | Describes the rectangle (dirty region) where the content is to be updated in the local **OHNativeWindow**.| 28| [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | Describes the HDR metadata.| 29| [OHExtDataHandle](_o_h_ext_data_handle.md) | Describes the extended data handle.| 30 31 32### Types 33 34| Name| Description| 35| -------- | -------- | 36| [OHNativeWindow](#ohnativewindow) | Provides the capability of accessing the **OHNativeWindow**.| 37| [OHNativeWindowBuffer](#ohnativewindowbuffer) | Provides the capability of accessing the **OHNativeWindowBuffer**.| 38| [Region](#region) | Describes the rectangle (dirty region) where the content is to be updated in the local **OHNativeWindow**.| 39 40 41### Enums 42 43| Name| Description| 44| -------- | -------- | 45| [NativeWindowOperation](#nativewindowoperation) {<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<br>} | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function.| 46| [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.| 47| [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.| 48 49 50### Functions 51 52| Name| Description| 53| -------- | -------- | 54| [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | Creates an **OHNativeWindow** instance. A new **OHNativeWindow** instance is created each time this function is called.| 55| [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.| 56| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | Creates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called.| 57| [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer) ([OH_NativeBuffer](_o_h___native_buffer.md#oh_nativebuffer) \*nativeBuffer) | Creates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called.| 58| [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.| 59| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) ([OHNativeWindow](#ohnativewindow) \*window, [OHNativeWindowBuffer](#ohnativewindowbuffer) \*\*buffer, int \*fenceFd) | Requests an **OHNativeWindowBuffer** through an **OHNativeWindow** instance for content production.| 60| [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.| 61| [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.| 62| [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.| 63| [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.| 64| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) ([OHNativeWindowBuffer](#ohnativewindowbuffer) \*buffer) | Obtains the pointer to a **BufferHandle** of an **OHNativeWindowBuffer** instance.| 65| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | Adds the reference count of a native object.| 66| [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.| 67| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | Obtains the magic ID of a native object.| 68| [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode) ([OHNativeWindow](#ohnativewindow) \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | Sets a scaling mode for an **OHNativeWindow**.| 69| [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**.| 70| [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**.| 71| [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**.| 72 73 74## Type Description 75 76 77### OHNativeWindow 78 79``` 80typedef struct NativeWindow OHNativeWindow 81``` 82 83**Description** 84 85Provides the capability of accessing the **OHNativeWindow**. 86 87**Since**: 8 88 89 90### OHNativeWindowBuffer 91 92``` 93typedef struct NativeWindowBuffer OHNativeWindowBuffer 94``` 95 96**Description** 97 98Provides the capability of accessing the **OHNativeWindowBuffer**. 99 100**Since**: 8 101 102 103### Region 104 105``` 106typedef struct RegionRegion 107``` 108 109**Description** 110 111Defines the rectangle (dirty region) where the content is to be updated in the local **OHNativeWindow**. 112 113**Since**: 8 114 115 116## Enum Description 117 118 119### NativeWindowOperation 120 121``` 122enum NativeWindowOperation 123``` 124 125**Description** 126 127Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. 128 129**Since**: 8 130 131| Value| Description| 132| -------- | -------- | 133| 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.| 134| 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.| 135| GET_FORMAT | Obtaining the format of the local window buffer.<br>Variable argument in the function: [Output] int32_t *format.<br>For details, see [OH_NativeBuffer_Format](_o_h___native_buffer.md#oh_nativebuffer_format).| 136| SET_FORMAT | Setting the format for the local window buffer.<br>Variable argument in the function: [Input] int32_t format.<br>For details, see [OH_NativeBuffer_Format](_o_h___native_buffer.md#oh_nativebuffer_format).| 137| GET_USAGE | Obtaining the usage mode of the local window buffer.<br>Variable argument in the function: [Output] int32_t *usage.<br>For details, see [OH_NativeBuffer_Format](_o_h___native_buffer.md#oh_nativebuffer_format).| 138| SET_USAGE | Setting the usage mode for the local window buffer.<br>Variable argument in the function: [Input] int32_t usage.<br>For details, see [OH_NativeBuffer_Format](_o_h___native_buffer.md#oh_nativebuffer_format).| 139| SET_STRIDE | Setting the stride for the local window buffer.<br>Variable argument in the function: [Input] int32_t stride.| 140| GET_STRIDE | Obtaining the stride of the local window buffer.<br>Variable argument in the function: [Output] int32_t *stride.| 141| SET_SWAP_INTERVAL | Setting the swap interval for the local window buffer.<br>Variable argument in the function: [Input] int32_t interval.| 142| GET_SWAP_INTERVAL | Obtaining the swap interval of the local window buffer.<br>Variable argument in the function: [Output] int32_t *interval.| 143| SET_TIMEOUT | Setting the timeout duration for requesting the local window buffer.<br>Variable argument in the function: [Input] int32_t timeout.| 144| GET_TIMEOUT | Obtaining the timeout duration for requesting the local window buffer.<br>Variable argument in the function: [Output] int32_t *timeout.| 145| SET_COLOR_GAMUT | Setting the color gamut for the local window buffer.<br>Variable argument in the function: [Input] int32_t colorGamut.| 146| GET_COLOR_GAMUT | Obtaining the color gamut of the local window buffer.<br>Variable argument in the function: [Output] int32_t *colorGamut.| 147| SET_TRANSFORM | Setting the transform for the local window buffer.<br>Variable argument in the function: [Input] int32_t transform.| 148| GET_TRANSFORM | Obtaining the transform of the local window buffer.<br>Variable argument in the function: [Output] int32_t *transform.| 149| SET_UI_TIMESTAMP | Setting the UI timestamp for the local window buffer.<br>Variable argument in the function: [Input] uint64_t uiTimestamp.| 150 151 152### OHHDRMetadataKey 153 154``` 155enum OHHDRMetadataKey 156``` 157 158**Description** 159 160Enumerates the HDR metadata keys. 161 162**Since**: 9 163 164**Deprecated**: This enum is deprecated since API version 10. No substitute is provided. 165 166| Value| Description| 167| -------- | -------- | 168| OH_METAKEY_RED_PRIMARY_X | X coordinate of the red primary color.| 169| OH_METAKEY_RED_PRIMARY_Y | Y coordinate of the red primary color.| 170| OH_METAKEY_GREEN_PRIMARY_X | X coordinate of the green primary color.| 171| OH_METAKEY_GREEN_PRIMARY_Y | Y coordinate of the green primary color.| 172| OH_METAKEY_BLUE_PRIMARY_X | X coordinate of the blue primary color.| 173| OH_METAKEY_BLUE_PRIMARY_Y | Y coordinate of the blue primary color.| 174| OH_METAKEY_WHITE_PRIMARY_X | X coordinate of the white point.| 175| OH_METAKEY_WHITE_PRIMARY_Y | Y coordinate of the white point.| 176| OH_METAKEY_MAX_LUMINANCE | Maximum luminance.| 177| OH_METAKEY_MIN_LUMINANCE | Minimum luminance.| 178| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | Maximum content light level (MaxCLL).| 179| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | Maximum frame average light level (MaxFALLL).| 180| OH_METAKEY_HDR10_PLUS | HDR10 Plus.| 181| OH_METAKEY_HDR_VIVID | Vivid.| 182 183 184### OHScalingMode 185 186``` 187enum OHScalingMode 188``` 189 190**Description** 191 192Enumerates the scaling modes. 193 194**Since**: 9 195 196**Deprecated**: This enum is deprecated since API version 10. No substitute is provided. 197 198| Value| Description| 199| -------- | -------- | 200| OH_SCALING_MODE_FREEZE | The window content cannot be updated before the buffer of the window size is received.| 201| OH_SCALING_MODE_SCALE_TO_WINDOW | The buffer is scaled in two dimensions to match the window size.| 202| OH_SCALING_MODE_SCALE_CROP | The buffer is scaled uniformly so that its smaller size can match the window size.| 203| 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.| 204 205 206## Function Description 207 208 209### OH_NativeWindow_CreateNativeWindow() 210 211``` 212OHNativeWindow* OH_NativeWindow_CreateNativeWindow (void * pSurface) 213``` 214 215**Description** 216 217Creates an **OHNativeWindow** instance. A new **OHNativeWindow** instance is created each time this function is called. 218 219**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 220 221**Since**: 8 222 223**Parameters** 224 225| Name| Description| 226| -------- | -------- | 227| pSurface | Pointer to a **ProduceSurface**. The type is **sptr<OHOS::Surface>**.| 228 229**Returns** 230 231Returns the pointer to the **OHNativeWindow** instance created. 232 233> **NOTE** 234> 235> If this API is unavailable, you can create an **OHNativeWindow** instance by calling [OH_NativeImage_AcquireNativeWindow](_o_h___native_image.md#oh_nativeimage_acquirenativewindow) or through the **\<XComponent>**. 236 237 238### OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer() 239 240``` 241OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer (OH_NativeBuffer * nativeBuffer) 242``` 243 244**Description** 245 246Creates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called. 247 248**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 249 250**Since**: 11 251 252**Parameters** 253 254| Name| Description| 255| -------- | -------- | 256| nativeBuffer | Pointer to an **OH_NativeBuffer** instance.| 257 258**Returns** 259 260Returns the pointer to the **OHNativeWindowBuffer** instance created. 261 262 263### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer() 264 265``` 266OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void * pSurfaceBuffer) 267``` 268 269**Description** 270 271Creates an **OHNativeWindowBuffer** instance. A new **OHNativeWindowBuffer** instance is created each time this function is called. 272 273**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 274 275**Since**: 8 276 277**Parameters** 278 279| Name| Description| 280| -------- | -------- | 281| pSurfaceBuffer | Pointer to a **ProduceSurfaceBuffer**. The type is **sptr<OHOS::SurfaceBuffer>**.| 282 283**Returns** 284 285Returns the pointer to the **OHNativeWindowBuffer** instance created. 286 287> **NOTE** 288> 289> If this API is unavailable, you can create an **OHNativeWindowBuffer** instance by calling [OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer](#oh_nativewindow_createnativewindowbufferfromnativebuffer). 290 291 292### OH_NativeWindow_DestroyNativeWindow() 293 294``` 295void OH_NativeWindow_DestroyNativeWindow (OHNativeWindow * window) 296``` 297 298**Description** 299 300Decreases the reference count of an **OHNativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. 301 302**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 303 304**Since**: 8 305 306**Parameters** 307 308| Name| Description| 309| -------- | -------- | 310| window | Pointer to an **OHNativeWindow** instance.| 311 312 313### OH_NativeWindow_DestroyNativeWindowBuffer() 314 315``` 316void OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer * buffer) 317``` 318 319**Description** 320 321Decreases the reference count of an **OHNativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. 322 323**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 324 325**Since**: 8 326 327**Parameters** 328 329| Name| Description| 330| -------- | -------- | 331| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 332 333 334### OH_NativeWindow_GetBufferHandleFromNative() 335 336``` 337BufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer * buffer) 338``` 339 340**Description** 341 342Obtains the pointer to a **BufferHandle** of an **OHNativeWindowBuffer** instance. 343 344**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 345 346**Since**: 8 347 348**Parameters** 349 350| Name| Description| 351| -------- | -------- | 352| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 353 354**Returns** 355 356Returns the pointer to the **BufferHandle** instance obtained. 357 358 359### OH_NativeWindow_GetLastFlushedBuffer() 360 361``` 362int32_t OH_NativeWindow_GetLastFlushedBuffer (OHNativeWindow * window, OHNativeWindowBuffer **buffer, int *fenceFd, float matrix[16]) 363``` 364 365**Description** 366 367Obtains the **OHNativeWindowBuffer** that was flushed to the buffer queue last time through an **OHNativeWindow** instance. 368 369**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 370 371**Since**: 11 372 373**Parameters** 374 375| Name| Description| 376| -------- | -------- | 377| window | Pointer to an **OHNativeWindow** instance.| 378| buffer | Double pointer to an **OHNativeWindowBuffer** instance.| 379| fenceFd | Pointer to a file descriptor.| 380| matrix | Retrieved 4*4 transformation matrix.| 381 382**Returns** 383 384Returns **0** if the operation is successful. 385 386 387### OH_NativeWindow_GetNativeObjectMagic() 388 389``` 390int32_t OH_NativeWindow_GetNativeObjectMagic (void * obj) 391``` 392 393**Description** 394 395Obtains the magic ID of a native object. 396 397**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 398 399**Since**: 8 400 401**Parameters** 402 403| Name| Description| 404| -------- | -------- | 405| obj | Pointer to an **OHNativeWindow** or **OHNativeWindowBuffer** instance.| 406 407**Returns** 408 409Returns the magic ID, which is unique for each native object. 410 411 412### OH_NativeWindow_NativeObjectReference() 413 414``` 415int32_t OH_NativeWindow_NativeObjectReference (void * obj) 416``` 417 418**Description** 419 420Adds the reference count of a native object. 421 422**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 423 424**Since**: 8 425 426**Parameters** 427 428| Name| Description| 429| -------- | -------- | 430| obj | Pointer to an **OHNativeWindow** or **OHNativeWindowBuffer** instance.| 431 432**Returns** 433 434Returns **0** if the operation is successful. 435 436 437### OH_NativeWindow_NativeObjectUnreference() 438 439``` 440int32_t OH_NativeWindow_NativeObjectUnreference (void * obj) 441``` 442 443**Description** 444 445Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. 446 447**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 448 449**Since**: 8 450 451**Parameters** 452 453| Name| Description| 454| -------- | -------- | 455| obj | Pointer to an **OHNativeWindow** or **OHNativeWindowBuffer** instance.| 456 457**Returns** 458 459Returns **0** if the operation is successful. 460 461 462### OH_NativeWindow_NativeWindowAbortBuffer() 463 464``` 465int32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer ) 466``` 467 468**Description** 469 470Returns the **OHNativeWindowBuffer** to the buffer queue through an **OHNativeWindow** instance, without filling in any content. The **OHNativeWindowBuffer** can be used for a new request. 471 472**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 473 474**Since**: 8 475 476**Parameters** 477 478| Name| Description| 479| -------- | -------- | 480| window | Pointer to an **OHNativeWindow** instance.| 481| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 482 483**Returns** 484 485Returns **0** if the operation is successful. 486 487 488### OH_NativeWindow_NativeWindowFlushBuffer() 489 490``` 491int32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer, int fenceFd, Region region ) 492``` 493 494**Description** 495 496Flushes the **OHNativeWindowBuffer** filled with the produced content to the buffer queue through an **OHNativeWindow** instance for content consumption. 497 498**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 499 500**Since**: 8 501 502**Parameters** 503 504| Name| Description| 505| -------- | -------- | 506| window | Pointer to an **OHNativeWindow** instance.| 507| buffer | Pointer to an **OHNativeWindowBuffer** instance.| 508| fenceFd | File descriptor handle, which is used for timing synchronization.| 509| region | Dirty region where content is updated.| 510 511**Returns** 512 513Returns **0** if the operation is successful. 514 515 516### OH_NativeWindow_NativeWindowHandleOpt() 517 518``` 519int32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow * window, int code, ... ) 520``` 521 522**Description** 523 524Sets or obtains the attributes of an **OHNativeWindow** instance, including the width, height, and content format. 525 526**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 527 528**Since**: 8 529 530**Parameters** 531 532| Name| Description| 533| -------- | -------- | 534| window | Pointer to an **OHNativeWindow** instance.| 535| code | Operation code. For details, see [NativeWindowOperation](#nativewindowoperation).| 536| ... | Variable argument, which must correspond to the operation code.| 537 538**Returns** 539 540Returns **0** if the operation is successful. 541 542 543### OH_NativeWindow_NativeWindowRequestBuffer() 544 545``` 546int32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow * window, OHNativeWindowBuffer ** buffer, int * fenceFd ) 547``` 548 549**Description** 550 551Requests an **OHNativeWindowBuffer** through an **OHNativeWindow** instance for content production. 552 553**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 554 555**Since**: 8 556 557**Parameters** 558 559| Name| Description| 560| -------- | -------- | 561| window | Pointer to an **OHNativeWindow** instance.| 562| buffer | Double pointer to an **OHNativeWindowBuffer** instance.| 563| fenceFd | Pointer to a file descriptor handle.| 564 565**Returns** 566 567Returns **0** if the operation is successful. 568 569 570### OH_NativeWindow_NativeWindowSetMetaData() 571 572``` 573int32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow * window, uint32_t sequence, int32_t size, const OHHDRMetaData * metaData ) 574``` 575 576**Description** 577 578Sets metadata for an **OHNativeWindow**. 579 580**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 581 582**Since**: 9 583 584**Parameters** 585 586| Name| Description| 587| -------- | -------- | 588| window | Pointer to an **OHNativeWindow** instance.| 589| sequence | Sequence of the producer buffer.| 590| size | Size of the **OHHDRMetaData** array.| 591| metaData| Pointer to the **OHHDRMetaData** array.| 592 593**Returns** 594 595Returns **0** if the operation is successful. 596 597**Deprecated** 598 599This function is deprecated since API version 10. No substitute is provided. 600 601 602### OH_NativeWindow_NativeWindowSetMetaDataSet() 603 604``` 605int32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow * window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t * metaData ) 606``` 607 608**Description** 609 610Sets a metadata set for an **OHNativeWindow**. 611 612**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 613 614**Since**: 9 615 616**Parameters** 617 618| Name| Description| 619| -------- | -------- | 620| window | Pointer to an **OHNativeWindow** instance.| 621| sequence | Sequence of the producer buffer.| 622| key | Metadata key. For details, see [OHHDRMetadataKey](#ohhdrmetadatakey).| 623| size | Size of the uint8_t vector.| 624| metaData| Pointer to the uint8_t vector.| 625 626**Returns** 627 628Returns **0** if the operation is successful. 629 630**Deprecated** 631 632This function is deprecated since API version 10. No substitute is provided. 633 634 635### OH_NativeWindow_NativeWindowSetScalingMode() 636 637``` 638int32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow * window, uint32_t sequence, OHScalingMode scalingMode ) 639``` 640 641**Description** 642 643Sets a scaling mode for an **OHNativeWindow**. 644 645**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 646 647**Since**: 9 648 649**Parameters** 650 651| Name| Description| 652| -------- | -------- | 653| window | Pointer to an **OHNativeWindow** instance.| 654| sequence | Sequence of the producer buffer.| 655| scalingMode | Scaling mode to set. For details, see [OHScalingMode](#ohscalingmode).| 656 657**Returns** 658 659Returns **0** if the operation is successful. 660 661**Deprecated** 662 663This function is deprecated since API version 10. No substitute is provided. 664 665 666### OH_NativeWindow_NativeWindowSetTunnelHandle() 667 668``` 669int32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow * window, const OHExtDataHandle * handle ) 670``` 671 672**Description** 673 674Sets a tunnel handle to an **OHNativeWindow**. 675 676**System capability**: SystemCapability.Graphic.Graphic2D.NativeWindow 677 678**Since**: 9 679 680**Parameters** 681 682| Name| Description| 683| -------- | -------- | 684| window | Pointer to an **OHNativeWindow** instance.| 685| handle | Pointer to an [OHExtDataHandle](_o_h_ext_data_handle.md).| 686 687**Returns** 688 689Returns **0** if the operation is successful. 690 691**Deprecated** 692 693This function is deprecated since API version 10. No substitute is provided. 694