[cairo-commit] 4 commits - perf/Makefile.am test/get-path-extents.c test/solid-pattern-cache-stress.c test/user-font-mask.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Mar 24 00:51:24 PDT 2009


 perf/Makefile.am                  |    2 +
 test/get-path-extents.c           |    9 ++++++++
 test/solid-pattern-cache-stress.c |   41 +++++++++++++++++++++++++++-----------
 test/user-font-mask.c             |    7 +++++-
 4 files changed, 47 insertions(+), 12 deletions(-)

New commits:
commit 578b06a978d51dc3d1d844ee7eea9ddd8329cc8d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Mar 23 10:56:43 2009 +0000

    [perf] Use CAIRO_LDFLAGS
    
    Use CAIRO_LDFLAGS in order to pull in additional link options, such as
    --coverage.

diff --git a/perf/Makefile.am b/perf/Makefile.am
index f4feed0..08f9cc0 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -7,6 +7,8 @@ AM_CPPFLAGS =					\
 	-I$(top_builddir)/src			\
 	$(CAIRO_CFLAGS)
 
+AM_LDFLAGS = $(CAIRO_LDFLAGS)
+
 EXTRA_PROGRAMS += cairo-perf \
 		  cairo-perf-diff-files \
 		  cairo-perf-compare-backends \
commit ac30ced6135c5cf0fb34a67fe8f863030c1fbeb9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Mar 22 19:02:27 2009 +0000

    [test] Check for surface create failure.
    
    If the image surface creation fails, the data pointer will be NULL leading
    to a segfault -- so check!

diff --git a/test/user-font-mask.c b/test/user-font-mask.c
index 149f8ee..6fd40c8 100644
--- a/test/user-font-mask.c
+++ b/test/user-font-mask.c
@@ -117,6 +117,9 @@ test_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
     metrics->x_advance = (glyphs[glyph].width + 1) / 8.0;
 
     image = cairo_image_surface_create (CAIRO_FORMAT_A1, glyphs[glyph].width, 8);
+    if (cairo_surface_status (image))
+	return cairo_surface_status (image);
+
     data = cairo_image_surface_get_data (image);
     for (i = 0; i < 8; i++) {
 	byte = glyphs[glyph].data[i];
@@ -125,15 +128,17 @@ test_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
     }
 
     pattern = cairo_pattern_create_for_surface (image);
+    cairo_surface_destroy (image);
+
     cairo_matrix_init_identity (&matrix);
     cairo_matrix_scale (&matrix, 1.0/8.0, 1.0/8.0);
     cairo_matrix_translate (&matrix, 0, -8);
     cairo_matrix_invert (&matrix);
     cairo_pattern_set_matrix (pattern, &matrix);
+
     cairo_set_source (cr, pattern);
     cairo_mask (cr, pattern);
     cairo_pattern_destroy (pattern);
-    cairo_surface_destroy (image);
 
     return CAIRO_STATUS_SUCCESS;
 }
commit b5a4a2c4b1b1bab25e2ff0842e3c27205ec73d51
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Mar 22 19:00:04 2009 +0000

    [test] Early test for memfault.
    
    Check the error status within after each iteration in
    solid-pattern-cache-stress.

