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