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 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 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        ///
222        /// # Safety
223        ///
224        /// - `options` generic should be of the correct type.
225        /// - `completion_handler` must be a valid pointer.
226        #[unsafe(method(newTextureWithContentsOfURL:options:completionHandler:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn newTextureWithContentsOfURL_options_completionHandler(
229            &self,
230            url: &NSURL,
231            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
232            completion_handler: MTKTextureLoaderCallback,
233        );
234
235        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
236        /// Asynchronously create a Metal texture and load image data from a given texture or image
237        /// asset name
238        ///
239        /// Parameter `name`: A texture or image asset name
240        ///
241        /// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog.  Typically the
242        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
243        ///
244        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
245        ///
246        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
247        /// to load a texture asset but can be used when creating a texture from an image asset:
248        /// MTKTextureLoaderOptionGenerateMipmaps
249        /// MTKTextureLoaderOptionSRGB
250        /// MTKTextureLoaderOptionCubeFromVerticalTexture
251        /// MTKTextureLoaderOptionOrigin
252        ///
253        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
254        ///
255        /// Uses texture data from version of the texture from the texture set in the asset catalog
256        /// which mathces the device's traits.
257        /// This method attempts to load a texture asset with thw name iven.  If a texture asset
258        /// with the name given does not exist, it will attempt to create a texture from an
259        /// image asset with the given name
260        ///
261        /// # Safety
262        ///
263        /// - `options` generic should be of the correct type.
264        /// - `completion_handler` must be a valid pointer.
265        #[unsafe(method(newTextureWithName:scaleFactor:bundle:options:completionHandler:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn newTextureWithName_scaleFactor_bundle_options_completionHandler(
268            &self,
269            name: &NSString,
270            scale_factor: CGFloat,
271            bundle: Option<&NSBundle>,
272            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
273            completion_handler: MTKTextureLoaderCallback,
274        );
275
276        #[cfg(all(
277            feature = "block2",
278            feature = "objc2-app-kit",
279            feature = "objc2-core-foundation"
280        ))]
281        #[cfg(target_os = "macos")]
282        /// Asynchronously create a Metal texture and load image data from a given texture or image
283        /// asset name
284        ///
285        /// Parameter `name`: A texture or image asset name
286        ///
287        /// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog.  Typically the
288        /// value retrieved from -[NSWindow backingScaleFactor].
289        ///
290        /// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode.  You'd typically
291        /// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
292        /// and pass that value here if it returns YES.
293        ///
294        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
295        ///
296        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
297        /// to load a texture asset but can be used when creating a texture from an image asset:
298        /// MTKTextureLoaderOptionGenerateMipmaps
299        /// MTKTextureLoaderOptionSRGB
300        /// MTKTextureLoaderOptionCubeFromVerticalTexture
301        /// MTKTextureLoaderOptionOrigin
302        ///
303        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
304        ///
305        /// Uses texture data from version of the texture from the texture set in the asset catalog
306        /// which mathces the device's traits.
307        /// This method attempts to load a texture asset with the name given.  If a texture asset
308        /// with the name given does not exist, it will attempt to create a texture from an
309        /// image asset with the given name.
310        /// This method can be used on macOS to choose between sRGB and P3 versions of a texture
311        /// asset depending on the gamut of the display rendered to.
312        ///
313        /// # Safety
314        ///
315        /// - `options` generic should be of the correct type.
316        /// - `completion_handler` must be a valid pointer.
317        #[unsafe(method(newTextureWithName:scaleFactor:displayGamut:bundle:options:completionHandler:))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn newTextureWithName_scaleFactor_displayGamut_bundle_options_completionHandler(
320            &self,
321            name: &NSString,
322            scale_factor: CGFloat,
323            display_gamut: NSDisplayGamut,
324            bundle: Option<&NSBundle>,
325            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
326            completion_handler: MTKTextureLoaderCallback,
327        );
328
329        #[cfg(feature = "block2")]
330        /// Asynchronously create an array of Metal textures and load image data from the files at URLs
331        ///
332        /// Parameter `URLs`: Locations of image files from which to create the textures
333        ///
334        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions, which will be used for every texture loaded
335        ///
336        /// 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.
337        ///
338        /// # Safety
339        ///
340        /// - `options` generic should be of the correct type.
341        /// - `completion_handler` must be a valid pointer.
342        #[unsafe(method(newTexturesWithContentsOfURLs:options:completionHandler:))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn newTexturesWithContentsOfURLs_options_completionHandler(
345            &self,
346            ur_ls: &NSArray<NSURL>,
347            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
348            completion_handler: MTKTextureLoaderArrayCallback,
349        );
350
351        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
352        /// Asynchronously create Metal textures and load image data from a given texture or image
353        /// asset names
354        ///
355        /// Parameter `names`: An array texture or image asset names.  If an error occurs while loading a texture,
356        /// the corresponding index in the returned array contain [NSNull null]
357        ///
358        /// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog.  Typically the
359        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
360        ///
361        /// Parameter `bundle`: Resource bundle in which the assets are located.  Main bundle used if nil.
362        ///
363        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
364        /// to load a texture asset but can be used when creating a texture from an image asset
365        /// MTKTextureLoaderOptionGenerateMipmaps
366        /// MTKTextureLoaderOptionSRGB
367        /// MTKTextureLoaderOptionCubeFromVerticalTexture
368        /// MTKTextureLoaderOptionOrigin
369        ///
370        /// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully
371        /// initialized. The NSError will be null if all of the textures are loaded
372        /// successfully, or will correspond to one of the textures which failed to
373        /// load.
374        ///
375        /// Uses texture data from version of the texture from the texture set in the asset catalog
376        /// which mathces the device's traits.
377        /// This method attempts to load a texture asset with each name iven.  If a texture asset
378        /// with the name given does not exist, it will attempt to create a texture from an
379        /// image asset with the given name.
380        ///
381        /// # Safety
382        ///
383        /// - `options` generic should be of the correct type.
384        /// - `completion_handler` must be a valid pointer.
385        #[unsafe(method(newTexturesWithNames:scaleFactor:bundle:options:completionHandler:))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn newTexturesWithNames_scaleFactor_bundle_options_completionHandler(
388            &self,
389            names: &NSArray<NSString>,
390            scale_factor: CGFloat,
391            bundle: Option<&NSBundle>,
392            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
393            completion_handler: MTKTextureLoaderArrayCallback,
394        );
395
396        #[cfg(all(
397            feature = "block2",
398            feature = "objc2-app-kit",
399            feature = "objc2-core-foundation"
400        ))]
401        #[cfg(target_os = "macos")]
402        /// Asynchronously create Metal textures and load image data from given texture or image
403        /// asset names
404        ///
405        /// Parameter `names`: An array texture or image asset names.  If an error occurs while loading a texture,
406        /// the corresponding index in the returned array contain [NSNull null]
407        ///
408        /// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog.  Typically the
409        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor]
410        ///
411        /// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode.  You'd typically
412        /// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
413        /// and pass that value here if it returns YES.
414        ///
415        /// Parameter `bundle`: Resource bundle in which the assets are located
416        ///
417        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
418        /// to load a texture asset but can be used when creating a texture from an image asset
419        /// MTKTextureLoaderOptionGenerateMipmaps
420        /// MTKTextureLoaderOptionSRGB
421        /// MTKTextureLoaderOptionCubeFromVerticalTexture
422        /// MTKTextureLoaderOptionOrigin
423        ///
424        /// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully
425        /// initialized. The NSError will be nif if all of the textures are loaded
426        /// successfully, or will correspond to one of the textures which failed to
427        /// load.
428        ///
429        /// Uses texture data from version of the texture from the texture sets in the asset catalog
430        /// which mathces the device's traits.
431        /// This method attempts to load a texture asset with each name given.  If a texture asset
432        /// with the name given does not exist, it will attempt to create a texture from an
433        /// image asset with the given name.
434        /// This method can be used on macOS to choose between sRGB and P3 versions of a texture
435        /// asset depending on the gamut of the display rendered to,
436        /// If a texture with a name fails to load, the correposding index in the returned array
437        /// will be set to [NSNull null].  An error will also be set.  Thus, if there is a failure
438        /// to load a texture with a name, other names may succesfully be loaded.  Also, a set
439        /// error does not necessarily mean all textures in the names array have failed to load.
440        ///
441        /// # Safety
442        ///
443        /// - `options` generic should be of the correct type.
444        /// - `completion_handler` must be a valid pointer.
445        #[unsafe(method(newTexturesWithNames:scaleFactor:displayGamut:bundle:options:completionHandler:))]
446        #[unsafe(method_family = none)]
447        pub unsafe fn newTexturesWithNames_scaleFactor_displayGamut_bundle_options_completionHandler(
448            &self,
449            names: &NSArray<NSString>,
450            scale_factor: CGFloat,
451            display_gamut: NSDisplayGamut,
452            bundle: Option<&NSBundle>,
453            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
454            completion_handler: MTKTextureLoaderArrayCallback,
455        );
456
457        #[cfg(feature = "block2")]
458        /// Asynchronously create a Metal texture and load image data from the NSData object provided
459        ///
460        /// Parameter `data`: NSData object containing image file data from which to create the texture
461        ///
462        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
463        ///
464        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
465        ///
466        /// # Safety
467        ///
468        /// - `options` generic should be of the correct type.
469        /// - `completion_handler` must be a valid pointer.
470        #[unsafe(method(newTextureWithData:options:completionHandler:))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn newTextureWithData_options_completionHandler(
473            &self,
474            data: &NSData,
475            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
476            completion_handler: MTKTextureLoaderCallback,
477        );
478
479        #[cfg(all(feature = "block2", feature = "objc2-core-graphics"))]
480        /// Asynchronously create a Metal texture and load image data from the given CGImageRef
481        ///
482        /// Parameter `cgImage`: CGImageRef containing image data from which to create the texture
483        ///
484        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
485        ///
486        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
487        ///
488        /// # Safety
489        ///
490        /// - `options` generic should be of the correct type.
491        /// - `completion_handler` must be a valid pointer.
492        #[unsafe(method(newTextureWithCGImage:options:completionHandler:))]
493        #[unsafe(method_family = none)]
494        pub unsafe fn newTextureWithCGImage_options_completionHandler(
495            &self,
496            cg_image: &CGImage,
497            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
498            completion_handler: MTKTextureLoaderCallback,
499        );
500
501        #[cfg(all(feature = "block2", feature = "objc2-model-io"))]
502        /// Asynchronously create a Metal texture and load image data from the given MDLTexture
503        ///
504        /// Parameter `texture`: MDLTexture containing image data from which to create the texture
505        ///
506        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
507        ///
508        /// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
509        ///
510        /// # Safety
511        ///
512        /// - `options` generic should be of the correct type.
513        /// - `completion_handler` must be a valid pointer.
514        #[unsafe(method(newTextureWithMDLTexture:options:completionHandler:))]
515        #[unsafe(method_family = none)]
516        pub unsafe fn newTextureWithMDLTexture_options_completionHandler(
517            &self,
518            texture: &MDLTexture,
519            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
520            completion_handler: MTKTextureLoaderCallback,
521        );
522
523        /// Synchronously create a Metal texture and load image data from the file at URL
524        ///
525        /// Returns: The Metal texture. nil if an error occured
526        ///
527        /// Parameter `URL`: Location of image file from which to create the texture
528        ///
529        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
530        ///
531        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
532        ///
533        /// # Safety
534        ///
535        /// `options` generic should be of the correct type.
536        #[unsafe(method(newTextureWithContentsOfURL:options:error:_))]
537        #[unsafe(method_family = new)]
538        pub unsafe fn newTextureWithContentsOfURL_options_error(
539            &self,
540            url: &NSURL,
541            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
542        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
543
544        /// Synchronously create an array of Metal textures and load image data from the files at URLs
545        ///
546        /// Returns: An array of MTLTextures of the same length and in the same order as the requested array of
547        /// paths.  If an error occurs while loading a texture, the corresponding array index will
548        /// contain [NSNull null].
549        ///
550        /// Parameter `URLs`: Locations of image files from which to create the textures
551        ///
552        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions, which will be used for every texture loaded
553        ///
554        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred.
555        /// Will be null if all of the textures are loaded successfully, or will correspond to
556        /// one of the textures which failed to load.
557        ///
558        /// # Safety
559        ///
560        /// `options` generic should be of the correct type.
561        #[unsafe(method(newTexturesWithContentsOfURLs:options:error:))]
562        #[unsafe(method_family = new)]
563        pub unsafe fn newTexturesWithContentsOfURLs_options_error(
564            &self,
565            ur_ls: &NSArray<NSURL>,
566            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
567            error: Option<&mut Option<Retained<NSError>>>,
568        ) -> Retained<NSArray<ProtocolObject<dyn MTLTexture>>>;
569
570        /// Synchronously create a Metal texture and load image data from the NSData object provided
571        ///
572        /// Returns: The Metal texture. nil if an error occured
573        ///
574        /// Parameter `data`: NSData object containing image file data from which to create the texture
575        ///
576        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
577        ///
578        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
579        ///
580        /// # Safety
581        ///
582        /// `options` generic should be of the correct type.
583        #[unsafe(method(newTextureWithData:options:error:_))]
584        #[unsafe(method_family = new)]
585        pub unsafe fn newTextureWithData_options_error(
586            &self,
587            data: &NSData,
588            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
589        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
590
591        #[cfg(feature = "objc2-core-graphics")]
592        /// Synchronously create a Metal texture and load image data from the given CGImageRef
593        ///
594        /// Returns: The Metal texture. nil if an error occured
595        ///
596        /// Parameter `cgImage`: CGImageRef containing image data from which to create the texture
597        ///
598        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
599        ///
600        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
601        ///
602        /// # Safety
603        ///
604        /// `options` generic should be of the correct type.
605        #[unsafe(method(newTextureWithCGImage:options:error:_))]
606        #[unsafe(method_family = new)]
607        pub unsafe fn newTextureWithCGImage_options_error(
608            &self,
609            cg_image: &CGImage,
610            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
611        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
612
613        #[cfg(feature = "objc2-model-io")]
614        /// Synchronously create a Metal texture and load image data from the given MDLTexture
615        ///
616        /// Returns: The Metal texture. nil if an error occured
617        ///
618        /// Parameter `texture`: MDLTexture containing image data from which to create the texture
619        ///
620        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions
621        ///
622        /// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
623        ///
624        /// # Safety
625        ///
626        /// `options` generic should be of the correct type.
627        #[unsafe(method(newTextureWithMDLTexture:options:error:_))]
628        #[unsafe(method_family = new)]
629        pub unsafe fn newTextureWithMDLTexture_options_error(
630            &self,
631            texture: &MDLTexture,
632            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
633        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
634
635        #[cfg(feature = "objc2-core-foundation")]
636        /// Synchronously create a Metal texture with texture data from a given texture or image
637        /// asset name
638        ///
639        /// Returns: The Metal texture. nil if an error occured
640        ///
641        /// Parameter `names`: An array of texture asset names
642        ///
643        /// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog.  Typically the
644        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
645        ///
646        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
647        ///
648        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
649        /// to load a texture asset but can be used when creating a texture from an image asset
650        /// MTKTextureLoaderOptionGenerateMipmaps
651        /// MTKTextureLoaderOptionSRGB
652        /// MTKTextureLoaderOptionCubeFromVerticalTexture
653        /// MTKTextureLoaderOptionOrigins
654        ///
655        /// Uses texture data from version of the texture from the texture set in the asset catalog
656        /// which mathces the device's traits.
657        /// This method attempts to load a texture asset with the name given.  If a texture asset
658        /// with the name given does not exist, it will attempt to create a texture from an
659        /// image asset with the given name.
660        ///
661        /// # Safety
662        ///
663        /// `options` generic should be of the correct type.
664        #[unsafe(method(newTextureWithName:scaleFactor:bundle:options:error:_))]
665        #[unsafe(method_family = new)]
666        pub unsafe fn newTextureWithName_scaleFactor_bundle_options_error(
667            &self,
668            name: &NSString,
669            scale_factor: CGFloat,
670            bundle: Option<&NSBundle>,
671            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
672        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
673
674        #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
675        #[cfg(target_os = "macos")]
676        /// Synchronously create a Metal texture with texture data from a given texture or image
677        /// asset name
678        ///
679        /// Returns: The Metal texture. nil if an error occured
680        ///
681        /// Parameter `names`: An array of texture asset names
682        ///
683        /// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog.  Typically the
684        /// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
685        ///
686        /// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode.  You'd typically
687        /// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
688        /// and pass that value here if it returns YES.
689        ///
690        /// Parameter `bundle`: Resource bundle in which the assets are located
691        ///
692        /// Parameter `bundle`: Resource bundle in which the asset is located.  Main bundle used if nil.
693        ///
694        /// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
695        /// to load a texture asset but can be used when creating a texture from an image asset
696        /// MTKTextureLoaderOptionGenerateMipmaps
697        /// MTKTextureLoaderOptionSRGB
698        /// MTKTextureLoaderOptionCubeFromVerticalTexture
699        /// MTKTextureLoaderOptionOrigin
700        ///
701        /// Uses texture data from version of the texture from the texture set in the asset catalog
702        /// which mathces the device's traits.
703        /// This method attempts to load a texture asset with the name given.  If a texture asset
704        /// with the name given does not exist, it will attempt to create a texture from an
705        /// image asset with the given name.
706        /// This method can be used on macOS to choose between sRGB and P3 versions of a texture
707        /// asset depending on the gamut of the display rendered to.
708        ///
709        /// # Safety
710        ///
711        /// `options` generic should be of the correct type.
712        #[unsafe(method(newTextureWithName:scaleFactor:displayGamut:bundle:options:error:_))]
713        #[unsafe(method_family = new)]
714        pub unsafe fn newTextureWithName_scaleFactor_displayGamut_bundle_options_error(
715            &self,
716            name: &NSString,
717            scale_factor: CGFloat,
718            display_gamut: NSDisplayGamut,
719            bundle: Option<&NSBundle>,
720            options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
721        ) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
722    );
723}
724
725/// Methods declared on superclass `NSObject`.
726impl MTKTextureLoader {
727    extern_methods!(
728        #[unsafe(method(new))]
729        #[unsafe(method_family = new)]
730        pub unsafe fn new() -> Retained<Self>;
731    );
732}