[cairo-commit] src/cairo-traps-compositor.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Sep 14 04:46:36 PDT 2011


 src/cairo-traps-compositor.c |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

New commits:
commit 7cf7ee5e299bf03f1efd100739545f66a4acc24b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Sep 14 12:44:27 2011 +0100

    traps: Skip compositing an empty bounded regions
    
    Fixes the cairo-xlib crash with tighten-bounds. (I thought I had fixed
    it earlier, but I was obviously wrong.)
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c
index 5b22fd7..c84fa5f 100644
--- a/src/cairo-traps-compositor.c
+++ b/src/cairo-traps-compositor.c
@@ -760,7 +760,7 @@ clip_and_composite (const cairo_traps_compositor_t *compositor,
     cairo_surface_t *src;
     int src_x, src_y;
     cairo_region_t *clip_region = NULL;
-    cairo_status_t status;
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
 
     if (reduce_alpha_op (extents)) {
 	op = CAIRO_OPERATOR_ADD;
@@ -772,13 +772,6 @@ clip_and_composite (const cairo_traps_compositor_t *compositor,
 	source = NULL;
     }
 
-    src = compositor->pattern_to_surface (dst, source, FALSE,
-					  &extents->bounded,
-					  &extents->source_sample_area,
-					  &src_x, &src_y);
-    if (unlikely (src->status))
-	return src->status;
-
     compositor->acquire (dst);
 
     if (need_clip & NEED_CLIP_REGION) {
@@ -804,6 +797,16 @@ clip_and_composite (const cairo_traps_compositor_t *compositor,
 	}
     }
 
+    if (extents->bounded.width == 0 || extents->bounded.height == 0)
+	goto skip;
+
+    src = compositor->pattern_to_surface (dst, source, FALSE,
+					  &extents->bounded,
+					  &extents->source_sample_area,
+					  &src_x, &src_y);
+    if (unlikely (status = src->status))
+	goto error;
+
     if (op == CAIRO_OPERATOR_SOURCE) {
 	status = clip_and_composite_source (compositor, dst,
 					    draw_func, mask_func, draw_closure,
@@ -830,7 +833,9 @@ clip_and_composite (const cairo_traps_compositor_t *compositor,
 				extents->clip);
 	}
     }
+    cairo_surface_destroy (src);
 
+skip:
     if (status == CAIRO_STATUS_SUCCESS && ! extents->is_bounded) {
 	if (need_clip & NEED_CLIP_SURFACE)
 	    status = fixup_unbounded_with_mask (compositor, extents);
@@ -838,10 +843,10 @@ clip_and_composite (const cairo_traps_compositor_t *compositor,
 	    status = fixup_unbounded (compositor, extents, NULL);
     }
 
+error:
     if (clip_region)
 	compositor->set_clip_region (dst, NULL);
 
-    cairo_surface_destroy (src);
     compositor->release (dst);
 
     return status;


More information about the cairo-commit mailing list