diff options
author | Andrea Canciani <ranma42@gmail.com> | 2014-10-12 21:06:23 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@dhcp-131-114-88-208.di.unipi.it> | 2015-03-10 14:39:50 +0100 |
commit | 66b5419704aa1971c77de764fd94b2f7d2a05b76 (patch) | |
tree | 27b48383e7dacec383a2d94ebbfc2f88d5e02614 | |
parent | 79dbe1bad8089aa3e0b9a9a63443a74cd9e22f32 (diff) |
Remove support for MacOS X 10.4wip/remove-10.4
NOT FOR MERGING
This commit removes support for 10.4.
Some more investigation is needed (example: investigate why
CGContextCopyPath and CGContextSetAllowsFontSmoothing are dynamically
linked, even though they are supposed to be available since 10.2) and
the commit should be split into self-contained changes.
-rw-r--r-- | src/cairo-quartz-font.c | 123 | ||||
-rw-r--r-- | src/cairo-quartz-surface.c | 111 |
2 files changed, 22 insertions, 212 deletions
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c index 02f34267b..43fc58ece 100644 --- a/src/cairo-quartz-font.c +++ b/src/cairo-quartz-font.c @@ -64,34 +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; static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = 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; @@ -104,43 +81,16 @@ 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"); - - 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"); FMGetATSFontRefFromFontPtr = dlsym(RTLD_DEFAULT, "FMGetATSFontRefFromFont"); - if ((CGFontCreateWithFontNamePtr || CGFontCreateWithNamePtr) && - CGFontGetGlyphBBoxesPtr && - CGFontGetGlyphsForUnicharsPtr && - CGFontGetUnitsPerEmPtr && - CGFontGetGlyphAdvancesPtr && - (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr))) + if (CGFontGetGlyphsForUnicharsPtr) _cairo_quartz_font_symbols_present = TRUE; _cairo_quartz_font_symbol_lookup_done = TRUE; @@ -213,13 +163,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; @@ -277,46 +223,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); - - 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; + 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); - 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); @@ -410,14 +327,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 (glyph == INVALID_GLYPH) 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, @@ -596,7 +513,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; @@ -621,8 +538,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; } @@ -766,9 +683,7 @@ _cairo_quartz_load_truetype_table (void *abstract_font, 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); - + data = CGFontCopyTableForTag (font_face->cgFont, tag); if (!data) return CAIRO_INT_STATUS_UNSUPPORTED; diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 1116ff94c..dbd103d9f 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -86,36 +86,11 @@ * 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.5 */ -static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL; - /* public since 10.6 */ +/* TODO: check me: documentation states these are available since 10.2 */ static CGPathRef (*CGContextCopyPathPtr) (CGContextRef) = NULL; static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL; @@ -146,7 +121,6 @@ static void quartz_ensure_symbols (void) if (likely (_cairo_quartz_symbol_lookup_done)) return; - CGContextDrawTiledImagePtr = dlsym (RTLD_DEFAULT, "CGContextDrawTiledImage"); CGContextGetTypePtr = dlsym (RTLD_DEFAULT, "CGContextGetType"); CGContextCopyPathPtr = dlsym (RTLD_DEFAULT, "CGContextCopyPath"); CGContextGetAllowsFontSmoothingPtr = dlsym (RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing"); @@ -363,60 +337,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) { @@ -452,7 +372,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: @@ -477,20 +396,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: @@ -517,16 +422,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; @@ -1233,7 +1128,7 @@ _cairo_quartz_setup_state (cairo_quartz_drawing_state_t *state, } if (source->type == CAIRO_PATTERN_TYPE_SURFACE && - (source->extend == CAIRO_EXTEND_NONE || (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT))) + (source->extend == CAIRO_EXTEND_NONE || source->extend == CAIRO_EXTEND_REPEAT)) { const cairo_surface_pattern_t *spat = (const cairo_surface_pattern_t *) source; cairo_surface_t *pat_surf = spat->surface; @@ -1425,7 +1320,7 @@ _cairo_quartz_draw_source (cairo_quartz_drawing_state_t *state, CGContextEOFillPath (state->cgDrawContext); } } else { - CGContextDrawTiledImagePtr (state->cgDrawContext, state->rect, state->image); + CGContextDrawTiledImage (state->cgDrawContext, state->rect, state->image); } } |