objc2_core_image/generated/
CIImageProcessor.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-video")]
9use objc2_core_video::*;
10use objc2_foundation::*;
11#[cfg(feature = "objc2-io-surface")]
12use objc2_io_surface::*;
13#[cfg(feature = "objc2-metal")]
14use objc2_metal::*;
15
16use crate::*;
17
18extern_class!(
19    /// The abstract class you extend to create custom image processors that can integrate with Core Image workflows.
20    ///
21    /// Unlike the ``CIKernel`` class and its other subclasses that allow you to create new image-processing effects
22    /// with the Core Image Kernel Language, the `CIImageProcessorKernel` class provides direct access to the underlying
23    /// bitmap image data for a step in the Core Image processing pipeline. As such, you can create subclasses of this
24    /// class to integrate other image-processing technologies—such as Metal compute shaders, Metal Performance Shaders,
25    /// Accelerate vImage operations, or your own CPU-based image-processing routines—with a Core Image filter chain.
26    ///
27    /// Your custom image processing operation is invoked by your subclassed image processor kernel's
28    /// ``processWithInputs:arguments:output:error:`` method. The method can accept zero, one or more `input` objects.
29    /// Processors  that generate imagery (such as a noise or pattern generator) need no inputs, while kernels that
30    /// composite source images together require multiple inputs. The `arguments` dictionary allows the caller to pass in
31    /// additional parameter values (such as the radius of a blur) and the `output` contains the destination for your
32    /// image processing code to write to.
33    ///
34    /// The following code shows how you can subclass `CIImageProcessorKernel` to apply the Metal Performance Shader
35    /// <doc
36    /// ://com.apple.documentation/documentation/metalperformanceshaders/mpsimagethresholdbinary> kernel to a ``CIImage``:
37    ///
38    /// ```swift
39    /// class ThresholdImageProcessorKernel: CIImageProcessorKernel {
40    /// override class func process(with inputs: [CIImageProcessorInput]?, arguments: [String : Any]?, output: CIImageProcessorOutput) throws {
41    /// guard
42    /// let commandBuffer = output.metalCommandBuffer,
43    /// let input = inputs?.first,
44    /// let sourceTexture = input.metalTexture,
45    /// let destinationTexture = output.metalTexture,
46    /// let thresholdValue = arguments?["thresholdValue"] as? Float else {
47    /// return
48    /// }
49    ///
50    /// let threshold = MPSImageThresholdBinary(
51    /// device: commandBuffer.device,
52    /// thresholdValue: thresholdValue,
53    /// maximumValue: 1.0,
54    /// linearGrayColorTransform: nil)
55    ///
56    /// threshold.encode(
57    /// commandBuffer: commandBuffer,
58    /// sourceTexture: sourceTexture,
59    /// destinationTexture: destinationTexture)
60    /// }
61    /// }
62    /// ```
63    ///
64    /// To apply to kernel to an image, the calling side invokes the image processor's `apply(withExtent:inputs:arguments:)`
65    /// method. The following code generates a new ``CIImage`` object named `result` which contains a thresholded version of
66    /// the source image, `inputImage`.
67    ///
68    /// ```swift
69    /// let result = try? ThresholdImageProcessorKernel.apply(
70    /// withExtent: inputImage.extent,
71    /// inputs: [inputImage],
72    /// arguments: ["thresholdValue": 0.25])
73    /// ```
74    ///
75    /// > Important: Core Image will concatenate kernels in a render into as fewer programs as possible, avoiding the creation
76    /// of intermediate buffers. However, it is unable to do this with image processor kernels. To get the best performance,
77    /// you should use `CIImageProcessorKernel` objects only when your algorithms can't be expressed as a ``CIKernel``.
78    ///
79    /// ## Subclassing Notes
80    ///
81    /// The `CIImageProcessorKernel` class is abstract; to create a custom image processor, you define a subclass of this class.
82    ///
83    /// You do not directly create instances of a custom `CIImageProcessorKernel` subclass. Image processors must not carry or
84    /// use state specific to any single invocation of the processor, so all methods (and accessors for readonly properties)
85    /// of an image processor kernel class are class methods.
86    ///
87    /// Your subclass should override at least the ``processWithInputs:arguments:output:error:`` method to perform its
88    /// image processing.
89    ///
90    /// If your image processor needs to work with a larger or smaller region of interest in the input image than each
91    /// corresponding region of the output image (for example, a blur filter, which samples several input pixels for
92    /// each output pixel), you should also override the ``roiForInput:arguments:outputRect:`` method.
93    ///
94    /// You can also override the formatForInputAtIndex: method and outputFormat property getter to customize the input
95    /// and output pixel formats for your processor (for example, as part of a multi-step workflow where you extract a
96    /// single channel from an RGBA image, apply an effect to that channel only, then recombine the channels).
97    ///
98    /// ## Using a Custom Image Processor
99    ///
100    /// To apply your custom image processor class to create a ``CIImage`` object, call the
101    /// ``applyWithExtent:inputs:arguments:error:`` class method. (Do not override this method.)
102    ///
103    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/ciimageprocessorkernel?language=objc)
104    #[unsafe(super(NSObject))]
105    #[derive(Debug, PartialEq, Eq, Hash)]
106    pub struct CIImageProcessorKernel;
107);
108
109extern_conformance!(
110    unsafe impl NSObjectProtocol for CIImageProcessorKernel {}
111);
112
113impl CIImageProcessorKernel {
114    extern_methods!(
115        /// Override this class method to implement your Core Image Processor Kernel subclass.
116        ///
117        /// When a `CIImage` containing your `CIImageProcessorKernel` class is rendered, your class' implementation of
118        /// this method will be called as needed for that render.  The method may be called more than once if Core Image
119        /// needs to tile to limit memory usage.
120        ///
121        /// When your implementation of this class method is called, use the provided `inputs` and `arguments` objects
122        /// to return processed pixel data to Core Image via `output`.
123        ///
124        /// > Important: this is a class method so that you cannot use or capture any state by accident.
125        /// All the parameters that affect the output results must be passed to
126        /// ``applyWithExtent:inputs:arguments:error:``.
127        ///
128        /// - Parameters:
129        /// - inputs: An array of `id
130        /// <CIImageProcessorInput
131        /// >` that the class consumes to produce its output.
132        /// The `input.region` may be larger than the rect returned by ``roiForInput:arguments:outputRect:``.
133        /// - arguments: the arguments dictionary that was passed to ``applyWithExtent:inputs:arguments:error:``.
134        /// - output: The `id
135        /// <CIImageProcessorOutput
136        /// >` that the `CIImageProcessorKernel` must provide results to.
137        /// - error: Pointer to the `NSError` object into which processing errors will be written.
138        /// - Returns:
139        /// Returns YES if processing succeeded, and NO if processing failed.
140        ///
141        /// # Safety
142        ///
143        /// `arguments` generic should be of the correct type.
144        #[unsafe(method(processWithInputs:arguments:output:error:_))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn processWithInputs_arguments_output_error(
147            inputs: Option<&NSArray<ProtocolObject<dyn CIImageProcessorInput>>>,
148            arguments: Option<&NSDictionary<NSString, AnyObject>>,
149            output: &ProtocolObject<dyn CIImageProcessorOutput>,
150        ) -> Result<(), Retained<NSError>>;
151
152        #[cfg(feature = "objc2-core-foundation")]
153        /// Override this class method to implement your processor’s ROI callback.
154        ///
155        /// This will be called one or more times per render to determine what portion
156        /// of the input images are needed to render a given 'outputRect' of the output.
157        /// This will not be called if processor has no input images.
158        ///
159        /// The default implementation would return outputRect.
160        ///
161        /// > Important: this is a class method so that you cannot use or capture any state by accident.
162        /// All the parameters that affect the output results must be passed to
163        /// ``applyWithExtent:inputs:arguments:error:``.
164        ///
165        /// - Parameters:
166        /// - inputIndex: the index that tells you which processor input for which to return the ROI rectangle.
167        /// - arguments: the arguments dictionary that was passed to ``applyWithExtent:inputs:arguments:error:``.
168        /// - outputRect: the output `CGRect` that processor will be asked to output.
169        /// - Returns:
170        /// The `CGRect` of the `inputIndex`th input that is required for the above `outputRect`
171        ///
172        /// # Safety
173        ///
174        /// `arguments` generic should be of the correct type.
175        #[unsafe(method(roiForInput:arguments:outputRect:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn roiForInput_arguments_outputRect(
178            input_index: c_int,
179            arguments: Option<&NSDictionary<NSString, AnyObject>>,
180            output_rect: CGRect,
181        ) -> CGRect;
182
183        #[cfg(all(feature = "CIVector", feature = "objc2-core-foundation"))]
184        /// Override this class method to implement your processor’s tiled ROI callback.
185        ///
186        /// This will be called one or more times per render to determine what tiles
187        /// of the input images are needed to render a given `outputRect` of the output.
188        ///
189        /// If the processor implements this method, then when rendered;
190        /// * as CoreImage prepares for a render, this method will be called for each input to return an ROI tile array.
191        /// * as CoreImage performs the render, the method ``processWithInputs:arguments:output:error:`` will be called once for each tile.
192        ///
193        /// > Important: this is a class method so that you cannot use or capture any state by accident.
194        /// All the parameters that affect the output results must be passed to
195        /// ``applyWithExtent:inputs:arguments:error:``.
196        ///
197        /// - Parameters:
198        /// - inputIndex: the index that tells you which processor input for which to return the array of ROI rectangles
199        /// - arguments: the arguments dictionary that was passed to ``applyWithExtent:inputs:arguments:error:``.
200        /// - outputRect: the output `CGRect` that processor will be asked to output.
201        /// - Returns:
202        /// An array of ``CIVector`` that specify tile regions of the `inputIndex`'th input that is required for the above `outputRect`
203        /// Each region tile in the array is a created by calling ``/CIVector/vectorWithCGRect:/``
204        /// The tiles may overlap but should fully cover the area of 'input' that is needed.
205        /// If a processor has multiple inputs, then each input should return the same number of region tiles.
206        ///
207        /// # Safety
208        ///
209        /// `arguments` generic should be of the correct type.
210        #[unsafe(method(roiTileArrayForInput:arguments:outputRect:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn roiTileArrayForInput_arguments_outputRect(
213            input_index: c_int,
214            arguments: Option<&NSDictionary<NSString, AnyObject>>,
215            output_rect: CGRect,
216        ) -> Retained<NSArray<CIVector>>;
217
218        #[cfg(feature = "CIImage")]
219        /// Override this class method if you want your any of the inputs to be in a specific pixel format.
220        ///
221        /// The format must be one of `kCIFormatBGRA8`, `kCIFormatRGBAh`, `kCIFormatRGBAf` or `kCIFormatR8`.
222        /// On iOS 12 and macOS 10.14, the formats `kCIFormatRh` and `kCIFormatRf` are also supported.
223        ///
224        /// If the requested inputFormat is `0`, then the input will be a supported format that best
225        /// matches the rendering context's ``/CIContext/workingFormat``.
226        ///
227        /// If a processor wants data in a colorspace other than the context's working color space,
228        /// then call ``/CIImage/imageByColorMatchingWorkingSpaceToColorSpace:`` on the processor input.
229        /// If a processor wants it input as alpha-unpremultiplied RGBA data, then call
230        /// ``/CIImage/imageByUnpremultiplyingAlpha`` on the processor input.
231        #[unsafe(method(formatForInputAtIndex:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn formatForInputAtIndex(input_index: c_int) -> CIFormat;
234
235        #[cfg(feature = "CIImage")]
236        /// Override this class property if you want your processor's output to be in a specific pixel format.
237        ///
238        /// The format must be one of `kCIFormatBGRA8`, `kCIFormatRGBAh`, `kCIFormatRGBAf` or `kCIFormatR8`.
239        /// On iOS 12 and macOS 10.14, the formats `kCIFormatRh` and `kCIFormatRf` are also supported.
240        ///
241        /// If the outputFormat is `0`, then the output will be a supported format that best
242        /// matches the rendering context's ``/CIContext/workingFormat``.
243        ///
244        /// If a processor returns data in a color space other than the context working color space,
245        /// then call ``/CIImage/imageByColorMatchingColorSpaceToWorkingSpace:`` on the processor output.
246        /// If a processor returns data as alpha-unpremultiplied RGBA data, then call,
247        /// ``/CIImage/imageByPremultiplyingAlpha`` on the processor output.
248        #[unsafe(method(outputFormat))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn outputFormat() -> CIFormat;
251
252        /// Override this class property if your processor's output stores 1.0 into the
253        /// alpha channel of all pixels within the output extent.
254        ///
255        /// If not overridden, false is returned.
256        #[unsafe(method(outputIsOpaque))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn outputIsOpaque() -> bool;
259
260        /// Override this class property to return false if you want your processor to be given
261        /// input objects that have not been synchronized for CPU access.
262        ///
263        /// Generally, if your subclass uses the GPU your should override this method to return false.
264        /// If not overridden, true is returned.
265        #[unsafe(method(synchronizeInputs))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn synchronizeInputs() -> bool;
268
269        #[cfg(all(feature = "CIImage", feature = "objc2-core-foundation"))]
270        /// Call this method on your Core Image Processor Kernel subclass to create a new image of the specified extent.
271        ///
272        /// The inputs and arguments will be retained so that your subclass can be called when the image is drawn.
273        ///
274        /// This method will return `nil` and an error if:
275        /// * calling ``outputFormat`` on your subclass returns an unsupported format.
276        /// * calling ``formatForInputAtIndex:`` on your subclass returns an unsupported format.
277        /// * your subclass does not implement ``processWithInputs:arguments:output:error:``
278        ///
279        /// - Parameters:
280        /// - extent: The bounding `CGRect` of pixels that the `CIImageProcessorKernel` can produce.
281        /// This method will return ``/CIImage/emptyImage`` if extent is empty.
282        /// - inputs: An array of ``CIImage`` objects to use as input.
283        /// - arguments: This dictionary contains any additional parameters that the processor needs to
284        /// produce its output. The argument objects can be of any type but in order for
285        /// CoreImage  to cache intermediates, they must be of the following immutable types:
286        /// `NSArray`, `NSDictionary`, `NSNumber`, `NSValue`, `NSData`, `NSString`, `NSNull`,
287        /// ``CIVector``, ``CIColor``, `CGImage`, `CGColorSpace`, or `MLModel`.
288        /// - error: Pointer to the `NSError` object into which processing errors will be written.
289        /// - Returns:
290        /// An autoreleased ``CIImage``
291        ///
292        /// # Safety
293        ///
294        /// `arguments` generic should be of the correct type.
295        #[unsafe(method(applyWithExtent:inputs:arguments:error:_))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn applyWithExtent_inputs_arguments_error(
298            extent: CGRect,
299            inputs: Option<&NSArray<CIImage>>,
300            arguments: Option<&NSDictionary<NSString, AnyObject>>,
301        ) -> Result<Retained<CIImage>, Retained<NSError>>;
302    );
303}
304
305/// Methods declared on superclass `NSObject`.
306impl CIImageProcessorKernel {
307    extern_methods!(
308        #[unsafe(method(init))]
309        #[unsafe(method_family = init)]
310        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
311
312        #[unsafe(method(new))]
313        #[unsafe(method_family = new)]
314        pub unsafe fn new() -> Retained<Self>;
315    );
316}
317
318/// MultipleOutputSupport.
319impl CIImageProcessorKernel {
320    extern_methods!(
321        /// Override this class method of your Core Image Processor Kernel subclass if it needs to produce multiple outputs.
322        ///
323        /// This supports 0, 1, 2 or more input images and 2 or more output images.
324        ///
325        /// When a `CIImage` containing your `CIImageProcessorKernel` class is rendered, your class' implementation of
326        /// this method will be called as needed for that render.  The method may be called more than once if Core Image
327        /// needs to tile to limit memory usage.
328        ///
329        /// When your implementation of this class method is called, use the provided `inputs` and `arguments` objects
330        /// to return processed pixel data to Core Image via multiple `outputs`.
331        ///
332        /// > Important: this is a class method so that you cannot use or capture any state by accident.
333        /// All the parameters that affect the output results must be passed to
334        /// ``applyWithExtent:inputs:arguments:error:``.
335        ///
336        /// - Parameters:
337        /// - inputs: An array of `id
338        /// <CIImageProcessorInput
339        /// >` that the class consumes to produce its output.
340        /// The `input.region` may be larger than the rect returned by ``roiForInput:arguments:outputRect:``.
341        /// - arguments: the arguments dictionary that was passed to ``applyWithExtent:inputs:arguments:error:``.
342        /// - outputs: An array `id
343        /// <CIImageProcessorOutput
344        /// >` that the `CIImageProcessorKernel` must provide results to.
345        /// - error: Pointer to the `NSError` object into which processing errors will be written.
346        /// - Returns:
347        /// Returns YES if processing succeeded, and NO if processing failed.
348        ///
349        /// # Safety
350        ///
351        /// `arguments` generic should be of the correct type.
352        #[unsafe(method(processWithInputs:arguments:outputs:error:_))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn processWithInputs_arguments_outputs_error(
355            inputs: Option<&NSArray<ProtocolObject<dyn CIImageProcessorInput>>>,
356            arguments: Option<&NSDictionary<NSString, AnyObject>>,
357            outputs: &NSArray<ProtocolObject<dyn CIImageProcessorOutput>>,
358        ) -> Result<(), Retained<NSError>>;
359
360        #[cfg(feature = "CIImage")]
361        /// Override this class method if your processor has more than one output and
362        /// you want your processor's output to be in a specific supported `CIPixelFormat`.
363        ///
364        /// The format must be one of `kCIFormatBGRA8`, `kCIFormatRGBAh`, `kCIFormatRGBAf` or `kCIFormatR8`.
365        /// On iOS 12 and macOS 10.14, the formats `kCIFormatRh` and `kCIFormatRf` are also supported.
366        ///
367        /// If the outputFormat is `0`, then the output will be a supported format that best
368        /// matches the rendering context's ``/CIContext/workingFormat``.
369        ///
370        /// - Parameters:
371        /// - outputIndex: the index that tells you which processor output for which to return the desired `CIPixelFormat`
372        /// - arguments: the arguments dictionary that was passed to ``applyWithExtent:inputs:arguments:error:``.
373        /// - Returns:
374        /// Return the desired `CIPixelFormat`
375        ///
376        /// # Safety
377        ///
378        /// `arguments` generic should be of the correct type.
379        #[unsafe(method(outputFormatAtIndex:arguments:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn outputFormatAtIndex_arguments(
382            output_index: c_int,
383            arguments: Option<&NSDictionary<NSString, AnyObject>>,
384        ) -> CIFormat;
385
386        #[cfg(all(feature = "CIImage", feature = "CIVector"))]
387        /// Call this method on your multiple-output Core Image Processor Kernel subclass
388        /// to create an array of new image objects given the specified array of extents.
389        ///
390        /// The inputs and arguments will be retained so that your subclass can be called when the image is drawn.
391        ///
392        /// This method will return `nil` and an error if:
393        /// * calling ``outputFormatAtIndex:arguments:`` on your subclass returns an unsupported format.
394        /// * calling ``formatForInputAtIndex:`` on your subclass returns an unsupported format.
395        /// * your subclass does not implement ``processWithInputs:arguments:output:error:``
396        ///
397        /// - Parameters:
398        /// - extents: The array of bounding rectangles  that the `CIImageProcessorKernel` can produce.
399        /// Each rectangle in the array is an object created using ``/CIVector/vectorWithCGRect:``
400        /// This method will return `CIImage.emptyImage` if a rectangle in the array is empty.
401        /// - inputs: An array of ``CIImage`` objects to use as input.
402        /// - arguments: This dictionary contains any additional parameters that the processor needs to
403        /// produce its output. The argument objects can be of any type but in order for
404        /// CoreImage  to cache intermediates, they must be of the following immutable types:
405        /// `NSArray`, `NSDictionary`, `NSNumber`, `NSValue`, `NSData`, `NSString`, `NSNull`,
406        /// ``CIVector``, ``CIColor``, `CGImage`, `CGColorSpace`, or `MLModel`.
407        /// - error: Pointer to the `NSError` object into which processing errors will be written.
408        /// - Returns:
409        /// An autoreleased ``CIImage``
410        ///
411        /// # Safety
412        ///
413        /// `arguments` generic should be of the correct type.
414        #[unsafe(method(applyWithExtents:inputs:arguments:error:_))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn applyWithExtents_inputs_arguments_error(
417            extents: &NSArray<CIVector>,
418            inputs: Option<&NSArray<CIImage>>,
419            arguments: Option<&NSDictionary<NSString, AnyObject>>,
420        ) -> Result<Retained<NSArray<CIImage>>, Retained<NSError>>;
421    );
422}
423
424extern_protocol!(
425    /// Your app does not define classes that adopt this protocol; Core Image provides an object of this type
426    /// when rendering a custom image processor you create with a ``CIImageProcessorKernel`` subclass.
427    ///
428    /// When a `CIImage` containing your `CIImageProcessorKernel` class is rendered, your
429    /// ``CIImageProcessorKernel/processWithInputs:arguments:output:error:`` class method will be called as
430    /// needed for that render.  The method may be called more than once if Core Image needs to tile to
431    /// limit memory usage.
432    ///
433    /// When your image processor class method is called, use the provided `CIImageProcessorInput` object to
434    /// access the image data and supporting information to perform your custom image processing routine.
435    /// For example, if you process the image using a Metal shader, use the `metalTexture` property to bind the
436    /// image as an input texture. Or, if you process the image using a CPU-based routine, use the `baseAddress`
437    /// property to access pixel data in memory.
438    ///
439    /// You should use the input's `region` property to determine which portion of the input image is available
440    /// to be processed.
441    ///
442    /// To finish setting up or performing your image processing routine, use the provided ``CIImageProcessorOutput``
443    /// object to return processed pixel data to Core Image.
444    ///
445    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/ciimageprocessorinput?language=objc)
446    pub unsafe trait CIImageProcessorInput {
447        #[cfg(feature = "objc2-core-foundation")]
448        /// The rectangular region of the input image that your Core Image Processor Kernel can use to provide the output.
449        /// > Note: This will contain but may be larger than the rect returned by 'roiCallback'.
450        #[unsafe(method(region))]
451        #[unsafe(method_family = none)]
452        unsafe fn region(&self) -> CGRect;
453
454        /// The bytes per row of the CPU memory that your Core Image Processor Kernel can read pixelsfrom.
455        #[unsafe(method(bytesPerRow))]
456        #[unsafe(method_family = none)]
457        unsafe fn bytesPerRow(&self) -> usize;
458
459        #[cfg(feature = "CIImage")]
460        /// The pixel format of the CPU memory that your Core Image Processor Kernel can read pixels from.
461        #[unsafe(method(format))]
462        #[unsafe(method_family = none)]
463        unsafe fn format(&self) -> CIFormat;
464
465        /// The base address of CPU memory that your Core Image Processor Kernel can read pixels from.
466        /// > Warning: This memory must not be modified by the ``CIImageProcessorKernel``.
467        #[unsafe(method(baseAddress))]
468        #[unsafe(method_family = none)]
469        unsafe fn baseAddress(&self) -> NonNull<c_void>;
470
471        #[cfg(feature = "objc2-io-surface")]
472        /// An input surface object that your Core Image Processor Kernel can read from.
473        /// > Warning: This surface must not be modified by the ``CIImageProcessorKernel``.
474        #[unsafe(method(surface))]
475        #[unsafe(method_family = none)]
476        unsafe fn surface(&self) -> Retained<IOSurfaceRef>;
477
478        #[cfg(feature = "objc2-core-video")]
479        /// An input pixel buffer object that your Core Image Processor Kernel can read from.
480        /// > Warning: This buffer must not be modified by the ``CIImageProcessorKernel``.
481        #[unsafe(method(pixelBuffer))]
482        #[unsafe(method_family = none)]
483        unsafe fn pixelBuffer(&self) -> Option<Retained<CVPixelBuffer>>;
484
485        #[cfg(feature = "objc2-metal")]
486        /// A MTLTexture object that can be bound for input using Metal.
487        /// > Warning: This texture must not be modified by the ``CIImageProcessorKernel``.
488        #[unsafe(method(metalTexture))]
489        #[unsafe(method_family = none)]
490        unsafe fn metalTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
491
492        /// A 64-bit digest that uniquely describes the contents of the input to a processor.
493        ///
494        /// This digest will change if the graph of the input changes in any way.
495        #[unsafe(method(digest))]
496        #[unsafe(method_family = none)]
497        unsafe fn digest(&self) -> u64;
498
499        /// This property tells a tiled-input processor which input tile index is being processed.
500        ///
501        /// This property is only relevant if your processor implements ``/CIImageProcessorKernel/roiTileArrayForInput:arguments:outputRect:``
502        ///
503        /// This can be useful if the processor needs to clear the ``CIImageProcessorOutput`` before the first tile is processed.
504        #[unsafe(method(roiTileIndex))]
505        #[unsafe(method_family = none)]
506        unsafe fn roiTileIndex(&self) -> NSUInteger;
507
508        /// This property tells a tiled-input processor how many input tiles will be processed.
509        ///
510        /// This property is only relevant if your processor implements ``/CIImageProcessorKernel/roiTileArrayForInput:arguments:outputRect:``
511        ///
512        /// This can be useful if the processor needs to do work ``CIImageProcessorOutput`` after the last tile is processed.
513        #[unsafe(method(roiTileCount))]
514        #[unsafe(method_family = none)]
515        unsafe fn roiTileCount(&self) -> NSUInteger;
516    }
517);
518
519extern_protocol!(
520    /// Your app does not define classes that adopt this protocol; Core Image provides an object of this type
521    /// when rendering a custom image processor you create with a ``CIImageProcessorKernel`` subclass.
522    ///
523    /// When a `CIImage` containing your `CIImageProcessorKernel` class is rendered, your
524    /// ``CIImageProcessorKernel/processWithInputs:arguments:output:error:`` class method will be called as
525    /// needed for that render.  The method may be called more than once if Core Image needs to tile to
526    /// limit memory usage.
527    ///
528    /// When your image processor class method is called, use the provided `CIImageProcessorOutput` object to return
529    /// processed pixel data to Core Image. For example, if you process the image using a Metal shader, bind the `metalTexture`
530    /// property as an attachment in a render pass or as an output texture in a compute pass. Or, if you process the image
531    /// using a CPU-based routine, write processed pixel data to memory using the `baseAddress` pointer.
532    ///
533    /// You should use the output's `region` property to determine which portion of the output image needs to be processed.
534    /// Your code should fill the entirety of the `region`. This includes setting to zero any pixels in the `region` that
535    /// are outside the extent passed extent `applyWithExtent:inputs:arguments:error:`.
536    ///
537    /// > Important: You must provide rendered output using only one of the following properties of the output:
538    /// `baseAddress`, `surface`, `pixelBuffer`, `metalTexture`.
539    ///
540    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/ciimageprocessoroutput?language=objc)
541    pub unsafe trait CIImageProcessorOutput {
542        #[cfg(feature = "objc2-core-foundation")]
543        /// The rectangular region of the output image that your Core Image Processor Kernel must provide.
544        /// > Note: This may be different (larger or smaller) than the `extent` that was passed to
545        /// ``/CIImageProcessorKernel/applyWithExtent:inputs:arguments:error:``.
546        #[unsafe(method(region))]
547        #[unsafe(method_family = none)]
548        unsafe fn region(&self) -> CGRect;
549
550        /// The bytes per row of the CPU memory that your Core Image Processor Kernel can write pixels to.
551        #[unsafe(method(bytesPerRow))]
552        #[unsafe(method_family = none)]
553        unsafe fn bytesPerRow(&self) -> usize;
554
555        #[cfg(feature = "CIImage")]
556        /// The pixel format of the CPU memory that your Core Image Processor Kernel can write pixels to.
557        #[unsafe(method(format))]
558        #[unsafe(method_family = none)]
559        unsafe fn format(&self) -> CIFormat;
560
561        /// The base address of CPU memory that your Core Image Processor Kernel can write pixels to.
562        #[unsafe(method(baseAddress))]
563        #[unsafe(method_family = none)]
564        unsafe fn baseAddress(&self) -> NonNull<c_void>;
565
566        #[cfg(feature = "objc2-io-surface")]
567        /// An output surface object that your Core Image Processor Kernel can write to.
568        #[unsafe(method(surface))]
569        #[unsafe(method_family = none)]
570        unsafe fn surface(&self) -> Retained<IOSurfaceRef>;
571
572        #[cfg(feature = "objc2-core-video")]
573        /// An output pixelBuffer object that your Core Image Processor Kernel can write to.
574        #[unsafe(method(pixelBuffer))]
575        #[unsafe(method_family = none)]
576        unsafe fn pixelBuffer(&self) -> Option<Retained<CVPixelBuffer>>;
577
578        #[cfg(feature = "objc2-metal")]
579        /// A Metal texture object that can be bound for output using Metal.
580        #[unsafe(method(metalTexture))]
581        #[unsafe(method_family = none)]
582        unsafe fn metalTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>;
583
584        #[cfg(feature = "objc2-metal")]
585        /// Returns a Metal command buffer object that can be used for encoding commands.
586        #[unsafe(method(metalCommandBuffer))]
587        #[unsafe(method_family = none)]
588        unsafe fn metalCommandBuffer(
589            &self,
590        ) -> Option<Retained<ProtocolObject<dyn MTLCommandBuffer>>>;
591
592        /// A 64-bit digest that uniquely describes the contents of the output of a processor.
593        ///
594        /// This digest will change if the graph up to and including the output of the processor changes in any way.
595        #[unsafe(method(digest))]
596        #[unsafe(method_family = none)]
597        unsafe fn digest(&self) -> u64;
598    }
599);