2 * Copyright (C) 2014 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef CoreGraphicsSPI_h
27 #define CoreGraphicsSPI_h
29 #include <CoreFoundation/CoreFoundation.h>
30 #include <CoreGraphics/CoreGraphics.h>
32 #if USE(APPLE_INTERNAL_SDK)
34 #include <CoreGraphics/CGFontCache.h>
35 #include <CoreGraphics/CoreGraphicsPrivate.h>
38 struct CGFontHMetrics {
43 int minLeftSideBearing;
44 int minRightSideBearing;
47 struct CGFontDescriptor {
62 typedef const struct CGColorTransform* CGColorTransformRef;
66 kCGCompositeSover = 2,
67 } CGCompositeOperation;
70 kCGFontRenderingStyleAntialiasing = 1 << 0,
71 kCGFontRenderingStyleSmoothing = 1 << 1,
72 kCGFontRenderingStyleSubpixelPositioning = 1 << 2,
73 kCGFontRenderingStyleSubpixelQuantization = 1 << 3,
74 kCGFontRenderingStylePlatformNative = 1 << 9,
75 kCGFontRenderingStyleMask = 0x20F,
77 typedef uint32_t CGFontRenderingStyle;
80 kCGFontAntialiasingStyleUnfiltered = 0 << 7,
81 kCGFontAntialiasingStyleFilterLight = 1 << 7,
82 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
83 kCGFontAntialiasingStyleUnfilteredCustomDilation = (8 << 7),
86 typedef uint32_t CGFontAntialiasingStyle;
89 kCGImageCachingTransient = 1,
90 kCGImageCachingTemporary = 3,
92 typedef uint32_t CGImageCachingFlags;
95 typedef struct CGSRegionEnumeratorObject* CGSRegionEnumeratorObj;
96 typedef struct CGSRegionObject* CGSRegionObj;
97 typedef struct CGSRegionObject* CGRegionRef;
100 #ifdef CGFLOAT_IS_DOUBLE
101 #define CGRound(value) round((value))
102 #define CGFloor(value) floor((value))
103 #define CGCeiling(value) ceil((value))
104 #define CGFAbs(value) fabs((value))
106 #define CGRound(value) roundf((value))
107 #define CGFloor(value) floorf((value))
108 #define CGCeiling(value) ceilf((value))
109 #define CGFAbs(value) fabsf((value))
112 static inline CGFloat CGFloatMin(CGFloat a, CGFloat b) { return isnan(a) ? b : ((isnan(b) || a < b) ? a : b); }
114 typedef struct CGFontCache CGFontCache;
117 typedef uint32_t CGSConnectionID;
118 typedef uint32_t CGSWindowID;
119 typedef uint32_t CGSWindowCount;
120 typedef CGSWindowID *CGSWindowIDList;
123 kCGSWindowCaptureNominalResolution = 0x0200,
124 kCGSCaptureIgnoreGlobalClipShape = 0x0800,
126 typedef uint32_t CGSWindowCaptureOptions;
129 #endif // USE(APPLE_INTERNAL_SDK)
133 CGColorRef CGColorTransformConvertColor(CGColorTransformRef, CGColorRef, CGColorRenderingIntent);
134 CGColorTransformRef CGColorTransformCreate(CGColorSpaceRef, CFDictionaryRef attributes);
136 CGAffineTransform CGContextGetBaseCTM(CGContextRef);
137 CGCompositeOperation CGContextGetCompositeOperation(CGContextRef);
138 CGColorRef CGContextGetFillColorAsColor(CGContextRef);
139 CGFloat CGContextGetLineWidth(CGContextRef);
140 bool CGContextGetShouldSmoothFonts(CGContextRef);
141 void CGContextSetBaseCTM(CGContextRef, CGAffineTransform);
142 void CGContextSetCTM(CGContextRef, CGAffineTransform);
143 void CGContextSetCompositeOperation(CGContextRef, CGCompositeOperation);
144 void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts);
145 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
146 void CGContextSetFontDilation(CGContextRef, CGSize);
147 void CGContextSetFontRenderingStyle(CGContextRef, CGFontRenderingStyle);
150 CFStringRef CGFontCopyFamilyName(CGFontRef);
151 bool CGFontGetDescriptor(CGFontRef, CGFontDescriptor*);
152 bool CGFontGetGlyphAdvancesForStyle(CGFontRef, const CGAffineTransform* , CGFontRenderingStyle, const CGGlyph[], size_t count, CGSize advances[]);
153 void CGFontGetGlyphsForUnichars(CGFontRef, const UniChar[], CGGlyph[], size_t count);
154 const CGFontHMetrics* CGFontGetHMetrics(CGFontRef);
155 const char* CGFontGetPostScriptName(CGFontRef);
156 bool CGFontIsFixedPitch(CGFontRef);
157 void CGFontSetShouldUseMulticache(bool);
159 void CGImageSetCachingFlags(CGImageRef, CGImageCachingFlags);
160 CGImageCachingFlags CGImageGetCachingFlags(CGImageRef);
162 CGDataProviderRef CGPDFDocumentGetDataProvider(CGPDFDocumentRef);
164 CGFontAntialiasingStyle CGContextGetFontAntialiasingStyle(CGContextRef);
165 void CGContextSetFontAntialiasingStyle(CGContextRef, CGFontAntialiasingStyle);
168 CGSRegionEnumeratorObj CGSRegionEnumerator(CGRegionRef);
169 CGRect* CGSNextRect(const CGSRegionEnumeratorObj);
170 CGError CGSReleaseRegionEnumerator(const CGSRegionEnumeratorObj);
174 CGFontCache* CGFontCacheGetLocalCache();
175 void CGFontCacheSetShouldAutoExpire(CGFontCache*, bool);
176 void CGFontCacheSetMaxSize(CGFontCache*, size_t);
180 CGSConnectionID CGSMainConnectionID(void);
181 CFArrayRef CGSHWCaptureWindowList(CGSConnectionID cid, CGSWindowIDList windowList, CGSWindowCount windowCount, CGSWindowCaptureOptions options);
186 #endif // CoreGraphicsSPI_h