diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-07-29 15:50:21 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-13 00:27:01 +0200 |
commit | bbaca9598292eaee2da3c8a7c275d53bf1a1a652 (patch) | |
tree | 6add8f7e419ae2239d008ca1290e1e23aad6dc6d /src | |
parent | 51a6ae9d71daefdca214fdc48e1bb8fcba10029d (diff) |
quartz: Unify DO_SHADING, DO_IMAGE and DO_TILED_IMAGE
DO_SHADING, DO_IMAGE and DO_TILED_IMAGE sources all require the source
to be painted over the whole surface (inside the clip region), thus can
share the same code path in drawing functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-quartz-surface.c | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 9bf02402..ec5aa267 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1606,11 +1606,15 @@ _cairo_quartz_setup_source_safe (cairo_quartz_surface_t *surface, } static void -_cairo_quartz_draw_image (cairo_quartz_surface_t *surface, cairo_operator_t op) +_cairo_quartz_draw_source (cairo_quartz_surface_t *surface, cairo_operator_t op) { - assert (surface && surface->sourceImage && (surface->action == DO_IMAGE || surface->action == DO_TILED_IMAGE)); - CGContextConcatCTM (surface->cgContext, surface->sourceTransform); + + if (surface->action == DO_SHADING) { + CGContextDrawShading (surface->cgContext, surface->sourceShading); + return; + } + CGContextTranslateCTM (surface->cgContext, 0, surface->sourceImageRect.size.height); CGContextScaleCTM (surface->cgContext, 1, -1); @@ -2000,11 +2004,8 @@ _cairo_quartz_surface_paint_cg (cairo_quartz_surface_t *surface, surface->extents.y, surface->extents.width, surface->extents.height)); - } else if (surface->action == DO_SHADING) { - CGContextConcatCTM (surface->cgContext, surface->sourceTransform); - CGContextDrawShading (surface->cgContext, surface->sourceShading); - } else if (surface->action == DO_IMAGE || surface->action == DO_TILED_IMAGE) { - _cairo_quartz_draw_image (surface, op); + } else { + _cairo_quartz_draw_source (surface, op); } _cairo_quartz_teardown_source (surface, source); @@ -2083,24 +2084,13 @@ _cairo_quartz_surface_fill_cg (cairo_quartz_surface_t *surface, CGContextFillPath (surface->cgContext); else CGContextEOFillPath (surface->cgContext); - } else if (surface->action == DO_SHADING) { - - // we have to clip and then paint the shading; we can't fill - // with the shading - if (fill_rule == CAIRO_FILL_RULE_WINDING) - CGContextClip (surface->cgContext); - else - CGContextEOClip (surface->cgContext); - - CGContextConcatCTM (surface->cgContext, surface->sourceTransform); - CGContextDrawShading (surface->cgContext, surface->sourceShading); - } else if (surface->action == DO_IMAGE || surface->action == DO_TILED_IMAGE) { + } else { if (fill_rule == CAIRO_FILL_RULE_WINDING) CGContextClip (surface->cgContext); else CGContextEOClip (surface->cgContext); - _cairo_quartz_draw_image (surface, op); + _cairo_quartz_draw_source (surface, op); } _cairo_quartz_teardown_source (surface, source); @@ -2234,20 +2224,12 @@ _cairo_quartz_surface_stroke_cg (cairo_quartz_surface_t *surface, if (surface->action == DO_DIRECT) { CGContextStrokePath (surface->cgContext); - } else if (surface->action == DO_IMAGE || surface->action == DO_TILED_IMAGE) { - CGContextReplacePathWithStrokedPath (surface->cgContext); - CGContextClip (surface->cgContext); - - CGContextSetCTM (surface->cgContext, origCTM); - _cairo_quartz_draw_image (surface, op); - } else if (surface->action == DO_SHADING) { + } else { CGContextReplacePathWithStrokedPath (surface->cgContext); CGContextClip (surface->cgContext); CGContextSetCTM (surface->cgContext, origCTM); - - CGContextConcatCTM (surface->cgContext, surface->sourceTransform); - CGContextDrawShading (surface->cgContext, surface->sourceShading); + _cairo_quartz_draw_source (surface, op); } _cairo_quartz_teardown_source (surface, source); @@ -2362,7 +2344,7 @@ _cairo_quartz_surface_show_glyphs_cg (cairo_quartz_surface_t *surface, if (surface->action == DO_DIRECT) { CGContextSetTextDrawingMode (surface->cgContext, kCGTextFill); - } else if (surface->action == DO_IMAGE || surface->action == DO_TILED_IMAGE || surface->action == DO_SHADING) { + } else { CGContextSetTextDrawingMode (surface->cgContext, kCGTextClip); isClipping = TRUE; } @@ -2446,12 +2428,8 @@ _cairo_quartz_surface_show_glyphs_cg (cairo_quartz_surface_t *surface, CGContextSetCTM (surface->cgContext, ctm); - if (surface->action == DO_IMAGE || surface->action == DO_TILED_IMAGE) { - _cairo_quartz_draw_image (surface, op); - } else if (surface->action == DO_SHADING) { - CGContextConcatCTM (surface->cgContext, surface->sourceTransform); - CGContextDrawShading (surface->cgContext, surface->sourceShading); - } + if (surface->action != DO_DIRECT) + _cairo_quartz_draw_source (surface, op); BAIL: _cairo_quartz_teardown_source (surface, source); |