objc2_core_graphics/generated/
CGLayer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cglayer?language=objc)
14#[repr(C)]
15pub struct CGLayer {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    unsafe impl CGLayer {}
22);
23#[cfg(feature = "objc2")]
24cf_objc2_type!(
25    unsafe impl RefEncode<"CGLayer"> for CGLayer {}
26);
27
28impl CGLayer {
29    #[doc(alias = "CGLayerCreateWithContext")]
30    #[cfg(feature = "CGContext")]
31    #[inline]
32    pub unsafe fn with_context(
33        context: Option<&CGContext>,
34        size: CGSize,
35        auxiliary_info: Option<&CFDictionary>,
36    ) -> Option<CFRetained<CGLayer>> {
37        extern "C-unwind" {
38            fn CGLayerCreateWithContext(
39                context: Option<&CGContext>,
40                size: CGSize,
41                auxiliary_info: Option<&CFDictionary>,
42            ) -> Option<NonNull<CGLayer>>;
43        }
44        let ret = unsafe { CGLayerCreateWithContext(context, size, auxiliary_info) };
45        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
46    }
47
48    #[doc(alias = "CGLayerGetSize")]
49    #[inline]
50    pub unsafe fn size(layer: Option<&CGLayer>) -> CGSize {
51        extern "C-unwind" {
52            fn CGLayerGetSize(layer: Option<&CGLayer>) -> CGSize;
53        }
54        unsafe { CGLayerGetSize(layer) }
55    }
56
57    #[doc(alias = "CGLayerGetContext")]
58    #[cfg(feature = "CGContext")]
59    #[inline]
60    pub unsafe fn context(layer: Option<&CGLayer>) -> Option<CFRetained<CGContext>> {
61        extern "C-unwind" {
62            fn CGLayerGetContext(layer: Option<&CGLayer>) -> Option<NonNull<CGContext>>;
63        }
64        let ret = unsafe { CGLayerGetContext(layer) };
65        ret.map(|ret| unsafe { CFRetained::retain(ret) })
66    }
67}
68
69#[cfg(feature = "CGContext")]
70impl CGContext {
71    #[doc(alias = "CGContextDrawLayerInRect")]
72    #[cfg(feature = "CGContext")]
73    #[inline]
74    pub unsafe fn draw_layer_in_rect(
75        context: Option<&CGContext>,
76        rect: CGRect,
77        layer: Option<&CGLayer>,
78    ) {
79        extern "C-unwind" {
80            fn CGContextDrawLayerInRect(
81                context: Option<&CGContext>,
82                rect: CGRect,
83                layer: Option<&CGLayer>,
84            );
85        }
86        unsafe { CGContextDrawLayerInRect(context, rect, layer) }
87    }
88
89    #[doc(alias = "CGContextDrawLayerAtPoint")]
90    #[cfg(feature = "CGContext")]
91    #[inline]
92    pub unsafe fn draw_layer_at_point(
93        context: Option<&CGContext>,
94        point: CGPoint,
95        layer: Option<&CGLayer>,
96    ) {
97        extern "C-unwind" {
98            fn CGContextDrawLayerAtPoint(
99                context: Option<&CGContext>,
100                point: CGPoint,
101                layer: Option<&CGLayer>,
102            );
103        }
104        unsafe { CGContextDrawLayerAtPoint(context, point, layer) }
105    }
106}
107
108unsafe impl ConcreteType for CGLayer {
109    #[doc(alias = "CGLayerGetTypeID")]
110    #[inline]
111    fn type_id() -> CFTypeID {
112        extern "C-unwind" {
113            fn CGLayerGetTypeID() -> CFTypeID;
114        }
115        unsafe { CGLayerGetTypeID() }
116    }
117}
118
119#[cfg(feature = "CGContext")]
120#[deprecated = "renamed to `CGLayer::with_context`"]
121#[inline]
122pub unsafe extern "C-unwind" fn CGLayerCreateWithContext(
123    context: Option<&CGContext>,
124    size: CGSize,
125    auxiliary_info: Option<&CFDictionary>,
126) -> Option<CFRetained<CGLayer>> {
127    extern "C-unwind" {
128        fn CGLayerCreateWithContext(
129            context: Option<&CGContext>,
130            size: CGSize,
131            auxiliary_info: Option<&CFDictionary>,
132        ) -> Option<NonNull<CGLayer>>;
133    }
134    let ret = unsafe { CGLayerCreateWithContext(context, size, auxiliary_info) };
135    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
136}
137
138extern "C-unwind" {
139    #[deprecated = "renamed to `CGLayer::size`"]
140    pub fn CGLayerGetSize(layer: Option<&CGLayer>) -> CGSize;
141}
142
143#[cfg(feature = "CGContext")]
144#[deprecated = "renamed to `CGLayer::context`"]
145#[inline]
146pub unsafe extern "C-unwind" fn CGLayerGetContext(
147    layer: Option<&CGLayer>,
148) -> Option<CFRetained<CGContext>> {
149    extern "C-unwind" {
150        fn CGLayerGetContext(layer: Option<&CGLayer>) -> Option<NonNull<CGContext>>;
151    }
152    let ret = unsafe { CGLayerGetContext(layer) };
153    ret.map(|ret| unsafe { CFRetained::retain(ret) })
154}
155
156extern "C-unwind" {
157    #[cfg(feature = "CGContext")]
158    #[deprecated = "renamed to `CGContext::draw_layer_in_rect`"]
159    pub fn CGContextDrawLayerInRect(
160        context: Option<&CGContext>,
161        rect: CGRect,
162        layer: Option<&CGLayer>,
163    );
164}
165
166extern "C-unwind" {
167    #[cfg(feature = "CGContext")]
168    #[deprecated = "renamed to `CGContext::draw_layer_at_point`"]
169    pub fn CGContextDrawLayerAtPoint(
170        context: Option<&CGContext>,
171        point: CGPoint,
172        layer: Option<&CGLayer>,
173    );
174}