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 core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

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

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

/// An opaque type that specifies the configuration of one of the layer’s
/// drawable textures.
///
/// For direct-to-screen drawing, you specify how you want Compositor to
/// configure the required textures when you configure your layer. For a
/// device with multiple displays, Compositor can configure the textures
/// in different ways. For example, it can create a separate texture for
/// each display, or it can combine the images from multiple displays into
/// a single texture. A texture topology type contains the details of one
/// of the textures Compositor creates for your app.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_texture_topology_t?language=objc)
pub type cp_texture_topology_t = *mut cp_texture_topology;

impl cp_texture_topology {
    /// Returns the number of items in the texture array.
    ///
    /// - Parameters:
    /// - texture_topology: A texture configuration you obtained from the
    /// layer's properties. Fetch this value using the
    /// ``cp_layer_renderer_properties_get_texture_topology`` function.
    /// - Returns: The number of separate items in the texture array.
    ///
    /// Array-based texture types such as
    /// <doc
    /// ://com.apple.documentation/documentation/metal/mtltexturetype/type2darray>
    /// manage one or more images of the same size. This function returns the
    /// number of separate images the texture manages. Other array types store
    /// only one image.
    ///
    /// # Safety
    ///
    /// `texture_topology` must be a valid pointer.
    #[doc(alias = "cp_texture_topology_get_array_length")]
    #[inline]
    pub unsafe fn array_length(texture_topology: cp_texture_topology_t) -> u64 {
        extern "C-unwind" {
            fn cp_texture_topology_get_array_length(texture_topology: cp_texture_topology_t)
                -> u64;
        }
        unsafe { cp_texture_topology_get_array_length(texture_topology) }
    }

    /// Returns the type value that specifies how the underlying texture
    /// organizes its views.
    ///
    /// - Parameters:
    /// - texture_topology: The texture topology to query. Get the texture
    /// topology from the layer properties using the
    /// ``cp_layer_renderer_properties_get_texture_topology`` function.
    /// - Returns: A Metal value that indicates the arrangement of views
    /// within the texture.
    ///
    /// A texture might store the content of one view or multiple views. For
    /// example, a single texture might store one or both views for the left
    /// and right eyes of a head-mounted display. The texture type indicates
    /// this content organization strategy.
    ///
    /// # Safety
    ///
    /// `texture_topology` must be a valid pointer.
    #[doc(alias = "cp_texture_topology_get_texture_type")]
    #[cfg(feature = "objc2-metal")]
    #[inline]
    pub unsafe fn texture_type(texture_topology: cp_texture_topology_t) -> MTLTextureType {
        extern "C-unwind" {
            fn cp_texture_topology_get_texture_type(
                texture_topology: cp_texture_topology_t,
            ) -> MTLTextureType;
        }
        unsafe { cp_texture_topology_get_texture_type(texture_topology) }
    }
}

extern_class!(
    /// An opaque type that describes the organization of the layer's textures
    /// and the relationships between those textures and the views you use
    /// for drawing.
    ///
    /// You might use the layer's properties to configure other parts of
    /// your app. For example, use them to configure your app's render pipeline.
    ///
    /// You can obtain layer properties directly from your layer. If you don't
    /// yet have the layer type, you can create an equivalent set of properties
    /// using the ``cp_layer_renderer_properties_create_using_configuration`` function.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_object_cp_layer_renderer_properties?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CP_OBJECT_cp_layer_renderer_properties;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for CP_OBJECT_cp_layer_renderer_properties {}
);

