ohos_sys/native_image/native_image_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)]
6use ohos_sys_opaque_types::OHNativeWindow;
7#[cfg(feature = "api-12")]
8use ohos_sys_opaque_types::OHNativeWindowBuffer;
9
10#[repr(C)]
11pub struct OH_NativeImage {
12 _unused: [u8; 0],
13}
14/// The callback function of frame available.
15///
16///
17/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
18/// # Arguments
19///
20/// * `context` - User defined context, returned to the user in the callback function
21///
22/// Available since API-level: 11
23///
24/// Version: 1.0
25#[cfg(feature = "api-11")]
26#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
27pub type OH_OnFrameAvailable =
28 ::core::option::Option<unsafe extern "C" fn(context: *mut ::core::ffi::c_void)>;
29/// A listener for native image, use <b>OH_NativeImage_SetOnFrameAvailableListener</b> to register
30///
31/// the listener object to <b>OH_NativeImage</b>, the callback will be triggered when there is available frame
32///
33///
34/// Available since API-level: 11
35///
36/// Version: 1.0
37#[cfg(feature = "api-11")]
38#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
39#[repr(C)]
40#[derive(Debug)]
41pub struct OH_OnFrameAvailableListener {
42 /// User defined context, returned to the user in the callback function
43 pub context: *mut ::core::ffi::c_void,
44 /// The callback function of frame available.
45 pub onFrameAvailable: OH_OnFrameAvailable,
46}
47extern "C" {
48 /// Create a <b>OH_NativeImage</b> related to an Opengl ES texture and target.
49 ///
50 /// This interface needs to be used in conjunction with <b>OH_NativeImage_Destroy<otherwise memory leaks will occur.
51 ///
52 /// This interface is a non-thread-safe type interface.
53 ///
54 ///
55 ///
56 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
57 /// # Arguments
58 ///
59 /// * `textureId` - Indicates the id of the Opengl ES texture which the native image attached to.
60 ///
61 /// * `textureTarget` - Indicates the Opengl ES target.
62 ///
63 /// # Returns
64 ///
65 /// * Returns the pointer to the <b>OH_NativeImage</b> instance created if the operation is successful,
66 ///
67 /// returns <b>NULL</b> otherwise.
68 ///
69 /// Available since API-level: 9
70 ///
71 /// Version: 1.0
72 pub fn OH_NativeImage_Create(textureId: u32, textureTarget: u32) -> *mut OH_NativeImage;
73 /// Acquire the OHNativeWindow for the OH_NativeImage.
74 ///
75 /// This interface is a non-thread-safe type interface.
76 ///
77 ///
78 ///
79 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
80 /// # Arguments
81 ///
82 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
83 ///
84 /// # Returns
85 ///
86 /// * Returns the pointer to the OHNativeWindow if the operation is successful, returns <b>NULL</b> otherwise.
87 ///
88 /// Available since API-level: 9
89 ///
90 /// Version: 1.0
91 pub fn OH_NativeImage_AcquireNativeWindow(image: *mut OH_NativeImage) -> *mut OHNativeWindow;
92 /// Attach the OH_NativeImage to Opengl ES context, and the Opengl ES texture is bound to the
93 ///
94 /// GL_TEXTURE_EXTERNAL_OES, which will update by the OH_NativeImage.
95 ///
96 /// This interface is a non-thread-safe type interface.
97 ///
98 ///
99 ///
100 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
101 /// # Arguments
102 ///
103 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
104 ///
105 /// * `textureId` - Indicates the id of the Opengl ES texture which the native image attached to.
106 ///
107 /// # Returns
108 ///
109 /// * Returns an error code, 0 is success, otherwise, failed.
110 ///
111 /// Available since API-level: 9
112 ///
113 /// Version: 1.0
114 pub fn OH_NativeImage_AttachContext(image: *mut OH_NativeImage, textureId: u32) -> i32;
115 /// Detach the OH_NativeImage from the Opengl ES context.
116 ///
117 /// This interface is a non-thread-safe type interface.
118 ///
119 ///
120 ///
121 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
122 /// # Arguments
123 ///
124 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
125 ///
126 /// # Returns
127 ///
128 /// * Returns an error code, 0 is success, otherwise, failed.
129 ///
130 /// Available since API-level: 9
131 ///
132 /// Version: 1.0
133 pub fn OH_NativeImage_DetachContext(image: *mut OH_NativeImage) -> i32;
134 /// Update the related Opengl ES texture with the OH_NativeImage acquired buffer.
135 ///
136 /// This interface needs to be called in the Opengl ES context thread.
137 ///
138 /// This interface needs to be called after receiving the <b>OH_OnFrameAvailableListener<callback.
139 ///
140 /// This interface is a non-thread-safe type interface.
141 ///
142 ///
143 ///
144 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
145 /// # Arguments
146 ///
147 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
148 ///
149 /// # Returns
150 ///
151 /// * Returns an error code, 0 is success, otherwise, failed.
152 ///
153 /// Available since API-level: 9
154 ///
155 /// Version: 1.0
156 pub fn OH_NativeImage_UpdateSurfaceImage(image: *mut OH_NativeImage) -> i32;
157 /// Get the timestamp of the texture image set by the most recent call to OH_NativeImage_UpdateSurfaceImage.
158 ///
159 /// This interface is a non-thread-safe type interface.
160 ///
161 ///
162 ///
163 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
164 /// # Arguments
165 ///
166 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
167 ///
168 /// # Returns
169 ///
170 /// * Returns the timestamp associated to the texture image.
171 ///
172 /// Available since API-level: 9
173 ///
174 /// Version: 1.0
175 pub fn OH_NativeImage_GetTimestamp(image: *mut OH_NativeImage) -> i64;
176 /// Return the transform matrix of the texture image set by the most recent call to
177 ///
178 /// OH_NativeImage_UpdateSurfaceImage.
179 ///
180 ///
181 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
182 /// # Arguments
183 ///
184 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
185 ///
186 /// * `matrix` - Indicates the retrieved 4*4 transform matrix .
187 ///
188 /// # Returns
189 ///
190 /// * Returns an error code, 0 is success, otherwise, failed.
191 ///
192 /// Available since API-level: 9
193 ///
194 /// Version: 1.0
195 ///
196 /// **Deprecated** since 12
197 /// OH_NativeImage_GetTransformMatrixV2
198 pub fn OH_NativeImage_GetTransformMatrix(image: *mut OH_NativeImage, matrix: *mut f32) -> i32;
199 /// Return the native image's surface id.
200 ///
201 /// This interface is a non-thread-safe type interface.
202 ///
203 ///
204 ///
205 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
206 /// # Arguments
207 ///
208 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
209 ///
210 /// * `surfaceId` - Indicates the surface id.
211 ///
212 /// # Returns
213 ///
214 /// * Returns an error code, 0 is success, otherwise, failed.
215 ///
216 /// Available since API-level: 11
217 ///
218 /// Version: 1.0
219 #[cfg(feature = "api-11")]
220 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
221 pub fn OH_NativeImage_GetSurfaceId(image: *mut OH_NativeImage, surfaceId: *mut u64) -> i32;
222 /// Set the frame available callback.
223 ///
224 /// Not allow calling other interfaces in the callback function.
225 ///
226 /// This interface is a non-thread-safe type interface.
227 ///
228 ///
229 ///
230 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
231 /// # Arguments
232 ///
233 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
234 ///
235 /// * `listener` - Indicates the callback function.
236 ///
237 /// # Returns
238 ///
239 /// * Returns an error code, 0 is success, otherwise, failed.
240 ///
241 /// Available since API-level: 11
242 ///
243 /// Version: 1.0
244 #[cfg(feature = "api-11")]
245 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
246 pub fn OH_NativeImage_SetOnFrameAvailableListener(
247 image: *mut OH_NativeImage,
248 listener: OH_OnFrameAvailableListener,
249 ) -> i32;
250 /// Unset the frame available callback.
251 ///
252 /// This interface is a non-thread-safe type interface.
253 ///
254 ///
255 ///
256 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
257 /// # Arguments
258 ///
259 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
260 ///
261 /// # Returns
262 ///
263 /// * Returns an error code, 0 is success, otherwise, failed.
264 ///
265 /// Available since API-level: 11
266 ///
267 /// Version: 1.0
268 #[cfg(feature = "api-11")]
269 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
270 pub fn OH_NativeImage_UnsetOnFrameAvailableListener(image: *mut OH_NativeImage) -> i32;
271 /// Destroy the <b>OH_NativeImage</b> created by OH_NativeImage_Create, and the pointer to
272 /// <b>OH_NativeImage</b> will be null after this operation.
273 ///
274 /// This interface is a non-thread-safe type interface.
275 ///
276 ///
277 ///
278 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
279 /// # Arguments
280 ///
281 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> pointer.
282 ///
283 /// Available since API-level: 9
284 ///
285 /// Version: 1.0
286 pub fn OH_NativeImage_Destroy(image: *mut *mut OH_NativeImage);
287 /// Obtains the transform matrix of the texture image by producer transform type.
288 ///
289 /// The matrix will not be update until <b>OH_NativeImage_UpdateSurfaceImage<is called.
290 ///
291 /// This interface is a non-thread-safe type interface.
292 ///
293 ///
294 ///
295 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
296 /// # Arguments
297 ///
298 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
299 ///
300 /// * `matrix` - Indicates the retrieved 4*4 transform matrix .
301 ///
302 /// # Returns
303 ///
304 /// * 0 - Success.
305 /// 40001000 - image is NULL.
306 ///
307 /// Available since API-level: 12
308 ///
309 /// Version: 1.0
310 #[cfg(feature = "api-12")]
311 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
312 pub fn OH_NativeImage_GetTransformMatrixV2(image: *mut OH_NativeImage, matrix: *mut f32)
313 -> i32;
314 /// Acquire an <b>OHNativeWindowBuffer</b> through an <b>OH_NativeImage</b> instance for content consumer.
315 ///
316 /// This method can not be used at the same time with <b>OH_NativeImage_UpdateSurfaceImage</b>.
317 ///
318 /// This method will create an <b>OHNativeWindowBuffer</b>.
319 ///
320 /// When using <b>OHNativeWindowBuffer</b>, need to increase its reference count
321 /// by <b>OH_NativeWindow_NativeObjectReference</b>.
322 ///
323 /// When the <b>OHNativeWindowBuffer</b> is used up, its reference count needs to be decremented
324 /// by <b>OH_NativeWindow_NativeObjectUnreference</b>.
325 ///
326 /// This interface needs to be used in conjunction with <b>OH_NativeImage_ReleaseNativeWindowBuffer<otherwise memory leaks will occur.
327 ///
328 /// When the fenceFd is used up, you need to close it.
329 ///
330 /// This interface is a non-thread-safe type interface.
331 ///
332 ///
333 ///
334 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
335 /// # Arguments
336 ///
337 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
338 ///
339 /// * `nativeWindowBuffer` - Indicates the pointer to an <b>OHNativeWindowBuffer</b> point.
340 ///
341 /// * `fenceFd` - Indicates the pointer to a file descriptor handle.
342 ///
343 /// # Returns
344 ///
345 /// * [`NATIVE_ERROR_OK`] 0 - Success.
346 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - image, nativeWindowBuffer, fenceFd is NULL.
347 /// [`NATIVE_ERROR_NO_BUFFER`] 40601000 - No buffer for consume.
348 ///
349 /// Available since API-level: 12
350 ///
351 /// Version: 1.0
352 #[cfg(feature = "api-12")]
353 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
354 pub fn OH_NativeImage_AcquireNativeWindowBuffer(
355 image: *mut OH_NativeImage,
356 nativeWindowBuffer: *mut *mut OHNativeWindowBuffer,
357 fenceFd: *mut ::core::ffi::c_int,
358 ) -> i32;
359 /// Release the <b>OHNativeWindowBuffer</b> to the buffer queue through an
360 /// <b>OH_NativeImage</b> instance for reuse.
361 ///
362 /// The fenceFd will be close by system.
363 ///
364 /// This interface is a non-thread-safe type interface.
365 ///
366 ///
367 ///
368 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
369 /// # Arguments
370 ///
371 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
372 ///
373 /// * `nativeWindowBuffer` - Indicates the pointer to an <b>OHNativeWindowBuffer</b> instance.
374 ///
375 /// * `fenceFd` - Indicates a file descriptor handle, which is used for timing synchronization.
376 ///
377 /// # Returns
378 ///
379 /// * [`NATIVE_ERROR_OK`] 0 - Success.
380 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - image, nativeWindowBuffer is NULL.
381 /// [`NATIVE_ERROR_BUFFER_STATE_INVALID`] 41207000 - nativeWindowBuffer state invalid.
382 /// [`NATIVE_ERROR_BUFFER_NOT_IN_CACHE`] 41210000 - nativeWindowBuffer not in cache.
383 ///
384 /// Available since API-level: 12
385 ///
386 /// Version: 1.0
387 #[cfg(feature = "api-12")]
388 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
389 pub fn OH_NativeImage_ReleaseNativeWindowBuffer(
390 image: *mut OH_NativeImage,
391 nativeWindowBuffer: *mut OHNativeWindowBuffer,
392 fenceFd: ::core::ffi::c_int,
393 ) -> i32;
394 /// Create a <b>OH_NativeImage</b> as a consumerSurface.
395 ///
396 /// This interface is only used for memory rotation on the surface consumer,
397 /// the <b>OH_NativeImage</b> will not actively perform memory rendering processing.
398 ///
399 /// This method can not be used at the same time with <b>OH_NativeImage_UpdateSurfaceImage</b>.
400 ///
401 /// This interface is used in conjunction with <b>OH_NativeImage_AcquireNativeWindowBuffer<and
402 /// <b>OH_NativeImage_ReleaseNativeWindowBuffer<This interface needs to be used in conjunction with <b>OH_NativeImage_Destroy<otherwise memory leaks will occur.
403 ///
404 /// This interface is a non-thread-safe type interface.
405 ///
406 ///
407 ///
408 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
409 ///
410 /// # Returns
411 ///
412 /// * Returns the pointer to the <b>OH_NativeImage</b> instance created if the operation is successful,
413 ///
414 /// returns <b>NULL</b> otherwise.
415 ///
416 /// Available since API-level: 12
417 ///
418 /// Version: 1.0
419 #[cfg(feature = "api-12")]
420 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
421 pub fn OH_ConsumerSurface_Create() -> *mut OH_NativeImage;
422 /// Set the default usage of the <b>OH_NativeImage</b>.
423 ///
424 /// This interface is a non-thread-safe type interface.
425 ///
426 ///
427 ///
428 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
429 /// # Arguments
430 ///
431 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
432 ///
433 /// * `usage` - Indicates the usage of the <b>OH_NativeImage</b>.Refer to the enum <b>OH_NativeBuffer_Usage</b>.
434 ///
435 /// # Returns
436 ///
437 /// * [`NATIVE_ERROR_OK`] 0 - Success.
438 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - image is NULL.
439 ///
440 /// Available since API-level: 13
441 ///
442 /// Version: 1.0
443 #[cfg(feature = "api-13")]
444 #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
445 pub fn OH_ConsumerSurface_SetDefaultUsage(image: *mut OH_NativeImage, usage: u64) -> i32;
446 /// Set the default size of the <b>OH_NativeImage</b>.
447 ///
448 /// This interface is a non-thread-safe type interface.
449 ///
450 ///
451 ///
452 /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeImage
453 /// # Arguments
454 ///
455 /// * `image` - Indicates the pointer to a <b>OH_NativeImage</b> instance.
456 ///
457 /// * `width` - Indicates the width of the <b>OH_NativeImage</b>, and it should be greater than 0.
458 ///
459 /// * `height` - Indicates the height of the <b>OH_NativeImage</b>, and it should be greater than 0.
460 ///
461 /// # Returns
462 ///
463 /// * [`NATIVE_ERROR_OK`] 0 - Success.
464 /// [`NATIVE_ERROR_INVALID_ARGUMENTS`] 40001000 - image is NULL or width, height less than or equal to 0.
465 ///
466 /// Available since API-level: 13
467 ///
468 /// Version: 1.0
469 #[cfg(feature = "api-13")]
470 #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
471 pub fn OH_ConsumerSurface_SetDefaultSize(
472 image: *mut OH_NativeImage,
473 width: i32,
474 height: i32,
475 ) -> i32;
476}