diff options
author | Keith Packard <keithp@keithp.com> | 2005-10-28 20:41:22 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2005-10-28 20:41:22 +0000 |
commit | 93cbc71a7998485d768a3b4cb4f26b2a443c81c5 (patch) | |
tree | c151145c1541e02d153b4cdff3f2844b79d55407 /src | |
parent | 1540504bd66a75a2fed8352ebfe8b029b3f199dd (diff) | |
download | cairo-93cbc71a7998485d768a3b4cb4f26b2a443c81c5.tar.gz |
Split _cairo_operator_bounded into two separate functions _cairo_operator_bounded_by_mask and _cairo_operator_bound_by_source to distinguish between how operators use source and mask operands.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-gstate.c | 56 | ||||
-rw-r--r-- | src/cairo-image-surface.c | 6 | ||||
-rw-r--r-- | src/cairo-xlib-surface.c | 8 | ||||
-rw-r--r-- | src/cairoint.h | 5 |
4 files changed, 57 insertions, 18 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index e28b7be0e..40403657c 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -750,20 +750,20 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) } /** - * _cairo_operator_bounded: + * _cairo_operator_bounded_by_mask: * @operator: a #cairo_operator_t * - * A bounded operator is one where a source or mask pixel + * A bounded operator is one where mask pixel * of zero results in no effect on the destination image. * * Unbounded operators often require special handling; if you, for * example, draw trapezoids with an unbounded operator, the effect * extends past the bounding box of the trapezoids. * - * Return value: %TRUE if the operator is bounded + * Return value: %TRUE if the operator is bounded by the mask operand **/ cairo_bool_t -_cairo_operator_bounded (cairo_operator_t operator) +_cairo_operator_bounded_by_mask (cairo_operator_t operator) { switch (operator) { case CAIRO_OPERATOR_CLEAR: @@ -788,6 +788,46 @@ _cairo_operator_bounded (cairo_operator_t operator) return FALSE; } +/** + * _cairo_operator_bounded_by_source: + * @operator: a #cairo_operator_t + * + * A bounded operator is one where source pixels of zero + * (in all four components, r, g, b and a) effect no change + * in the resulting destination image. + * + * Unbounded operators often require special handling; if you, for + * example, copy a surface with the SOURCE operator, the effect + * extends past the bounding box of the source surface. + * + * Return value: %TRUE if the operator is bounded by the source operand + **/ +cairo_bool_t +_cairo_operator_bounded_by_source (cairo_operator_t operator) +{ + switch (operator) { + case CAIRO_OPERATOR_OVER: + case CAIRO_OPERATOR_ATOP: + case CAIRO_OPERATOR_DEST: + case CAIRO_OPERATOR_DEST_OVER: + case CAIRO_OPERATOR_DEST_OUT: + case CAIRO_OPERATOR_XOR: + case CAIRO_OPERATOR_ADD: + case CAIRO_OPERATOR_SATURATE: + return TRUE; + case CAIRO_OPERATOR_CLEAR: + case CAIRO_OPERATOR_SOURCE: + case CAIRO_OPERATOR_OUT: + case CAIRO_OPERATOR_IN: + case CAIRO_OPERATOR_DEST_IN: + case CAIRO_OPERATOR_DEST_ATOP: + return FALSE; + } + + ASSERT_NOT_REACHED; + return FALSE; +} + static cairo_status_t _create_composite_mask_pattern (cairo_surface_pattern_t *mask_pattern, cairo_clip_t *clip, @@ -1057,7 +1097,7 @@ _cairo_gstate_clip_and_composite (cairo_clip_t *clip, src, draw_func, draw_closure, dst, extents); - else if (_cairo_operator_bounded (operator)) + else if (_cairo_operator_bounded_by_mask (operator)) status = _cairo_gstate_clip_and_composite_with_mask (clip, operator, src, draw_func, draw_closure, @@ -1338,7 +1378,7 @@ _cairo_surface_clip_and_composite_trapezoids (cairo_pattern_t *src, if (status) return status; - if (_cairo_operator_bounded (operator)) + if (_cairo_operator_bounded_by_mask (operator)) { if (trap_region) { status = _cairo_clip_intersect_to_region (clip, trap_region); @@ -1411,7 +1451,7 @@ _cairo_surface_clip_and_composite_trapezoids (cairo_pattern_t *src, goto out; } - if ((_cairo_operator_bounded (operator) && operator != CAIRO_OPERATOR_SOURCE) || + if ((_cairo_operator_bounded_by_mask (operator) && operator != CAIRO_OPERATOR_SOURCE) || !clip->surface) { /* For a simple rectangle, we can just use composite(), for more @@ -2011,7 +2051,7 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate, &transformed_glyphs[i].y); } - if (_cairo_operator_bounded (gstate->operator)) + if (_cairo_operator_bounded_by_mask (gstate->operator)) status = _cairo_scaled_font_glyph_device_extents (gstate->scaled_font, transformed_glyphs, num_glyphs, diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 20d14c170..c05dfeb60 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -620,9 +620,7 @@ _cairo_image_surface_composite (cairo_operator_t operator, width, height); } - if (!_cairo_operator_bounded (operator) || - operator == CAIRO_OPERATOR_SOURCE || - operator == CAIRO_OPERATOR_CLEAR) + if (!_cairo_operator_bounded_by_source (operator)) status = _cairo_surface_composite_fixup_unbounded (&dst->base, &src_attr, src->width, src->height, mask ? &mask_attr : NULL, @@ -785,7 +783,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t operator, dst_x, dst_y, width, height); - if (!_cairo_operator_bounded (operator)) + if (!_cairo_operator_bounded_by_mask (operator)) status = _cairo_surface_composite_shape_fixup_unbounded (&dst->base, &attributes, src->width, src->height, width, height, diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 3c6caf645..47ef825e1 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -1302,9 +1302,7 @@ _cairo_xlib_surface_composite (cairo_operator_t operator, ASSERT_NOT_REACHED; } - if (!_cairo_operator_bounded (operator) || - operator == CAIRO_OPERATOR_SOURCE || - operator == CAIRO_OPERATOR_CLEAR) + if (!_cairo_operator_bounded_by_source (operator)) status = _cairo_surface_composite_fixup_unbounded (&dst->base, &src_attr, src->width, src->height, mask ? &mask_attr : NULL, @@ -1511,7 +1509,7 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t operator, if (status) goto FAIL; - if (!_cairo_operator_bounded (operator)) { + if (!_cairo_operator_bounded_by_mask (operator)) { /* XRenderCompositeTrapezoids() creates a mask only large enough for the * trapezoids themselves, but if the operator is unbounded, then we need * to actually composite all the way out to the bounds, so we create @@ -2478,7 +2476,7 @@ _cairo_xlib_surface_show_glyphs (cairo_scaled_font_t *scaled_font, source_y + attributes.y_offset - dest_y, glyphs, num_glyphs); - if (status == CAIRO_STATUS_SUCCESS && !_cairo_operator_bounded (operator)) { + if (status == CAIRO_STATUS_SUCCESS && !_cairo_operator_bounded_by_mask (operator)) { cairo_rectangle_t extents; status = _cairo_scaled_font_glyph_device_extents (scaled_font, glyphs, diff --git a/src/cairoint.h b/src/cairoint.h index a6b7f88b5..91e7ce661 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1243,7 +1243,10 @@ _cairo_gstate_clip_and_composite (cairo_clip_t *clip, const cairo_rectangle_t *extents); cairo_private cairo_bool_t -_cairo_operator_bounded (cairo_operator_t operator); +_cairo_operator_bounded_by_mask (cairo_operator_t operator); + +cairo_private cairo_bool_t +_cairo_operator_bounded_by_source (cairo_operator_t operator); /* cairo_color.c */ cairo_private const cairo_color_t * |