From aa2fb0c05fefeea97a2d72f882a6b2c40d98af39 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Sat, 1 Jan 2011 22:36:45 +0100 Subject: [PATCH] quartz: Do not use opaque patterns as masks When an opaque surface is used as a mask, Quartz converts it to greyscale and uses the result as an alpha value. Cairo expects the mask operation to ignore the color components and only use the alpha of the pattern. The expected behavior can be achieved by drawing the mask on a temporary surface with an alpha channel. Fixes clear-source. --- src/cairo-quartz-surface.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index e8ac7f6b6..5f84c65ce 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -2399,8 +2399,12 @@ _cairo_quartz_surface_mask_cg (cairo_quartz_surface_t *surface, } /* For these, we can skip creating a temporary surface, since we already have one */ - if (mask->type == CAIRO_PATTERN_TYPE_SURFACE && mask->extend == CAIRO_EXTEND_NONE) - return _cairo_quartz_surface_mask_with_surface (surface, op, source, (cairo_surface_pattern_t *) mask, clip); + if (mask->type == CAIRO_PATTERN_TYPE_SURFACE && mask->extend == CAIRO_EXTEND_NONE) { + const cairo_surface_pattern_t *mask_spat = (const cairo_surface_pattern_t *) mask; + + if (mask_spat->surface->content & CAIRO_CONTENT_ALPHA) + return _cairo_quartz_surface_mask_with_surface (surface, op, source, mask_spat, clip); + } return _cairo_quartz_surface_mask_with_generic (surface, op, source, mask, clip); }