• 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 #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 the timeout in milliseconds when the native window requests a buffer,
167      * the default value is 3000 milliseconds when not set,
168      * variable parameter in function is
169      * [in] int32_t timeout, in milliseconds.
170      */
171     SET_TIMEOUT,
172     /**
173      * get the timeout in milliseconds when the native window requests a buffer,
174      * the default value is 3000 milliseconds when not set,
175      * variable parameter in function is
176      * [out] int32_t *timeout, in milliseconds.
177      */
178     GET_TIMEOUT,
179     /**
180      * set native window buffer colorGamut,
181      * variable parameter in function is
182      * [in] int32_t colorGamut, the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}.
183      */
184     SET_COLOR_GAMUT,
185     /**
186      * get native window buffer colorGamut,
187      * variable parameter in function is
188      * [out int32_t *colorGamut], the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}.
189      */
190     GET_COLOR_GAMUT,
191     /**
192      * set native window buffer transform,
193      * variable parameter in function is
194      * [in] int32_t transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}.
195      */
196     SET_TRANSFORM,
197     /**
198      * get native window buffer transform,
199      * variable parameter in function is
200      * [out] int32_t *transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}.
201      */
202     GET_TRANSFORM,
203     /**
204      * set native window buffer uiTimestamp,
205      * variable parameter in function is
206      * [in] uint64_t uiTimestamp.
207      */
208     SET_UI_TIMESTAMP,
209     /**
210      * get native window bufferqueue size,
211      * variable parameter in function is
212      * [out] int32_t *size.
213      * @since 12
214      */
215     GET_BUFFERQUEUE_SIZE,
216     /**
217      * set surface source type,
218      * variable parameter in function is
219      * [in] int32_t sourceType, the enumeration value refers to {@link OHSurfaceSource}.
220      * @since 12
221      */
222     SET_SOURCE_TYPE,
223     /**
224      * get surface source type,
225      * variable parameter in function is
226      * [out] int32_t *sourceType, the enumeration value refers to {@link OHSurfaceSource}.
227      * @since 12
228      */
229     GET_SOURCE_TYPE,
230     /**
231      * set app framework type,
232      * variable parameter in function is
233      * [in] char* frameworkType. maximum length is 64 bytes, otherwise the setting fails.
234      * @since 12
235      */
236     SET_APP_FRAMEWORK_TYPE,
237     /**
238      * get app framework type,
239      * variable parameter in function is
240      * [out] char** frameworkType.
241      * @since 12
242      */
243     GET_APP_FRAMEWORK_TYPE,
244     /**
245      * set hdr white point brightness,
246      * variable parameter in function is
247      * [in] float brightness. the value range is 0.0f to 1.0f.
248      * @since 12
249      */
250     SET_HDR_WHITE_POINT_BRIGHTNESS,
251     /**
252      * set sdr white point brightness,
253      * variable parameter in function is
254      * [in] float brightness. the value range is 0.0f to 1.0f.
255      * @since 12
256      */
257     SET_SDR_WHITE_POINT_BRIGHTNESS,
258     /**
259      * Set native window buffer desiredPresentTimestamp, indicates the desired time to present the buffer.\n
260      * Which should be generated by std::chrono::steady_clock in nanoseconds.\n
261      * It is only effective when RenderService is the consumer.\n
262      * The buffer will wait until desiredPresentTimestamp is reached before being consumed and displayed.\n
263      * If multiple buffers reach desiredPresentTimestamp, the earlier buffer will be dropped.\n
264      * This Operation should be called before calling <b>OH_NativeWindow_NativeWindowFlushBuffer</b>.\n
265      * If desiredPresentTimestamp is greater than 1 second of the consumer-provided timestamp,
266      * the desiredPresentTimestamp will be ignored.\n
267      * Variable parameter in function is
268      * [in] int64_t desiredPresentTimestamp.
269      * @since 13
270      */
271     SET_DESIRED_PRESENT_TIMESTAMP = 24,
272 } NativeWindowOperation;
273 
274 /**
275  * @brief Indicates Scaling Mode.
276  * @since 9
277  * @deprecated(since = "10")
278  */
279 typedef enum {
280     /**
281      * the window content is not updated until a buffer of
282      * the window size is received
283      */
284     OH_SCALING_MODE_FREEZE = 0,
285     /**
286      * the buffer is scaled in two dimensions to match the window size
287      */
288     OH_SCALING_MODE_SCALE_TO_WINDOW,
289     /**
290      * the buffer is uniformly scaled so that the smaller size of
291      * the buffer matches the window size
292      */
293     OH_SCALING_MODE_SCALE_CROP,
294     /**
295      * the window is clipped to the size of the buffer's clipping rectangle
296      * pixels outside the clipping rectangle are considered fully transparent.
297      */
298     OH_SCALING_MODE_NO_SCALE_CROP,
299 } OHScalingMode;
300 
301 /**
302  * @brief Indicates Scaling Mode.
303  * @since 12
304  */
305 typedef enum {
306     /**
307      * the window content is not updated until a buffer of
308      * the window size is received
309      */
310     OH_SCALING_MODE_FREEZE_V2 = 0,
311     /**
312      * the buffer is scaled in two dimensions to match the window size
313      */
314     OH_SCALING_MODE_SCALE_TO_WINDOW_V2,
315     /**
316      * the buffer is uniformly scaled so that the smaller size of
317      * the buffer matches the window size
318      */
319     OH_SCALING_MODE_SCALE_CROP_V2,
320     /**
321      * the window is clipped to the size of the buffer's clipping rectangle
322      * pixels outside the clipping rectangle are considered fully transparent.
323      */
324     OH_SCALING_MODE_NO_SCALE_CROP_V2,
325     /**
326      * Adapt to the buffer and scale proportionally to the buffer size. Prioritize displaying all buffer content.
327      * If the size is not the same as the window size, fill the unfilled area of the window with a background color.
328      */
329     OH_SCALING_MODE_SCALE_FIT_V2,
330 } OHScalingModeV2;
331 
332 /**
333  * @brief Enumerates the HDR metadata keys.
334  * @since 9
335  * @deprecated(since = "10")
336  */
337 typedef enum {
338     OH_METAKEY_RED_PRIMARY_X = 0,
339     OH_METAKEY_RED_PRIMARY_Y = 1,
340     OH_METAKEY_GREEN_PRIMARY_X = 2,
341     OH_METAKEY_GREEN_PRIMARY_Y = 3,
342     OH_METAKEY_BLUE_PRIMARY_X = 4,
343     OH_METAKEY_BLUE_PRIMARY_Y = 5,
344     OH_METAKEY_WHITE_PRIMARY_X = 6,
345     OH_METAKEY_WHITE_PRIMARY_Y = 7,
346     OH_METAKEY_MAX_LUMINANCE = 8,
347     OH_METAKEY_MIN_LUMINANCE = 9,
348     OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10,
349     OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
350     OH_METAKEY_HDR10_PLUS = 12,
351     OH_METAKEY_HDR_VIVID = 13,
352 } OHHDRMetadataKey;
353 
354 /**
355  * @brief Defines the HDR metadata.
356  * @since 9
357  * @deprecated(since = "10")
358  */
359 typedef struct {
360     OHHDRMetadataKey key;
361     float value;
362 } OHHDRMetaData;
363 
364 /**
365  * @brief Defines the ExtData Handle
366  * @since 9
367  * @deprecated(since = "10")
368  */
369 typedef struct OHExtDataHandle {
370     /**< Handle fd, -1 if not supported */
371     int32_t fd;
372     /**< the number of reserved integer value */
373     uint32_t reserveInts;
374     /**< the reserved data */
375     int32_t reserve[0];
376 } OHExtDataHandle;
377 
378 /**
379  * @brief Indicates the source type of surface.
380  * @since 12
381  */
382 typedef enum {
383     /*
384      * the default source type of surface.
385      */
386     OH_SURFACE_SOURCE_DEFAULT = 0,
387     /*
388      * the surface is created by ui.
389      */
390     OH_SURFACE_SOURCE_UI,
391     /*
392      * the surface is created by game.
393      */
394     OH_SURFACE_SOURCE_GAME,
395     /*
396      * the surface is created by camera.
397      */
398     OH_SURFACE_SOURCE_CAMERA,
399     /*
400      * the surface is created by video.
401      */
402     OH_SURFACE_SOURCE_VIDEO,
403 } OHSurfaceSource;
404 
405 /**
406  * @brief Creates a <b>OHNativeWindow</b> instance. A new <b>OHNativeWindow</b> instance is created each time this function is called.
407  *
408  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
409  * @param pSurface Indicates the pointer to a <b>ProduceSurface</b>. The type is a pointer to <b>sptr<OHOS::Surface></b>.
410  * @return Returns the pointer to the <b>OHNativeWindow</b> instance created.
411  * @since 8
412  * @version 1.0
413  * @deprecated since 12
414  */
415 OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface);
416 
417 /**
418  * @brief Decreases the reference count of a <b>OHNativeWindow</b> instance by 1,
419  * and when the reference count reaches 0, destroys the instance.\n
420  * This interface is a non-thread-safe type interface.\n
421  *
422  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
423  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
424  * @since 8
425  * @version 1.0
426  */
427 void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window);
428 
429 /**
430  * @brief Creates a <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created each time this function is called.
431  *
432  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
433  * @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is <b>sptr<OHOS::SurfaceBuffer></b>.
434  * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
435  * @since 8
436  * @version 1.0
437  * @deprecated since 12
438  * @useinstead OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer
439  */
440 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer);
441 
442 /**
443  * @brief Creates a <b>OHNativeWindowBuffer</b> instance.\n
444  * A new <b>OHNativeWindowBuffer</b> instance is created each time this function is called.\n
445  * This interface needs to be used in conjunction with <b>OH_NativeWindow_DestroyNativeWindowBuffer<\b>,
446  * otherwise memory leaks will occur.\n
447  * This interface is a non-thread-safe type interface.\n
448  *
449  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
450  * @param nativeBuffer Indicates the pointer to a native buffer. The type is <b>OH_NativeBuffer*</b>.
451  * @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.
452  * @since 11
453  * @version 1.0
454  */
455 OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(OH_NativeBuffer* nativeBuffer);
456 
457 /**
458  * @brief Decreases the reference count of a <b>OHNativeWindowBuffer</b> instance by 1 and,
459  * when the reference count reaches 0, destroys the instance.\n
460  * This interface is a non-thread-safe type interface.\n
461  *
462  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
463  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
464  * @since 8
465  * @version 1.0
466  */
467 void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer);
468 
469 /**
470  * @brief Requests a <b>OHNativeWindowBuffer</b> through a <b>OHNativeWindow</b> instance for content production.\n
471  * Before calling this interface, you need to set the width and height of
472  * <b>OHNativeWindow</b> through <b>SET_BUFFER_GEOMETRY</b>.\n
473  * This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeWindowFlushBuffer<\b>,
474  * otherwise buffer will be exhausted.\n
475  * When the fenceFd is used up, you need to close it.\n
476  * This interface is a non-thread-safe type interface.\n
477  *
478  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
479  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
480  * @param buffer Indicates the double pointer to a <b>OHNativeWindowBuffer</b> instance.
481  * @param fenceFd Indicates the pointer to a file descriptor handle.
482  * @return Returns an error code, 0 is success, otherwise, failed.
483  * @since 8
484  * @version 1.0
485  */
486 int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window,
487     OHNativeWindowBuffer **buffer, int *fenceFd);
488 
489 /**
490  * @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue
491  * through a <b>OHNativeWindow</b> instance for content consumption.\n
492  * The fenceFd will be close by system.\n
493  * This interface is a non-thread-safe type interface.\n
494  *
495  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
496  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
497  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
498  * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization.
499  * @param region Indicates a dirty region where content is updated.
500  * @return Returns an error code, 0 is success, otherwise, failed.
501  * @since 8
502  * @version 1.0
503  */
504 int32_t OH_NativeWindow_NativeWindowFlushBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer,
505     int fenceFd, Region region);
506 
507 /**
508  * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from a <b>OHNativeWindow</b> instance.
509  *
510  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
511  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
512  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> pointer.
513  * @param fenceFd Indicates the pointer to a file descriptor handle.
514  * @param matrix Indicates the retrieved 4*4 transform matrix.
515  * @return Returns an error code, 0 is success, otherwise, failed.
516  * @since 11
517  * @version 1.0
518  * @deprecated since 12
519  * @useinstead OH_NativeWindow_GetLastFlushedBufferV2
520  */
521 int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
522     int *fenceFd, float matrix[16]);
523 
524  /**
525  * @brief Returns the <b>OHNativeWindowBuffer</b> to the buffer queue through a <b>OHNativeWindow</b> instance,
526  * without filling in any content. The <b>OHNativeWindowBuffer</b> can be used for another request.\n
527  * This interface is a non-thread-safe type interface.\n
528  *
529  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
530  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
531  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
532  * @return Returns an error code, 0 is success, otherwise, failed.
533  * @since 8
534  * @version 1.0
535  */
536 int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
537 
538 /**
539  * @brief Sets or obtains the attributes of a native window, including the width, height, and content format.\n
540  * This interface is a non-thread-safe type interface.\n
541  *
542  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
543  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
544  * @param code Indicates the operation code, pointer to <b>NativeWindowOperation</b>.
545  * @param ... variable parameter, must correspond to code one-to-one.
546  * @return Returns an error code, 0 is success, otherwise, failed.
547  * @since 8
548  * @version 1.0
549  */
550 int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...);
551 
552 /**
553  * @brief Obtains the pointer to a <b>BufferHandle</b> of a <b>OHNativeWindowBuffer</b> instance.\n
554  * This interface is a non-thread-safe type interface.\n
555  *
556  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
557  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
558  * @return Returns the pointer to the <b>BufferHandle</b> instance obtained.
559  * @since 8
560  * @version 1.0
561  */
562 BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *buffer);
563 
564 /**
565  * @brief Adds the reference count of a native object.\n
566  * This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeObjectUnreference<\b>,
567  * otherwise memory leaks will occur.\n
568  * This interface is a non-thread-safe type interface.\n
569  *
570  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
571  * @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
572  * @return Returns an error code, 0 is success, otherwise, failed.
573  * @since 8
574  * @version 1.0
575  */
576 int32_t OH_NativeWindow_NativeObjectReference(void *obj);
577 
578 /**
579  * @brief Decreases the reference count of a native object and,
580  * when the reference count reaches 0, destroys this object.\n
581  * This interface is a non-thread-safe type interface.\n
582  *
583  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
584  * @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.
585  * @return Returns an error code, 0 is success, otherwise, failed.
586  * @since 8
587  * @version 1.0
588  */
589 int32_t OH_NativeWindow_NativeObjectUnreference(void *obj);
590 
591 /**
592  * @brief Obtains the magic ID of a native object.\n
593  * This interface is a non-thread-safe type interface.\n
594  *
595  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
596  * @param obj Indicates the pointer to a <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 a <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 a <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 a <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 a <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 Attach a buffer to an <b>OHNativeWindow</b> instance.\n
666  * This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeWindowDetachBuffer<\b>,
667  * otherwise buffer management will be chaotic.\n
668  * This interface is a non-thread-safe type interface.\n
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.\n
681  * This interface is a non-thread-safe type interface.\n
682  *
683  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
684  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
685  * @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.
686  * @return Returns an error code, 0 is success, otherwise, failed.
687  * @since 12
688  * @version 1.0
689  */
690 int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
691 
692 /**
693  * @brief Get surfaceId from native window.\n
694  * This interface is a non-thread-safe type interface.\n
695  *
696  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
697  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
698  * @param surfaceId Indicates the pointer to a surfaceId.
699  * @return Returns an error code, 0 is success, otherwise, failed.
700  * @since 12
701  * @version 1.0
702  */
703 int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId);
704 
705 /**
706  * @brief Creates an <b>OHNativeWindow</b> instance.\n
707  * This interface needs to be used in conjunction with <b>OH_NativeWindow_DestroyNativeWindow<\b>,
708  * otherwise memory leaks will occur.\n
709  * If there is a concurrent destroy OHNativeWindow, you need to add once and decrement once to the
710  * OHNativeWindow reference count through <b>OH_NativeWindow_NativeObjectReference<\b> and
711  * <b>OH_NativeWindow_NativeObjectUnreference<\b>.\n
712  * If the surface obtained through surfaceId is created in this process, the surface cannot be obtained
713  * across processes.\n
714  * This interface is a non-thread-safe type interface.\n
715  *
716  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
717  * @param surfaceId Indicates the surfaceId to a surface.
718  * @param window indicates the pointer to an <b>OHNativeWindow</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_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window);
724 
725 /**
726  * @brief Sets scalingMode of a native window.\n
727  * This interface is a non-thread-safe type interface.\n
728  *
729  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
730  * @param window indicates the pointer to an <b>OHNativeWindow</b> instance.
731  * @param scalingMode Indicates the enum value to <b>OHScalingModeV2</b>
732  * @return Returns an error code, 0 is Success, otherwise, failed.
733  * @since 12
734  * @version 1.0
735  */
736 int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode);
737 
738 /**
739  * @brief Set native window buffer hold.\n
740  * This interface is a non-thread-safe type interface.\n
741  *
742  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
743  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
744  * @since 12
745  * @version 1.0
746  */
747 void OH_NativeWindow_SetBufferHold(OHNativeWindow *window);
748 
749 /**
750  * @brief Write an OHNativeWindow to an OHIPCParcel.\n
751  * This interface is a non-thread-safe type interface.\n
752  *
753  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
754  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
755  * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.
756  * @return {@link NATIVE_ERROR_OK} 0 - Success.
757  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or window is NULL.
758  * @since 12
759  * @version 1.0
760  */
761 int32_t OH_NativeWindow_WriteToParcel(OHNativeWindow *window, OHIPCParcel *parcel);
762 
763 /**
764  * @brief Read an OHNativeWindow from an OHIPCParcel.\n
765  * This interface is a non-thread-safe type interface.\n
766  *
767  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
768  * @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.
769  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
770  * @return {@link NATIVE_ERROR_OK} 0 - Success.
771  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or parcel does not contain the window.
772  * @since 12
773  * @version 1.0
774  */
775 int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window);
776 
777 /**
778  * @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance.\n
779  * When the fenceFd is used up, you need to close it.\n
780  * This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeObjectUnreference<\b>,
781  * otherwise memory leaks will occur.\n
782  * This interface is a non-thread-safe type interface.\n
783  *
784  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
785  * @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.
786  * @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.
787  * @param fenceFd Indicates the pointer to a file descriptor handle.
788  * @param matrix Indicates the retrieved 4*4 transform matrix.
789  * @return {@link NATIVE_ERROR_OK} 0 - Success.
790  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL or buffer is NULL or fenceFd is NULL.
791  *     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - buffer state is wrong.
792  * @since 12
793  * @version 1.0
794  */
795 
796 int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
797     int *fenceFd, float matrix[16]);
798 /**
799  * @brief Set the color space of the native window.\n
800  * This interface is a non-thread-safe type interface.\n
801  *
802  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
803  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
804  * @param colorSpace Indicates the color space of native window, see <b>OH_NativeBuffer_ColorSpace</b>.
805  * @return {@link NATIVE_ERROR_OK} 0 - Success.
806  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.
807  *     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state.
808  * @since 12
809  * @version 1.0
810  */
811 int32_t OH_NativeWindow_SetColorSpace(OHNativeWindow *window, OH_NativeBuffer_ColorSpace colorSpace);
812 
813 /**
814  * @brief Get the color space of the native window.\n
815  * This interface is a non-thread-safe type interface.\n
816  *
817  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
818  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
819  * @param colorSpace Indicates the color space of native window, see <b>OH_NativeBuffer_ColorSpace</b>.
820  * @return {@link NATIVE_ERROR_OK} 0 - Success.
821  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.
822  *     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state.
823  * @since 12
824  * @version 1.0
825  */
826 int32_t OH_NativeWindow_GetColorSpace(OHNativeWindow *window, OH_NativeBuffer_ColorSpace *colorSpace);
827 
828 /**
829  * @brief Set the metadata type of the native window.\n
830  * This interface is a non-thread-safe type interface.\n
831  *
832  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
833  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
834  * @param metadataKey Indicates the metadata type of native window, see <b>OH_NativeBuffer_MetadataKey</b>.
835  * @param size Indicates the size of a uint8_t vector.
836  * @param metadata Indicates the pointer to a uint8_t vector.
837  * @return {@link NATIVE_ERROR_OK} 0 - Success.
838  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window or metadata is NULL.
839  *     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state.
840  *     {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key.
841  * @since 12
842  * @version 1.0
843  */
844 int32_t OH_NativeWindow_SetMetadataValue(OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey,
845     int32_t size, uint8_t *metadata);
846 
847 /**
848  * @brief Set the metadata type of the native window.\n
849  * This interface is a non-thread-safe type interface.\n
850  *
851  * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
852  * @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.
853  * @param metadataKey Indicates the metadata type of native window, see <b>OH_NativeBuffer_MetadataKey</b>.
854  * @param size Indicates the size of a uint8_t vector.
855  * @param metadata Indicates the pointer to a uint8_t vector.
856  * @return {@link NATIVE_ERROR_OK} 0 - Success.
857  *     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window, metadata, or size is NULL.
858  *     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state.
859  *     {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key.
860  * @since 12
861  * @version 1.0
862  */
863 int32_t OH_NativeWindow_GetMetadataValue(OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey,
864     int32_t *size, uint8_t **metadata);
865 #ifdef __cplusplus
866 }
867 #endif
868 
869 /** @} */
870 #endif