[cairo-commit] 12 commits - boilerplate/cairo-boilerplate-test-surfaces.c configure.in src/cairo-cff-subset.c src/cairo-clip.c src/cairo-glitz-surface.c src/cairo-hull.c src/cairo-image-surface.c src/cairo-pdf-surface.c src/cairo-traps.c src/cairo-win32-font.c src/cairo-win32-printing-surface.c src/cairo-win32-surface.c src/cairo-xlib-surface.c src/test-meta-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Oct 10 06:49:02 PDT 2007


 boilerplate/cairo-boilerplate-test-surfaces.c |    3 
 configure.in                                  |    1 
 src/cairo-cff-subset.c                        |   16 ++--
 src/cairo-clip.c                              |   49 ++++++++------
 src/cairo-glitz-surface.c                     |   28 +++++---
 src/cairo-hull.c                              |   10 --
 src/cairo-image-surface.c                     |    3 
 src/cairo-pdf-surface.c                       |    8 +-
 src/cairo-traps.c                             |   11 ---
 src/cairo-win32-font.c                        |   89 ++++++++++++++------------
 src/cairo-win32-printing-surface.c            |   26 ++++---
 src/cairo-win32-surface.c                     |   24 ++-----
 src/cairo-xlib-surface.c                      |    8 +-
 src/test-meta-surface.c                       |    8 +-
 14 files changed, 163 insertions(+), 121 deletions(-)

New commits:
diff-tree 7e6ac74de17cf82f224d9f5fad3ad60e92d7690b (from bee05467a5f398eaaaa8d79b3ff0a8b119856143)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 10 14:00:56 2007 +0100

    [win32] Clean up compiler warnings.
    
    Fix up a few instances of unused status returns.

diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 9e6c340..32e47df 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -233,23 +233,22 @@ _get_system_quality (void)
  * all be 0, and face_hfont is the result of calling CreateFontIndirectW on
  * logfont.
  */
