objc2-compositor-services 0.3.2

Bindings to the CompositorServices framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_drawable_render_context?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct cp_drawable_render_context {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

unsafe impl RefEncode for cp_drawable_render_context {
    const ENCODING_REF: Encoding =
        Encoding::Pointer(&Encoding::Struct("cp_drawable_render_context", &[]));
}

/// An object that can render any effects associated with a drawable
/// This is required for applications that want to render using the
/// Progressive Immersion Style
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_drawable_render_context_t?language=objc)
pub type cp_drawable_render_context_t = *mut cp_drawable_render_context;

impl cp_drawable_render_context {
    /// Store the `value` parameter in the stencil texture in the pixels that Compositor
    /// will display on the screen.
    ///
    /// - Parameters:
    /// - render_context: The render context to use to present the drawable.
    /// - command_encoder: The command encoder to use to render the Compositor effects
    /// and present the drawable.
    /// - value: The value to use when updating the stencil texture in the command_encoder.
    ///
    /// - Note: In Full and Mixed immersion style, this will be the full texture.
    ///
    /// - Note: The command encoder used in the render context has the following constraints:
    /// - stencil texture: should have the same pixel format as
    /// ``cp_layer_renderer_configuration_get_drawable_render_context_stencil_format``
    /// - renderTargetArrayLength: should be the same as the number of views
    /// in the drawable.
    /// - rasterizationRateMap: should be the one provided by the drawable.
    /// - layer renderer layout: Dedicated and Shared layout is not supported.
    ///
    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
    /// to true to avoid Metal API validation errors.
    /// This API is not available on simulator; as a workaround, either disable API validation or separate
    /// the rendering into multiple render encoders for other color attachments.
    ///
    /// - Note: This function will modify the depth stencil state, the viewports, the vertex amplification count
    /// and some of the texture bindings in the render command encoder passed to the function.
    /// Make sure to set those values again to the ones expected in your application.
    ///
    /// # Safety
    ///
    /// `render_context` must be a valid pointer.
    #[doc(alias = "cp_drawable_render_context_draw_mask_on_stencil_attachment")]
    #[cfg(feature = "objc2-metal")]
    #[inline]
    pub unsafe fn draw_mask_on_stencil_attachment(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
        value: u8,
    ) {
        extern "C-unwind" {
            fn cp_drawable_render_context_draw_mask_on_stencil_attachment(
                render_context: cp_drawable_render_context_t,
                command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
                value: u8,
            );
        }
        unsafe {
            cp_drawable_render_context_draw_mask_on_stencil_attachment(
                render_context,
                command_encoder,
                value,
            )
        }
    }

    /// Finish encoding the render context.
    ///
    /// - Parameters:
    /// - render_context: The render context to use to present the drawable.
    /// - command_encoder: The command encoder to use to render the Compositor effects
    /// and present the drawable.
    ///
    /// - Note: The ownership of the command encoder is passed to the drawable render context, which will
    /// call endEncoding on the command encoder.
    ///
    /// - Note: The command encoder used in the render context has the following constraints:
    /// - color texture: colorAttachment[0] should contain the color texture
    /// provided by the drawable.
    /// - depth texture: depthAttachment should contain the depth texture provided
    /// by the drawable.
    /// - renderTargetArrayLength: should be the same as the number of views
    /// in the drawable.
    /// - rasterizationRateMap: should be the one provided by the drawable.
    /// - layer renderer layout: Dedicated and Shared layout is not supported.
    ///
    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
    /// to true to avoid Metal API validation errors.
    /// This API is not available on simulator; as a workaround, either disable API validation or separate
    /// the rendering into multiple render encoders for other color attachments.
    ///
    /// # Safety
    ///
    /// `render_context` must be a valid pointer.
    #[doc(alias = "cp_drawable_render_context_end_encoding")]
    #[cfg(feature = "objc2-metal")]
    #[inline]
    pub unsafe fn end_encoding(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
    ) {
        extern "C-unwind" {
            fn cp_drawable_render_context_end_encoding(
                render_context: cp_drawable_render_context_t,
                command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
            );
        }
        unsafe { cp_drawable_render_context_end_encoding(render_context, command_encoder) }
    }

