• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 } OHSurfaceSource;
407 
408 /**
409  * @brief Creates an <b>OHNativeWindow</b> instance.
410  * A new <b>OHNativeWindow</b> instance is created each time this function is called.\n
411  *
412  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
413  * @param pSurface Indicates the pointer to a <b>ProduceSurface</b>.
414  * The type is a pointer to <b>sptr<OHOS::Surface></b>.
415  * @return Returns the pointer to the <b>OHNativeWindow</b> instance created.
416  * @since 8
417  * @version 1.0
418  * @deprecated since 12
419  */
420 OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface);
421 
422 /**
423  * @brief Decreases the reference count of an <b>OHNativeWindow</b> instance by 1, and when the reference count \n
424  * reaches 0, destroys the instance.
425  *
426  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
427  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
428  * @since 8
429  * @version 1.0
430  */
431 void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window);
432 
433 /**
434  * @brief Creates an <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created \n
435  * each time this function is called.
436  *
437  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
438  * @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is <b>sptr<OHOS::SurfaceBuffer></b>.
439  * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
440  * @since 8
441  * @version 1.0
442  * @deprecated since 12
443  * @useinstead OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer
444  */
445 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer);
446 
447 /**
448  * @brief Creates an <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created \n
449  * each time this function is called.
450  *
451  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
452  * @param nativeBuffer Indicates the pointer to a native buffer. The type is <b>OH_NativeBuffer*</b>.
453  * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
454  * @since 11
455  * @version 1.0
456  */
457 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(OH_NativeBuffer* nativeBuffer);
458 
459 /**
460  * @brief Decreases the reference count of an <b>OHNativeWindowBuffer</b> instance by 1 and, when the reference \n
461  * count reaches 0, destroys the instance.
462  *
463  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
464  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
465  * @since 8
466  * @version 1.0
467  */
468 void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer);
469 
470 /**
471  * @brief Requests an <b>OHNativeWindowBuffer</b> through an <b>OHNativeWindow</b> instance for content production.
472  *
473  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
474  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
475  * @param buffer Indicates the double pointer to an <b>OHNativeWindowBuffer</b> instance.
476  * @param fenceFd Indicates the pointer to a file descriptor handle.
477  * @return Returns an error code, 0 is success, otherwise, failed.
478  * @since 8
479  * @version 1.0
480  */
481 int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window,
482     OHNativeWindowBuffer **buffer, int *fenceFd);
483 
484 /**
485  * @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue through an \n
486  * <b>OHNativeWindow</b> instance for content consumption.
487  *
488  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
489  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
490  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
491  * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization.
492  * @param region Indicates a dirty region where content is updated.
493  * @return Returns an error code, 0 is success, otherwise, failed.
494  * @since 8
495  * @version 1.0
496  */
497 int32_t OH_NativeWindow_NativeWindowFlushBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer,
498     int fenceFd, Region region);
499 
500 /**
501  * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance.
502  *
503  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
504  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
505  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.
506  * @param fenceFd Indicates the pointer to a file descriptor handle.
507  * @param matrix Indicates the retrieved 4*4 transform matrix.
508  * @return Returns an error code, 0 is success, otherwise, failed.
509  * @since 11
510  * @version 1.0
511  * @deprecated since 12
512  * @useinstead OH_NativeWindow_GetLastFlushedBufferV2
513  */
514 int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
515     int *fenceFd, float matrix[16]);
516 
517  /**
518  * @brief Returns the <b>OHNativeWindowBuffer</b> to the buffer queue through an <b>OHNativeWindow</b> instance, \n
519  * without filling in any content. The <b>OHNativeWindowBuffer</b> can be used for another request.
520  *
521  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
522  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
523  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
524  * @return Returns an error code, 0 is success, otherwise, failed.
525  * @since 8
526  * @version 1.0
527  */
528 int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
529 
530 /**
531  * @brief Sets or obtains the attributes of a native window, including the width, height, and content format.
532  *
533  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
534  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
535  * @param code Indicates the operation code, pointer to <b>NativeWindowOperation</b>.
536  * @param ... variable parameter, must correspond to code one-to-one.
537  * @return Returns an error code, 0 is success, otherwise, failed.
538  * @since 8
539  * @version 1.0
540  */
541 int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...);
542 
543 /**
544  * @brief Obtains the pointer to a <b>BufferHandle</b> of an <b>OHNativeWindowBuffer</b> instance.
545  *
546  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
547  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
548  * @return Returns the pointer to the <b>BufferHandle</b> instance obtained.
549  * @since 8
550  * @version 1.0
551  */
552 BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *buffer);
553 
554 /**
555  * @brief Adds the reference count of a native object.
556  *
557  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
558  * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
559  * @return Returns an error code, 0 is success, otherwise, failed.
560  * @since 8
561  * @version 1.0
562  */
563 int32_t OH_NativeWindow_NativeObjectReference(void *obj);
564 
565 /**
566  * @brief Decreases the reference count of a native object and, when the reference count reaches 0, \n
567  * destroys this object.
568  *
569  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
570  * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
571  * @return Returns an error code, 0 is success, otherwise, failed.
572  * @since 8
573  * @version 1.0
574  */
575 int32_t OH_NativeWindow_NativeObjectUnreference(void *obj);
576 
577 /**
578  * @brief Obtains the magic ID of a native object.
579  *
580  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
581  * @param obj Indicates the pointer to an <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
582  * @return Returns the magic ID, which is unique for each native object.
583  * @since 8
584  * @version 1.0
585  */
586 int32_t OH_NativeWindow_GetNativeObjectMagic(void *obj);
587 
588 /**
589  * @brief Sets scalingMode of a native window.
590  *
591  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
592  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
593  * @param sequence Indicates the sequence to a produce buffer.
594  * @param scalingMode Indicates the enum value to <b>OHScalingMode</b>
595  * @return Returns an error code, 0 is success, otherwise, failed.
596  * @since 9
597  * @version 1.0
598  * @deprecated(since = "10")
599  */
600 int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence,
601                                                    OHScalingMode scalingMode);
602 
603 /**
604  * @brief Sets metaData 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 size Indicates the size of a <b>OHHDRMetaData</b> vector.
610  * @param metaDate Indicates the pointer to a <b>OHHDRMetaData</b> vector.
611  * @return Returns an error code, 0 is success, otherwise, failed.
612  * @since 9
613  * @version 1.0
614  * @deprecated(since = "10")
615  */
616 int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size,
617                                                 const OHHDRMetaData *metaData);
618 
619 /**
620  * @brief Sets metaDataSet of a native window.
621  *
622  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
623  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
624  * @param sequence Indicates the sequence to a produce buffer.
625  * @param key Indicates the enum value to <b>OHHDRMetadataKey</b>
626  * @param size Indicates the size of a uint8_t vector.
627  * @param metaDate Indicates the pointer to a uint8_t vector.
628  * @return Returns an error code, 0 is success, otherwise, failed.
629  * @since 9
630  * @version 1.0
631  * @deprecated(since = "10")
632  */
633 int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key,
634                                                    int32_t size, const uint8_t *metaData);
635 
636 /**
637  * @brief Sets tunnel handle of a native window.
638  *
639  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
640  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
641  * @param handle Indicates the pointer to a <b>OHExtDataHandle</b>.
642  * @return Returns an error code, 0 is success, otherwise, failed.
643  * @since 9
644  * @version 1.0
645  * @deprecated(since = "10")
646  */
647 int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle);
648 
649 /**
650  * @brief Get surfaceId from native window.
651  *
652  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
653  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
654  * @param surfaceId Indicates the pointer to a surfaceId.
655  * @return Returns an error code, 0 is success, otherwise, failed.
656  * @since 12
657  * @version 1.0
658  */
659 int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId);
660 
661 /**
662  * @brief Creates an <b>OHNativeWindow</b> instance.\n
663  *
664  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
665  * @param surfaceId Indicates the surfaceId to a surface.
666  * @param window indicates the pointer to an <b>OHNativeWindow</b> instance.
667  * @return Returns an error code, 0 is Success, otherwise, failed.
668  * @since 12
669  * @version 1.0
670  */
671 int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window);
672 
673 /**
674  * @brief Attach a buffer to an <b>OHNativeWindow</b> instance.
675  *
676  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
677  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
678  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
679  * @return Returns an error code, 0 is success, otherwise, failed.
680  * @since 12
681  * @version 1.0
682  */
683 int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
684 
685 /**
686  * @brief Detach a buffer from an <b>OHNativeWindow</b> instance.
687  *
688  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
689  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
690  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
691  * @return Returns an error code, 0 is success, otherwise, failed.
692  * @since 12
693  * @version 1.0
694  */
695 int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
696 
697 /**
698  * @brief Sets scalingMode of a native window.
699  *
700  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
701  * @param window indicates the pointer to an <b>OHNativeWindow</b> instance.
702  * @param scalingMode Indicates the enum value to <b>OHScalingModeV2</b>
703  * @return Returns an error code, 0 is Success, otherwise, failed.
704  * @since 12
705  * @version 1.0
706  */
707 int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode);
708 
709 /**
710  * @brief Set native window buffer hold.
711  *
712  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
713  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
714  * @since 12
715  * @version 1.0
716  */
717 void OH_NativeWindow_SetBufferHold(OHNativeWindow *window);
718 
719 /**
720  * @brief Write an OHNativeWindow to an OHIPCParcel.
721  *
722  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
723  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
724  * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.
725  * @return Returns an error code, 0 is success, otherwise, failed.
726  * @since 12
727  * @version 1.0
728  */
729 int32_t OH_NativeWindow_WriteToParcel(OHNativeWindow *window, OHIPCParcel *parcel);
730 
731 /**
732  * @brief Read an OHNativeWindow from an OHIPCParcel.
733  *
734  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
735  * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.
736  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
737  * @return 0 - Success.
738  *     40001000 - parcel is NULL or parcel does not contain the window.
739  * @since 12
740  * @version 1.0
741  */
742 int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window);
743 
744 /**
745  * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance.
746  *
747  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
748  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
749  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.
750  * @param fenceFd Indicates the pointer to a file descriptor handle.
751  * @param matrix Indicates the retrieved 4*4 transform matrix.
752  * @return 0 - Success.
753  *     40001000 - window is NULL or buffer is NULL or fenceFd is NULL.
754  *     41207000 - buffer state is wrong.
755  * @since 12
756  * @version 1.0
757  */
758 int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
759     int *fenceFd, float matrix[16]);
760 
761 /**
762  * @brief Clean all <b>OHNativeWindowBuffer</b> caches of this <b>OHNativeWindow</b>
763  * This interface is a non-thread-safe type interface.\n
764  *
765  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
766  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
767  * @return {@link NATIVE_ERROR_OK} 0 - Success.
768  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.
769  *     {@link NATIVE_ERROR_CONSUMER_DISCONNECTED} 41211000 - the consumer is disconnected.
770  *     {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed.
771  * @since 18
772  * @version 1.0
773  */
774 int32_t OH_NativeWindow_CleanCache(OHNativeWindow *window);
775 #ifdef __cplusplus
776 }
777 #endif
778 
779 /** @} */
780 #endif