objc2_sprite_kit/generated/
SKTexture.rs1use 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::*;
13#[cfg(feature = "objc2-core-image")]
14#[cfg(not(target_os = "watchos"))]
15use objc2_core_image::*;
16use objc2_foundation::*;
17
18use crate::*;
19
20#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct SKTextureFilteringMode(pub NSInteger);
25impl SKTextureFilteringMode {
26 #[doc(alias = "SKTextureFilteringNearest")]
27 pub const Nearest: Self = Self(0);
28 #[doc(alias = "SKTextureFilteringLinear")]
29 pub const Linear: Self = Self(1);
30}
31
32unsafe impl Encode for SKTextureFilteringMode {
33 const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for SKTextureFilteringMode {
37 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41 #[unsafe(super(NSObject))]
45 #[derive(Debug, PartialEq, Eq, Hash)]
46 pub struct SKTexture;
47);
48
49unsafe impl NSCoding for SKTexture {}
50
51unsafe impl NSCopying for SKTexture {}
52
53unsafe impl CopyingHelper for SKTexture {
54 type Result = Self;
55}
56
57unsafe impl NSObjectProtocol for SKTexture {}
58
59unsafe impl NSSecureCoding for SKTexture {}
60
61impl SKTexture {
62 extern_methods!(
63 #[unsafe(method(textureWithImageNamed:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn textureWithImageNamed(name: &NSString) -> Retained<Self>;
70
71 #[cfg(feature = "objc2-core-foundation")]
72 #[unsafe(method(textureWithRect:inTexture:))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn textureWithRect_inTexture(
81 rect: CGRect,
82 texture: &SKTexture,
83 ) -> Retained<Self>;
84
85 #[cfg(feature = "objc2-core-foundation")]
86 #[unsafe(method(textureVectorNoiseWithSmoothness:size:))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn textureVectorNoiseWithSmoothness_size(
96 smoothness: CGFloat,
97 size: CGSize,
98 ) -> Retained<Self>;
99
100 #[cfg(feature = "objc2-core-foundation")]
101 #[unsafe(method(textureNoiseWithSmoothness:size:grayscale:))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn textureNoiseWithSmoothness_size_grayscale(
112 smoothness: CGFloat,
113 size: CGSize,
114 grayscale: bool,
115 ) -> Retained<Self>;
116
117 #[cfg(feature = "objc2-core-graphics")]
118 #[unsafe(method(textureWithCGImage:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn textureWithCGImage(image: &CGImage) -> Retained<Self>;
125
126 #[cfg(feature = "objc2-app-kit")]
127 #[cfg(target_os = "macos")]
128 #[unsafe(method(textureWithImage:))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn textureWithImage(image: &NSImage) -> Retained<Self>;
131
132 #[cfg(feature = "objc2-core-foundation")]
133 #[unsafe(method(textureWithData:size:))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn textureWithData_size(pixel_data: &NSData, size: CGSize) -> Retained<Self>;
142
143 #[cfg(feature = "objc2-core-foundation")]
144 #[unsafe(method(textureWithData:size:flipped:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn textureWithData_size_flipped(
147 pixel_data: &NSData,
148 size: CGSize,
149 flipped: bool,
150 ) -> Retained<Self>;
151
152 #[cfg(feature = "objc2-core-foundation")]
153 #[unsafe(method(textureWithData:size:rowLength:alignment:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn textureWithData_size_rowLength_alignment(
166 pixel_data: &NSData,
167 size: CGSize,
168 row_length: c_uint,
169 alignment: c_uint,
170 ) -> Retained<Self>;
171
172 #[cfg(feature = "objc2-core-image")]
173 #[cfg(not(target_os = "watchos"))]
174 #[unsafe(method(textureByApplyingCIFilter:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn textureByApplyingCIFilter(&self, filter: &CIFilter) -> Retained<Self>;
181
182 #[unsafe(method(textureByGeneratingNormalMap))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn textureByGeneratingNormalMap(&self) -> Retained<Self>;
186
187 #[cfg(feature = "objc2-core-foundation")]
188 #[unsafe(method(textureByGeneratingNormalMapWithSmoothness:contrast:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn textureByGeneratingNormalMapWithSmoothness_contrast(
197 &self,
198 smoothness: CGFloat,
199 contrast: CGFloat,
200 ) -> Retained<Self>;
201
202 #[cfg(feature = "objc2-core-foundation")]
203 #[unsafe(method(textureRect))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn textureRect(&self) -> CGRect;
207
208 #[cfg(feature = "objc2-core-foundation")]
209 #[unsafe(method(size))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn size(&self) -> CGSize;
213
214 #[unsafe(method(filteringMode))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn filteringMode(&self) -> SKTextureFilteringMode;
218
219 #[unsafe(method(setFilteringMode:))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn setFilteringMode(&self, filtering_mode: SKTextureFilteringMode);
223
224 #[unsafe(method(usesMipmaps))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn usesMipmaps(&self) -> bool;
228
229 #[unsafe(method(setUsesMipmaps:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setUsesMipmaps(&self, uses_mipmaps: bool);
233
234 #[cfg(feature = "objc2-core-graphics")]
235 #[unsafe(method(CGImage))]
237 #[unsafe(method_family = copy)]
239 pub unsafe fn CGImage(&self) -> Retained<CGImage>;
240
241 #[cfg(feature = "block2")]
242 #[unsafe(method(preloadTextures:withCompletionHandler:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn preloadTextures_withCompletionHandler(
251 textures: &NSArray<SKTexture>,
252 completion_handler: &block2::Block<dyn Fn()>,
253 );
254
255 #[cfg(feature = "block2")]
256 #[unsafe(method(preloadWithCompletionHandler:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn preloadWithCompletionHandler(
260 &self,
261 completion_handler: &block2::Block<dyn Fn()>,
262 );
263 );
264}
265
266impl SKTexture {
268 extern_methods!(
269 #[unsafe(method(init))]
270 #[unsafe(method_family = init)]
271 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
272
273 #[unsafe(method(new))]
274 #[unsafe(method_family = new)]
275 pub unsafe fn new() -> Retained<Self>;
276 );
277}