objc2-compositor-services 0.3.2

Bindings to the CompositorServices framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_frame_timing?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct cp_frame_timing {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

unsafe impl RefEncode for cp_frame_timing {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_frame_timing", &[]));
}

/// An opaque type that stores information about a frame’s
/// encoding, rendering, and presentation deadlines.
///
/// Before you start drawing, call the ``cp_frame_predict_timing``
/// function to update and retrieve the frame’s timing information.
/// After you access the frame’s ``cp_drawable_t`` type, get the
/// timing information using the ``cp_drawable_get_frame_timing`` function.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_frame_timing_t?language=objc)
pub type cp_frame_timing_t = *mut cp_frame_timing;

impl cp_frame_timing {
    /// Returns the optimal time to query the input for a frame.
    ///
    /// - Parameters:
    /// - timing_information: The frame’s timing information. Fetch this
    /// information using the ``cp_frame_predict_timing`` function. If
    /// you already called that function once for the frame, you can call
    /// the ``cp_drawable_get_frame_timing`` function to get the information
    /// instead.
    /// - Returns: The Mach absolute time at which to query the input for your frame.
    ///
    /// The returned value indicates the optimal time for you to query the input
    /// for your frame.
    ///
    /// # Safety
    ///
    /// `frame_timing` must be a valid pointer.
    #[doc(alias = "cp_frame_timing_get_optimal_input_time")]
    #[cfg(feature = "cp_types")]
    #[inline]
    pub unsafe fn optimal_input_time(frame_timing: cp_frame_timing_t) -> cp_time_t {
        extern "C-unwind" {
            fn cp_frame_timing_get_optimal_input_time(frame_timing: cp_frame_timing_t)
                -> cp_time_t;
        }
        unsafe { cp_frame_timing_get_optimal_input_time(frame_timing) }
    }

    /// Returns the time at which you must finish all work for the specified
    /// frame.
    ///
    /// - Parameters:
    /// - timing_information: The frame’s timing information. Fetch this
    /// information using the ``cp_frame_predict_timing`` function. If you
    /// already called that function once for the frame, you can call the
    /// ``cp_drawable_get_frame_timing`` function to get the information
    /// instead.
    /// - Returns: The Mach absolute time at which you must finish all work
    /// for the frame. This value reflects the total presentation time minus
    /// the overhead for the compositor to render your frame and display it
    /// onscreen.
    ///
    /// Finish all CPU and GPU work by the returned time to ensure the timely
    /// display of the frame onscreen.
    ///
    /// # Safety
    ///
    /// `frame_timing` must be a valid pointer.
    #[doc(alias = "cp_frame_timing_get_rendering_deadline")]
    #[cfg(feature = "cp_types")]
    #[inline]
    pub unsafe fn rendering_deadline(frame_timing: cp_frame_timing_t) -> cp_time_t {
        extern "C-unwind" {
            fn cp_frame_timing_get_rendering_deadline(frame_timing: cp_frame_timing_t)
                -> cp_time_t;
        }
        unsafe { cp_frame_timing_get_rendering_deadline(frame_timing) }
    }

    /// Returns the time at which the system will display the frame
    /// onscreen.
    ///
    /// - Parameters:
    /// - timing_information: The frame’s timing information. Fetch
    /// this information using the ``cp_frame_predict_timing`` function.
    /// If you already called that function once for the frame, you
    /// can call the ``cp_drawable_get_frame_timing`` function to get
    /// the information instead.
    /// - Returns: The Mach absolute time at which the layer presents the
    /// frame onscreen.
    ///
    /// You can use the presentation time as a synchronization point for
    /// other parts of your app. For example, you might play a specific
    /// audio clip when the frame appears.
    ///
    /// # Safety
    ///
    /// `frame_timing` must be a valid pointer.
    #[doc(alias = "cp_frame_timing_get_presentation_time")]
    #[cfg(feature = "cp_types")]
    #[inline]
    pub unsafe fn presentation_time(frame_timing: cp_frame_timing_t) -> cp_time_t {
        extern "C-unwind" {
            fn cp_frame_timing_get_presentation_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
        }
        unsafe { cp_frame_timing_get_presentation_time(frame_timing) }
    }

    /// Returns the time to used to predict transform of trackable anchors to provide best
    /// content registration with the frame.
    ///
    /// - Parameters:
    /// - timing_information: The frame’s timing information. Fetch
    /// this information using the ``cp_frame_predict_timing`` function.
    /// If you already called that function once for the frame, you
    /// can call the ``cp_drawable_get_frame_timing`` function to get
    /// the information instead.
    /// - Returns: The Mach absolute time to use to predict transform of a trackable anchor.
    ///
    /// You can use trackable anchor prediction time for prediction of ARKit trackable anchors
    /// to register rendered anchored content to the real-world objects. The offset of this time
    /// to presentation time is variable, so it is recommended to query this per-frame.
    ///
    /// - note: For predicting ARKit device anchor use presentation time, see
    /// ``cp_frame_timing_get_presentation_time``
    ///
    /// # Safety
    ///
    /// `frame_timing` must be a valid pointer.
    #[doc(alias = "cp_frame_timing_get_trackable_anchor_time")]
    #[cfg(feature = "cp_types")]
    #[inline]
    pub unsafe fn trackable_anchor_time(frame_timing: cp_frame_timing_t) -> cp_time_t {
        extern "C-unwind" {
            fn cp_frame_timing_get_trackable_anchor_time(
                frame_timing: cp_frame_timing_t,
            ) -> cp_time_t;
        }
        unsafe { cp_frame_timing_get_trackable_anchor_time(frame_timing) }
    }
}

extern "C-unwind" {
    #[cfg(feature = "cp_types")]
    #[deprecated = "renamed to `cp_frame_timing::optimal_input_time`"]
    pub fn cp_frame_timing_get_optimal_input_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
}

extern "C-unwind" {
    #[cfg(feature = "cp_types")]
    #[deprecated = "renamed to `cp_frame_timing::rendering_deadline`"]
    pub fn cp_frame_timing_get_rendering_deadline(frame_timing: cp_frame_timing_t) -> cp_time_t;
}

extern "C-unwind" {
    #[cfg(feature = "cp_types")]
    #[deprecated = "renamed to `cp_frame_timing::presentation_time`"]
    pub fn cp_frame_timing_get_presentation_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
}

extern "C-unwind" {
    #[cfg(feature = "cp_types")]
    #[deprecated = "renamed to `cp_frame_timing::trackable_anchor_time`"]
    pub fn cp_frame_timing_get_trackable_anchor_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
}