objc2_metal_performance_shaders/generated/MPSImage/
MPSImageThreshold.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7use objc2_metal::*;
8
9use crate::*;
10
11extern_class!(
12    /// The MPSThreshold filter applies a fixed-level threshold to each pixel in the image.
13    /// The threshold functions convert a single channel image to a binary image.
14    /// If the input image is not a single channel image, convert the inputimage to a single channel
15    /// luminance image using the linearGrayColorTransform and then apply the threshold.
16    /// The ThresholdBinary function is:
17    /// destinationPixelValue = sourcePixelValue > thresholdValue ? maximumValue : 0
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagethresholdbinary?language=objc)
20    #[unsafe(super(MPSUnaryImageKernel, MPSKernel, NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    #[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
23    pub struct MPSImageThresholdBinary;
24);
25
26#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
27extern_conformance!(
28    unsafe impl NSCoding for MPSImageThresholdBinary {}
29);
30
31#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
32extern_conformance!(
33    unsafe impl NSCopying for MPSImageThresholdBinary {}
34);
35
36#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
37unsafe impl CopyingHelper for MPSImageThresholdBinary {
38    type Result = Self;
39}
40
41#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
42extern_conformance!(
43    unsafe impl NSObjectProtocol for MPSImageThresholdBinary {}
44);
45
46#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
47extern_conformance!(
48    unsafe impl NSSecureCoding for MPSImageThresholdBinary {}
49);
50
51#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
52impl MPSImageThresholdBinary {
53    extern_methods!(
54        /// initialize a MPSImageThresholdBinary filter
55        ///
56        /// Parameter `device`: The device the filter will run on
57        ///
58        /// Parameter `thresholdValue`: The threshold value to use
59        ///
60        /// Parameter `maximumValue`: The maximum value to use
61        ///
62        /// Parameter `transform`: This matrix is an array of 3 floats.
63        /// The default if no transform is specifed is BT.601/JPEG: {0.299f, 0.587f, 0.114f};
64        ///
65        /// # Safety
66        ///
67        /// `transform` must be a valid pointer or null.
68        #[unsafe(method(initWithDevice:thresholdValue:maximumValue:linearGrayColorTransform:))]
69        #[unsafe(method_family = init)]
70        pub unsafe fn initWithDevice_thresholdValue_maximumValue_linearGrayColorTransform(
71            this: Allocated<Self>,
72            device: &ProtocolObject<dyn MTLDevice>,
73            threshold_value: c_float,
74            maximum_value: c_float,
75            transform: *const c_float,
76        ) -> Retained<Self>;
77
78        /// NSSecureCoding compatability
79        ///
80        /// While the standard NSSecureCoding/NSCoding method
81        /// -initWithCoder: should work, since the file can't
82        /// know which device your data is allocated on, we
83        /// have to guess and may guess incorrectly.  To avoid
84        /// that problem, use initWithCoder:device instead.
85        ///
86        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
87        ///
88        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
89        ///
90        /// Returns: A new MPSKernel object, or nil if failure.
91        ///
92        /// # Safety
93        ///
94        /// `a_decoder` possibly has further requirements.
95        #[unsafe(method(initWithCoder:device:))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn initWithCoder_device(
98            this: Allocated<Self>,
99            a_decoder: &NSCoder,
100            device: &ProtocolObject<dyn MTLDevice>,
101        ) -> Option<Retained<Self>>;
102
103        #[unsafe(method(initWithDevice:))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithDevice(
106            this: Allocated<Self>,
107            device: &ProtocolObject<dyn MTLDevice>,
108        ) -> Retained<Self>;
109
110        /// The threshold value used to init the threshold filter
111        #[unsafe(method(thresholdValue))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn thresholdValue(&self) -> c_float;
114
115        /// The maximum value used to init the threshold filter
116        #[unsafe(method(maximumValue))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn maximumValue(&self) -> c_float;
119
120        /// The color transform used to init the threshold filter
121        #[unsafe(method(transform))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn transform(&self) -> NonNull<c_float>;
124    );
125}
126
127/// Methods declared on superclass `MPSKernel`.
128#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
129impl MPSImageThresholdBinary {
130    extern_methods!(
131        /// Called by NSCoder to decode MPSKernels
132        ///
133        /// This isn't the right interface to decode a MPSKernel, but
134        /// it is the one that NSCoder uses. To enable your NSCoder
135        /// (e.g. NSKeyedUnarchiver) to set which device to use
136        /// extend the object to adopt the MPSDeviceProvider
137        /// protocol. Otherwise, the Metal system default device
138        /// will be used.
139        ///
140        /// # Safety
141        ///
142        /// `a_decoder` possibly has further requirements.
143        #[unsafe(method(initWithCoder:))]
144        #[unsafe(method_family = init)]
145        pub unsafe fn initWithCoder(
146            this: Allocated<Self>,
147            a_decoder: &NSCoder,
148        ) -> Option<Retained<Self>>;
149    );
150}
151
152/// Methods declared on superclass `NSObject`.
153#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
154impl MPSImageThresholdBinary {
155    extern_methods!(
156        #[unsafe(method(init))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
159
160        #[unsafe(method(new))]
161        #[unsafe(method_family = new)]
162        pub unsafe fn new() -> Retained<Self>;
163    );
164}
165
166extern_class!(
167    /// The MPSImageThresholdBinaryInverse filter applies a fixed-level threshold to each pixel in the image.
168    /// The threshold functions convert a single channel image to a binary image.
169    /// If the input image is not a single channel image, convert the inputimage to a single channel
170    /// luminance image using the linearGrayColorTransform and then apply the threshold.
171    /// The ThresholdBinaryInverse function is:
172    /// destinationPixelValue = sourcePixelValue > thresholdValue ? 0 : maximumValue
173    ///
174    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagethresholdbinaryinverse?language=objc)
175    #[unsafe(super(MPSUnaryImageKernel, MPSKernel, NSObject))]
176    #[derive(Debug, PartialEq, Eq, Hash)]
177    #[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
178    pub struct MPSImageThresholdBinaryInverse;
179);
180
181#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
182extern_conformance!(
183    unsafe impl NSCoding for MPSImageThresholdBinaryInverse {}
184);
185
186#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
187extern_conformance!(
188    unsafe impl NSCopying for MPSImageThresholdBinaryInverse {}
189);
190
191#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
192unsafe impl CopyingHelper for MPSImageThresholdBinaryInverse {
193    type Result = Self;
194}
195
196#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
197extern_conformance!(
198    unsafe impl NSObjectProtocol for MPSImageThresholdBinaryInverse {}
199);
200
201#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
202extern_conformance!(
203    unsafe impl NSSecureCoding for MPSImageThresholdBinaryInverse {}
204);
205
206#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
207impl MPSImageThresholdBinaryInverse {
208    extern_methods!(
209        /// initialize a MPSImageThresholdBinaryInverse filter
210        ///
211        /// Parameter `device`: The device the filter will run on
212        ///
213        /// Parameter `thresholdValue`: The threshold value to use
214        ///
215        /// Parameter `maximumValue`: The maximum value to use
216        ///
217        /// Parameter `transform`: This matrix is an array of 3 floats.
218        /// The default if no transform is specifed is BT.601/JPEG: {0.299f, 0.587f, 0.114f};
219        ///
220        /// # Safety
221        ///
222        /// `transform` must be a valid pointer or null.
223        #[unsafe(method(initWithDevice:thresholdValue:maximumValue:linearGrayColorTransform:))]
224        #[unsafe(method_family = init)]
225        pub unsafe fn initWithDevice_thresholdValue_maximumValue_linearGrayColorTransform(
226            this: Allocated<Self>,
227            device: &ProtocolObject<dyn MTLDevice>,
228            threshold_value: c_float,
229            maximum_value: c_float,
230            transform: *const c_float,
231        ) -> Retained<Self>;
232
233        /// NSSecureCoding compatability
234        ///
235        /// While the standard NSSecureCoding/NSCoding method
236        /// -initWithCoder: should work, since the file can't
237        /// know which device your data is allocated on, we
238        /// have to guess and may guess incorrectly.  To avoid
239        /// that problem, use initWithCoder:device instead.
240        ///
241        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
242        ///
243        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
244        ///
245        /// Returns: A new MPSKernel object, or nil if failure.
246        ///
247        /// # Safety
248        ///
249        /// `a_decoder` possibly has further requirements.
250        #[unsafe(method(initWithCoder:device:))]
251        #[unsafe(method_family = init)]
252        pub unsafe fn initWithCoder_device(
253            this: Allocated<Self>,
254            a_decoder: &NSCoder,
255            device: &ProtocolObject<dyn MTLDevice>,
256        ) -> Option<Retained<Self>>;
257
258        #[unsafe(method(initWithDevice:))]
259        #[unsafe(method_family = init)]
260        pub unsafe fn initWithDevice(
261            this: Allocated<Self>,
262            device: &ProtocolObject<dyn MTLDevice>,
263        ) -> Retained<Self>;
264
265        /// The threshold value used to init the threshold filter
266        #[unsafe(method(thresholdValue))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn thresholdValue(&self) -> c_float;
269
270        /// The maximum value used to init the threshold filter
271        #[unsafe(method(maximumValue))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn maximumValue(&self) -> c_float;
274
275        /// The color transform used to init the threshold filter
276        #[unsafe(method(transform))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn transform(&self) -> NonNull<c_float>;
279    );
280}
281
282/// Methods declared on superclass `MPSKernel`.
283#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
284impl MPSImageThresholdBinaryInverse {
285    extern_methods!(
286        /// Called by NSCoder to decode MPSKernels
287        ///
288        /// This isn't the right interface to decode a MPSKernel, but
289        /// it is the one that NSCoder uses. To enable your NSCoder
290        /// (e.g. NSKeyedUnarchiver) to set which device to use
291        /// extend the object to adopt the MPSDeviceProvider
292        /// protocol. Otherwise, the Metal system default device
293        /// will be used.
294        ///
295        /// # Safety
296        ///
297        /// `a_decoder` possibly has further requirements.
298        #[unsafe(method(initWithCoder:))]
299        #[unsafe(method_family = init)]
300        pub unsafe fn initWithCoder(
301            this: Allocated<Self>,
302            a_decoder: &NSCoder,
303        ) -> Option<Retained<Self>>;
304    );
305}
306
307/// Methods declared on superclass `NSObject`.
308#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
309impl MPSImageThresholdBinaryInverse {
310    extern_methods!(
311        #[unsafe(method(init))]
312        #[unsafe(method_family = init)]
313        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
314
315        #[unsafe(method(new))]
316        #[unsafe(method_family = new)]
317        pub unsafe fn new() -> Retained<Self>;
318    );
319}
320
321extern_class!(
322    /// The MPSImageThresholdTruncate filter applies a fixed-level threshold to each pixel in the image:
323    /// The threshold functions convert a single channel image to a binary image.
324    /// If the input image is not a single channel image, convert the inputimage to a single channel
325    /// luminance image using the linearGrayColorTransform and then apply the threshold.
326    /// The ThresholdTruncate function is:
327    /// destinationPixelValue = sourcePixelValue > thresholdValue ? thresholdValue : sourcePixelValue
328    ///
329    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagethresholdtruncate?language=objc)
330    #[unsafe(super(MPSUnaryImageKernel, MPSKernel, NSObject))]
331    #[derive(Debug, PartialEq, Eq, Hash)]
332    #[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
333    pub struct MPSImageThresholdTruncate;
334);
335
336#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
337extern_conformance!(
338    unsafe impl NSCoding for MPSImageThresholdTruncate {}
339);
340
341#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
342extern_conformance!(
343    unsafe impl NSCopying for MPSImageThresholdTruncate {}
344);
345
346#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
347unsafe impl CopyingHelper for MPSImageThresholdTruncate {
348    type Result = Self;
349}
350
351#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
352extern_conformance!(
353    unsafe impl NSObjectProtocol for MPSImageThresholdTruncate {}
354);
355
356#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
357extern_conformance!(
358    unsafe impl NSSecureCoding for MPSImageThresholdTruncate {}
359);
360
361#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
362impl MPSImageThresholdTruncate {
363    extern_methods!(
364        /// initialize a MPSImageThresholdTruncate filter
365        ///
366        /// Parameter `device`: The device the filter will run on
367        ///
368        /// Parameter `thresholdValue`: The threshold value to use
369        ///
370        /// Parameter `transform`: This matrix is an array of 3 floats.
371        /// The default if no transform is specifed is BT.601/JPEG: {0.299f, 0.587f, 0.114f};
372        ///
373        /// # Safety
374        ///
375        /// `transform` must be a valid pointer or null.
376        #[unsafe(method(initWithDevice:thresholdValue:linearGrayColorTransform:))]
377        #[unsafe(method_family = init)]
378        pub unsafe fn initWithDevice_thresholdValue_linearGrayColorTransform(
379            this: Allocated<Self>,
380            device: &ProtocolObject<dyn MTLDevice>,
381            threshold_value: c_float,
382            transform: *const c_float,
383        ) -> Retained<Self>;
384
385        /// NSSecureCoding compatability
386        ///
387        /// While the standard NSSecureCoding/NSCoding method
388        /// -initWithCoder: should work, since the file can't
389        /// know which device your data is allocated on, we
390        /// have to guess and may guess incorrectly.  To avoid
391        /// that problem, use initWithCoder:device instead.
392        ///
393        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
394        ///
395        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
396        ///
397        /// Returns: A new MPSKernel object, or nil if failure.
398        ///
399        /// # Safety
400        ///
401        /// `a_decoder` possibly has further requirements.
402        #[unsafe(method(initWithCoder:device:))]
403        #[unsafe(method_family = init)]
404        pub unsafe fn initWithCoder_device(
405            this: Allocated<Self>,
406            a_decoder: &NSCoder,
407            device: &ProtocolObject<dyn MTLDevice>,
408        ) -> Option<Retained<Self>>;
409
410        #[unsafe(method(initWithDevice:))]
411        #[unsafe(method_family = init)]
412        pub unsafe fn initWithDevice(
413            this: Allocated<Self>,
414            device: &ProtocolObject<dyn MTLDevice>,
415        ) -> Retained<Self>;
416
417        /// The threshold value used to init the threshold filter
418        #[unsafe(method(thresholdValue))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn thresholdValue(&self) -> c_float;
421
422        /// The color transform used to init the threshold filter
423        #[unsafe(method(transform))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn transform(&self) -> NonNull<c_float>;
426    );
427}
428
429/// Methods declared on superclass `MPSKernel`.
430#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
431impl MPSImageThresholdTruncate {
432    extern_methods!(
433        /// Called by NSCoder to decode MPSKernels
434        ///
435        /// This isn't the right interface to decode a MPSKernel, but
436        /// it is the one that NSCoder uses. To enable your NSCoder
437        /// (e.g. NSKeyedUnarchiver) to set which device to use
438        /// extend the object to adopt the MPSDeviceProvider
439        /// protocol. Otherwise, the Metal system default device
440        /// will be used.
441        ///
442        /// # Safety
443        ///
444        /// `a_decoder` possibly has further requirements.
445        #[unsafe(method(initWithCoder:))]
446        #[unsafe(method_family = init)]
447        pub unsafe fn initWithCoder(
448            this: Allocated<Self>,
449            a_decoder: &NSCoder,
450        ) -> Option<Retained<Self>>;
451    );
452}
453
454/// Methods declared on superclass `NSObject`.
455#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
456impl MPSImageThresholdTruncate {
457    extern_methods!(
458        #[unsafe(method(init))]
459        #[unsafe(method_family = init)]
460        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
461
462        #[unsafe(method(new))]
463        #[unsafe(method_family = new)]
464        pub unsafe fn new() -> Retained<Self>;
465    );
466}
467
468extern_class!(
469    /// The MPSImageThresholdToZero filter applies a fixed-level threshold to each pixel in the image.
470    /// The threshold functions convert a single channel image to a binary image.
471    /// If the input image is not a single channel image, convert the inputimage to a single channel
472    /// luminance image using the linearGrayColorTransform and then apply the threshold.
473    /// The ThresholdToZero function is:
474    /// destinationPixelValue = sourcePixelValue > thresholdValue ? sourcePixelValue : 0
475    ///
476    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagethresholdtozero?language=objc)
477    #[unsafe(super(MPSUnaryImageKernel, MPSKernel, NSObject))]
478    #[derive(Debug, PartialEq, Eq, Hash)]
479    #[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
480    pub struct MPSImageThresholdToZero;
481);
482
483#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
484extern_conformance!(
485    unsafe impl NSCoding for MPSImageThresholdToZero {}
486);
487
488#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
489extern_conformance!(
490    unsafe impl NSCopying for MPSImageThresholdToZero {}
491);
492
493#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
494unsafe impl CopyingHelper for MPSImageThresholdToZero {
495    type Result = Self;
496}
497
498#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
499extern_conformance!(
500    unsafe impl NSObjectProtocol for MPSImageThresholdToZero {}
501);
502
503#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
504extern_conformance!(
505    unsafe impl NSSecureCoding for MPSImageThresholdToZero {}
506);
507
508#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
509impl MPSImageThresholdToZero {
510    extern_methods!(
511        /// initialize a MPSImageThresholdToZero filter
512        ///
513        /// Parameter `device`: The device the filter will run on
514        ///
515        /// Parameter `thresholdValue`: The threshold value to use
516        ///
517        /// Parameter `transform`: This matrix is an array of 3 floats.
518        /// The default if no transform is specifed is BT.601/JPEG: {0.299f, 0.587f, 0.114f};
519        ///
520        /// # Safety
521        ///
522        /// `transform` must be a valid pointer or null.
523        #[unsafe(method(initWithDevice:thresholdValue:linearGrayColorTransform:))]
524        #[unsafe(method_family = init)]
525        pub unsafe fn initWithDevice_thresholdValue_linearGrayColorTransform(
526            this: Allocated<Self>,
527            device: &ProtocolObject<dyn MTLDevice>,
528            threshold_value: c_float,
529            transform: *const c_float,
530        ) -> Retained<Self>;
531
532        #[unsafe(method(initWithDevice:))]
533        #[unsafe(method_family = init)]
534        pub unsafe fn initWithDevice(
535            this: Allocated<Self>,
536            device: &ProtocolObject<dyn MTLDevice>,
537        ) -> Retained<Self>;
538
539        /// NSSecureCoding compatability
540        ///
541        /// While the standard NSSecureCoding/NSCoding method
542        /// -initWithCoder: should work, since the file can't
543        /// know which device your data is allocated on, we
544        /// have to guess and may guess incorrectly.  To avoid
545        /// that problem, use initWithCoder:device instead.
546        ///
547        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
548        ///
549        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
550        ///
551        /// Returns: A new MPSKernel object, or nil if failure.
552        ///
553        /// # Safety
554        ///
555        /// `a_decoder` possibly has further requirements.
556        #[unsafe(method(initWithCoder:device:))]
557        #[unsafe(method_family = init)]
558        pub unsafe fn initWithCoder_device(
559            this: Allocated<Self>,
560            a_decoder: &NSCoder,
561            device: &ProtocolObject<dyn MTLDevice>,
562        ) -> Option<Retained<Self>>;
563
564        /// The threshold value used to init the threshold filter
565        #[unsafe(method(thresholdValue))]
566        #[unsafe(method_family = none)]
567        pub unsafe fn thresholdValue(&self) -> c_float;
568
569        /// The color transform used to init the threshold filter
570        #[unsafe(method(transform))]
571        #[unsafe(method_family = none)]
572        pub unsafe fn transform(&self) -> NonNull<c_float>;
573    );
574}
575
576/// Methods declared on superclass `MPSKernel`.
577#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
578impl MPSImageThresholdToZero {
579    extern_methods!(
580        /// Called by NSCoder to decode MPSKernels
581        ///
582        /// This isn't the right interface to decode a MPSKernel, but
583        /// it is the one that NSCoder uses. To enable your NSCoder
584        /// (e.g. NSKeyedUnarchiver) to set which device to use
585        /// extend the object to adopt the MPSDeviceProvider
586        /// protocol. Otherwise, the Metal system default device
587        /// will be used.
588        ///
589        /// # Safety
590        ///
591        /// `a_decoder` possibly has further requirements.
592        #[unsafe(method(initWithCoder:))]
593        #[unsafe(method_family = init)]
594        pub unsafe fn initWithCoder(
595            this: Allocated<Self>,
596            a_decoder: &NSCoder,
597        ) -> Option<Retained<Self>>;
598    );
599}
600
601/// Methods declared on superclass `NSObject`.
602#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
603impl MPSImageThresholdToZero {
604    extern_methods!(
605        #[unsafe(method(init))]
606        #[unsafe(method_family = init)]
607        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
608
609        #[unsafe(method(new))]
610        #[unsafe(method_family = new)]
611        pub unsafe fn new() -> Retained<Self>;
612    );
613}
614
615extern_class!(
616    /// The MPSImageThresholdToZeroInverse filter applies a fixed-level threshold to each pixel in the image.
617    /// The threshold functions convert a single channel image to a binary image.
618    /// If the input image is not a single channel image, convert the inputimage to a single channel
619    /// luminance image using the linearGrayColorTransform and then apply the threshold.
620    /// The ThresholdToZeroINverse function is:
621    /// destinationPixelValue = sourcePixelValue > thresholdValue ? 0 : sourcePixelValue
622    ///
623    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagethresholdtozeroinverse?language=objc)
624    #[unsafe(super(MPSUnaryImageKernel, MPSKernel, NSObject))]
625    #[derive(Debug, PartialEq, Eq, Hash)]
626    #[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
627    pub struct MPSImageThresholdToZeroInverse;
628);
629
630#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
631extern_conformance!(
632    unsafe impl NSCoding for MPSImageThresholdToZeroInverse {}
633);
634
635#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
636extern_conformance!(
637    unsafe impl NSCopying for MPSImageThresholdToZeroInverse {}
638);
639
640#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
641unsafe impl CopyingHelper for MPSImageThresholdToZeroInverse {
642    type Result = Self;
643}
644
645#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
646extern_conformance!(
647    unsafe impl NSObjectProtocol for MPSImageThresholdToZeroInverse {}
648);
649
650#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
651extern_conformance!(
652    unsafe impl NSSecureCoding for MPSImageThresholdToZeroInverse {}
653);
654
655#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
656impl MPSImageThresholdToZeroInverse {
657    extern_methods!(
658        /// initialize a MPSImageThresholdToZeroInverse filter
659        ///
660        /// Parameter `device`: The device the filter will run on
661        ///
662        /// Parameter `thresholdValue`: The threshold value to use
663        ///
664        /// Parameter `transform`: This matrix is an array of 3 floats.
665        /// The default if no transform is specifed is BT.601/JPEG: {0.299f, 0.587f, 0.114f};
666        ///
667        /// # Safety
668        ///
669        /// `transform` must be a valid pointer or null.
670        #[unsafe(method(initWithDevice:thresholdValue:linearGrayColorTransform:))]
671        #[unsafe(method_family = init)]
672        pub unsafe fn initWithDevice_thresholdValue_linearGrayColorTransform(
673            this: Allocated<Self>,
674            device: &ProtocolObject<dyn MTLDevice>,
675            threshold_value: c_float,
676            transform: *const c_float,
677        ) -> Retained<Self>;
678
679        /// NSSecureCoding compatability
680        ///
681        /// While the standard NSSecureCoding/NSCoding method
682        /// -initWithCoder: should work, since the file can't
683        /// know which device your data is allocated on, we
684        /// have to guess and may guess incorrectly.  To avoid
685        /// that problem, use initWithCoder:device instead.
686        ///
687        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
688        ///
689        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
690        ///
691        /// Returns: A new MPSKernel object, or nil if failure.
692        ///
693        /// # Safety
694        ///
695        /// `a_decoder` possibly has further requirements.
696        #[unsafe(method(initWithCoder:device:))]
697        #[unsafe(method_family = init)]
698        pub unsafe fn initWithCoder_device(
699            this: Allocated<Self>,
700            a_decoder: &NSCoder,
701            device: &ProtocolObject<dyn MTLDevice>,
702        ) -> Option<Retained<Self>>;
703
704        #[unsafe(method(initWithDevice:))]
705        #[unsafe(method_family = init)]
706        pub unsafe fn initWithDevice(
707            this: Allocated<Self>,
708            device: &ProtocolObject<dyn MTLDevice>,
709        ) -> Retained<Self>;
710
711        /// The threshold value used to init the threshold filter
712        #[unsafe(method(thresholdValue))]
713        #[unsafe(method_family = none)]
714        pub unsafe fn thresholdValue(&self) -> c_float;
715
716        /// The color transform used to init the threshold filter
717        #[unsafe(method(transform))]
718        #[unsafe(method_family = none)]
719        pub unsafe fn transform(&self) -> NonNull<c_float>;
720    );
721}
722
723/// Methods declared on superclass `MPSKernel`.
724#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
725impl MPSImageThresholdToZeroInverse {
726    extern_methods!(
727        /// Called by NSCoder to decode MPSKernels
728        ///
729        /// This isn't the right interface to decode a MPSKernel, but
730        /// it is the one that NSCoder uses. To enable your NSCoder
731        /// (e.g. NSKeyedUnarchiver) to set which device to use
732        /// extend the object to adopt the MPSDeviceProvider
733        /// protocol. Otherwise, the Metal system default device
734        /// will be used.
735        ///
736        /// # Safety
737        ///
738        /// `a_decoder` possibly has further requirements.
739        #[unsafe(method(initWithCoder:))]
740        #[unsafe(method_family = init)]
741        pub unsafe fn initWithCoder(
742            this: Allocated<Self>,
743            a_decoder: &NSCoder,
744        ) -> Option<Retained<Self>>;
745    );
746}
747
748/// Methods declared on superclass `NSObject`.
749#[cfg(all(feature = "MPSCore", feature = "MPSImageKernel", feature = "MPSKernel"))]
750impl MPSImageThresholdToZeroInverse {
751    extern_methods!(
752        #[unsafe(method(init))]
753        #[unsafe(method_family = init)]
754        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
755
756        #[unsafe(method(new))]
757        #[unsafe(method_family = new)]
758        pub unsafe fn new() -> Retained<Self>;
759    );
760}