Control: tags -1 fixed-upstream patch

On 2013-06-08 07:42 +0200, Milan Kostić wrote:

>  And this is actually fixed in upstream git week ago:
>
>  
> http://cgit.freedesktop.org/cairo/commit/?id=41bef0fc385381b8c6b9091ec7ca2abe04cfc147

I can confirm that this patch (attached for convenience) fixes the
problem, it would be great to include it in the next cairo upload.

Cheers,
       Sven

>From 41bef0fc385381b8c6b9091ec7ca2abe04cfc147 Mon Sep 17 00:00:00 2001
From: Chris Wilson <ch...@chris-wilson.co.uk>
Date: Thu, 30 May 2013 19:57:04 +0000
Subject: traps: Ensure that we correctly clip when using multiple clip boxes

We need to be more careful when trying to discard a clip to be sure that
it is truly not required. In particular, we need to not throw a way a
clip region when it has more than one box intersecting the mask.

Reported-by: Alexander Larsson
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=697357
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index c26098a..e6639d0 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -167,6 +167,13 @@ _cairo_composite_rectangles_intersect (cairo_composite_rectangles_t *extents,
 				      _cairo_clip_get_extents (extents->clip)))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
+    if (! _cairo_rectangle_intersect (&extents->bounded,
+				      _cairo_clip_get_extents (extents->clip)) &&
+	extents->is_bounded & CAIRO_OPERATOR_BOUND_BY_MASK)
+    {
+	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,
diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c
index 02fbe75..988d23c 100644
--- a/src/cairo-traps-compositor.c
+++ b/src/cairo-traps-compositor.c
@@ -928,12 +928,20 @@ need_bounded_clip (cairo_composite_rectangles_t *extents)
 {
     unsigned int flags = 0;
 
-    if (extents->unbounded.width < extents->destination.width ||
-	extents->unbounded.height < extents->destination.height)
+    if (extents->clip->num_boxes > 1 ||
+	extents->mask.width > extents->unbounded.width ||
+	extents->mask.height > extents->unbounded.height)
     {
 	flags |= NEED_CLIP_REGION;
     }
 
+    if (extents->clip->num_boxes > 1 ||
+	extents->mask.width > extents->bounded.width ||
+	extents->mask.height > extents->bounded.height)
+    {
+	flags |= FORCE_CLIP_REGION;
+    }
+
     if (! _cairo_clip_is_region (extents->clip))
 	flags |= NEED_CLIP_SURFACE;
 
@@ -2160,18 +2168,14 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor,
 				    double			 tolerance,
 				    cairo_traps_t		*traps);
 	composite_traps_info_t info;
-	unsigned flags = 0;
+	unsigned flags;
 
 	if (antialias == CAIRO_ANTIALIAS_BEST || antialias == CAIRO_ANTIALIAS_GOOD) {
 	    func = _cairo_path_fixed_stroke_polygon_to_traps;
+	    flags = 0;
 	} else {
 	    func = _cairo_path_fixed_stroke_to_traps;
-	    if (extents->clip->num_boxes > 1 ||
-		extents->mask.width  > extents->unbounded.width ||
-		extents->mask.height > extents->unbounded.height)
-	    {
-		flags = NEED_CLIP_REGION | FORCE_CLIP_REGION;
-	    }
+	    flags = need_bounded_clip (extents) & ~NEED_CLIP_SURFACE;
 	}
 
 	info.antialias = antialias;
@@ -2299,7 +2303,6 @@ _cairo_traps_compositor_glyphs (const cairo_compositor_t	*_compositor,
 						 &num_glyphs);
     if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
 	cairo_composite_glyphs_info_t info;
-	unsigned flags = 0;
 
 	info.font = scaled_font;
 	info.glyphs = glyphs;
@@ -2307,16 +2310,9 @@ _cairo_traps_compositor_glyphs (const cairo_compositor_t	*_compositor,
 	info.use_mask = overlap || ! extents->is_bounded;
 	info.extents = extents->bounded;
 
-	if (extents->mask.width > extents->bounded.width ||
-	    extents->mask.height > extents->bounded.height)
-	{
-	    flags |= FORCE_CLIP_REGION;
-	}
-
 	status = clip_and_composite (compositor, extents,
 				     composite_glyphs, NULL, &info,
-				     need_bounded_clip (extents) |
-				     flags);
+				     need_bounded_clip (extents) | FORCE_CLIP_REGION);
     }
     _cairo_scaled_font_thaw_cache (scaled_font);
 
--
cgit v0.9.0.2-2-gbebe

Reply via email to