diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-09-18 08:26:42 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-09-18 08:27:06 +0100 |
commit | 6c6bd6fb292c7168b60f1cc0580c52292f99ae86 (patch) | |
tree | 124c53356378ab639b15861551076c3d9f4e6c32 /src/cairo-composite-rectangles.c | |
parent | b13c2270f5b7546453f81dd0e1ebdc7fb8e4b630 (diff) | |
download | cairo-6c6bd6fb292c7168b60f1cc0580c52292f99ae86.tar.gz |
composite-rectangle: Add a helper to refine source extents
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-composite-rectangles.c')
-rw-r--r-- | src/cairo-composite-rectangles.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c index a6f37689a..c66d3d628 100644 --- a/src/cairo-composite-rectangles.c +++ b/src/cairo-composite-rectangles.c @@ -172,6 +172,60 @@ _cairo_composite_rectangles_intersect (cairo_composite_rectangles_t *extents, } cairo_int_status_t +_cairo_composite_rectangles_intersect_source_extents (cairo_composite_rectangles_t *extents, + const cairo_box_t *box) +{ + cairo_rectangle_int_t rect; + cairo_clip_t *clip; + + _cairo_box_round_to_rectangle (box, &rect); + if (rect.x == extents->source.x && + rect.y == extents->source.y && + rect.width == extents->source.width && + rect.height == extents->source.height) + { + return CAIRO_INT_STATUS_SUCCESS; + } + + _cairo_rectangle_intersect (&extents->source, &rect); + + rect = extents->bounded; + if (! _cairo_rectangle_intersect (&extents->bounded, &extents->source) && + extents->is_bounded & CAIRO_OPERATOR_BOUND_BY_SOURCE) + return CAIRO_INT_STATUS_NOTHING_TO_DO; + + if (rect.width == extents->bounded.width && + rect.height == extents->bounded.height) + return CAIRO_INT_STATUS_SUCCESS; + + if (extents->is_bounded == (CAIRO_OPERATOR_BOUND_BY_MASK | CAIRO_OPERATOR_BOUND_BY_SOURCE)) + extents->unbounded = extents->bounded; + + clip = extents->clip; + extents->clip = _cairo_clip_reduce_for_composite (clip, extents); + if (clip != extents->clip) + _cairo_clip_destroy (clip); + + if (_cairo_clip_is_all_clipped (extents->clip)) + return CAIRO_INT_STATUS_NOTHING_TO_DO; + + if (extents->source_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID) + _cairo_pattern_sampled_area (&extents->source_pattern.base, + &extents->bounded, + &extents->source_sample_area); + if (extents->mask_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID) { + _cairo_pattern_sampled_area (&extents->mask_pattern.base, + &extents->bounded, + &extents->mask_sample_area); + if (extents->mask_sample_area.width == 0 || + extents->mask_sample_area.height == 0) + return CAIRO_INT_STATUS_NOTHING_TO_DO; + } + + return CAIRO_INT_STATUS_SUCCESS; +} + +cairo_int_status_t _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t *extents, const cairo_box_t *box) { @@ -201,11 +255,8 @@ _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t if (extents->is_bounded == (CAIRO_OPERATOR_BOUND_BY_MASK | CAIRO_OPERATOR_BOUND_BY_SOURCE)) extents->unbounded = extents->bounded; - extents->mask = mask; clip = extents->clip; - extents->clip = _cairo_clip_reduce_for_composite (clip, extents); - if (clip != extents->clip) _cairo_clip_destroy (clip); |