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 #[doc(alias = "cp_view_texture_map_get_texture_index")]
47 #[inline]
48 pub unsafe fn texture_index(view_texture_map: cp_view_texture_map_t) -> usize {
49 extern "C-unwind" {
50 fn cp_view_texture_map_get_texture_index(
51 view_texture_map: cp_view_texture_map_t,
52 ) -> usize;
53 }
54 unsafe { cp_view_texture_map_get_texture_index(view_texture_map) }
55 }
56
57 /// Returns the index of the view’s texture in an array-based texture type.
58 ///
59 /// - Parameters:
60 /// - view_texture_map: The texture map for your view.
61 /// - Returns: The index of the view’s texture in an array-based texture type.
62 ///
63 /// Use the returned index to retrieve the view’s texture when the texture
64 /// type is
65 /// <doc
66 /// ://com.apple.documentation/documentation/metal/mtltexturetype/type2darray>.
67 /// When configuring your render pass descriptor, specify the index in the
68 /// <doc
69 /// ://com.apple.documentation/documentation/metal/mtlrenderpassattachmentdescriptor/1437914-slice>
70 /// property of the descriptor’s color and depth attachments.
71 ///
72 /// To request an array-based texture from your layer, configure your layer
73 /// with the ``cp_layer_renderer_layout/cp_layer_renderer_layout_dedicated`` layout option.
74 #[doc(alias = "cp_view_texture_map_get_slice_index")]
75 #[inline]
76 pub unsafe fn slice_index(view_texture_map: cp_view_texture_map_t) -> usize {
77 extern "C-unwind" {
78 fn cp_view_texture_map_get_slice_index(
79 view_texture_map: cp_view_texture_map_t,
80 ) -> usize;
81 }
82 unsafe { cp_view_texture_map_get_slice_index(view_texture_map) }
83 }
84
85 /// Returns the portion of the texture that the view uses to draw its content.
86 ///
87 /// - Parameters:
88 /// - view_texture_map: The texture map for your view.
89 /// - Returns: A Metal viewport that specifies the view’s size and location
90 /// in the texture.
91 ///
92 /// Call this function to get the size of the view and its location within
93 /// the texture. If the layer dedicates a separate texture to each view,
94 /// the texture bounds and view bounds match. However, if the layer uses a
95 /// shared or layered texture, the view’s location or other slice index
96 /// might differ.
97 #[doc(alias = "cp_view_texture_map_get_viewport")]
98 #[cfg(feature = "objc2-metal")]
99 #[inline]
100 pub unsafe fn viewport(view_texture_map: cp_view_texture_map_t) -> MTLViewport {
101 extern "C-unwind" {
102 fn cp_view_texture_map_get_viewport(
103 view_texture_map: cp_view_texture_map_t,
104 ) -> MTLViewport;
105 }
106 unsafe { cp_view_texture_map_get_viewport(view_texture_map) }
107 }
108}
109
110/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view?language=objc)
111#[repr(C)]
112#[derive(Debug)]
113pub struct cp_view {
114 inner: [u8; 0],
115 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
116}
117
118unsafe impl RefEncode for cp_view {
119 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("cp_view", &[]));
120}
121
122/// An opaque type that manages the information for how to render
123/// content into the current frame.
124///
125/// Compositor provides a view for each distinct render viewpoint.
126/// For example, a head-mounted display typically contains two views:
127/// one for each eye. Use the information in the views to set up your
128/// render pass descriptor. For example, use it to determine which
129/// part of a texture to fill with content.
130///
131/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view_t?language=objc)
132pub type cp_view_t = *mut cp_view;
133
134impl cp_view {
135 /// Returns the texture map for this view.
136 ///
137 /// - Parameters:
138 /// - view: The view with the texture map.
139 /// - Returns: The texture map for the layer assigned to this view.
140 ///
141 /// Use the texture map to fetch additional information you need to
142 /// draw your content. For example, use it to fetch the rectangle to
143 /// use for drawing in the associated texture.
144 #[doc(alias = "cp_view_get_view_texture_map")]
145 #[inline]
146 pub unsafe fn view_texture_map(view: cp_view_t) -> cp_view_texture_map_t {
147 extern "C-unwind" {
148 fn cp_view_get_view_texture_map(view: cp_view_t) -> cp_view_texture_map_t;
149 }
150 unsafe { cp_view_get_view_texture_map(view) }
151 }
152}
153
154extern "C-unwind" {
155 #[deprecated = "renamed to `cp_view_texture_map::texture_index`"]
156 pub fn cp_view_texture_map_get_texture_index(view_texture_map: cp_view_texture_map_t) -> usize;
157}
158
159extern "C-unwind" {
160 #[deprecated = "renamed to `cp_view_texture_map::slice_index`"]
161 pub fn cp_view_texture_map_get_slice_index(view_texture_map: cp_view_texture_map_t) -> usize;
162}
163
164extern "C-unwind" {
165 #[cfg(feature = "objc2-metal")]
166 #[deprecated = "renamed to `cp_view_texture_map::viewport`"]
167 pub fn cp_view_texture_map_get_viewport(view_texture_map: cp_view_texture_map_t)
168 -> MTLViewport;
169}
170
171extern "C-unwind" {
172 #[deprecated = "renamed to `cp_view::view_texture_map`"]
173 pub fn cp_view_get_view_texture_map(view: cp_view_t) -> cp_view_texture_map_t;
174}