objc2_metal_performance_shaders/generated/MPSImage/
MPSImageConversion.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7#[cfg(feature = "objc2-core-graphics")]
8use objc2_core_graphics::*;
9use objc2_foundation::*;
10use objc2_metal::*;
11
12use crate::*;
13
14extern_class!(
15    /// The MPSImageConversion filter performs a conversion from source to destination
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimageconversion?language=objc)
18    #[unsafe(super(MPSUnaryImageKernel, MPSKernel, NSObject))]
19    #[derive(Debug, PartialEq, Eq, Hash)]
20    #[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
21    pub struct MPSImageConversion;
22);
23
24#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
25extern_conformance!(
26    unsafe impl NSCoding for MPSImageConversion {}
27);
28
29#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
30extern_conformance!(
31    unsafe impl NSCopying for MPSImageConversion {}
32);
33
34#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
35unsafe impl CopyingHelper for MPSImageConversion {
36    type Result = Self;
37}
38
39#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
40extern_conformance!(
41    unsafe impl NSObjectProtocol for MPSImageConversion {}
42);
43
44#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
45extern_conformance!(
46    unsafe impl NSSecureCoding for MPSImageConversion {}
47);
48
49#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
50impl MPSImageConversion {
51    extern_methods!(
52        #[cfg(feature = "MPSImageTypes")]
53        /// Premultiplication description for the source texture
54        ///
55        /// Most colorspace conversion operations can not work directly on premultiplied data.
56        /// Use this property to tag premultiplied data so that the source texture can
57        /// be unpremultiplied prior to application of these transforms.
58        /// Default: MPSPixelAlpha_AlphaIsOne
59        #[unsafe(method(sourceAlpha))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn sourceAlpha(&self) -> MPSAlphaType;
62
63        #[cfg(feature = "MPSImageTypes")]
64        /// Premultiplication description for the destinationAlpha texture
65        ///
66        /// Colorspace conversion operations produce non-premultiplied data.
67        /// Use this property to tag cases where premultiplied results are required.
68        /// If MPSPixelAlpha_AlphaIsOne is used, the alpha channel will be set to 1.
69        /// Default: MPSPixelAlpha_AlphaIsOne
70        #[unsafe(method(destinationAlpha))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn destinationAlpha(&self) -> MPSAlphaType;
73
74        #[cfg(all(
75            feature = "MPSImageTypes",
76            feature = "objc2-core-foundation",
77            feature = "objc2-core-graphics"
78        ))]
79        /// Create a converter that can convert texture colorspace, alpha and texture format
80        ///
81        /// Create a converter that can convert texture colorspace, alpha and MTLPixelFormat.
82        /// Optimized cases exist for NULL color space converter and no alpha conversion.
83        ///
84        /// Parameter `device`: The device the filter will run on
85        ///
86        /// Parameter `srcAlpha`: The alpha encoding for the source texture
87        ///
88        /// Parameter `destAlpha`: The alpha encoding for the destination texture
89        ///
90        /// Parameter `backgroundColor`: An array of CGFloats giving the background color to use when flattening an image.
91        /// The color is in the source colorspace.  The length of the array is the number
92        /// of color channels in the src colorspace. If NULL, use {0}.
93        ///
94        /// Parameter `conversionInfo`: The colorspace conversion to use. May be NULL, indicating no
95        /// color space conversions need to be done.
96        ///
97        ///
98        /// Returns: An initialized MPSImageConversion object.
99        ///
100        /// # Safety
101        ///
102        /// `background_color` must be a valid pointer or null.
103        #[unsafe(method(initWithDevice:srcAlpha:destAlpha:backgroundColor:conversionInfo:))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithDevice_srcAlpha_destAlpha_backgroundColor_conversionInfo(
106            this: Allocated<Self>,
107            device: &ProtocolObject<dyn MTLDevice>,
108            src_alpha: MPSAlphaType,
109            dest_alpha: MPSAlphaType,
110            background_color: *mut CGFloat,
111            conversion_info: Option<&CGColorConversionInfo>,
112        ) -> Retained<Self>;
113    );
114}
115
116/// Methods declared on superclass `MPSUnaryImageKernel`.
117#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
118impl MPSImageConversion {
119    extern_methods!(
120        /// Standard init with default properties per filter type
121        ///
122        /// Parameter `device`: The device that the filter will be used on. May not be NULL.
123        ///
124        /// Returns: a pointer to the newly initialized object. This will fail, returning
125        /// nil if the device is not supported. Devices must be
126        /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
127        #[unsafe(method(initWithDevice:))]
128        #[unsafe(method_family = init)]
129        pub unsafe fn initWithDevice(
130            this: Allocated<Self>,
131            device: &ProtocolObject<dyn MTLDevice>,
132        ) -> Retained<Self>;
133
134        /// NSSecureCoding compatability
135        ///
136        /// While the standard NSSecureCoding/NSCoding method
137        /// -initWithCoder: should work, since the file can't
138        /// know which device your data is allocated on, we
139        /// have to guess and may guess incorrectly.  To avoid
140        /// that problem, use initWithCoder:device instead.
141        ///
142        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
143        ///
144        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
145        ///
146        /// Returns: A new MPSKernel object, or nil if failure.
147        ///
148        /// # Safety
149        ///
150        /// `a_decoder` possibly has further requirements.
151        #[unsafe(method(initWithCoder:device:))]
152        #[unsafe(method_family = init)]
153        pub unsafe fn initWithCoder_device(
154            this: Allocated<Self>,
155            a_decoder: &NSCoder,
156            device: &ProtocolObject<dyn MTLDevice>,
157        ) -> Option<Retained<Self>>;
158    );
159}
160
161/// Methods declared on superclass `MPSKernel`.
162#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
163impl MPSImageConversion {
164    extern_methods!(
165        /// Called by NSCoder to decode MPSKernels
166        ///
167        /// This isn't the right interface to decode a MPSKernel, but
168        /// it is the one that NSCoder uses. To enable your NSCoder
169        /// (e.g. NSKeyedUnarchiver) to set which device to use
170        /// extend the object to adopt the MPSDeviceProvider
171        /// protocol. Otherwise, the Metal system default device
172        /// will be used.
173        ///
174        /// # Safety
175        ///
176        /// `a_decoder` possibly has further requirements.
177        #[unsafe(method(initWithCoder:))]
178        #[unsafe(method_family = init)]
179        pub unsafe fn initWithCoder(
180            this: Allocated<Self>,
181            a_decoder: &NSCoder,
182        ) -> Option<Retained<Self>>;
183    );
184}
185
186/// Methods declared on superclass `NSObject`.
187#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
188impl MPSImageConversion {
189    extern_methods!(
190        #[unsafe(method(init))]
191        #[unsafe(method_family = init)]
192        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
193
194        #[unsafe(method(new))]
195        #[unsafe(method_family = new)]
196        pub unsafe fn new() -> Retained<Self>;
197    );
198}