objc2_metal_kit/generated/MTKTextureLoader.rs
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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;
use objc2_metal::*;
#[cfg(feature = "objc2-model-io")]
use objc2_model_io::*;
use crate::*;
/// MTKTextureLoaderErrors
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadererror?language=objc)
// NS_TYPED_ENUM
pub type MTKTextureLoaderError = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadererrordomain?language=objc)
pub static MTKTextureLoaderErrorDomain: &'static MTKTextureLoaderError;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadererrorkey?language=objc)
pub static MTKTextureLoaderErrorKey: &'static MTKTextureLoaderError;
}
/// MTKTextureLoaderOptions
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoption?language=objc)
// NS_TYPED_ENUM
pub type MTKTextureLoaderOption = NSString;
extern "C" {
/// Identifier to be used in an options NSDictionary with a boolean NSNumber specifying whether to allocate memory for mipmaps when creating the texture
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionallocatemipmaps?language=objc)
pub static MTKTextureLoaderOptionAllocateMipmaps: &'static MTKTextureLoaderOption;
}
extern "C" {
/// Identifier to be used in an options NSDictionary with a boolean NSNumber specifying whether to generate mipmaps when creating the texture
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiongeneratemipmaps?language=objc)
pub static MTKTextureLoaderOptionGenerateMipmaps: &'static MTKTextureLoaderOption;
}
extern "C" {
/// 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
///
/// 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.
///
/// Warning: When deploying to OS's prior to macOS 10.15 / iOS 13.0, this option is ignored for loading KTX textures.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionsrgb?language=objc)
pub static MTKTextureLoaderOptionSRGB: &'static MTKTextureLoaderOption;
}
extern "C" {
/// Identifier to be used with an NSNumber specifying the MTLTextureUsage flags
///
/// The resulting Metal texture will be created with the MTLTextureUsage flags indicated by the NSNumber associated with this string.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiontextureusage?language=objc)
pub static MTKTextureLoaderOptionTextureUsage: &'static MTKTextureLoaderOption;
}
extern "C" {
/// Identifier to be used with an NSNumber specifying the MTLCPUCacheMode
///
/// The resulting Metal texture will be created with the MTLCPUCacheMode indicated by the NSNumber associated with this string.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiontexturecpucachemode?language=objc)
pub static MTKTextureLoaderOptionTextureCPUCacheMode: &'static MTKTextureLoaderOption;
}
extern "C" {
/// Identifier to be used with an NSNumber specifying the MTLStorageMode
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptiontexturestoragemode?language=objc)
pub static MTKTextureLoaderOptionTextureStorageMode: &'static MTKTextureLoaderOption;
}
/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadercubelayout?language=objc)
// NS_TYPED_ENUM
pub type MTKTextureLoaderCubeLayout = NSString;
extern "C" {
/// Identifier to be used in an options NSDictionary with an MTKTextureLoaderCubeLayout NSString specifying whether to create a cubemap from a 2D image
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptioncubelayout?language=objc)
pub static MTKTextureLoaderOptionCubeLayout: &'static MTKTextureLoaderOption;
}
extern "C" {
/// Identifier specifying that the texture loader will create a cube texture from six faces arranged vertically within a single 2D image
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadercubelayoutvertical?language=objc)
pub static MTKTextureLoaderCubeLayoutVertical: &'static MTKTextureLoaderCubeLayout;
}
/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderorigin?language=objc)
// NS_TYPED_ENUM
pub type MTKTextureLoaderOrigin = NSString;
extern "C" {
/// Identifier to be used in an options NSDictionary with an MTKTextureLoaderOrigin NSString specifying whether to flip textures vertically
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionorigin?language=objc)
pub static MTKTextureLoaderOptionOrigin: &'static MTKTextureLoaderOption;
}
extern "C" {
/// Identifier specifying that the texture loader should flip textures whose origin is in the bottom-left corner
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderorigintopleft?language=objc)
pub static MTKTextureLoaderOriginTopLeft: &'static MTKTextureLoaderOrigin;
}
extern "C" {
/// Identifier specifying that the texture loader should flip textures whose origin is in the top-left corner
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoriginbottomleft?language=objc)
pub static MTKTextureLoaderOriginBottomLeft: &'static MTKTextureLoaderOrigin;
}
extern "C" {
/// Identifier specifying that the texture loader should always flip textures
///
/// The texture will be flipped vertically regardless of any metadata in the file indicating the placement of the origin in the source data
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoriginflippedvertically?language=objc)
pub static MTKTextureLoaderOriginFlippedVertically: &'static MTKTextureLoaderOrigin;
}
extern "C" {
/// Identifier specifying that the texture should be loaded as an array texture when possible.
///
/// Type is an NSNumber with a boolean value.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderoptionloadasarray?language=objc)
pub static MTKTextureLoaderOptionLoadAsArray: &'static MTKTextureLoaderOption;
}
/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloadercallback?language=objc)
#[cfg(feature = "block2")]
pub type MTKTextureLoaderCallback =
*mut block2::Block<dyn Fn(*mut ProtocolObject<dyn MTLTexture>, *mut NSError)>;
/// [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloaderarraycallback?language=objc)
#[cfg(feature = "block2")]
pub type MTKTextureLoaderArrayCallback =
*mut block2::Block<dyn Fn(NonNull<NSArray<ProtocolObject<dyn MTLTexture>>>, *mut NSError)>;
extern_class!(
/// Load Metal textures from files with the device specified at initialization
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metalkit/mtktextureloader?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTKTextureLoader;
);
unsafe impl NSObjectProtocol for MTKTextureLoader {}
impl MTKTextureLoader {
extern_methods!(
/// Metal device with which to create Metal textures
#[unsafe(method(device))]
#[unsafe(method_family = none)]
pub unsafe fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Initialize the loader
///
/// Parameter `device`: Metal device with which to create Metal textures
#[unsafe(method(initWithDevice:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithDevice(
this: Allocated<Self>,
device: &ProtocolObject<dyn MTLDevice>,
) -> Retained<Self>;
#[cfg(feature = "block2")]
/// Asynchronously create a Metal texture and load image data from the file at URL
///
/// Parameter `URL`: Location of image file from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `completionHandler`: Block called when the texture has been loaded and fully initialized
#[unsafe(method(newTextureWithContentsOfURL:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTextureWithContentsOfURL_options_completionHandler(
&self,
url: &NSURL,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderCallback,
);
#[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
/// Asynchronously create a Metal texture and load image data from a given texture or image
/// asset name
///
/// Parameter `name`: A texture or image asset name
///
/// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog. Typically the
/// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
///
/// Parameter `bundle`: Resource bundle in which the asset is located. Main bundle used if nil.
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
/// to load a texture asset but can be used when creating a texture from an image asset:
/// MTKTextureLoaderOptionGenerateMipmaps
/// MTKTextureLoaderOptionSRGB
/// MTKTextureLoaderOptionCubeFromVerticalTexture
/// MTKTextureLoaderOptionOrigin
///
/// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
///
/// Uses texture data from version of the texture from the texture set in the asset catalog
/// which mathces the device's traits.
/// This method attempts to load a texture asset with thw name iven. If a texture asset
/// with the name given does not exist, it will attempt to create a texture from an
/// image asset with the given name
#[unsafe(method(newTextureWithName:scaleFactor:bundle:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTextureWithName_scaleFactor_bundle_options_completionHandler(
&self,
name: &NSString,
scale_factor: CGFloat,
bundle: Option<&NSBundle>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderCallback,
);
#[cfg(all(
feature = "block2",
feature = "objc2-app-kit",
feature = "objc2-core-foundation"
))]
#[cfg(target_os = "macos")]
/// Asynchronously create a Metal texture and load image data from a given texture or image
/// asset name
///
/// Parameter `name`: A texture or image asset name
///
/// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog. Typically the
/// value retrieved from -[NSWindow backingScaleFactor].
///
/// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode. You'd typically
/// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
/// and pass that value here if it returns YES.
///
/// Parameter `bundle`: Resource bundle in which the asset is located. Main bundle used if nil.
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
/// to load a texture asset but can be used when creating a texture from an image asset:
/// MTKTextureLoaderOptionGenerateMipmaps
/// MTKTextureLoaderOptionSRGB
/// MTKTextureLoaderOptionCubeFromVerticalTexture
/// MTKTextureLoaderOptionOrigin
///
/// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
///
/// Uses texture data from version of the texture from the texture set in the asset catalog
/// which mathces the device's traits.
/// This method attempts to load a texture asset with the name given. If a texture asset
/// with the name given does not exist, it will attempt to create a texture from an
/// image asset with the given name.
/// This method can be used on macOS to choose between sRGB and P3 versions of a texture
/// asset depending on the gamut of the display rendered to.
#[unsafe(method(newTextureWithName:scaleFactor:displayGamut:bundle:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTextureWithName_scaleFactor_displayGamut_bundle_options_completionHandler(
&self,
name: &NSString,
scale_factor: CGFloat,
display_gamut: NSDisplayGamut,
bundle: Option<&NSBundle>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderCallback,
);
#[cfg(feature = "block2")]
/// Asynchronously create an array of Metal textures and load image data from the files at URLs
///
/// Parameter `URLs`: Locations of image files from which to create the textures
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions, which will be used for every texture loaded
///
/// 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.
#[unsafe(method(newTexturesWithContentsOfURLs:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTexturesWithContentsOfURLs_options_completionHandler(
&self,
ur_ls: &NSArray<NSURL>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderArrayCallback,
);
#[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
/// Asynchronously create Metal textures and load image data from a given texture or image
/// asset names
///
/// Parameter `names`: An array texture or image asset names. If an error occurs while loading a texture,
/// the corresponding index in the returned array contain [NSNull null]
///
/// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog. Typically the
/// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
///
/// Parameter `bundle`: Resource bundle in which the assets are located. Main bundle used if nil.
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
/// to load a texture asset but can be used when creating a texture from an image asset
/// MTKTextureLoaderOptionGenerateMipmaps
/// MTKTextureLoaderOptionSRGB
/// MTKTextureLoaderOptionCubeFromVerticalTexture
/// MTKTextureLoaderOptionOrigin
///
/// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully
/// initialized. 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.
///
/// Uses texture data from version of the texture from the texture set in the asset catalog
/// which mathces the device's traits.
/// This method attempts to load a texture asset with each name iven. If a texture asset
/// with the name given does not exist, it will attempt to create a texture from an
/// image asset with the given name.
#[unsafe(method(newTexturesWithNames:scaleFactor:bundle:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTexturesWithNames_scaleFactor_bundle_options_completionHandler(
&self,
names: &NSArray<NSString>,
scale_factor: CGFloat,
bundle: Option<&NSBundle>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderArrayCallback,
);
#[cfg(all(
feature = "block2",
feature = "objc2-app-kit",
feature = "objc2-core-foundation"
))]
#[cfg(target_os = "macos")]
/// Asynchronously create Metal textures and load image data from given texture or image
/// asset names
///
/// Parameter `names`: An array texture or image asset names. If an error occurs while loading a texture,
/// the corresponding index in the returned array contain [NSNull null]
///
/// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog. Typically the
/// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor]
///
/// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode. You'd typically
/// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
/// and pass that value here if it returns YES.
///
/// Parameter `bundle`: Resource bundle in which the assets are located
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
/// to load a texture asset but can be used when creating a texture from an image asset
/// MTKTextureLoaderOptionGenerateMipmaps
/// MTKTextureLoaderOptionSRGB
/// MTKTextureLoaderOptionCubeFromVerticalTexture
/// MTKTextureLoaderOptionOrigin
///
/// Parameter `completionHandler`: Block called when all of the textures have been loaded and fully
/// initialized. The NSError will be nif if all of the textures are loaded
/// successfully, or will correspond to one of the textures which failed to
/// load.
///
/// Uses texture data from version of the texture from the texture sets in the asset catalog
/// which mathces the device's traits.
/// This method attempts to load a texture asset with each name given. If a texture asset
/// with the name given does not exist, it will attempt to create a texture from an
/// image asset with the given name.
/// This method can be used on macOS to choose between sRGB and P3 versions of a texture
/// asset depending on the gamut of the display rendered to,
/// If a texture with a name fails to load, the correposding index in the returned array
/// will be set to [NSNull null]. An error will also be set. Thus, if there is a failure
/// to load a texture with a name, other names may succesfully be loaded. Also, a set
/// error does not necessarily mean all textures in the names array have failed to load.
#[unsafe(method(newTexturesWithNames:scaleFactor:displayGamut:bundle:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTexturesWithNames_scaleFactor_displayGamut_bundle_options_completionHandler(
&self,
names: &NSArray<NSString>,
scale_factor: CGFloat,
display_gamut: NSDisplayGamut,
bundle: Option<&NSBundle>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderArrayCallback,
);
#[cfg(feature = "block2")]
/// Asynchronously create a Metal texture and load image data from the NSData object provided
///
/// Parameter `data`: NSData object containing image file data from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
#[unsafe(method(newTextureWithData:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTextureWithData_options_completionHandler(
&self,
data: &NSData,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderCallback,
);
#[cfg(all(feature = "block2", feature = "objc2-core-graphics"))]
/// Asynchronously create a Metal texture and load image data from the given CGImageRef
///
/// Parameter `cgImage`: CGImageRef containing image data from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
#[unsafe(method(newTextureWithCGImage:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTextureWithCGImage_options_completionHandler(
&self,
cg_image: &CGImage,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderCallback,
);
#[cfg(all(feature = "block2", feature = "objc2-model-io"))]
/// Asynchronously create a Metal texture and load image data from the given MDLTexture
///
/// Parameter `texture`: MDLTexture containing image data from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `completionHandler`: Block called when texture has been loaded and fully initialized
#[unsafe(method(newTextureWithMDLTexture:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn newTextureWithMDLTexture_options_completionHandler(
&self,
texture: &MDLTexture,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
completion_handler: MTKTextureLoaderCallback,
);
/// Synchronously create a Metal texture and load image data from the file at URL
///
/// Returns: The Metal texture. nil if an error occured
///
/// Parameter `URL`: Location of image file from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
#[unsafe(method(newTextureWithContentsOfURL:options:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newTextureWithContentsOfURL_options_error(
&self,
url: &NSURL,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
/// Synchronously create a Metal texture and load image data from the NSData object provided
///
/// Returns: The Metal texture. nil if an error occured
///
/// Parameter `data`: NSData object containing image file data from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
#[unsafe(method(newTextureWithData:options:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newTextureWithData_options_error(
&self,
data: &NSData,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
#[cfg(feature = "objc2-core-graphics")]
/// Synchronously create a Metal texture and load image data from the given CGImageRef
///
/// Returns: The Metal texture. nil if an error occured
///
/// Parameter `cgImage`: CGImageRef containing image data from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
#[unsafe(method(newTextureWithCGImage:options:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newTextureWithCGImage_options_error(
&self,
cg_image: &CGImage,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
#[cfg(feature = "objc2-model-io")]
/// Synchronously create a Metal texture and load image data from the given MDLTexture
///
/// Returns: The Metal texture. nil if an error occured
///
/// Parameter `texture`: MDLTexture containing image data from which to create the texture
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions
///
/// Parameter `error`: Pointer to an autoreleased NSError object which will be set if an error occurred
#[unsafe(method(newTextureWithMDLTexture:options:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newTextureWithMDLTexture_options_error(
&self,
texture: &MDLTexture,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
#[cfg(feature = "objc2-core-foundation")]
/// Synchronously create a Metal texture with texture data from a given texture or image
/// asset name
///
/// Returns: The Metal texture. nil if an error occured
///
/// Parameter `names`: An array of texture asset names
///
/// Parameter `scaleFactor`: scale factor of the texture to retrieve from the asset catalog. Typically the
/// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
///
/// Parameter `bundle`: Resource bundle in which the asset is located. Main bundle used if nil.
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
/// to load a texture asset but can be used when creating a texture from an image asset
/// MTKTextureLoaderOptionGenerateMipmaps
/// MTKTextureLoaderOptionSRGB
/// MTKTextureLoaderOptionCubeFromVerticalTexture
/// MTKTextureLoaderOptionOrigins
///
/// Uses texture data from version of the texture from the texture set in the asset catalog
/// which mathces the device's traits.
/// This method attempts to load a texture asset with the name given. If a texture asset
/// with the name given does not exist, it will attempt to create a texture from an
/// image asset with the given name.
#[unsafe(method(newTextureWithName:scaleFactor:bundle:options:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newTextureWithName_scaleFactor_bundle_options_error(
&self,
name: &NSString,
scale_factor: CGFloat,
bundle: Option<&NSBundle>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
#[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
#[cfg(target_os = "macos")]
/// Synchronously create a Metal texture with texture data from a given texture or image
/// asset name
///
/// Returns: The Metal texture. nil if an error occured
///
/// Parameter `names`: An array of texture asset names
///
/// Parameter `scaleFactor`: Scale factor of the texture to retrieve from the asset catalog. Typically the
/// value retrieved from -[UIView contentScale] or -[NSWindow backingScaleFactor].
///
/// Parameter `displayGamut`: Version of the texture based upon the "Gamut" trait in Xcode. You'd typically
/// check -[NSWindow canRepresentDisplayGamut:] with the widest NSDisplayGamut value
/// and pass that value here if it returns YES.
///
/// Parameter `bundle`: Resource bundle in which the assets are located
///
/// Parameter `bundle`: Resource bundle in which the asset is located. Main bundle used if nil.
///
/// Parameter `options`: Dictonary of MTKTextureLoaderOptions. The following options are ignormed when used
/// to load a texture asset but can be used when creating a texture from an image asset
/// MTKTextureLoaderOptionGenerateMipmaps
/// MTKTextureLoaderOptionSRGB
/// MTKTextureLoaderOptionCubeFromVerticalTexture
/// MTKTextureLoaderOptionOrigin
///
/// Uses texture data from version of the texture from the texture set in the asset catalog
/// which mathces the device's traits.
/// This method attempts to load a texture asset with the name given. If a texture asset
/// with the name given does not exist, it will attempt to create a texture from an
/// image asset with the given name.
/// This method can be used on macOS to choose between sRGB and P3 versions of a texture
/// asset depending on the gamut of the display rendered to.
#[unsafe(method(newTextureWithName:scaleFactor:displayGamut:bundle:options:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newTextureWithName_scaleFactor_displayGamut_bundle_options_error(
&self,
name: &NSString,
scale_factor: CGFloat,
display_gamut: NSDisplayGamut,
bundle: Option<&NSBundle>,
options: Option<&NSDictionary<MTKTextureLoaderOption, AnyObject>>,
) -> Result<Retained<ProtocolObject<dyn MTLTexture>>, Retained<NSError>>;
);
}
/// Methods declared on superclass `NSObject`.
impl MTKTextureLoader {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}