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#[doc(alias = "CGLayerRef")]
15#[repr(C)]
16pub struct CGLayer {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl CGLayer {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"CGLayer"> for CGLayer {}
27);
28
29impl CGLayer {
30    /// # Safety
31    ///
32    /// `auxiliary_info` generics must be of the correct type.
33    #[doc(alias = "CGLayerCreateWithContext")]
34    #[cfg(feature = "CGContext")]
35    #[inline]
36    pub unsafe fn with_context(
37        context: Option<&CGContext>,
38        size: CGSize,
39        auxiliary_info: Option<&CFDictionary>,
40    ) -> Option<CFRetained<CGLayer>> {
41        extern "C-unwind" {
42            fn CGLayerCreateWithContext(
43                context: Option<&CGContext>,
44                size: CGSize,
45                auxiliary_info: Option<&CFDictionary>,
46            ) -> Option<NonNull<CGLayer>>;
47        }
48        let ret = unsafe { CGLayerCreateWithContext(context, size, auxiliary_info) };
49        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
50    }
51
52    #[doc(alias = "CGLayerGetSize")]
53    #[inline]
54    pub fn size(layer: Option<&CGLayer>) -> CGSize {
55        extern "C-unwind" {
56            fn CGLayerGetSize(layer: Option<&CGLayer>) -> CGSize;
57        }
58        unsafe { CGLayerGetSize(layer) }
59    }
60
61    #[doc(alias = "CGLayerGetContext")]
62    #[cfg(feature = "CGContext")]
63    #[inline]
64    pub fn context(layer: Option<&CGLayer>) -> Option<CFRetained<CGContext>> {
65        extern "C-unwind" {
66            fn CGLayerGetContext(layer: Option<&CGLayer>) -> Option<NonNull<CGContext>>;
67        }
68        let ret = unsafe { CGLayerGetContext(layer) };
69        ret.map(|ret| unsafe { CFRetained::retain(ret) })
70    }
71}
72
73#[cfg(feature = "CGContext")]
74impl CGContext {
75    #[doc(alias = "CGContextDrawLayerInRect")]
76    #[cfg(feature = "CGContext")]
77    #[inline]
78    pub fn draw_layer_in_rect(context: Option<&CGContext>, rect: CGRect, layer: Option<&CGLayer>) {
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 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
138#[deprecated = "renamed to `CGLayer::size`"]
139#[inline]
140pub extern "C-unwind" fn CGLayerGetSize(layer: Option<&CGLayer>) -> CGSize {
141    extern "C-unwind" {
142        fn CGLayerGetSize(layer: Option<&CGLayer>) -> CGSize;
143    }
144    unsafe { CGLayerGetSize(layer) }
145}
146
147#[cfg(feature = "CGContext")]
148#[deprecated = "renamed to `CGLayer::context`"]
149#[inline]
150pub extern "C-unwind" fn CGLayerGetContext(
151    layer: Option<&CGLayer>,
152) -> Option<CFRetained<CGContext>> {
153    extern "C-unwind" {
154        fn CGLayerGetContext(layer: Option<&CGLayer>) -> Option<NonNull<CGContext>>;
155    }
156    let ret = unsafe { CGLayerGetContext(layer) };
157    ret.map(|ret| unsafe { CFRetained::retain(ret) })
158}
159
160#[cfg(feature = "CGContext")]
161#[deprecated = "renamed to `CGContext::draw_layer_in_rect`"]
162#[inline]
163pub extern "C-unwind" fn CGContextDrawLayerInRect(
164    context: Option<&CGContext>,
165    rect: CGRect,
166    layer: Option<&CGLayer>,
167) {
168    extern "C-unwind" {
169        fn CGContextDrawLayerInRect(
170            context: Option<&CGContext>,
171            rect: CGRect,
172            layer: Option<&CGLayer>,
173        );
174    }
175    unsafe { CGContextDrawLayerInRect(context, rect, layer) }
176}
177
178#[cfg(feature = "CGContext")]
179#[deprecated = "renamed to `CGContext::draw_layer_at_point`"]
180#[inline]
181pub extern "C-unwind" fn CGContextDrawLayerAtPoint(
182    context: Option<&CGContext>,
183    point: CGPoint,
184    layer: Option<&CGLayer>,
185) {
186    extern "C-unwind" {
187        fn CGContextDrawLayerAtPoint(
188            context: Option<&CGContext>,
189            point: CGPoint,
190            layer: Option<&CGLayer>,
191        );
192    }
193    unsafe { CGContextDrawLayerAtPoint(context, point, layer) }
194}