diff --git a/test/solid-pattern-cache-stress.c b/test/solid-pattern-cache-stress.c
index ec183fd..285275e 100644
--- a/test/solid-pattern-cache-stress.c
+++ b/test/solid-pattern-cache-stress.c
@@ -108,6 +108,9 @@ use_similar (cairo_t *cr,
 {
     cairo_t *cr2;
 
+    if (cairo_status (cr))
+	return;
+
     cr2 = _cairo_create_similar (cr, 1, 1);
 
     _draw (cr2, red, green, blue);
@@ -125,6 +128,9 @@ use_image (cairo_t *cr,
 {
     cairo_t *cr2;
 
+    if (cairo_status (cr))
+	return;
+
     cr2 = _cairo_create_image (cr, format, 1, 1);
 
     _draw (cr2, red, green, blue);
@@ -153,23 +159,36 @@ use_solid (cairo_t *cr,
 static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
-    int loop;
-    int i;
+    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
+    cairo_status_t status;
+    const double colors[8][3] = {
+	{ 1.0, 0.0, 0.0 }, /* red */
+	{ 0.0, 1.0, 0.0 }, /* green */
+	{ 1.0, 1.0, 0.0 }, /* yellow */
+	{ 0.0, 0.0, 1.0 }, /* blue */
+	{ 1.0, 0.0, 1.0 }, /* magenta */
+	{ 0.0, 1.0, 1.0 }, /* cyan */
+	{ 1.0, 1.0, 1.0 }, /* white */
+	{ 0.0, 0.0, 0.0 }, /* black */
+    };
+    int i, j, loop;
 
     for (loop = 0; loop < LOOPS; loop++) {
 	for (i = 0; i < LOOPS; i++) {
-	    use_solid (cr, 0.0, 0.0, 0.0); /* black */
-	    use_solid (cr, 1.0, 0.0, 0.0); /* red */
-	    use_solid (cr, 0.0, 1.0, 0.0); /* green */
-	    use_solid (cr, 1.0, 1.0, 0.0); /* yellow */
-	    use_solid (cr, 0.0, 0.0, 1.0); /* blue */
-	    use_solid (cr, 1.0, 0.0, 1.0); /* magenta */
-	    use_solid (cr, 0.0, 1.0, 1.0); /* cyan */
-	    use_solid (cr, 1.0, 1.0, 1.0); /* white */
+	    for (j = 0; j < 8; j++) {
+		use_solid (cr, colors[j][0], colors[j][1], colors[j][2]);
+		status = cairo_status (cr);
+		if (status)
+		    return cairo_test_status_from_status (ctx, status);
+	    }
 	}
 
-	for (i = 0; i < NRAND; i++)
+	for (i = 0; i < NRAND; i++) {
 	    use_solid (cr, drand48 (), drand48 (), drand48 ());
+	    status = cairo_status (cr);
+	    if (status)
+		return cairo_test_status_from_status (ctx, status);
+	}
     }
 
     /* stress test only, so clear the surface before comparing */
commit 1a7b94f934f8c9a25e60d9466651b0b7fb919656
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Mar 20 11:06:29 2009 +0000

    [test] Check for errors during get-path-extents.
    
    Need to check that an error was not raised on the context before checking
    whether the extents match expectations.

diff --git a/test/get-path-extents.c b/test/get-path-extents.c
index ce1bc7c..96fdfcc 100644
--- a/test/get-path-extents.c
+++ b/test/get-path-extents.c
@@ -57,6 +57,10 @@ check_extents (const cairo_test_context_t *ctx,
         break;
     }
 
+    /* ignore results after an error occurs */
+    if (cairo_status (cr))
+	return 1;
+
     /* let empty rects match */
     if ((ext_x1 == ext_x2 || ext_y1 == ext_y2) && (width == 0 || height == 0))
         return 1;
@@ -106,6 +110,7 @@ draw (cairo_t *cr, int width, int height)
     const char      *phase;
     const char	     string[] = "The quick brown fox jumps over the lazy dog.";
     cairo_text_extents_t extents, scaled_font_extents;
+    cairo_status_t   status;
     int              errors = 0;
 
     surface = cairo_surface_create_similar (cairo_get_group_target (cr),
@@ -365,8 +370,12 @@ draw (cairo_t *cr, int width, int height)
     cairo_new_path (cr2);
     cairo_restore (cr2);
 
+    status = cairo_status (cr2);
     cairo_destroy (cr2);
 
+    if (status)
+	return cairo_test_status_from_status (ctx, status);
+
     return errors == 0 ? CAIRO_TEST_SUCCESS : CAIRO_TEST_FAILURE;
 }
 


More information about the cairo-commit mailing list