1use 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 #[cfg(feature = "objc2-core-foundation")]
15 pub static kIOSurfaceAllocSize: &'static CFString;
16}
17
18extern "C" {
19 #[cfg(feature = "objc2-core-foundation")]
21 pub static kIOSurfaceWidth: &'static CFString;
22}
23
24extern "C" {
25 #[cfg(feature = "objc2-core-foundation")]
27 pub static kIOSurfaceHeight: &'static CFString;
28}
29
30extern "C" {
31 #[cfg(feature = "objc2-core-foundation")]
33 pub static kIOSurfaceBytesPerRow: &'static CFString;
34}
35
36extern "C" {
37 #[cfg(feature = "objc2-core-foundation")]
39 pub static kIOSurfaceBytesPerElement: &'static CFString;
40}
41
42extern "C" {
43 #[cfg(feature = "objc2-core-foundation")]
45 pub static kIOSurfaceElementWidth: &'static CFString;
46}
47
48extern "C" {
49 #[cfg(feature = "objc2-core-foundation")]
51 pub static kIOSurfaceElementHeight: &'static CFString;
52}
53
54extern "C" {
55 #[cfg(feature = "objc2-core-foundation")]
57 pub static kIOSurfaceOffset: &'static CFString;
58}
59
60extern "C" {
61 #[cfg(feature = "objc2-core-foundation")]
63 pub static kIOSurfacePlaneInfo: &'static CFString;
64}
65
66extern "C" {
67 #[cfg(feature = "objc2-core-foundation")]
69 pub static kIOSurfacePlaneWidth: &'static CFString;
70}
71
72extern "C" {
73 #[cfg(feature = "objc2-core-foundation")]
75 pub static kIOSurfacePlaneHeight: &'static CFString;
76}
77
78extern "C" {
79 #[cfg(feature = "objc2-core-foundation")]
81 pub static kIOSurfacePlaneBytesPerRow: &'static CFString;
82}
83
84extern "C" {
85 #[cfg(feature = "objc2-core-foundation")]
87 pub static kIOSurfacePlaneOffset: &'static CFString;
88}
89
90extern "C" {
91 #[cfg(feature = "objc2-core-foundation")]
93 pub static kIOSurfacePlaneSize: &'static CFString;
94}
95
96extern "C" {
97 #[cfg(feature = "objc2-core-foundation")]
99 pub static kIOSurfacePlaneBase: &'static CFString;
100}
101
102extern "C" {
103 #[cfg(feature = "objc2-core-foundation")]
105 pub static kIOSurfacePlaneBitsPerElement: &'static CFString;
106}
107
108extern "C" {
109 #[cfg(feature = "objc2-core-foundation")]
111 pub static kIOSurfacePlaneBytesPerElement: &'static CFString;
112}
113
114extern "C" {
115 #[cfg(feature = "objc2-core-foundation")]
117 pub static kIOSurfacePlaneElementWidth: &'static CFString;
118}
119
120extern "C" {
121 #[cfg(feature = "objc2-core-foundation")]
123 pub static kIOSurfacePlaneElementHeight: &'static CFString;
124}
125
126extern "C" {
127 #[cfg(feature = "objc2-core-foundation")]
129 pub static kIOSurfaceCacheMode: &'static CFString;
130}
131
132extern "C" {
133 #[cfg(feature = "objc2-core-foundation")]
135 #[deprecated = "Global surfaces are insecure"]
136 pub static kIOSurfaceIsGlobal: &'static CFString;
137}
138
139extern "C" {
140 #[cfg(feature = "objc2-core-foundation")]
142 pub static kIOSurfacePixelFormat: &'static CFString;
143}
144
145extern "C" {
146 #[cfg(feature = "objc2-core-foundation")]
148 pub static kIOSurfacePixelSizeCastingAllowed: &'static CFString;
149}
150
151extern "C" {
152 #[cfg(feature = "objc2-core-foundation")]
154 pub static kIOSurfacePlaneComponentBitDepths: &'static CFString;
155}
156
157extern "C" {
158 #[cfg(feature = "objc2-core-foundation")]
160 pub static kIOSurfacePlaneComponentBitOffsets: &'static CFString;
161}
162
163extern "C" {
164 #[cfg(feature = "objc2-core-foundation")]
166 pub static kIOSurfaceName: &'static CFString;
167}
168
169#[repr(transparent)]
172#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
173pub struct IOSurfaceComponentName(pub i32);
174impl IOSurfaceComponentName {
175 #[doc(alias = "kIOSurfaceComponentNameUnknown")]
176 pub const Unknown: Self = Self(0);
177 #[doc(alias = "kIOSurfaceComponentNameAlpha")]
178 pub const Alpha: Self = Self(1);
179 #[doc(alias = "kIOSurfaceComponentNameRed")]
180 pub const Red: Self = Self(2);
181 #[doc(alias = "kIOSurfaceComponentNameGreen")]
182 pub const Green: Self = Self(3);
183 #[doc(alias = "kIOSurfaceComponentNameBlue")]
184 pub const Blue: Self = Self(4);
185 #[doc(alias = "kIOSurfaceComponentNameLuma")]
186 pub const Luma: Self = Self(5);
187 #[doc(alias = "kIOSurfaceComponentNameChromaRed")]
188 pub const ChromaRed: Self = Self(6);
189 #[doc(alias = "kIOSurfaceComponentNameChromaBlue")]
190 pub const ChromaBlue: Self = Self(7);
191}
192
193#[cfg(feature = "objc2")]
194unsafe impl Encode for IOSurfaceComponentName {
195 const ENCODING: Encoding = i32::ENCODING;
196}
197
198#[cfg(feature = "objc2")]
199unsafe impl RefEncode for IOSurfaceComponentName {
200 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
201}
202
203unsafe impl Send for IOSurfaceComponentName {}
204
205unsafe impl Sync for IOSurfaceComponentName {}
206
207extern "C" {
208 #[cfg(feature = "objc2-core-foundation")]
210 pub static kIOSurfacePlaneComponentNames: &'static CFString;
211}
212
213#[repr(transparent)]
216#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
217pub struct IOSurfaceComponentType(pub i32);
218impl IOSurfaceComponentType {
219 #[doc(alias = "kIOSurfaceComponentTypeUnknown")]
220 pub const Unknown: Self = Self(0);
221 #[doc(alias = "kIOSurfaceComponentTypeUnsignedInteger")]
222 pub const UnsignedInteger: Self = Self(1);
223 #[doc(alias = "kIOSurfaceComponentTypeSignedInteger")]
224 pub const SignedInteger: Self = Self(2);
225 #[doc(alias = "kIOSurfaceComponentTypeFloat")]
226 pub const Float: Self = Self(3);
227 #[doc(alias = "kIOSurfaceComponentTypeSignedNormalized")]
228 pub const SignedNormalized: Self = Self(4);
229}
230
231#[cfg(feature = "objc2")]
232unsafe impl Encode for IOSurfaceComponentType {
233 const ENCODING: Encoding = i32::ENCODING;
234}
235
236#[cfg(feature = "objc2")]
237unsafe impl RefEncode for IOSurfaceComponentType {
238 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
239}
240
241unsafe impl Send for IOSurfaceComponentType {}
242
243unsafe impl Sync for IOSurfaceComponentType {}
244
245extern "C" {
246 #[cfg(feature = "objc2-core-foundation")]
248 pub static kIOSurfacePlaneComponentTypes: &'static CFString;
249}
250
251#[repr(transparent)]
254#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
255pub struct IOSurfaceComponentRange(pub i32);
256impl IOSurfaceComponentRange {
257 #[doc(alias = "kIOSurfaceComponentRangeUnknown")]
258 pub const Unknown: Self = Self(0);
259 #[doc(alias = "kIOSurfaceComponentRangeFullRange")]
260 pub const FullRange: Self = Self(1);
261 #[doc(alias = "kIOSurfaceComponentRangeVideoRange")]
262 pub const VideoRange: Self = Self(2);
263 #[doc(alias = "kIOSurfaceComponentRangeWideRange")]
264 pub const WideRange: Self = Self(3);
265}
266
267#[cfg(feature = "objc2")]
268unsafe impl Encode for IOSurfaceComponentRange {
269 const ENCODING: Encoding = i32::ENCODING;
270}
271
272#[cfg(feature = "objc2")]
273unsafe impl RefEncode for IOSurfaceComponentRange {
274 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
275}
276
277unsafe impl Send for IOSurfaceComponentRange {}
278
279unsafe impl Sync for IOSurfaceComponentRange {}
280
281extern "C" {
282 #[cfg(feature = "objc2-core-foundation")]
284 pub static kIOSurfacePlaneComponentRanges: &'static CFString;
285}
286
287#[repr(transparent)]
290#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
291pub struct IOSurfaceSubsampling(pub i32);
292impl IOSurfaceSubsampling {
293 #[doc(alias = "kIOSurfaceSubsamplingUnknown")]
294 pub const SubsamplingUnknown: Self = Self(0);
295 #[doc(alias = "kIOSurfaceSubsamplingNone")]
296 pub const SubsamplingNone: Self = Self(1);
297 #[doc(alias = "kIOSurfaceSubsampling422")]
298 pub const Subsampling422: Self = Self(2);
299 #[doc(alias = "kIOSurfaceSubsampling420")]
300 pub const Subsampling420: Self = Self(3);
301 #[doc(alias = "kIOSurfaceSubsampling411")]
302 pub const Subsampling411: Self = Self(4);
303}
304
305#[cfg(feature = "objc2")]
306unsafe impl Encode for IOSurfaceSubsampling {
307 const ENCODING: Encoding = i32::ENCODING;
308}
309
310#[cfg(feature = "objc2")]
311unsafe impl RefEncode for IOSurfaceSubsampling {
312 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
313}
314
315unsafe impl Send for IOSurfaceSubsampling {}
316
317unsafe impl Sync for IOSurfaceSubsampling {}
318
319extern "C" {
320 #[cfg(feature = "objc2-core-foundation")]
322 pub static kIOSurfaceSubsampling: &'static CFString;
323}
324
325#[cfg(feature = "objc2-core-foundation")]
326unsafe impl ConcreteType for IOSurfaceRef {
327 #[doc(alias = "IOSurfaceGetTypeID")]
328 #[inline]
329 fn type_id() -> CFTypeID {
330 extern "C-unwind" {
331 fn IOSurfaceGetTypeID() -> CFTypeID;
332 }
333 unsafe { IOSurfaceGetTypeID() }
334 }
335}
336
337impl IOSurfaceRef {
338 #[doc(alias = "IOSurfaceCreate")]
342 #[cfg(feature = "objc2-core-foundation")]
343 #[inline]
344 pub unsafe fn new(properties: &CFDictionary) -> Option<CFRetained<IOSurfaceRef>> {
345 extern "C-unwind" {
346 fn IOSurfaceCreate(properties: &CFDictionary) -> Option<NonNull<IOSurfaceRef>>;
347 }
348 let ret = unsafe { IOSurfaceCreate(properties) };
349 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
350 }
351
352 #[doc(alias = "IOSurfaceLookup")]
353 #[cfg(all(feature = "IOSurfaceTypes", feature = "objc2-core-foundation"))]
354 #[inline]
355 pub fn lookup(csid: IOSurfaceID) -> Option<CFRetained<IOSurfaceRef>> {
356 extern "C-unwind" {
357 fn IOSurfaceLookup(csid: IOSurfaceID) -> Option<NonNull<IOSurfaceRef>>;
358 }
359 let ret = unsafe { IOSurfaceLookup(csid) };
360 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
361 }
362
363 #[doc(alias = "IOSurfaceGetID")]
364 #[cfg(feature = "IOSurfaceTypes")]
365 #[inline]
366 pub fn id(&self) -> IOSurfaceID {
367 extern "C-unwind" {
368 fn IOSurfaceGetID(buffer: &IOSurfaceRef) -> IOSurfaceID;
369 }
370 unsafe { IOSurfaceGetID(self) }
371 }
372
373 #[doc(alias = "IOSurfaceLock")]
377 #[cfg(all(feature = "IOSurfaceTypes", feature = "libc"))]
378 #[inline]
379 pub unsafe fn lock(
380 &self,
381 options: IOSurfaceLockOptions,
382 seed: *mut u32,
383 ) -> libc::kern_return_t {
384 extern "C-unwind" {
385 fn IOSurfaceLock(
386 buffer: &IOSurfaceRef,
387 options: IOSurfaceLockOptions,
388 seed: *mut u32,
389 ) -> libc::kern_return_t;
390 }
391 unsafe { IOSurfaceLock(self, options, seed) }
392 }
393
394 #[doc(alias = "IOSurfaceUnlock")]
398 #[cfg(all(feature = "IOSurfaceTypes", feature = "libc"))]
399 #[inline]
400 pub unsafe fn unlock(
401 &self,
402 options: IOSurfaceLockOptions,
403 seed: *mut u32,
404 ) -> libc::kern_return_t {
405 extern "C-unwind" {
406 fn IOSurfaceUnlock(
407 buffer: &IOSurfaceRef,
408 options: IOSurfaceLockOptions,
409 seed: *mut u32,
410 ) -> libc::kern_return_t;
411 }
412 unsafe { IOSurfaceUnlock(self, options, seed) }
413 }
414
415 #[doc(alias = "IOSurfaceGetAllocSize")]
416 #[inline]
417 pub fn alloc_size(&self) -> usize {
418 extern "C-unwind" {
419 fn IOSurfaceGetAllocSize(buffer: &IOSurfaceRef) -> usize;
420 }
421 unsafe { IOSurfaceGetAllocSize(self) }
422 }
423
424 #[doc(alias = "IOSurfaceGetWidth")]
425 #[inline]
426 pub fn width(&self) -> usize {
427 extern "C-unwind" {
428 fn IOSurfaceGetWidth(buffer: &IOSurfaceRef) -> usize;
429 }
430 unsafe { IOSurfaceGetWidth(self) }
431 }
432
433 #[doc(alias = "IOSurfaceGetHeight")]
434 #[inline]
435 pub fn height(&self) -> usize {
436 extern "C-unwind" {
437 fn IOSurfaceGetHeight(buffer: &IOSurfaceRef) -> usize;
438 }
439 unsafe { IOSurfaceGetHeight(self) }
440 }
441
442 #[doc(alias = "IOSurfaceGetBytesPerElement")]
443 #[inline]
444 pub fn bytes_per_element(&self) -> usize {
445 extern "C-unwind" {
446 fn IOSurfaceGetBytesPerElement(buffer: &IOSurfaceRef) -> usize;
447 }
448 unsafe { IOSurfaceGetBytesPerElement(self) }
449 }
450
451 #[doc(alias = "IOSurfaceGetBytesPerRow")]
452 #[inline]
453 pub fn bytes_per_row(&self) -> usize {
454 extern "C-unwind" {
455 fn IOSurfaceGetBytesPerRow(buffer: &IOSurfaceRef) -> usize;
456 }
457 unsafe { IOSurfaceGetBytesPerRow(self) }
458 }
459
460 #[doc(alias = "IOSurfaceGetBaseAddress")]
461 #[inline]
462 pub fn base_address(&self) -> NonNull<c_void> {
463 extern "C-unwind" {
464 fn IOSurfaceGetBaseAddress(buffer: &IOSurfaceRef) -> Option<NonNull<c_void>>;
465 }
466 let ret = unsafe { IOSurfaceGetBaseAddress(self) };
467 ret.expect("function was marked as returning non-null, but actually returned NULL")
468 }
469
470 #[doc(alias = "IOSurfaceGetElementWidth")]
471 #[inline]
472 pub fn element_width(&self) -> usize {
473 extern "C-unwind" {
474 fn IOSurfaceGetElementWidth(buffer: &IOSurfaceRef) -> usize;
475 }
476 unsafe { IOSurfaceGetElementWidth(self) }
477 }
478
479 #[doc(alias = "IOSurfaceGetElementHeight")]
480 #[inline]
481 pub fn element_height(&self) -> usize {
482 extern "C-unwind" {
483 fn IOSurfaceGetElementHeight(buffer: &IOSurfaceRef) -> usize;
484 }
485 unsafe { IOSurfaceGetElementHeight(self) }
486 }
487
488 #[doc(alias = "IOSurfaceGetPixelFormat")]
489 #[inline]
490 pub fn pixel_format(&self) -> OSType {
491 extern "C-unwind" {
492 fn IOSurfaceGetPixelFormat(buffer: &IOSurfaceRef) -> OSType;
493 }
494 unsafe { IOSurfaceGetPixelFormat(self) }
495 }
496
497 #[doc(alias = "IOSurfaceGetSeed")]
498 #[inline]
499 pub fn seed(&self) -> u32 {
500 extern "C-unwind" {
501 fn IOSurfaceGetSeed(buffer: &IOSurfaceRef) -> u32;
502 }
503 unsafe { IOSurfaceGetSeed(self) }
504 }
505
506 #[doc(alias = "IOSurfaceGetPlaneCount")]
507 #[inline]
508 pub fn plane_count(&self) -> usize {
509 extern "C-unwind" {
510 fn IOSurfaceGetPlaneCount(buffer: &IOSurfaceRef) -> usize;
511 }
512 unsafe { IOSurfaceGetPlaneCount(self) }
513 }
514
515 #[doc(alias = "IOSurfaceGetWidthOfPlane")]
516 #[inline]
517 pub fn width_of_plane(&self, plane_index: usize) -> usize {
518 extern "C-unwind" {
519 fn IOSurfaceGetWidthOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
520 }
521 unsafe { IOSurfaceGetWidthOfPlane(self, plane_index) }
522 }
523
524 #[doc(alias = "IOSurfaceGetHeightOfPlane")]
525 #[inline]
526 pub fn height_of_plane(&self, plane_index: usize) -> usize {
527 extern "C-unwind" {
528 fn IOSurfaceGetHeightOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
529 }
530 unsafe { IOSurfaceGetHeightOfPlane(self, plane_index) }
531 }
532
533 #[doc(alias = "IOSurfaceGetBytesPerElementOfPlane")]
534 #[inline]
535 pub fn bytes_per_element_of_plane(&self, plane_index: usize) -> usize {
536 extern "C-unwind" {
537 fn IOSurfaceGetBytesPerElementOfPlane(
538 buffer: &IOSurfaceRef,
539 plane_index: usize,
540 ) -> usize;
541 }
542 unsafe { IOSurfaceGetBytesPerElementOfPlane(self, plane_index) }
543 }
544
545 #[doc(alias = "IOSurfaceGetBytesPerRowOfPlane")]
546 #[inline]
547 pub fn bytes_per_row_of_plane(&self, plane_index: usize) -> usize {
548 extern "C-unwind" {
549 fn IOSurfaceGetBytesPerRowOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
550 }
551 unsafe { IOSurfaceGetBytesPerRowOfPlane(self, plane_index) }
552 }
553
554 #[doc(alias = "IOSurfaceGetBaseAddressOfPlane")]
555 #[inline]
556 pub fn base_address_of_plane(&self, plane_index: usize) -> NonNull<c_void> {
557 extern "C-unwind" {
558 fn IOSurfaceGetBaseAddressOfPlane(
559 buffer: &IOSurfaceRef,
560 plane_index: usize,
561 ) -> Option<NonNull<c_void>>;
562 }
563 let ret = unsafe { IOSurfaceGetBaseAddressOfPlane(self, plane_index) };
564 ret.expect("function was marked as returning non-null, but actually returned NULL")
565 }
566
567 #[doc(alias = "IOSurfaceGetElementWidthOfPlane")]
568 #[inline]
569 pub fn element_width_of_plane(&self, plane_index: usize) -> usize {
570 extern "C-unwind" {
571 fn IOSurfaceGetElementWidthOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
572 }
573 unsafe { IOSurfaceGetElementWidthOfPlane(self, plane_index) }
574 }
575
576 #[doc(alias = "IOSurfaceGetElementHeightOfPlane")]
577 #[inline]
578 pub fn element_height_of_plane(&self, plane_index: usize) -> usize {
579 extern "C-unwind" {
580 fn IOSurfaceGetElementHeightOfPlane(buffer: &IOSurfaceRef, plane_index: usize)
581 -> usize;
582 }
583 unsafe { IOSurfaceGetElementHeightOfPlane(self, plane_index) }
584 }
585
586 #[doc(alias = "IOSurfaceGetNumberOfComponentsOfPlane")]
587 #[inline]
588 pub fn number_of_components_of_plane(&self, plane_index: usize) -> usize {
589 extern "C-unwind" {
590 fn IOSurfaceGetNumberOfComponentsOfPlane(
591 buffer: &IOSurfaceRef,
592 plane_index: usize,
593 ) -> usize;
594 }
595 unsafe { IOSurfaceGetNumberOfComponentsOfPlane(self, plane_index) }
596 }
597
598 #[doc(alias = "IOSurfaceGetNameOfComponentOfPlane")]
599 #[inline]
600 pub fn name_of_component_of_plane(
601 &self,
602 plane_index: usize,
603 component_index: usize,
604 ) -> IOSurfaceComponentName {
605 extern "C-unwind" {
606 fn IOSurfaceGetNameOfComponentOfPlane(
607 buffer: &IOSurfaceRef,
608 plane_index: usize,
609 component_index: usize,
610 ) -> IOSurfaceComponentName;
611 }
612 unsafe { IOSurfaceGetNameOfComponentOfPlane(self, plane_index, component_index) }
613 }
614
615 #[doc(alias = "IOSurfaceGetTypeOfComponentOfPlane")]
616 #[inline]
617 pub fn type_of_component_of_plane(
618 &self,
619 plane_index: usize,
620 component_index: usize,
621 ) -> IOSurfaceComponentType {
622 extern "C-unwind" {
623 fn IOSurfaceGetTypeOfComponentOfPlane(
624 buffer: &IOSurfaceRef,
625 plane_index: usize,
626 component_index: usize,
627 ) -> IOSurfaceComponentType;
628 }
629 unsafe { IOSurfaceGetTypeOfComponentOfPlane(self, plane_index, component_index) }
630 }
631
632 #[doc(alias = "IOSurfaceGetRangeOfComponentOfPlane")]
633 #[inline]
634 pub fn range_of_component_of_plane(
635 &self,
636 plane_index: usize,
637 component_index: usize,
638 ) -> IOSurfaceComponentRange {
639 extern "C-unwind" {
640 fn IOSurfaceGetRangeOfComponentOfPlane(
641 buffer: &IOSurfaceRef,
642 plane_index: usize,
643 component_index: usize,
644 ) -> IOSurfaceComponentRange;
645 }
646 unsafe { IOSurfaceGetRangeOfComponentOfPlane(self, plane_index, component_index) }
647 }
648
649 #[doc(alias = "IOSurfaceGetBitDepthOfComponentOfPlane")]
650 #[inline]
651 pub fn bit_depth_of_component_of_plane(
652 &self,
653 plane_index: usize,
654 component_index: usize,
655 ) -> usize {
656 extern "C-unwind" {
657 fn IOSurfaceGetBitDepthOfComponentOfPlane(
658 buffer: &IOSurfaceRef,
659 plane_index: usize,
660 component_index: usize,
661 ) -> usize;
662 }
663 unsafe { IOSurfaceGetBitDepthOfComponentOfPlane(self, plane_index, component_index) }
664 }
665
666 #[doc(alias = "IOSurfaceGetBitOffsetOfComponentOfPlane")]
667 #[inline]
668 pub fn bit_offset_of_component_of_plane(
669 &self,
670 plane_index: usize,
671 component_index: usize,
672 ) -> usize {
673 extern "C-unwind" {
674 fn IOSurfaceGetBitOffsetOfComponentOfPlane(
675 buffer: &IOSurfaceRef,
676 plane_index: usize,
677 component_index: usize,
678 ) -> usize;
679 }
680 unsafe { IOSurfaceGetBitOffsetOfComponentOfPlane(self, plane_index, component_index) }
681 }
682
683 #[doc(alias = "IOSurfaceGetSubsampling")]
684 #[inline]
685 pub fn subsampling(&self) -> IOSurfaceSubsampling {
686 extern "C-unwind" {
687 fn IOSurfaceGetSubsampling(buffer: &IOSurfaceRef) -> IOSurfaceSubsampling;
688 }
689 unsafe { IOSurfaceGetSubsampling(self) }
690 }
691}
692
693extern "C" {
694 #[cfg(feature = "objc2-core-foundation")]
696 pub static kIOSurfaceColorSpace: &'static CFString;
697}
698
699extern "C" {
700 #[cfg(feature = "objc2-core-foundation")]
702 pub static kIOSurfaceICCProfile: &'static CFString;
703}
704
705extern "C" {
706 #[cfg(feature = "objc2-core-foundation")]
708 pub static kIOSurfaceContentHeadroom: &'static CFString;
709}
710
711impl IOSurfaceRef {
712 #[doc(alias = "IOSurfaceSetValue")]
716 #[cfg(feature = "objc2-core-foundation")]
717 #[inline]
718 pub unsafe fn set_value(&self, key: &CFString, value: &CFType) {
719 extern "C-unwind" {
720 fn IOSurfaceSetValue(buffer: &IOSurfaceRef, key: &CFString, value: &CFType);
721 }
722 unsafe { IOSurfaceSetValue(self, key, value) }
723 }
724
725 #[doc(alias = "IOSurfaceCopyValue")]
726 #[cfg(feature = "objc2-core-foundation")]
727 #[inline]
728 pub fn value(&self, key: &CFString) -> Option<CFRetained<CFType>> {
729 extern "C-unwind" {
730 fn IOSurfaceCopyValue(buffer: &IOSurfaceRef, key: &CFString)
731 -> Option<NonNull<CFType>>;
732 }
733 let ret = unsafe { IOSurfaceCopyValue(self, key) };
734 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
735 }
736
737 #[doc(alias = "IOSurfaceRemoveValue")]
738 #[cfg(feature = "objc2-core-foundation")]
739 #[inline]
740 pub fn remove_value(&self, key: &CFString) {
741 extern "C-unwind" {
742 fn IOSurfaceRemoveValue(buffer: &IOSurfaceRef, key: &CFString);
743 }
744 unsafe { IOSurfaceRemoveValue(self, key) }
745 }
746
747 #[doc(alias = "IOSurfaceSetValues")]
751 #[cfg(feature = "objc2-core-foundation")]
752 #[inline]
753 pub unsafe fn set_values(&self, keys_and_values: &CFDictionary) {
754 extern "C-unwind" {
755 fn IOSurfaceSetValues(buffer: &IOSurfaceRef, keys_and_values: &CFDictionary);
756 }
757 unsafe { IOSurfaceSetValues(self, keys_and_values) }
758 }
759
760 #[doc(alias = "IOSurfaceCopyAllValues")]
761 #[cfg(feature = "objc2-core-foundation")]
762 #[inline]
763 pub fn all_values(&self) -> Option<CFRetained<CFDictionary>> {
764 extern "C-unwind" {
765 fn IOSurfaceCopyAllValues(buffer: &IOSurfaceRef) -> Option<NonNull<CFDictionary>>;
766 }
767 let ret = unsafe { IOSurfaceCopyAllValues(self) };
768 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
769 }
770
771 #[doc(alias = "IOSurfaceRemoveAllValues")]
772 #[inline]
773 pub fn remove_all_values(&self) {
774 extern "C-unwind" {
775 fn IOSurfaceRemoveAllValues(buffer: &IOSurfaceRef);
776 }
777 unsafe { IOSurfaceRemoveAllValues(self) }
778 }
779
780 #[doc(alias = "IOSurfaceCreateMachPort")]
781 #[cfg(feature = "libc")]
782 #[inline]
783 pub fn create_mach_port(&self) -> libc::mach_port_t {
784 extern "C-unwind" {
785 fn IOSurfaceCreateMachPort(buffer: &IOSurfaceRef) -> libc::mach_port_t;
786 }
787 unsafe { IOSurfaceCreateMachPort(self) }
788 }
789
790 #[doc(alias = "IOSurfaceLookupFromMachPort")]
791 #[cfg(all(feature = "libc", feature = "objc2-core-foundation"))]
792 #[inline]
793 pub fn lookup_from_mach_port(port: libc::mach_port_t) -> Option<CFRetained<IOSurfaceRef>> {
794 extern "C-unwind" {
795 fn IOSurfaceLookupFromMachPort(
796 port: libc::mach_port_t,
797 ) -> Option<NonNull<IOSurfaceRef>>;
798 }
799 let ret = unsafe { IOSurfaceLookupFromMachPort(port) };
800 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
801 }
802
803 #[doc(alias = "IOSurfaceGetPropertyMaximum")]
804 #[cfg(feature = "objc2-core-foundation")]
805 #[inline]
806 pub fn property_maximum(property: &CFString) -> usize {
807 extern "C-unwind" {
808 fn IOSurfaceGetPropertyMaximum(property: &CFString) -> usize;
809 }
810 unsafe { IOSurfaceGetPropertyMaximum(property) }
811 }
812
813 #[doc(alias = "IOSurfaceGetPropertyAlignment")]
814 #[cfg(feature = "objc2-core-foundation")]
815 #[inline]
816 pub fn property_alignment(property: &CFString) -> usize {
817 extern "C-unwind" {
818 fn IOSurfaceGetPropertyAlignment(property: &CFString) -> usize;
819 }
820 unsafe { IOSurfaceGetPropertyAlignment(property) }
821 }
822
823 #[doc(alias = "IOSurfaceAlignProperty")]
824 #[cfg(feature = "objc2-core-foundation")]
825 #[inline]
826 pub fn align_property(property: &CFString, value: usize) -> usize {
827 extern "C-unwind" {
828 fn IOSurfaceAlignProperty(property: &CFString, value: usize) -> usize;
829 }
830 unsafe { IOSurfaceAlignProperty(property, value) }
831 }
832
833 #[doc(alias = "IOSurfaceIncrementUseCount")]
834 #[inline]
835 pub fn increment_use_count(&self) {
836 extern "C-unwind" {
837 fn IOSurfaceIncrementUseCount(buffer: &IOSurfaceRef);
838 }
839 unsafe { IOSurfaceIncrementUseCount(self) }
840 }
841
842 #[doc(alias = "IOSurfaceDecrementUseCount")]
843 #[inline]
844 pub fn decrement_use_count(&self) {
845 extern "C-unwind" {
846 fn IOSurfaceDecrementUseCount(buffer: &IOSurfaceRef);
847 }
848 unsafe { IOSurfaceDecrementUseCount(self) }
849 }
850
851 #[doc(alias = "IOSurfaceGetUseCount")]
852 #[inline]
853 pub fn use_count(&self) -> i32 {
854 extern "C-unwind" {
855 fn IOSurfaceGetUseCount(buffer: &IOSurfaceRef) -> i32;
856 }
857 unsafe { IOSurfaceGetUseCount(self) }
858 }
859
860 #[doc(alias = "IOSurfaceIsInUse")]
861 #[inline]
862 pub fn is_in_use(&self) -> bool {
863 extern "C-unwind" {
864 fn IOSurfaceIsInUse(buffer: &IOSurfaceRef) -> Boolean;
865 }
866 let ret = unsafe { IOSurfaceIsInUse(self) };
867 ret != 0
868 }
869
870 #[doc(alias = "IOSurfaceAllowsPixelSizeCasting")]
871 #[inline]
872 pub fn allows_pixel_size_casting(&self) -> bool {
873 extern "C-unwind" {
874 fn IOSurfaceAllowsPixelSizeCasting(buffer: &IOSurfaceRef) -> Boolean;
875 }
876 let ret = unsafe { IOSurfaceAllowsPixelSizeCasting(self) };
877 ret != 0
878 }
879
880 #[doc(alias = "IOSurfaceSetPurgeable")]
884 #[cfg(feature = "libc")]
885 #[inline]
886 pub unsafe fn set_purgeable(&self, new_state: u32, old_state: *mut u32) -> libc::kern_return_t {
887 extern "C-unwind" {
888 fn IOSurfaceSetPurgeable(
889 buffer: &IOSurfaceRef,
890 new_state: u32,
891 old_state: *mut u32,
892 ) -> libc::kern_return_t;
893 }
894 unsafe { IOSurfaceSetPurgeable(self, new_state, old_state) }
895 }
896}
897
898#[repr(transparent)]
901#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
902pub struct IOSurfaceMemoryLedgerTags(pub c_int);
903impl IOSurfaceMemoryLedgerTags {
904 #[doc(alias = "kIOSurfaceMemoryLedgerTagDefault")]
905 pub const Default: Self = Self(0x00000001);
906 #[doc(alias = "kIOSurfaceMemoryLedgerTagNetwork")]
907 pub const Network: Self = Self(0x00000002);
908 #[doc(alias = "kIOSurfaceMemoryLedgerTagMedia")]
909 pub const Media: Self = Self(0x00000003);
910 #[doc(alias = "kIOSurfaceMemoryLedgerTagGraphics")]
911 pub const Graphics: Self = Self(0x00000004);
912 #[doc(alias = "kIOSurfaceMemoryLedgerTagNeural")]
913 pub const Neural: Self = Self(0x00000005);
914}
915
916#[cfg(feature = "objc2")]
917unsafe impl Encode for IOSurfaceMemoryLedgerTags {
918 const ENCODING: Encoding = c_int::ENCODING;
919}
920
921#[cfg(feature = "objc2")]
922unsafe impl RefEncode for IOSurfaceMemoryLedgerTags {
923 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
924}
925
926unsafe impl Send for IOSurfaceMemoryLedgerTags {}
927
928unsafe impl Sync for IOSurfaceMemoryLedgerTags {}
929
930#[repr(transparent)]
933#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
934pub struct IOSurfaceMemoryLedgerFlags(pub u32);
935bitflags::bitflags! {
936 impl IOSurfaceMemoryLedgerFlags: u32 {
937 #[doc(alias = "kIOSurfaceMemoryLedgerFlagNoFootprint")]
938 const NoFootprint = 1<<0;
939 }
940}
941
942#[cfg(feature = "objc2")]
943unsafe impl Encode for IOSurfaceMemoryLedgerFlags {
944 const ENCODING: Encoding = u32::ENCODING;
945}
946
947#[cfg(feature = "objc2")]
948unsafe impl RefEncode for IOSurfaceMemoryLedgerFlags {
949 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
950}
951
952unsafe impl Send for IOSurfaceMemoryLedgerFlags {}
953
954unsafe impl Sync for IOSurfaceMemoryLedgerFlags {}
955
956#[cfg(feature = "objc2-core-foundation")]
957#[deprecated = "renamed to `IOSurfaceRef::new`"]
958#[inline]
959pub unsafe extern "C-unwind" fn IOSurfaceCreate(
960 properties: &CFDictionary,
961) -> Option<CFRetained<IOSurfaceRef>> {
962 extern "C-unwind" {
963 fn IOSurfaceCreate(properties: &CFDictionary) -> Option<NonNull<IOSurfaceRef>>;
964 }
965 let ret = unsafe { IOSurfaceCreate(properties) };
966 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
967}
968
969#[cfg(all(feature = "IOSurfaceTypes", feature = "objc2-core-foundation"))]
970#[deprecated = "renamed to `IOSurfaceRef::lookup`"]
971#[inline]
972pub extern "C-unwind" fn IOSurfaceLookup(csid: IOSurfaceID) -> Option<CFRetained<IOSurfaceRef>> {
973 extern "C-unwind" {
974 fn IOSurfaceLookup(csid: IOSurfaceID) -> Option<NonNull<IOSurfaceRef>>;
975 }
976 let ret = unsafe { IOSurfaceLookup(csid) };
977 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
978}
979
980#[cfg(feature = "IOSurfaceTypes")]
981#[deprecated = "renamed to `IOSurfaceRef::id`"]
982#[inline]
983pub extern "C-unwind" fn IOSurfaceGetID(buffer: &IOSurfaceRef) -> IOSurfaceID {
984 extern "C-unwind" {
985 fn IOSurfaceGetID(buffer: &IOSurfaceRef) -> IOSurfaceID;
986 }
987 unsafe { IOSurfaceGetID(buffer) }
988}
989
990extern "C-unwind" {
991 #[cfg(all(feature = "IOSurfaceTypes", feature = "libc"))]
992 #[deprecated = "renamed to `IOSurfaceRef::lock`"]
993 pub fn IOSurfaceLock(
994 buffer: &IOSurfaceRef,
995 options: IOSurfaceLockOptions,
996 seed: *mut u32,
997 ) -> libc::kern_return_t;
998}
999
1000extern "C-unwind" {
1001 #[cfg(all(feature = "IOSurfaceTypes", feature = "libc"))]
1002 #[deprecated = "renamed to `IOSurfaceRef::unlock`"]
1003 pub fn IOSurfaceUnlock(
1004 buffer: &IOSurfaceRef,
1005 options: IOSurfaceLockOptions,
1006 seed: *mut u32,
1007 ) -> libc::kern_return_t;
1008}
1009
1010#[deprecated = "renamed to `IOSurfaceRef::alloc_size`"]
1011#[inline]
1012pub extern "C-unwind" fn IOSurfaceGetAllocSize(buffer: &IOSurfaceRef) -> usize {
1013 extern "C-unwind" {
1014 fn IOSurfaceGetAllocSize(buffer: &IOSurfaceRef) -> usize;
1015 }
1016 unsafe { IOSurfaceGetAllocSize(buffer) }
1017}
1018
1019#[deprecated = "renamed to `IOSurfaceRef::width`"]
1020#[inline]
1021pub extern "C-unwind" fn IOSurfaceGetWidth(buffer: &IOSurfaceRef) -> usize {
1022 extern "C-unwind" {
1023 fn IOSurfaceGetWidth(buffer: &IOSurfaceRef) -> usize;
1024 }
1025 unsafe { IOSurfaceGetWidth(buffer) }
1026}
1027
1028#[deprecated = "renamed to `IOSurfaceRef::height`"]
1029#[inline]
1030pub extern "C-unwind" fn IOSurfaceGetHeight(buffer: &IOSurfaceRef) -> usize {
1031 extern "C-unwind" {
1032 fn IOSurfaceGetHeight(buffer: &IOSurfaceRef) -> usize;
1033 }
1034 unsafe { IOSurfaceGetHeight(buffer) }
1035}
1036
1037#[deprecated = "renamed to `IOSurfaceRef::bytes_per_element`"]
1038#[inline]
1039pub extern "C-unwind" fn IOSurfaceGetBytesPerElement(buffer: &IOSurfaceRef) -> usize {
1040 extern "C-unwind" {
1041 fn IOSurfaceGetBytesPerElement(buffer: &IOSurfaceRef) -> usize;
1042 }
1043 unsafe { IOSurfaceGetBytesPerElement(buffer) }
1044}
1045
1046#[deprecated = "renamed to `IOSurfaceRef::bytes_per_row`"]
1047#[inline]
1048pub extern "C-unwind" fn IOSurfaceGetBytesPerRow(buffer: &IOSurfaceRef) -> usize {
1049 extern "C-unwind" {
1050 fn IOSurfaceGetBytesPerRow(buffer: &IOSurfaceRef) -> usize;
1051 }
1052 unsafe { IOSurfaceGetBytesPerRow(buffer) }
1053}
1054
1055#[deprecated = "renamed to `IOSurfaceRef::base_address`"]
1056#[inline]
1057pub extern "C-unwind" fn IOSurfaceGetBaseAddress(buffer: &IOSurfaceRef) -> NonNull<c_void> {
1058 extern "C-unwind" {
1059 fn IOSurfaceGetBaseAddress(buffer: &IOSurfaceRef) -> Option<NonNull<c_void>>;
1060 }
1061 let ret = unsafe { IOSurfaceGetBaseAddress(buffer) };
1062 ret.expect("function was marked as returning non-null, but actually returned NULL")
1063}
1064
1065#[deprecated = "renamed to `IOSurfaceRef::element_width`"]
1066#[inline]
1067pub extern "C-unwind" fn IOSurfaceGetElementWidth(buffer: &IOSurfaceRef) -> usize {
1068 extern "C-unwind" {
1069 fn IOSurfaceGetElementWidth(buffer: &IOSurfaceRef) -> usize;
1070 }
1071 unsafe { IOSurfaceGetElementWidth(buffer) }
1072}
1073
1074#[deprecated = "renamed to `IOSurfaceRef::element_height`"]
1075#[inline]
1076pub extern "C-unwind" fn IOSurfaceGetElementHeight(buffer: &IOSurfaceRef) -> usize {
1077 extern "C-unwind" {
1078 fn IOSurfaceGetElementHeight(buffer: &IOSurfaceRef) -> usize;
1079 }
1080 unsafe { IOSurfaceGetElementHeight(buffer) }
1081}
1082
1083#[deprecated = "renamed to `IOSurfaceRef::pixel_format`"]
1084#[inline]
1085pub extern "C-unwind" fn IOSurfaceGetPixelFormat(buffer: &IOSurfaceRef) -> OSType {
1086 extern "C-unwind" {
1087 fn IOSurfaceGetPixelFormat(buffer: &IOSurfaceRef) -> OSType;
1088 }
1089 unsafe { IOSurfaceGetPixelFormat(buffer) }
1090}
1091
1092#[deprecated = "renamed to `IOSurfaceRef::seed`"]
1093#[inline]
1094pub extern "C-unwind" fn IOSurfaceGetSeed(buffer: &IOSurfaceRef) -> u32 {
1095 extern "C-unwind" {
1096 fn IOSurfaceGetSeed(buffer: &IOSurfaceRef) -> u32;
1097 }
1098 unsafe { IOSurfaceGetSeed(buffer) }
1099}
1100
1101#[deprecated = "renamed to `IOSurfaceRef::plane_count`"]
1102#[inline]
1103pub extern "C-unwind" fn IOSurfaceGetPlaneCount(buffer: &IOSurfaceRef) -> usize {
1104 extern "C-unwind" {
1105 fn IOSurfaceGetPlaneCount(buffer: &IOSurfaceRef) -> usize;
1106 }
1107 unsafe { IOSurfaceGetPlaneCount(buffer) }
1108}
1109
1110#[deprecated = "renamed to `IOSurfaceRef::width_of_plane`"]
1111#[inline]
1112pub extern "C-unwind" fn IOSurfaceGetWidthOfPlane(
1113 buffer: &IOSurfaceRef,
1114 plane_index: usize,
1115) -> usize {
1116 extern "C-unwind" {
1117 fn IOSurfaceGetWidthOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
1118 }
1119 unsafe { IOSurfaceGetWidthOfPlane(buffer, plane_index) }
1120}
1121
1122#[deprecated = "renamed to `IOSurfaceRef::height_of_plane`"]
1123#[inline]
1124pub extern "C-unwind" fn IOSurfaceGetHeightOfPlane(
1125 buffer: &IOSurfaceRef,
1126 plane_index: usize,
1127) -> usize {
1128 extern "C-unwind" {
1129 fn IOSurfaceGetHeightOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
1130 }
1131 unsafe { IOSurfaceGetHeightOfPlane(buffer, plane_index) }
1132}
1133
1134#[deprecated = "renamed to `IOSurfaceRef::bytes_per_element_of_plane`"]
1135#[inline]
1136pub extern "C-unwind" fn IOSurfaceGetBytesPerElementOfPlane(
1137 buffer: &IOSurfaceRef,
1138 plane_index: usize,
1139) -> usize {
1140 extern "C-unwind" {
1141 fn IOSurfaceGetBytesPerElementOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
1142 }
1143 unsafe { IOSurfaceGetBytesPerElementOfPlane(buffer, plane_index) }
1144}
1145
1146#[deprecated = "renamed to `IOSurfaceRef::bytes_per_row_of_plane`"]
1147#[inline]
1148pub extern "C-unwind" fn IOSurfaceGetBytesPerRowOfPlane(
1149 buffer: &IOSurfaceRef,
1150 plane_index: usize,
1151) -> usize {
1152 extern "C-unwind" {
1153 fn IOSurfaceGetBytesPerRowOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
1154 }
1155 unsafe { IOSurfaceGetBytesPerRowOfPlane(buffer, plane_index) }
1156}
1157
1158#[deprecated = "renamed to `IOSurfaceRef::base_address_of_plane`"]
1159#[inline]
1160pub extern "C-unwind" fn IOSurfaceGetBaseAddressOfPlane(
1161 buffer: &IOSurfaceRef,
1162 plane_index: usize,
1163) -> NonNull<c_void> {
1164 extern "C-unwind" {
1165 fn IOSurfaceGetBaseAddressOfPlane(
1166 buffer: &IOSurfaceRef,
1167 plane_index: usize,
1168 ) -> Option<NonNull<c_void>>;
1169 }
1170 let ret = unsafe { IOSurfaceGetBaseAddressOfPlane(buffer, plane_index) };
1171 ret.expect("function was marked as returning non-null, but actually returned NULL")
1172}
1173
1174#[deprecated = "renamed to `IOSurfaceRef::element_width_of_plane`"]
1175#[inline]
1176pub extern "C-unwind" fn IOSurfaceGetElementWidthOfPlane(
1177 buffer: &IOSurfaceRef,
1178 plane_index: usize,
1179) -> usize {
1180 extern "C-unwind" {
1181 fn IOSurfaceGetElementWidthOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
1182 }
1183 unsafe { IOSurfaceGetElementWidthOfPlane(buffer, plane_index) }
1184}
1185
1186#[deprecated = "renamed to `IOSurfaceRef::element_height_of_plane`"]
1187#[inline]
1188pub extern "C-unwind" fn IOSurfaceGetElementHeightOfPlane(
1189 buffer: &IOSurfaceRef,
1190 plane_index: usize,
1191) -> usize {
1192 extern "C-unwind" {
1193 fn IOSurfaceGetElementHeightOfPlane(buffer: &IOSurfaceRef, plane_index: usize) -> usize;
1194 }
1195 unsafe { IOSurfaceGetElementHeightOfPlane(buffer, plane_index) }
1196}
1197
1198#[deprecated = "renamed to `IOSurfaceRef::number_of_components_of_plane`"]
1199#[inline]
1200pub extern "C-unwind" fn IOSurfaceGetNumberOfComponentsOfPlane(
1201 buffer: &IOSurfaceRef,
1202 plane_index: usize,
1203) -> usize {
1204 extern "C-unwind" {
1205 fn IOSurfaceGetNumberOfComponentsOfPlane(
1206 buffer: &IOSurfaceRef,
1207 plane_index: usize,
1208 ) -> usize;
1209 }
1210 unsafe { IOSurfaceGetNumberOfComponentsOfPlane(buffer, plane_index) }
1211}
1212
1213#[deprecated = "renamed to `IOSurfaceRef::name_of_component_of_plane`"]
1214#[inline]
1215pub extern "C-unwind" fn IOSurfaceGetNameOfComponentOfPlane(
1216 buffer: &IOSurfaceRef,
1217 plane_index: usize,
1218 component_index: usize,
1219) -> IOSurfaceComponentName {
1220 extern "C-unwind" {
1221 fn IOSurfaceGetNameOfComponentOfPlane(
1222 buffer: &IOSurfaceRef,
1223 plane_index: usize,
1224 component_index: usize,
1225 ) -> IOSurfaceComponentName;
1226 }
1227 unsafe { IOSurfaceGetNameOfComponentOfPlane(buffer, plane_index, component_index) }
1228}
1229
1230#[deprecated = "renamed to `IOSurfaceRef::type_of_component_of_plane`"]
1231#[inline]
1232pub extern "C-unwind" fn IOSurfaceGetTypeOfComponentOfPlane(
1233 buffer: &IOSurfaceRef,
1234 plane_index: usize,
1235 component_index: usize,
1236) -> IOSurfaceComponentType {
1237 extern "C-unwind" {
1238 fn IOSurfaceGetTypeOfComponentOfPlane(
1239 buffer: &IOSurfaceRef,
1240 plane_index: usize,
1241 component_index: usize,
1242 ) -> IOSurfaceComponentType;
1243 }
1244 unsafe { IOSurfaceGetTypeOfComponentOfPlane(buffer, plane_index, component_index) }
1245}
1246
1247#[deprecated = "renamed to `IOSurfaceRef::range_of_component_of_plane`"]
1248#[inline]
1249pub extern "C-unwind" fn IOSurfaceGetRangeOfComponentOfPlane(
1250 buffer: &IOSurfaceRef,
1251 plane_index: usize,
1252 component_index: usize,
1253) -> IOSurfaceComponentRange {
1254 extern "C-unwind" {
1255 fn IOSurfaceGetRangeOfComponentOfPlane(
1256 buffer: &IOSurfaceRef,
1257 plane_index: usize,
1258 component_index: usize,
1259 ) -> IOSurfaceComponentRange;
1260 }
1261 unsafe { IOSurfaceGetRangeOfComponentOfPlane(buffer, plane_index, component_index) }
1262}
1263
1264#[deprecated = "renamed to `IOSurfaceRef::bit_depth_of_component_of_plane`"]
1265#[inline]
1266pub extern "C-unwind" fn IOSurfaceGetBitDepthOfComponentOfPlane(
1267 buffer: &IOSurfaceRef,
1268 plane_index: usize,
1269 component_index: usize,
1270) -> usize {
1271 extern "C-unwind" {
1272 fn IOSurfaceGetBitDepthOfComponentOfPlane(
1273 buffer: &IOSurfaceRef,
1274 plane_index: usize,
1275 component_index: usize,
1276 ) -> usize;
1277 }
1278 unsafe { IOSurfaceGetBitDepthOfComponentOfPlane(buffer, plane_index, component_index) }
1279}
1280
1281#[deprecated = "renamed to `IOSurfaceRef::bit_offset_of_component_of_plane`"]
1282#[inline]
1283pub extern "C-unwind" fn IOSurfaceGetBitOffsetOfComponentOfPlane(
1284 buffer: &IOSurfaceRef,
1285 plane_index: usize,
1286 component_index: usize,
1287) -> usize {
1288 extern "C-unwind" {
1289 fn IOSurfaceGetBitOffsetOfComponentOfPlane(
1290 buffer: &IOSurfaceRef,
1291 plane_index: usize,
1292 component_index: usize,
1293 ) -> usize;
1294 }
1295 unsafe { IOSurfaceGetBitOffsetOfComponentOfPlane(buffer, plane_index, component_index) }
1296}
1297
1298#[deprecated = "renamed to `IOSurfaceRef::subsampling`"]
1299#[inline]
1300pub extern "C-unwind" fn IOSurfaceGetSubsampling(buffer: &IOSurfaceRef) -> IOSurfaceSubsampling {
1301 extern "C-unwind" {
1302 fn IOSurfaceGetSubsampling(buffer: &IOSurfaceRef) -> IOSurfaceSubsampling;
1303 }
1304 unsafe { IOSurfaceGetSubsampling(buffer) }
1305}
1306
1307extern "C-unwind" {
1308 #[cfg(feature = "objc2-core-foundation")]
1309 #[deprecated = "renamed to `IOSurfaceRef::set_value`"]
1310 pub fn IOSurfaceSetValue(buffer: &IOSurfaceRef, key: &CFString, value: &CFType);
1311}
1312
1313#[cfg(feature = "objc2-core-foundation")]
1314#[deprecated = "renamed to `IOSurfaceRef::value`"]
1315#[inline]
1316pub extern "C-unwind" fn IOSurfaceCopyValue(
1317 buffer: &IOSurfaceRef,
1318 key: &CFString,
1319) -> Option<CFRetained<CFType>> {
1320 extern "C-unwind" {
1321 fn IOSurfaceCopyValue(buffer: &IOSurfaceRef, key: &CFString) -> Option<NonNull<CFType>>;
1322 }
1323 let ret = unsafe { IOSurfaceCopyValue(buffer, key) };
1324 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1325}
1326
1327#[cfg(feature = "objc2-core-foundation")]
1328#[deprecated = "renamed to `IOSurfaceRef::remove_value`"]
1329#[inline]
1330pub extern "C-unwind" fn IOSurfaceRemoveValue(buffer: &IOSurfaceRef, key: &CFString) {
1331 extern "C-unwind" {
1332 fn IOSurfaceRemoveValue(buffer: &IOSurfaceRef, key: &CFString);
1333 }
1334 unsafe { IOSurfaceRemoveValue(buffer, key) }
1335}
1336
1337extern "C-unwind" {
1338 #[cfg(feature = "objc2-core-foundation")]
1339 #[deprecated = "renamed to `IOSurfaceRef::set_values`"]
1340 pub fn IOSurfaceSetValues(buffer: &IOSurfaceRef, keys_and_values: &CFDictionary);
1341}
1342
1343#[cfg(feature = "objc2-core-foundation")]
1344#[deprecated = "renamed to `IOSurfaceRef::all_values`"]
1345#[inline]
1346pub extern "C-unwind" fn IOSurfaceCopyAllValues(
1347 buffer: &IOSurfaceRef,
1348) -> Option<CFRetained<CFDictionary>> {
1349 extern "C-unwind" {
1350 fn IOSurfaceCopyAllValues(buffer: &IOSurfaceRef) -> Option<NonNull<CFDictionary>>;
1351 }
1352 let ret = unsafe { IOSurfaceCopyAllValues(buffer) };
1353 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1354}
1355
1356#[deprecated = "renamed to `IOSurfaceRef::remove_all_values`"]
1357#[inline]
1358pub extern "C-unwind" fn IOSurfaceRemoveAllValues(buffer: &IOSurfaceRef) {
1359 extern "C-unwind" {
1360 fn IOSurfaceRemoveAllValues(buffer: &IOSurfaceRef);
1361 }
1362 unsafe { IOSurfaceRemoveAllValues(buffer) }
1363}
1364
1365#[cfg(feature = "libc")]
1366#[deprecated = "renamed to `IOSurfaceRef::create_mach_port`"]
1367#[inline]
1368pub extern "C-unwind" fn IOSurfaceCreateMachPort(buffer: &IOSurfaceRef) -> libc::mach_port_t {
1369 extern "C-unwind" {
1370 fn IOSurfaceCreateMachPort(buffer: &IOSurfaceRef) -> libc::mach_port_t;
1371 }
1372 unsafe { IOSurfaceCreateMachPort(buffer) }
1373}
1374
1375#[cfg(all(feature = "libc", feature = "objc2-core-foundation"))]
1376#[deprecated = "renamed to `IOSurfaceRef::lookup_from_mach_port`"]
1377#[inline]
1378pub extern "C-unwind" fn IOSurfaceLookupFromMachPort(
1379 port: libc::mach_port_t,
1380) -> Option<CFRetained<IOSurfaceRef>> {
1381 extern "C-unwind" {
1382 fn IOSurfaceLookupFromMachPort(port: libc::mach_port_t) -> Option<NonNull<IOSurfaceRef>>;
1383 }
1384 let ret = unsafe { IOSurfaceLookupFromMachPort(port) };
1385 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1386}
1387
1388#[cfg(feature = "objc2-core-foundation")]
1389#[deprecated = "renamed to `IOSurfaceRef::property_maximum`"]
1390#[inline]
1391pub extern "C-unwind" fn IOSurfaceGetPropertyMaximum(property: &CFString) -> usize {
1392 extern "C-unwind" {
1393 fn IOSurfaceGetPropertyMaximum(property: &CFString) -> usize;
1394 }
1395 unsafe { IOSurfaceGetPropertyMaximum(property) }
1396}
1397
1398#[cfg(feature = "objc2-core-foundation")]
1399#[deprecated = "renamed to `IOSurfaceRef::property_alignment`"]
1400#[inline]
1401pub extern "C-unwind" fn IOSurfaceGetPropertyAlignment(property: &CFString) -> usize {
1402 extern "C-unwind" {
1403 fn IOSurfaceGetPropertyAlignment(property: &CFString) -> usize;
1404 }
1405 unsafe { IOSurfaceGetPropertyAlignment(property) }
1406}
1407
1408#[cfg(feature = "objc2-core-foundation")]
1409#[deprecated = "renamed to `IOSurfaceRef::align_property`"]
1410#[inline]
1411pub extern "C-unwind" fn IOSurfaceAlignProperty(property: &CFString, value: usize) -> usize {
1412 extern "C-unwind" {
1413 fn IOSurfaceAlignProperty(property: &CFString, value: usize) -> usize;
1414 }
1415 unsafe { IOSurfaceAlignProperty(property, value) }
1416}
1417
1418#[deprecated = "renamed to `IOSurfaceRef::increment_use_count`"]
1419#[inline]
1420pub extern "C-unwind" fn IOSurfaceIncrementUseCount(buffer: &IOSurfaceRef) {
1421 extern "C-unwind" {
1422 fn IOSurfaceIncrementUseCount(buffer: &IOSurfaceRef);
1423 }
1424 unsafe { IOSurfaceIncrementUseCount(buffer) }
1425}
1426
1427#[deprecated = "renamed to `IOSurfaceRef::decrement_use_count`"]
1428#[inline]
1429pub extern "C-unwind" fn IOSurfaceDecrementUseCount(buffer: &IOSurfaceRef) {
1430 extern "C-unwind" {
1431 fn IOSurfaceDecrementUseCount(buffer: &IOSurfaceRef);
1432 }
1433 unsafe { IOSurfaceDecrementUseCount(buffer) }
1434}
1435
1436#[deprecated = "renamed to `IOSurfaceRef::use_count`"]
1437#[inline]
1438pub extern "C-unwind" fn IOSurfaceGetUseCount(buffer: &IOSurfaceRef) -> i32 {
1439 extern "C-unwind" {
1440 fn IOSurfaceGetUseCount(buffer: &IOSurfaceRef) -> i32;
1441 }
1442 unsafe { IOSurfaceGetUseCount(buffer) }
1443}
1444
1445#[deprecated = "renamed to `IOSurfaceRef::is_in_use`"]
1446#[inline]
1447pub extern "C-unwind" fn IOSurfaceIsInUse(buffer: &IOSurfaceRef) -> bool {
1448 extern "C-unwind" {
1449 fn IOSurfaceIsInUse(buffer: &IOSurfaceRef) -> Boolean;
1450 }
1451 let ret = unsafe { IOSurfaceIsInUse(buffer) };
1452 ret != 0
1453}
1454
1455#[deprecated = "renamed to `IOSurfaceRef::allows_pixel_size_casting`"]
1456#[inline]
1457pub extern "C-unwind" fn IOSurfaceAllowsPixelSizeCasting(buffer: &IOSurfaceRef) -> bool {
1458 extern "C-unwind" {
1459 fn IOSurfaceAllowsPixelSizeCasting(buffer: &IOSurfaceRef) -> Boolean;
1460 }
1461 let ret = unsafe { IOSurfaceAllowsPixelSizeCasting(buffer) };
1462 ret != 0
1463}
1464
1465extern "C-unwind" {
1466 #[cfg(feature = "libc")]
1467 #[deprecated = "renamed to `IOSurfaceRef::set_purgeable`"]
1468 pub fn IOSurfaceSetPurgeable(
1469 buffer: &IOSurfaceRef,
1470 new_state: u32,
1471 old_state: *mut u32,
1472 ) -> libc::kern_return_t;
1473}