objc2_compositor_services/generated/view.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#[cfg(feature = "objc2-metal")]
7use objc2_metal::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view_texture_map?language=objc)
12#[repr(C)]
13#[derive(Debug)]
14pub struct cp_view_texture_map {
15 inner: [u8; 0],
16 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
17}
18
19unsafe impl RefEncode for cp_view_texture_map {
20 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_view_texture_map", &[]));
21}
22
23/// An opaque type that describes the relationship between a
24/// view and the underlying texture.
25///
26/// A texture map helps you locate the content for a specific view within
27/// a texture. Texture maps are especially important when a layer uses a
28/// single texture to manage multiple views. For example, a head-mounted
29/// display might store the images for both the left and right eyes in a
30/// single texture. Pass this type to other functions to get specific details
31/// about the current texture, such as its view bounds or its index into
32/// a texture array.
33///
34/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view_texture_map_t?language=objc)
35pub type cp_view_texture_map_t = *mut cp_view_texture_map;
36
37impl cp_view_texture_map {
38 /// Returns the index of the view’s textures in the drawable.
39 ///
40 /// - Parameters:
41 /// - view_texture_map: The texture map for your view.
42 /// - Returns: The index of the color or depth texture in the drawable.
43 ///
44 /// Pass the returned index to the ``cp_drawable_get_color_texture``
45 /// or ``cp_drawable_get_depth_texture`` function.
46 ///
47 /// # Safety
48 ///
49 /// `view_texture_map` must be a valid pointer.
50 #[doc(alias = "cp_view_texture_map_get_texture_index")]
51 #[inline]
52 pub unsafe fn texture_index(view_texture_map: cp_view_texture_map_t) -> usize {
53 extern "C-unwind" {
54 fn cp_view_texture_map_get_texture_index(
55 view_texture_map: cp_view_texture_map_t,
56 ) -> usize;
57 }
58 unsafe { cp_view_texture_map_get_texture_index(view_texture_map) }
59 }
60
61 /// Returns the index of the view’s texture in an array-based texture type.
62 ///
63 /// - Parameters:
64 /// - view_texture_map: The texture map for your view.
65 /// - Returns: The index of the view’s texture in an array-based texture type.
66 ///
67 /// Use the returned index to retrieve the view’s texture when the texture
68 /// type is
69 /// <doc
70 /// ://com.apple.documentation/documentation/metal/mtltexturetype/type2darray>.
71 /// When configuring your render pass descriptor, specify the index in the
72 /// <doc
73 /// ://com.apple.documentation/documentation/metal/mtlrenderpassattachmentdescriptor/1437914-slice>
74 /// property of the descriptor’s color and depth attachments.
75 ///
76 /// To request an array-based texture from your layer, configure your layer
77 /// with the ``cp_layer_renderer_layout/cp_layer_renderer_layout_dedicated`` layout option.
78 ///
79 /// # Safety
80 ///
81 /// `view_texture_map` must be a valid pointer.
82 #[doc(alias = "cp_view_texture_map_get_slice_index")]
83 #[inline]
84 pub unsafe fn slice_index(view_texture_map: cp_view_texture_map_t) -> usize {
85 extern "C-unwind" {
86 fn cp_view_texture_map_get_slice_index(
87 view_texture_map: cp_view_texture_map_t,
88 ) -> usize;
89 }
90 unsafe { cp_view_texture_map_get_slice_index(view_texture_map) }
91 }
92
93 /// Returns the portion of the texture that the view uses to draw its content.
94 ///
95 /// - Parameters:
96 /// - view_texture_map: The texture map for your view.
97 /// - Returns: A Metal viewport that specifies the view’s size and location
98 /// in the texture.
99 ///
100 /// Call this function to get the size of the view and its location within
101 /// the texture. If the layer dedicates a separate texture to each view,
102 /// the texture bounds and view bounds match. However, if the layer uses a
103 /// shared or layered texture, the view’s location or other slice index
104 /// might differ.
105 ///
106 /// # Safety
107 ///
108 /// `view_texture_map` must be a valid pointer.
109 #[doc(alias = "cp_view_texture_map_get_viewport")]
110 #[cfg(feature = "objc2-metal")]
111 #[inline]
112 pub unsafe fn viewport(view_texture_map: cp_view_texture_map_t) -> MTLViewport {
113 extern "C-unwind" {
114 fn cp_view_texture_map_get_viewport(
115 view_texture_map: cp_view_texture_map_t,
116 ) -> MTLViewport;
117 }
118 unsafe { cp_view_texture_map_get_viewport(view_texture_map) }
119 }
120}
121
122/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view?language=objc)
123#[repr(C)]
124#[derive(Debug)]
125pub struct cp_view {
126 inner: [u8; 0],
127 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
128}
129
130unsafe impl RefEncode for cp_view {
131 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_view", &[]));
132}
133
134/// An opaque type that manages the information for how to render
135/// content into the current frame.
136///
137/// Compositor provides a view for each distinct render viewpoint.
138/// For example, a head-mounted display typically contains two views:
139/// one for each eye. Use the information in the views to set up your
140/// render pass descriptor. For example, use it to determine which
141/// part of a texture to fill with content.
142///
143/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view_t?language=objc)
144pub type cp_view_t = *mut cp_view;
145
146impl cp_view {
147 /// Returns the texture map for this view.
148 ///
149 /// - Parameters:
150 /// - view: The view with the texture map.
151 /// - Returns: The texture map for the layer assigned to this view.
152 ///
153 /// Use the texture map to fetch additional information you need to
154 /// draw your content. For example, use it to fetch the rectangle to
155 /// use for drawing in the associated texture.
156 ///
157 /// # Safety
158 ///
159 /// `view` must be a valid pointer.
160 #[doc(alias = "cp_view_get_view_texture_map")]
161 #[inline]
162 pub unsafe fn view_texture_map(view: cp_view_t) -> cp_view_texture_map_t {
163 extern "C-unwind" {
164 fn cp_view_get_view_texture_map(view: cp_view_t) -> cp_view_texture_map_t;
165 }
166 unsafe { cp_view_get_view_texture_map(view) }
167 }
168}
169
170extern "C-unwind" {
171 #[deprecated = "renamed to `cp_view_texture_map::texture_index`"]
172 pub fn cp_view_texture_map_get_texture_index(view_texture_map: cp_view_texture_map_t) -> usize;
173}
174
175extern "C-unwind" {
176 #[deprecated = "renamed to `cp_view_texture_map::slice_index`"]
177 pub fn cp_view_texture_map_get_slice_index(view_texture_map: cp_view_texture_map_t) -> usize;
178}
179
180extern "C-unwind" {
181 #[cfg(feature = "objc2-metal")]
182 #[deprecated = "renamed to `cp_view_texture_map::viewport`"]
183 pub fn cp_view_texture_map_get_viewport(view_texture_map: cp_view_texture_map_t)
184 -> MTLViewport;
185}
186
187extern "C-unwind" {
188 #[deprecated = "renamed to `cp_view::view_texture_map`"]
189 pub fn cp_view_get_view_texture_map(view: cp_view_t) -> cp_view_texture_map_t;
190}