From b922477e4e31198739098dff1bc1ed49f81e4745 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Tue, 27 Jul 2010 14:44:17 +0200 Subject: [PATCH] quartz: Check for valid patterns The pattern handling code ensures that 0 stops patterns are reduced to clear solid patterns before being passed down to the backend. An assertion is used to make sure that the assumption actually holds, removing the duplication of the reduce-to-solid-clear logic. --- src/cairo-quartz-surface.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index d0c339147..21f4aa666 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1250,8 +1250,7 @@ _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (cairo_quartz_surface_t cairo_matrix_t m; /* SURFACE is the only type we'll handle here */ - if (apattern->type != CAIRO_PATTERN_TYPE_SURFACE) - return CAIRO_INT_STATUS_UNSUPPORTED; + assert (apattern->type == CAIRO_PATTERN_TYPE_SURFACE); spattern = (cairo_surface_pattern_t *) apattern; pat_surf = spattern->surface; @@ -1431,11 +1430,7 @@ _cairo_quartz_setup_linear_source (cairo_quartz_surface_t *surface, CGColorSpaceRef rgb; bool extend = abspat->extend == CAIRO_EXTEND_PAD; - if (lpat->base.n_stops == 0) { - CGContextSetRGBStrokeColor (surface->cgContext, 0., 0., 0., 0.); - CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.); - return DO_SOLID; - } + assert (lpat->base.n_stops > 0); if (lpat->p1.x == lpat->p2.x && lpat->p1.y == lpat->p2.y) { @@ -1501,11 +1496,7 @@ _cairo_quartz_setup_radial_source (cairo_quartz_surface_t *surface, double dy = c1y - c2y; double centerDistance = sqrt (dx*dx + dy*dy); - if (rpat->base.n_stops == 0) { - CGContextSetRGBStrokeColor (surface->cgContext, 0., 0., 0., 0.); - CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.); - return DO_SOLID; - } + assert (rpat->base.n_stops > 0); if (r2 <= centerDistance + r1 + 1e-6 && /* circle 2 doesn't contain circle 1 */ r1 <= centerDistance + r2 + 1e-6) { /* circle 1 doesn't contain circle 2 */