impl CP_OBJECT_cp_layer_renderer_properties {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// An opaque type that describes the organization of the layer's textures
/// and the relationships between those textures and the views you use
/// for drawing.
///
/// You might use the layer's properties to configure other parts of
/// your app. For example, use them to configure your app's render pipeline.
///
/// You can obtain layer properties directly from your layer. If you don't
/// yet have the layer type, you can create an equivalent set of properties
/// using the ``cp_layer_renderer_properties_create_using_configuration`` function.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/compositorservices/cp_layer_renderer_properties_t?language=objc)
pub type cp_layer_renderer_properties_t = CP_OBJECT_cp_layer_renderer_properties;

/// Creates a new opaque type to store layer-related properties.
///
/// - Parameters:
/// - configuration: An opaque type that contains the layer’s
/// configuration details. Compositor uses this information to
/// configure the properties an equivalent layer would use.
/// - error: A pointer to an error object. On success, the function sets
/// this value to `nil`. If an error occurs, this function sets the value
/// of the pointer to an error object with details about the problem.
/// The caller is responsible for releasing the returned error object.
/// - Returns: A new layer properties type with details about how the layer
/// configures its topologies and texture maps. The function returns `nil`
/// if an error occurs.
///
/// Call this function to create a set of layer properties when you don't
/// yet have a ``cp_layer_renderer_t`` type. This function generates an equivalent
/// set of properties for the configuration you provide. You can use those
/// properties to configure other parts of your app before the layer becomes
/// available. For example, you might use the information to configure portions
/// of your app's render pipeline.
///
/// # Safety
///
/// `error` must be a valid pointer or null.
#[cfg(all(
    feature = "layer_renderer_configuration",
    feature = "objc2-core-foundation"
))]
#[inline]
pub unsafe extern "C-unwind" fn cp_layer_renderer_properties_create_using_configuration(
    configuration: &cp_layer_renderer_configuration_t,
    error: *mut *mut CFError,
) -> Option<Retained<cp_layer_renderer_properties_t>> {
    extern "C-unwind" {
        fn cp_layer_renderer_properties_create_using_configuration(
            configuration: &cp_layer_renderer_configuration_t,
            error: *mut *mut CFError,
        ) -> *mut cp_layer_renderer_properties_t;
    }
    let ret =
        unsafe { cp_layer_renderer_properties_create_using_configuration(configuration, error) };
    unsafe { Retained::from_raw(ret) }
}

extern "C-unwind" {
    /// Returns the number of texture topologies available for you to inspect.
    ///
    /// - Parameters:
    /// - layer_properties: The layer properties to query.
    /// - Returns: The number of texture topologies present in the layer.
    ///
    /// The layer’s configuration determines the total number of available
    /// topologies, and each topology contains details about one texture you
    /// use for rendering. Fetch the topology details using the
    /// ``cp_layer_renderer_properties_get_texture_topology`` function.
    pub fn cp_layer_renderer_properties_get_texture_topology_count(
        layer_properties: &cp_layer_renderer_properties_t,
    ) -> usize;
}

extern "C-unwind" {
    /// Retrieves the texture topology at the specified index in the
    /// layer's properties.
    ///
    /// - Parameters:
    /// - layer_properties: The layer properties to query.
    /// - index: The index into the array of texture configurations.
    /// This value must be less than the value returned by the
    /// ``cp_layer_renderer_properties_get_texture_topology`` function.
    /// - Returns: An opaque type that contains details about the specific
    /// texture.
    ///
    /// Retrieve the topology type and use accessor functions to get details
    /// of that topology, including its type and array length.
    /// Use that information to allocate the resources you need to manage
    /// your content.
    pub fn cp_layer_renderer_properties_get_texture_topology(
        layer_properties: &cp_layer_renderer_properties_t,
        index: usize,
    ) -> cp_texture_topology_t;
}

extern "C-unwind" {
    /// Returns the number of views that will need to be rendered.
    ///
    /// - Parameters:
    /// - layer_properties: The layer properties to query.
    /// - Returns: The total number of views that need to be support on the drawables.
    ///
    /// Should use ``cp_frame_get_drawable_target_view_count`` when
    /// performing frustum culling to determine how many views specific views each
    /// drawable target has.
    ///
    /// Should use ``cp_drawable_get_view_count`` when drawing to
    /// determine how many views the specific frame has.
    pub fn cp_layer_renderer_properties_get_view_count(
        layer_properties: &cp_layer_renderer_properties_t,
    ) -> usize;
}

extern "C-unwind" {
    /// Returns the max render value for tracking areas' render values.
    ///
    /// - Parameters:
    /// - layer_properties: The layer properties to query.
    /// - Returns: The max render value for the tracking areas render values.
    ///
    /// The layer’s configuration determines the total number of available
    /// tracking areas. This will be the max render value available, based on
    /// ``cp_layer_renderer_configuration_get_tracking_areas_format`` function.
    #[cfg(feature = "tracking_area")]
    pub fn cp_layer_renderer_properties_get_tracking_areas_max_value(
        properties: &cp_layer_renderer_properties_t,
    ) -> cp_tracking_area_render_value;
}

extern "C-unwind" {
    #[deprecated = "renamed to `cp_texture_topology::array_length`"]
    pub fn cp_texture_topology_get_array_length(texture_topology: cp_texture_topology_t) -> u64;
}

extern "C-unwind" {
    #[cfg(feature = "objc2-metal")]
    #[deprecated = "renamed to `cp_texture_topology::texture_type`"]
    pub fn cp_texture_topology_get_texture_type(
        texture_topology: cp_texture_topology_t,
    ) -> MTLTextureType;
}