[quartz] Require at least Mac OS X 10.7 Lion

Allows removal of most conditional compilation and dlsym lookups.
This commit is contained in:
John Ralls 2022-04-07 16:51:16 -07:00
parent 0048f0f803
commit 77a8d0f9e4
4 changed files with 66 additions and 327 deletions

View file

@ -193,11 +193,8 @@ dnl ===========================================================================
CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [
dnl There is no pkgconfig for quartz; lets do a header check
AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, , [use_quartz="no (requires ApplicationServices framework)"])
if test "x$use_quartz" != "xyes" ; then
dnl check for CoreGraphics as a separate framework
AC_CHECK_HEADER(CoreGraphics/CoreGraphics.h, , [use_quartz="no (requires CoreGraphics framework)"])
quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics"
else
AC_CHECK_FUNC([CTFontDrawGlyphs],,[use_quartz_fonts="no (requires Mac OS X 10.7 or later)"])
if test "x$use_quartz" = "xyes" ; then
quartz_LIBS="-Xlinker -framework -Xlinker ApplicationServices"
fi
])

View file

@ -455,7 +455,6 @@ if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
deps += [quartz_deps]
feature_conf.set('CAIRO_HAS_QUARTZ_SURFACE', 1)
feature_conf.set('CAIRO_HAS_QUARTZ_FONT', 1)
feature_conf.set('CAIRO_HAS_QUARTZ_IMAGE_SURFACE', 1)
built_features += [
@ -468,13 +467,18 @@ if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
'name': 'cairo-quartz-image',
'description': 'Quartz Image surface backend',
'deps': quartz_deps,
},
{
'name': 'cairo-quartz-font',
'description': 'Quartz font backend',
'deps': quartz_deps,
},
]
}]
compiler = meson.get_compiler('c')
if compiler.has_function('CTFontDrawGlyphs', prefix: '#include <ApplicationServices/ApplicationServices.h>',
dependencies: quartz_deps)
built_features += [
{
'name': 'cairo-quartz-font',
'description': 'Quartz font backend',
'deps': quartz_deps,
}]
feature_conf.set('CAIRO_HAS_QUARTZ_FONT', 1)
endif
endif
endif

View file

