objc2_io_surface/generated/
IOSurfaceRef.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7#[cfg(feature = "objc2-core-foundation")]
8use objc2_core_foundation::*;
9
10use crate::*;
11
12extern "C" {
13    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceallocsize?language=objc)
14    #[cfg(feature = "objc2-core-foundation")]
15    pub static kIOSurfaceAllocSize: &'static CFString;
16}
17
18extern "C" {
19    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacewidth?language=objc)
20    #[cfg(feature = "objc2-core-foundation")]
21    pub static kIOSurfaceWidth: &'static CFString;
22}
23
24extern "C" {
25    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceheight?language=objc)
26    #[cfg(feature = "objc2-core-foundation")]
27    pub static kIOSurfaceHeight: &'static CFString;
28}
29
30extern "C" {
31    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacebytesperrow?language=objc)
32    #[cfg(feature = "objc2-core-foundation")]
33    pub static kIOSurfaceBytesPerRow: &'static CFString;
34}
35
36extern "C" {
37    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacebytesperelement?language=objc)
38    #[cfg(feature = "objc2-core-foundation")]
39    pub static kIOSurfaceBytesPerElement: &'static CFString;
40}
41
42extern "C" {
43    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceelementwidth?language=objc)
44    #[cfg(feature = "objc2-core-foundation")]
45    pub static kIOSurfaceElementWidth: &'static CFString;
46}
47
48extern "C" {
49    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceelementheight?language=objc)
50    #[cfg(feature = "objc2-core-foundation")]
51    pub static kIOSurfaceElementHeight: &'static CFString;
52}
53
54extern "C" {
55    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceoffset?language=objc)
56    #[cfg(feature = "objc2-core-foundation")]
57    pub static kIOSurfaceOffset: &'static CFString;
58}
59
60extern "C" {
61    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplaneinfo?language=objc)
62    #[cfg(feature = "objc2-core-foundation")]
63    pub static kIOSurfacePlaneInfo: &'static CFString;
64}
65
66extern "C" {
67    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanewidth?language=objc)
68    #[cfg(feature = "objc2-core-foundation")]
69    pub static kIOSurfacePlaneWidth: &'static CFString;
70}
71
72extern "C" {
73    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplaneheight?language=objc)
74    #[cfg(feature = "objc2-core-foundation")]
75    pub static kIOSurfacePlaneHeight: &'static CFString;
76}
77
78extern "C" {
79    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanebytesperrow?language=objc)
80    #[cfg(feature = "objc2-core-foundation")]
81    pub static kIOSurfacePlaneBytesPerRow: &'static CFString;
82}
83
84extern "C" {
85    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplaneoffset?language=objc)
86    #[cfg(feature = "objc2-core-foundation")]
87    pub static kIOSurfacePlaneOffset: &'static CFString;
88}
89
90extern "C" {
91    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanesize?language=objc)
92    #[cfg(feature = "objc2-core-foundation")]
93    pub static kIOSurfacePlaneSize: &'static CFString;
94}
95
96extern "C" {
97    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanebase?language=objc)
98    #[cfg(feature = "objc2-core-foundation")]
99    pub static kIOSurfacePlaneBase: &'static CFString;
100}
101
102extern "C" {
103    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanebitsperelement?language=objc)
104    #[cfg(feature = "objc2-core-foundation")]
105    pub static kIOSurfacePlaneBitsPerElement: &'static CFString;
106}
107
108extern "C" {
109    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanebytesperelement?language=objc)
110    #[cfg(feature = "objc2-core-foundation")]
111    pub static kIOSurfacePlaneBytesPerElement: &'static CFString;
112}
113
114extern "C" {
115    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplaneelementwidth?language=objc)
116    #[cfg(feature = "objc2-core-foundation")]
117    pub static kIOSurfacePlaneElementWidth: &'static CFString;
118}
119
120extern "C" {
121    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplaneelementheight?language=objc)
122    #[cfg(feature = "objc2-core-foundation")]
123    pub static kIOSurfacePlaneElementHeight: &'static CFString;
124}
125
126extern "C" {
127    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacecachemode?language=objc)
128    #[cfg(feature = "objc2-core-foundation")]
129    pub static kIOSurfaceCacheMode: &'static CFString;
130}
131
132extern "C" {
133    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceisglobal?language=objc)
134    #[cfg(feature = "objc2-core-foundation")]
135    pub static kIOSurfaceIsGlobal: &'static CFString;
136}
137
138extern "C" {
139    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacepixelformat?language=objc)
140    #[cfg(feature = "objc2-core-foundation")]
141    pub static kIOSurfacePixelFormat: &'static CFString;
142}
143
144extern "C" {
145    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacepixelsizecastingallowed?language=objc)
146    #[cfg(feature = "objc2-core-foundation")]
147    pub static kIOSurfacePixelSizeCastingAllowed: &'static CFString;
148}
149
150extern "C" {
151    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanecomponentbitdepths?language=objc)
152    #[cfg(feature = "objc2-core-foundation")]
153    pub static kIOSurfacePlaneComponentBitDepths: &'static CFString;
154}
155
156extern "C" {
157    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanecomponentbitoffsets?language=objc)
158    #[cfg(feature = "objc2-core-foundation")]
159    pub static kIOSurfacePlaneComponentBitOffsets: &'static CFString;
160}
161
162extern "C" {
163    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacename?language=objc)
164    #[cfg(feature = "objc2-core-foundation")]
165    pub static kIOSurfaceName: &'static CFString;
166}
167
168/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfacecomponentname?language=objc)
169// NS_ENUM
170#[repr(transparent)]
171#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
172pub struct IOSurfaceComponentName(pub i32);
173impl IOSurfaceComponentName {
174    #[doc(alias = "kIOSurfaceComponentNameUnknown")]
175    pub const Unknown: Self = Self(0);
176    #[doc(alias = "kIOSurfaceComponentNameAlpha")]
177    pub const Alpha: Self = Self(1);
178    #[doc(alias = "kIOSurfaceComponentNameRed")]
179    pub const Red: Self = Self(2);
180    #[doc(alias = "kIOSurfaceComponentNameGreen")]
181    pub const Green: Self = Self(3);
182    #[doc(alias = "kIOSurfaceComponentNameBlue")]
183    pub const Blue: Self = Self(4);
184    #[doc(alias = "kIOSurfaceComponentNameLuma")]
185    pub const Luma: Self = Self(5);
186    #[doc(alias = "kIOSurfaceComponentNameChromaRed")]
187    pub const ChromaRed: Self = Self(6);
188    #[doc(alias = "kIOSurfaceComponentNameChromaBlue")]
189    pub const ChromaBlue: Self = Self(7);
190}
191
192#[cfg(feature = "objc2")]
193unsafe impl Encode for IOSurfaceComponentName {
194    const ENCODING: Encoding = i32::ENCODING;
195}
196
197#[cfg(feature = "objc2")]
198unsafe impl RefEncode for IOSurfaceComponentName {
199    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
200}
201
202extern "C" {
203    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanecomponentnames?language=objc)
204    #[cfg(feature = "objc2-core-foundation")]
205    pub static kIOSurfacePlaneComponentNames: &'static CFString;
206}
207
208/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfacecomponenttype?language=objc)
209// NS_ENUM
210#[repr(transparent)]
211#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
212pub struct IOSurfaceComponentType(pub i32);
213impl IOSurfaceComponentType {
214    #[doc(alias = "kIOSurfaceComponentTypeUnknown")]
215    pub const Unknown: Self = Self(0);
216    #[doc(alias = "kIOSurfaceComponentTypeUnsignedInteger")]
217    pub const UnsignedInteger: Self = Self(1);
218    #[doc(alias = "kIOSurfaceComponentTypeSignedInteger")]
219    pub const SignedInteger: Self = Self(2);
220    #[doc(alias = "kIOSurfaceComponentTypeFloat")]
221    pub const Float: Self = Self(3);
222    #[doc(alias = "kIOSurfaceComponentTypeSignedNormalized")]
223    pub const SignedNormalized: Self = Self(4);
224}
225
226#[cfg(feature = "objc2")]
227unsafe impl Encode for IOSurfaceComponentType {
228    const ENCODING: Encoding = i32::ENCODING;
229}
230
231#[cfg(feature = "objc2")]
232unsafe impl RefEncode for IOSurfaceComponentType {
233    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
234}
235
236extern "C" {
237    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanecomponenttypes?language=objc)
238    #[cfg(feature = "objc2-core-foundation")]
239    pub static kIOSurfacePlaneComponentTypes: &'static CFString;
240}
241
242/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfacecomponentrange?language=objc)
243// NS_ENUM
244#[repr(transparent)]
245#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
246pub struct IOSurfaceComponentRange(pub i32);
247impl IOSurfaceComponentRange {
248    #[doc(alias = "kIOSurfaceComponentRangeUnknown")]
249    pub const Unknown: Self = Self(0);
250    #[doc(alias = "kIOSurfaceComponentRangeFullRange")]
251    pub const FullRange: Self = Self(1);
252    #[doc(alias = "kIOSurfaceComponentRangeVideoRange")]
253    pub const VideoRange: Self = Self(2);
254    #[doc(alias = "kIOSurfaceComponentRangeWideRange")]
255    pub const WideRange: Self = Self(3);
256}
257
258#[cfg(feature = "objc2")]
259unsafe impl Encode for IOSurfaceComponentRange {
260    const ENCODING: Encoding = i32::ENCODING;
261}
262
263#[cfg(feature = "objc2")]
264unsafe impl RefEncode for IOSurfaceComponentRange {
265    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
266}
267
268extern "C" {
269    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceplanecomponentranges?language=objc)
270    #[cfg(feature = "objc2-core-foundation")]
271    pub static kIOSurfacePlaneComponentRanges: &'static CFString;
272}
273
274/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfacesubsampling?language=objc)
275// NS_ENUM
276#[repr(transparent)]
277#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
278pub struct IOSurfaceSubsampling(pub i32);
279impl IOSurfaceSubsampling {
280    #[doc(alias = "kIOSurfaceSubsamplingUnknown")]
281    pub const SubsamplingUnknown: Self = Self(0);
282    #[doc(alias = "kIOSurfaceSubsamplingNone")]
283    pub const SubsamplingNone: Self = Self(1);
284    #[doc(alias = "kIOSurfaceSubsampling422")]
285    pub const Subsampling422: Self = Self(2);
286    #[doc(alias = "kIOSurfaceSubsampling420")]
287    pub const Subsampling420: Self = Self(3);
288    #[doc(alias = "kIOSurfaceSubsampling411")]
289    pub const Subsampling411: Self = Self(4);
290}
291
292#[cfg(feature = "objc2")]
293unsafe impl Encode for IOSurfaceSubsampling {
294    const ENCODING: Encoding = i32::ENCODING;
295}
296
297#[cfg(feature = "objc2")]
298unsafe impl RefEncode for IOSurfaceSubsampling {
299    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
300}
301
302extern "C" {
303    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacesubsampling?language=objc)
304    #[cfg(feature = "objc2-core-foundation")]
305    pub static kIOSurfaceSubsampling: &'static CFString;
306}
307
308#[cfg(feature = "objc2-core-foundation")]
309unsafe impl ConcreteType for IOSurfaceRef {
310    #[doc(alias = "IOSurfaceGetTypeID")]
311    #[inline]
312    fn type_id() -> CFTypeID {
313        extern "C-unwind" {
314            fn IOSurfaceGetTypeID() -> CFTypeID;
315        }
316        unsafe { IOSurfaceGetTypeID() }
317    }
318}
319
320#[cfg(feature = "objc2-core-foundation")]
321#[inline]
322pub unsafe extern "C-unwind" fn IOSurfaceCreate(
323    properties: &CFDictionary,
324) -> Option<CFRetained<IOSurfaceRef>> {
325    extern "C-unwind" {
326        fn IOSurfaceCreate(properties: &CFDictionary) -> Option<NonNull<IOSurfaceRef>>;
327    }
328    let ret = unsafe { IOSurfaceCreate(properties) };
329    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
330}
331
332#[cfg(all(feature = "IOSurfaceTypes", feature = "objc2-core-foundation"))]
333#[inline]
334pub unsafe extern "C-unwind" fn IOSurfaceLookup(
335    csid: IOSurfaceID,
336) -> Option<CFRetained<IOSurfaceRef>> {
337    extern "C-unwind" {
338        fn IOSurfaceLookup(csid: IOSurfaceID) -> Option<NonNull<IOSurfaceRef>>;
339    }
340    let ret = unsafe { IOSurfaceLookup(csid) };
341    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
342}
343
344extern "C-unwind" {
345    #[cfg(feature = "IOSurfaceTypes")]
346    pub fn IOSurfaceGetID(buffer: &IOSurfaceRef) -> IOSurfaceID;
347}
348
349extern "C-unwind" {
350    #[cfg(all(feature = "IOSurfaceTypes", feature = "libc"))]
351    pub fn IOSurfaceLock(
352        buffer: &IOSurfaceRef,
353        options: IOSurfaceLockOptions,
354        seed: *mut u32,
355    ) -> libc::kern_return_t;
356}
357
358extern "C-unwind" {
359    #[cfg(all(feature = "IOSurfaceTypes", feature = "libc"))]
360    pub fn IOSurfaceUnlock(
361        buffer: &IOSurfaceRef,
362        options: IOSurfaceLockOptions,
363        seed: *mut u32,
364    ) -> libc::kern_return_t;
365}
366
367extern "C-unwind" {
368    pub fn IOSurfaceGetAllocSize(buffer: &IOSurfaceRef) -> usize;
369}
370
371extern "C-unwind" {
372    pub fn IOSurfaceGetWidth(buffer: &IOSurfaceRef) -> usize;
373}
374
375extern "C-unwind" {
376    pub fn IOSurfaceGetHeight(buffer: &IOSurfaceRef) -> usize;
377}
378
379extern "C-unwind" {
380    pub fn IOSurfaceGetBytesPerElement(buffer: &IOSurfaceRef) -> usize;
381}
382
383extern "C-unwind" {
384    pub fn IOSurfaceGetBytesPerRow(buffer: &IOSurfaceRef) -> usize;
385}
386
387#[inline]
388pub unsafe extern "C-unwind" fn IOSurfaceGetBaseAddress(buffer: &IOSurfaceRef) -> NonNull<c_void> {
389    extern "C-unwind" {
390        fn IOSurfaceGetBaseAddress(buffer: &IOSurfaceRef) -> Option<NonNull<c_void>>;
391    }
392    let ret = unsafe { IOSurfaceGetBaseAddress(buffer) };
393    ret.expect("function was marked as returning non-null, but actually returned NULL")
394}
395
396extern "C-unwind" {
397    pub fn IOSurfaceGetElementWidth(buffer: &IOSurfaceRef) -> usize;
398}
399
400extern "C-unwind" {
401    pub fn IOSurfaceGetElementHeight(buffer: &IOSurfaceRef) -> usize;
402}
403
404extern "C-unwind" {
405    pub fn IOSurfaceGetPixelFormat(buffer: &IOSurfaceRef) -> OSType;
406}
407
408extern "C-unwind" {
409    pub fn IOSurfaceGetSeed(buffer: &IOSurfaceRef) -> u32;
410}
411
412extern "C-unwind" {
413    pub fn IOSurfaceGetPlaneCount(buffer: &IOSurfaceRef) -> usize;
414}
415
416extern "C-unwind" {
417    pub fn IOSurfaceGetWidthOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
418}
419
420extern "C-unwind" {
421    pub fn IOSurfaceGetHeightOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
422}
423
424extern "C-unwind" {
425    pub fn IOSurfaceGetBytesPerElementOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
426}
427
428extern "C-unwind" {
429    pub fn IOSurfaceGetBytesPerRowOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
430}
431
432#[inline]
433pub unsafe extern "C-unwind" fn IOSurfaceGetBaseAddressOfPlane(
434    buffer: &IOSurfaceRef,
435    plane_index: usize,
436) -> NonNull<c_void> {
437    extern "C-unwind" {
438        fn IOSurfaceGetBaseAddressOfPlane(
439            buffer: &IOSurfaceRef,
440            plane_index: usize,
441        ) -> Option<NonNull<c_void>>;
442    }
443    let ret = unsafe { IOSurfaceGetBaseAddressOfPlane(buffer, plane_index) };
444    ret.expect("function was marked as returning non-null, but actually returned NULL")
445}
446
447extern "C-unwind" {
448    pub fn IOSurfaceGetElementWidthOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
449}
450
451extern "C-unwind" {
452    pub fn IOSurfaceGetElementHeightOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
453}
454
455extern "C-unwind" {
456    pub fn IOSurfaceGetNumberOfComponentsOfPlane(
457        buffer: &IOSurfaceRef,
458        plane_index: usize,
459    ) -> usize;
460}
461
462extern "C-unwind" {
463    pub fn IOSurfaceGetNameOfComponentOfPlane(
464        buffer: &IOSurfaceRef,
465        plane_index: usize,
466        component_index: usize,
467    ) -> IOSurfaceComponentName;
468}
469
470extern "C-unwind" {
471    pub fn IOSurfaceGetTypeOfComponentOfPlane(
472        buffer: &IOSurfaceRef,
473        plane_index: usize,
474        component_index: usize,
475    ) -> IOSurfaceComponentType;
476}
477
478extern "C-unwind" {
479    pub fn IOSurfaceGetRangeOfComponentOfPlane(
480        buffer: &IOSurfaceRef,
481        plane_index: usize,
482        component_index: usize,
483    ) -> IOSurfaceComponentRange;
484}
485
486extern "C-unwind" {
487    pub fn IOSurfaceGetBitDepthOfComponentOfPlane(
488        buffer: &IOSurfaceRef,
489        plane_index: usize,
490        component_index: usize,
491    ) -> usize;
492}
493
494extern "C-unwind" {
495    pub fn IOSurfaceGetBitOffsetOfComponentOfPlane(
496        buffer: &IOSurfaceRef,
497        plane_index: usize,
498        component_index: usize,
499    ) -> usize;
500}
501
502extern "C-unwind" {
503    pub fn IOSurfaceGetSubsampling(buffer: &IOSurfaceRef) -> IOSurfaceSubsampling;
504}
505
506extern "C" {
507    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacecolorspace?language=objc)
508    #[cfg(feature = "objc2-core-foundation")]
509    pub static kIOSurfaceColorSpace: &'static CFString;
510}
511
512extern "C" {
513    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfaceiccprofile?language=objc)
514    #[cfg(feature = "objc2-core-foundation")]
515    pub static kIOSurfaceICCProfile: &'static CFString;
516}
517
518extern "C" {
519    /// [Apple's documentation](https://developer.apple.com/documentation/iosurface/kiosurfacecontentheadroom?language=objc)
520    #[cfg(feature = "objc2-core-foundation")]
521    pub static kIOSurfaceContentHeadroom: &'static CFString;
522}
523
524extern "C-unwind" {
525    #[cfg(feature = "objc2-core-foundation")]
526    pub fn IOSurfaceSetValue(buffer: &IOSurfaceRef, key: &CFString, value: &CFType);
527}
528
529#[cfg(feature = "objc2-core-foundation")]
530#[inline]
531pub unsafe extern "C-unwind" fn IOSurfaceCopyValue(
532    buffer: &IOSurfaceRef,
533    key: &CFString,
534) -> Option<CFRetained<CFType>> {
535    extern "C-unwind" {
536        fn IOSurfaceCopyValue(buffer: &IOSurfaceRef, key: &CFString) -> Option<NonNull<CFType>>;
537    }
538    let ret = unsafe { IOSurfaceCopyValue(buffer, key) };
539    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
540}
541
542extern "C-unwind" {
543    #[cfg(feature = "objc2-core-foundation")]
544    pub fn IOSurfaceRemoveValue(buffer: &IOSurfaceRef, key: &CFString);
545}
546
547extern "C-unwind" {
548    #[cfg(feature = "objc2-core-foundation")]
549    pub fn IOSurfaceSetValues(buffer: &IOSurfaceRef, keys_and_values: &CFDictionary);
550}
551
552#[cfg(feature = "objc2-core-foundation")]
553#[inline]
554pub unsafe extern "C-unwind" fn IOSurfaceCopyAllValues(
555    buffer: &IOSurfaceRef,
556) -> Option<CFRetained<CFDictionary>> {
557    extern "C-unwind" {
558        fn IOSurfaceCopyAllValues(buffer: &IOSurfaceRef) -> Option<NonNull<CFDictionary>>;
559    }
560    let ret = unsafe { IOSurfaceCopyAllValues(buffer) };
561    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
562}
563
564extern "C-unwind" {
565    pub fn IOSurfaceRemoveAllValues(buffer: &IOSurfaceRef);
566}
567
568extern "C-unwind" {
569    #[cfg(feature = "libc")]
570    pub fn IOSurfaceCreateMachPort(buffer: &IOSurfaceRef) -> libc::mach_port_t;
571}
572
573#[cfg(all(feature = "libc", feature = "objc2-core-foundation"))]
574#[inline]
575pub unsafe extern "C-unwind" fn IOSurfaceLookupFromMachPort(
576    port: libc::mach_port_t,
577) -> Option<CFRetained<IOSurfaceRef>> {
578    extern "C-unwind" {
579        fn IOSurfaceLookupFromMachPort(port: libc::mach_port_t) -> Option<NonNull<IOSurfaceRef>>;
580    }
581    let ret = unsafe { IOSurfaceLookupFromMachPort(port) };
582    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
583}
584
585extern "C-unwind" {
586    #[cfg(feature = "objc2-core-foundation")]
587    pub fn IOSurfaceGetPropertyMaximum(property: &CFString) -> usize;
588}
589
590extern "C-unwind" {
591    #[cfg(feature = "objc2-core-foundation")]
592    pub fn IOSurfaceGetPropertyAlignment(property: &CFString) -> usize;
593}
594
595extern "C-unwind" {
596    #[cfg(feature = "objc2-core-foundation")]
597    pub fn IOSurfaceAlignProperty(property: &CFString, value: usize) -> usize;
598}
599
600extern "C-unwind" {
601    pub fn IOSurfaceIncrementUseCount(buffer: &IOSurfaceRef);
602}
603
604extern "C-unwind" {
605    pub fn IOSurfaceDecrementUseCount(buffer: &IOSurfaceRef);
606}
607
608extern "C-unwind" {
609    pub fn IOSurfaceGetUseCount(buffer: &IOSurfaceRef) -> i32;
610}
611
612#[inline]
613pub unsafe extern "C-unwind" fn IOSurfaceIsInUse(buffer: &IOSurfaceRef) -> bool {
614    extern "C-unwind" {
615        fn IOSurfaceIsInUse(buffer: &IOSurfaceRef) -> Boolean;
616    }
617    let ret = unsafe { IOSurfaceIsInUse(buffer) };
618    ret != 0
619}
620
621#[inline]
622pub unsafe extern "C-unwind" fn IOSurfaceAllowsPixelSizeCasting(buffer: &IOSurfaceRef) -> bool {
623    extern "C-unwind" {
624        fn IOSurfaceAllowsPixelSizeCasting(buffer: &IOSurfaceRef) -> Boolean;
625    }
626    let ret = unsafe { IOSurfaceAllowsPixelSizeCasting(buffer) };
627    ret != 0
628}
629
630extern "C-unwind" {
631    #[cfg(feature = "libc")]
632    pub fn IOSurfaceSetPurgeable(
633        buffer: &IOSurfaceRef,
634        new_state: u32,
635        old_state: *mut u32,
636    ) -> libc::kern_return_t;
637}
638
639/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfacememoryledgertags?language=objc)
640// NS_ENUM
641#[repr(transparent)]
642#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
643pub struct IOSurfaceMemoryLedgerTags(pub c_int);
644impl IOSurfaceMemoryLedgerTags {
645    #[doc(alias = "kIOSurfaceMemoryLedgerTagDefault")]
646    pub const Default: Self = Self(0x00000001);
647    #[doc(alias = "kIOSurfaceMemoryLedgerTagNetwork")]
648    pub const Network: Self = Self(0x00000002);
649    #[doc(alias = "kIOSurfaceMemoryLedgerTagMedia")]
650    pub const Media: Self = Self(0x00000003);
651    #[doc(alias = "kIOSurfaceMemoryLedgerTagGraphics")]
652    pub const Graphics: Self = Self(0x00000004);
653    #[doc(alias = "kIOSurfaceMemoryLedgerTagNeural")]
654    pub const Neural: Self = Self(0x00000005);
655}
656
657#[cfg(feature = "objc2")]
658unsafe impl Encode for IOSurfaceMemoryLedgerTags {
659    const ENCODING: Encoding = c_int::ENCODING;
660}
661
662#[cfg(feature = "objc2")]
663unsafe impl RefEncode for IOSurfaceMemoryLedgerTags {
664    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
665}
666
667/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfacememoryledgerflags?language=objc)
668// NS_OPTIONS
669#[repr(transparent)]
670#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
671pub struct IOSurfaceMemoryLedgerFlags(pub u32);
672bitflags::bitflags! {
673    impl IOSurfaceMemoryLedgerFlags: u32 {
674        #[doc(alias = "kIOSurfaceMemoryLedgerFlagNoFootprint")]
675        const NoFootprint = 1<<0;
676    }
677}
678
679#[cfg(feature = "objc2")]
680unsafe impl Encode for IOSurfaceMemoryLedgerFlags {
681    const ENCODING: Encoding = u32::ENCODING;
682}
683
684#[cfg(feature = "objc2")]
685unsafe impl RefEncode for IOSurfaceMemoryLedgerFlags {
686    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
687}