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