summaryrefslogtreecommitdiff
path: root/src/cairo-composite-rectangles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-composite-rectangles.c')
-rw-r--r--src/cairo-composite-rectangles.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index 439f453bd..6083973f6 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -54,11 +54,12 @@ _cairo_composite_rectangles_init (cairo_composite_rectangles_t *extents,
const cairo_clip_t *clip)
{
extents->clip = NULL;
+ extents->destination = *unbounded;
if (_cairo_clip_is_all_clipped (clip))
return FALSE;
- extents->unbounded = *unbounded;
+ extents->unbounded = extents->destination;
if (clip != NULL) {
if (! _cairo_rectangle_intersect (&extents->unbounded,
_cairo_clip_get_extents (clip)))
@@ -247,3 +248,26 @@ _cairo_composite_rectangles_init_for_glyphs (cairo_composite_rectangles_t *exten
return _cairo_composite_rectangles_intersect (extents, clip);
}
+
+cairo_bool_t
+_cairo_composite_rectangles_can_reduce_clip (cairo_composite_rectangles_t *composite,
+ cairo_clip_t *clip)
+{
+ cairo_rectangle_int_t extents;
+
+ if (clip == NULL)
+ return TRUE;
+
+ /* XXX In the not a region case, we could still search through the boxes */
+ if (! _cairo_clip_is_region (clip))
+ return FALSE;
+
+ extents = composite->destination;
+ if (composite->is_bounded & CAIRO_OPERATOR_BOUND_BY_SOURCE)
+ _cairo_rectangle_intersect (&extents, &composite->source);
+ if (composite->is_bounded & CAIRO_OPERATOR_BOUND_BY_MASK)
+ _cairo_rectangle_intersect (&extents, &composite->mask);
+
+ return cairo_region_contains_rectangle (_cairo_clip_get_region (clip),
+ &extents) == CAIRO_REGION_OVERLAP_IN;
+}