[cairo-commit] 4 commits - src/cairo-clip.c src/cairo-image-surface.c test/bitmap-font.c test/mask-glyphs.c

Chris Wilson ickle at kemper.freedesktop.org
Wed May 5 02:23:17 PDT 2010


 src/cairo-clip.c          |    6 ++++++
 src/cairo-image-surface.c |    9 ++++++++-
 test/bitmap-font.c        |    8 ++------
 test/mask-glyphs.c        |   32 +++++++++++++++++++++++---------
 4 files changed, 39 insertions(+), 16 deletions(-)

New commits:
commit 840dad765febf7b807bbb75e401c159a8c5c4dfe
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 5 09:46:03 2010 +0100

    test/mask-glyphs: Check for memfault

diff --git a/test/mask-glyphs.c b/test/mask-glyphs.c
index 213722d..1a76c4e 100644
--- a/test/mask-glyphs.c
+++ b/test/mask-glyphs.c
@@ -32,13 +32,14 @@ static const char *png_filename = "romedalen.png";
 #define WIDTH 800
 #define HEIGHT 600
 
-static int
+static cairo_status_t
 _image_to_glyphs (cairo_surface_t *image,
 		  int channel,
 		  int level,
 		  cairo_scaled_font_t *scaled_font,
+		  double tx, double ty,
 		  cairo_glyph_t *glyphs,
-		  double tx, double ty)
+		  int *num_glyphs)
 {
     int width, height, stride;
     const unsigned char *data;
@@ -62,6 +63,7 @@ _image_to_glyphs (cairo_surface_t *image,
 		char c = n % 26 + 'a';
 		int count = 1;
 		cairo_glyph_t *glyphs_p = &glyphs[n];
+		cairo_status_t status;
 
 		xx = 4 * (x - width/2.) + width/2.;
 		yy = 4 * (y - height/2.) + height/2.;
@@ -76,6 +78,10 @@ _image_to_glyphs (cairo_surface_t *image,
 						  &glyphs_p, &count,
 						  NULL, NULL,
 						  NULL);
+		status = cairo_scaled_font_status (scaled_font);
+		if (status)
+		    return status;
+
 		assert (glyphs_p == &glyphs[n]);
 		assert (count == 1);
 		n++;
@@ -83,7 +89,8 @@ _image_to_glyphs (cairo_surface_t *image,
 	}
     }
 
-    return n;
+    *num_glyphs = n;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -112,10 +119,8 @@ _render_image (cairo_t *cr,
     hh = cairo_image_surface_get_height (image);
 
     glyphs = cairo_glyph_allocate (ww * hh);
-    if (glyphs == NULL) {
-	cairo_surface_destroy (image);
+    if (glyphs == NULL)
 	return CAIRO_STATUS_NO_MEMORY;
-    }
 
     tx = (width - ww) / 2.;
     ty = (height - hh) / 2.;
@@ -126,11 +131,16 @@ _render_image (cairo_t *cr,
     for (i = 0; i < sizeof (channel) / sizeof (channel[0]); i++) {
 	cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA);
 	for (n = 0; n < 256; n++) {
+	    cairo_status_t status;
 	    int num_glyphs;
 
-	    num_glyphs = _image_to_glyphs (image, channel[i].shift, n,
-					   scaled_font,
-					   glyphs, tx, ty);
+	    status = _image_to_glyphs (image, channel[i].shift, n,
+				       scaled_font,
+				       tx, ty, glyphs, &num_glyphs);
+	    if (status) {
+		cairo_glyph_free (glyphs);
+		return status;
+	    }
 
 	    cairo_set_source_rgba (cr,
 				   0, 0, 0,
@@ -161,6 +171,10 @@ draw (cairo_t *cr, int width, int height)
     cairo_paint (cr);
 
     image = cairo_test_create_surface_from_png (ctx, png_filename);
+    status = cairo_surface_status (image);
+    if (status)
+	return cairo_test_status_from_status (ctx, status);
+
     status = _render_image (cr, width, height, image);
     cairo_surface_destroy (image);
 
commit ad541a1ec62e18bcaf74994affbdb0503e277f9c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 5 09:33:36 2010 +0100

    clip: Propagate memfault from translating clip region

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 7c3a1d5..0b51125 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -443,6 +443,12 @@ _cairo_clip_path_reapply_clip_path_translate (cairo_clip_t      *clip,
     clip_path->flags = other_path->flags;
     if (other_path->region != NULL) {
 	clip_path->region = cairo_region_copy (other_path->region);
+	if (unlikely (status = clip_path->region->status)) {
+	    clip->path = clip->path->prev;
+	    _cairo_clip_path_destroy (clip_path);
+	    return status;
+	}
+
 	cairo_region_translate (clip_path->region, tx, ty);
     }
     clip_path->surface = cairo_surface_reference (other_path->surface);
commit 4bc54643f5cdeddf2145d28c317b55ca6b5949a5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 4 21:36:03 2010 +0100

    image: Propagate failure from pixman_image_set_clip_region()

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 8f1e87b..04a907c 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1886,9 +1886,16 @@ _create_composite_mask_pattern (cairo_clip_t                  *clip,
 
     /* Is it worth setting the clip region here? */
     if (clip_region != NULL) {
+	pixman_bool_t ret;
+
 	pixman_region32_translate (&clip_region->rgn, -extents->x, -extents->y);
-	pixman_image_set_clip_region32 (mask, &clip_region->rgn);
+	ret = pixman_image_set_clip_region32 (mask, &clip_region->rgn);
 	pixman_region32_translate (&clip_region->rgn, extents->x, extents->y);
+
+	if (! ret) {
+	    pixman_image_unref (mask);
+	    return NULL;
+	}
     }
 
     status = draw_func (draw_closure,
commit 9ef33a1d8c0476f4f1eeba4f26523fdeb6f7d809
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 4 21:35:51 2010 +0100

    test/bitmap-font: Destroy FcPattern

diff --git a/test/bitmap-font.c b/test/bitmap-font.c
index 1c13779..62e51ea 100644
--- a/test/bitmap-font.c
+++ b/test/bitmap-font.c
@@ -101,13 +101,13 @@ draw (cairo_t *cr, int width, int height)
     }
 
     font_face = cairo_ft_font_face_create_for_pattern (pattern);
+    FcPatternDestroy (pattern);
 
     status = cairo_font_face_status (font_face);
     if (status) {
 	cairo_test_log (ctx, "Error creating font face for %s: %s\n",
 			filename,
 			cairo_status_to_string (status));
-	FcPatternDestroy (pattern);
 	return cairo_test_status_from_status (ctx, status);
     }
 
@@ -115,11 +115,11 @@ draw (cairo_t *cr, int width, int height)
 	cairo_test_log (ctx, "Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
 			cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_FT);
 	cairo_font_face_destroy (font_face);
-	FcPatternDestroy (pattern);
 	return CAIRO_TEST_FAILURE;
     }
 
     cairo_set_font_face (cr, font_face);
+    cairo_font_face_destroy (font_face);
 
     font_options = cairo_font_options_create ();
 
@@ -135,9 +135,6 @@ draw (cairo_t *cr, int width, int height)
     cairo_font_extents (cr, &font_extents);
     CHECK_FONT_EXTENTS ("default");
 
-    FcPatternDestroy (pattern);
-    cairo_font_face_destroy (font_face);
-
     cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_ON);
     cairo_set_font_options (cr, font_options);
 
@@ -146,7 +143,6 @@ draw (cairo_t *cr, int width, int height)
     cairo_move_to (cr, 1, font_extents.ascent - 1);
     cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); /* blue */
 
-
     cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
     cairo_set_font_options (cr, font_options);
     CHECK_FONT_EXTENTS ("HINT_METRICS_ON HINT_STYLE_NONE");


More information about the cairo-commit mailing list