1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup NativeWindow 18 * @{ 19 * 20 * @brief Provides the native window capability for connection to the EGL. 21 * 22 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 23 * @since 8 24 * @version 1.0 25 */ 26 27 /** 28 * @file external_window.h 29 * 30 * @brief Defines the functions for obtaining and using a native window. 31 * 32 * @library libnative_window.so 33 * @since 8 34 * @version 1.0 35 */ 36 37 #ifndef NDK_INCLUDE_EXTERNAL_NATIVE_WINDOW_H_ 38 #define NDK_INCLUDE_EXTERNAL_NATIVE_WINDOW_H_ 39 40 #include <stdint.h> 41 #include "buffer_handle.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 typedef struct OH_NativeBuffer OH_NativeBuffer; 47 48 /** 49 * @brief Defines the ipc parcel. 50 * 51 * @since 12 52 * @version 1.0 53 */ 54 typedef struct OHIPCParcel OHIPCParcel; 55 56 /** 57 * @brief native window. 58 * @since 8 59 */ 60 struct NativeWindow; 61 62 /** 63 * @brief native window buffer. 64 * @since 8 65 */ 66 struct NativeWindowBuffer; 67 68 /** 69 * @brief define the new type name OHNativeWindow for struct NativeWindow. 70 * @since 8 71 */ 72 typedef struct NativeWindow OHNativeWindow; 73 74 /** 75 * @brief define the new type name OHNativeWindowBuffer for struct NativeWindowBuffer. 76 * @since 8 77 */ 78 typedef struct NativeWindowBuffer OHNativeWindowBuffer; 79 80 /** 81 * @brief indicates a dirty region where content is updated. 82 * @since 8 83 */ 84 typedef struct Region { 85 /** if rects is nullptr, fill the Buffer dirty size by default */ 86 struct Rect { 87 int32_t x; 88 int32_t y; 89 uint32_t w; 90 uint32_t h; 91 } *rects; 92 /** if rectNumber is 0, fill the Buffer dirty size by default */ 93 int32_t rectNumber; 94 }Region; 95 96 97 /** 98 * @brief Indicates the operation code in the function OH_NativeWindow_NativeWindowHandleOpt. 99 * @since 8 100 */ 101 typedef enum NativeWindowOperation { 102 /** 103 * set native window buffer geometry, 104 * variable parameter in function is 105 * [in] int32_t width, [in] int32_t height 106 */ 107 SET_BUFFER_GEOMETRY, 108 /** 109 * get native window buffer geometry, 110 * variable parameter in function is 111 * [out] int32_t *height, [out] int32_t *width 112 */ 113 GET_BUFFER_GEOMETRY, 114 /** 115 * get native window buffer format, 116 * variable parameter in function is 117 * [out] int32_t *format 118 */ 119 GET_FORMAT, 120 /** 121 * set native window buffer format, 122 * variable parameter in function is 123 * [in] int32_t format 124 */ 125 SET_FORMAT, 126 /** 127 * get native window buffer usage, 128 * variable parameter in function is 129 * [out] uint64_t *usage. 130 */ 131 GET_USAGE, 132 /** 133 * set native window buffer usage, 134 * variable parameter in function is 135 * [in] uint64_t usage. 136 */ 137 SET_USAGE, 138 /** 139 * set native window buffer stride in bytes, 140 * variable parameter in function is 141 * [in] int32_t stride, in bytes. 142 * @deprecated since 16 143 */ 144 SET_STRIDE, 145 /** 146 * get native window buffer stride in bytes, 147 * variable parameter in function is 148 * [out] int32_t *stride, in bytes. 149 * @deprecated since 16 150 * @useinstead Use OH_NativeWindow_GetBufferHandleFromNative to get a BufferHandleand from a buffer 151 * and then retrieve the stride from the BufferHandle. 152 */ 153 GET_STRIDE, 154 /** 155 * set native window buffer swap interval, 156 * variable parameter in function is 157 * [in] int32_t interval. 158 * @deprecated since 14 159 */ 160 SET_SWAP_INTERVAL, 161 /** 162 * get native window buffer swap interval, 163 * variable parameter in function is 164 * [out] int32_t *interval. 165 * @deprecated since 14 166 */ 167 GET_SWAP_INTERVAL, 168 /** 169 * set the timeout in milliseconds when the native window requests a buffer, 170 * the default value is 3000 milliseconds when not set, 171 * variable parameter in function is 172 * [in] int32_t timeout, in milliseconds. 173 */ 174 SET_TIMEOUT, 175 /** 176 * get the timeout in milliseconds when the native window requests a buffer, 177 * the default value is 3000 milliseconds when not set, 178 * variable parameter in function is 179 * [out] int32_t *timeout, in milliseconds. 180 */ 181 GET_TIMEOUT, 182 /** 183 * set native window buffer colorGamut, 184 * variable parameter in function is 185 * [in] int32_t colorGamut. 186 */ 187 SET_COLOR_GAMUT, 188 /** 189 * get native window buffer colorGamut, 190 * variable parameter in function is 191 * [out] int32_t *colorGamut. 192 */ 193 GET_COLOR_GAMUT, 194 /** 195 * set native window buffer transform, 196 * variable parameter in function is 197 * [in] int32_t transform. 198 */ 199 SET_TRANSFORM, 200 /** 201 * get native window buffer transform, 202 * variable parameter in function is 203 * [out] int32_t *transform. 204 */ 205 GET_TRANSFORM, 206 /** 207 * set native window buffer uiTimestamp, 208 * variable parameter in function is 209 * [in] uint64_t uiTimestamp. 210 */ 211 SET_UI_TIMESTAMP, 212 /** 213 * get native window bufferqueue size, 214 * variable parameter in function is 215 * [out] int32_t *size. 216 * @since 12 217 */ 218 GET_BUFFERQUEUE_SIZE, 219 /** 220 * set surface source type, 221 * variable parameter in function is 222 * [in] int32_t sourceType. 223 * @since 12 224 */ 225 SET_SOURCE_TYPE, 226 /** 227 * get surface source type, 228 * variable parameter in function is 229 * [out] int32_t *sourceType. 230 * @since 12 231 */ 232 GET_SOURCE_TYPE, 233 /** 234 * set app framework type, 235 * variable parameter in function is 236 * [in] char* frameworkType. maximum length is 64 bytes, otherwise the setting fails. 237 * @since 12 238 */ 239 SET_APP_FRAMEWORK_TYPE, 240 /** 241 * get app framework type, 242 * variable parameter in function is 243 * [out] char** frameworkType. 244 * @since 12 245 */ 246 GET_APP_FRAMEWORK_TYPE, 247 /** 248 * set hdr white point brightness, 249 * variable parameter in function is 250 * [in] float brightness. the value range is 0.0f to 1.0f. 251 * @since 12 252 */ 253 SET_HDR_WHITE_POINT_BRIGHTNESS, 254 /** 255 * set sdr white point brightness, 256 * variable parameter in function is 257 * [in] float brightness. the value range is 0.0f to 1.0f. 258 * @since 12 259 */ 260 SET_SDR_WHITE_POINT_BRIGHTNESS, 261 /** 262 * Set native window buffer desiredPresentTimestamp, indicates the desired time to present the buffer.\n 263 * Which should be generated by std::chrono::steady_clock in nanoseconds.\n 264 * It is only effective when RenderService is the consumer.\n 265 * The buffer will wait until desiredPresentTimestamp is reached before being consumed and displayed.\n 266 * If multiple buffers reach desiredPresentTimestamp, the earlier buffer will be dropped.\n 267 * This Operation should be called before calling <b>OH_NativeWindow_NativeWindowFlushBuffer</b>.\n 268 * If desiredPresentTimestamp is greater than 1 second of the consumer-provided timestamp, 269 * the desiredPresentTimestamp will be ignored.\n 270 * Variable parameter in function is 271 * [in] int64_t desiredPresentTimestamp. 272 * @since 13 273 */ 274 SET_DESIRED_PRESENT_TIMESTAMP = 24, 275 } NativeWindowOperation; 276 277 /** 278 * @brief Indicates Scaling Mode. 279 * @since 9 280 * @deprecated(since = "10") 281 */ 282 typedef enum { 283 /** 284 * the window content is not updated until a buffer of 285 * the window size is received 286 */ 287 OH_SCALING_MODE_FREEZE = 0, 288 /** 289 * the buffer is scaled in two dimensions to match the window size 290 */ 291 OH_SCALING_MODE_SCALE_TO_WINDOW, 292 /** 293 * the buffer is uniformly scaled so that the smaller size of 294 * the buffer matches the window size 295 */ 296 OH_SCALING_MODE_SCALE_CROP, 297 /** 298 * the window is clipped to the size of the buffer's clipping rectangle 299 * pixels outside the clipping rectangle are considered fully transparent. 300 */ 301 OH_SCALING_MODE_NO_SCALE_CROP, 302 } OHScalingMode; 303 304 /** 305 * @brief Indicates Scaling Mode. 306 * @since 12 307 */ 308 typedef enum { 309 /** 310 * the window content is not updated until a buffer of 311 * the window size is received 312 */ 313 OH_SCALING_MODE_FREEZE_V2 = 0, 314 /** 315 * the buffer is scaled in two dimensions to match the window size 316 */ 317 OH_SCALING_MODE_SCALE_TO_WINDOW_V2, 318 /** 319 * the buffer is uniformly scaled so that the smaller size of 320 * the buffer matches the window size 321 */ 322 OH_SCALING_MODE_SCALE_CROP_V2, 323 /** 324 * the window is clipped to the size of the buffer's clipping rectangle 325 * pixels outside the clipping rectangle are considered fully transparent. 326 */ 327 OH_SCALING_MODE_NO_SCALE_CROP_V2, 328 /** 329 * Adapt to the buffer and scale proportionally to the buffer size. Prioritize displaying all buffer content. 330 * If the size is not the same as the window size, fill the unfilled area of the window with a background color. 331 */ 332 OH_SCALING_MODE_SCALE_FIT_V2, 333 } OHScalingModeV2; 334 335 /** 336 * @brief Enumerates the HDR metadata keys. 337 * @since 9 338 * @deprecated(since = "10") 339 */ 340 typedef enum { 341 OH_METAKEY_RED_PRIMARY_X = 0, 342 OH_METAKEY_RED_PRIMARY_Y = 1, 343 OH_METAKEY_GREEN_PRIMARY_X = 2, 344 OH_METAKEY_GREEN_PRIMARY_Y = 3, 345 OH_METAKEY_BLUE_PRIMARY_X = 4, 346 OH_METAKEY_BLUE_PRIMARY_Y = 5, 347 OH_METAKEY_WHITE_PRIMARY_X = 6, 348 OH_METAKEY_WHITE_PRIMARY_Y = 7, 349 OH_METAKEY_MAX_LUMINANCE = 8, 350 OH_METAKEY_MIN_LUMINANCE = 9, 351 OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, 352 OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, 353 OH_METAKEY_HDR10_PLUS = 12, 354 OH_METAKEY_HDR_VIVID = 13, 355 } OHHDRMetadataKey; 356 357 /** 358 * @brief Defines the HDR metadata. 359 * @since 9 360 * @deprecated(since = "10") 361 */ 362 typedef struct { 363 OHHDRMetadataKey key; 364 float value; 365 } OHHDRMetaData; 366 367 /** 368 * @brief Defines the ExtData Handle 369 * @since 9 370 * @deprecated(since = "10") 371 */ 372 typedef struct OHExtDataHandle { 373 /**< Handle fd, -1 if not supported */ 374 int32_t fd; 375 /**< the number of reserved integer value */ 376 uint32_t reserveInts; 377 /**< the reserved data */ 378 int32_t reserve[0]; 379 } OHExtDataHandle; 380 381 /** 382 * @brief Indicates the source type of surface. 383 * @since 12 384 */ 385 typedef enum { 386 /* 387 * the default source type of surface. 388 */ 389 OH_SURFACE_SOURCE_DEFAULT = 0, 390 /* 391 * the surface is created by ui. 392 */ 393 OH_SURFACE_SOURCE_UI, 394 /* 395 * the surface is created by game. 396 */ 397 OH_SURFACE_SOURCE_GAME, 398 /* 399 * the surface is created by camera. 400 */ 401 OH_SURFACE_SOURCE_CAMERA, 402 /* 403 * the surface is created by video. 404 */ 405 OH_SURFACE_SOURCE_VIDEO, 406 /* 407 * the surface is created by lowpowervideo. 408 */ 409 OH_SURFACE_SOURCE_LOWPOWERVIDEO, 410 } OHSurfaceSource; 411 412 /** 413 * @brief Creates an <b>OHNativeWindow</b> instance. 414 * A new <b>OHNativeWindow</b> instance is created each time this function is called.\n 415 * 416 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 417 * @param pSurface Indicates the pointer to a <b>ProduceSurface</b>. 418 * The type is a pointer to <b>sptr<OHOS::Surface></b>. 419 * @return Returns the pointer to the <b>OHNativeWindow</b> instance created. 420 * @since 8 421 * @version 1.0 422 * @deprecated since 12 423 */ 424 OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface); 425 426 /** 427 * @brief Decreases the reference count of an <b>OHNativeWindow</b> instance by 1, and when the reference count \n 428 * reaches 0, destroys the instance. 429 * 430 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 431 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 432 * @since 8 433 * @version 1.0 434 */ 435 void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window); 436 437 /** 438 * @brief Creates an <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created \n 439 * each time this function is called. 440 * 441 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 442 * @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is <b>sptr<OHOS::SurfaceBuffer></b>. 443 * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created. 444 * @since 8 445 * @version 1.0 446 * @deprecated since 12 447 * @useinstead OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer 448 */ 449 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer); 450 451 /** 452 * @brief Creates an <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created \n 453 * each time this function is called. 454 * 455 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 456 * @param nativeBuffer Indicates the pointer to a native buffer. The type is <b>OH_NativeBuffer*</b>. 457 * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created. 458 * @since 11 459 * @version 1.0 460 */ 461 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(OH_NativeBuffer* nativeBuffer); 462 463 /** 464 * @brief Decreases the reference count of an <b>OHNativeWindowBuffer</b> instance by 1 and, when the reference \n 465 * count reaches 0, destroys the instance. 466 * 467 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 468 * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance. 469 * @since 8 470 * @version 1.0 471 */ 472 void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer); 473 474 /** 475 * @brief Requests an <b>OHNativeWindowBuffer</b> through an <b>OHNativeWindow</b> instance for content production. 476 * 477 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 478 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 479 * @param buffer Indicates the double pointer to an <b>OHNativeWindowBuffer</b> instance. 480 * @param fenceFd Indicates the pointer to a file descriptor handle. 481 * @return Returns an error code, 0 is success, otherwise, failed. 482 * @since 8 483 * @version 1.0 484 */ 485 int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window, 486 OHNativeWindowBuffer **buffer, int *fenceFd); 487 488 /** 489 * @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue through an \n 490 * <b>OHNativeWindow</b> instance for content consumption. 491 * 492 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 493 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 494 * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance. 495 * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. 496 * @param region Indicates a dirty region where content is updated. 497 * @return Returns an error code, 0 is success, otherwise, failed. 498 * @since 8 499 * @version 1.0 500 */ 501 int32_t OH_NativeWindow_NativeWindowFlushBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer, 502 int fenceFd, Region region); 503 504 /** 505 * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance. 506 * 507 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 508 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 509 * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer. 510 * @param fenceFd Indicates the pointer to a file descriptor handle. 511 * @param matrix Indicates the retrieved 4*4 transform matrix. 512 * @return Returns an error code, 0 is success, otherwise, failed. 513 * @since 11 514 * @version 1.0 515 * @deprecated since 12 516 * @useinstead OH_NativeWindow_GetLastFlushedBufferV2 517 */ 518 int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWindowBuffer **buffer, 519 int *fenceFd, float matrix[16]); 520 521 /** 522 * @brief Returns the <b>OHNativeWindowBuffer</b> to the buffer queue through an <b>OHNativeWindow</b> instance, \n 523 * without filling in any content. The <b>OHNativeWindowBuffer</b> can be used for another request. 524 * 525 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 526 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 527 * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance. 528 * @return Returns an error code, 0 is success, otherwise, failed. 529 * @since 8 530 * @version 1.0 531 */ 532 int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer); 533 534 /** 535 * @brief Sets or obtains the attributes of a native window, including the width, height, and content format. 536 * 537 * <p><strong>API Note</strong> 538 * 539 * <strong>Performance Note</strong> 540 * <p>By default, the window buffer in the current operating system is accessed via the CPU. If an application 541 * does not need to access the window buffer data using the CPU, it can proactively disable CPU access to 542 * enhance energy efficiency and reduce power consumption. 543 * </p> 544 * <p>For details about how to optimize power consumption for data read/write operations in data buffers, 545 * see [How do I proactively disable CPU access to window buffers to reduce power consumption?]{@link https://developer.huawei.com/consumer/en/doc/harmonyos-faqs/faqs-arkgraphics-2d-14}.</p> 546 * </p> 547 * 548 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 549 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 550 * @param code Indicates the operation code, pointer to <b>NativeWindowOperation</b>. 551 * @param ... variable parameter, must correspond to code one-to-one. 552 * @return Returns an error code, 0 is success, otherwise, failed. 553 * @since 8 554 * @version 1.0 555 */ 556 int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...); 557 558 /** 559 * @brief Obtains the pointer to a <b>BufferHandle</b> of an <b>OHNativeWindowBuffer</b> instance. 560 * 561 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 562 * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance. 563 * @return Returns the pointer to the <b>BufferHandle</b> instance obtained. 564 * @since 8 565 * @version 1.0 566 */ 567 BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *buffer); 568 569 /** 570 * @brief Adds the reference count of a native object. 571 * 572 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 573 * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance. 574 * @return Returns an error code, 0 is success, otherwise, failed. 575 * @since 8 576 * @version 1.0 577 */ 578 int32_t OH_NativeWindow_NativeObjectReference(void *obj); 579 580 /** 581 * @brief Decreases the reference count of a native object and, when the reference count reaches 0, \n 582 * destroys this object. 583 * 584 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 585 * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance. 586 * @return Returns an error code, 0 is success, otherwise, failed. 587 * @since 8 588 * @version 1.0 589 */ 590 int32_t OH_NativeWindow_NativeObjectUnreference(void *obj); 591 592 /** 593 * @brief Obtains the magic ID of a native object. 594 * 595 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 596 * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance. 597 * @return Returns the magic ID, which is unique for each native object. 598 * @since 8 599 * @version 1.0 600 */ 601 int32_t OH_NativeWindow_GetNativeObjectMagic(void *obj); 602 603 /** 604 * @brief Sets scalingMode of a native window. 605 * 606 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 607 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 608 * @param sequence Indicates the sequence to a produce buffer. 609 * @param scalingMode Indicates the enum value to <b>OHScalingMode</b> 610 * @return Returns an error code, 0 is success, otherwise, failed. 611 * @since 9 612 * @version 1.0 613 * @deprecated(since = "10") 614 */ 615 int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence, 616 OHScalingMode scalingMode); 617 618 /** 619 * @brief Sets metaData of a native window. 620 * 621 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 622 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 623 * @param sequence Indicates the sequence to a produce buffer. 624 * @param size Indicates the size of a <b>OHHDRMetaData</b> vector. 625 * @param metaDate Indicates the pointer to a <b>OHHDRMetaData</b> vector. 626 * @return Returns an error code, 0 is success, otherwise, failed. 627 * @since 9 628 * @version 1.0 629 * @deprecated(since = "10") 630 */ 631 int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size, 632 const OHHDRMetaData *metaData); 633 634 /** 635 * @brief Sets metaDataSet of a native window. 636 * 637 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 638 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 639 * @param sequence Indicates the sequence to a produce buffer. 640 * @param key Indicates the enum value to <b>OHHDRMetadataKey</b> 641 * @param size Indicates the size of a uint8_t vector. 642 * @param metaDate Indicates the pointer to a uint8_t vector. 643 * @return Returns an error code, 0 is success, otherwise, failed. 644 * @since 9 645 * @version 1.0 646 * @deprecated(since = "10") 647 */ 648 int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key, 649 int32_t size, const uint8_t *metaData); 650 651 /** 652 * @brief Sets tunnel handle of a native window. 653 * 654 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 655 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 656 * @param handle Indicates the pointer to a <b>OHExtDataHandle</b>. 657 * @return Returns an error code, 0 is success, otherwise, failed. 658 * @since 9 659 * @version 1.0 660 * @deprecated(since = "10") 661 */ 662 int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle); 663 664 /** 665 * @brief Get surfaceId from native window. 666 * 667 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 668 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 669 * @param surfaceId Indicates the pointer to a surfaceId. 670 * @return Returns an error code, 0 is success, otherwise, failed. 671 * @since 12 672 * @version 1.0 673 */ 674 int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId); 675 676 /** 677 * @brief Creates an <b>OHNativeWindow</b> instance.\n 678 * 679 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 680 * @param surfaceId Indicates the surfaceId to a surface. 681 * @param window indicates the pointer to an <b>OHNativeWindow</b> instance. 682 * @return Returns an error code, 0 is Success, otherwise, failed. 683 * @since 12 684 * @version 1.0 685 */ 686 int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window); 687 688 /** 689 * @brief Attach a buffer to an <b>OHNativeWindow</b> instance. 690 * 691 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 692 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 693 * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance. 694 * @return Returns an error code, 0 is success, otherwise, failed. 695 * @since 12 696 * @version 1.0 697 */ 698 int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer); 699 700 /** 701 * @brief Detach a buffer from an <b>OHNativeWindow</b> instance. 702 * 703 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 704 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 705 * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance. 706 * @return Returns an error code, 0 is success, otherwise, failed. 707 * @since 12 708 * @version 1.0 709 */ 710 int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer); 711 712 /** 713 * @brief Sets scalingMode of a native window. 714 * 715 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 716 * @param window indicates the pointer to an <b>OHNativeWindow</b> instance. 717 * @param scalingMode Indicates the enum value to <b>OHScalingModeV2</b> 718 * @return Returns an error code, 0 is Success, otherwise, failed. 719 * @since 12 720 * @version 1.0 721 */ 722 int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode); 723 724 /** 725 * @brief Set native window buffer hold. 726 * 727 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 728 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 729 * @since 12 730 * @version 1.0 731 */ 732 void OH_NativeWindow_SetBufferHold(OHNativeWindow *window); 733 734 /** 735 * @brief Write an OHNativeWindow to an OHIPCParcel. 736 * 737 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 738 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 739 * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance. 740 * @return Returns an error code, 0 is success, otherwise, failed. 741 * @since 12 742 * @version 1.0 743 */ 744 int32_t OH_NativeWindow_WriteToParcel(OHNativeWindow *window, OHIPCParcel *parcel); 745 746 /** 747 * @brief Read an OHNativeWindow from an OHIPCParcel. 748 * 749 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 750 * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance. 751 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 752 * @return 0 - Success. 753 * 40001000 - parcel is NULL or parcel does not contain the window. 754 * @since 12 755 * @version 1.0 756 */ 757 int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window); 758 759 /** 760 * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance. 761 * 762 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 763 * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance. 764 * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer. 765 * @param fenceFd Indicates the pointer to a file descriptor handle. 766 * @param matrix Indicates the retrieved 4*4 transform matrix. 767 * @return 0 - Success. 768 * 40001000 - window is NULL or buffer is NULL or fenceFd is NULL. 769 * 41207000 - buffer state is wrong. 770 * @since 12 771 * @version 1.0 772 */ 773 int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer, 774 int *fenceFd, float matrix[16]); 775 776 /** 777 * @brief Clean all <b>OHNativeWindowBuffer</b> caches of this <b>OHNativeWindow</b> 778 * This interface is a non-thread-safe type interface.\n 779 * 780 * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow 781 * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance. 782 * @return {@link NATIVE_ERROR_OK} 0 - Success. 783 * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL. 784 * {@link NATIVE_ERROR_CONSUMER_DISCONNECTED} 41211000 - the consumer is disconnected. 785 * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. 786 * @since 19 787 * @version 1.0 788 */ 789 int32_t OH_NativeWindow_CleanCache(OHNativeWindow *window); 790 #ifdef __cplusplus 791 } 792 #endif 793 794 /** @} */ 795 #endif