Skip to content

Commit

Permalink
quartz: Unify DO_SHADING, DO_IMAGE and DO_TILED_IMAGE
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Andrea Canciani committed Oct 12, 2010
1 parent 51a6ae9 commit bbaca95
Showing 1 changed file with 16 additions and 38 deletions.
54 changes: 16 additions & 38 deletions src/cairo-quartz-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bbaca95

Please sign in to comment.