objc2_core_video/generated/CVMetalBufferCache.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#[cfg(feature = "objc2-metal")]
11#[cfg(not(target_os = "watchos"))]
12use objc2_metal::*;
13
14use crate::*;
15
16extern "C" {
17 /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvmetalbuffercachemaximumbufferagekey?language=objc)
18 pub static kCVMetalBufferCacheMaximumBufferAgeKey: &'static CFString;
19}
20
21/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvmetalbuffercache?language=objc)
22#[repr(C)]
23pub struct CVMetalBufferCache {
24 inner: [u8; 0],
25 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
26}
27
28cf_type!(
29 #[encoding_name = "__CVMetalBufferCache"]
30 unsafe impl CVMetalBufferCache {}
31);
32
33unsafe impl ConcreteType for CVMetalBufferCache {
34 #[doc(alias = "CVMetalBufferCacheGetTypeID")]
35 #[inline]
36 fn type_id() -> CFTypeID {
37 extern "C-unwind" {
38 fn CVMetalBufferCacheGetTypeID() -> CFTypeID;
39 }
40 unsafe { CVMetalBufferCacheGetTypeID() }
41 }
42}
43
44extern "C-unwind" {
45 /// Creates a new Buffer Cache.
46 ///
47 /// Parameter `allocator`: The CFAllocatorRef to use for allocating the cache. May be NULL.
48 ///
49 /// Parameter `cacheAttributes`: A CFDictionaryRef containing the attributes of the cache itself. May be NULL.
50 ///
51 /// Parameter `metalDevice`: The Metal device for which the buffer objects will be created.
52 ///
53 /// Parameter `cacheOut`: The newly created buffer cache will be placed here
54 ///
55 /// Returns: Returns kCVReturnSuccess on success
56 #[cfg(all(feature = "CVReturn", feature = "objc2", feature = "objc2-metal"))]
57 #[cfg(not(target_os = "watchos"))]
58 pub fn CVMetalBufferCacheCreate(
59 allocator: Option<&CFAllocator>,
60 cache_attributes: Option<&CFDictionary>,
61 metal_device: &ProtocolObject<dyn MTLDevice>,
62 cache_out: NonNull<*mut CVMetalBufferCache>,
63 ) -> CVReturn;
64}
65
66extern "C-unwind" {
67 /// Creates a CVMetalBuffer object from an existing CVImageBuffer
68 ///
69 /// Parameter `allocator`: The CFAllocatorRef to use for allocating the CVMetalBuffer object. May be NULL.
70 ///
71 /// Parameter `bufferCache`: The buffer cache object that will manage the buffer.
72 ///
73 /// Parameter `buffer`: The CVImageBuffer that you want to create a CVMetalBuffer from.
74 ///
75 /// Parameter `bufferOut`: The newly created buffer object will be placed here.
76 ///
77 /// Returns: Returns kCVReturnSuccess on success
78 ///
79 /// Creates or returns a cached CVMetalBuffer object mapped to the CVImageBuffer.
80 /// This creates a live binding between the CVImageBuffer and underlying CVMetalBuffer buffer object.
81 ///
82 /// IMPORTANT NOTE: Clients should retain CVMetalBuffer objects until they are done using the images in them.
83 /// Retaining a CVMetalBuffer is your way to indicate that you're still using the image in the buffer, and that it should not be recycled yet.
84 #[cfg(all(
85 feature = "CVBuffer",
86 feature = "CVImageBuffer",
87 feature = "CVMetalBuffer",
88 feature = "CVReturn"
89 ))]
90 pub fn CVMetalBufferCacheCreateBufferFromImage(
91 allocator: Option<&CFAllocator>,
92 buffer_cache: &CVMetalBufferCache,
93 image_buffer: &CVImageBuffer,
94 buffer_out: NonNull<*mut CVMetalBuffer>,
95 ) -> CVReturn;
96}
97
98extern "C-unwind" {
99 /// Performs internal housekeeping/recycling operations
100 ///
101 /// This call must be made periodically to give the buffer cache a chance to do internal housekeeping operations.
102 ///
103 /// Parameter `bufferCache`: The buffer cache object to flush
104 ///
105 /// Parameter `options`: Currently unused, set to 0.
106 #[cfg(feature = "CVBase")]
107 pub fn CVMetalBufferCacheFlush(buffer_cache: &CVMetalBufferCache, options: CVOptionFlags);
108}