objc2_core_graphics/generated/
CGDisplayStream.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 = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12#[cfg(feature = "objc2-io-surface")]
13#[cfg(not(target_os = "watchos"))]
14use objc2_io_surface::*;
15
16use crate::*;
17
18/// An opaque reference to a CGDisplayStream object
19///
20/// A CGDisplayStream provides a streaming API for capturing display updates in a realtime manner.  It can also provide
21/// scaling and color space conversion services, as well as allow capturing sub regions of the display.   Callbacks can be targetted
22/// at either a traditional CFRunLoop, or at a dispatch queue.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystream?language=objc)
25#[repr(C)]
26pub struct CGDisplayStream {
27    inner: [u8; 0],
28    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
29}
30
31cf_type!(
32    unsafe impl CGDisplayStream {}
33);
34#[cfg(feature = "objc2")]
35cf_objc2_type!(
36    unsafe impl RefEncode<"CGDisplayStream"> for CGDisplayStream {}
37);
38
39/// An opaque reference to a single frame's extra metadata that describes useful frame delta information
40///
41/// A CGDisplayStreamUpdate encapsulates information about what portions of a frame have changed relative to
42/// a previously delivered frame.   This includes regions that were changed in any way, which ones were actually redrawn, and which
43/// regions were merely copied from one place to another.   A routine is provided to merge two update refs together in cases
44/// where apps need to coalesce the values because they decided to skip processing for one or more frames.
45///
46/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamupdate?language=objc)
47#[repr(C)]
48pub struct CGDisplayStreamUpdate {
49    inner: [u8; 0],
50    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
51}
52
53cf_type!(
54    unsafe impl CGDisplayStreamUpdate {}
55);
56#[cfg(feature = "objc2")]
57cf_objc2_type!(
58    unsafe impl RefEncode<"CGDisplayStreamUpdate"> for CGDisplayStreamUpdate {}
59);
60
61/// Used to select which array of rectangles to be returned by CGDisplayUpdateGetRects
62///
63/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamupdaterecttype?language=objc)
64// NS_ENUM
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct CGDisplayStreamUpdateRectType(pub i32);
68impl CGDisplayStreamUpdateRectType {
69    #[doc(alias = "kCGDisplayStreamUpdateRefreshedRects")]
70    pub const RefreshedRects: Self = Self(0);
71    #[doc(alias = "kCGDisplayStreamUpdateMovedRects")]
72    pub const MovedRects: Self = Self(1);
73    #[doc(alias = "kCGDisplayStreamUpdateDirtyRects")]
74    pub const DirtyRects: Self = Self(2);
75    #[doc(alias = "kCGDisplayStreamUpdateReducedDirtyRects")]
76    pub const ReducedDirtyRects: Self = Self(3);
77}
78
79#[cfg(feature = "objc2")]
80unsafe impl Encode for CGDisplayStreamUpdateRectType {
81    const ENCODING: Encoding = i32::ENCODING;
82}
83
84#[cfg(feature = "objc2")]
85unsafe impl RefEncode for CGDisplayStreamUpdateRectType {
86    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
87}
88
89/// Provides information about incoming frame updates
90///
91/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamframestatus?language=objc)
92// NS_ENUM
93#[repr(transparent)]
94#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
95pub struct CGDisplayStreamFrameStatus(pub i32);
96impl CGDisplayStreamFrameStatus {
97    #[doc(alias = "kCGDisplayStreamFrameStatusFrameComplete")]
98    pub const FrameComplete: Self = Self(0);
99    #[doc(alias = "kCGDisplayStreamFrameStatusFrameIdle")]
100    pub const FrameIdle: Self = Self(1);
101    #[doc(alias = "kCGDisplayStreamFrameStatusFrameBlank")]
102    pub const FrameBlank: Self = Self(2);
103    #[doc(alias = "kCGDisplayStreamFrameStatusStopped")]
104    pub const Stopped: Self = Self(3);
105}
106
107#[cfg(feature = "objc2")]
108unsafe impl Encode for CGDisplayStreamFrameStatus {
109    const ENCODING: Encoding = i32::ENCODING;
110}
111
112#[cfg(feature = "objc2")]
113unsafe impl RefEncode for CGDisplayStreamFrameStatus {
114    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
115}
116
117/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamframeavailablehandler?language=objc)
118#[cfg(all(feature = "block2", feature = "objc2-io-surface"))]
119#[cfg(not(target_os = "watchos"))]
120pub type CGDisplayStreamFrameAvailableHandler = *mut block2::DynBlock<
121    dyn Fn(CGDisplayStreamFrameStatus, u64, *mut IOSurfaceRef, *const CGDisplayStreamUpdate),
122>;
123
124unsafe impl ConcreteType for CGDisplayStreamUpdate {
125    /// Returns the CF "class" ID for CGDisplayStreamUpdate
126    ///
127    /// Returns: The CFTypeID of the CGDisplayStreamUpdate class.
128    #[doc(alias = "CGDisplayStreamUpdateGetTypeID")]
129    #[inline]
130    fn type_id() -> CFTypeID {
131        extern "C-unwind" {
132            fn CGDisplayStreamUpdateGetTypeID() -> CFTypeID;
133        }
134        unsafe { CGDisplayStreamUpdateGetTypeID() }
135    }
136}
137
138impl CGDisplayStreamUpdate {
139    /// Returns a pointer to an array of CGRect structs that describe what parts of the frame have changed relative
140    /// to the previously delivered frame.   This rectangle list encapsulates both the update rectangles and movement rectangles.
141    ///
142    /// Parameter `updateRef`: The CGDisplayStreamUpdateRef
143    ///
144    /// Parameter `rectCount`: A pointer to where the count of the number of rectangles in the array is to be returned. Must not be NULL.
145    ///
146    /// Returns: A pointer to the array of CGRectangles.  This array should not be freed by the caller.
147    #[doc(alias = "CGDisplayStreamUpdateGetRects")]
148    #[deprecated = "Please use ScreenCaptureKit instead."]
149    #[inline]
150    pub unsafe fn rects(
151        update_ref: Option<&CGDisplayStreamUpdate>,
152        rect_type: CGDisplayStreamUpdateRectType,
153        rect_count: NonNull<usize>,
154    ) -> *const CGRect {
155        extern "C-unwind" {
156            fn CGDisplayStreamUpdateGetRects(
157                update_ref: Option<&CGDisplayStreamUpdate>,
158                rect_type: CGDisplayStreamUpdateRectType,
159                rect_count: NonNull<usize>,
160            ) -> *const CGRect;
161        }
162        unsafe { CGDisplayStreamUpdateGetRects(update_ref, rect_type, rect_count) }
163    }
164
165    /// Merge two CGDisplayUpdateRefs into a new one.
166    ///
167    /// In cases where the client wishes to drop certain frame updates, this function may be used to merge two
168    /// CGDisplayUpdateRefs together.  The core bit of functionality here is generating a new set of refresh/move/dirty
169    /// rectangle arrays that properly represent the union of the deltas between the two frames.  Note that the ordering of
170    /// the two refs is important.
171    ///
172    ///
173    /// Parameter `firstUpdate`: The first update (in a temporal sense)
174    ///
175    /// Parameter `secondUpdate`: The second update (in a temporal sense)
176    ///
177    /// Returns: The new CGDisplayStreamUpdateRef
178    #[doc(alias = "CGDisplayStreamUpdateCreateMergedUpdate")]
179    #[deprecated = "Please use ScreenCaptureKit instead."]
180    #[inline]
181    pub unsafe fn new_merged_update(
182        first_update: Option<&CGDisplayStreamUpdate>,
183        second_update: Option<&CGDisplayStreamUpdate>,
184    ) -> Option<CFRetained<CGDisplayStreamUpdate>> {
185        extern "C-unwind" {
186            fn CGDisplayStreamUpdateCreateMergedUpdate(
187                first_update: Option<&CGDisplayStreamUpdate>,
188                second_update: Option<&CGDisplayStreamUpdate>,
189            ) -> Option<NonNull<CGDisplayStreamUpdate>>;
190        }
191        let ret = unsafe { CGDisplayStreamUpdateCreateMergedUpdate(first_update, second_update) };
192        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
193    }
194
195    /// Return the movement dx and dy values for a single update
196    ///
197    /// Parameter `updateRef`: The CGDisplayStreamUpdateRef
198    ///
199    /// Parameter `dx`: A pointer to a CGFloat to store the x component of the movement delta
200    ///
201    /// Parameter `dy`: A pointer to a CGFloat to store the y component of the movement delta
202    ///
203    /// The delta values describe the offset from the moved rectangles back to the source location.
204    #[doc(alias = "CGDisplayStreamUpdateGetMovedRectsDelta")]
205    #[deprecated = "Please use ScreenCaptureKit instead."]
206    #[inline]
207    pub unsafe fn moved_rects_delta(
208        update_ref: Option<&CGDisplayStreamUpdate>,
209        dx: NonNull<CGFloat>,
210        dy: NonNull<CGFloat>,
211    ) {
212        extern "C-unwind" {
213            fn CGDisplayStreamUpdateGetMovedRectsDelta(
214                update_ref: Option<&CGDisplayStreamUpdate>,
215                dx: NonNull<CGFloat>,
216                dy: NonNull<CGFloat>,
217            );
218        }
219        unsafe { CGDisplayStreamUpdateGetMovedRectsDelta(update_ref, dx, dy) }
220    }
221
222    /// Return how many frames (if any) have been dropped since the last call to the handler.
223    ///
224    /// Parameter `updateRef`: The CGDisplayStreamUpdateRef
225    ///
226    /// Returns: The number of dropped frames
227    ///
228    /// This call is primarily useful for performance measurement to determine if the client is keeping up with
229    /// all WindowServer updates.
230    #[doc(alias = "CGDisplayStreamUpdateGetDropCount")]
231    #[deprecated = "Please use ScreenCaptureKit instead."]
232    #[inline]
233    pub unsafe fn drop_count(update_ref: Option<&CGDisplayStreamUpdate>) -> usize {
234        extern "C-unwind" {
235            fn CGDisplayStreamUpdateGetDropCount(
236                update_ref: Option<&CGDisplayStreamUpdate>,
237            ) -> usize;
238        }
239        unsafe { CGDisplayStreamUpdateGetDropCount(update_ref) }
240    }
241}
242
243extern "C" {
244    /// This may be used to request a subregion of the display to be provided as the source of the display stream.  Use
245    /// CGRectCreateDictionaryRepresentation to convert from a CGRect to the value used here.   Note: The coordinate system for the
246    /// source rectangle is specified in display logical coordinates and not in pixels, in order to match the normal convention on
247    /// HiDPI displays.
248    ///
249    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamsourcerect?language=objc)
250    pub static kCGDisplayStreamSourceRect: &'static CFString;
251}
252
253extern "C" {
254    /// This may be used to request where within the destination buffer the display updates should be placed. Use
255    /// CGRectCreateDictionaryRepresentation to convert from a CGRect to the value used here.   Note: The coordinate system for
256    /// the destination rectangle is always specified in output pixels to match the fact that the output buffer size is also
257    /// specified in terms of pixels.
258    ///
259    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamdestinationrect?language=objc)
260    pub static kCGDisplayStreamDestinationRect: &'static CFString;
261}
262
263extern "C" {
264    /// Enable/disable the work the Window Server will do to preserve the display aspect ratio.  By default the Window Server will
265    /// assume that it should preserve the original aspect ratio of the source display rect.  If the aspect ratio of the source display and
266    /// the display stream destination rect are not the same, black borders will be inserted at the top/bottom or right/left sides of the destination
267    /// in order to preserve the source aspect ratio.
268    ///
269    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreampreserveaspectratio?language=objc)
270    pub static kCGDisplayStreamPreserveAspectRatio: &'static CFString;
271}
272
273extern "C" {
274    /// Set the desired CGColorSpace of the output frames.  By default the color space will be that of the display.
275    ///
276    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamcolorspace?language=objc)
277    pub static kCGDisplayStreamColorSpace: &'static CFString;
278}
279
280extern "C" {
281    /// Request that the delta between frame updates be at least as much specified by this value.
282    ///
283    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamminimumframetime?language=objc)
284    pub static kCGDisplayStreamMinimumFrameTime: &'static CFString;
285}
286
287extern "C" {
288    /// Controls whether the cursor is embedded within the provided buffers or not.
289    ///
290    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamshowcursor?language=objc)
291    pub static kCGDisplayStreamShowCursor: &'static CFString;
292}
293
294extern "C" {
295    /// Controls how many frames deep the frame queue will be.  Defaults to N.
296    ///
297    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamqueuedepth?language=objc)
298    pub static kCGDisplayStreamQueueDepth: &'static CFString;
299}
300
301extern "C" {
302    /// When outputting frames in 420v or 420f format, this key may be used to control which YCbCr matrix is used
303    /// The value should be one of the three kCGDisplayStreamYCbCrMatrix values specified below.
304    ///
305    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix?language=objc)
306    pub static kCGDisplayStreamYCbCrMatrix: &'static CFString;
307}
308
309extern "C" {
310    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix_itu_r_709_2?language=objc)
311    pub static kCGDisplayStreamYCbCrMatrix_ITU_R_709_2: &'static CFString;
312}
313
314extern "C" {
315    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix_itu_r_601_4?language=objc)
316    pub static kCGDisplayStreamYCbCrMatrix_ITU_R_601_4: &'static CFString;
317}
318
319extern "C" {
320    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix_smpte_240m_1995?language=objc)
321    pub static kCGDisplayStreamYCbCrMatrix_SMPTE_240M_1995: &'static CFString;
322}
323
324unsafe impl ConcreteType for CGDisplayStream {
325    /// Returns the CF "class" ID for CGDisplayStream
326    ///
327    /// Returns: The CFTypeID of the CGDisplayStream class.
328    #[doc(alias = "CGDisplayStreamGetTypeID")]
329    #[inline]
330    fn type_id() -> CFTypeID {
331        extern "C-unwind" {
332            fn CGDisplayStreamGetTypeID() -> CFTypeID;
333        }
334        unsafe { CGDisplayStreamGetTypeID() }
335    }
336}
337
338impl CGDisplayStream {
339    /// Creates a new CGDisplayStream intended to be used with a CFRunLoop
340    ///
341    /// This function creates a new CGDisplayStream that is to be used to get a stream of frame updates
342    /// from a particular display.
343    ///
344    /// Parameter `display`: The CGDirectDisplayID to use as the source for generated frames
345    ///
346    /// Parameter `outputWidth`: The output width (in pixels, not points) of the frames to be generated.  Must not be zero.
347    ///
348    /// Parameter `outputHeight`: The output height (in pixels, not points) of the frames to be generated.  Must not be zero.
349    ///
350    /// Parameter `pixelFormat`: The desired CoreVideo/CoreMedia-style pixel format of the output IOSurfaces.  The currently
351    /// supported values are:
352    ///
353    /// 'BGRA' Packed Little Endian ARGB8888
354    /// 'l10r' Packed Little Endian ARGB2101010
355    /// '420v' 2-plane "video" range YCbCr 4:2:0
356    /// '420f' 2-plane "full" range YCbCr 4:2:0
357    ///
358    ///
359    /// Parameter `properties`: Any optional properties of the CGDisplayStream
360    ///
361    /// Parameter `handler`: A block that will be called for frame deliver.
362    ///
363    /// Returns: The new CGDisplayStream object.
364    #[doc(alias = "CGDisplayStreamCreate")]
365    #[cfg(all(
366        feature = "CGDirectDisplay",
367        feature = "block2",
368        feature = "objc2-io-surface"
369    ))]
370    #[cfg(not(target_os = "watchos"))]
371    #[deprecated = "Please use ScreenCaptureKit instead."]
372    #[inline]
373    pub unsafe fn new(
374        display: CGDirectDisplayID,
375        output_width: usize,
376        output_height: usize,
377        pixel_format: i32,
378        properties: Option<&CFDictionary>,
379        handler: CGDisplayStreamFrameAvailableHandler,
380    ) -> Option<CFRetained<CGDisplayStream>> {
381        extern "C-unwind" {
382            fn CGDisplayStreamCreate(
383                display: CGDirectDisplayID,
384                output_width: usize,
385                output_height: usize,
386                pixel_format: i32,
387                properties: Option<&CFDictionary>,
388                handler: CGDisplayStreamFrameAvailableHandler,
389            ) -> Option<NonNull<CGDisplayStream>>;
390        }
391        let ret = unsafe {
392            CGDisplayStreamCreate(
393                display,
394                output_width,
395                output_height,
396                pixel_format,
397                properties,
398                handler,
399            )
400        };
401        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
402    }
403
404    /// Creates a new CGDisplayStream intended to be serviced by a block handler
405    ///
406    /// This function creates a new CGDisplayStream that is to be used to get a stream of frame updates
407    /// from a particular display.
408    ///
409    /// Parameter `display`: The CGDirectDisplayID to use as the source for generated frames
410    ///
411    /// Parameter `outputWidth`: The output width (in pixels, not points) of the frames to be generated.  Must not be zero.
412    ///
413    /// Parameter `outputHeight`: The output height (in pixels, not points) of the frames to be generated.  Must not be zero.
414    ///
415    /// Parameter `pixelFormat`: The desired CoreVideo/CoreMedia-style pixel format of the output IOSurfaces
416    ///
417    /// Parameter `properties`: Any optional properties of the CGDisplayStream
418    ///
419    /// Parameter `queue`: The dispatch_queue_t that will be used to invoke the callback handler.
420    ///
421    /// Parameter `handler`: A block that will be called for frame deliver.
422    ///
423    /// Returns: The new CGDisplayStream object.
424    #[doc(alias = "CGDisplayStreamCreateWithDispatchQueue")]
425    #[cfg(all(
426        feature = "CGDirectDisplay",
427        feature = "block2",
428        feature = "dispatch2",
429        feature = "objc2-io-surface"
430    ))]
431    #[cfg(not(target_os = "watchos"))]
432    #[deprecated = "Please use ScreenCaptureKit instead."]
433    #[inline]
434    pub unsafe fn with_dispatch_queue(
435        display: CGDirectDisplayID,
436        output_width: usize,
437        output_height: usize,
438        pixel_format: i32,
439        properties: Option<&CFDictionary>,
440        queue: &DispatchQueue,
441        handler: CGDisplayStreamFrameAvailableHandler,
442    ) -> Option<CFRetained<CGDisplayStream>> {
443        extern "C-unwind" {
444            fn CGDisplayStreamCreateWithDispatchQueue(
445                display: CGDirectDisplayID,
446                output_width: usize,
447                output_height: usize,
448                pixel_format: i32,
449                properties: Option<&CFDictionary>,
450                queue: &DispatchQueue,
451                handler: CGDisplayStreamFrameAvailableHandler,
452            ) -> Option<NonNull<CGDisplayStream>>;
453        }
454        let ret = unsafe {
455            CGDisplayStreamCreateWithDispatchQueue(
456                display,
457                output_width,
458                output_height,
459                pixel_format,
460                properties,
461                queue,
462                handler,
463            )
464        };
465        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
466    }
467
468    /// Begin delivering frame updates to the handler block.
469    ///
470    /// Parameter `displayStream`: to be started
471    ///
472    /// Returns: kCGErrorSuccess If the display stream was started, otherwise an error.
473    #[doc(alias = "CGDisplayStreamStart")]
474    #[cfg(feature = "CGError")]
475    #[deprecated = "Please use ScreenCaptureKit instead."]
476    #[inline]
477    pub unsafe fn start(display_stream: Option<&CGDisplayStream>) -> CGError {
478        extern "C-unwind" {
479            fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError;
480        }
481        unsafe { CGDisplayStreamStart(display_stream) }
482    }
483
484    /// End delivery of frame updates to the handler block.
485    ///
486    /// Parameter `displayStream`: to be stopped
487    ///
488    /// Returns: kCGErrorSuccess If the display stream was stopped, otherwise an error.
489    ///
490    /// After this call returns, the CGDisplayStream callback function will eventually be called with a
491    /// status of kCGDisplayStreamFrameStatusStopped.  After that point it is safe to release the CGDisplayStream.
492    /// It is safe to call this function from within the handler block, but the previous caveat still applies.
493    #[doc(alias = "CGDisplayStreamStop")]
494    #[cfg(feature = "CGError")]
495    #[deprecated = "Please use ScreenCaptureKit instead."]
496    #[inline]
497    pub unsafe fn stop(display_stream: Option<&CGDisplayStream>) -> CGError {
498        extern "C-unwind" {
499            fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError;
500        }
501        unsafe { CGDisplayStreamStop(display_stream) }
502    }
503
504    /// Return the singleton CFRunLoopSourceRef for a CGDisplayStream.
505    ///
506    /// Parameter `displayStream`: The CGDisplayStream object
507    ///
508    /// Returns: The CFRunLoopSource for this displayStream.  Note: This function will return NULL if the
509    /// display stream was created via  CGDisplayStreamCreateWithDispatchQueue().
510    #[doc(alias = "CGDisplayStreamGetRunLoopSource")]
511    #[deprecated = "Please use ScreenCaptureKit instead."]
512    #[inline]
513    pub unsafe fn run_loop_source(
514        display_stream: Option<&CGDisplayStream>,
515    ) -> Option<CFRetained<CFRunLoopSource>> {
516        extern "C-unwind" {
517            fn CGDisplayStreamGetRunLoopSource(
518                display_stream: Option<&CGDisplayStream>,
519            ) -> Option<NonNull<CFRunLoopSource>>;
520        }
521        let ret = unsafe { CGDisplayStreamGetRunLoopSource(display_stream) };
522        ret.map(|ret| unsafe { CFRetained::retain(ret) })
523    }
524}
525
526extern "C-unwind" {
527    #[deprecated = "renamed to `CGDisplayStreamUpdate::rects`"]
528    pub fn CGDisplayStreamUpdateGetRects(
529        update_ref: Option<&CGDisplayStreamUpdate>,
530        rect_type: CGDisplayStreamUpdateRectType,
531        rect_count: NonNull<usize>,
532    ) -> *const CGRect;
533}
534
535#[deprecated = "renamed to `CGDisplayStreamUpdate::new_merged_update`"]
536#[inline]
537pub unsafe extern "C-unwind" fn CGDisplayStreamUpdateCreateMergedUpdate(
538    first_update: Option<&CGDisplayStreamUpdate>,
539    second_update: Option<&CGDisplayStreamUpdate>,
540) -> Option<CFRetained<CGDisplayStreamUpdate>> {
541    extern "C-unwind" {
542        fn CGDisplayStreamUpdateCreateMergedUpdate(
543            first_update: Option<&CGDisplayStreamUpdate>,
544            second_update: Option<&CGDisplayStreamUpdate>,
545        ) -> Option<NonNull<CGDisplayStreamUpdate>>;
546    }
547    let ret = unsafe { CGDisplayStreamUpdateCreateMergedUpdate(first_update, second_update) };
548    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
549}
550
551extern "C-unwind" {
552    #[deprecated = "renamed to `CGDisplayStreamUpdate::moved_rects_delta`"]
553    pub fn CGDisplayStreamUpdateGetMovedRectsDelta(
554        update_ref: Option<&CGDisplayStreamUpdate>,
555        dx: NonNull<CGFloat>,
556        dy: NonNull<CGFloat>,
557    );
558}
559
560extern "C-unwind" {
561    #[deprecated = "renamed to `CGDisplayStreamUpdate::drop_count`"]
562    pub fn CGDisplayStreamUpdateGetDropCount(update_ref: Option<&CGDisplayStreamUpdate>) -> usize;
563}
564
565#[cfg(all(
566    feature = "CGDirectDisplay",
567    feature = "block2",
568    feature = "objc2-io-surface"
569))]
570#[cfg(not(target_os = "watchos"))]
571#[deprecated = "renamed to `CGDisplayStream::new`"]
572#[inline]
573pub unsafe extern "C-unwind" fn CGDisplayStreamCreate(
574    display: CGDirectDisplayID,
575    output_width: usize,
576    output_height: usize,
577    pixel_format: i32,
578    properties: Option<&CFDictionary>,
579    handler: CGDisplayStreamFrameAvailableHandler,
580) -> Option<CFRetained<CGDisplayStream>> {
581    extern "C-unwind" {
582        fn CGDisplayStreamCreate(
583            display: CGDirectDisplayID,
584            output_width: usize,
585            output_height: usize,
586            pixel_format: i32,
587            properties: Option<&CFDictionary>,
588            handler: CGDisplayStreamFrameAvailableHandler,
589        ) -> Option<NonNull<CGDisplayStream>>;
590    }
591    let ret = unsafe {
592        CGDisplayStreamCreate(
593            display,
594            output_width,
595            output_height,
596            pixel_format,
597            properties,
598            handler,
599        )
600    };
601    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
602}
603
604#[cfg(all(
605    feature = "CGDirectDisplay",
606    feature = "block2",
607    feature = "dispatch2",
608    feature = "objc2-io-surface"
609))]
610#[cfg(not(target_os = "watchos"))]
611#[deprecated = "renamed to `CGDisplayStream::with_dispatch_queue`"]
612#[inline]
613pub unsafe extern "C-unwind" fn CGDisplayStreamCreateWithDispatchQueue(
614    display: CGDirectDisplayID,
615    output_width: usize,
616    output_height: usize,
617    pixel_format: i32,
618    properties: Option<&CFDictionary>,
619    queue: &DispatchQueue,
620    handler: CGDisplayStreamFrameAvailableHandler,
621) -> Option<CFRetained<CGDisplayStream>> {
622    extern "C-unwind" {
623        fn CGDisplayStreamCreateWithDispatchQueue(
624            display: CGDirectDisplayID,
625            output_width: usize,
626            output_height: usize,
627            pixel_format: i32,
628            properties: Option<&CFDictionary>,
629            queue: &DispatchQueue,
630            handler: CGDisplayStreamFrameAvailableHandler,
631        ) -> Option<NonNull<CGDisplayStream>>;
632    }
633    let ret = unsafe {
634        CGDisplayStreamCreateWithDispatchQueue(
635            display,
636            output_width,
637            output_height,
638            pixel_format,
639            properties,
640            queue,
641            handler,
642        )
643    };
644    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
645}
646
647extern "C-unwind" {
648    #[cfg(feature = "CGError")]
649    #[deprecated = "renamed to `CGDisplayStream::start`"]
650    pub fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError;
651}
652
653extern "C-unwind" {
654    #[cfg(feature = "CGError")]
655    #[deprecated = "renamed to `CGDisplayStream::stop`"]
656    pub fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError;
657}
658
659#[deprecated = "renamed to `CGDisplayStream::run_loop_source`"]
660#[inline]
661pub unsafe extern "C-unwind" fn CGDisplayStreamGetRunLoopSource(
662    display_stream: Option<&CGDisplayStream>,
663) -> Option<CFRetained<CFRunLoopSource>> {
664    extern "C-unwind" {
665        fn CGDisplayStreamGetRunLoopSource(
666            display_stream: Option<&CGDisplayStream>,
667        ) -> Option<NonNull<CFRunLoopSource>>;
668    }
669    let ret = unsafe { CGDisplayStreamGetRunLoopSource(display_stream) };
670    ret.map(|ret| unsafe { CFRetained::retain(ret) })
671}