• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_MAC_WRAP_CG_DISPLAY_H_
6 #define BASE_MAC_WRAP_CG_DISPLAY_H_
7 
8 // All these symbols have incorrect availability annotations in the 13.3 SDK.
9 // These have the correct annotation. See https://crbug.com/1431897.
10 // TODO(thakis): Remove this once FB12109479 is fixed and we updated to an SDK
11 // with the fix.
12 
13 #include <CoreGraphics/CoreGraphics.h>
14 
wrapCGDisplayStreamCreate(CGDirectDisplayID display,size_t outputWidth,size_t outputHeight,int32_t pixelFormat,CFDictionaryRef __nullable properties,CGDisplayStreamFrameAvailableHandler __nullable handler)15 inline CGDisplayStreamRef __nullable wrapCGDisplayStreamCreate(
16     CGDirectDisplayID display,
17     size_t outputWidth,
18     size_t outputHeight,
19     int32_t pixelFormat,
20     CFDictionaryRef __nullable properties,
21     CGDisplayStreamFrameAvailableHandler __nullable handler)
22     CG_AVAILABLE_BUT_DEPRECATED(
23         10.8,
24         14.0,
25         "Please use ScreenCaptureKit API's "
26         "initWithFilter:configuration:delegate: instead") {
27 #pragma clang diagnostic push
28 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
29   return CGDisplayStreamCreate(display, outputWidth, outputHeight, pixelFormat,
30                                properties, handler);
31 #pragma clang diagnostic pop
32 }
33 
wrapCGDisplayStreamGetRunLoopSource(CGDisplayStreamRef cg_nullable displayStream)34 inline CFRunLoopSourceRef __nullable wrapCGDisplayStreamGetRunLoopSource(
35     CGDisplayStreamRef cg_nullable displayStream)
36     CG_AVAILABLE_BUT_DEPRECATED(
37         10.8,
38         14.0,
39         "There is no direct replacement for this function. Please use "
40         "ScreenCaptureKit API's SCStream to replace CGDisplayStream") {
41 #pragma clang diagnostic push
42 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
43   return CGDisplayStreamGetRunLoopSource(displayStream);
44 #pragma clang diagnostic pop
45 }
46 
wrapCGDisplayStreamStart(CGDisplayStreamRef cg_nullable displayStream)47 inline CGError wrapCGDisplayStreamStart(
48     CGDisplayStreamRef cg_nullable displayStream)
49     CG_AVAILABLE_BUT_DEPRECATED(
50         10.8,
51         14.0,
52         "Please use ScreenCaptureKit API's "
53         "startCaptureWithCompletionHandler: to start a stream instead") {
54 #pragma clang diagnostic push
55 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
56   return CGDisplayStreamStart(displayStream);
57 #pragma clang diagnostic pop
58 }
59 
wrapCGDisplayStreamStop(CGDisplayStreamRef cg_nullable displayStream)60 inline CGError wrapCGDisplayStreamStop(
61     CGDisplayStreamRef cg_nullable displayStream)
62     CG_AVAILABLE_BUT_DEPRECATED(
63         10.8,
64         14.0,
65         "Please use ScreenCaptureKit API's "
66         "stopCaptureWithCompletionHandler: to stop a stream instead") {
67 #pragma clang diagnostic push
68 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
69   return CGDisplayStreamStop(displayStream);
70 #pragma clang diagnostic pop
71 }
72 
wrapkCGDisplayStreamColorSpace()73 inline _Null_unspecified CFStringRef wrapkCGDisplayStreamColorSpace()
74     CG_AVAILABLE_BUT_DEPRECATED(
75         10.8,
76         14.0,
77         "Please use ScreenCaptureKit API's SCStreamConfiguration "
78         "colorSpaceName property instead") {
79 #pragma clang diagnostic push
80 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
81   return kCGDisplayStreamColorSpace;
82 #pragma clang diagnostic pop
83 }
84 
wrapkCGDisplayStreamDestinationRect()85 inline _Null_unspecified CFStringRef wrapkCGDisplayStreamDestinationRect()
86     CG_AVAILABLE_BUT_DEPRECATED(
87         10.8,
88         14.0,
89         "Please use ScreenCaptureKit API's SCStreamConfiguration "
90         "destinationRect property instead") {
91 #pragma clang diagnostic push
92 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
93   return kCGDisplayStreamDestinationRect;
94 #pragma clang diagnostic pop
95 }
96 
wrapkCGDisplayStreamMinimumFrameTime()97 inline _Null_unspecified CFStringRef wrapkCGDisplayStreamMinimumFrameTime()
98     CG_AVAILABLE_BUT_DEPRECATED(
99         10.8,
100         14.0,
101         "Please use ScreenCaptureKit API's SCStreamConfiguration "
102         "minimumFrameInterval property instead") {
103 #pragma clang diagnostic push
104 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
105   return kCGDisplayStreamMinimumFrameTime;
106 #pragma clang diagnostic pop
107 }
108 
wrapkCGDisplayStreamPreserveAspectRatio()109 inline _Null_unspecified CFStringRef wrapkCGDisplayStreamPreserveAspectRatio()
110     CG_AVAILABLE_BUT_DEPRECATED(
111         10.8,
112         14.0,
113         "Please use ScreenCaptureKit API's SCStreamConfiguration "
114         "preserveAspectRatio property instead") {
115 #pragma clang diagnostic push
116 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
117   return kCGDisplayStreamPreserveAspectRatio;
118 #pragma clang diagnostic pop
119 }
120 
wrapkCGDisplayStreamShowCursor()121 inline _Null_unspecified CFStringRef wrapkCGDisplayStreamShowCursor()
122     CG_AVAILABLE_BUT_DEPRECATED(
123         10.8,
124         14.0,
125         "Please use ScreenCaptureKit API's SCStreamConfiguration showsCursor "
126         "property instead") {
127 #pragma clang diagnostic push
128 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
129   return kCGDisplayStreamShowCursor;
130 #pragma clang diagnostic pop
131 }
132 
133 inline const CGRect* __nullable
wrapCGDisplayStreamUpdateGetRects(CGDisplayStreamUpdateRef __nullable updateRef,CGDisplayStreamUpdateRectType rectType,size_t * _Null_unspecified rectCount)134 wrapCGDisplayStreamUpdateGetRects(CGDisplayStreamUpdateRef __nullable updateRef,
135                                   CGDisplayStreamUpdateRectType rectType,
136                                   size_t* _Null_unspecified rectCount)
137     CG_AVAILABLE_BUT_DEPRECATED(
138         10.8,
139         14.0,
140         "Please use ScreenCaptureKit API's SCStreamFrameInfo with "
141         "SCStreamFrameInfoContentRect instead") {
142 #pragma clang diagnostic push
143 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
144   return CGDisplayStreamUpdateGetRects(updateRef, rectType, rectCount);
145 #pragma clang diagnostic pop
146 }
147 
148 #endif  // BASE_MAC_WRAP_CG_DISPLAY_H_
149