gfx/cairo/quartz-surface-mask-patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/quartz-surface-mask-patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.5 +--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.6 ++++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.7 +@@ -128,20 +128,22 @@ CG_EXTERN CGImageRef CGBitmapContextCrea
     1.8 +  */
     1.9 + static void (*CGContextClipToMaskPtr) (CGContextRef, CGRect, CGImageRef) = NULL;
    1.10 + static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL;
    1.11 + static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL;
    1.12 + static void (*CGContextSetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL;
    1.13 + static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
    1.14 + static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
    1.15 + static CGPathRef (*CGContextCopyPathPtr) (CGContextRef) = NULL;
    1.16 + static CGFloat (*CGContextGetAlphaPtr) (CGContextRef) = NULL;
    1.17 + 
    1.18 ++static SInt32 _cairo_quartz_osx_version = 0x0;
    1.19 ++
    1.20 + static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE;
    1.21 + 
    1.22 + /*
    1.23 +  * Utility functions
    1.24 +  */
    1.25 + 
    1.26 + #ifdef QUARTZ_DEBUG
    1.27 + static void quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest);
    1.28 + static void quartz_image_to_png (CGImageRef, char *dest);
    1.29 + #endif
    1.30 +@@ -163,20 +165,25 @@ static void quartz_ensure_symbols(void)
    1.31 + 
    1.32 +     CGContextClipToMaskPtr = dlsym(RTLD_DEFAULT, "CGContextClipToMask");
    1.33 +     CGContextDrawTiledImagePtr = dlsym(RTLD_DEFAULT, "CGContextDrawTiledImage");
    1.34 +     CGContextGetTypePtr = dlsym(RTLD_DEFAULT, "CGContextGetType");
    1.35 +     CGContextSetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldAntialiasFonts");
    1.36 +     CGContextCopyPathPtr = dlsym(RTLD_DEFAULT, "CGContextCopyPath");
    1.37 +     CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
    1.38 +     CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
    1.39 +     CGContextGetAlphaPtr = dlsym(RTLD_DEFAULT, "CGContextGetAlpha");
    1.40 + 
    1.41 ++    if (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) {
    1.42 ++        // assume 10.5
    1.43 ++        _cairo_quartz_osx_version = 0x1050;
    1.44 ++    }
    1.45 ++
    1.46 +     _cairo_quartz_symbol_lookup_done = TRUE;
    1.47 + }
    1.48 + 
    1.49 + CGImageRef
    1.50 + _cairo_quartz_create_cgimage (cairo_format_t format,
    1.51 + 			      unsigned int width,
    1.52 + 			      unsigned int height,
    1.53 + 			      unsigned int stride,
    1.54 + 			      void *data,
    1.55 + 			      cairo_bool_t interpolate,
    1.56 +@@ -3028,22 +3035,25 @@ static cairo_int_status_t
    1.57 + 	CGContextSetAlpha (surface->cgContext, solid_mask->color.alpha);
    1.58 + 	rv = _cairo_quartz_surface_paint_cg (surface, op, source, clip);
    1.59 + 	CGContextSetAlpha (surface->cgContext, 1.0);
    1.60 + 
    1.61 + 	return rv;
    1.62 +     }
    1.63 + 
    1.64 +     /* If we have CGContextClipToMask, we can do more complex masks */
    1.65 +     if (CGContextClipToMaskPtr) {
    1.66 + 	/* For these, we can skip creating a temporary surface, since we already have one */
    1.67 +-	if (mask->type == CAIRO_PATTERN_TYPE_SURFACE && mask->extend == CAIRO_EXTEND_NONE)
    1.68 ++	/* For some reason this doesn't work reliably on OS X 10.5.  See bug 721663. */
    1.69 ++	if (_cairo_quartz_osx_version >= 0x1060 && mask->type == CAIRO_PATTERN_TYPE_SURFACE &&
    1.70 ++	    mask->extend == CAIRO_EXTEND_NONE) {
    1.71 + 	    return _cairo_quartz_surface_mask_with_surface (surface, op, source, (cairo_surface_pattern_t *) mask, clip);
    1.72 ++	}
    1.73 + 
    1.74 + 	return _cairo_quartz_surface_mask_with_generic (surface, op, source, mask, clip);
    1.75 +     }
    1.76 + 
    1.77 +     /* So, CGContextClipToMask is not present in 10.3.9, so we're
    1.78 +      * doomed; if we have imageData, we can do fallback, otherwise
    1.79 +      * just pretend success.
    1.80 +      */
    1.81 +     if (surface->imageData)
    1.82 + 	return CAIRO_INT_STATUS_UNSUPPORTED;

mercurial