gfx/cairo/quartz-optimize-OVER.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/quartz-optimize-OVER.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +From: Robert O'Callahan <robert@ocallahan.org>
     1.5 +Bug 579885. Part 4: Paint opaque surfaces using kPrivateCGCompositeCopy when possible. r=jrmuizel,a=blocking
     1.6 +
     1.7 +diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.8 +--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.9 ++++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
    1.10 +@@ -122,16 +122,17 @@ static void (*CGContextClipToMaskPtr) (C
    1.11 + static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL;
    1.12 + static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL;
    1.13 + static void (*CGContextSetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL;
    1.14 + static bool (*CGContextGetShouldAntialiasFontsPtr) (CGContextRef) = NULL;
    1.15 + static bool (*CGContextGetShouldSmoothFontsPtr) (CGContextRef) = NULL;
    1.16 + static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
    1.17 + static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
    1.18 + static void (*CGContextReplacePathWithClipPathPtr) (CGContextRef) = NULL;
    1.19 ++static CGFloat (*CGContextGetAlphaPtr) (CGContextRef) = NULL;
    1.20 + 
    1.21 + static SInt32 _cairo_quartz_osx_version = 0x0;
    1.22 + 
    1.23 + static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE;
    1.24 + 
    1.25 + /*
    1.26 +  * Utility functions
    1.27 +  */
    1.28 +@@ -157,16 +158,17 @@ static void quartz_ensure_symbols(void)
    1.29 +     CGContextDrawTiledImagePtr = dlsym(RTLD_DEFAULT, "CGContextDrawTiledImage");
    1.30 +     CGContextGetTypePtr = dlsym(RTLD_DEFAULT, "CGContextGetType");
    1.31 +     CGContextSetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldAntialiasFonts");
    1.32 +     CGContextGetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextGetShouldAntialiasFonts");
    1.33 +     CGContextGetShouldSmoothFontsPtr = dlsym(RTLD_DEFAULT, "CGContextGetShouldSmoothFonts");
    1.34 +     CGContextReplacePathWithClipPathPtr = dlsym(RTLD_DEFAULT, "CGContextReplacePathWithClipPath");
    1.35 +     CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
    1.36 +     CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
    1.37 ++    CGContextGetAlphaPtr = dlsym(RTLD_DEFAULT, "CGContextGetAlpha");
    1.38 + 
    1.39 +     if (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) {
    1.40 + 	// assume 10.4
    1.41 + 	_cairo_quartz_osx_version = 0x1040;
    1.42 +     }
    1.43 + 
    1.44 +     _cairo_quartz_symbol_lookup_done = TRUE;
    1.45 + }
    1.46 +@@ -1698,16 +1700,28 @@ _cairo_quartz_setup_state (cairo_quartz_
    1.47 + 
    1.48 +     if (source->type == CAIRO_PATTERN_TYPE_RADIAL) {
    1.49 + 	const cairo_radial_pattern_t *rpat = (const cairo_radial_pattern_t *)source;
    1.50 + 	_cairo_quartz_setup_radial_source (surface, rpat, extents, &state);
    1.51 + 	return state;
    1.52 +     }
    1.53 + 
    1.54 +     if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
    1.55 ++        if (op == CAIRO_OPERATOR_OVER && _cairo_pattern_is_opaque (source) &&
    1.56 ++            CGContextGetAlphaPtr &&
    1.57 ++            CGContextGetAlphaPtr (surface->cgContext) == 1.0) {
    1.58 ++            // Quartz won't touch pixels outside the bounds of the
    1.59 ++            // source surface, so we can just go ahead and use Copy here
    1.60 ++            // to accelerate things.
    1.61 ++            // Quartz won't necessarily be able to do this optimization internally;
    1.62 ++            // for CGLayer surfaces, we can know all the pixels are opaque
    1.63 ++            // (because it's CONTENT_COLOR), but Quartz won't know.
    1.64 ++            CGContextSetCompositeOperation (context, kPrivateCGCompositeCopy);
    1.65 ++        }
    1.66 ++
    1.67 + 	const cairo_surface_pattern_t *spat = (const cairo_surface_pattern_t *) source;
    1.68 +         _cairo_quartz_setup_surface_source (surface, spat, extents, &state);
    1.69 +         return state;
    1.70 +     }
    1.71 + 
    1.72 +     state.action = DO_UNSUPPORTED;
    1.73 +     return state;
    1.74 + }

mercurial