ohos-native-window-sys 0.1.3

OpenHarmony's native window binding for rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/* automatically generated by rust-bindgen 0.65.1 */

#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(clippy::missing_safety_doc)]
// bindgen's bitfield accessors transmute/cast between identical types.
#![allow(clippy::useless_transmute)]
#![allow(clippy::unnecessary_cast)]

use ohos_native_buffer_sys::*;

#[link(name = "native_window")]
unsafe extern "C" {}

#[repr(C)]
#[derive(Default)]
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
    #[inline]
    pub const fn new() -> Self {
        __IncompleteArrayField(::std::marker::PhantomData, [])
    }
    #[inline]
    pub fn as_ptr(&self) -> *const T {
        self as *const _ as *const T
    }
    #[inline]
    pub fn as_mut_ptr(&mut self) -> *mut T {
        self as *mut _ as *mut T
    }
    #[inline]
    pub unsafe fn as_slice(&self, len: usize) -> &[T] {
        ::std::slice::from_raw_parts(self.as_ptr(), len)
    }
    #[inline]
    pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
        ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
    }
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_str("__IncompleteArrayField")
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OHIPCParcel {
    _unused: [u8; 0],
}
#[doc = " @brief native window.\n @since 8"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NativeWindow {
    _unused: [u8; 0],
}
#[doc = " @brief define the new type name OHNativeWindow for struct NativeWindow.\n @since 8"]
pub type OHNativeWindow = NativeWindow;
#[doc = " @brief define the new type name OHNativeWindowBuffer for struct NativeWindowBuffer.\n @since 8"]
pub type OHNativeWindowBuffer = NativeWindowBuffer;
#[doc = " @brief indicates a dirty region where content is updated.\n @since 8"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Region {
    pub rects: *mut Region_Rect,
    #[doc = " if rectNumber is 0, fill the Buffer dirty size by default"]
    pub rectNumber: i32,
}
#[doc = " if rects is nullptr, fill the Buffer dirty size by default"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Region_Rect {
    pub x: i32,
    pub y: i32,
    pub w: u32,
    pub h: u32,
}
#[doc = " set native window buffer geometry,\n variable parameter in function is\n [in] int32_t width, [in] int32_t height"]
pub const NativeWindowOperation_SET_BUFFER_GEOMETRY: NativeWindowOperation = 0;
#[doc = " get native window buffer geometry,\n variable parameter in function is\n [out] int32_t *height, [out] int32_t *width"]
pub const NativeWindowOperation_GET_BUFFER_GEOMETRY: NativeWindowOperation = 1;
#[doc = " get native window buffer format,\n variable parameter in function is\n [out] int32_t *format, the enumeration value refers to {@link OH_NativeBuffer_Format}."]
pub const NativeWindowOperation_GET_FORMAT: NativeWindowOperation = 2;
#[doc = " set native window buffer format,\n variable parameter in function is\n [in] int32_t format, the enumeration value refers to {@link OH_NativeBuffer_Format}."]
pub const NativeWindowOperation_SET_FORMAT: NativeWindowOperation = 3;
#[doc = " get native window buffer usage,\n variable parameter in function is\n [out] uint64_t *usage, the enumeration value refers to {@link OH_NativeBuffer_Usage}."]
pub const NativeWindowOperation_GET_USAGE: NativeWindowOperation = 4;
#[doc = " set native window buffer usage,\n variable parameter in function is\n [in] uint64_t usage, the enumeration value refers to {@link OH_NativeBuffer_Usage}."]
pub const NativeWindowOperation_SET_USAGE: NativeWindowOperation = 5;
#[doc = " set native window buffer stride,\n variable parameter in function is\n [in] int32_t stride.\n @deprecated since 16"]
pub const NativeWindowOperation_SET_STRIDE: NativeWindowOperation = 6;
#[doc = " get native window buffer stride,\n variable parameter in function is\n [out] int32_t *stride.\n @deprecated since 16\n @useinstead Use {@link OH_NativeWindow_GetBufferHandleFromNative} to get a {@link BufferHandleand} from a buffer\n and then retrieve the stride from the {@link BufferHandle}."]
pub const NativeWindowOperation_GET_STRIDE: NativeWindowOperation = 7;
#[doc = " set native window buffer swap interval,\n variable parameter in function is\n [in] int32_t interval."]
pub const NativeWindowOperation_SET_SWAP_INTERVAL: NativeWindowOperation = 8;
#[doc = " get native window buffer swap interval,\n variable parameter in function is\n [out] int32_t *interval."]
pub const NativeWindowOperation_GET_SWAP_INTERVAL: NativeWindowOperation = 9;
#[doc = " set the timeout in milliseconds when the native window requests a buffer,\n the default value is 3000 milliseconds when not set,\n variable parameter in function is\n [in] int32_t timeout, in milliseconds."]
pub const NativeWindowOperation_SET_TIMEOUT: NativeWindowOperation = 10;
#[doc = " get the timeout in milliseconds when the native window requests a buffer,\n the default value is 3000 milliseconds when not set,\n variable parameter in function is\n [out] int32_t *timeout, in milliseconds."]
pub const NativeWindowOperation_GET_TIMEOUT: NativeWindowOperation = 11;
#[doc = " set native window buffer colorGamut,\n variable parameter in function is\n [in] int32_t colorGamut, the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}."]
pub const NativeWindowOperation_SET_COLOR_GAMUT: NativeWindowOperation = 12;
#[doc = " get native window buffer colorGamut,\n variable parameter in function is\n [out] int32_t *colorGamut, the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}."]
pub const NativeWindowOperation_GET_COLOR_GAMUT: NativeWindowOperation = 13;
#[doc = " set native window buffer transform,\n variable parameter in function is\n [in] int32_t transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}."]
pub const NativeWindowOperation_SET_TRANSFORM: NativeWindowOperation = 14;
#[doc = " get native window buffer transform,\n variable parameter in function is\n [out] int32_t *transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}."]
pub const NativeWindowOperation_GET_TRANSFORM: NativeWindowOperation = 15;
#[doc = " set native window buffer uiTimestamp,\n variable parameter in function is\n [in] uint64_t uiTimestamp."]
pub const NativeWindowOperation_SET_UI_TIMESTAMP: NativeWindowOperation = 16;
#[doc = " get native window bufferqueue size,\n variable parameter in function is\n [out] int32_t *size.\n @since 12"]
pub const NativeWindowOperation_GET_BUFFERQUEUE_SIZE: NativeWindowOperation = 17;
#[doc = " set surface source type,\n variable parameter in function is\n [in] int32_t sourceType, the enumeration value refers to {@link OHSurfaceSource}.\n @since 12"]
pub const NativeWindowOperation_SET_SOURCE_TYPE: NativeWindowOperation = 18;
#[doc = " get surface source type,\n variable parameter in function is\n [out] int32_t *sourceType, the enumeration value refers to {@link OHSurfaceSource}.\n @since 12"]
pub const NativeWindowOperation_GET_SOURCE_TYPE: NativeWindowOperation = 19;
#[doc = " set app framework type,\n variable parameter in function is\n [in] char* frameworkType. maximum length is 64 bytes, otherwise the setting fails.\n @since 12"]
pub const NativeWindowOperation_SET_APP_FRAMEWORK_TYPE: NativeWindowOperation = 20;
#[doc = " get app framework type,\n variable parameter in function is\n [out] char** frameworkType.\n @since 12"]
pub const NativeWindowOperation_GET_APP_FRAMEWORK_TYPE: NativeWindowOperation = 21;
#[doc = " set hdr white point brightness,\n variable parameter in function is\n [in] float brightness. the value range is 0.0f to 1.0f.\n @since 12"]
pub const NativeWindowOperation_SET_HDR_WHITE_POINT_BRIGHTNESS: NativeWindowOperation = 22;
#[doc = " set sdr white point brightness,\n variable parameter in function is\n [in] float brightness. the value range is 0.0f to 1.0f.\n @since 12"]
pub const NativeWindowOperation_SET_SDR_WHITE_POINT_BRIGHTNESS: NativeWindowOperation = 23;
#[doc = " Set native window buffer desiredPresentTimestamp, indicates the desired time to present the buffer.\\n\n Which should be generated by std::chrono::steady_clock in nanoseconds.\\n\n It is only effective when RenderService is the consumer.\\n\n The buffer will wait until desiredPresentTimestamp is reached before being consumed and displayed.\\n\n If multiple buffers reach desiredPresentTimestamp, the earlier buffer will be dropped.\\n\n This Operation should be called before calling <b>OH_NativeWindow_NativeWindowFlushBuffer</b>.\\n\n If desiredPresentTimestamp is greater than 1 second of the consumer-provided timestamp,\n the desiredPresentTimestamp will be ignored.\\n\n Variable parameter in function is\n [in] int64_t desiredPresentTimestamp.\n @since 13"]
#[cfg(feature = "api-13")]
pub const NativeWindowOperation_SET_DESIRED_PRESENT_TIMESTAMP: NativeWindowOperation = 24;
#[doc = " @brief Indicates the operation code in the function OH_NativeWindow_NativeWindowHandleOpt.\n @since 8"]
pub type NativeWindowOperation = u32;
#[doc = " the window content is not updated until a buffer of\n the window size is received"]
pub const OHScalingMode_OH_SCALING_MODE_FREEZE: OHScalingMode = 0;
#[doc = " the buffer is scaled in two dimensions to match the window size"]
pub const OHScalingMode_OH_SCALING_MODE_SCALE_TO_WINDOW: OHScalingMode = 1;
#[doc = " the buffer is uniformly scaled so that the smaller size of\n the buffer matches the window size"]
pub const OHScalingMode_OH_SCALING_MODE_SCALE_CROP: OHScalingMode = 2;
#[doc = " the window is clipped to the size of the buffer's clipping rectangle\n pixels outside the clipping rectangle are considered fully transparent."]
pub const OHScalingMode_OH_SCALING_MODE_NO_SCALE_CROP: OHScalingMode = 3;
#[doc = " @brief Indicates Scaling Mode.\n @since 9\n @deprecated since 10\n @useinstead OHScalingModeV2"]
pub type OHScalingMode = u32;
#[doc = " the window content is not updated until a buffer of\n the window size is received"]
pub const OHScalingModeV2_OH_SCALING_MODE_FREEZE_V2: OHScalingModeV2 = 0;
#[doc = " the buffer is scaled in two dimensions to match the window size"]
pub const OHScalingModeV2_OH_SCALING_MODE_SCALE_TO_WINDOW_V2: OHScalingModeV2 = 1;
#[doc = " the buffer is uniformly scaled so that the smaller size of\n the buffer matches the window size"]
pub const OHScalingModeV2_OH_SCALING_MODE_SCALE_CROP_V2: OHScalingModeV2 = 2;
#[doc = " the window is clipped to the size of the buffer's clipping rectangle\n pixels outside the clipping rectangle are considered fully transparent."]
pub const OHScalingModeV2_OH_SCALING_MODE_NO_SCALE_CROP_V2: OHScalingModeV2 = 3;
#[doc = " Adapt to the buffer and scale proportionally to the buffer size. Prioritize displaying all buffer content.\n If the size is not the same as the window size, fill the unfilled area of the window with a background color."]
pub const OHScalingModeV2_OH_SCALING_MODE_SCALE_FIT_V2: OHScalingModeV2 = 4;
#[doc = " @brief Indicates Scaling Mode.\n @since 12"]
pub type OHScalingModeV2 = u32;
pub const OHHDRMetadataKey_OH_METAKEY_RED_PRIMARY_X: OHHDRMetadataKey = 0;
pub const OHHDRMetadataKey_OH_METAKEY_RED_PRIMARY_Y: OHHDRMetadataKey = 1;
pub const OHHDRMetadataKey_OH_METAKEY_GREEN_PRIMARY_X: OHHDRMetadataKey = 2;
pub const OHHDRMetadataKey_OH_METAKEY_GREEN_PRIMARY_Y: OHHDRMetadataKey = 3;
pub const OHHDRMetadataKey_OH_METAKEY_BLUE_PRIMARY_X: OHHDRMetadataKey = 4;
pub const OHHDRMetadataKey_OH_METAKEY_BLUE_PRIMARY_Y: OHHDRMetadataKey = 5;
pub const OHHDRMetadataKey_OH_METAKEY_WHITE_PRIMARY_X: OHHDRMetadataKey = 6;
pub const OHHDRMetadataKey_OH_METAKEY_WHITE_PRIMARY_Y: OHHDRMetadataKey = 7;
pub const OHHDRMetadataKey_OH_METAKEY_MAX_LUMINANCE: OHHDRMetadataKey = 8;
pub const OHHDRMetadataKey_OH_METAKEY_MIN_LUMINANCE: OHHDRMetadataKey = 9;
pub const OHHDRMetadataKey_OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL: OHHDRMetadataKey = 10;
pub const OHHDRMetadataKey_OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL: OHHDRMetadataKey = 11;
pub const OHHDRMetadataKey_OH_METAKEY_HDR10_PLUS: OHHDRMetadataKey = 12;
pub const OHHDRMetadataKey_OH_METAKEY_HDR_VIVID: OHHDRMetadataKey = 13;
#[doc = " @brief Enumerates the HDR metadata keys.\n @since 9\n @deprecated since 10"]
pub type OHHDRMetadataKey = u32;
#[doc = " @brief Defines the HDR metadata.\n @since 9\n @deprecated since 10"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OHHDRMetaData {
    pub key: OHHDRMetadataKey,
    pub value: f32,
}
#[doc = " @brief Defines the ExtData Handle\n @since 9\n @deprecated since 10"]
#[repr(C)]
#[derive(Debug)]
pub struct OHExtDataHandle {
    pub fd: i32,
    pub reserveInts: u32,
    pub reserve: __IncompleteArrayField<i32>,
}
extern "C" {
    #[doc = " @brief Creates a <b>OHNativeWindow</b> instance. A new <b>OHNativeWindow</b> instance is created each time this function is called.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param pSurface Indicates the pointer to a <b>ProduceSurface</b>. The type is a pointer to <b>sptr<OHOS::Surface></b>.\n @return Returns the pointer to the <b>OHNativeWindow</b> instance created.\n @since 8\n @version 1.0\n @deprecated since 12"]
    pub fn OH_NativeWindow_CreateNativeWindow(
        pSurface: *mut ::std::os::raw::c_void,
    ) -> *mut OHNativeWindow;
}
extern "C" {
    #[doc = " @brief Decreases the reference count of a <b>OHNativeWindow</b> instance by 1,\n and when the reference count reaches 0, destroys the instance.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_DestroyNativeWindow(window: *mut OHNativeWindow);
}
extern "C" {
    #[doc = " @brief Creates a <b>OHNativeWindowBuffer</b> instance. A new <b>OHNativeWindowBuffer</b> instance is created each time this function is called.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is <b>sptr<OHOS::SurfaceBuffer></b>.\n @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.\n @since 8\n @version 1.0\n @deprecated since 12\n @useinstead OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer"]
    pub fn OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(
        pSurfaceBuffer: *mut ::std::os::raw::c_void,
    ) -> *mut OHNativeWindowBuffer;
}
extern "C" {
    #[doc = " @brief Creates a <b>OHNativeWindowBuffer</b> instance.\\n\n A new <b>OHNativeWindowBuffer</b> instance is created each time this function is called.\\n\n This interface needs to be used in conjunction with <b>OH_NativeWindow_DestroyNativeWindowBuffer</b>,\n otherwise memory leaks will occur.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param nativeBuffer Indicates the pointer to a native buffer. The type is <b>OH_NativeBuffer*</b>.\n @return Returns the pointer to the <b>OHNativeWindowBuffer</b> instance created.\n @since 11\n @version 1.0"]
    pub fn OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(
        nativeBuffer: *mut OH_NativeBuffer,
    ) -> *mut OHNativeWindowBuffer;
}
extern "C" {
    #[doc = " @brief Decreases the reference count of a <b>OHNativeWindowBuffer</b> instance by 1 and,\n when the reference count reaches 0, destroys the instance.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_DestroyNativeWindowBuffer(buffer: *mut OHNativeWindowBuffer);
}
extern "C" {
    #[doc = " @brief Requests a <b>OHNativeWindowBuffer</b> through a <b>OHNativeWindow</b> instance for content production.\\n\n Before calling this interface, you need to set the width and height of\n <b>OHNativeWindow</b> through <b>SET_BUFFER_GEOMETRY</b>.\\n\n This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeWindowFlushBuffer</b>,\n otherwise buffer will be exhausted.\\n\n When the fenceFd is used up, you need to close it.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param buffer Indicates the double pointer to a <b>OHNativeWindowBuffer</b> instance.\n @param fenceFd Indicates the pointer to a file descriptor handle.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowRequestBuffer(
        window: *mut OHNativeWindow,
        buffer: *mut *mut OHNativeWindowBuffer,
        fenceFd: *mut ::std::os::raw::c_int,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue\n through a <b>OHNativeWindow</b> instance for content consumption.\\n\n The fenceFd will be close by system.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.\n @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization.\n @param region Indicates a dirty region where content is updated.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowFlushBuffer(
        window: *mut OHNativeWindow,
        buffer: *mut OHNativeWindowBuffer,
        fenceFd: ::std::os::raw::c_int,
        region: Region,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Get the last flushed <b>OHNativeWindowBuffer</b> from a <b>OHNativeWindow</b> instance.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> pointer.\n @param fenceFd Indicates the pointer to a file descriptor handle.\n @param matrix Indicates the retrieved 4*4 transform matrix.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 11\n @version 1.0\n @deprecated since 12\n @useinstead OH_NativeWindow_GetLastFlushedBufferV2"]
    pub fn OH_NativeWindow_GetLastFlushedBuffer(
        window: *mut OHNativeWindow,
        buffer: *mut *mut OHNativeWindowBuffer,
        fenceFd: *mut ::std::os::raw::c_int,
        matrix: *mut f32,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Returns the <b>OHNativeWindowBuffer</b> to the buffer queue through a <b>OHNativeWindow</b> instance,\n without filling in any content. The <b>OHNativeWindowBuffer</b> can be used for another request.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowAbortBuffer(
        window: *mut OHNativeWindow,
        buffer: *mut OHNativeWindowBuffer,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Sets or obtains the attributes of a native window, including the width, height, and content format.\\n\n This interface is a non-thread-safe type interface.\\n\n\n <p><strong>API Note</strong>\n\n <strong>Performance Note</strong>\n <p>By default, the window buffer in the current operating system is accessed via the CPU. If an application\n does not need to access the window buffer data using the CPU, it can proactively disable CPU access to\n enhance energy efficiency and reduce power consumption.\n </p>\n <p>For details about how to optimize power consumption for data read/write operations in data buffers,\n see [How do I proactively disable CPU access to window buffers to reduce power consumption?]{@link https://developer.huawei.com/consumer/en/doc/harmonyos-faqs/faqs-arkgraphics-2d-14}.</p>\n </p>\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param code Indicates the operation code, pointer to <b>NativeWindowOperation</b>.\n @param ... variable parameter, must correspond to code one-to-one.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowHandleOpt(
        window: *mut OHNativeWindow,
        code: ::std::os::raw::c_int,
        ...
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Obtains the pointer to a <b>BufferHandle</b> of a <b>OHNativeWindowBuffer</b> instance.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.\n @return Returns the pointer to the <b>BufferHandle</b> instance obtained.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_GetBufferHandleFromNative(
        buffer: *mut OHNativeWindowBuffer,
    ) -> *mut BufferHandle;
}
extern "C" {
    #[doc = " @brief Adds the reference count of a native object.\\n\n This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeObjectUnreference</b>,\n otherwise memory leaks will occur.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_NativeObjectReference(obj: *mut ::std::os::raw::c_void) -> i32;
}
extern "C" {
    #[doc = " @brief Decreases the reference count of a native object and,\n when the reference count reaches 0, destroys this object.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_NativeObjectUnreference(obj: *mut ::std::os::raw::c_void) -> i32;
}
extern "C" {
    #[doc = " @brief Obtains the magic ID of a native object.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param obj Indicates the pointer to a <b>OHNativeWindow</b> or <b>OHNativeWindowBuffer</b> instance.\n @return Returns the magic ID, which is unique for each native object.\n @since 8\n @version 1.0"]
    pub fn OH_NativeWindow_GetNativeObjectMagic(obj: *mut ::std::os::raw::c_void) -> i32;
}
extern "C" {
    #[doc = " @brief Sets scalingMode of a native window.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param sequence Indicates the sequence to a produce buffer.\n @param scalingMode Indicates the enum value to <b>OHScalingMode</b>\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 9\n @version 1.0\n @deprecated since 10\n @useinstead OH_NativeWindow_NativeWindowSetScalingModeV2"]
    pub fn OH_NativeWindow_NativeWindowSetScalingMode(
        window: *mut OHNativeWindow,
        sequence: u32,
        scalingMode: OHScalingMode,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Sets metaData of a native window.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param sequence Indicates the sequence to a produce buffer.\n @param size Indicates the size of a <b>OHHDRMetaData</b> vector.\n @param metaDate Indicates the pointer to a <b>OHHDRMetaData</b> vector.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 9\n @version 1.0\n @deprecated since 10"]
    pub fn OH_NativeWindow_NativeWindowSetMetaData(
        window: *mut OHNativeWindow,
        sequence: u32,
        size: i32,
        metaData: *const OHHDRMetaData,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Sets metaDataSet of a native window.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param sequence Indicates the sequence to a produce buffer.\n @param key Indicates the enum value to <b>OHHDRMetadataKey</b>\n @param size Indicates the size of a uint8_t vector.\n @param metaDate Indicates the pointer to a uint8_t vector.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 9\n @version 1.0\n @deprecated since 10"]
    pub fn OH_NativeWindow_NativeWindowSetMetaDataSet(
        window: *mut OHNativeWindow,
        sequence: u32,
        key: OHHDRMetadataKey,
        size: i32,
        metaData: *const u8,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Sets tunnel handle of a native window.\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param handle Indicates the pointer to a <b>OHExtDataHandle</b>.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 9\n @version 1.0\n @deprecated since 10"]
    pub fn OH_NativeWindow_NativeWindowSetTunnelHandle(
        window: *mut OHNativeWindow,
        handle: *const OHExtDataHandle,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Attach a buffer to an <b>OHNativeWindow</b> instance.\\n\n This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeWindowDetachBuffer</b>,\n otherwise buffer management will be chaotic.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowAttachBuffer(
        window: *mut OHNativeWindow,
        buffer: *mut OHNativeWindowBuffer,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Detach a buffer from an <b>OHNativeWindow</b> instance.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @param buffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowDetachBuffer(
        window: *mut OHNativeWindow,
        buffer: *mut OHNativeWindowBuffer,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Get surfaceId from native window.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @param surfaceId Indicates the pointer to a surfaceId.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_GetSurfaceId(window: *mut OHNativeWindow, surfaceId: *mut u64) -> i32;
}
extern "C" {
    #[doc = " @brief Creates an <b>OHNativeWindow</b> instance.\\n\n This interface needs to be used in conjunction with <b>OH_NativeWindow_DestroyNativeWindow</b>,\n otherwise memory leaks will occur.\\n\n If there is a concurrent destroy OHNativeWindow, you need to add once and decrement once to the\n OHNativeWindow reference count through <b>OH_NativeWindow_NativeObjectReference</b> and\n <b>OH_NativeWindow_NativeObjectUnreference</b>.\\n\n If the surface obtained through surfaceId is created in this process, the surface cannot be obtained\n across processes.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param surfaceId Indicates the surfaceId to a surface.\n @param window indicates the pointer to an <b>OHNativeWindow</b> instance.\n @return Returns an error code, 0 is Success, otherwise, failed.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_CreateNativeWindowFromSurfaceId(
        surfaceId: u64,
        window: *mut *mut OHNativeWindow,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Sets scalingMode of a native window.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window indicates the pointer to an <b>OHNativeWindow</b> instance.\n @param scalingMode Indicates the enum value to <b>OHScalingModeV2</b>\n @return Returns an error code, 0 is Success, otherwise, failed.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_NativeWindowSetScalingModeV2(
        window: *mut OHNativeWindow,
        scalingMode: OHScalingModeV2,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Set native window buffer hold.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_SetBufferHold(window: *mut OHNativeWindow);
}
extern "C" {
    #[doc = " @brief Write an OHNativeWindow to an OHIPCParcel.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or window is NULL.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_WriteToParcel(
        window: *mut OHNativeWindow,
        parcel: *mut OHIPCParcel,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Read an OHNativeWindow from an OHIPCParcel.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param parcel Indicates the pointer to an <b>OHIPCParcel</b> instance.\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or parcel does not contain the window.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_ReadFromParcel(
        parcel: *mut OHIPCParcel,
        window: *mut *mut OHNativeWindow,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Get the last flushed <b>OHNativeWindowBuffer</b> from an <b>OHNativeWindow</b> instance.\\n\n When the fenceFd is used up, you need to close it.\\n\n This interface needs to be used in conjunction with <b>OH_NativeWindow_NativeObjectUnreference</b>,\n otherwise memory leaks will occur.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to an <b>OHNativeWindow</b> instance.\n @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.\n @param fenceFd Indicates the pointer to a file descriptor handle.\n @param matrix Indicates the retrieved 4*4 transform matrix.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL or buffer is NULL or fenceFd is NULL.\n     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - buffer state is wrong.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_GetLastFlushedBufferV2(
        window: *mut OHNativeWindow,
        buffer: *mut *mut OHNativeWindowBuffer,
        fenceFd: *mut ::std::os::raw::c_int,
        matrix: *mut f32,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Set the color space of the native window.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param colorSpace Indicates the color space of native window, see <b>OH_NativeBuffer_ColorSpace</b>.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.\n     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_SetColorSpace(
        window: *mut OHNativeWindow,
        colorSpace: OH_NativeBuffer_ColorSpace,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Get the color space of the native window.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param colorSpace Indicates the color space of native window, see <b>OH_NativeBuffer_ColorSpace</b>.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.\n     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_GetColorSpace(
        window: *mut OHNativeWindow,
        colorSpace: *mut OH_NativeBuffer_ColorSpace,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Set the metadata type of the native window.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param metadataKey Indicates the metadata type of native window, see <b>OH_NativeBuffer_MetadataKey</b>.\n @param size Indicates the size of a uint8_t vector.\n @param metadata Indicates the pointer to a uint8_t vector.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window or metadata is NULL.\n     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state.\n     {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_SetMetadataValue(
        window: *mut OHNativeWindow,
        metadataKey: OH_NativeBuffer_MetadataKey,
        size: i32,
        metadata: *mut u8,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Set the metadata type of the native window.\\n\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param metadataKey Indicates the metadata type of native window, see <b>OH_NativeBuffer_MetadataKey</b>.\n @param size Indicates the size of a uint8_t vector.\n @param metadata Indicates the pointer to a uint8_t vector.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window, metadata, or size is NULL.\n     {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state.\n     {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key.\n @since 12\n @version 1.0"]
    pub fn OH_NativeWindow_GetMetadataValue(
        window: *mut OHNativeWindow,
        metadataKey: OH_NativeBuffer_MetadataKey,
        size: *mut i32,
        metadata: *mut *mut u8,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Clean all <b>OHNativeWindowBuffer</b> caches of this <b>OHNativeWindow</b>\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.\n     {@link NATIVE_ERROR_CONSUMER_DISCONNECTED} 41211000 - the consumer is disconnected.\n     {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed.\n @since 19\n @version 1.0"]
    #[cfg(feature = "api-19")]
    pub fn OH_NativeWindow_CleanCache(window: *mut OHNativeWindow) -> i32;
}
extern "C" {
    #[doc = " @brief PreAlloc <b>OHNativeWindowBuffer</b> of this <b>OHNativeWindow</b>\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param allocBufferCnt Indicates the count of <b>OHNativeWindowBuffers</b>.\n @return Returns an error code, 0 is success, otherwise, failed.\n @since 22\n @version 1.0"]
    #[cfg(feature = "api-22")]
    pub fn OH_NativeWindow_PreAllocBuffers(window: *mut OHNativeWindow, allocBufferCnt: u32)
        -> i32;
}
extern "C" {
    #[doc = " @brief Requests an <b>OHNativeWindowBuffer</b> through an <b>OHNativeWindow</b> instance for content production,\\n\n and lock the <b>OHNativeWindowBuffer</b>, the interface needs to be paired with\\n\n <b>OH_NativeWindow_UnlockAndFlushBuffer</b> for use, after lock, it must be unlocked in order to relock,\\n\n repeatedly lock or unlock will return an illegal operation error code, the interface supports rendering images\\n\n directly through memory read and write on the CPU.\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @param region Indicates the info of the dirty region.\n @param buffer Indicates the pointer to an <b>OHNativeWindowBuffer</b> pointer.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window or buffer is NULL.\n     {@link NATIVE_ERROR_UNKNOWN} 50002000 - surface of window is NULL.\n @since 23\n @version 1.0"]
    #[cfg(feature = "api-23")]
    pub fn OH_NativeWindow_LockBuffer(
        window: *mut OHNativeWindow,
        region: Region,
        buffer: *mut *mut OHNativeWindowBuffer,
    ) -> i32;
}
extern "C" {
    #[doc = " @brief Flushes the <b>OHNativeWindowBuffer</b> filled with the content to the buffer queue through an \\n\n <b>OHNativeWindow</b> instance for content consumption, and unlock the <b>OHNativeWindowBuffer</b>.\n This interface is a non-thread-safe type interface.\\n\n\n @syscap SystemCapability.Graphic.Graphic2D.NativeWindow\n @param window Indicates the pointer to a <b>OHNativeWindow</b> instance.\n @return {@link NATIVE_ERROR_OK} 0 - Success.\n     {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.\n     {@link NATIVE_ERROR_UNKNOWN} 50002000 - surface of window is NULL.\n @since 23\n @version 1.0"]
    #[cfg(feature = "api-23")]
    pub fn OH_NativeWindow_UnlockAndFlushBuffer(window: *mut OHNativeWindow) -> i32;
}