objc2_compositor_services/generated/
frame.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use objc2::__framework_prelude::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_frame?language=objc)
11#[repr(C)]
12#[derive(Debug)]
13pub struct cp_frame {
14    inner: [u8; 0],
15    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
16}
17
18unsafe impl RefEncode for cp_frame {
19    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_frame", &[]));
20}
21
22/// An opaque type that provides access to the timing information and
23/// data types you need to render a single frame of content.
24///
25/// During each cycle of your app’s rendering loop, retrieve a frame
26/// using the ``cp_layer_renderer_query_next_frame`` function and use it to
27/// render your app’s content. The ``cp_frame_t`` type provides access
28/// to the information you need to render your frame in a timely manner.
29/// It also provides access to the ``cp_drawable_t`` type you use to
30/// retrieve the textures you need for drawing.
31///
32/// Separate the work you do for each frame into two phases: the update
33/// phase and the encode phase. Use the update phase to perform app-specific
34/// tasks, such as processing interactions with your content. Use the
35/// encode phase to commit the Metal commands you need to draw your
36/// content for the current pose. For both phases, use frame functions
37/// to notify the Compositor when you start and stop the related work.
38/// For example, surround update work with calls to the
39/// ``cp_frame_start_update`` and ``cp_frame_end_update``
40/// functions.
41///
42/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_frame_t?language=objc)
43pub type cp_frame_t = *mut cp_frame;
44
45impl cp_frame {
46    /// Returns the sequential index number of the specified frame.
47    ///
48    /// - Parameters:
49    /// - frame: The frame to query.
50    /// - Returns: The sequential index of the frame, which is always a
51    /// positive integer.
52    ///
53    /// The layer assigns a unique index number to each frame, starting at
54    /// the first frame and incrementing the index by 1 for each new frame.
55    #[doc(alias = "cp_frame_get_frame_index")]
56    #[cfg(feature = "cp_types")]
57    #[inline]
58    pub unsafe fn frame_index(frame: cp_frame_t) -> cp_layer_frame_index_t {
59        extern "C-unwind" {
60            fn cp_frame_get_frame_index(frame: cp_frame_t) -> cp_layer_frame_index_t;
61        }
62        unsafe { cp_frame_get_frame_index(frame) }
63    }
64
65    /// Computes and returns the predicted timing information for the specified frame.
66    ///
67    /// - Parameters:
68    /// - frame: The frame you're preparing to draw.
69    /// - Returns: The predicted timing information for the specified frame, or `NULL`
70    /// if the layer is in the ``cp_layer_renderer/cp_layer_renderer_state_paused`` or
71    /// ``cp_layer_renderer/cp_layer_renderer_state_invalidated`` state.
72    ///
73    /// Use the returned timing information in any functions that return
74    /// frame-related deadlines. For example, pass the timing information
75    /// to the ``cp_frame_timing_get_optimal_input_time`` function to
76    /// determine when to start encoding the frame. This function updates
77    /// the frame-specific timing information using the latest data from
78    /// the compositor before it returns it.
79    ///
80    /// Don’t call this function after you call ``cp_frame_query_drawable``
81    /// for the specified frame. If you need the timing information after you
82    /// retrieve the frame's ``cp_drawable_t`` type, save the return value
83    /// of this function, or call ``cp_drawable_get_frame_timing`` to get
84    /// the information from the drawable instead.
85    #[doc(alias = "cp_frame_predict_timing")]
86    #[cfg(feature = "frame_timing")]
87    #[inline]
88    pub unsafe fn predict_timing(frame: cp_frame_t) -> cp_frame_timing_t {
89        extern "C-unwind" {
90            fn cp_frame_predict_timing(frame: cp_frame_t) -> cp_frame_timing_t;
91        }
92        unsafe { cp_frame_predict_timing(frame) }
93    }
94
95    /// Returns the drawable type you use to retrieve the textures and
96    /// drawing environment for the frame.
97    ///
98    /// - Parameters:
99    /// - frame: The frame to query.
100    /// - Returns: The drawable type, or `NULL` if the layer is in the
101    /// ``cp_layer_renderer/cp_layer_renderer_state_paused`` or
102    /// ``cp_layer_renderer/cp_layer_renderer_state_invalidated`` state.
103    ///
104    /// Call this function when you're ready to encode the drawing commands
105    /// for the frame. The ``cp_drawable_t`` type contains the textures and
106    /// other information you need to set up your render descriptor in Metal.
107    ///
108    /// Note: This function isn't safe to be called concurrently. Always ensure a
109    /// single thread call this function at a time.
110    #[doc(alias = "cp_frame_query_drawable")]
111    #[cfg(feature = "drawable")]
112    #[inline]
113    pub unsafe fn query_drawable(frame: cp_frame_t) -> cp_drawable_t {
114        extern "C-unwind" {
115            fn cp_frame_query_drawable(frame: cp_frame_t) -> cp_drawable_t;
116        }
117        unsafe { cp_frame_query_drawable(frame) }
118    }
119
120    /// Notifies the compositor that you started updating the app-specific
121    /// content you need to render the frame.
122    ///
123    /// - Parameters:
124    /// - frame: The frame you are ready to prepare.
125    ///
126    /// This function helps you optimize your app’s rendering efficiency.
127    /// Before you render a frame, you might need to respond to
128    /// interactions and update your app's data structures before you can
129    /// render items in your scene.  Call this function immediately
130    /// before you start that work, and call the ``cp_frame_end_update``
131    /// function as soon as you finish. The compositor uses the time difference
132    /// to improve its predictions for when to start the frame encoding process.
133    ///
134    /// Move as much work as possible into the update phase to minimize encoding
135    /// time. Don't do any work that relies on the current pose information during
136    /// the update phase. Instead, make any pose-related changes during the
137    /// encoding phase.
138    #[doc(alias = "cp_frame_start_update")]
139    #[inline]
140    pub unsafe fn start_update(frame: cp_frame_t) {
141        extern "C-unwind" {
142            fn cp_frame_start_update(frame: cp_frame_t);
143        }
144        unsafe { cp_frame_start_update(frame) }
145    }
146
147    /// Notifies the compositor that you finished updating the app-specific
148    /// content you need to render the frame.
149    ///
150    /// - Parameters:
151    /// - frame: The frame you finished preparing.
152    ///
153    /// This function helps you optimize your app’s rendering efficiency.
154    /// Before you render a frame, you might need to respond to
155    /// interactions and update your app's data structures before you can
156    /// render items in your scene. Call the ``cp_frame_start_update``
157    /// function immediately before you start that work, and call this function
158    /// as soon as you finish. Compositor uses the frame update time to improve
159    /// its predictions for when to start the frame encoding process.
160    ///
161    /// Move as much work as possible into the update phase to minimize encoding
162    /// time. Don't do any work that relies on the current pose information during
163    /// the update phase. Instead, make any pose-related changes during the
164    /// encoding phase.
165    #[doc(alias = "cp_frame_end_update")]
166    #[inline]
167    pub unsafe fn end_update(frame: cp_frame_t) {
168        extern "C-unwind" {
169            fn cp_frame_end_update(frame: cp_frame_t);
170        }
171        unsafe { cp_frame_end_update(frame) }
172    }
173
174    /// Notifies the compositor that you're ready to generate the
175    /// GPU commands to render the specified frame.
176    ///
177    /// - Parameters:
178    /// - frame: The frame you're ready to encode and send to the GPU.
179    ///
180    /// This function helps you optimize your app’s rendering efficiency.
181    /// Call this function function before you start any of the GPU work that depends
182    /// on the input data. Call the ``cp_frame_end_submission`` function after
183    /// you finish your drawing commands and are ready to commit the frame to
184    /// the GPU. Compositor uses the time difference to improve its predictions
185    /// for when to start the frame submission process. Those predictions help
186    /// you schedule the encoding process at a more optimal time for the
187    /// system.
188    #[doc(alias = "cp_frame_start_submission")]
189    #[inline]
190    pub unsafe fn start_submission(frame: cp_frame_t) {
191        extern "C-unwind" {
192            fn cp_frame_start_submission(frame: cp_frame_t);
193        }
194        unsafe { cp_frame_start_submission(frame) }
195    }
196
197    /// Notifies the compositor that you finished generating the GPU
198    /// commands to render the specified frame.
199    ///
200    /// - Parameters:
201    /// - frame: The frame you're ready to submit to the GPU.
202    ///
203    /// This function helps you optimize your app’s rendering efficiency.
204    /// Call the ``cp_frame_start_submission`` function before you start any of the GPU
205    /// work that depends on the input data. Call this function after
206    /// you finish your drawing commands and are ready to commit the frame to
207    /// the GPU. Compositor uses the time difference to improve its predictions
208    /// for when to start the frame submission process. Those predictions help
209    /// you schedule the encoding process at a more optimal time for the
210    /// system.
211    #[doc(alias = "cp_frame_end_submission")]
212    #[inline]
213    pub unsafe fn end_submission(frame: cp_frame_t) {
214        extern "C-unwind" {
215            fn cp_frame_end_submission(frame: cp_frame_t);
216        }
217        unsafe { cp_frame_end_submission(frame) }
218    }
219}
220
221extern "C-unwind" {
222    #[cfg(feature = "cp_types")]
223    #[deprecated = "renamed to `cp_frame::frame_index`"]
224    pub fn cp_frame_get_frame_index(frame: cp_frame_t) -> cp_layer_frame_index_t;
225}
226
227extern "C-unwind" {
228    #[cfg(feature = "frame_timing")]
229    #[deprecated = "renamed to `cp_frame::predict_timing`"]
230    pub fn cp_frame_predict_timing(frame: cp_frame_t) -> cp_frame_timing_t;
231}
232
233extern "C-unwind" {
234    #[cfg(feature = "drawable")]
235    #[deprecated = "renamed to `cp_frame::query_drawable`"]
236    pub fn cp_frame_query_drawable(frame: cp_frame_t) -> cp_drawable_t;
237}
238
239extern "C-unwind" {
240    #[deprecated = "renamed to `cp_frame::start_update`"]
241    pub fn cp_frame_start_update(frame: cp_frame_t);
242}
243
244extern "C-unwind" {
245    #[deprecated = "renamed to `cp_frame::end_update`"]
246    pub fn cp_frame_end_update(frame: cp_frame_t);
247}
248
249extern "C-unwind" {
250    #[deprecated = "renamed to `cp_frame::start_submission`"]
251    pub fn cp_frame_start_submission(frame: cp_frame_t);
252}
253
254extern "C-unwind" {
255    #[deprecated = "renamed to `cp_frame::end_submission`"]
256    pub fn cp_frame_end_submission(frame: cp_frame_t);
257}