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::marker::{PhantomData, PhantomPinned};
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

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

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

/// An opaque type that describes the relationship between a
/// view and the underlying texture.
///
/// A texture map helps you locate the content for a specific view within
/// a texture. Texture maps are especially important when a layer uses a
/// single texture to manage multiple views. For example, a head-mounted
/// display might store the images for both the left and right eyes in a
/// single texture. Pass this type to other functions to get specific details
/// about the current texture, such as its view bounds or its index into
/// a texture array.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view_texture_map_t?language=objc)
pub type cp_view_texture_map_t = *mut cp_view_texture_map;

impl cp_view_texture_map {
    /// Returns the index of the view’s textures in the drawable.
    ///
    /// - Parameters:
    /// - view_texture_map: The texture map for your view.
    /// - Returns: The index of the color or depth texture in the drawable.
    ///
    /// Pass the returned index to the ``cp_drawable_get_color_texture``
    /// or ``cp_drawable_get_depth_texture`` function.
    ///
    /// # Safety
    ///
    /// `view_texture_map` must be a valid pointer.
    #[doc(alias = "cp_view_texture_map_get_texture_index")]
    #[inline]
    pub unsafe fn texture_index(view_texture_map: cp_view_texture_map_t) -> usize {
        extern "C-unwind" {
            fn cp_view_texture_map_get_texture_index(
                view_texture_map: cp_view_texture_map_t,
            ) -> usize;
        }
        unsafe { cp_view_texture_map_get_texture_index(view_texture_map) }
    }

    /// Returns the index of the view’s texture in an array-based texture type.
    ///
    /// - Parameters:
    /// - view_texture_map: The texture map for your view.
    /// - Returns: The index of the view’s texture in an array-based texture type.
    ///
    /// Use the returned index to retrieve the view’s texture when the texture
    /// type is
    /// <doc
    /// ://com.apple.documentation/documentation/metal/mtltexturetype/type2darray>.
    /// When configuring your render pass descriptor, specify the index in the
    /// <doc
    /// ://com.apple.documentation/documentation/metal/mtlrenderpassattachmentdescriptor/1437914-slice>
    /// property of the descriptor’s color and depth attachments.
    ///
    /// To request an array-based texture from your layer, configure your layer
    /// with the ``cp_layer_renderer_layout/cp_layer_renderer_layout_dedicated`` layout option.
    ///
    /// # Safety
    ///
    /// `view_texture_map` must be a valid pointer.
    #[doc(alias = "cp_view_texture_map_get_slice_index")]
    #[inline]
    pub unsafe fn slice_index(view_texture_map: cp_view_texture_map_t) -> usize {
        extern "C-unwind" {
            fn cp_view_texture_map_get_slice_index(
                view_texture_map: cp_view_texture_map_t,
            ) -> usize;
        }
        unsafe { cp_view_texture_map_get_slice_index(view_texture_map) }
    }

    /// Returns the portion of the texture that the view uses to draw its content.
    ///
    /// - Parameters:
    /// - view_texture_map: The texture map for your view.
    /// - Returns: A Metal viewport that specifies the view’s size and location
    /// in the texture.
    ///
    /// Call this function to get the size of the view and its location within
    /// the texture. If the layer dedicates a separate texture to each view,
    /// the texture bounds and view bounds match. However, if the layer uses a
    /// shared or layered texture, the view’s location or other slice index
    /// might differ.
    ///
    /// # Safety
    ///
    /// `view_texture_map` must be a valid pointer.
    #[doc(alias = "cp_view_texture_map_get_viewport")]
    #[cfg(feature = "objc2-metal")]
    #[inline]
    pub unsafe fn viewport(view_texture_map: cp_view_texture_map_t) -> MTLViewport {
        extern "C-unwind" {
            fn cp_view_texture_map_get_viewport(
                view_texture_map: cp_view_texture_map_t,
            ) -> MTLViewport;
        }
        unsafe { cp_view_texture_map_get_viewport(view_texture_map) }
    }
}

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

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

/// An opaque type that manages the information for how to render
/// content into the current frame.
///
/// Compositor provides a view for each distinct render viewpoint.
/// For example, a head-mounted display typically contains two views:
/// one for each eye. Use the information in the views to set up your
/// render pass descriptor. For example, use it to determine which
/// part of a texture to fill with content.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_view_t?language=objc)
pub type cp_view_t = *mut cp_view;

impl cp_view {
    /// Returns the texture map for this view.
    ///
    /// - Parameters:
    /// - view: The view with the texture map.
    /// - Returns: The texture map for the layer assigned to this view.
    ///
    /// Use the texture map to fetch additional information you need to
    /// draw your content. For example, use it to fetch the rectangle to
    /// use for drawing in the associated texture.
    ///
    /// # Safety
    ///
    /// `view` must be a valid pointer.
    #[doc(alias = "cp_view_get_view_texture_map")]
    #[inline]
    pub unsafe fn view_texture_map(view: cp_view_t) -> cp_view_texture_map_t {
        extern "C-unwind" {
            fn cp_view_get_view_texture_map(view: cp_view_t) -> cp_view_texture_map_t;
        }
        unsafe { cp_view_get_view_texture_map(view) }
    }
}

extern "C-unwind" {
    #[deprecated = "renamed to `cp_view_texture_map::texture_index`"]
    pub fn cp_view_texture_map_get_texture_index(view_texture_map: cp_view_texture_map_t) -> usize;
}

extern "C-unwind" {
    #[deprecated = "renamed to `cp_view_texture_map::slice_index`"]
    pub fn cp_view_texture_map_get_slice_index(view_texture_map: cp_view_texture_map_t) -> usize;
}

extern "C-unwind" {
    #[cfg(feature = "objc2-metal")]
    #[deprecated = "renamed to `cp_view_texture_map::viewport`"]
    pub fn cp_view_texture_map_get_viewport(view_texture_map: cp_view_texture_map_t)
        -> MTLViewport;
}

extern "C-unwind" {
    #[deprecated = "renamed to `cp_view::view_texture_map`"]
    pub fn cp_view_get_view_texture_map(view: cp_view_t) -> cp_view_texture_map_t;
}