objc2_compositor_services/generated/layer_renderer_properties.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 core::ptr::NonNull;
6use objc2::__framework_prelude::*;
7#[cfg(feature = "objc2-core-foundation")]
8use objc2_core_foundation::*;
9#[cfg(feature = "objc2-metal")]
10use objc2_metal::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_texture_topology?language=objc)
15#[repr(C)]
16#[derive(Debug)]
17pub struct cp_texture_topology {
18 inner: [u8; 0],
19 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22unsafe impl RefEncode for cp_texture_topology {
23 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_texture_topology", &[]));
24}
25
26/// An opaque type that specifies the configuration of one of the layer’s
27/// drawable textures.
28///
29/// For direct-to-screen drawing, you specify how you want Compositor to
30/// configure the required textures when you configure your layer. For a
31/// device with multiple displays, Compositor can configure the textures
32/// in different ways. For example, it can create a separate texture for
33/// each display, or it can combine the images from multiple displays into
34/// a single texture. A texture topology type contains the details of one
35/// of the textures Compositor creates for your app.
36///
37/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_texture_topology_t?language=objc)
38pub type cp_texture_topology_t = *mut cp_texture_topology;
39
40impl cp_texture_topology {
41 /// Returns the number of items in the texture array.
42 ///
43 /// - Parameters:
44 /// - texture_topology: A texture configuration you obtained from the
45 /// layer's properties. Fetch this value using the
46 /// ``cp_layer_renderer_properties_get_texture_topology`` function.
47 /// - Returns: The number of separate items in the texture array.
48 ///
49 /// Array-based texture types such as
50 /// <doc
51 /// ://com.apple.documentation/documentation/metal/mtltexturetype/type2darray>
52 /// manage one or more images of the same size. This function returns the
53 /// number of separate images the texture manages. Other array types store
54 /// only one image.
55 ///
56 /// # Safety
57 ///
58 /// `texture_topology` must be a valid pointer.
59 #[doc(alias = "cp_texture_topology_get_array_length")]
60 #[inline]
61 pub unsafe fn array_length(texture_topology: cp_texture_topology_t) -> u64 {
62 extern "C-unwind" {
63 fn cp_texture_topology_get_array_length(texture_topology: cp_texture_topology_t)
64 -> u64;
65 }
66 unsafe { cp_texture_topology_get_array_length(texture_topology) }
67 }
68
69 /// Returns the type value that specifies how the underlying texture
70 /// organizes its views.
71 ///
72 /// - Parameters:
73 /// - texture_topology: The texture topology to query. Get the texture
74 /// topology from the layer properties using the
75 /// ``cp_layer_renderer_properties_get_texture_topology`` function.
76 /// - Returns: A Metal value that indicates the arrangement of views
77 /// within the texture.
78 ///
79 /// A texture might store the content of one view or multiple views. For
80 /// example, a single texture might store one or both views for the left
81 /// and right eyes of a head-mounted display. The texture type indicates
82 /// this content organization strategy.
83 ///
84 /// # Safety
85 ///
86 /// `texture_topology` must be a valid pointer.
87 #[doc(alias = "cp_texture_topology_get_texture_type")]
88 #[cfg(feature = "objc2-metal")]
89 #[inline]
90 pub unsafe fn texture_type(texture_topology: cp_texture_topology_t) -> MTLTextureType {
91 extern "C-unwind" {
92 fn cp_texture_topology_get_texture_type(
93 texture_topology: cp_texture_topology_t,
94 ) -> MTLTextureType;
95 }
96 unsafe { cp_texture_topology_get_texture_type(texture_topology) }
97 }
98}
99
100extern_class!(
101 /// An opaque type that describes the organization of the layer's textures
102 /// and the relationships between those textures and the views you use
103 /// for drawing.
104 ///
105 /// You might use the layer's properties to configure other parts of
106 /// your app. For example, use them to configure your app's render pipeline.
107 ///
108 /// You can obtain layer properties directly from your layer. If you don't
109 /// yet have the layer type, you can create an equivalent set of properties
110 /// using the ``cp_layer_renderer_properties_create_using_configuration`` function.
111 ///
112 /// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_object_cp_layer_renderer_properties?language=objc)
113 #[unsafe(super(NSObject))]
114 #[derive(Debug, PartialEq, Eq, Hash)]
115 pub struct CP_OBJECT_cp_layer_renderer_properties;
116);
117
118extern_conformance!(
119 unsafe impl NSObjectProtocol for CP_OBJECT_cp_layer_renderer_properties {}
120);
121
122impl CP_OBJECT_cp_layer_renderer_properties {
123 extern_methods!(
124 #[unsafe(method(init))]
125 #[unsafe(method_family = init)]
126 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
127
128 #[unsafe(method(new))]
129 #[unsafe(method_family = new)]
130 pub unsafe fn new() -> Retained<Self>;
131 );
132}
133
134/// An opaque type that describes the organization of the layer's textures
135/// and the relationships between those textures and the views you use
136/// for drawing.
137///
138/// You might use the layer's properties to configure other parts of
139/// your app. For example, use them to configure your app's render pipeline.
140///
141/// You can obtain layer properties directly from your layer. If you don't
142/// yet have the layer type, you can create an equivalent set of properties
143/// using the ``cp_layer_renderer_properties_create_using_configuration`` function.
144///
145/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_layer_renderer_properties_t?language=objc)
146pub type cp_layer_renderer_properties_t = CP_OBJECT_cp_layer_renderer_properties;
147
148/// Creates a new opaque type to store layer-related properties.
149///
150/// - Parameters:
151/// - configuration: An opaque type that contains the layer’s
152/// configuration details. Compositor uses this information to
153/// configure the properties an equivalent layer would use.
154/// - error: A pointer to an error object. On success, the function sets
155/// this value to `nil`. If an error occurs, this function sets the value
156/// of the pointer to an error object with details about the problem.
157/// The caller is responsible for releasing the returned error object.
158/// - Returns: A new layer properties type with details about how the layer
159/// configures its topologies and texture maps. The function returns `nil`
160/// if an error occurs.
161///
162/// Call this function to create a set of layer properties when you don't
163/// yet have a ``cp_layer_renderer_t`` type. This function generates an equivalent
164/// set of properties for the configuration you provide. You can use those
165/// properties to configure other parts of your app before the layer becomes
166/// available. For example, you might use the information to configure portions
167/// of your app's render pipeline.
168///
169/// # Safety
170///
171/// `error` must be a valid pointer or null.
172#[cfg(all(
173 feature = "layer_renderer_configuration",
174 feature = "objc2-core-foundation"
175))]
176#[inline]
177pub unsafe extern "C-unwind" fn cp_layer_renderer_properties_create_using_configuration(
178 configuration: &cp_layer_renderer_configuration_t,
179 error: *mut *mut CFError,
180) -> Option<Retained<cp_layer_renderer_properties_t>> {
181 extern "C-unwind" {
182 fn cp_layer_renderer_properties_create_using_configuration(
183 configuration: &cp_layer_renderer_configuration_t,
184 error: *mut *mut CFError,
185 ) -> *mut cp_layer_renderer_properties_t;
186 }
187 let ret =
188 unsafe { cp_layer_renderer_properties_create_using_configuration(configuration, error) };
189 unsafe { Retained::from_raw(ret) }
190}
191
192extern "C-unwind" {
193 /// Returns the number of texture topologies available for you to inspect.
194 ///
195 /// - Parameters:
196 /// - layer_properties: The layer properties to query.
197 /// - Returns: The number of texture topologies present in the layer.
198 ///
199 /// The layer’s configuration determines the total number of available
200 /// topologies, and each topology contains details about one texture you
201 /// use for rendering. Fetch the topology details using the
202 /// ``cp_layer_renderer_properties_get_texture_topology`` function.
203 pub fn cp_layer_renderer_properties_get_texture_topology_count(
204 layer_properties: &cp_layer_renderer_properties_t,
205 ) -> usize;
206}
207
208extern "C-unwind" {
209 /// Retrieves the texture topology at the specified index in the
210 /// layer's properties.
211 ///
212 /// - Parameters:
213 /// - layer_properties: The layer properties to query.
214 /// - index: The index into the array of texture configurations.
215 /// This value must be less than the value returned by the
216 /// ``cp_layer_renderer_properties_get_texture_topology`` function.
217 /// - Returns: An opaque type that contains details about the specific
218 /// texture.
219 ///
220 /// Retrieve the topology type and use accessor functions to get details
221 /// of that topology, including its type and array length.
222 /// Use that information to allocate the resources you need to manage
223 /// your content.
224 pub fn cp_layer_renderer_properties_get_texture_topology(
225 layer_properties: &cp_layer_renderer_properties_t,
226 index: usize,
227 ) -> cp_texture_topology_t;
228}
229
230extern "C-unwind" {
231 /// Returns the number of views that will need to be rendered.
232 ///
233 /// - Parameters:
234 /// - layer_properties: The layer properties to query.
235 /// - Returns: The total number of views that need to be support on the drawables.
236 ///
237 /// Should use ``cp_frame_get_drawable_target_view_count`` when
238 /// performing frustum culling to determine how many views specific views each
239 /// drawable target has.
240 ///
241 /// Should use ``cp_drawable_get_view_count`` when drawing to
242 /// determine how many views the specific frame has.
243 pub fn cp_layer_renderer_properties_get_view_count(
244 layer_properties: &cp_layer_renderer_properties_t,
245 ) -> usize;
246}
247
248extern "C-unwind" {
249 /// Returns the max render value for tracking areas' render values.
250 ///
251 /// - Parameters:
252 /// - layer_properties: The layer properties to query.
253 /// - Returns: The max render value for the tracking areas render values.
254 ///
255 /// The layer’s configuration determines the total number of available
256 /// tracking areas. This will be the max render value available, based on
257 /// ``cp_layer_renderer_configuration_get_tracking_areas_format`` function.
258 #[cfg(feature = "tracking_area")]
259 pub fn cp_layer_renderer_properties_get_tracking_areas_max_value(
260 properties: &cp_layer_renderer_properties_t,
261 ) -> cp_tracking_area_render_value;
262}
263
264extern "C-unwind" {
265 #[deprecated = "renamed to `cp_texture_topology::array_length`"]
266 pub fn cp_texture_topology_get_array_length(texture_topology: cp_texture_topology_t) -> u64;
267}
268
269extern "C-unwind" {
270 #[cfg(feature = "objc2-metal")]
271 #[deprecated = "renamed to `cp_texture_topology::texture_type`"]
272 pub fn cp_texture_topology_get_texture_type(
273 texture_topology: cp_texture_topology_t,
274 ) -> MTLTextureType;
275}