objc2_core_image/generated/
CIImageProvider.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-graphics")]
7use objc2_core_graphics::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-metal")]
10use objc2_metal::*;
11
12use crate::*;
13
14/// CIImageProvider.
15#[cfg(feature = "CIImage")]
16impl CIImage {
17    extern_methods!(
18        #[cfg(feature = "objc2-core-graphics")]
19        /// Create an image object based on pixels from an image provider object.
20        ///
21        /// Core Image retains the provider object until the image is deallocated.
22        /// The image provider object will not be called until the image is rendered.
23        ///
24        /// - Parameters:
25        /// - provider: An object that implements the `CIImageProvider` protocol.
26        /// - width: The width of the image.
27        /// - height: The height of the image.
28        /// - format: The ``CIFormat`` of the provided pixels.
29        /// - colorSpace: The color space that the image is defined in.
30        /// If `nil`, then the pixels will not be is not color matched to the Core Image working color space.
31        /// - options: A dictionary that contains various ``CIImageOption`` keys that affect the resulting ``CIImage``.
32        /// The option ``kCIImageProviderTileSize`` controls if and how the provider object is called in tiles.
33        /// The option ``kCIImageProviderUserInfo`` allows additional state to be passed to the provider object.
34        /// - Returns:
35        /// An autoreleased ``CIImage`` object based on the data provider.
36        ///
37        /// # Safety
38        ///
39        /// - `provider` should be of the correct type.
40        /// - `options` generic should be of the correct type.
41        #[unsafe(method(imageWithImageProvider:size::format:colorSpace:options:))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn imageWithImageProvider_size__format_colorSpace_options(
44            provider: &AnyObject,
45            width: usize,
46            height: usize,
47            format: CIFormat,
48            color_space: Option<&CGColorSpace>,
49            options: Option<&NSDictionary<CIImageOption, AnyObject>>,
50        ) -> Retained<CIImage>;
51
52        #[cfg(feature = "objc2-core-graphics")]
53        /// Initializes an image object based on pixels from an image provider object.
54        ///
55        /// Core Image retains the provider object until the image is deallocated.
56        /// The image provider object will not be called until the image is rendered.
57        ///
58        /// - Parameters:
59        /// - provider: An object that implements the `CIImageProvider` protocol.
60        /// - width: The width of the image.
61        /// - height: The height of the image.
62        /// - format: The ``CIFormat`` of the provided pixels.
63        /// - colorSpace: The color space that the image is defined in.
64        /// If `nil`, then the pixels will not be is not color matched to the Core Image working color space.
65        /// - options: A dictionary that contains various ``CIImageOption`` keys that affect the resulting ``CIImage``.
66        /// The option ``kCIImageProviderTileSize`` controls if and how the provider object is called in tiles.
67        /// The option ``kCIImageProviderUserInfo`` allows additional state to be passed to the provider object.
68        /// - Returns:
69        /// An initialized ``CIImage`` object based on the data provider.
70        ///
71        /// # Safety
72        ///
73        /// - `provider` should be of the correct type.
74        /// - `options` generic should be of the correct type.
75        #[unsafe(method(initWithImageProvider:size::format:colorSpace:options:))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn initWithImageProvider_size__format_colorSpace_options(
78            this: Allocated<Self>,
79            provider: &AnyObject,
80            width: usize,
81            height: usize,
82            format: CIFormat,
83            color_space: Option<&CGColorSpace>,
84            options: Option<&NSDictionary<CIImageOption, AnyObject>>,
85        ) -> Retained<Self>;
86    );
87}
88
89mod private_NSObjectCIImageProvider {
90    pub trait Sealed {}
91}
92
93/// Category "CIImageProvider" on [`NSObject`].
94///
95/// Protocol used to lazily supply image data.
96#[doc(alias = "CIImageProvider")]
97pub unsafe trait NSObjectCIImageProvider:
98    ClassType + Sized + private_NSObjectCIImageProvider::Sealed
99{
100    extern_methods!(
101        /// The method that an image provider object must implement.
102        /// This method provides pixel data when the image object is rendered.
103        ///
104        /// The implementation should provide pixels for the requested sub-rect `x,y,width,height` of the image.
105        /// The sub-rect is in defined in the image's local coordinate space,
106        /// where the origin is relative to the top left corner of the image.
107        ///
108        /// By default, this method will be called to request the full image
109        /// regardless of what sub-rect is needed for the current render.
110        /// In this case the requested `x,y,width,height` will be `0,0,imageWidth,imageHeight`
111        ///
112        /// If the ``kCIImageProviderTileSize`` option is specified when the ``CIImage`` was created,
113        /// then this method may be called once for each tile that is needed for the current render.
114        ///
115        /// - Parameters:
116        /// - data: A pointer into which the provider should copy the pixels for the requested sub-rect.
117        /// - rowbytes: The number of bytes per row for the requested pixels.
118        /// - originx: The x origin of the requested sub-rect relative to the upper left corner of the image.
119        /// - originy: The y origin of the requested sub-rect relative to the upper left corner of the image.
120        /// - width: The width of the requested sub-rect.
121        /// - height: The height of the requested sub-rect.
122        /// - info: The value of the `kCIImageProviderTileSize`` option specified when calling:
123        /// * ``/CIImage/imageWithImageProvider:size::format:colorSpace:options:``
124        /// * ``/CIImage/initWithImageProvider:size::format:colorSpace:options:``
125        ///
126        /// # Safety
127        ///
128        /// - `data` must be a valid pointer.
129        /// - `info` should be of the correct type.
130        #[unsafe(method(provideImageData:bytesPerRow:origin::size::userInfo:))]
131        #[unsafe(method_family = none)]
132        unsafe fn provideImageData_bytesPerRow_origin__size__userInfo(
133            &self,
134            data: NonNull<c_void>,
135            rowbytes: usize,
136            originx: usize,
137            originy: usize,
138            width: usize,
139            height: usize,
140            info: Option<&AnyObject>,
141        );
142
143        #[cfg(feature = "objc2-metal")]
144        /// An optional method that an image provider object way implement.
145        /// With this method, the provider object can use the Metal API to provide pixel
146        /// data into a MTLTexture when the image object is rendered.
147        ///
148        /// The implementation should provide pixels for the requested sub-rect `x,y,width,height` of the image.
149        /// The sub-rect is in defined in the image's local coordinate space,
150        /// where the origin is relative to the top left corner of the image.
151        ///
152        /// The work to fill the `MTLTexture` should be encoded on the specified `commandBuffer`.
153        /// If the implementation uses its own commandBuffer,
154        /// then it should call `waitUntilCompleted` before returning.
155        /// If the texture is surface-backed then you only need to
156        /// call `waitUntilScheduled` before returning.
157        ///
158        /// By default, this method will be called to request the full image
159        /// regardless of what sub-rect is needed for the current render.
160        /// In this case the requested `x,y,width,height` will be `0,0,imageWidth,imageHeight`
161        ///
162        /// If the ``kCIImageProviderTileSize`` option is specified when the ``CIImage`` was created,
163        /// then this method may be called once for each tile that is needed for the current render.
164        ///
165        /// - Parameters:
166        /// - texture: The `
167        /// <id
168        /// >MTLTexture` into which the provider should copy the pixels for the requested sub-rect.
169        /// - commandBuffer: The `
170        /// <id
171        /// >MTLCommandBuffer` that the provider should use encoded the copy.
172        /// - originx: The x origin of the requested sub-rect relative to the upper left corner of the image.
173        /// - originy: The y origin of the requested sub-rect relative to the upper left corner of the image.
174        /// - width: The width of the requested sub-rect.
175        /// - height: The height of the requested sub-rect.
176        /// - info: The value of the `kCIImageProviderTileSize`` option specified when calling:
177        /// * ``/CIImage/imageWithImageProvider:size::format:colorSpace:options:``
178        /// * ``/CIImage/initWithImageProvider:size::format:colorSpace:options:``
179        ///
180        /// # Safety
181        ///
182        /// - `texture` may need to be synchronized.
183        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
184        /// - `info` should be of the correct type.
185        #[unsafe(method(provideImageToMTLTexture:commandBuffer:originx:originy:width:height:userInfo:))]
186        #[unsafe(method_family = none)]
187        unsafe fn provideImageToMTLTexture_commandBuffer_originx_originy_width_height_userInfo(
188            &self,
189            texture: &ProtocolObject<dyn MTLTexture>,
190            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
191            originx: usize,
192            originy: usize,
193            width: usize,
194            height: usize,
195            info: Option<&AnyObject>,
196        );
197    );
198}
199
200impl private_NSObjectCIImageProvider::Sealed for NSObject {}
201unsafe impl NSObjectCIImageProvider for NSObject {}
202
203extern "C" {
204    /// Specifies the tile size that the Provide Image Data method will be called for.
205    ///
206    /// This key and its value may be passed to:
207    /// * ``/CIImage/imageWithImageProvider:size::format:colorSpace:options:``
208    /// * ``/CIImage/initWithImageProvider:size::format:colorSpace:options:``
209    ///
210    /// If the value of this key is:
211    /// Value                      | Behavior of sub-rect passed to ``provideImageData:bytesPerRow:origin::size::userData:``
212    /// -------------------------- | ----------------------------
213    /// Not specified              |  the entire image
214    /// `NSNumber`                 |  square tiles of size x size
215    /// `NSArray` with 2 numbers   |  rectangular tiles of width x height.
216    /// ``CIVector`` with 2 values |  rectangular tiles of width x height.
217    /// `NSNull`                   |  can be called for any possible origin and size.
218    ///
219    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimageprovidertilesize?language=objc)
220    #[cfg(feature = "CIImage")]
221    pub static kCIImageProviderTileSize: &'static CIImageOption;
222}
223
224extern "C" {
225    /// A key for any data needed by the image provider object.
226    /// The associated value is an object that contains the needed data.
227    ///
228    /// This key and its value may be passed to:
229    /// * ``/CIImage/imageWithImageProvider:size::format:colorSpace:options:``
230    /// * ``/CIImage/initWithImageProvider:size::format:colorSpace:options:``
231    ///
232    /// The value object is retained until the image is deallocated.
233    ///
234    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimageprovideruserinfo?language=objc)
235    #[cfg(feature = "CIImage")]
236    pub static kCIImageProviderUserInfo: &'static CIImageOption;
237}