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,
140      * variable parameter in function is
141      * [in] int32_t stride.
142      */
143     SET_STRIDE,
144     /**
145      * get native window buffer stride,
146      * variable parameter in function is
147      * [out] int32_t *stride.
148      */
149     GET_STRIDE,
150     /**
151      * set native window buffer swap interval,
152      * variable parameter in function is
153      * [in] int32_t interval.
154      */
155     SET_SWAP_INTERVAL,
156     /**
157      * get native window buffer swap interval,
158      * variable parameter in function is
159      * [out] int32_t *interval.
160      */
161     GET_SWAP_INTERVAL,
162     /**
163      * set the timeout in milliseconds when the native window requests a buffer,
164      * the default value is 3000 milliseconds when not set,
165      * variable parameter in function is
166      * [in] int32_t timeout.
167      */
168     SET_TIMEOUT,
169     /**
170      * get the timeout in milliseconds when the native window requests a buffer,
171      * the default value is 3000 milliseconds when not set,
172      * variable parameter in function is
173      * [out] int32_t *timeout.
174      */
175     GET_TIMEOUT,
176     /**
177      * set native window buffer colorGamut,
178      * variable parameter in function is
179      * [in] int32_t colorGamut.
180      */
181     SET_COLOR_GAMUT,
182     /**
183      * get native window buffer colorGamut,
184      * variable parameter in function is
185      * [out int32_t *colorGamut].
186      */
187     GET_COLOR_GAMUT,
188     /**
189      * set native window buffer transform,
190      * variable parameter in function is
191      * [in] int32_t transform.
192      */
193     SET_TRANSFORM,
194     /**
195      * get native window buffer transform,
196      * variable parameter in function is
197      * [out] int32_t *transform.
198      */
199     GET_TRANSFORM,
200     /**
201      * set native window buffer uiTimestamp,
202      * variable parameter in function is
203      * [in] uint64_t uiTimestamp.
204      */
205     SET_UI_TIMESTAMP,
206     /**
207      * get native window bufferqueue size,
208      * variable parameter in function is
209      * [out] int32_t *size.
210      * @since 12
211      */
212     GET_BUFFERQUEUE_SIZE,
213     /**
214      * set surface source type,
215      * variable parameter in function is
216      * [in] int32_t sourceType.
217      * @since 12
218      */
219     SET_SOURCE_TYPE,
220     /**
221      * get surface source type,
222      * variable parameter in function is
223      * [out] int32_t *sourceType.
224      * @since 12
225      */
226     GET_SOURCE_TYPE,
227     /**
228      * set app framework type,
229      * variable parameter in function is
230      * [in] char* frameworkType. maximum length is 64 bytes, otherwise the setting fails.
231      * @since 12
232      */
233     SET_APP_FRAMEWORK_TYPE,
234     /**
235      * get app framework type,
236      * variable parameter in function is
237      * [out] char** frameworkType.
238      * @since 12
239      */
240     GET_APP_FRAMEWORK_TYPE,
241     /**
242      * set hdr white point brightness,
243      * variable parameter in function is
244      * [in] float brightness. the value range is 0.0f to 1.0f.
245      * @since 12
246      */
247     SET_HDR_WHITE_POINT_BRIGHTNESS,
248     /**
249      * set sdr white point brightness,
250      * variable parameter in function is
251      * [in] float brightness. the value range is 0.0f to 1.0f.
252      * @since 12
253      */
254     SET_SDR_WHITE_POINT_BRIGHTNESS,
255     /**
256      * Set native window buffer desiredPresentTimestamp, indicates the desired time to present the buffer.\n
257      * Which should be generated by std::chrono::steady_clock in nanoseconds.\n
258      * It is only effective when RenderService is the consumer.\n
259      * The buffer will wait until desiredPresentTimestamp is reached before being consumed and displayed.\n
260      * If multiple buffers reach desiredPresentTimestamp, the earlier buffer will be dropped.\n
261      * This Operation should be called before calling <b>OH_NativeWindow_NativeWindowFlushBuffer</b>.\n
262      * If desiredPresentTimestamp is greater than 1 second of the consumer-provided timestamp,
263      * the desiredPresentTimestamp will be ignored.\n
264      * Variable parameter in function is
265      * [in] int64_t desiredPresentTimestamp.
266      * @since 13
267      */
268     SET_DESIRED_PRESENT_TIMESTAMP = 24,
269 } NativeWindowOperation;
270 
271 /**
272  * @brief Indicates Scaling Mode.
273  * @since 9
274  * @deprecated(since = "10")
275  */
276 typedef enum {
277     /**
278      * the window content is not updated until a buffer of
279      * the window size is received
280      */
281     OH_SCALING_MODE_FREEZE = 0,
282     /**
283      * the buffer is scaled in two dimensions to match the window size
284      */
285     OH_SCALING_MODE_SCALE_TO_WINDOW,
286     /**
287      * the buffer is uniformly scaled so that the smaller size of
288      * the buffer matches the window size
289      */
290     OH_SCALING_MODE_SCALE_CROP,
291     /**
292      * the window is clipped to the size of the buffer's clipping rectangle
293      * pixels outside the clipping rectangle are considered fully transparent.
294      */
295     OH_SCALING_MODE_NO_SCALE_CROP,
296 } OHScalingMode;
297 
298 /**
299  * @brief Indicates Scaling Mode.
300  * @since 12
301  */
302 typedef enum {
303     /**
304      * the window content is not updated until a buffer of
305      * the window size is received
306      */
307     OH_SCALING_MODE_FREEZE_V2 = 0,
308     /**
309      * the buffer is scaled in two dimensions to match the window size
310      */
311     OH_SCALING_MODE_SCALE_TO_WINDOW_V2,
312     /**
313      * the buffer is uniformly scaled so that the smaller size of
314      * the buffer matches the window size
315      */
316     OH_SCALING_MODE_SCALE_CROP_V2,
317     /**
318      * the window is clipped to the size of the buffer's clipping rectangle
319      * pixels outside the clipping rectangle are considered fully transparent.
320      */
321     OH_SCALING_MODE_NO_SCALE_CROP_V2,
322     /**
323      * Adapt to the buffer and scale proportionally to the buffer size. Prioritize displaying all buffer content.
324      * If the size is not the same as the window size, fill the unfilled area of the window with a background color.
325      */
326     OH_SCALING_MODE_SCALE_FIT_V2,
327 } OHScalingModeV2;
328 
329 /**
330  * @brief Enumerates the HDR metadata keys.
331  * @since 9
332  * @deprecated(since = "10")
333  */
334 typedef enum {
335     OH_METAKEY_RED_PRIMARY_X = 0,
336     OH_METAKEY_RED_PRIMARY_Y = 1,
337     OH_METAKEY_GREEN_PRIMARY_X = 2,
338     OH_METAKEY_GREEN_PRIMARY_Y = 3,
339     OH_METAKEY_BLUE_PRIMARY_X = 4,
340     OH_METAKEY_BLUE_PRIMARY_Y = 5,
341     OH_METAKEY_WHITE_PRIMARY_X = 6,
342     OH_METAKEY_WHITE_PRIMARY_Y = 7,
343     OH_METAKEY_MAX_LUMINANCE = 8,
344     OH_METAKEY_MIN_LUMINANCE = 9,
345     OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10,
346     OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
347     OH_METAKEY_HDR10_PLUS = 12,
348     OH_METAKEY_HDR_VIVID = 13,
349 } OHHDRMetadataKey;
350 
351 /**
352  * @brief Defines the HDR metadata.
353  * @since 9
354  * @deprecated(since = "10")
355  */
356 typedef struct {
357     OHHDRMetadataKey key;
358     float value;
359 } OHHDRMetaData;
360 
361 /**
362  * @brief Defines the ExtData Handle
363  * @since 9
364  * @deprecated(since = "10")
365  */
366 typedef struct OHExtDataHandle {
367     /**< Handle fd, -1 if not supported */
368     int32_t fd;
369     /**< the number of reserved integer value */
370     uint32_t reserveInts;
371     /**< the reserved data */
372     int32_t reserve[0];
373 } OHExtDataHandle;
374 
375 /**
376  * @brief Indicates the source type of surface.
377  * @since 12
378  */
379 typedef enum {
380     /*
381      * the default source type of surface.
382      */
383     OH_SURFACE_SOURCE_DEFAULT = 0,
384     /*
385      * the surface is created by ui.
386      */
387     OH_SURFACE_SOURCE_UI,
388     /*
389      * the surface is created by game.
390      */
391     OH_SURFACE_SOURCE_GAME,
392     /*
393      * the surface is created by camera.
394      */
395     OH_SURFACE_SOURCE_CAMERA,
396     /*
397      * the surface is created by video.
398      */
399     OH_SURFACE_SOURCE_VIDEO,
400 } OHSurfaceSource;
401 
402 /**
403  * @brief Creates an <b>OHNativeWindow</b> instance.
404  * A new <b>OHNativeWindow</b> instance is created each time this function is called.\n
405  *
406  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
407  * @param pSurface Indicates the pointer to a <b>ProduceSurface</b>.
408  * The type is a pointer to <b>sptr<OHOS::Surface></b>.
409  * @return Returns the pointer to the <b>OHNativeWindow</b> instance created.
410  * @since 8
411  * @version 1.0
412  * @deprecated since 12
413  */
414 OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface);
415 
416 /**
417  * @brief Decreases the reference count of an <b>OHNativeWindow</b> instance by 1, and when the reference count \n
418  * reaches 0, destroys the instance.
419  *
420  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
421  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
422  * @since 8
423  * @version 1.0
424  */
425 void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window);
426 
427 /**
428  * @brief Creates an <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created \n
429  * each time this function is called.
430  *
431  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
432  * @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is <b>sptr<OHOS::SurfaceBuffer></b>.
433  * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
434  * @since 8
435  * @version 1.0
436  * @deprecated since 12
437  * @useinstead OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer
438  */
439 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer);
440 
441 /**
442  * @brief Creates an <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created \n
443  * each time this function is called.
444  *
445  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
446  * @param nativeBuffer Indicates the pointer to a native buffer. The type is <b>OH_NativeBuffer*</b>.
447  * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
448  * @since 11
449  * @version 1.0
450  */
451 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(OH_NativeBuffer* nativeBuffer);
452 
453 /**
454  * @brief Decreases the reference count of an <b>OHNativeWindowBuffer</b> instance by 1 and, when the reference \n
455  * count reaches 0, destroys the instance.
456  *
457  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
458  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
459  * @since 8
460  * @version 1.0
461  */
462 void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer);
463 
464 /**
465  * @brief Requests an <b>OHNativeWindowBuffer</b> through an <b>OHNativeWindow</b> instance for content production.
466  *
467  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
468  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
469  * @param buffer Indicates the double pointer to an <b>OHNativeWindowBuffer</b> instance.
470  * @param fenceFd Indicates the pointer to a file descriptor handle.
471  * @return Returns an error code, 0 is success, otherwise, failed.
472  * @since 8
473  * @version 1.0
474  */
475 int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window,
476     OHNativeWindowBuffer **buffer, int *fenceFd);
477 
478 /**
479  * @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue through an \n
480  * <b>OHNativeWindow</b> instance for content consumption.
481  *
482  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
483  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
484  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
485  * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization.
486  * @param region Indicates a dirty region where content is updated.
487  * @return Returns an error code, 0 is success, otherwise, failed.
488  * @since 8
489  * @version 1.0
490  */
491 int32_t OH_NativeWindow_NativeWindowFlushBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer,
492     int fenceFd, Region region);
493 
494 /**
495  * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance.
496  *
497  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
498  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
499  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.
500  * @param fenceFd Indicates the pointer to a file descriptor handle.
501  * @param matrix Indicates the retrieved 4*4 transform matrix.
502  * @return Returns an error code, 0 is success, otherwise, failed.
503  * @since 11
504  * @version 1.0
505  * @deprecated since 12
506  * @useinstead OH_NativeWindow_GetLastFlushedBufferV2
507  */
508 int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
509     int *fenceFd, float matrix[16]);
510 
511  /**
512  * @brief Returns the <b>OHNativeWindowBuffer</b> to the buffer queue through an <b>OHNativeWindow</b> instance, \n
513  * without filling in any content. The <b>OHNativeWindowBuffer</b> can be used for another request.
514  *
515  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
516  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
517  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
518  * @return Returns an error code, 0 is success, otherwise, failed.
519  * @since 8
520  * @version 1.0
521  */
522 int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
523 
524 /**
525  * @brief Sets or obtains the attributes of a native window, including the width, height, and content format.
526  *
527  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
528  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
529  * @param code Indicates the operation code, pointer to <b>NativeWindowOperation</b>.
530  * @param ... variable parameter, must correspond to code one-to-one.
531  * @return Returns an error code, 0 is success, otherwise, failed.
532  * @since 8
533  * @version 1.0
534  */
535 int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...);
536 
537 /**
538  * @brief Obtains the pointer to a <b>BufferHandle</b> of an <b>OHNativeWindowBuffer</b> instance.
539  *
540  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
541  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
542  * @return Returns the pointer to the <b>BufferHandle</b> instance obtained.
543  * @since 8
544  * @version 1.0
545  */
546 BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *buffer);
547 
548 /**
549  * @brief Adds the reference count of a native object.
550  *
551  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
552  * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
553  * @return Returns an error code, 0 is success, otherwise, failed.
554  * @since 8
555  * @version 1.0
556  */
557 int32_t OH_NativeWindow_NativeObjectReference(void *obj);
558 
559 /**
560  * @brief Decreases the reference count of a native object and, when the reference count reaches 0, \n
561  * destroys this object.
562  *
563  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
564  * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
565  * @return Returns an error code, 0 is success, otherwise, failed.
566  * @since 8
567  * @version 1.0
568  */
569 int32_t OH_NativeWindow_NativeObjectUnreference(void *obj);
570 
571 /**
572  * @brief Obtains the magic ID of a native object.
573  *
574  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
575  * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
576  * @return Returns the magic ID, which is unique for each native object.
577  * @since 8
578  * @version 1.0
579  */
580 int32_t OH_NativeWindow_GetNativeObjectMagic(void *obj);
581 
582 /**
583  * @brief Sets scalingMode of a native window.
584  *
585  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
586  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
587  * @param sequence Indicates the sequence to a produce buffer.
588  * @param scalingMode Indicates the enum value to <b>OHScalingMode</b>
589  * @return Returns an error code, 0 is success, otherwise, failed.
590  * @since 9
591  * @version 1.0
592  * @deprecated(since = "10")
593  */
594 int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence,
595                                                    OHScalingMode scalingMode);
596 
597 /**
598  * @brief Sets metaData of a native window.
599  *
600  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
601  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
602  * @param sequence Indicates the sequence to a produce buffer.
603  * @param size Indicates the size of a <b>OHHDRMetaData</b> vector.
604  * @param metaDate Indicates the pointer to a <b>OHHDRMetaData</b> vector.
605  * @return Returns an error code, 0 is success, otherwise, failed.
606  * @since 9
607  * @version 1.0
608  * @deprecated(since = "10")
609  */
610 int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size,
611                                                 const OHHDRMetaData *metaData);
612 
613 /**
614  * @brief Sets metaDataSet of a native window.
615  *
616  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
617  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
618  * @param sequence Indicates the sequence to a produce buffer.
619  * @param key Indicates the enum value to <b>OHHDRMetadataKey</b>
620  * @param size Indicates the size of a uint8_t vector.
621  * @param metaDate Indicates the pointer to a uint8_t vector.
622  * @return Returns an error code, 0 is success, otherwise, failed.
623  * @since 9
624  * @version 1.0
625  * @deprecated(since = "10")
626  */
627 int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key,
628                                                    int32_t size, const uint8_t *metaData);
629 
630 /**
631  * @brief Sets tunnel handle of a native window.
632  *
633  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
634  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
635  * @param handle Indicates the pointer to a <b>OHExtDataHandle</b>.
636  * @return Returns an error code, 0 is success, otherwise, failed.
637  * @since 9
638  * @version 1.0
639  * @deprecated(since = "10")
640  */
641 int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle);
642 
643 /**
644  * @brief Get surfaceId from native window.
645  *
646  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
647  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
648  * @param surfaceId Indicates the pointer to a surfaceId.
649  * @return Returns an error code, 0 is success, otherwise, failed.
650  * @since 12
651  * @version 1.0
652  */
653 int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId);
654 
655 /**
656  * @brief Creates an <b>OHNativeWindow</b> instance.\n
657  *
658  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
659  * @param surfaceId Indicates the surfaceId to a surface.
660  * @param window indicates the pointer to an <b>OHNativeWindow</b> instance.
661  * @return Returns an error code, 0 is Success, otherwise, failed.
662  * @since 12
663  * @version 1.0
664  */
665 int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window);
666 
667 /**
668  * @brief Attach a buffer to an <b>OHNativeWindow</b> instance.
669  *
670  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
671  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
672  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
673  * @return Returns an error code, 0 is success, otherwise, failed.
674  * @since 12
675  * @version 1.0
676  */
677 int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
678 
679 /**
680  * @brief Detach a buffer from an <b>OHNativeWindow</b> instance.
681  *
682  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
683  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
684  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
685  * @return Returns an error code, 0 is success, otherwise, failed.
686  * @since 12
687  * @version 1.0
688  */
689 int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
690 
691 /**
692  * @brief Sets scalingMode of a native window.
693  *
694  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
695  * @param window indicates the pointer to an <b>OHNativeWindow</b> instance.
696  * @param scalingMode Indicates the enum value to <b>OHScalingModeV2</b>
697  * @return Returns an error code, 0 is Success, otherwise, failed.
698  * @since 12
699  * @version 1.0
700  */
701 int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode);
702 
703 /**
704  * @brief Set native window buffer hold.
705  *
706  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
707  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
708  * @since 12
709  * @version 1.0
710  */
711 void OH_NativeWindow_SetBufferHold(OHNativeWindow *window);
712 
713 /**
714  * @brief Write an OHNativeWindow to an OHIPCParcel.
715  *
716  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
717  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
718  * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.
719  * @return Returns an error code, 0 is success, otherwise, failed.
720  * @since 12
721  * @version 1.0
722  */
723 int32_t OH_NativeWindow_WriteToParcel(OHNativeWindow *window, OHIPCParcel *parcel);
724 
725 /**
726  * @brief Read an OHNativeWindow from an OHIPCParcel.
727  *
728  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
729  * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.
730  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
731  * @return 0 - Success.
732  *     40001000 - parcel is NULL or parcel does not contain the window.
733  * @since 12
734  * @version 1.0
735  */
736 int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window);
737 
738 /**
739  * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance.
740  *
741  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
742  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
743  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.
744  * @param fenceFd Indicates the pointer to a file descriptor handle.
745  * @param matrix Indicates the retrieved 4*4 transform matrix.
746  * @return 0 - Success.
747  *     40001000 - window is NULL or buffer is NULL or fenceFd is NULL.
748  *     41207000 - buffer state is wrong.
749  * @since 12
750  * @version 1.0
751  */
752 int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
753     int *fenceFd, float matrix[16]);
754 
755 #ifdef __cplusplus
756 }
757 #endif
758 
759 /** @} */
760 #endif