objc2_metal_performance_shaders/generated/MPSImage/MPSImageKeypoint.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7use objc2_metal::*;
8
9use crate::*;
10
11/// Specifies information to find the keypoints in an image.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagekeypointrangeinfo?language=objc)
14#[repr(C)]
15#[derive(Clone, Copy, Debug, PartialEq)]
16pub struct MPSImageKeypointRangeInfo {
17 /// maximum number of keypoints
18 pub maximumKeypoints: NSUInteger,
19 /// minimum threshold value - value between 0.0 and 1.0f
20 pub minimumThresholdValue: c_float,
21}
22
23unsafe impl Encode for MPSImageKeypointRangeInfo {
24 const ENCODING: Encoding =
25 Encoding::Struct("?", &[<NSUInteger>::ENCODING, <c_float>::ENCODING]);
26}
27
28unsafe impl RefEncode for MPSImageKeypointRangeInfo {
29 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33 /// The MPSImageFindKeypoints kernel is used to find a list of keypoints whose values are >= minimumPixelThresholdValue
34 /// in MPSImageKeypointRangeInfo. The keypoints are generated for a specified region in the image.
35 /// The pixel format of the source image must be MTLPixelFormatR8Unorm.
36 ///
37 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagefindkeypoints?language=objc)
38 #[unsafe(super(MPSKernel, NSObject))]
39 #[derive(Debug, PartialEq, Eq, Hash)]
40 #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
41 pub struct MPSImageFindKeypoints;
42);
43
44#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
45extern_conformance!(
46 unsafe impl NSCoding for MPSImageFindKeypoints {}
47);
48
49#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
50extern_conformance!(
51 unsafe impl NSCopying for MPSImageFindKeypoints {}
52);
53
54#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
55unsafe impl CopyingHelper for MPSImageFindKeypoints {
56 type Result = Self;
57}
58
59#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
60extern_conformance!(
61 unsafe impl NSObjectProtocol for MPSImageFindKeypoints {}
62);
63
64#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
65extern_conformance!(
66 unsafe impl NSSecureCoding for MPSImageFindKeypoints {}
67);
68
69#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
70impl MPSImageFindKeypoints {
71 extern_methods!(
72 /// Return a structure describing the keypoint range info
73 ///
74 /// Returns a MPSImageKeypointRangeInfo structure
75 #[unsafe(method(keypointRangeInfo))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn keypointRangeInfo(&self) -> MPSImageKeypointRangeInfo;
78
79 /// Specifies information to find keypoints in an image.
80 ///
81 /// Parameter `device`: The device the filter will run on
82 ///
83 /// Parameter `info`: Pointer to the MPSImageKeypointRangeInfo struct
84 ///
85 /// Returns: A valid MPSImageFindKeypoints object or nil, if failure.
86 ///
87 /// # Safety
88 ///
89 /// `info` must be a valid pointer.
90 #[unsafe(method(initWithDevice:info:))]
91 #[unsafe(method_family = init)]
92 pub unsafe fn initWithDevice_info(
93 this: Allocated<Self>,
94 device: &ProtocolObject<dyn MTLDevice>,
95 info: NonNull<MPSImageKeypointRangeInfo>,
96 ) -> Retained<Self>;
97
98 #[unsafe(method(initWithDevice:))]
99 #[unsafe(method_family = init)]
100 pub unsafe fn initWithDevice(
101 this: Allocated<Self>,
102 device: &ProtocolObject<dyn MTLDevice>,
103 ) -> Retained<Self>;
104
105 /// NSSecureCoding compatability
106 ///
107 /// While the standard NSSecureCoding/NSCoding method
108 /// -initWithCoder: should work, since the file can't
109 /// know which device your data is allocated on, we
110 /// have to guess and may guess incorrectly. To avoid
111 /// that problem, use initWithCoder:device instead.
112 ///
113 /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
114 ///
115 /// Parameter `device`: The MTLDevice on which to make the MPSKernel
116 ///
117 /// Returns: A new MPSKernel object, or nil if failure.
118 ///
119 /// # Safety
120 ///
121 /// `a_decoder` possibly has further requirements.
122 #[unsafe(method(initWithCoder:device:))]
123 #[unsafe(method_family = init)]
124 pub unsafe fn initWithCoder_device(
125 this: Allocated<Self>,
126 a_decoder: &NSCoder,
127 device: &ProtocolObject<dyn MTLDevice>,
128 ) -> Option<Retained<Self>>;
129
130 /// Encode the filter to a command buffer using a MTLComputeCommandEncoder.
131 ///
132 /// The filter will not begin to execute until after the command
133 /// buffer has been enqueued and committed.
134 ///
135 ///
136 /// Parameter `commandBuffer`: A valid MTLCommandBuffer.
137 ///
138 /// Parameter `source`: A valid MTLTexture containing the source image for the filter.
139 ///
140 /// Parameter `regions`: An array of rectangles that describe regions in the image.
141 /// The list of keypoints is generated for each individual rectangle specifed.
142 ///
143 /// Parameter `keypointCountBuffer`: The list of keypoints for each specified region
144 ///
145 /// Parameter `keypointCountBufferOffset`: Byte offset into keypointCountBufferOffset buffer at which to write the keypoint results.
146 /// Must be a multiple of 32 bytes.
147 ///
148 /// Parameter `keypointDataBuffer`: A valid MTLBuffer to receive the keypoint data results for each rectangle.
149 /// The keypoint data for keypoints in each rectangle are stored consecutively.
150 /// The keypoint data for each rectangle starts at the following offset:
151 /// MPSImageKeypointRangeInfo.maximumKeyPoints * rectangle index
152 ///
153 /// Parameter `keypointDataBufferOffset`: Byte offset into keypointData buffer at which to write the keypoint results.
154 /// Must be a multiple of 32 bytes.
155 ///
156 /// # Safety
157 ///
158 /// - `source` may need to be synchronized.
159 /// - `source` may be unretained, you must ensure it is kept alive while in use.
160 /// - `regions` must be a valid pointer.
161 /// - `keypoint_count_buffer` may need to be synchronized.
162 /// - `keypoint_count_buffer` may be unretained, you must ensure it is kept alive while in use.
163 /// - `keypoint_count_buffer` contents should be of the correct type.
164 /// - `keypoint_data_buffer` may need to be synchronized.
165 /// - `keypoint_data_buffer` may be unretained, you must ensure it is kept alive while in use.
166 /// - `keypoint_data_buffer` contents should be of the correct type.
167 #[unsafe(method(encodeToCommandBuffer:sourceTexture:regions:numberOfRegions:keypointCountBuffer:keypointCountBufferOffset:keypointDataBuffer:keypointDataBufferOffset:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn encodeToCommandBuffer_sourceTexture_regions_numberOfRegions_keypointCountBuffer_keypointCountBufferOffset_keypointDataBuffer_keypointDataBufferOffset(
170 &self,
171 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
172 source: &ProtocolObject<dyn MTLTexture>,
173 regions: NonNull<MTLRegion>,
174 number_of_regions: NSUInteger,
175 keypoint_count_buffer: &ProtocolObject<dyn MTLBuffer>,
176 keypoint_count_buffer_offset: NSUInteger,
177 keypoint_data_buffer: &ProtocolObject<dyn MTLBuffer>,
178 keypoint_data_buffer_offset: NSUInteger,
179 );
180 );
181}
182
183/// Methods declared on superclass `MPSKernel`.
184#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
185impl MPSImageFindKeypoints {
186 extern_methods!(
187 /// Called by NSCoder to decode MPSKernels
188 ///
189 /// This isn't the right interface to decode a MPSKernel, but
190 /// it is the one that NSCoder uses. To enable your NSCoder
191 /// (e.g. NSKeyedUnarchiver) to set which device to use
192 /// extend the object to adopt the MPSDeviceProvider
193 /// protocol. Otherwise, the Metal system default device
194 /// will be used.
195 ///
196 /// # Safety
197 ///
198 /// `a_decoder` possibly has further requirements.
199 #[unsafe(method(initWithCoder:))]
200 #[unsafe(method_family = init)]
201 pub unsafe fn initWithCoder(
202 this: Allocated<Self>,
203 a_decoder: &NSCoder,
204 ) -> Option<Retained<Self>>;
205 );
206}
207
208/// Methods declared on superclass `NSObject`.
209#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
210impl MPSImageFindKeypoints {
211 extern_methods!(
212 #[unsafe(method(init))]
213 #[unsafe(method_family = init)]
214 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
215
216 #[unsafe(method(new))]
217 #[unsafe(method_family = new)]
218 pub unsafe fn new() -> Retained<Self>;
219 );
220}