/
CoreGraphicsSPI.h
416 lines (344 loc) · 15.9 KB
/
CoreGraphicsSPI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
/*
* Copyright (C) 2014-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#if HAVE(IOSURFACE)
#include <pal/spi/cocoa/IOSurfaceSPI.h>
#endif
#if PLATFORM(MAC)
#include <pal/spi/cocoa/IOKitSPI.h>
#endif
#if USE(APPLE_INTERNAL_SDK)
#if HAVE(CPP20_INCOMPATIBLE_INTERNAL_HEADERS)
#define CGCOLORTAGGEDPOINTER_H_
#endif
#include <CoreGraphics/CGContextDelegatePrivate.h>
#include <CoreGraphics/CGFontCache.h>
#include <CoreGraphics/CGPathPrivate.h>
#include <CoreGraphics/CGShadingPrivate.h>
#include <CoreGraphics/CGStylePrivate.h>
#include <CoreGraphics/CoreGraphicsPrivate.h>
#if PLATFORM(MAC)
#include <CoreGraphics/CGAccessibility.h>
#include <CoreGraphics/CGEventPrivate.h>
#endif
#else
struct CGFontHMetrics {
int ascent;
int descent;
int lineGap;
int maxAdvanceWidth;
int minLeftSideBearing;
int minRightSideBearing;
};
typedef CF_ENUM (int32_t, CGContextDelegateCallbackName)
{
deDrawImage = 7,
deDrawGlyphs = 8,
deBeginLayer = 17,
deEndLayer = 18,
};
typedef const struct CGColorTransform* CGColorTransformRef;
typedef enum {
kCGContextTypeUnknown,
kCGContextTypePDF,
kCGContextTypePostScript,
kCGContextTypeWindow,
kCGContextTypeBitmap,
kCGContextTypeGL,
kCGContextTypeDisplayList,
kCGContextTypeKSeparation,
kCGContextTypeIOSurface,
kCGContextTypeCount
} CGContextType;
typedef enum {
kCGCompositeCopy = 1,
kCGCompositeSover = 2,
} CGCompositeOperation;
enum {
kCGFontRenderingStyleAntialiasing = 1 << 0,
kCGFontRenderingStyleSmoothing = 1 << 1,
kCGFontRenderingStyleSubpixelPositioning = 1 << 2,
kCGFontRenderingStyleSubpixelQuantization = 1 << 3,
kCGFontRenderingStylePlatformNative = 1 << 9,
kCGFontRenderingStyleMask = 0x20F,
};
typedef uint32_t CGFontRenderingStyle;
enum {
kCGFontAntialiasingStyleUnfiltered = 0 << 7,
kCGFontAntialiasingStyleFilterLight = 1 << 7,
#if PLATFORM(MAC)
kCGFontAntialiasingStyleUnfilteredCustomDilation = (8 << 7),
#endif
};
typedef uint32_t CGFontAntialiasingStyle;
enum {
kCGImageCachingTransient = 1,
kCGImageCachingTemporary = 3,
};
typedef uint32_t CGImageCachingFlags;
#if PLATFORM(COCOA)
typedef struct CGSRegionEnumeratorObject* CGSRegionEnumeratorObj;
typedef struct CGSRegionObject* CGSRegionObj;
typedef struct CGSRegionObject* CGRegionRef;
#endif
#ifdef CGFLOAT_IS_DOUBLE
#define CGRound(value) round((value))
#define CGFloor(value) floor((value))
#define CGCeiling(value) ceil((value))
#define CGFAbs(value) fabs((value))
#else
#define CGRound(value) roundf((value))
#define CGFloor(value) floorf((value))
#define CGCeiling(value) ceilf((value))
#define CGFAbs(value) fabsf((value))
#endif
static inline CGFloat CGFloatMin(CGFloat a, CGFloat b) { return isnan(a) ? b : ((isnan(b) || a < b) ? a : b); }
typedef struct CGFontCache CGFontCache;
#if PLATFORM(COCOA)
enum {
kCGSWindowCaptureNominalResolution = 0x0200,
kCGSCaptureIgnoreGlobalClipShape = 0x0800,
};
typedef uint32_t CGSWindowCaptureOptions;
typedef CF_ENUM (int32_t, CGStyleDrawOrdering) {
kCGStyleDrawOrderingStyleOnly = 0,
kCGStyleDrawOrderingBelow = 1,
kCGStyleDrawOrderingAbove = 2,
};
typedef CF_ENUM (int32_t, CGFocusRingOrdering) {
kCGFocusRingOrderingNone = kCGStyleDrawOrderingStyleOnly,
kCGFocusRingOrderingBelow = kCGStyleDrawOrderingBelow,
kCGFocusRingOrderingAbove = kCGStyleDrawOrderingAbove,
};
typedef CF_ENUM (int32_t, CGFocusRingTint) {
kCGFocusRingTintBlue = 0,
kCGFocusRingTintGraphite = 1,
};
struct CGFocusRingStyle {
unsigned int version;
CGFocusRingTint tint;
CGFocusRingOrdering ordering;
CGFloat alpha;
CGFloat radius;
CGFloat threshold;
CGRect bounds;
int accumulate;
};
typedef struct CGFocusRingStyle CGFocusRingStyle;
#endif // PLATFORM(COCOA)
struct CGShadowStyle {
unsigned a;
CGFloat b;
CGFloat azimuth;
CGFloat c;
CGFloat height;
CGFloat radius;
CGFloat d;
};
typedef struct CGShadowStyle CGShadowStyle;
typedef CF_ENUM (int32_t, CGStyleType)
{
kCGStyleShadow = 1,
};
#if PLATFORM(MAC)
typedef CF_ENUM(uint32_t, CGSNotificationType) {
kCGSFirstConnectionNotification = 900,
kCGSFirstSessionNotification = 1500,
};
static const CGSNotificationType kCGSConnectionWindowModificationsStarted = (CGSNotificationType)(kCGSFirstConnectionNotification + 6);
static const CGSNotificationType kCGSConnectionWindowModificationsStopped = (CGSNotificationType)(kCGSFirstConnectionNotification + 7);
static const CGSNotificationType kCGSessionConsoleConnect = kCGSFirstSessionNotification;
static const CGSNotificationType kCGSessionConsoleDisconnect = (CGSNotificationType)(kCGSessionConsoleConnect + 1);
static const CGSNotificationType kCGSessionRemoteConnect = (CGSNotificationType)(kCGSessionConsoleDisconnect + 1);
static const CGSNotificationType kCGSessionRemoteDisconnect = (CGSNotificationType)(kCGSessionRemoteConnect + 1);
static const CGSNotificationType kCGSessionLoggedOn = (CGSNotificationType)(kCGSessionRemoteDisconnect + 1);
static const CGSNotificationType kCGSessionLoggedOff = (CGSNotificationType)(kCGSessionLoggedOn + 1);
static const CGSNotificationType kCGSessionConsoleWillDisconnect = (CGSNotificationType)(kCGSessionLoggedOff + 1);
#endif // PLATFORM(MAC)
typedef struct CGContextDelegate *CGContextDelegateRef;
typedef void (*CGContextDelegateCallback)(void);
typedef struct CGRenderingState *CGRenderingStateRef;
typedef struct CGGState *CGGStateRef;
typedef struct CGStyle *CGStyleRef;
#endif // USE(APPLE_INTERNAL_SDK)
#if PLATFORM(COCOA)
typedef uint32_t CGSByteCount;
typedef uint32_t CGSConnectionID;
typedef uint32_t CGSWindowCount;
typedef uint32_t CGSWindowID;
typedef CGSWindowID* CGSWindowIDList;
typedef struct CF_BRIDGED_TYPE(id) CGSRegionObject* CGSRegionObj;
typedef void* CGSNotificationArg;
typedef void* CGSNotificationData;
#endif
#if PLATFORM(MAC)
typedef void (*CGSNotifyConnectionProcPtr)(CGSNotificationType, void* data, uint32_t data_length, void* arg, CGSConnectionID);
typedef void (*CGSNotifyProcPtr)(CGSNotificationType, void* data, uint32_t data_length, void* arg);
#endif
WTF_EXTERN_C_BEGIN
bool CGColorTransformConvertColorComponents(CGColorTransformRef, CGColorSpaceRef, CGColorRenderingIntent, const CGFloat srcComponents[], CGFloat dstComponents[]);
CGColorRef CGColorTransformConvertColor(CGColorTransformRef, CGColorRef, CGColorRenderingIntent);
CGColorTransformRef CGColorTransformCreate(CGColorSpaceRef, CFDictionaryRef attributes);
CGAffineTransform CGContextGetBaseCTM(CGContextRef);
CGCompositeOperation CGContextGetCompositeOperation(CGContextRef);
CGColorRef CGContextGetFillColorAsColor(CGContextRef);
CGColorRef CGContextGetStrokeColorAsColor(CGContextRef);
CGFloat CGContextGetLineWidth(CGContextRef);
bool CGContextGetShouldSmoothFonts(CGContextRef);
bool CGContextGetShouldAntialias(CGContextRef);
void CGContextSetBaseCTM(CGContextRef, CGAffineTransform);
void CGContextSetCTM(CGContextRef, CGAffineTransform);
void CGContextSetCompositeOperation(CGContextRef, CGCompositeOperation);
void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts);
void CGContextResetClip(CGContextRef);
CGContextType CGContextGetType(CGContextRef);
CFStringRef CGFontCopyFamilyName(CGFontRef);
bool CGFontGetGlyphAdvancesForStyle(CGFontRef, const CGAffineTransform* , CGFontRenderingStyle, const CGGlyph[], size_t count, CGSize advances[]);
void CGFontGetGlyphsForUnichars(CGFontRef, const UniChar[], CGGlyph[], size_t count);
const CGFontHMetrics* CGFontGetHMetrics(CGFontRef);
const char* CGFontGetPostScriptName(CGFontRef);
bool CGFontIsFixedPitch(CGFontRef);
void CGFontSetShouldUseMulticache(bool);
void CGImageSetCachingFlags(CGImageRef, CGImageCachingFlags);
CGImageCachingFlags CGImageGetCachingFlags(CGImageRef);
CGDataProviderRef CGPDFDocumentGetDataProvider(CGPDFDocumentRef);
CGFontAntialiasingStyle CGContextGetFontAntialiasingStyle(CGContextRef);
void CGContextSetFontAntialiasingStyle(CGContextRef, CGFontAntialiasingStyle);
bool CGContextGetAllowsFontSubpixelPositioning(CGContextRef);
bool CGContextDrawsWithCorrectShadowOffsets(CGContextRef);
CGPatternRef CGPatternCreateWithImage2(CGImageRef, CGAffineTransform, CGPatternTiling);
CGContextDelegateRef CGContextDelegateCreate(void* info);
void CGContextDelegateSetCallback(CGContextDelegateRef, CGContextDelegateCallbackName, CGContextDelegateCallback);
CGContextRef CGContextCreateWithDelegate(CGContextDelegateRef, CGContextType, CGRenderingStateRef, CGGStateRef);
void* CGContextDelegateGetInfo(CGContextDelegateRef);
void CGContextDelegateRelease(CGContextDelegateRef);
CGFloat CGGStateGetAlpha(CGGStateRef);
CGFontRef CGGStateGetFont(CGGStateRef);
CGFloat CGGStateGetFontSize(CGGStateRef);
const CGAffineTransform *CGGStateGetCTM(CGGStateRef);
CGColorRef CGGStateGetFillColor(CGGStateRef);
CGColorRef CGGStateGetStrokeColor(CGGStateRef);
CGStyleRef CGGStateGetStyle(CGGStateRef);
CGStyleType CGStyleGetType(CGStyleRef);
const void *CGStyleGetData(CGStyleRef);
CGColorRef CGStyleGetColor(CGStyleRef);
bool CGColorSpaceEqualToColorSpace(CGColorSpaceRef, CGColorSpaceRef);
CFStringRef CGColorSpaceCopyICCProfileDescription(CGColorSpaceRef);
#if HAVE(CGPATH_GET_NUMBER_OF_ELEMENTS)
size_t CGPathGetNumberOfElements(CGPathRef);
#endif
#if HAVE(IOSURFACE)
CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
CGImageRef CGIOSurfaceContextCreateImageReference(CGContextRef);
CGColorSpaceRef CGIOSurfaceContextGetColorSpace(CGContextRef);
void CGIOSurfaceContextSetDisplayMask(CGContextRef, uint32_t mask);
IOSurfaceRef CGIOSurfaceContextGetSurface(CGContextRef);
#endif // HAVE(IOSURFACE)
#if PLATFORM(COCOA)
bool CGColorSpaceUsesExtendedRange(CGColorSpaceRef);
typedef struct CGPDFAnnotation *CGPDFAnnotationRef;
typedef bool (^CGPDFAnnotationDrawCallbackType)(CGContextRef context, CGPDFPageRef page, CGPDFAnnotationRef annotation);
void CGContextDrawPDFPageWithAnnotations(CGContextRef, CGPDFPageRef, CGPDFAnnotationDrawCallbackType);
void CGContextDrawPathDirect(CGContextRef, CGPathDrawingMode, CGPathRef, const CGRect* boundingBox);
CGColorSpaceRef CGContextCopyDeviceColorSpace(CGContextRef);
CFPropertyListRef CGColorSpaceCopyPropertyList(CGColorSpaceRef);
CGError CGSNewRegionWithRect(const CGRect*, CGRegionRef*);
CGError CGSPackagesEnableConnectionOcclusionNotifications(CGSConnectionID, bool flag, bool* outCurrentVisibilityState);
CGError CGSPackagesEnableConnectionWindowModificationNotifications(CGSConnectionID, bool flag, bool* outConnectionIsCurrentlyIdle);
CGError CGSReleaseRegion(const CGRegionRef CF_RELEASES_ARGUMENT);
CGError CGSReleaseRegionEnumerator(const CGSRegionEnumeratorObj);
CGError CGSSetWindowAlpha(CGSConnectionID, CGSWindowID, float alpha);
CGError CGSSetWindowClipShape(CGSConnectionID, CGSWindowID, CGRegionRef shape);
CGError CGSSetWindowWarp(CGSConnectionID, CGSWindowID, int w, int h, const float* mesh);
CGRect* CGSNextRect(const CGSRegionEnumeratorObj);
CGSRegionEnumeratorObj CGSRegionEnumerator(CGRegionRef);
CGStyleRef CGStyleCreateFocusRingWithColor(const CGFocusRingStyle*, CGColorRef);
void CGContextSetStyle(CGContextRef, CGStyleRef);
void CGContextDrawConicGradient(CGContextRef, CGGradientRef, CGPoint center, CGFloat angle);
void CGPathAddUnevenCornersRoundedRect(CGMutablePathRef, const CGAffineTransform *, CGRect, const CGSize corners[4]);
bool CGFontRenderingGetFontSmoothingDisabled(void);
CGShadingRef CGShadingCreateConic(CGColorSpaceRef, CGPoint center, CGFloat angle, CGFunctionRef);
#if HAVE(CORE_GRAPHICS_GRADIENT_CREATE_WITH_OPTIONS)
CGGradientRef CGGradientCreateWithColorComponentsAndOptions(CGColorSpaceRef, const CGFloat*, const CGFloat*, size_t, CFDictionaryRef);
CGGradientRef CGGradientCreateWithColorsAndOptions(CGColorSpaceRef, CFArrayRef, const CGFloat*, CFDictionaryRef);
#endif
#if HAVE(CORE_GRAPHICS_PREMULTIPLIED_INTERPOLATION_GRADIENT)
extern const CFStringRef kCGGradientInterpolatesPremultiplied;
#endif
#endif // PLATFORM(COCOA)
#if PLATFORM(WIN)
CGFontCache* CGFontCacheGetLocalCache();
void CGFontCacheSetShouldAutoExpire(CGFontCache*, bool);
void CGFontCacheSetMaxSize(CGFontCache*, size_t);
void CGContextSetFontSmoothingContrast(CGContextRef, CGFloat);
void CGContextSetFontSmoothingStyle(CGContextRef, uint32_t);
uint32_t CGContextGetFontSmoothingStyle(CGContextRef);
void CGContextSetShouldUsePlatformNativeGlyphs(CGContextRef, bool);
void CGContextSetFocusRingWithColor(CGContextRef, CGFloat blur, CGColorRef, const CGRect *clipRect, CFDictionaryRef options);
#endif // PLATFORM(WIN)
#if PLATFORM(MAC)
bool CGDisplayUsesForceToGray(void);
CGSConnectionID CGSMainConnectionID(void);
CFArrayRef CGSHWCaptureWindowList(CGSConnectionID, CGSWindowIDList windowList, CGSWindowCount, CGSWindowCaptureOptions);
CGError CGSSetConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef value);
CGError CGSCopyConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef *value);
CGError CGSGetScreenRectForWindow(CGSConnectionID, CGSWindowID, CGRect *);
CGError CGSRegisterConnectionNotifyProc(CGSConnectionID, CGSNotifyConnectionProcPtr, CGSNotificationType, void* arg);
CGError CGSRegisterNotifyProc(CGSNotifyProcPtr, CGSNotificationType, void* arg);
size_t CGDisplayModeGetPixelsWide(CGDisplayModeRef);
size_t CGDisplayModeGetPixelsHigh(CGDisplayModeRef);
typedef int32_t CGSDisplayID;
CGSDisplayID CGSMainDisplayID(void);
IOHIDEventRef CGEventCopyIOHIDEvent(CGEventRef);
#endif // PLATFORM(MAC)
#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
CGError CGSSetDenyWindowServerConnections(bool);
#endif
#if ENABLE(PDFKIT_PLUGIN) && !USE(APPLE_INTERNAL_SDK)
extern const off_t kCGDataProviderIndeterminateSize;
extern const CFStringRef kCGDataProviderHasHighLatency;
typedef void (*CGDataProviderGetByteRangesCallback)(void *info,
CFMutableArrayRef buffers, const CFRange *ranges, size_t count);
struct CGDataProviderDirectAccessRangesCallbacks {
unsigned version;
CGDataProviderGetBytesAtPositionCallback getBytesAtPosition;
CGDataProviderGetByteRangesCallback getBytesInRanges;
CGDataProviderReleaseInfoCallback releaseInfo;
};
typedef struct CGDataProviderDirectAccessRangesCallbacks CGDataProviderDirectAccessRangesCallbacks;
extern void CGDataProviderSetProperty(CGDataProviderRef, CFStringRef key, CFTypeRef value);
extern CGDataProviderRef CGDataProviderCreateMultiRangeDirectAccess(
void *info, off_t size,
const CGDataProviderDirectAccessRangesCallbacks *);
#endif // ENABLE(PDFKIT_PLUGIN) && !USE(APPLE_INTERNAL_SDK)
#if HAVE(LOCKDOWN_MODE_PDF_ADDITIONS)
CG_EXTERN void CGEnterLockdownModeForPDF();
CG_LOCAL bool CGIsInLockdownModeForPDF();
CG_EXTERN void CGEnterLockdownModeForFonts();
#endif
WTF_EXTERN_C_END