ohos_vsync_sys/vsync_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6
7#[repr(C)]
8pub struct OH_NativeVSync {
9 _unused: [u8; 0],
10}
11pub type OH_NativeVSync_FrameCallback = ::core::option::Option<
12 unsafe extern "C" fn(timestamp: ::core::ffi::c_longlong, data: *mut ::core::ffi::c_void),
13>;
14/// Defines the expected frame rate range struct.
15///
16///
17/// Available since API-level: 20
18///
19/// Version: 1.0
20#[cfg(feature = "api-20")]
21#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
22#[repr(C)]
23#[derive(Debug, Copy, Clone)]
24pub struct OH_NativeVSync_ExpectedRateRange {
25 /// The minimum frame rate of dynamical callback rate range.
26 pub min: i32,
27 /// The maximum frame rate of dynamical callback rate range.
28 pub max: i32,
29 /// The expected frame rate of dynamical callback rate range.
30 pub expected: i32,
31}
32extern "C" {
33 /// Creates a <b>NativeVsync</b> instance.
34 ///
35 /// A new <b>NativeVsync</b> instance is created each time this function is called.
36 ///
37 ///
38 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
39 /// # Arguments
40 ///
41 /// * `name` - Indicates the vsync connection name.
42 ///
43 /// * `length` - Indicates the name's length.
44 ///
45 /// # Returns
46 ///
47 /// * Returns the pointer to the <b>NativeVsync</b> instance created.
48 ///
49 /// Available since API-level: 9
50 ///
51 /// Version: 1.0
52 pub fn OH_NativeVSync_Create(
53 name: *const ::core::ffi::c_char,
54 length: ::core::ffi::c_uint,
55 ) -> *mut OH_NativeVSync;
56 /// Destroys an <b>OH_NativeVSync</b> instance.
57 /// Once the <b>OH_NativeVSync</b> pointer is destroyed, it must not be used to prevent dangling pointer problems.
58 /// Pay special attention to the management of the <b>OH_NativeVSync</b> pointer in concurrent multithreaded scenarios.
59 ///
60 ///
61 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
62 /// # Arguments
63 ///
64 /// * `nativeVsync` - Pointer to an <b>OH_NativeVSync</b> instance.
65 ///
66 /// Available since API-level: 9
67 ///
68 /// Version: 1.0
69 pub fn OH_NativeVSync_Destroy(nativeVsync: *mut OH_NativeVSync);
70 /// Creates a <b>NativeVsync</b> instance.
71 ///
72 /// A new <b>NativeVsync</b> instance is created each time this function is called.
73 ///
74 ///
75 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
76 /// # Arguments
77 ///
78 /// * `windowID` - Indicates the id of the associated window.
79 ///
80 /// * `name` - Indicates the vsync connection name.
81 ///
82 /// * `length` - Indicates the name's length.
83 ///
84 /// # Returns
85 ///
86 /// * Returns the pointer to the <b>NativeVsync</b> instance created.
87 ///
88 /// Available since API-level: 14
89 ///
90 /// Version: 1.0
91 #[cfg(feature = "api-14")]
92 #[cfg_attr(docsrs, doc(cfg(feature = "api-14")))]
93 pub fn OH_NativeVSync_Create_ForAssociatedWindow(
94 windowID: u64,
95 name: *const ::core::ffi::c_char,
96 length: ::core::ffi::c_uint,
97 ) -> *mut OH_NativeVSync;
98 /// Request next vsync with callback.
99 /// If you call this interface multiple times in one frame, it will only call the last callback.
100 ///
101 ///
102 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
103 /// # Arguments
104 ///
105 /// * `nativeVsync` - Indicates the pointer to a NativeVsync.
106 ///
107 /// * `callback` - Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming.
108 ///
109 /// * `data` - Indicates data which will be used in callback.
110 ///
111 /// # Returns
112 ///
113 /// * [`NATIVE_ERROR_OK`] 0 - Success.
114 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL or callback is NULL.
115 /// [`NATIVE_ERROR_BINDER_ERROR`] 50401000 - ipc send failed.
116 ///
117 /// Available since API-level: 9
118 ///
119 /// Version: 1.0
120 pub fn OH_NativeVSync_RequestFrame(
121 nativeVsync: *mut OH_NativeVSync,
122 callback: OH_NativeVSync_FrameCallback,
123 data: *mut ::core::ffi::c_void,
124 ) -> ::core::ffi::c_int;
125 /// Request next vsync with callback.
126 /// If this function is called multiple times in one vsync period, all these callbacks and dataset will be called.
127 ///
128 ///
129 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
130 /// # Arguments
131 ///
132 /// * `nativeVsync` - Indicates the pointer to a NativeVsync.
133 ///
134 /// * `callback` - Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming.
135 ///
136 /// * `data` - Indicates data which will be used in callback.
137 ///
138 /// # Returns
139 ///
140 /// * [`NATIVE_ERROR_OK`] 0 - Success.
141 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL or callback is NULL.
142 /// [`NATIVE_ERROR_BINDER_ERROR`] 50401000 - ipc send failed.
143 ///
144 /// Available since API-level: 12
145 ///
146 /// Version: 1.0
147 #[cfg(feature = "api-12")]
148 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
149 pub fn OH_NativeVSync_RequestFrameWithMultiCallback(
150 nativeVsync: *mut OH_NativeVSync,
151 callback: OH_NativeVSync_FrameCallback,
152 data: *mut ::core::ffi::c_void,
153 ) -> ::core::ffi::c_int;
154 /// Obtains the VSync period.
155 /// The VSync period is refreshed only when the <b>OH_NativeVSync_FrameCallback</b> callback is received
156 /// following a request for a VSync signal via <b>OH_NativeVSync_RequestFrame</b>.
157 /// To obtain the VSync period for the first time using this function,
158 /// you need to call <b>OH_NativeVSync_RequestFrame</b> to request a VSync signal.
159 /// Once the <b>OH_NativeVSync_FrameCallback</b> callback is received, the vsync period can be obtained.
160 ///
161 ///
162 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
163 /// # Arguments
164 ///
165 /// * `nativeVsync` - Indicates the pointer to a NativeVsync.
166 ///
167 /// * `period` - Indicates the vsync period.
168 ///
169 /// # Returns
170 ///
171 /// * Returns int32_t, return value == 0, success, otherwise, failed.
172 ///
173 /// Available since API-level: 10
174 ///
175 /// Version: 1.0
176 pub fn OH_NativeVSync_GetPeriod(
177 nativeVsync: *mut OH_NativeVSync,
178 period: *mut ::core::ffi::c_longlong,
179 ) -> ::core::ffi::c_int;
180 /// Enables DVSync to improve the smoothness of self-drawing animations.
181 /// DVSync, short for Decoupled VSync, is a frame timing management policy that is decoupled from the hardware's VSync.
182 /// DVSync drives the early rendering of upcoming animation frames by sending VSync signals with future timestamps.
183 /// These frames are stored in a frame buffer queue. This helps DVSync reduce potential frame drop and therefore
184 /// enhances the smoothness of animations.
185 /// DVSync requires free self-drawing frame buffers to store these pre-rendered animation frames.
186 /// Therefore, you must ensure that at least one free frame buffer is available. Otherwise, do not enable DVSync.
187 /// After DVSync is enabled, you must correctly respond to the early VSync signals and request the subsequent VSync
188 /// after the animation frame associated with the previous VSync is complete. In addition, the self-drawing frames must
189 /// carry timestamps that align with VSync.
190 /// After the animation ends, disable DVSync.
191 /// Only phones and tablets support DVSync.
192 /// On a platform that does not support DVSync or if another application has enabled DVSync, the attempt to enable it
193 /// will not take effect, and the application still receives normal VSync signals.
194 ///
195 ///
196 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
197 /// # Arguments
198 ///
199 /// * `nativeVsync` - Indicates the pointer to a NativeVsync.
200 ///
201 /// * `enable` - Whether to enable DVSync.The value true means to enable DVSync, and false means the opposite.
202 ///
203 /// # Returns
204 ///
205 /// * [`NATIVE_ERROR_OK`] 0 - Success.
206 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL.
207 /// [`NATIVE_ERROR_BINDER_ERROR`] 50401000 - ipc send failed.
208 ///
209 /// Available since API-level: 14
210 ///
211 /// Version: 1.0
212 #[cfg(feature = "api-14")]
213 #[cfg_attr(docsrs, doc(cfg(feature = "api-14")))]
214 pub fn OH_NativeVSync_DVSyncSwitch(
215 nativeVsync: *mut OH_NativeVSync,
216 enable: bool,
217 ) -> ::core::ffi::c_int;
218 /// Set vsync expected frame rate range.
219 ///
220 ///
221 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeVsync
222 /// # Arguments
223 ///
224 /// * `nativeVsync` - Indicates the pointer to a NativeVsync.
225 ///
226 /// * `range` - Indicates the pointer to an expected rate range.
227 ///
228 /// # Returns
229 ///
230 /// * [`NATIVE_ERROR_OK`] 0 - Success.
231 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - the parameter nativeVsync is NULL or range is NULL or Invalid.
232 ///
233 /// Available since API-level: 20
234 ///
235 /// Version: 1.0
236 #[cfg(feature = "api-20")]
237 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
238 pub fn OH_NativeVSync_SetExpectedFrameRateRange(
239 nativeVsync: *mut OH_NativeVSync,
240 range: *mut OH_NativeVSync_ExpectedRateRange,
241 ) -> ::core::ffi::c_int;
242}