-static cairo_scaled_font_t *
+static cairo_status_t
 _win32_scaled_font_create (LOGFONTW                   *logfont,
 			   HFONT                      face_hfont,
 			   cairo_font_face_t	      *font_face,
 			   const cairo_matrix_t       *font_matrix,
 			   const cairo_matrix_t       *ctm,
-			   const cairo_font_options_t *options)
+			   const cairo_font_options_t *options,
+			   cairo_scaled_font_t       **font_out)
 {
     cairo_win32_scaled_font_t *f;
     cairo_matrix_t scale;
     cairo_status_t status;
 
     f = malloc (sizeof(cairo_win32_scaled_font_t));
-    if (f == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return NULL;
-    }
+    if (f == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     f->logfont = *logfont;
 
@@ -309,17 +308,17 @@ _win32_scaled_font_create (LOGFONTW     
 	goto FAIL;
 
     status = _cairo_win32_scaled_font_set_metrics (f);
-
     if (status) {
 	_cairo_scaled_font_fini (&f->base);
 	goto FAIL;
     }
 
-    return &f->base;
+    *font_out = &f->base;
+    return CAIRO_STATUS_SUCCESS;
 
  FAIL:
     free (f);
-    return NULL;
+    return status;
 }
 
 static cairo_status_t
@@ -415,7 +414,7 @@ _win32_scaled_font_get_unscaled_hfont (c
 
 	otm = malloc (otm_size);
 	if (!otm) {
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    return NULL;
 	}
 
@@ -487,7 +486,6 @@ _cairo_win32_scaled_font_create_toy (cai
 				     cairo_scaled_font_t        **scaled_font_out)
 {
     LOGFONTW logfont;
-    cairo_scaled_font_t *scaled_font;
     uint16_t *face_name;
     int face_name_len;
     cairo_status_t status;
@@ -546,14 +544,9 @@ _cairo_win32_scaled_font_create_toy (cai
     if (!logfont.lfFaceName)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    scaled_font = _win32_scaled_font_create (&logfont, NULL, &toy_face->base,
-					     font_matrix, ctm, options);
-    if (!scaled_font)
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
-    *scaled_font_out = scaled_font;
-
-    return CAIRO_STATUS_SUCCESS;
+    return _win32_scaled_font_create (&logfont, NULL, &toy_face->base,
+			              font_matrix, ctm, options,
+				      scaled_font_out);
 }
 
 static void
@@ -695,7 +688,6 @@ _cairo_win32_scaled_font_text_to_glyphs 
  FAIL1:
     free (utf16);
 
-    _cairo_error (status);
     return status;
 }
 
@@ -1021,6 +1013,7 @@ _add_glyph (cairo_glyph_state_t *state,
 static void
 _finish_glyphs (cairo_glyph_state_t *state)
 {
+    /* ignore errors as we only call _finish_glyphs on the error path */
     _flush_glyphs (state);
 
     _cairo_array_fini (&state->glyphs);
@@ -1223,9 +1216,14 @@ _cairo_win32_scaled_font_show_glyphs (vo
 	r.bottom = height;
 	FillRect (tmp_surface->dc, &r, GetStockObject (WHITE_BRUSH));
 
-	_draw_glyphs_on_surface (tmp_surface, scaled_font, RGB (0, 0, 0),
-				 dest_x, dest_y,
-				 glyphs, num_glyphs);
+	status = _draw_glyphs_on_surface (tmp_surface,
+		                          scaled_font, RGB (0, 0, 0),
+					  dest_x, dest_y,
+					  glyphs, num_glyphs);
+	if (status) {
+	    cairo_surface_destroy (&tmp_surface->base);
+	    return status;
+	}
 
 	if (scaled_font->quality == CLEARTYPE_QUALITY) {
 	    /* For ClearType, we need a 4-channel mask. If we are compositing on
@@ -1387,8 +1385,7 @@ _cairo_win32_scaled_font_init_glyph_path
 			  GGO_NATIVE | glyph_index_option,
 			  &metrics, bytesGlyph, buffer, &matrix) == GDI_ERROR) {
 	status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_glyph_path");
-	free (buffer);
-	goto CLEANUP_FONT;
+	goto CLEANUP_BUFFER;
     }
 
     while (ptr < buffer + bytesGlyph) {
@@ -1401,7 +1398,9 @@ _cairo_win32_scaled_font_init_glyph_path
                                                header->pfxStart.x,
                                                header->pfxStart.y,
                                                &x, &y);
-        _cairo_path_fixed_move_to (path, x, y);
+        status = _cairo_path_fixed_move_to (path, x, y);
+	if (status)
+	    goto CLEANUP_BUFFER;
 
 	while (ptr < endPoly) {
 	    TTPOLYCURVE *curve = (TTPOLYCURVE *)ptr;
@@ -1414,13 +1413,17 @@ _cairo_win32_scaled_font_init_glyph_path
                                                            points[i].x,
                                                            points[i].y,
                                                            &x, &y);
-		    _cairo_path_fixed_line_to (path, x, y);
+		    status = _cairo_path_fixed_line_to (path, x, y);
+		    if (status)
+			goto CLEANUP_BUFFER;
 		}
 		break;
 	    case TT_PRIM_QSPLINE:
 		for (i = 0; i < curve->cpfx - 1; i++) {
 		    cairo_fixed_t p1x, p1y, p2x, p2y, cx, cy, c1x, c1y, c2x, c2y;
-		    _cairo_path_fixed_get_current_point (path, &p1x, &p1y);
+		    status = _cairo_path_fixed_get_current_point (path, &p1x, &p1y);
+		    if (status)
+			goto CLEANUP_BUFFER;
                     _cairo_win32_transform_FIXED_to_fixed (&transform,
                                                            points[i].x,
                                                            points[i].y,
@@ -1447,7 +1450,9 @@ _cairo_win32_scaled_font_init_glyph_path
 		    c2x = 2 * cx / 3 + p2x / 3;
 		    c2y = 2 * cy / 3 + p2y / 3;
 
-		    _cairo_path_fixed_curve_to (path, c1x, c1y, c2x, c2y, p2x, p2y);
+		    status = _cairo_path_fixed_curve_to (path, c1x, c1y, c2x, c2y, p2x, p2y);
+		    if (status)
+			goto CLEANUP_BUFFER;
 		}
 		break;
 	    case TT_PRIM_CSPLINE:
@@ -1465,13 +1470,17 @@ _cairo_win32_scaled_font_init_glyph_path
                                                            points[i + 2].x,
                                                            points[i + 2].y,
                                                            &x2, &y2);
-		    _cairo_path_fixed_curve_to (path, x, y, x1, y1, x2, y2);
+		    status = _cairo_path_fixed_curve_to (path, x, y, x1, y1, x2, y2);
+		    if (status)
+			goto CLEANUP_BUFFER;
 		}
 		break;
 	    }
 	    ptr += sizeof(TTPOLYCURVE) + sizeof (POINTFX) * (curve->cpfx - 1);
 	}
-	_cairo_path_fixed_close_path (path);
+	status = _cairo_path_fixed_close_path (path);
+	if (status)
+	    goto CLEANUP_BUFFER;
     }
     free(buffer);
 
@@ -1479,6 +1488,9 @@ _cairo_win32_scaled_font_init_glyph_path
 				  &scaled_font->base,
 				  path);
 
+ CLEANUP_BUFFER:
+    free (buffer);
+
  CLEANUP_FONT:
     cairo_win32_scaled_font_done_font (&scaled_font->base);
 
@@ -1550,14 +1562,11 @@ _cairo_win32_font_face_scaled_font_creat
         }
     }
 
-    *font = _win32_scaled_font_create (&font_face->logfont,
-				       hfont,
-				       &font_face->base,
-				       font_matrix, ctm, options);
-    if (*font)
-	return CAIRO_STATUS_SUCCESS;
-    else
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    return _win32_scaled_font_create (&font_face->logfont,
+				      hfont,
+				      &font_face->base,
+				      font_matrix, ctm, options,
+				      font);
 }
 
 static const cairo_font_face_backend_t _cairo_win32_font_face_backend = {
@@ -1592,7 +1601,7 @@ cairo_win32_font_face_create_for_logfont
 
     font_face = malloc (sizeof (cairo_win32_font_face_t));
     if (!font_face) {
-        _cairo_error (CAIRO_STATUS_NO_MEMORY);
+        _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return (cairo_font_face_t *)&_cairo_font_face_nil;
     }
 
diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index fd8efc1..8e044a4 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -338,7 +338,9 @@ _cairo_win32_printing_surface_paint_surf
     bi.bmiHeader.biClrImportant = 0;
 
     m = pattern->base.matrix;
-    cairo_matrix_invert (&m);
+    status = cairo_matrix_invert (&m);
+    /* _cairo_pattern_set_matrix guarantees invertibility */
+    assert (status == CAIRO_STATUS_SUCCESS);
 
     SaveDC (surface->dc);
     SetGraphicsMode (surface->dc, GM_ADVANCED);
@@ -417,12 +419,15 @@ _cairo_win32_printing_surface_paint_line
     cairo_extend_t extend;
     int range_start, range_stop, num_ranges, num_rects, stop;
     int total_verts, total_rects;
+    cairo_status_t status;
 
     extend = cairo_pattern_get_extend (&pattern->base.base);
     SaveDC (surface->dc);
 
     mat = pattern->base.base.matrix;
-    cairo_matrix_invert (&mat);
+    status = cairo_matrix_invert (&mat);
+    /* _cairo_pattern_set_matrix guarantees invertibility */
+    assert (status == CAIRO_STATUS_SUCCESS);
 
     p1x = _cairo_fixed_to_double (pattern->p1.x);
     p1y = _cairo_fixed_to_double (pattern->p1.y);
@@ -899,7 +904,7 @@ _cairo_win32_printing_surface_stroke (vo
 	/* Return to device space to paint the pattern */
 	if (!ModifyWorldTransform (surface->dc, &xform, MWT_IDENTITY))
 	    return _cairo_win32_print_gdi_error ("_win32_surface_stroke:ModifyWorldTransform");
-	_cairo_win32_printing_surface_paint_pattern (surface, source);
+	status = _cairo_win32_printing_surface_paint_pattern (surface, source);
     }
     RestoreDC (surface->dc, -1);
     DeleteObject (pen);
@@ -949,13 +954,16 @@ _cairo_win32_printing_surface_fill (void
     }
 
     if (source->type == CAIRO_PATTERN_TYPE_SOLID) {
-	_cairo_win32_printing_surface_select_solid_brush (surface, source);
+	status = _cairo_win32_printing_surface_select_solid_brush (surface, source);
+	if (status)
+	    return status;
+
 	FillPath (surface->dc);
 	_cairo_win32_printing_surface_done_solid_brush (surface);
     } else {
 	SaveDC (surface->dc);
 	SelectClipPath (surface->dc, RGN_AND);
-	_cairo_win32_printing_surface_paint_pattern (surface, source);
+	status = _cairo_win32_printing_surface_paint_pattern (surface, source);
 	RestoreDC (surface->dc, -1);
     }
 
@@ -1049,9 +1057,9 @@ _cairo_win32_printing_surface_show_glyph
 	status = _cairo_win32_printing_surface_emit_path (surface, scaled_glyph->path);
     }
     EndPath (surface->dc);
-    if (status == 0) {
+    if (status == CAIRO_STATUS_SUCCESS) {
 	SelectClipPath (surface->dc, RGN_AND);
-	_cairo_win32_printing_surface_paint_pattern (surface, source);
+	status = _cairo_win32_printing_surface_paint_pattern (surface, source);
     }
     RestoreDC (surface->dc, -1);
 
@@ -1108,13 +1116,13 @@ cairo_win32_printing_surface_create (HDC
     if (GetClipBox (hdc, &rect) == ERROR) {
 	_cairo_win32_print_gdi_error ("cairo_win32_surface_create");
 	/* XXX: Can we make a more reasonable guess at the error cause here? */
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NIL_SURFACE;
     }
 
     surface = malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NIL_SURFACE;
     }
 
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 21336de..dd99b8f 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -151,7 +151,7 @@ _create_dc_and_bitmap (cairo_win32_surfa
 		       cairo_format_t         format,
 		       int                    width,
 		       int                    height,
-		       char                 **bits_out,
+		       unsigned char        **bits_out,
 		       int                   *rowstride_out)
 {
     cairo_status_t status;
@@ -329,12 +329,12 @@ _cairo_win32_surface_create_for_dc (HDC 
 {
     cairo_status_t status;
     cairo_win32_surface_t *surface;
-    char *bits;
+    unsigned char *bits;
     int rowstride;
 
     surface = malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NIL_SURFACE;
     }
 
@@ -376,13 +376,7 @@ _cairo_win32_surface_create_for_dc (HDC 
     if (surface)
 	free (surface);
 
-    if (status == CAIRO_STATUS_NO_MEMORY) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return NIL_SURFACE;
-    } else {
-	_cairo_error (status);
-	return NIL_SURFACE;
-    }
+    return NIL_SURFACE;
 }
 
 static cairo_surface_t *
@@ -1440,7 +1434,9 @@ _cairo_win32_surface_set_clip_region (vo
 	unsigned int serial;
 
 	serial = _cairo_surface_allocate_clip_serial (surface->image);
-	_cairo_surface_set_clip_region (surface->image, region, serial);
+	status = _cairo_surface_set_clip_region (surface->image, region, serial);
+	if (status)
+	    return status;
     }
 
     /* The semantics we want is that any clip set by cairo combines
@@ -1724,7 +1720,7 @@ cairo_win32_surface_create (HDC hdc)
     if (clipBoxType == ERROR) {
 	_cairo_win32_print_gdi_error ("cairo_win32_surface_create");
 	/* XXX: Can we make a more reasonable guess at the error cause here? */
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NIL_SURFACE;
     }
 
@@ -1742,7 +1738,7 @@ cairo_win32_surface_create (HDC hdc)
 	    format = CAIRO_FORMAT_A1;
 	else {
 	    _cairo_win32_print_gdi_error("cairo_win32_surface_create(bad BITSPIXEL)");
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    return NIL_SURFACE;
 	}
     } else {
@@ -1751,7 +1747,7 @@ cairo_win32_surface_create (HDC hdc)
 
     surface = malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NIL_SURFACE;
     }
 
diff-tree bee05467a5f398eaaaa8d79b3ff0a8b119856143 (from 785cb5b7e11a2786b60a995c43e9ee411ec5ec2d)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 10 12:32:16 2007 +0100

    [configure.in] Initialise test_svg.
    
    Set test_svg to no prior for checking for SVG availability so that the
    printed summary is correct if the user explicitly disables the SVG
    surface on the configure command line.

diff --git a/configure.in b/configure.in
index 004d921..7c76397 100644
--- a/configure.in
+++ b/configure.in
@@ -613,6 +613,7 @@ CAIRO_BACKEND_ENABLE(svg, SVG, svg, SVG_
 ])
 
 LIBRSVG_VERSION_REQUIRED=2.15.0
+test_svg=no
 if test "x$use_svg" = "xyes"; then
   librsvg_DEPENDENCY="librsvg-2.0 >= $LIBRSVG_VERSION_REQUIRED"
   PKG_CHECK_MODULES(LIBRSVG, $librsvg_DEPENDENCY gdk-2.0,
diff-tree 785cb5b7e11a2786b60a995c43e9ee411ec5ec2d (from 2268c5907ce80fe40d54ccfac8435ee5e22d36de)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 16:58:46 2007 +0100

    [cairo-image-surface] Dead code elimination.
    
    Remove an unreachable return and unused variable - tidy up after
    a bad merge.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 5b1ad76..ec3477b 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -471,7 +471,6 @@ cairo_image_surface_create (cairo_format
 			    int			width,
 			    int			height)
 {
-    cairo_surface_t	*surface;
     pixman_format_code_t pixman_format;
 
     if (! CAIRO_FORMAT_VALID (format)) {
@@ -483,8 +482,6 @@ cairo_image_surface_create (cairo_format
 
     return _cairo_image_surface_create_with_pixman_format (NULL, pixman_format,
 							   width, height, -1);
-
-    return surface;
 }
 slim_hidden_def (cairo_image_surface_create);
 
diff-tree 2268c5907ce80fe40d54ccfac8435ee5e22d36de (from 4958789b9e8bf531259b3d1ea27887a8319f7696)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 13:23:34 2007 +0100

    [cairo-glitz-surface] Propagate errors from set_image().
    
    Propagate errors from _cairo_glitz_surface_set_image().

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 83a5109..eb68b43 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -493,10 +493,13 @@ _cairo_glitz_surface_release_dest_image 
 					 void                    *image_extra)
 {
     cairo_glitz_surface_t *surface = abstract_surface;
+    cairo_status_t status;
 
-    _cairo_glitz_surface_set_image (surface, image, 0, 0,
-				    image->width, image->height,
-				    image_rect->x, image_rect->y);
+    status = _cairo_glitz_surface_set_image (surface, image, 0, 0,
+				             image->width, image->height,
+				             image_rect->x, image_rect->y);
+    if (status)
+	status = _cairo_surface_set_error (&surface->base, status);
 
     cairo_surface_destroy (&image->base);
 }
@@ -512,6 +515,7 @@ _cairo_glitz_surface_clone_similar (void
 {
     cairo_glitz_surface_t *surface = abstract_surface;
     cairo_glitz_surface_t *clone;
+    cairo_status_t status;
 
     if (surface->base.status)
 	return surface->base.status;
@@ -549,10 +553,14 @@ _cairo_glitz_surface_clone_similar (void
 
 	_cairo_rectangle_intersect(&extent, &image_extent);
 
-	_cairo_glitz_surface_set_image (clone, image_src,
-					extent.x, extent.y,
-					extent.width, extent.height,
-					extent.x, extent.y);
+	status = _cairo_glitz_surface_set_image (clone, image_src,
+					         extent.x, extent.y,
+						 extent.width, extent.height,
+						 extent.x, extent.y);
+	if (status) {
+	    cairo_surface_destroy (&clone->base);
+	    return status;
+	}
 
 	*clone_out = &clone->base;
 
@@ -1387,9 +1395,13 @@ _cairo_glitz_surface_composite_trapezoid
 	    return mask->base.status;
 	}
 
-	_cairo_glitz_surface_set_image (mask, image, 0, 0, width, height, 0, 0);
+	status = _cairo_glitz_surface_set_image (mask, image,
+		                                 0, 0, width, height, 0, 0);
 
 	cairo_surface_destroy(&image->base);
+
+	if (status)
+	    return status;
     }
 
     _cairo_glitz_surface_set_attributes (src, &attributes);
diff-tree 4958789b9e8bf531259b3d1ea27887a8319f7696 (from 9c65efeeb108c39e6f55c9247e7d11bfea35cb66)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 12:49:08 2007 +0100

    [cairo-xlib-surface] Propagate error from _draw_image_surface() to surface.
    
    Instead of simply ignoring the error that may occur when we upload the
    destination image to the xlib surface (via XPutImage) record the error
    on the xlib surface.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index f911de1..f44ed4b 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -810,10 +810,12 @@ _cairo_xlib_surface_release_dest_image (
 					void                    *image_extra)
 {
     cairo_xlib_surface_t *surface = abstract_surface;
+    cairo_status_t status;
 
-    /* ignore errors */
-    _draw_image_surface (surface, image, 0, 0, image->width, image->height,
-			 image_rect->x, image_rect->y);
+    status = _draw_image_surface (surface, image,
+	                          0, 0, image->width, image->height,
+				  image_rect->x, image_rect->y);
+    status = _cairo_surface_set_error (&surface->base, status);
 
     cairo_surface_destroy (&image->base);
 }
diff-tree 9c65efeeb108c39e6f55c9247e7d11bfea35cb66 (from caf04b1bb89c1a7668e36d5f334765a2323bd564)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 11:51:48 2007 +0100

    [boilerplate-test-surfaces] Check show page for errors.
    
    Check that cairo_surface_show_page() did not generate any errors before
    reading back the image buffer and saving it as a png.

diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
index 667ed5b..e112dca 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -122,6 +122,9 @@ _cairo_boilerplate_test_paginated_surfac
 
     /* show page first.  the automatic show_page is too late for us */
     cairo_surface_show_page (surface);
+    status = cairo_surface_status (surface);
+    if (status)
+	return status;
 
     tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
 
diff-tree caf04b1bb89c1a7668e36d5f334765a2323bd564 (from ef275cd65a9f20a8a3b1fb3883aff0cc8a3bf401)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 11:22:46 2007 +0100

    [cairo-cff-subset] Propagate error status from failed append_copy().
    
    Add a couple of missing status checks for the result of
    cff_index_append_copy().

diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index d1826df..344baf4 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -1001,14 +1001,18 @@ cairo_cff_font_set_ros_strings (cairo_cf
     const char *ordering = "Identity";
 
     sid1 = NUM_STD_STRINGS + _cairo_array_num_elements (&font->strings_subset_index);
-    cff_index_append_copy (&font->strings_subset_index,
-                           (unsigned char *)registry,
-                           strlen(registry));
+    status = cff_index_append_copy (&font->strings_subset_index,
+                                    (unsigned char *)registry,
+                                    strlen(registry));
+    if (status)
+	return status;
 
     sid2 = NUM_STD_STRINGS + _cairo_array_num_elements (&font->strings_subset_index);
-    cff_index_append_copy (&font->strings_subset_index,
-                           (unsigned char *)ordering,
-                           strlen(ordering));
+    status = cff_index_append_copy (&font->strings_subset_index,
+                                    (unsigned char *)ordering,
+				    strlen(ordering));
+    if (status)
+	return status;
 
     p = encode_integer (buf, sid1);
     p = encode_integer (p, sid2);
diff-tree ef275cd65a9f20a8a3b1fb3883aff0cc8a3bf401 (from 7758e56d0c96fd113a12b2adc92c783e962feebf)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 11:19:45 2007 +0100

    [test-meta-surface] Propagate error from show_page().
    
    Add a missing error propagation for _test_meta_surface_show_page().

diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c
index 3b317ab..4c08601 100644
--- a/src/test-meta-surface.c
+++ b/src/test-meta-surface.c
@@ -121,9 +121,13 @@ _test_meta_surface_acquire_source_image 
 					 void			**image_extra)
 {
     test_meta_surface_t *surface = abstract_surface;
+    cairo_status_t status;
 
-    if (! surface->image_reflects_meta)
-	_test_meta_surface_show_page (abstract_surface);
+    if (! surface->image_reflects_meta) {
+	status = _test_meta_surface_show_page (abstract_surface);
+	if (status)
+	    return status;
+    }
 
     return _cairo_surface_acquire_source_image (surface->image,
 						image_out, image_extra);
diff-tree 7758e56d0c96fd113a12b2adc92c783e962feebf (from 1dabfc2b271a57b4eaa13922a031ccd38a586dd1)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 11:16:40 2007 +0100

    [cairo-hull] Remove a couple of redundant status returns.
    
    Those two functions unconditionally returned success, so change the
    return to void.

diff --git a/src/cairo-hull.c b/src/cairo-hull.c
index 9eed671..d4e4af8 100644
--- a/src/cairo-hull.c
+++ b/src/cairo-hull.c
@@ -142,7 +142,7 @@ _cairo_hull_next_valid (cairo_hull_t *hu
     return index;
 }
 
-static cairo_status_t
+static void
 _cairo_hull_eliminate_concave (cairo_hull_t *hull, int num_hull)
 {
     int i, j, k;
@@ -159,7 +159,7 @@ _cairo_hull_eliminate_concave (cairo_hul
 	/* Is the angle formed by ij and jk concave? */
 	if (_cairo_slope_compare (&slope_ij, &slope_jk) >= 0) {
 	    if (i == k)
-		return CAIRO_STATUS_SUCCESS;
+		return;
 	    hull[j].discard = 1;
 	    j = i;
 	    i = _cairo_hull_prev_valid (hull, num_hull, j);
@@ -169,11 +169,9 @@ _cairo_hull_eliminate_concave (cairo_hul
 	    k = _cairo_hull_next_valid (hull, num_hull, j);
 	}
     } while (j != 0);
-
-    return CAIRO_STATUS_SUCCESS;
 }
 
-static cairo_status_t
+static void
 _cairo_hull_to_pen (cairo_hull_t *hull, cairo_pen_vertex_t *vertices, int *num_vertices)
 {
     int i, j = 0;
@@ -185,8 +183,6 @@ _cairo_hull_to_pen (cairo_hull_t *hull, 
     }
 
     *num_vertices = j;
-
-    return CAIRO_STATUS_SUCCESS;
 }
 
 /* Given a set of vertices, compute the convex hull using the Graham
diff-tree 1dabfc2b271a57b4eaa13922a031ccd38a586dd1 (from 32b78fffc3b8441029ee6b48762a7d0c06bb44a8)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 11:15:27 2007 +0100

    [cairo-clip] Propagate error status from clip_intersect_path().
    
    Propagate the error status (filtering out UNSUPPORTED) from
    intersect_path() when reapplying the clip path during a deep copy.

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 43b25ca..a48f4c4 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -534,18 +534,23 @@ _cairo_clip_translate (cairo_clip_t  *cl
     }
 }
 
-static void
+static cairo_status_t
 _cairo_clip_path_reapply_clip_path (cairo_clip_t      *clip,
                                     cairo_clip_path_t *clip_path)
 {
-    if (clip_path->prev)
-        _cairo_clip_path_reapply_clip_path (clip, clip_path->prev);
+    cairo_status_t status;
 
-    _cairo_clip_intersect_path (clip,
-                                &clip_path->path,
-                                clip_path->fill_rule,
-                                clip_path->tolerance,
-                                clip_path->antialias);
+    if (clip_path->prev) {
+        status = _cairo_clip_path_reapply_clip_path (clip, clip_path->prev);
+	if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
+	    return status;
+    }
+
+    return _cairo_clip_intersect_path (clip,
+                                       &clip_path->path,
+				       clip_path->fill_rule,
+				       clip_path->tolerance,
+				       clip_path->antialias);
 }
 
 cairo_status_t
@@ -553,6 +558,8 @@ _cairo_clip_init_deep_copy (cairo_clip_t
                             cairo_clip_t    *other,
                             cairo_surface_t *target)
 {
+    cairo_status_t status;
+
     _cairo_clip_init (clip, target);
 
     if (other->mode != clip->mode) {
@@ -560,26 +567,30 @@ _cairo_clip_init_deep_copy (cairo_clip_t
          * whatever the right handling is happen */
     } else {
         if (other->has_region) {
-            if (_cairo_region_copy (&clip->region, &other->region) !=
-		CAIRO_STATUS_SUCCESS)
+            status = _cairo_region_copy (&clip->region, &other->region);
+	    if (status)
 		goto BAIL;
+
 	    clip->has_region = TRUE;
         }
 
         if (other->surface) {
-            if (_cairo_surface_clone_similar (target, other->surface,
-					  other->surface_rect.x,
-					  other->surface_rect.y,
-					  other->surface_rect.width,
-					  other->surface_rect.height,
-					  &clip->surface) !=
-		    CAIRO_STATUS_SUCCESS)
+            status = _cairo_surface_clone_similar (target, other->surface,
+					           other->surface_rect.x,
+						   other->surface_rect.y,
+						   other->surface_rect.width,
+						   other->surface_rect.height,
+						   &clip->surface);
+	    if (status)
 		goto BAIL;
+
             clip->surface_rect = other->surface_rect;
         }
 
         if (other->path) {
-            _cairo_clip_path_reapply_clip_path (clip, other->path);
+            status = _cairo_clip_path_reapply_clip_path (clip, other->path);
+	    if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
+		goto BAIL;
         }
     }
 
@@ -591,7 +602,7 @@ BAIL:
     if (clip->surface)
 	cairo_surface_destroy (clip->surface);
 
-    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    return status;
 }
 
 const cairo_rectangle_list_t _cairo_rectangles_nil =
diff-tree 32b78fffc3b8441029ee6b48762a7d0c06bb44a8 (from 66563eddd8ba2610fa59341b9337a30533e70d56)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 11:08:58 2007 +0100

    [cairo-traps] Simplify the status interaction of traps_grow().
    
    Simply return the error status from the traps_grow() function rather
    than having an assignment in the return function and then immediately
    another assignment of the error to the status member at its callsite.

diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 1893fc2..099b09e 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -257,22 +257,17 @@ _cairo_traps_grow (cairo_traps_t *traps)
     cairo_trapezoid_t *new_traps;
     int new_size = 2 * MAX (traps->traps_size, 16);
 
-    if (traps->status)
-	return traps->status;
-
     if (traps->traps == traps->traps_embedded) {
 	new_traps = _cairo_malloc_ab (new_size, sizeof (cairo_trapezoid_t));
 	if (new_traps)
 	    memcpy (new_traps, traps->traps, sizeof (traps->traps_embedded));
     } else {
 	new_traps = _cairo_realloc_ab (traps->traps,
-	       	                       new_size, sizeof (cairo_trapezoid_t));
+	                               new_size, sizeof (cairo_trapezoid_t));
     }
 
-    if (new_traps == NULL) {
-	traps->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return traps->status;
-    }
+    if (new_traps == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     traps->traps = new_traps;
     traps->traps_size = new_size;
diff-tree 66563eddd8ba2610fa59341b9337a30533e70d56 (from be7d1f0f8f84ddac9e8c7dda4aa39f88806a5e39)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 09:28:35 2007 +0100

    [cairo-pdf-surface] Check status return after emit_meta_pattern().
    
    Add the missing status propagation.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index bf99c40..77e6c8d 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1661,9 +1661,13 @@ _cairo_pdf_surface_emit_surface_pattern 
 	status = _cairo_pdf_surface_emit_meta_surface (surface,
 						       meta_surface,
 						       &pattern_resource);
+	if (status)
+	    return status;
+
 	status = _cairo_surface_get_extents (meta_surface, &pattern_extents);
 	if (status)
 	    return status;
+
 	pattern_width = pattern_extents.width;
 	pattern_height = pattern_extents.height;
     } else {
@@ -1672,9 +1676,9 @@ _cairo_pdf_surface_emit_surface_pattern 
 							&pattern_resource,
 							&pattern_width,
 							&pattern_height);
+	if (status)
+	    return status;
     }
-    if (status)
-	return status;
 
     status = _cairo_surface_get_extents (&surface->base, &surface_extents);
     if (status)


More information about the cairo-commit mailing list