objc2_compositor_services/generated/frame_timing.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_frame_timing?language=objc)
10#[repr(C)]
11#[derive(Debug)]
12pub struct cp_frame_timing {
13 inner: [u8; 0],
14 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
15}
16
17unsafe impl RefEncode for cp_frame_timing {
18 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_frame_timing", &[]));
19}
20
21/// An opaque type that stores information about a frame’s
22/// encoding, rendering, and presentation deadlines.
23///
24/// Before you start drawing, call the ``cp_frame_predict_timing``
25/// function to update and retrieve the frame’s timing information.
26/// After you access the frame’s ``cp_drawable_t`` type, get the
27/// timing information using the ``cp_drawable_get_frame_timing`` function.
28///
29/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_frame_timing_t?language=objc)
30pub type cp_frame_timing_t = *mut cp_frame_timing;
31
32impl cp_frame_timing {
33 /// Returns the optimal time to query the input for a frame.
34 ///
35 /// - Parameters:
36 /// - timing_information: The frame’s timing information. Fetch this
37 /// information using the ``cp_frame_predict_timing`` function. If
38 /// you already called that function once for the frame, you can call
39 /// the ``cp_drawable_get_frame_timing`` function to get the information
40 /// instead.
41 /// - Returns: The Mach absolute time at which to query the input for your frame.
42 ///
43 /// The returned value indicates the optimal time for you to query the input
44 /// for your frame.
45 ///
46 /// # Safety
47 ///
48 /// `frame_timing` must be a valid pointer.
49 #[doc(alias = "cp_frame_timing_get_optimal_input_time")]
50 #[cfg(feature = "cp_types")]
51 #[inline]
52 pub unsafe fn optimal_input_time(frame_timing: cp_frame_timing_t) -> cp_time_t {
53 extern "C-unwind" {
54 fn cp_frame_timing_get_optimal_input_time(frame_timing: cp_frame_timing_t)
55 -> cp_time_t;
56 }
57 unsafe { cp_frame_timing_get_optimal_input_time(frame_timing) }
58 }
59
60 /// Returns the time at which you must finish all work for the specified
61 /// frame.
62 ///
63 /// - Parameters:
64 /// - timing_information: The frame’s timing information. Fetch this
65 /// information using the ``cp_frame_predict_timing`` function. If you
66 /// already called that function once for the frame, you can call the
67 /// ``cp_drawable_get_frame_timing`` function to get the information
68 /// instead.
69 /// - Returns: The Mach absolute time at which you must finish all work
70 /// for the frame. This value reflects the total presentation time minus
71 /// the overhead for the compositor to render your frame and display it
72 /// onscreen.
73 ///
74 /// Finish all CPU and GPU work by the returned time to ensure the timely
75 /// display of the frame onscreen.
76 ///
77 /// # Safety
78 ///
79 /// `frame_timing` must be a valid pointer.
80 #[doc(alias = "cp_frame_timing_get_rendering_deadline")]
81 #[cfg(feature = "cp_types")]
82 #[inline]
83 pub unsafe fn rendering_deadline(frame_timing: cp_frame_timing_t) -> cp_time_t {
84 extern "C-unwind" {
85 fn cp_frame_timing_get_rendering_deadline(frame_timing: cp_frame_timing_t)
86 -> cp_time_t;
87 }
88 unsafe { cp_frame_timing_get_rendering_deadline(frame_timing) }
89 }
90
91 /// Returns the time at which the system will display the frame
92 /// onscreen.
93 ///
94 /// - Parameters:
95 /// - timing_information: The frame’s timing information. Fetch
96 /// this information using the ``cp_frame_predict_timing`` function.
97 /// If you already called that function once for the frame, you
98 /// can call the ``cp_drawable_get_frame_timing`` function to get
99 /// the information instead.
100 /// - Returns: The Mach absolute time at which the layer presents the
101 /// frame onscreen.
102 ///
103 /// You can use the presentation time as a synchronization point for
104 /// other parts of your app. For example, you might play a specific
105 /// audio clip when the frame appears.
106 ///
107 /// # Safety
108 ///
109 /// `frame_timing` must be a valid pointer.
110 #[doc(alias = "cp_frame_timing_get_presentation_time")]
111 #[cfg(feature = "cp_types")]
112 #[inline]
113 pub unsafe fn presentation_time(frame_timing: cp_frame_timing_t) -> cp_time_t {
114 extern "C-unwind" {
115 fn cp_frame_timing_get_presentation_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
116 }
117 unsafe { cp_frame_timing_get_presentation_time(frame_timing) }
118 }
119
120 /// Returns the time to used to predict transform of trackable anchors to provide best
121 /// content registration with the frame.
122 ///
123 /// - Parameters:
124 /// - timing_information: The frame’s timing information. Fetch
125 /// this information using the ``cp_frame_predict_timing`` function.
126 /// If you already called that function once for the frame, you
127 /// can call the ``cp_drawable_get_frame_timing`` function to get
128 /// the information instead.
129 /// - Returns: The Mach absolute time to use to predict transform of a trackable anchor.
130 ///
131 /// You can use trackable anchor prediction time for prediction of ARKit trackable anchors
132 /// to register rendered anchored content to the real-world objects. The offset of this time
133 /// to presentation time is variable, so it is recommended to query this per-frame.
134 ///
135 /// - note: For predicting ARKit device anchor use presentation time, see
136 /// ``cp_frame_timing_get_presentation_time``
137 ///
138 /// # Safety
139 ///
140 /// `frame_timing` must be a valid pointer.
141 #[doc(alias = "cp_frame_timing_get_trackable_anchor_time")]
142 #[cfg(feature = "cp_types")]
143 #[inline]
144 pub unsafe fn trackable_anchor_time(frame_timing: cp_frame_timing_t) -> cp_time_t {
145 extern "C-unwind" {
146 fn cp_frame_timing_get_trackable_anchor_time(
147 frame_timing: cp_frame_timing_t,
148 ) -> cp_time_t;
149 }
150 unsafe { cp_frame_timing_get_trackable_anchor_time(frame_timing) }
151 }
152}
153
154extern "C-unwind" {
155 #[cfg(feature = "cp_types")]
156 #[deprecated = "renamed to `cp_frame_timing::optimal_input_time`"]
157 pub fn cp_frame_timing_get_optimal_input_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
158}
159
160extern "C-unwind" {
161 #[cfg(feature = "cp_types")]
162 #[deprecated = "renamed to `cp_frame_timing::rendering_deadline`"]
163 pub fn cp_frame_timing_get_rendering_deadline(frame_timing: cp_frame_timing_t) -> cp_time_t;
164}
165
166extern "C-unwind" {
167 #[cfg(feature = "cp_types")]
168 #[deprecated = "renamed to `cp_frame_timing::presentation_time`"]
169 pub fn cp_frame_timing_get_presentation_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
170}
171
172extern "C-unwind" {
173 #[cfg(feature = "cp_types")]
174 #[deprecated = "renamed to `cp_frame_timing::trackable_anchor_time`"]
175 pub fn cp_frame_timing_get_trackable_anchor_time(frame_timing: cp_frame_timing_t) -> cp_time_t;
176}