objc2_metal_kit/generated/
MTKTextureLoader.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-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11#[cfg(feature = "objc2-core-graphics")]
12use objc2_core_graphics::*;
13use objc2_foundation::*;
14use objc2_metal::*;
15#[cfg(feature = "objc2-model-io")]
16use objc2_model_io::*;
17
18use crate::*;
19
20/// MTKTextureLoaderErrors
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadererror?language=objc)
23// NS_TYPED_ENUM
24pub type MTKTextureLoaderError = NSString;
25
26extern "C" {
27    /// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadererrordomain?language=objc)
28    pub static MTKTextureLoaderErrorDomain: &'static MTKTextureLoaderError;
29}
30
31extern "C" {
32    /// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadererrorkey?language=objc)
33    pub static MTKTextureLoaderErrorKey: &'static MTKTextureLoaderError;
34}
35
36/// MTKTextureLoaderOptions
37///
38/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoption?language=objc)
39// NS_TYPED_ENUM
40pub type MTKTextureLoaderOption = NSString;
41
42extern "C" {
43    /// Identifier to be used in an options NSDictionary with a boolean NSNumber specifying whether to allocate memory for mipmaps when creating the texture
44    ///
45    /// If the boolean value specified with this string is true, the resulting Metal texture will have been created with mipmaps whose contents are undefined. It is the responsibility of the caller to fill out the contents of the mipmap data unless MTLTextureLoaderOptionGenerateMipmaps is specified. If the file being loaded contains data for mipmaps (such as in a PVR or KTX file) this option does not need to be specified. In those cases the mipmap memory will be allocated and the image data loaded.
46    ///
47    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionallocatemipmaps?language=objc)
48    pub static MTKTextureLoaderOptionAllocateMipmaps: &'static MTKTextureLoaderOption;
49}
50
51extern "C" {
52    /// Identifier to be used in an options NSDictionary with a boolean NSNumber specifying whether to generate mipmaps when creating the texture
53    ///
54    /// If the boolean value specified with this string is true, the resulting Metal texture will be created with mipmaps. If the file being loaded contains data for mipmaps (such as in a PVR or KTX file), specifying this option will overwrite the existing mipmap data in the loaded texture. This option can only be used if the pixel format of the texture is color filterable and color renderable. This option implies MTKTextureLoaderOptionAllocateMipmaps. Specifying this option will cause the MTKTextureLoader to submit work to the GPU on behalf of the caller.
55    ///
56    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiongeneratemipmaps?language=objc)
57    pub static MTKTextureLoaderOptionGenerateMipmaps: &'static MTKTextureLoaderOption;
58}
59
60extern "C" {
61    /// Identifier to be used in an options NSDictionary with a boolean NSNumber specifying whether to create the texture with an sRGB (gamma corrected) pixel format
62    ///
63    /// If the boolean value specified with this string is true, the texture will be created with an sRGB pixel format regardless of whether the image file specifies that the data has already been gamma corrected. Likewise, if false, the texture will be created with a non-sRGB pixel format regardless of whether the image file specifies that the data has been gamma corrected. To use the sRGB information specified in the file, do not specify this in the options dictionary.
64    ///
65    /// Warning: When deploying to OS's prior to macOS 10.15 / iOS 13.0, this option is ignored for loading KTX textures.
66    ///
67    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionsrgb?language=objc)
68    pub static MTKTextureLoaderOptionSRGB: &'static MTKTextureLoaderOption;
69}
70
71extern "C" {
72    /// Identifier to be used with an NSNumber specifying the MTLTextureUsage flags
73    ///
74    /// The resulting Metal texture will be created with the MTLTextureUsage flags indicated by the NSNumber associated with this string.
75    ///
76    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiontextureusage?language=objc)
77    pub static MTKTextureLoaderOptionTextureUsage: &'static MTKTextureLoaderOption;
78}
79
80extern "C" {
81    /// Identifier to be used with an NSNumber specifying the MTLCPUCacheMode
82    ///
83    /// The resulting Metal texture will be created with the MTLCPUCacheMode indicated by the NSNumber associated with this string.
84    ///
85    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiontexturecpucachemode?language=objc)
86    pub static MTKTextureLoaderOptionTextureCPUCacheMode: &'static MTKTextureLoaderOption;
87}
88
89extern "C" {
90    /// Identifier to be used with an NSNumber specifying the MTLStorageMode
91    ///
92    /// The resulting Metal texture will be created with the MTLStorageMode indicated by the NSNumber associated with this string. If this option is omitted, the texture will be created with the default storage mode for Metal textures: MTLStorageModeShared on iOS, and MTLStorageModeManaged on OS X. Specifying this option with MTLTextureStorageModePrivate cause the MTKTextureLoader to submit work to the GPU on behalf of the caller.
93    ///
94    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiontexturestoragemode?language=objc)
95    pub static MTKTextureLoaderOptionTextureStorageMode: &'static MTKTextureLoaderOption;
96}
97
98/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadercubelayout?language=objc)
99// NS_TYPED_ENUM
100pub type MTKTextureLoaderCubeLayout = NSString;
101
102extern "C" {
103    /// Identifier to be used in an options NSDictionary with an MTKTextureLoaderCubeLayout NSString specifying whether to create a cubemap from a 2D image
104    ///
105    /// The NSString value specified with this string must be one option of MTKTextureLoaderCubeLayout. If this option is omitted, the texture loader will not create cubemaps from 2D textures. This option cannot be used with PVR files, KTX files, or MDLTextures, which support cube textures directly.
106    ///
107    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptioncubelayout?language=objc)
108    pub static MTKTextureLoaderOptionCubeLayout: &'static MTKTextureLoaderOption;
109}
110
111extern "C" {
112    /// Identifier specifying that the texture loader will create a cube texture from six faces arranged vertically within a single 2D image
113    ///
114    /// A texture cube will be created from six faces arranged vertically within a single 2D image. The image height must be six times the image width, with faces arranged in the following order from top to bottom: +X, -X, +Y, -Y, +Z, -Z.
115    ///
116    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadercubelayoutvertical?language=objc)
117    pub static MTKTextureLoaderCubeLayoutVertical: &'static MTKTextureLoaderCubeLayout;
118}
119
120/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderorigin?language=objc)
121// NS_TYPED_ENUM
122pub type MTKTextureLoaderOrigin = NSString;
123
124extern "C" {
125    /// Identifier to be used in an options NSDictionary with an MTKTextureLoaderOrigin NSString specifying whether to flip textures vertically
126    ///
127    /// The NSString value specified with this string must be one option of MTKTextureLoaderOrigin. If this option is omitted, the texture loader will not flip loaded textures. This option cannot be used with block-compressed texture formats, and can only be used with 2D, 2D array, and cube map textures. Each mipmap level and slice of a texture will be flipped.
128    ///
129    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionorigin?language=objc)
130    pub static MTKTextureLoaderOptionOrigin: &'static MTKTextureLoaderOption;
131}
132
133extern "C" {
134    /// Identifier specifying that the texture loader should flip textures whose origin is in the bottom-left corner
135    ///
136    /// The texture will be flipped vertically if metadata in the file being loaded indicates that the source data starts with the bottom-left corner of the texture.
137    ///
138    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderorigintopleft?language=objc)
139    pub static MTKTextureLoaderOriginTopLeft: &'static MTKTextureLoaderOrigin;
140}
141
142extern "C" {
143    /// Identifier specifying that the texture loader should flip textures whose origin is in the top-left corner
144    ///
145    /// The texture will be flipped vertically if metadata in the file being loaded indicates that the source data starts with the top-left corner of the texture.
146    ///
147    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoriginbottomleft?language=objc)
148    pub static MTKTextureLoaderOriginBottomLeft: &'static MTKTextureLoaderOrigin;
149}
150
151extern "C" {
152    /// Identifier specifying that the texture loader should always flip textures
153    ///
154    /// The texture will be flipped vertically regardless of any metadata in the file indicating the placement of the origin in the source data
155    ///
156    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoriginflippedvertically?language=objc)
157    pub static MTKTextureLoaderOriginFlippedVertically: &'static MTKTextureLoaderOrigin;
158}
159
160extern "C" {
161    /// Identifier specifying that the texture should be loaded as an array texture when possible.
162    ///
163    /// Type is an NSNumber with a boolean value.
164    ///
165    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionloadasarray?language=objc)
166    pub static MTKTextureLoaderOptionLoadAsArray: &'static MTKTextureLoaderOption;
167}
168
169/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadercallback?language=objc)
170#[cfg(feature = "block2")]
171pub type MTKTextureLoaderCallback =
172    *mut block2::DynBlock<dyn Fn(*mut ProtocolObject<dyn MTLTexture>, *mut NSError)>;
173
174/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderarraycallback?language=objc)
175#[cfg(feature = "block2")]
176pub type MTKTextureLoaderArrayCallback =
177    *mut block2::DynBlock<dyn Fn(NonNull<NSArray<ProtocolObject<dyn MTLTexture>>>, *mut NSError)>;
178
179extern_class!(
180    /// Load Metal textures from files with the device specified at initialization
181    ///
182    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloader?language=objc)
183    #[unsafe(super(NSObject))]
184    #[derive(Debug, PartialEq, Eq, Hash)]
185    pub struct MTKTextureLoader;
186);
187
188extern_conformance!(
189    unsafe impl NSObjectProtocol for MTKTextureLoader {}
190);
191
192impl MTKTextureLoader {
193    extern_methods!(
194        /// Metal device with which to create Metal textures
195        #[unsafe(method(device))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
198
199        #[unsafe(method(init))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
202
203        /// Initialize the loader
204        ///
205        /// Parameter `device`: Metal device with which to create Metal textures
206        #[unsafe(method(initWithDevice:))]
207        #[unsafe(method_family = init)]
208        pub unsafe fn initWithDevice(
209            this: Allocated<Self>,
210            device: &ProtocolObject<dyn MTLDevice>,
211        ) -> Retained<Self>;
212
213        #[cfg(feature = "block2")]
214        /// Asynchronously create a Metal texture and load image data from the file at URL
215        ///
216        /// Parameter `URL`: Location of image file from which to create the texture
217        ///
218        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
219        ///
220        /// Parameter `completionHandler`: Block called when the texture has been loaded and fully initialized
221        #[unsafe(method(newTextureWithContentsOfURL:options:completionHandler:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn newTextureWithContentsOfURL_options_completionHandler(
224            &self,
225            url: &NSURL,
226            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
227            completion_handler: MTKTextureLoaderCallback,
228        );
229
230        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
231        /// Asynchronously create a Metal texture and load image data from a given texture or image
232        /// asset name
233        ///
234        /// Parameter `name`: A texture or image asset name
235        ///
236        /// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog.  Typically the
237        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
238        ///
239        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
240        ///
241        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
242        /// to load a texture asset but can be used when creating a texture from an image asset:
243        /// MTKTextureLoaderOptionGenerateMipmaps
244        /// MTKTextureLoaderOptionSRGB
245        /// MTKTextureLoaderOptionCubeFromVerticalTexture
246        /// MTKTextureLoaderOptionOrigin
247        ///
248        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
249        ///
250        /// Uses texture data from version of the texture from the texture set in the asset catalog
251        /// which mathces the device's traits.
252        /// This method attempts to load a texture asset with thw name iven.  If a texture asset
253        /// with the name given does not exist, it will attempt to create a texture from an
254        /// image asset with the given name
255        #[unsafe(method(newTextureWithName:scaleFactor:bundle:options:completionHandler:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn newTextureWithName_scaleFactor_bundle_options_completionHandler(
258            &self,
259            name: &NSString,
260            scale_factor: CGFloat,
261            bundle: Option<&NSBundle>,
262            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
263            completion_handler: MTKTextureLoaderCallback,
264        );
265
266        #[cfg(all(
267            feature = "block2",
268            feature = "objc2-app-kit",
269            feature = "objc2-core-foundation"
270        ))]
271        #[cfg(target_os = "macos")]
272        /// Asynchronously create a Metal texture and load image data from a given texture or image
273        /// asset name
274        ///
275        /// Parameter `name`: A texture or image asset name
276        ///
277        /// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog.  Typically the
278        /// value retrieved from -[NSWindow backingScaleFactor].
279        ///
280        /// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode.  You'd typically
281        /// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
282        /// and pass that value here if it returns YES.
283        ///
284        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
285        ///
286        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
287        /// to load a texture asset but can be used when creating a texture from an image asset:
288        /// MTKTextureLoaderOptionGenerateMipmaps
289        /// MTKTextureLoaderOptionSRGB
290        /// MTKTextureLoaderOptionCubeFromVerticalTexture
291        /// MTKTextureLoaderOptionOrigin
292        ///
293        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
294        ///
295        /// Uses texture data from version of the texture from the texture set in the asset catalog
296        /// which mathces the device's traits.
297        /// This method attempts to load a texture asset with the name given.  If a texture asset
298        /// with the name given does not exist, it will attempt to create a texture from an
299        /// image asset with the given name.
300        /// This method can be used on macOS to choose between sRGB and P3 versions of a texture
301        /// asset depending on the gamut of the display rendered to.
302        #[unsafe(method(newTextureWithName:scaleFactor:displayGamut:bundle:options:completionHandler:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn newTextureWithName_scaleFactor_displayGamut_bundle_options_completionHandler(
305            &self,
306            name: &NSString,
307            scale_factor: CGFloat,
308            display_gamut: NSDisplayGamut,
309            bundle: Option<&NSBundle>,
310            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
311            completion_handler: MTKTextureLoaderCallback,
312        );
313
314        #[cfg(feature = "block2")]
315        /// Asynchronously create an array of Metal textures and load image data from the files at URLs
316        ///
317        /// Parameter `URLs`: Locations of image files from which to create the textures
318        ///
319        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions, which will be used for every texture loaded
320        ///
321        /// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully initialized. The array of MTLTextures will be the same length and in the same order as the requested array of paths. If an error occurs while loading a texture, the corresponding array index will contain NSNull. The NSError will be null if all of the textures are loaded successfully, or will correspond to one of the textures which failed to load.
322        #[unsafe(method(newTexturesWithContentsOfURLs:options:completionHandler:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn newTexturesWithContentsOfURLs_options_completionHandler(
325            &self,
326            ur_ls: &NSArray<NSURL>,
327            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
328            completion_handler: MTKTextureLoaderArrayCallback,
329        );
330
331        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
332        /// Asynchronously create Metal textures and load image data from a given texture or image
333        /// asset names
334        ///
335        /// Parameter `names`: An array texture or image asset names.  If an error occurs while loading a texture,
336        /// the corresponding index in the returned array contain [NSNull null]
337        ///
338        /// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog.  Typically the
339        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
340        ///
341        /// Parameter `bundle`: Resource bundle in which the assets are located.  Main bundle used if nil.
342        ///
343        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
344        /// to load a texture asset but can be used when creating a texture from an image asset
345        /// MTKTextureLoaderOptionGenerateMipmaps
346        /// MTKTextureLoaderOptionSRGB
347        /// MTKTextureLoaderOptionCubeFromVerticalTexture
348        /// MTKTextureLoaderOptionOrigin
349        ///
350        /// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully
351        /// initialized. The NSError will be null if all of the textures are loaded
352        /// successfully, or will correspond to one of the textures which failed to
353        /// load.
354        ///
355        /// Uses texture data from version of the texture from the texture set in the asset catalog
356        /// which mathces the device's traits.
357        /// This method attempts to load a texture asset with each name iven.  If a texture asset
358        /// with the name given does not exist, it will attempt to create a texture from an
359        /// image asset with the given name.
360        #[unsafe(method(newTexturesWithNames:scaleFactor:bundle:options:completionHandler:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn newTexturesWithNames_scaleFactor_bundle_options_completionHandler(
363            &self,
364            names: &NSArray<NSString>,
365            scale_factor: CGFloat,
366            bundle: Option<&NSBundle>,
367            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
368            completion_handler: MTKTextureLoaderArrayCallback,
369        );
370
371        #[cfg(all(
372            feature = "block2",
373            feature = "objc2-app-kit",
374            feature = "objc2-core-foundation"
375        ))]
376        #[cfg(target_os = "macos")]
377        /// Asynchronously create Metal textures and load image data from given texture or image
378        /// asset names
379        ///
380        /// Parameter `names`: An array texture or image asset names.  If an error occurs while loading a texture,
381        /// the corresponding index in the returned array contain [NSNull null]
382        ///
383        /// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog.  Typically the
384        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor]
385        ///
386        /// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode.  You'd typically
387        /// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
388        /// and pass that value here if it returns YES.
389        ///
390        /// Parameter `bundle`: Resource bundle in which the assets are located
391        ///
392        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
393        /// to load a texture asset but can be used when creating a texture from an image asset
394        /// MTKTextureLoaderOptionGenerateMipmaps
395        /// MTKTextureLoaderOptionSRGB
396        /// MTKTextureLoaderOptionCubeFromVerticalTexture
397        /// MTKTextureLoaderOptionOrigin
398        ///
399        /// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully
400        /// initialized. The NSError will be nif if all of the textures are loaded
401        /// successfully, or will correspond to one of the textures which failed to
402        /// load.
403        ///
404        /// Uses texture data from version of the texture from the texture sets in the asset catalog
405        /// which mathces the device's traits.
406        /// This method attempts to load a texture asset with each name given.  If a texture asset
407        /// with the name given does not exist, it will attempt to create a texture from an
408        /// image asset with the given name.
409        /// This method can be used on macOS to choose between sRGB and P3 versions of a texture
410        /// asset depending on the gamut of the display rendered to,
411        /// If a texture with a name fails to load, the correposding index in the returned array
412        /// will be set to [NSNull null].  An error will also be set.  Thus, if there is a failure
413        /// to load a texture with a name, other names may succesfully be loaded.  Also, a set
414        /// error does not necessarily mean all textures in the names array have failed to load.
415        #[unsafe(method(newTexturesWithNames:scaleFactor:displayGamut:bundle:options:completionHandler:))]
416        #[unsafe(method_family = none)]
417        pub unsafe fn newTexturesWithNames_scaleFactor_displayGamut_bundle_options_completionHandler(
418            &self,
419            names: &NSArray<NSString>,
420            scale_factor: CGFloat,
421            display_gamut: NSDisplayGamut,
422            bundle: Option<&NSBundle>,
423            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
424            completion_handler: MTKTextureLoaderArrayCallback,
425        );
426
427        #[cfg(feature = "block2")]
428        /// Asynchronously create a Metal texture and load image data from the NSData object provided
429        ///
430        /// Parameter `data`: NSData object containing image file data from which to create the texture
431        ///
432        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
433        ///
434        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
435        #[unsafe(method(newTextureWithData:options:completionHandler:))]
436        #[unsafe(method_family = none)]
437        pub unsafe fn newTextureWithData_options_completionHandler(
438            &self,
439            data: &NSData,
440            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
441            completion_handler: MTKTextureLoaderCallback,
442        );
443
444        #[cfg(all(feature = "block2", feature = "objc2-core-graphics"))]
445        /// Asynchronously create a Metal texture and load image data from the given CGImageRef
446        ///
447        /// Parameter `cgImage`: CGImageRef containing image data from which to create the texture
448        ///
449        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
450        ///
451        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
452        #[unsafe(method(newTextureWithCGImage:options:completionHandler:))]
453        #[unsafe(method_family = none)]
454        pub unsafe fn newTextureWithCGImage_options_completionHandler(
455            &self,
456            cg_image: &CGImage,
457            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
458            completion_handler: MTKTextureLoaderCallback,
459        );
460
461        #[cfg(all(feature = "block2", feature = "objc2-model-io"))]
462        /// Asynchronously create a Metal texture and load image data from the given MDLTexture
463        ///
464        /// Parameter `texture`: MDLTexture containing image data from which to create the texture
465        ///
466        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
467        ///
468        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
469        #[unsafe(method(newTextureWithMDLTexture:options:completionHandler:))]
470        #[unsafe(method_family = none)]
471        pub unsafe fn newTextureWithMDLTexture_options_completionHandler(
472            &self,
473            texture: &MDLTexture,
474            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
475            completion_handler: MTKTextureLoaderCallback,
476        );
477
478        /// Synchronously create a Metal texture and load image data from the file at URL
479        ///
480        /// Returns: The Metal texture. nil if an error occured
481        ///
482        /// Parameter `URL`: Location of image file from which to create the texture
483        ///
484        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
485        ///
486        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
487        #[unsafe(method(newTextureWithContentsOfURL:options:error:_))]
488        #[unsafe(method_family = new)]
489        pub unsafe fn newTextureWithContentsOfURL_options_error(
490            &self,
491            url: &NSURL,
492            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
493        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
494
495        /// Synchronously create a Metal texture and load image data from the NSData object provided
496        ///
497        /// Returns: The Metal texture. nil if an error occured
498        ///
499        /// Parameter `data`: NSData object containing image file data from which to create the texture
500        ///
501        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
502        ///
503        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
504        #[unsafe(method(newTextureWithData:options:error:_))]
505        #[unsafe(method_family = new)]
506        pub unsafe fn newTextureWithData_options_error(
507            &self,
508            data: &NSData,
509            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
510        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
511
512        #[cfg(feature = "objc2-core-graphics")]
513        /// Synchronously create a Metal texture and load image data from the given CGImageRef
514        ///
515        /// Returns: The Metal texture. nil if an error occured
516        ///
517        /// Parameter `cgImage`: CGImageRef containing image data from which to create the texture
518        ///
519        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
520        ///
521        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
522        #[unsafe(method(newTextureWithCGImage:options:error:_))]
523        #[unsafe(method_family = new)]
524        pub unsafe fn newTextureWithCGImage_options_error(
525            &self,
526            cg_image: &CGImage,
527            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
528        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
529
530        #[cfg(feature = "objc2-model-io")]
531        /// Synchronously create a Metal texture and load image data from the given MDLTexture
532        ///
533        /// Returns: The Metal texture. nil if an error occured
534        ///
535        /// Parameter `texture`: MDLTexture containing image data from which to create the texture
536        ///
537        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
538        ///
539        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
540        #[unsafe(method(newTextureWithMDLTexture:options:error:_))]
541        #[unsafe(method_family = new)]
542        pub unsafe fn newTextureWithMDLTexture_options_error(
543            &self,
544            texture: &MDLTexture,
545            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
546        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
547
548        #[cfg(feature = "objc2-core-foundation")]
549        /// Synchronously create a Metal texture with texture data from a given texture or image
550        /// asset name
551        ///
552        /// Returns: The Metal texture. nil if an error occured
553        ///
554        /// Parameter `names`: An array of texture asset names
555        ///
556        /// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog.  Typically the
557        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
558        ///
559        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
560        ///
561        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
562        /// to load a texture asset but can be used when creating a texture from an image asset
563        /// MTKTextureLoaderOptionGenerateMipmaps
564        /// MTKTextureLoaderOptionSRGB
565        /// MTKTextureLoaderOptionCubeFromVerticalTexture
566        /// MTKTextureLoaderOptionOrigins
567        ///
568        /// Uses texture data from version of the texture from the texture set in the asset catalog
569        /// which mathces the device's traits.
570        /// This method attempts to load a texture asset with the name given.  If a texture asset
571        /// with the name given does not exist, it will attempt to create a texture from an
572        /// image asset with the given name.
573        #[unsafe(method(newTextureWithName:scaleFactor:bundle:options:error:_))]
574        #[unsafe(method_family = new)]
575        pub unsafe fn newTextureWithName_scaleFactor_bundle_options_error(
576            &self,
577            name: &NSString,
578            scale_factor: CGFloat,
579            bundle: Option<&NSBundle>,
580            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
581        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
582
583        #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
584        #[cfg(target_os = "macos")]
585        /// Synchronously create a Metal texture with texture data from a given texture or image
586        /// asset name
587        ///
588        /// Returns: The Metal texture. nil if an error occured
589        ///
590        /// Parameter `names`: An array of texture asset names
591        ///
592        /// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog.  Typically the
593        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
594        ///
595        /// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode.  You'd typically
596        /// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
597        /// and pass that value here if it returns YES.
598        ///
599        /// Parameter `bundle`: Resource bundle in which the assets are located
600        ///
601        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
602        ///
603        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
604        /// to load a texture asset but can be used when creating a texture from an image asset
605        /// MTKTextureLoaderOptionGenerateMipmaps
606        /// MTKTextureLoaderOptionSRGB
607        /// MTKTextureLoaderOptionCubeFromVerticalTexture
608        /// MTKTextureLoaderOptionOrigin
609        ///
610        /// Uses texture data from version of the texture from the texture set in the asset catalog
611        /// which mathces the device's traits.
612        /// This method attempts to load a texture asset with the name given.  If a texture asset
613        /// with the name given does not exist, it will attempt to create a texture from an
614        /// image asset with the given name.
615        /// This method can be used on macOS to choose between sRGB and P3 versions of a texture
616        /// asset depending on the gamut of the display rendered to.
617        #[unsafe(method(newTextureWithName:scaleFactor:displayGamut:bundle:options:error:_))]
618        #[unsafe(method_family = new)]
619        pub unsafe fn newTextureWithName_scaleFactor_displayGamut_bundle_options_error(
620            &self,
621            name: &NSString,
622            scale_factor: CGFloat,
623            display_gamut: NSDisplayGamut,
624            bundle: Option<&NSBundle>,
625            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
626        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
627    );
628}
629
630/// Methods declared on superclass `NSObject`.
631impl MTKTextureLoader {
632    extern_methods!(
633        #[unsafe(method(new))]
634        #[unsafe(method_family = new)]
635        pub unsafe fn new() -> Retained<Self>;
636    );
637}