[cairo-commit] 3 commits - src/cairo-path-bounds.c test/cairo-test.c test/pdiff

Chris Wilson ickle at kemper.freedesktop.org
Thu Dec 20 09:13:33 PST 2007


 src/cairo-path-bounds.c |   18 ++++++++----------
 test/cairo-test.c       |    1 +
 test/pdiff/pdiff.c      |   40 +++++++++++++++++++++++++++-------------
 3 files changed, 36 insertions(+), 23 deletions(-)

New commits:
commit 281b11aef14f04b12639028e2a76bbdc7a1a32bf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Dec 20 17:11:03 2007 +0000

    [cairo-test] Use CAIRO_OPERATOR_SOURCE when painting the group surface.
    
    To correctly copy a surface onto the destination irrespective of its
    content requires the SOURCE operator. Forgetting to do so here causes
    uninitialized pixels to be mixed into the result and the failure of
    many tests for the similar surface. Oops...

diff --git a/test/cairo-test.c b/test/cairo-test.c
index f036163..d262dbb 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -384,6 +384,7 @@ cairo_test_for_target (cairo_test_t			 *test,
 
     if (similar) {
 	cairo_pop_group_to_source (cr);
+	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
 	cairo_paint (cr);
     }
 
commit ed3fccec01257a7c52694150cda9ea1059c33585
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 17 22:37:31 2007 +0000

    [pdiff] Avoid the memleak for small surfaces.
    
    Allocate the arrays after the guard against small surfaces to avoid
    leaking them.

diff --git a/test/pdiff/pdiff.c b/test/pdiff/pdiff.c
index 4f3226d..3f472f3 100644
--- a/test/pdiff/pdiff.c
+++ b/test/pdiff/pdiff.c
@@ -257,19 +257,19 @@ pdiff_compare (cairo_surface_t *surface_a,
     unsigned int i;
 
     /* assuming colorspaces are in Adobe RGB (1998) convert to XYZ */
-    float *aX = xmalloc (dim * sizeof (float));
-    float *aY = xmalloc (dim * sizeof (float));
-    float *aZ = xmalloc (dim * sizeof (float));
-    float *bX = xmalloc (dim * sizeof (float));
-    float *bY = xmalloc (dim * sizeof (float));
-    float *bZ = xmalloc (dim * sizeof (float));
-    float *aLum = xmalloc (dim * sizeof (float));
-    float *bLum = xmalloc (dim * sizeof (float));
-
-    float *aA = xmalloc (dim * sizeof (float));
-    float *bA = xmalloc (dim * sizeof (float));
-    float *aB = xmalloc (dim * sizeof (float));
-    float *bB = xmalloc (dim * sizeof (float));
+    float *aX;
+    float *aY;
+    float *aZ;
+    float *bX;
+    float *bY;
+    float *bZ;
+    float *aLum;
+    float *bLum;
+
+    float *aA;
+    float *bA;
+    float *aB;
+    float *bB;
 
     unsigned int x, y, w, h;
 
@@ -289,6 +289,20 @@ pdiff_compare (cairo_surface_t *surface_a,
     if (w < 3 || h < 3) /* too small for the Laplacian convolution */
 	return -1;
 
+    aX = xmalloc (dim * sizeof (float));
+    aY = xmalloc (dim * sizeof (float));
+    aZ = xmalloc (dim * sizeof (float));
+    bX = xmalloc (dim * sizeof (float));
+    bY = xmalloc (dim * sizeof (float));
+    bZ = xmalloc (dim * sizeof (float));
+    aLum = xmalloc (dim * sizeof (float));
+    bLum = xmalloc (dim * sizeof (float));
+
+    aA = xmalloc (dim * sizeof (float));
+    bA = xmalloc (dim * sizeof (float));
+    aB = xmalloc (dim * sizeof (float));
+    bB = xmalloc (dim * sizeof (float));
+
     for (y = 0; y < h; y++) {
 	for (x = 0; x < w; x++) {
 	    float r, g, b, l;
commit df938a515bd59138421b6ab4419966805d027b52
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Dec 17 21:39:25 2007 +0000

    [cairo-path-bounds] Check for the empty path.
    
    Avoid returning uninitialized variables if we're asked to find the
    bounds of an empty path - in which case we just return a rectangle
    of zero width and height similar to the empty clip region.

diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c
index 5b60cf1..49b4ab9 100644
--- a/src/cairo-path-bounds.c
+++ b/src/cairo-path-bounds.c
@@ -165,18 +165,16 @@ _cairo_path_fixed_bounds (cairo_path_fixed_t *path,
 					  _cairo_path_bounder_curve_to,
 					  _cairo_path_bounder_close_path,
 					  &bounder);
-    if (status) {
-	*x1 = *y1 = *x2 = *y2 = 0.0;
-	_cairo_path_bounder_fini (&bounder);
-	return status;
+    if (status || ! bounder.has_point) {
+	*x1 = *y1 = *x2 = *y2 = 0.;
+    } else {
+	*x1 = _cairo_fixed_to_double (bounder.min_x);
+	*y1 = _cairo_fixed_to_double (bounder.min_y);
+	*x2 = _cairo_fixed_to_double (bounder.max_x);
+	*y2 = _cairo_fixed_to_double (bounder.max_y);
     }
 
-    *x1 = _cairo_fixed_to_double (bounder.min_x);
-    *y1 = _cairo_fixed_to_double (bounder.min_y);
-    *x2 = _cairo_fixed_to_double (bounder.max_x);
-    *y2 = _cairo_fixed_to_double (bounder.max_y);
-
     _cairo_path_bounder_fini (&bounder);
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }


More information about the cairo-commit mailing list