objc2_compositor_services/generated/
drawable_render_context.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 core::ptr::NonNull;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-metal")]
9use objc2_metal::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_drawable_render_context?language=objc)
14#[repr(C)]
15#[derive(Debug)]
16pub struct cp_drawable_render_context {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21unsafe impl RefEncode for cp_drawable_render_context {
22    const ENCODING_REF: Encoding =
23        Encoding::Pointer(&Encoding::Struct("cp_drawable_render_context", &[]));
24}
25
26/// An object that can render any effects associated with a drawable
27/// This is required for applications that want to render using the
28/// Progressive Immersion Style
29///
30/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_drawable_render_context_t?language=objc)
31pub type cp_drawable_render_context_t = *mut cp_drawable_render_context;
32
33impl cp_drawable_render_context {
34    /// Store the `value` parameter in the stencil texture in the pixels that Compositor
35    /// will display on the screen.
36    ///
37    /// - Parameters:
38    /// - render_context: The render context to use to present the drawable.
39    /// - command_encoder: The command encoder to use to render the Compositor effects
40    /// and present the drawable.
41    /// - value: The value to use when updating the stencil texture in the command_encoder.
42    ///
43    /// - Note: In Full and Mixed immersion style, this will be the full texture.
44    ///
45    /// - Note: The command encoder used in the render context has the following constraints:
46    /// - stencil texture: should have the same pixel format as
47    /// ``cp_layer_renderer_configuration_get_drawable_render_context_stencil_format``
48    /// - renderTargetArrayLength: should be the same as the number of views
49    /// in the drawable.
50    /// - rasterizationRateMap: should be the one provided by the drawable.
51    /// - layer renderer layout: Dedicated and Shared layout is not supported.
52    ///
53    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
54    /// to true to avoid Metal API validation errors.
55    /// This API is not available on simulator; as a workaround, either disable API validation or separate
56    /// the rendering into multiple render encoders for other color attachments.
57    ///
58    /// - Note: This function will modify the depth stencil state, the viewports, the vertex amplification count
59    /// and some of the texture bindings in the render command encoder passed to the function.
60    /// Make sure to set those values again to the ones expected in your application.
61    ///
62    /// # Safety
63    ///
64    /// `render_context` must be a valid pointer.
65    #[doc(alias = "cp_drawable_render_context_draw_mask_on_stencil_attachment")]
66    #[cfg(feature = "objc2-metal")]
67    #[inline]
68    pub unsafe fn draw_mask_on_stencil_attachment(
69        render_context: cp_drawable_render_context_t,
70        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
71        value: u8,
72    ) {
73        extern "C-unwind" {
74            fn cp_drawable_render_context_draw_mask_on_stencil_attachment(
75                render_context: cp_drawable_render_context_t,
76                command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
77                value: u8,
78            );
79        }
80        unsafe {
81            cp_drawable_render_context_draw_mask_on_stencil_attachment(
82                render_context,
83                command_encoder,
84                value,
85            )
86        }
87    }
88
89    /// Finish encoding the render context.
90    ///
91    /// - Parameters:
92    /// - render_context: The render context to use to present the drawable.
93    /// - command_encoder: The command encoder to use to render the Compositor effects
94    /// and present the drawable.
95    ///
96    /// - Note: The ownership of the command encoder is passed to the drawable render context, which will
97    /// call endEncoding on the command encoder.
98    ///
99    /// - Note: The command encoder used in the render context has the following constraints:
100    /// - color texture: colorAttachment[0] should contain the color texture
101    /// provided by the drawable.
102    /// - depth texture: depthAttachment should contain the depth texture provided
103    /// by the drawable.
104    /// - renderTargetArrayLength: should be the same as the number of views
105    /// in the drawable.
106    /// - rasterizationRateMap: should be the one provided by the drawable.
107    /// - layer renderer layout: Dedicated and Shared layout is not supported.
108    ///
109    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
110    /// to true to avoid Metal API validation errors.
111    /// This API is not available on simulator; as a workaround, either disable API validation or separate
112    /// the rendering into multiple render encoders for other color attachments.
113    ///
114    /// # Safety
115    ///
116    /// `render_context` must be a valid pointer.
117    #[doc(alias = "cp_drawable_render_context_end_encoding")]
118    #[cfg(feature = "objc2-metal")]
119    #[inline]
120    pub unsafe fn end_encoding(
121        render_context: cp_drawable_render_context_t,
122        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
123    ) {
124        extern "C-unwind" {
125            fn cp_drawable_render_context_end_encoding(
126                render_context: cp_drawable_render_context_t,
127                command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
128            );
129        }
130        unsafe { cp_drawable_render_context_end_encoding(render_context, command_encoder) }
131    }
132
133    /// Store the `value` parameter in the stencil texture in the pixels that Compositor
134    /// will display on the screen.
135    ///
136    /// - Parameters:
137    /// - render_context: The render context to use to present the drawable.
138    /// - command_encoder: The command encoder to use to render the Compositor effects
139    /// and present the drawable.
140    /// - value: The value to use when updating the stencil texture in the command_encoder.
141    ///
142    /// - Note: In Full and Mixed immersion style, this will be the full texture.
143    ///
144    /// - Note: The command encoder used in the render context has the following constraints:
145    /// - stencil texture: should have the same pixel format as
146    /// ``cp_layer_renderer_configuration_get_drawable_render_context_stencil_format``
147    /// - renderTargetArrayLength: should be the same as the number of views
148    /// in the drawable.
149    /// - rasterizationRateMap: should be the one provided by the drawable.
150    /// - layer renderer layout: Dedicated and Shared layout is not supported.
151    ///
152    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
153    /// to true to avoid Metal API validation errors.
154    /// This API is not available on simulator; as a workaround, either disable API validation or separate
155    /// the rendering into multiple render encoders for other color attachments.
156    ///
157    /// - Note: This function will modify the depth stencil state, the viewports, the vertex amplification count
158    /// and some of the texture bindings in the render command encoder passed to the function.
159    /// Make sure to set those values again to the ones expected in your application.
160    ///
161    /// # Safety
162    ///
163    /// `render_context` must be a valid pointer.
164    #[doc(alias = "cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment")]
165    #[cfg(feature = "objc2-metal")]
166    #[inline]
167    pub unsafe fn mtl4_draw_mask_on_stencil_attachment(
168        render_context: cp_drawable_render_context_t,
169        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
170        value: u8,
171    ) {
172        extern "C-unwind" {
173            fn cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
174                render_context: cp_drawable_render_context_t,
175                command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
176                value: u8,
177            );
178        }
179        unsafe {
180            cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
181                render_context,
182                command_encoder,
183                value,
184            )
185        }
186    }
187
188    /// Finish encoding the render context.
189    ///
190    /// - Parameters:
191    /// - render_context: The render context to use to present the drawable.
192    /// - command_encoder: The command encoder to use to render the Compositor effects
193    /// and present the drawable.
194    ///
195    /// - Note: The ownership of the command encoder is passed to the drawable render context, which will
196    /// call endEncoding on the command encoder.
197    ///
198    /// - Note: The command encoder used in the render context has the following constraints:
199    /// - color texture: colorAttachment[0] should contain the color texture
200    /// provided by the drawable.
201    /// - depth texture: depthAttachment should contain the depth texture provided
202    /// by the drawable.
203    /// - renderTargetArrayLength: should be the same as the number of views
204    /// in the drawable.
205    /// - rasterizationRateMap: should be the one provided by the drawable.
206    /// - layer renderer layout: Dedicated and Shared layout is not supported.
207    ///
208    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
209    /// to true to avoid Metal API validation errors.
210    /// This API is not available on simulator; as a workaround, either disable API validation or separate
211    /// the rendering into multiple render encoders for other color attachments.
212    ///
213    /// # Safety
214    ///
215    /// `render_context` must be a valid pointer.
216    #[doc(alias = "cp_drawable_render_context_mtl4_end_encoding")]
217    #[cfg(feature = "objc2-metal")]
218    #[inline]
219    pub unsafe fn mtl4_end_encoding(
220        render_context: cp_drawable_render_context_t,
221        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
222    ) {
223        extern "C-unwind" {
224            fn cp_drawable_render_context_mtl4_end_encoding(
225                render_context: cp_drawable_render_context_t,
226                command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
227            );
228        }
229        unsafe { cp_drawable_render_context_mtl4_end_encoding(render_context, command_encoder) }
230    }
231}
232
233extern "C-unwind" {
234    #[cfg(feature = "objc2-metal")]
235    #[deprecated = "renamed to `cp_drawable_render_context::draw_mask_on_stencil_attachment`"]
236    pub fn cp_drawable_render_context_draw_mask_on_stencil_attachment(
237        render_context: cp_drawable_render_context_t,
238        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
239        value: u8,
240    );
241}
242
243extern "C-unwind" {
244    #[cfg(feature = "objc2-metal")]
245    #[deprecated = "renamed to `cp_drawable_render_context::end_encoding`"]
246    pub fn cp_drawable_render_context_end_encoding(
247        render_context: cp_drawable_render_context_t,
248        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
249    );
250}
251
252extern "C-unwind" {
253    #[cfg(feature = "objc2-metal")]
254    #[deprecated = "renamed to `cp_drawable_render_context::mtl4_draw_mask_on_stencil_attachment`"]
255    pub fn cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
256        render_context: cp_drawable_render_context_t,
257        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
258        value: u8,
259    );
260}
261
262extern "C-unwind" {
263    #[cfg(feature = "objc2-metal")]
264    #[deprecated = "renamed to `cp_drawable_render_context::mtl4_end_encoding`"]
265    pub fn cp_drawable_render_context_mtl4_end_encoding(
266        render_context: cp_drawable_render_context_t,
267        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
268    );
269}