    /// Store the `value` parameter in the stencil texture in the pixels that Compositor
    /// will display on the screen.
    ///
    /// - Parameters:
    /// - render_context: The render context to use to present the drawable.
    /// - command_encoder: The command encoder to use to render the Compositor effects
    /// and present the drawable.
    /// - value: The value to use when updating the stencil texture in the command_encoder.
    ///
    /// - Note: In Full and Mixed immersion style, this will be the full texture.
    ///
    /// - Note: The command encoder used in the render context has the following constraints:
    /// - stencil texture: should have the same pixel format as
    /// ``cp_layer_renderer_configuration_get_drawable_render_context_stencil_format``
    /// - renderTargetArrayLength: should be the same as the number of views
    /// in the drawable.
    /// - rasterizationRateMap: should be the one provided by the drawable.
    /// - layer renderer layout: Dedicated and Shared layout is not supported.
    ///
    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
    /// to true to avoid Metal API validation errors.
    /// This API is not available on simulator; as a workaround, either disable API validation or separate
    /// the rendering into multiple render encoders for other color attachments.
    ///
    /// - Note: This function will modify the depth stencil state, the viewports, the vertex amplification count
    /// and some of the texture bindings in the render command encoder passed to the function.
    /// Make sure to set those values again to the ones expected in your application.
    ///
    /// # Safety
    ///
    /// `render_context` must be a valid pointer.
    #[doc(alias = "cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment")]
    #[cfg(feature = "objc2-metal")]
    #[inline]
    pub unsafe fn mtl4_draw_mask_on_stencil_attachment(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
        value: u8,
    ) {
        extern "C-unwind" {
            fn cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
                render_context: cp_drawable_render_context_t,
                command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
                value: u8,
            );
        }
        unsafe {
            cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
                render_context,
                command_encoder,
                value,
            )
        }
    }

    /// Finish encoding the render context.
    ///
    /// - Parameters:
    /// - render_context: The render context to use to present the drawable.
    /// - command_encoder: The command encoder to use to render the Compositor effects
    /// and present the drawable.
    ///
    /// - Note: The ownership of the command encoder is passed to the drawable render context, which will
    /// call endEncoding on the command encoder.
    ///
    /// - Note: The command encoder used in the render context has the following constraints:
    /// - color texture: colorAttachment[0] should contain the color texture
    /// provided by the drawable.
    /// - depth texture: depthAttachment should contain the depth texture provided
    /// by the drawable.
    /// - renderTargetArrayLength: should be the same as the number of views
    /// in the drawable.
    /// - rasterizationRateMap: should be the one provided by the drawable.
    /// - layer renderer layout: Dedicated and Shared layout is not supported.
    ///
    /// - Note: If the render encoder has multiple color attachments then set `supportColorAttachmentMapping`
    /// to true to avoid Metal API validation errors.
    /// This API is not available on simulator; as a workaround, either disable API validation or separate
    /// the rendering into multiple render encoders for other color attachments.
    ///
    /// # Safety
    ///
    /// `render_context` must be a valid pointer.
    #[doc(alias = "cp_drawable_render_context_mtl4_end_encoding")]
    #[cfg(feature = "objc2-metal")]
    #[inline]
    pub unsafe fn mtl4_end_encoding(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
    ) {
        extern "C-unwind" {
            fn cp_drawable_render_context_mtl4_end_encoding(
                render_context: cp_drawable_render_context_t,
                command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
            );
        }
        unsafe { cp_drawable_render_context_mtl4_end_encoding(render_context, command_encoder) }
    }
}

extern "C-unwind" {
    #[cfg(feature = "objc2-metal")]
    #[deprecated = "renamed to `cp_drawable_render_context::draw_mask_on_stencil_attachment`"]
    pub fn cp_drawable_render_context_draw_mask_on_stencil_attachment(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
        value: u8,
    );
}

extern "C-unwind" {
    #[cfg(feature = "objc2-metal")]
    #[deprecated = "renamed to `cp_drawable_render_context::end_encoding`"]
    pub fn cp_drawable_render_context_end_encoding(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTLRenderCommandEncoder>,
    );
}

extern "C-unwind" {
    #[cfg(feature = "objc2-metal")]
    #[deprecated = "renamed to `cp_drawable_render_context::mtl4_draw_mask_on_stencil_attachment`"]
    pub fn cp_drawable_render_context_mtl4_draw_mask_on_stencil_attachment(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
        value: u8,
    );
}

extern "C-unwind" {
    #[cfg(feature = "objc2-metal")]
    #[deprecated = "renamed to `cp_drawable_render_context::mtl4_end_encoding`"]
    pub fn cp_drawable_render_context_mtl4_end_encoding(
        render_context: cp_drawable_render_context_t,
        command_encoder: &ProtocolObject<dyn MTL4RenderCommandEncoder>,
    );
}