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
// automatically generated by rust-bindgen 0.71.1
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#[repr(C)]
pub struct OH_NativeVSync {
_unused: [u8; 0],
}
pub type OH_NativeVSync_FrameCallback = ::core::option::Option<
unsafe extern "C" fn(timestamp: ::core::ffi::c_longlong, data: *mut ::core::ffi::c_void),
>;
/// Defines the expected frame rate range struct.
///
///
/// Available since API-level: 20
///
/// Version: 1.0
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OH_NativeVSync_ExpectedRateRange {
/// The minimum frame rate of dynamical callback rate range.
pub min: i32,
/// The maximum frame rate of dynamical callback rate range.
pub max: i32,
/// The expected frame rate of dynamical callback rate range.
pub expected: i32,
}
extern "C" {
/// Creates a <b>NativeVsync</b> instance.
///
/// A new <b>NativeVsync</b> instance is created each time this function is called.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `name` - Indicates the vsync connection name.
///
/// * `length` - Indicates the name's length.
///
/// # Returns
///
/// * Returns the pointer to the <b>NativeVsync</b> instance created.
///
/// Available since API-level: 9
///
/// Version: 1.0
pub fn OH_NativeVSync_Create(
name: *const ::core::ffi::c_char,
length: ::core::ffi::c_uint,
) -> *mut OH_NativeVSync;
/// Destroys an <b>OH_NativeVSync</b> instance.
/// Once the <b>OH_NativeVSync</b> pointer is destroyed, it must not be used to prevent dangling pointer problems.
/// Pay special attention to the management of the <b>OH_NativeVSync</b> pointer in concurrent multithreaded scenarios.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `nativeVsync` - Pointer to an <b>OH_NativeVSync</b> instance.
///
/// Available since API-level: 9
///
/// Version: 1.0
pub fn OH_NativeVSync_Destroy(nativeVsync: *mut OH_NativeVSync);
/// Creates a <b>NativeVsync</b> instance.
///
/// A new <b>NativeVsync</b> instance is created each time this function is called.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `windowID` - Indicates the id of the associated window.
///
/// * `name` - Indicates the vsync connection name.
///
/// * `length` - Indicates the name's length.
///
/// # Returns
///
/// * Returns the pointer to the <b>NativeVsync</b> instance created.
///
/// Available since API-level: 14
///
/// Version: 1.0
#[cfg(feature = "api-14")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-14")))]
pub fn OH_NativeVSync_Create_ForAssociatedWindow(
windowID: u64,
name: *const ::core::ffi::c_char,
length: ::core::ffi::c_uint,
) -> *mut OH_NativeVSync;
/// Request next vsync with callback.
/// If you call this interface multiple times in one frame, it will only call the last callback.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `nativeVsync` - Indicates the pointer to a NativeVsync.
///
/// * `callback` - Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming.
///
/// * `data` - Indicates data which will be used in callback.
///
/// # Returns
///
/// * [`NATIVE_ERROR_OK`] 0 - Success.
/// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL or callback is NULL.
/// [`NATIVE_ERROR_BINDER_ERROR`] 50401000 - ipc send failed.
///
/// Available since API-level: 9
///
/// Version: 1.0
pub fn OH_NativeVSync_RequestFrame(
nativeVsync: *mut OH_NativeVSync,
callback: OH_NativeVSync_FrameCallback,
data: *mut ::core::ffi::c_void,
) -> ::core::ffi::c_int;
/// Request next vsync with callback.
/// If this function is called multiple times in one vsync period, all these callbacks and dataset will be called.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `nativeVsync` - Indicates the pointer to a NativeVsync.
///
/// * `callback` - Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming.
///
/// * `data` - Indicates data which will be used in callback.
///
/// # Returns
///
/// * [`NATIVE_ERROR_OK`] 0 - Success.
/// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL or callback is NULL.
/// [`NATIVE_ERROR_BINDER_ERROR`] 50401000 - ipc send failed.
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_NativeVSync_RequestFrameWithMultiCallback(
nativeVsync: *mut OH_NativeVSync,
callback: OH_NativeVSync_FrameCallback,
data: *mut ::core::ffi::c_void,
) -> ::core::ffi::c_int;
/// Obtains the VSync period.
/// The VSync period is refreshed only when the <b>OH_NativeVSync_FrameCallback</b> callback is received
/// following a request for a VSync signal via <b>OH_NativeVSync_RequestFrame</b>.
/// To obtain the VSync period for the first time using this function,
/// you need to call <b>OH_NativeVSync_RequestFrame</b> to request a VSync signal.
/// Once the <b>OH_NativeVSync_FrameCallback</b> callback is received, the vsync period can be obtained.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `nativeVsync` - Indicates the pointer to a NativeVsync.
///
/// * `period` - Indicates the vsync period.
///
/// # Returns
///
/// * Returns int32_t, return value == 0, success, otherwise, failed.
///
/// Available since API-level: 10
///
/// Version: 1.0
pub fn OH_NativeVSync_GetPeriod(
nativeVsync: *mut OH_NativeVSync,
period: *mut ::core::ffi::c_longlong,
) -> ::core::ffi::c_int;
/// Enables DVSync to improve the smoothness of self-drawing animations.
/// DVSync, short for Decoupled VSync, is a frame timing management policy that is decoupled from the hardware's VSync.
/// DVSync drives the early rendering of upcoming animation frames by sending VSync signals with future timestamps.
/// These frames are stored in a frame buffer queue. This helps DVSync reduce potential frame drop and therefore
/// enhances the smoothness of animations.
/// DVSync requires free self-drawing frame buffers to store these pre-rendered animation frames.
/// Therefore, you must ensure that at least one free frame buffer is available. Otherwise, do not enable DVSync.
/// After DVSync is enabled, you must correctly respond to the early VSync signals and request the subsequent VSync
/// after the animation frame associated with the previous VSync is complete. In addition, the self-drawing frames must
/// carry timestamps that align with VSync.
/// After the animation ends, disable DVSync.
/// Only phones and tablets support DVSync.
/// On a platform that does not support DVSync or if another application has enabled DVSync, the attempt to enable it
/// will not take effect, and the application still receives normal VSync signals.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `nativeVsync` - Indicates the pointer to a NativeVsync.
///
/// * `enable` - Whether to enable DVSync.The value true means to enable DVSync, and false means the opposite.
///
/// # Returns
///
/// * [`NATIVE_ERROR_OK`] 0 - Success.
/// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL.
/// [`NATIVE_ERROR_BINDER_ERROR`] 50401000 - ipc send failed.
///
/// Available since API-level: 14
///
/// Version: 1.0
#[cfg(feature = "api-14")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-14")))]
pub fn OH_NativeVSync_DVSyncSwitch(
nativeVsync: *mut OH_NativeVSync,
enable: bool,
) -> ::core::ffi::c_int;
/// Set vsync expected frame rate range.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
/// # Arguments
///
/// * `nativeVsync` - Indicates the pointer to a NativeVsync.
///
/// * `range` - Indicates the pointer to an expected rate range.
///
/// # Returns
///
/// * [`NATIVE_ERROR_OK`] 0 - Success.
/// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL or range is NULL or Invalid.
///
/// Available since API-level: 20
///
/// Version: 1.0
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
pub fn OH_NativeVSync_SetExpectedFrameRateRange(
nativeVsync: *mut OH_NativeVSync,
range: *mut OH_NativeVSync_ExpectedRateRange,
) -> ::core::ffi::c_int;
}