ohos-vsync-sys 0.1.5

Raw Bindings to the vsync (Vertical Synchroization) API of OpenHarmony
Documentation
// 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;
}