1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

// NS_TYPED_ENUM
pub type CIContextOption = NSString;

extern "C" {
    pub static kCIContextOutputColorSpace: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextWorkingColorSpace: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextWorkingFormat: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextHighQualityDownsample: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextOutputPremultiplied: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextCacheIntermediates: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextUseSoftwareRenderer: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextPriorityRequestLow: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextAllowLowPower: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextName: &'static CIContextOption;
}

extern "C" {
    pub static kCIContextMemoryLimit: &'static CIContextOption;
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CIContext;

    unsafe impl ClassType for CIContext {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for CIContext {}

extern_methods!(
    unsafe impl CIContext {
        #[method_id(@__retain_semantics Other contextWithOptions:)]
        pub unsafe fn contextWithOptions(
            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
        ) -> Retained<CIContext>;

        #[method_id(@__retain_semantics Other context)]
        pub unsafe fn context() -> Retained<CIContext>;

        #[method_id(@__retain_semantics Init initWithOptions:)]
        pub unsafe fn initWithOptions(
            this: Allocated<Self>,
            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "objc2-metal")]
        #[method_id(@__retain_semantics Other contextWithMTLDevice:)]
        pub unsafe fn contextWithMTLDevice(
            device: &ProtocolObject<dyn MTLDevice>,
        ) -> Retained<CIContext>;

        #[cfg(feature = "objc2-metal")]
        #[method_id(@__retain_semantics Other contextWithMTLDevice:options:)]
        pub unsafe fn contextWithMTLDevice_options(
            device: &ProtocolObject<dyn MTLDevice>,
            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
        ) -> Retained<CIContext>;

        #[cfg(feature = "objc2-metal")]
        #[method_id(@__retain_semantics Other contextWithMTLCommandQueue:)]
        pub unsafe fn contextWithMTLCommandQueue(
            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
        ) -> Retained<CIContext>;

        #[cfg(feature = "objc2-metal")]
        #[method_id(@__retain_semantics Other contextWithMTLCommandQueue:options:)]
        pub unsafe fn contextWithMTLCommandQueue_options(
            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
        ) -> Retained<CIContext>;

        #[cfg(feature = "CIImage")]
        #[method(workingFormat)]
        pub unsafe fn workingFormat(&self) -> CIFormat;

        #[cfg(feature = "CIImage")]
        #[deprecated]
        #[method(drawImage:atPoint:fromRect:)]
        pub unsafe fn drawImage_atPoint_fromRect(
            &self,
            image: &CIImage,
            at_point: CGPoint,
            from_rect: CGRect,
        );

        #[cfg(feature = "CIImage")]
        #[method(drawImage:inRect:fromRect:)]
        pub unsafe fn drawImage_inRect_fromRect(
            &self,
            image: &CIImage,
            in_rect: CGRect,
            from_rect: CGRect,
        );

        #[method(reclaimResources)]
        pub unsafe fn reclaimResources(&self);

        #[method(clearCaches)]
        pub unsafe fn clearCaches(&self);

        #[method(inputImageMaximumSize)]
        pub unsafe fn inputImageMaximumSize(&self) -> CGSize;

        #[method(outputImageMaximumSize)]
        pub unsafe fn outputImageMaximumSize(&self) -> CGSize;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl CIContext {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_methods!(
    /// createCGImage
    unsafe impl CIContext {}
);

extern_methods!(
    /// OfflineGPUSupport
    unsafe impl CIContext {
        #[method(offlineGPUCount)]
        pub unsafe fn offlineGPUCount() -> c_uint;

        #[deprecated = "Core Image OpenGL API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)"]
        #[method_id(@__retain_semantics Other contextForOfflineGPUAtIndex:)]
        pub unsafe fn contextForOfflineGPUAtIndex(index: c_uint) -> Option<Retained<CIContext>>;
    }
);

// NS_TYPED_ENUM
pub type CIImageRepresentationOption = NSString;

extern "C" {
    pub static kCIImageRepresentationAVDepthData: &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationDepthImage: &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationDisparityImage: &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationAVPortraitEffectsMatte: &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationPortraitEffectsMatteImage:
        &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationAVSemanticSegmentationMattes:
        &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationSemanticSegmentationSkinMatteImage:
        &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationSemanticSegmentationHairMatteImage:
        &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationSemanticSegmentationTeethMatteImage:
        &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationSemanticSegmentationGlassesMatteImage:
        &'static CIImageRepresentationOption;
}

extern "C" {
    pub static kCIImageRepresentationSemanticSegmentationSkyMatteImage:
        &'static CIImageRepresentationOption;
}

extern_methods!(
    /// ImageRepresentation
    unsafe impl CIContext {
        #[cfg(feature = "CIImage")]
        #[method_id(@__retain_semantics Other OpenEXRRepresentationOfImage:options:error:_)]
        pub unsafe fn OpenEXRRepresentationOfImage_options_error(
            &self,
            image: &CIImage,
            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
        ) -> Result<Retained<NSData>, Retained<NSError>>;

        #[cfg(feature = "CIImage")]
        #[method(writeOpenEXRRepresentationOfImage:toURL:options:error:_)]
        pub unsafe fn writeOpenEXRRepresentationOfImage_toURL_options_error(
            &self,
            image: &CIImage,
            url: &NSURL,
            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
        ) -> Result<(), Retained<NSError>>;
    }
);

extern_methods!(
    /// CIDepthBlurEffect
    unsafe impl CIContext {
        #[cfg(feature = "CIFilter")]
        #[method_id(@__retain_semantics Other depthBlurEffectFilterForImageURL:options:)]
        pub unsafe fn depthBlurEffectFilterForImageURL_options(
            &self,
            url: &NSURL,
            options: Option<&NSDictionary>,
        ) -> Option<Retained<CIFilter>>;

        #[cfg(feature = "CIFilter")]
        #[method_id(@__retain_semantics Other depthBlurEffectFilterForImageData:options:)]
        pub unsafe fn depthBlurEffectFilterForImageData_options(
            &self,
            data: &NSData,
            options: Option<&NSDictionary>,
        ) -> Option<Retained<CIFilter>>;
    }
);