@ -64,47 +64,11 @@
* Since: 1.6
**/
static CFDataRef (*CGFontCopyTableForTagPtr) (CGFontRef font, uint32_t tag) = NULL;
/* CreateWithFontName exists in 10.5, but not in 10.4; CreateWithName isn't public in 10.4 */
static CGFontRef (*CGFontCreateWithFontNamePtr) (CFStringRef) = NULL;
static CGFontRef (*CGFontCreateWithNamePtr) (const char *) = NULL;
/* These aren't public before 10.5, and some have different names in 10.4 */
static int (*CGFontGetUnitsPerEmPtr) (CGFontRef) = NULL;
static bool (*CGFontGetGlyphAdvancesPtr) (CGFontRef, const CGGlyph[], size_t, int[]) = NULL;
static bool (*CGFontGetGlyphBBoxesPtr) (CGFontRef, const CGGlyph[], size_t, CGRect[]) = NULL;
static CGRect (*CGFontGetFontBBoxPtr) (CGFontRef) = NULL;
/* Not public, but present */
static void (*CGFontGetGlyphsForUnicharsPtr) (CGFontRef, const UniChar[], const CGGlyph[], size_t) = NULL;
static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
/* These are private functions */
static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
/* Not public in the least bit */
static CGPathRef (*CGFontGetGlyphPathPtr) (CGFontRef fontRef, CGAffineTransform *textTransform, int unknown, CGGlyph glyph) = NULL;
/* CTFontCreateWithGraphicsFont is not available until 10.5 */
typedef const struct __CTFontDescriptor *CTFontDescriptorRef;
static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef, CGFloat, const CGAffineTransform*, CTFontDescriptorRef) = NULL;
static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef, CGGlyph, CGAffineTransform *) = NULL;
/* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */
typedef struct {
int ascent;
int descent;
int leading;
} quartz_CGFontMetrics;
static quartz_CGFontMetrics* (*CGFontGetHMetricsPtr) (CGFontRef fontRef) = NULL;
static int (*CGFontGetAscentPtr) (CGFontRef fontRef) = NULL;
static int (*CGFontGetDescentPtr) (CGFontRef fontRef) = NULL;
static int (*CGFontGetLeadingPtr) (CGFontRef fontRef) = NULL;
/* Not public anymore in 64-bits nor in 10.7 */
static ATSFontRef (*FMGetATSFontRefFromFontPtr) (FMFont iFont) = NULL;
static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE;
static cairo_bool_t _cairo_quartz_font_symbols_present = FALSE;
/* Defined in 10.11 */
#define CGGLYPH_MAX ((CGGlyph) 0xFFFE) /* kCGFontIndexMax */
@ -116,51 +80,11 @@ quartz_font_ensure_symbols(void)
if (_cairo_quartz_font_symbol_lookup_done)
return;
CGFontCopyTableForTagPtr = dlsym(RTLD_DEFAULT, "CGFontCopyTableForTag");
/* Look for the 10.5 versions first */
CGFontGetGlyphBBoxesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphBBoxes");
if (!CGFontGetGlyphBBoxesPtr)
CGFontGetGlyphBBoxesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphBoundingBoxes");
CGFontGetGlyphsForUnicharsPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnichars");
if (!CGFontGetGlyphsForUnicharsPtr)
CGFontGetGlyphsForUnicharsPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnicodes");
CGFontGetFontBBoxPtr = dlsym(RTLD_DEFAULT, "CGFontGetFontBBox");
/* We just need one of these two */
CGFontCreateWithFontNamePtr = dlsym(RTLD_DEFAULT, "CGFontCreateWithFontName");
CGFontCreateWithNamePtr = dlsym(RTLD_DEFAULT, "CGFontCreateWithName");
/* These have the same name in 10.4 and 10.5 */
CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm");
CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances");
CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont");
CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyph");
if (!CTFontCreateWithGraphicsFontPtr || !CTFontCreatePathForGlyphPtr)
CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath");
CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");
CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");
CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent");
CGFontGetLeadingPtr = dlsym(RTLD_DEFAULT, "CGFontGetLeading");
CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
CGContextGetAllowsFontSmoothingPtr =
dlsym (RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
FMGetATSFontRefFromFontPtr = dlsym(RTLD_DEFAULT, "FMGetATSFontRefFromFont");
if ((CGFontCreateWithFontNamePtr || CGFontCreateWithNamePtr) &&
CGFontGetGlyphBBoxesPtr &&
CGFontGetGlyphsForUnicharsPtr &&
CGFontGetUnitsPerEmPtr &&
CGFontGetGlyphAdvancesPtr &&
((CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) || CGFontGetGlyphPathPtr) &&
(CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))
_cairo_quartz_font_symbols_present = TRUE;
_cairo_quartz_font_symbol_lookup_done = TRUE;
}
@ -191,10 +115,6 @@ _cairo_quartz_font_face_create_for_toy (cairo_toy_font_face_t *toy_face,
CGFontRef cgFont = NULL;
int loop;
quartz_font_ensure_symbols();
if (! _cairo_quartz_font_symbols_present)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
family = toy_face->family;
full_name = _cairo_malloc (strlen (family) + 64); // give us a bit of room to tack on Bold, Oblique, etc.
/* handle CSS-ish faces */
@ -231,13 +151,9 @@ _cairo_quartz_font_face_create_for_toy (cairo_toy_font_face_t *toy_face,
strcat (full_name, " Oblique");
}
if (CGFontCreateWithFontNamePtr) {
cgFontName = CFStringCreateWithCString (NULL, full_name, kCFStringEncodingASCII);
cgFont = CGFontCreateWithFontNamePtr (cgFontName);
CFRelease (cgFontName);
} else {
cgFont = CGFontCreateWithNamePtr (full_name);
}
cgFontName = CFStringCreateWithCString (NULL, full_name, kCFStringEncodingASCII);
cgFont = CGFontCreateWithFontName (cgFontName);
CFRelease (cgFontName);
if (cgFont)
break;
@ -279,10 +195,6 @@ _cairo_quartz_font_face_scaled_font_create (void *abstract_face,
double ems;
CGRect bbox;
quartz_font_ensure_symbols();
if (!_cairo_quartz_font_symbols_present)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font = _cairo_malloc (sizeof(cairo_quartz_scaled_font_t));
if (font == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -295,46 +207,17 @@ _cairo_quartz_font_face_scaled_font_create (void *abstract_face,
if (status)
goto FINISH;
ems = CGFontGetUnitsPerEmPtr (font_face->cgFont);
ems = CGFontGetUnitsPerEm (font_face->cgFont);
/* initialize metrics */
if (CGFontGetFontBBoxPtr && CGFontGetAscentPtr) {
fs_metrics.ascent = (CGFontGetAscentPtr (font_face->cgFont) / ems);
fs_metrics.descent = - (CGFontGetDescentPtr (font_face->cgFont) / ems);
fs_metrics.height = fs_metrics.ascent + fs_metrics.descent +
(CGFontGetLeadingPtr (font_face->cgFont) / ems);
fs_metrics.ascent = (CGFontGetAscent (font_face->cgFont) / ems);
fs_metrics.descent = - (CGFontGetDescent (font_face->cgFont) / ems);
fs_metrics.height = fs_metrics.ascent + fs_metrics.descent +
(CGFontGetLeading (font_face->cgFont) / ems);
bbox = CGFontGetFontBBoxPtr (font_face->cgFont);
fs_metrics.max_x_advance = CGRectGetMaxX(bbox) / ems;
fs_metrics.max_y_advance = 0.0;
} else {
CGGlyph wGlyph;
UniChar u;
quartz_CGFontMetrics *m;
m = CGFontGetHMetricsPtr (font_face->cgFont);
/* On OX 10.4, GetHMetricsPtr sometimes returns NULL for unknown reasons */
if (!m) {
status = _cairo_error(CAIRO_STATUS_NULL_POINTER);
goto FINISH;
}
fs_metrics.ascent = (m->ascent / ems);
fs_metrics.descent = - (m->descent / ems);
fs_metrics.height = fs_metrics.ascent + fs_metrics.descent + (m->leading / ems);
/* We kind of have to guess here; W's big, right? */
u = (UniChar) 'W';
CGFontGetGlyphsForUnicharsPtr (font_face->cgFont, &u, &wGlyph, 1);
if (wGlyph && CGFontGetGlyphBBoxesPtr (font_face->cgFont, &wGlyph, 1, &bbox)) {
fs_metrics.max_x_advance = CGRectGetMaxX(bbox) / ems;
fs_metrics.max_y_advance = 0.0;
} else {
fs_metrics.max_x_advance = 0.0;
fs_metrics.max_y_advance = 0.0;
}
}
bbox = CGFontGetFontBBox (font_face->cgFont);
fs_metrics.max_x_advance = CGRectGetMaxX(bbox) / ems;
fs_metrics.max_y_advance = 0.0;
status = _cairo_scaled_font_set_metrics (&font->base, &fs_metrics);
@ -371,11 +254,9 @@ const cairo_font_face_backend_t _cairo_quartz_font_face_backend = {
cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font)
{
cairo_quartz_font_face_t *font_face;
cairo_quartz_font_face_t *font_face =
_cairo_malloc (sizeof (cairo_quartz_font_face_t));
quartz_font_ensure_symbols();
font_face = _cairo_malloc (sizeof (cairo_quartz_font_face_t));
if (!font_face) {
cairo_status_t ignore_status;
ignore_status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -424,14 +305,14 @@ _cairo_quartz_init_glyph_metrics (cairo_quartz_scaled_font_t *font,
CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);
int advance;
CGRect bbox;
double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont);
double emscale = CGFontGetUnitsPerEm (font_face->cgFont);
double xmin, ymin, xmax, ymax;
if (unlikely (glyph == CGGLYPH_INVALID))
goto FAIL;
if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) ||
!CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox))
if (!CGFontGetGlyphAdvances (font_face->cgFont, &glyph, 1, &advance) ||
!CGFontGetGlyphBBoxes (font_face->cgFont, &glyph, 1, &bbox))
goto FAIL;
/* broken fonts like Al Bayan return incorrect bounds for some null characters,
@ -558,6 +439,7 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font);
CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);
CGAffineTransform textMatrix;
CTFontRef ctFont;
CGPathRef glyphPath;
cairo_path_fixed_t *path;
@ -573,13 +455,9 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
-font->base.scale.yy,
0, 0);
if (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) {
CTFontRef ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont, 1.0, NULL, NULL);
glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix);
CFRelease (ctFont);
} else {
glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);
}
ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 1.0, NULL, NULL);
glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix);
CFRelease (ctFont);
if (!glyphPath)
return CAIRO_INT_STATUS_UNSUPPORTED;
@ -614,7 +492,7 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
int advance;
CGRect bbox;
double width, height;
double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont);
double emscale = CGFontGetUnitsPerEm (font_face->cgFont);
CGContextRef cgContext = NULL;
CGAffineTransform textMatrix;
@ -639,8 +517,8 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
return CAIRO_STATUS_SUCCESS;
}
if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) ||
!CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox))
if (!CGFontGetGlyphAdvances (font_face->cgFont, &glyph, 1, &advance) ||
!CGFontGetGlyphBBoxes (font_face->cgFont, &glyph, 1, &bbox))
{
return CAIRO_INT_STATUS_UNSUPPORTED;
}
@ -706,9 +584,10 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
case CAIRO_ANTIALIAS_BEST:
CGContextSetShouldAntialias (cgContext, TRUE);
CGContextSetShouldSmoothFonts (cgContext, TRUE);
if (CGContextSetAllowsFontSmoothingPtr &&
quartz_font_ensure_symbols ();
if (CGContextGetAllowsFontSmoothingPtr &&
!CGContextGetAllowsFontSmoothingPtr (cgContext))
CGContextSetAllowsFontSmoothingPtr (cgContext, TRUE);
CGContextSetAllowsFontSmoothing (cgContext, TRUE);
break;
case CAIRO_ANTIALIAS_NONE:
CGContextSetShouldAntialias (cgContext, FALSE);
@ -767,12 +646,13 @@ _cairo_quartz_ucs4_to_index (void *abstract_font,
{
cairo_quartz_scaled_font_t *font = (cairo_quartz_scaled_font_t*) abstract_font;
cairo_quartz_font_face_t *ffont = _cairo_quartz_scaled_to_face(font);
CTFontRef ctFont;
CGGlyph glyph[2];
UniChar utf16[2];
int len = _cairo_ucs4_to_utf16 (ucs4, utf16);
CGFontGetGlyphsForUnicharsPtr (ffont->cgFont, utf16, glyph, len);
ctFont = CTFontCreateWithGraphicsFont(ffont->cgFont, 10.0, NULL, NULL);
CTFontGetGlyphsForCharacters (ctFont, utf16, glyph, len);
return glyph[0];
}
@ -784,10 +664,7 @@ _cairo_quartz_load_truetype_table (void *abstract_font,
unsigned long *length)
{
cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face (abstract_font);
CFDataRef data = NULL;
if (likely (CGFontCopyTableForTagPtr))
data = CGFontCopyTableForTagPtr (font_face->cgFont, tag);
CFDataRef data = CGFontCopyTableForTag (font_face->cgFont, tag);
if (!data)
return CAIRO_INT_STATUS_UNSUPPORTED;

View file

@ -85,46 +85,22 @@
* Since: 1.6
**/
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
/* This method is private, but it exists. Its params are are exposed
* as args to the NS* method, but not as CG.
*/
enum PrivateCGCompositeMode {
kPrivateCGCompositeClear = 0,
kPrivateCGCompositeCopy = 1,
kPrivateCGCompositeSourceOver = 2,
kPrivateCGCompositeSourceIn = 3,
kPrivateCGCompositeSourceOut = 4,
kPrivateCGCompositeSourceAtop = 5,
kPrivateCGCompositeDestinationOver = 6,
kPrivateCGCompositeDestinationIn = 7,
kPrivateCGCompositeDestinationOut = 8,
kPrivateCGCompositeDestinationAtop = 9,
kPrivateCGCompositeXOR = 10,
kPrivateCGCompositePlusDarker = 11, // (max (0, (1-d) + (1-s)))
kPrivateCGCompositePlusLighter = 12, // (min (1, s + d))
};
typedef enum PrivateCGCompositeMode PrivateCGCompositeMode;
CG_EXTERN void CGContextSetCompositeOperation (CGContextRef, PrivateCGCompositeMode);
#endif
/* Some of these are present in earlier versions of the OS than where
* they are public; other are not public at all
*/
/* public since 10.6 */
static CGPathRef (*CGContextCopyPathPtr) (CGContextRef) = NULL;
static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
/* not yet public */
static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL;
static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE;
/*
* Utility functions
* macOS Private functions
*/
static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL;
static void
quartz_ensure_symbols()
{
static cairo_bool_t symbol_lookup_done = FALSE;
if (!symbol_lookup_done) {
CGContextGetTypePtr = dlsym (RTLD_DEFAULT, "CGContextGetType");
CGContextGetAllowsFontSmoothingPtr =
dlsym (RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
symbol_lookup_done = TRUE;
}
}
#ifdef QUARTZ_DEBUG
static void quartz_surface_to_png (cairo_quartz_surface_t *nq, const char *dest);
@ -152,20 +128,6 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
unsigned int width,
unsigned int height);
/* Load all extra symbols */
static void quartz_ensure_symbols (void)
{
if (likely (_cairo_quartz_symbol_lookup_done))
return;
CGContextGetTypePtr = dlsym (RTLD_DEFAULT, "CGContextGetType");
CGContextCopyPathPtr = dlsym (RTLD_DEFAULT, "CGContextCopyPath");
CGContextGetAllowsFontSmoothingPtr = dlsym (RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
CGContextSetAllowsFontSmoothingPtr = dlsym (RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
_cairo_quartz_symbol_lookup_done = TRUE;
}
CGImageRef
CairoQuartzCreateCGImage (cairo_format_t format,
unsigned int width,
@ -270,6 +232,7 @@ _cairo_quartz_is_cgcontext_bitmap_context (CGContextRef cgc)
if (unlikely (cgc == NULL))
return FALSE;
quartz_ensure_symbols ();
if (likely (CGContextGetTypePtr)) {
/* 4 is the type value of a bitmap context */
return CGContextGetTypePtr (cgc) == 4;
@ -377,58 +340,6 @@ _cairo_quartz_cairo_path_to_quartz_context (const cairo_path_fixed_t *path,
* Misc helpers/callbacks
*/
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
static PrivateCGCompositeMode
_cairo_quartz_cairo_operator_to_quartz_composite (cairo_operator_t op)
{
switch (op) {
case CAIRO_OPERATOR_CLEAR:
return kPrivateCGCompositeClear;
case CAIRO_OPERATOR_SOURCE:
return kPrivateCGCompositeCopy;
case CAIRO_OPERATOR_OVER:
return kPrivateCGCompositeSourceOver;
case CAIRO_OPERATOR_IN:
return kPrivateCGCompositeSourceIn;
case CAIRO_OPERATOR_OUT:
return kPrivateCGCompositeSourceOut;
case CAIRO_OPERATOR_ATOP:
return kPrivateCGCompositeSourceAtop;
case CAIRO_OPERATOR_DEST_OVER:
return kPrivateCGCompositeDestinationOver;
case CAIRO_OPERATOR_DEST_IN:
return kPrivateCGCompositeDestinationIn;
case CAIRO_OPERATOR_DEST_OUT:
return kPrivateCGCompositeDestinationOut;
case CAIRO_OPERATOR_DEST_ATOP:
return kPrivateCGCompositeDestinationAtop;
case CAIRO_OPERATOR_XOR:
return kPrivateCGCompositeXOR;
case CAIRO_OPERATOR_ADD:
return kPrivateCGCompositePlusLighter;
case CAIRO_OPERATOR_DEST:
case CAIRO_OPERATOR_SATURATE:
case CAIRO_OPERATOR_MULTIPLY:
case CAIRO_OPERATOR_SCREEN:
case CAIRO_OPERATOR_OVERLAY:
case CAIRO_OPERATOR_DARKEN:
case CAIRO_OPERATOR_LIGHTEN:
case CAIRO_OPERATOR_COLOR_DODGE:
case CAIRO_OPERATOR_COLOR_BURN:
case CAIRO_OPERATOR_HARD_LIGHT:
case CAIRO_OPERATOR_SOFT_LIGHT:
case CAIRO_OPERATOR_DIFFERENCE:
case CAIRO_OPERATOR_EXCLUSION:
case CAIRO_OPERATOR_HSL_HUE:
case CAIRO_OPERATOR_HSL_SATURATION:
case CAIRO_OPERATOR_HSL_COLOR:
case CAIRO_OPERATOR_HSL_LUMINOSITY:
default:
ASSERT_NOT_REACHED;
}
}
#endif
static CGBlendMode
_cairo_quartz_cairo_operator_to_quartz_blend (cairo_operator_t op)
@ -465,7 +376,6 @@ _cairo_quartz_cairo_operator_to_quartz_blend (cairo_operator_t op)
case CAIRO_OPERATOR_HSL_LUMINOSITY:
return kCGBlendModeLuminosity;
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
case CAIRO_OPERATOR_CLEAR:
return kCGBlendModeClear;
case CAIRO_OPERATOR_SOURCE:
@ -490,21 +400,6 @@ _cairo_quartz_cairo_operator_to_quartz_blend (cairo_operator_t op)
return kCGBlendModeXOR;
case CAIRO_OPERATOR_ADD:
return kCGBlendModePlusLighter;
#else
case CAIRO_OPERATOR_CLEAR:
case CAIRO_OPERATOR_SOURCE:
case CAIRO_OPERATOR_OVER:
case CAIRO_OPERATOR_IN:
case CAIRO_OPERATOR_OUT:
case CAIRO_OPERATOR_ATOP:
case CAIRO_OPERATOR_DEST_OVER:
case CAIRO_OPERATOR_DEST_IN:
case CAIRO_OPERATOR_DEST_OUT:
case CAIRO_OPERATOR_DEST_ATOP:
case CAIRO_OPERATOR_XOR:
case CAIRO_OPERATOR_ADD:
#endif
case CAIRO_OPERATOR_DEST:
case CAIRO_OPERATOR_SATURATE:
default:
@ -534,16 +429,6 @@ _cairo_cgcontext_set_cairo_operator (CGContextRef context, cairo_operator_t op)
return CAIRO_INT_STATUS_UNSUPPORTED;
}
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (op <= CAIRO_OPERATOR_ADD) {
PrivateCGCompositeMode compmode;
compmode = _cairo_quartz_cairo_operator_to_quartz_composite (op);
CGContextSetCompositeOperation (context, compmode);
return CAIRO_STATUS_SUCCESS;
}
#endif
blendmode = _cairo_quartz_cairo_operator_to_quartz_blend (op);
CGContextSetBlendMode (context, blendmode);
return CAIRO_STATUS_SUCCESS;
@ -1558,13 +1443,6 @@ _cairo_quartz_surface_finish (void *abstract_surface)
surface->cgContext = NULL;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 10600
if (surface->imageData) {
free (surface->imageData);
surface->imageData = NULL;
}
#endif
if (surface->cgLayer)
{
CGLayerRelease (surface->cgLayer);
@ -2054,11 +1932,12 @@ _cairo_quartz_cg_glyphs (const cairo_compositor_t *compositor,
case CAIRO_ANTIALIAS_BEST:
CGContextSetShouldAntialias (state.cgMaskContext, TRUE);
CGContextSetShouldSmoothFonts (state.cgMaskContext, TRUE);
if (CGContextSetAllowsFontSmoothingPtr &&
quartz_ensure_symbols();
if (CGContextGetAllowsFontSmoothingPtr &&
!CGContextGetAllowsFontSmoothingPtr (state.cgMaskContext))
{
didForceFontSmoothing = TRUE;
CGContextSetAllowsFontSmoothingPtr (state.cgMaskContext, TRUE);
CGContextSetAllowsFontSmoothing (state.cgMaskContext, TRUE);
}
break;
case CAIRO_ANTIALIAS_NONE:
@ -2135,7 +2014,7 @@ _cairo_quartz_cg_glyphs (const cairo_compositor_t *compositor,
BAIL:
if (didForceFontSmoothing)
CGContextSetAllowsFontSmoothingPtr (state.cgMaskContext, FALSE);
CGContextSetAllowsFontSmoothing (state.cgMaskContext, FALSE);
_cairo_quartz_teardown_state (&state, extents);
@ -2319,8 +2198,6 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
{
cairo_quartz_surface_t *surface;
quartz_ensure_symbols ();
/* Init the base surface */
surface = _cairo_malloc (sizeof (cairo_quartz_surface_t));
if (unlikely (surface == NULL))
@ -2342,9 +2219,6 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
surface->extents.width = width;
surface->extents.height = height;
surface->virtual_extents = surface->extents;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 10600
surface->imageData = NULL;
#endif
if (IS_EMPTY (surface)) {
surface->cgContext = NULL;
@ -2473,16 +2347,6 @@ cairo_quartz_surface_create (cairo_format_t format,
* so we don't have to anything special on allocation.
*/
stride = (stride + 15) & ~15;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 10600
imageData = _cairo_malloc_ab (height, stride);
if (unlikely (!imageData)) {
CGColorSpaceRelease (cgColorspace);
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
/* zero the memory to match the image surface behavior */
memset (imageData, 0, height * stride);
#endif /* For newer macOS versions let Core Graphics manage the buffer. */
cgc = CGBitmapContextCreate (imageData,
width,
height,
@ -2515,9 +2379,6 @@ cairo_quartz_surface_create (cairo_format_t format,
return &surf->base;
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 10600
surf->imageData = imageData;
#endif
surf->base.is_clear = TRUE;
return &surf->base;