objc2_core_video/generated/
CVMetalBufferCache.rs1use 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#[cfg(feature = "objc2-metal")]
11#[cfg(not(target_os = "watchos"))]
12use objc2_metal::*;
13
14use crate::*;
15
16extern "C" {
17 pub static kCVMetalBufferCacheMaximumBufferAgeKey: &'static CFString;
19}
20
21#[doc(alias = "CVMetalBufferCacheRef")]
23#[repr(C)]
24pub struct CVMetalBufferCache {
25 inner: [u8; 0],
26 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
27}
28
29cf_type!(
30 unsafe impl CVMetalBufferCache {}
31);
32#[cfg(feature = "objc2")]
33cf_objc2_type!(
34 unsafe impl RefEncode<"__CVMetalBufferCache"> for CVMetalBufferCache {}
35);
36
37unsafe impl ConcreteType for CVMetalBufferCache {
38 #[doc(alias = "CVMetalBufferCacheGetTypeID")]
39 #[inline]
40 fn type_id() -> CFTypeID {
41 extern "C-unwind" {
42 fn CVMetalBufferCacheGetTypeID() -> CFTypeID;
43 }
44 unsafe { CVMetalBufferCacheGetTypeID() }
45 }
46}
47
48impl CVMetalBufferCache {
49 #[doc(alias = "CVMetalBufferCacheCreate")]
66 #[cfg(all(feature = "CVReturn", feature = "objc2", feature = "objc2-metal"))]
67 #[cfg(not(target_os = "watchos"))]
68 #[inline]
69 pub unsafe fn create(
70 allocator: Option<&CFAllocator>,
71 cache_attributes: Option<&CFDictionary>,
72 metal_device: &ProtocolObject<dyn MTLDevice>,
73 cache_out: NonNull<*mut CVMetalBufferCache>,
74 ) -> CVReturn {
75 extern "C-unwind" {
76 fn CVMetalBufferCacheCreate(
77 allocator: Option<&CFAllocator>,
78 cache_attributes: Option<&CFDictionary>,
79 metal_device: &ProtocolObject<dyn MTLDevice>,
80 cache_out: NonNull<*mut CVMetalBufferCache>,
81 ) -> CVReturn;
82 }
83 unsafe { CVMetalBufferCacheCreate(allocator, cache_attributes, metal_device, cache_out) }
84 }
85
86 #[doc(alias = "CVMetalBufferCacheCreateBufferFromImage")]
108 #[cfg(all(
109 feature = "CVBuffer",
110 feature = "CVImageBuffer",
111 feature = "CVMetalBuffer",
112 feature = "CVReturn"
113 ))]
114 #[inline]
115 pub unsafe fn create_buffer_from_image(
116 allocator: Option<&CFAllocator>,
117 buffer_cache: &CVMetalBufferCache,
118 image_buffer: &CVImageBuffer,
119 buffer_out: NonNull<*mut CVMetalBuffer>,
120 ) -> CVReturn {
121 extern "C-unwind" {
122 fn CVMetalBufferCacheCreateBufferFromImage(
123 allocator: Option<&CFAllocator>,
124 buffer_cache: &CVMetalBufferCache,
125 image_buffer: &CVImageBuffer,
126 buffer_out: NonNull<*mut CVMetalBuffer>,
127 ) -> CVReturn;
128 }
129 unsafe {
130 CVMetalBufferCacheCreateBufferFromImage(
131 allocator,
132 buffer_cache,
133 image_buffer,
134 buffer_out,
135 )
136 }
137 }
138
139 #[doc(alias = "CVMetalBufferCacheFlush")]
147 #[cfg(feature = "CVBase")]
148 #[inline]
149 pub fn flush(&self, options: CVOptionFlags) {
150 extern "C-unwind" {
151 fn CVMetalBufferCacheFlush(buffer_cache: &CVMetalBufferCache, options: CVOptionFlags);
152 }
153 unsafe { CVMetalBufferCacheFlush(self, options) }
154 }
155}
156
157extern "C-unwind" {
158 #[cfg(all(feature = "CVReturn", feature = "objc2", feature = "objc2-metal"))]
159 #[cfg(not(target_os = "watchos"))]
160 #[deprecated = "renamed to `CVMetalBufferCache::create`"]
161 pub fn CVMetalBufferCacheCreate(
162 allocator: Option<&CFAllocator>,
163 cache_attributes: Option<&CFDictionary>,
164 metal_device: &ProtocolObject<dyn MTLDevice>,
165 cache_out: NonNull<*mut CVMetalBufferCache>,
166 ) -> CVReturn;
167}
168
169extern "C-unwind" {
170 #[cfg(all(
171 feature = "CVBuffer",
172 feature = "CVImageBuffer",
173 feature = "CVMetalBuffer",
174 feature = "CVReturn"
175 ))]
176 #[deprecated = "renamed to `CVMetalBufferCache::create_buffer_from_image`"]
177 pub fn CVMetalBufferCacheCreateBufferFromImage(
178 allocator: Option<&CFAllocator>,
179 buffer_cache: &CVMetalBufferCache,
180 image_buffer: &CVImageBuffer,
181 buffer_out: NonNull<*mut CVMetalBuffer>,
182 ) -> CVReturn;
183}
184
185#[cfg(feature = "CVBase")]
186#[deprecated = "renamed to `CVMetalBufferCache::flush`"]
187#[inline]
188pub extern "C-unwind" fn CVMetalBufferCacheFlush(
189 buffer_cache: &CVMetalBufferCache,
190 options: CVOptionFlags,
191) {
192 extern "C-unwind" {
193 fn CVMetalBufferCacheFlush(buffer_cache: &CVMetalBufferCache, options: CVOptionFlags);
194 }
195 unsafe { CVMetalBufferCacheFlush(buffer_cache, options) }
196}