-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jonathan Schwender <[email protected]>
- Loading branch information
Showing
10 changed files
with
528 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! Bindings to `native_image` | ||
//! | ||
//! The native image module is used for associating a surface with an OpenGL external texture. | ||
//! It functions as the consumer of a graphics queue. | ||
//! You can use the APIs of this module to obtain and use a buffer, and output the buffer content to an OpenGL external texture. | ||
//! | ||
//! The following scenario is common for native image development: | ||
//! | ||
//! Use the native image APIs to create an OH_NativeImage instance as the consumer and obtain the corresponding OHNativeWindow instance (functioning as the producer). | ||
//! Use the native window APIs to fill in and flush the buffer, and then use the native image APIs to update the buffer content to an OpenGL ES texture. | ||
//! | ||
//! Source: [Official Native Image documentation](https://docs.openharmony.cn/pages/v5.0/en/application-dev/graphics/native-image-guidelines.md) | ||
//! | ||
#[link(name = "EGL")] | ||
#[link(name = "GLESv3")] | ||
#[link(name = "native_image")] | ||
extern "C" {} | ||
|
||
mod native_image_api10; | ||
pub use native_image_api10::*; | ||
|
||
#[cfg(feature = "api-11")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))] | ||
mod api11_additions; | ||
#[cfg(feature = "api-11")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))] | ||
pub use api11_additions::*; | ||
|
||
#[cfg(feature = "api-12")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] | ||
mod api12_additions; | ||
|
||
#[cfg(feature = "api-12")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] | ||
pub use api12_additions::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
|
||
use super::OH_NativeImage; | ||
|
||
/** @brief The callback function of frame available. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param context User defined context, returned to the user in the callback function | ||
@since 11 | ||
@version 1.0*/ | ||
pub type OH_OnFrameAvailable = | ||
::core::option::Option<unsafe extern "C" fn(context: *mut ::core::ffi::c_void)>; | ||
/** @brief A listener for native image, use <b>OH_NativeImage_SetOnFrameAvailableListener</b> to register \n | ||
the listener object to <b>OH_NativeImage</b>, the callback will be triggered when there is available frame | ||
@since 11 | ||
@version 1.0*/ | ||
#[repr(C)] | ||
#[derive(Debug)] | ||
pub struct OH_OnFrameAvailableListener { | ||
/// User defined context, returned to the user in the callback function | ||
pub context: *mut ::core::ffi::c_void, | ||
/// The callback function of frame available. | ||
pub onFrameAvailable: OH_OnFrameAvailable, | ||
} | ||
|
||
extern "C" { | ||
/** @brief Return the native image's surface id. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@param surfaceId Indicates the surface id. | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 11 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_GetSurfaceId(image: *mut OH_NativeImage, surfaceId: *mut u64) -> i32; | ||
/** @brief Set the frame available callback. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@param listener Indicates the callback function. | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 11 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_SetOnFrameAvailableListener( | ||
image: *mut OH_NativeImage, | ||
listener: OH_OnFrameAvailableListener, | ||
) -> i32; | ||
/** @brief Unset the frame available callback. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 11 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_UnsetOnFrameAvailableListener(image: *mut OH_NativeImage) -> i32; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
|
||
use super::OH_NativeImage; | ||
|
||
extern "C" { | ||
/** @brief Obtains the transform matrix of the texture image by producer transform type.\n | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@param matrix Indicates the retrieved 4*4 transform matrix . | ||
@return 0 - Success. | ||
40001000 - image is NULL. | ||
@since 12 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_GetTransformMatrixV2(image: *mut OH_NativeImage, matrix: *mut f32) | ||
-> i32; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* automatically generated by rust-bindgen 0.69.4 */ | ||
|
||
#![allow(non_upper_case_globals)] | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
use crate::native_window::OHNativeWindow; | ||
|
||
#[repr(C)] | ||
pub struct OH_NativeImage { | ||
_unused: [u8; 0], | ||
} | ||
extern "C" { | ||
/** @brief Create a <b>OH_NativeImage</b> related to an Opengl ES texture and target. \n | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param textureId Indicates the id of the Opengl ES texture which the native image attached to. | ||
@param textureTarget Indicates the Opengl ES target. | ||
@return Returns the pointer to the <b>OH_NativeImage</b> instance created if the operation is successful, \n | ||
returns <b>NULL</b> otherwise. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_Create(textureId: u32, textureTarget: u32) -> *mut OH_NativeImage; | ||
/** @brief Acquire the OHNativeWindow for the OH_NativeImage. This OHNativeWindow should be released by \n | ||
OH_NativeWindow_DestroyNativeWindow when no longer needed. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@return Returns the pointer to the OHNativeWindow if the operation is successful, returns <b>NULL</b> otherwise. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_AcquireNativeWindow(image: *mut OH_NativeImage) -> *mut OHNativeWindow; | ||
/** @brief Attach the OH_NativeImage to Opengl ES context, and the Opengl ES texture is bound to the \n | ||
GL_TEXTURE_EXTERNAL_OES, which will update by the OH_NativeImage. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@param textureId Indicates the id of the Opengl ES texture which the native image attached to. | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_AttachContext(image: *mut OH_NativeImage, textureId: u32) -> i32; | ||
/** @brief Detach the OH_NativeImage from the Opengl ES context. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_DetachContext(image: *mut OH_NativeImage) -> i32; | ||
/** @brief Update the related Opengl ES texture with the OH_NativeImage acquired buffer. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_UpdateSurfaceImage(image: *mut OH_NativeImage) -> i32; | ||
/** @brief Get the timestamp of the texture image set by the most recent call to OH_NativeImage_UpdateSurfaceImage. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@return Returns the timestamp associated to the texture image. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_GetTimestamp(image: *mut OH_NativeImage) -> i64; | ||
/** @brief Return the transform matrix of the texture image set by the most recent call to \n | ||
OH_NativeImage_UpdateSurfaceImage. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> instance. | ||
@param matrix Indicates the retrieved 4*4 transform matrix . | ||
@return Returns an error code, 0 is success, otherwise, failed. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_GetTransformMatrix(image: *mut OH_NativeImage, matrix: *mut f32) -> i32; | ||
/** @brief Destroy the <b>OH_NativeImage</b> created by OH_NativeImage_Create, and the pointer to \n | ||
<b>OH_NativeImage</b> will be null after this operation. | ||
@syscap SystemCapability.Graphic.Graphic2D.NativeImage | ||
@param image Indicates the pointer to a <b>OH_NativeImage</b> pointer. | ||
@since 9 | ||
@version 1.0*/ | ||
pub fn OH_NativeImage_Destroy(image: *mut *mut OH_NativeImage); | ||
} |
Oops, something went wrong.