[cairo-commit] 5 commits - src/cairo-analysis-surface.c src/cairo.c src/cairo-gstate.c src/cairo-image-surface.c src/cairoint.h src/cairo-paginated-surface.c src/cairo-path-bounds.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Feb 27 02:29:45 PST 2008


 src/cairo-analysis-surface.c  |    8 +++++--
 src/cairo-gstate.c            |   40 ++++++++++++++++++-------------------
 src/cairo-image-surface.c     |   45 ++++++++++++++++++++++--------------------
 src/cairo-paginated-surface.c |    1 
 src/cairo-path-bounds.c       |   10 ++++-----
 src/cairo.c                   |   10 ++++++---
 src/cairoint.h                |    4 +--
 7 files changed, 65 insertions(+), 53 deletions(-)

New commits:
commit 4f7d3063520b987d3df3bcebfaeed9489b16b12d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Feb 27 10:11:08 2008 +0000

    [cairo-paginated-surface] Fix enum compiler warning.
    
    Add a CAIRO_SURFACE_TYPE_QUARTZ_IMAGE to the switch to suppress a
    compiler warning.

diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 83f9dc9..f401aef 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -334,6 +334,7 @@ _paint_page (cairo_paginated_surface_t *surface)
 	case CAIRO_SURFACE_TYPE_XCB:
 	case CAIRO_SURFACE_TYPE_GLITZ:
 	case CAIRO_SURFACE_TYPE_QUARTZ:
+	case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
 	case CAIRO_SURFACE_TYPE_WIN32:
 	case CAIRO_SURFACE_TYPE_BEOS:
 	case CAIRO_SURFACE_TYPE_DIRECTFB:
commit cb5ea8abfdf2c92241d4dea8bb827648697fd8e9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 21 16:03:42 2008 +0000

    [cairo-image-surface] Compiler warnings and whitespace.
    
    Silence a couple of enum compiler warnings and tweak the whitespace.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 60c0592..2be0b01 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -59,6 +59,7 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format)
     case PIXMAN_a4:       case PIXMAN_r1g2b1:   case PIXMAN_b1g2r1:
     case PIXMAN_a1r1g1b1: case PIXMAN_a1b1g1r1: case PIXMAN_c4:
     case PIXMAN_g4:       case PIXMAN_g1:
+    case PIXMAN_yuy2:     case PIXMAN_yv12:
     default:
 	return CAIRO_FORMAT_INVALID;
     }
@@ -100,6 +101,8 @@ _cairo_content_from_pixman_format (pixman_format_code_t pixman_format)
     case PIXMAN_c4:
     case PIXMAN_g4:
     case PIXMAN_g1:
+    case PIXMAN_yuy2:
+    case PIXMAN_yv12:
 	return CAIRO_CONTENT_COLOR;
     case PIXMAN_a8:
     case PIXMAN_a1:
@@ -289,7 +292,7 @@ _cairo_image_surface_create_with_masks (unsigned char	       *data,
 					int			stride)
 {
     pixman_format_code_t pixman_format;
-    
+
     pixman_format = _pixman_format_from_masks (masks);
 
     return _cairo_image_surface_create_with_pixman_format (data,
@@ -299,7 +302,7 @@ _cairo_image_surface_create_with_masks (unsigned char	       *data,
 							   stride);
 }
 
-static pixman_format_code_t 
+static pixman_format_code_t
 _cairo_format_to_pixman_format_code (cairo_format_t format)
 {
     pixman_format_code_t ret;
@@ -484,7 +487,7 @@ cairo_image_surface_create_for_data (unsigned char     *data,
     pixman_format_code_t pixman_format;
 
     if (! CAIRO_FORMAT_VALID (format))
-	return _cairo_surface_create_in_error (_cairo_error(CAIRO_STATUS_INVALID_FORMAT));
+	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
 
     if ((stride & (STRIDE_ALIGNMENT-1)) != 0)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
@@ -528,7 +531,7 @@ cairo_image_surface_get_data (cairo_surface_t *surface)
 {
     cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
 
-    if (!_cairo_surface_is_image (surface)) {
+    if (! _cairo_surface_is_image (surface)) {
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return NULL;
     }
@@ -551,7 +554,7 @@ cairo_image_surface_get_format (cairo_surface_t *surface)
 {
     cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
 
-    if (!_cairo_surface_is_image (surface)) {
+    if (! _cairo_surface_is_image (surface)) {
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
@@ -574,7 +577,7 @@ cairo_image_surface_get_width (cairo_surface_t *surface)
 {
     cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
 
-    if (!_cairo_surface_is_image (surface)) {
+    if (! _cairo_surface_is_image (surface)) {
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
@@ -596,7 +599,7 @@ cairo_image_surface_get_height (cairo_surface_t *surface)
 {
     cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
 
-    if (!_cairo_surface_is_image (surface)) {
+    if (! _cairo_surface_is_image (surface)) {
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
@@ -624,7 +627,7 @@ cairo_image_surface_get_stride (cairo_surface_t *surface)
 
     cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
 
-    if (!_cairo_surface_is_image (surface)) {
+    if (! _cairo_surface_is_image (surface)) {
 	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return 0;
     }
@@ -794,7 +797,7 @@ _cairo_image_surface_set_matrix (cairo_image_surface_t	*surface,
 
     _cairo_matrix_to_pixman_matrix (matrix, &pixman_transform);
 
-    if (!pixman_image_set_transform (surface->pixman_image, &pixman_transform))
+    if (! pixman_image_set_transform (surface->pixman_image, &pixman_transform))
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
@@ -974,7 +977,7 @@ _cairo_image_surface_composite (cairo_operator_t	op,
 				width, height);
     }
 
-    if (!_cairo_operator_bounded_by_source (op))
+    if (! _cairo_operator_bounded_by_source (op))
 	status = _cairo_surface_composite_fixup_unbounded (&dst->base,
 							   &src_attr, src->width, src->height,
 							   mask ? &mask_attr : NULL,
@@ -1014,11 +1017,11 @@ _cairo_image_surface_fill_rectangles (void		      *abstract_surface,
     pixman_color.blue  = color->blue_short;
     pixman_color.alpha = color->alpha_short;
 
-    if (num_rects > ARRAY_LENGTH(stack_rects)) {
-	pixman_rects = _cairo_malloc_ab (num_rects, sizeof(pixman_rectangle16_t));
+    if (num_rects > ARRAY_LENGTH (stack_rects)) {
+	pixman_rects = _cairo_malloc_ab (num_rects, sizeof (pixman_rectangle16_t));
 	if (pixman_rects == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-    }		 
+    }
 
     for (i = 0; i < num_rects; i++) {
 	pixman_rects[i].x = rects[i].x;
@@ -1028,7 +1031,7 @@ _cairo_image_surface_fill_rectangles (void		      *abstract_surface,
     }
 
     /* XXX: pixman_fill_rectangles() should be implemented */
-    if (!pixman_image_fill_rectangles (_pixman_operator(op),
+    if (! pixman_image_fill_rectangles (_pixman_operator (op),
 				       surface->pixman_image,
 				       &pixman_color,
 				       num_rects,
@@ -1073,8 +1076,8 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
 	return CAIRO_STATUS_SUCCESS;
 
     /* Convert traps to pixman traps */
-    if (num_traps > ARRAY_LENGTH(stack_traps)) {
-	pixman_traps = _cairo_malloc_ab (num_traps, sizeof(pixman_trapezoid_t));
+    if (num_traps > ARRAY_LENGTH (stack_traps)) {
+	pixman_traps = _cairo_malloc_ab (num_traps, sizeof (pixman_trapezoid_t));
 	if (pixman_traps == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
@@ -1108,7 +1111,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
     if (op == CAIRO_OPERATOR_ADD &&
 	_cairo_pattern_is_opaque_solid (pattern) &&
 	dst->base.content == CAIRO_CONTENT_ALPHA &&
-	!dst->has_clip &&
+	! dst->has_clip &&
 	antialias != CAIRO_ANTIALIAS_NONE)
     {
 	pixman_add_trapezoids (dst->pixman_image, 0, 0,
@@ -1134,7 +1137,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
 	ret = 1;
 	mask_stride = ((width + 31) / 8) & ~0x03;
 	mask_bpp = 1;
- 	break;
+	break;
     case CAIRO_ANTIALIAS_GRAY:
     case CAIRO_ANTIALIAS_SUBPIXEL:
     case CAIRO_ANTIALIAS_DEFAULT:
@@ -1143,7 +1146,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
 	ret = 1;
 	mask_stride = (width + 3) & ~3;
 	mask_bpp = 8;
- 	break;
+	break;
     }
 
     /* The image must be initially transparent */
@@ -1173,7 +1176,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
 			    dst_x, dst_y,
 			    width, height);
 
-    if (!_cairo_operator_bounded_by_mask (op))
+    if (! _cairo_operator_bounded_by_mask (op))
 	status = _cairo_surface_composite_shape_fixup_unbounded (&dst->base,
 								 &attributes, src->width, src->height,
 								 width, height,
@@ -1201,7 +1204,7 @@ _cairo_image_surface_set_clip_region (void *abstract_surface,
 {
     cairo_image_surface_t *surface = (cairo_image_surface_t *) abstract_surface;
 
-    if (!pixman_image_set_clip_region (surface->pixman_image, &region->rgn))
+    if (! pixman_image_set_clip_region (surface->pixman_image, &region->rgn))
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     surface->has_clip = region != NULL;
commit 22600e2393f2ec5ebe40213c49599167523ddf20
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Feb 22 17:07:45 2008 +0000

    [cairo-gstate] Remove a couple of impossible guards.
    
    Delete a couple of superfluous gstate != NULL guards.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 9d9b49a..5049399 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -206,9 +206,6 @@ _cairo_gstate_fini (cairo_gstate_t *gstate)
 static void
 _cairo_gstate_destroy (cairo_gstate_t *gstate)
 {
-    if (gstate == NULL)
-	return;
-
     _cairo_gstate_fini (gstate);
     free (gstate);
 }
@@ -448,9 +445,6 @@ _cairo_gstate_set_source (cairo_gstate_t  *gstate,
 cairo_pattern_t *
 _cairo_gstate_get_source (cairo_gstate_t *gstate)
 {
-    if (gstate == NULL)
-	return NULL;
-
     return gstate->source;
 }
 
commit 37e597f1e553a98d06c5334aa95b918ed303e89e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Feb 22 17:03:51 2008 +0000

    [cairo-gstate] Propagate the error from _cairo_gstate_clone().
    
    Propagate the true status value back from the _cairo_gstate_init_copy()
    instead of assuming that is a NO_MEMORY and re-raising the error in the
    caller.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index fef7d4f..9d9b49a 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -225,8 +225,8 @@ _cairo_gstate_destroy (cairo_gstate_t *gstate)
  * Return value: a new #cairo_gstate_t or %NULL if there is insufficient
  * memory.
  **/
-static cairo_gstate_t*
-_cairo_gstate_clone (cairo_gstate_t *other)
+static cairo_status_t
+_cairo_gstate_clone (cairo_gstate_t *other, cairo_gstate_t **out)
 {
     cairo_status_t status;
     cairo_gstate_t *gstate;
@@ -234,18 +234,17 @@ _cairo_gstate_clone (cairo_gstate_t *other)
     assert (other != NULL);
 
     gstate = malloc (sizeof (cairo_gstate_t));
-    if (gstate == NULL) {
-	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-	return NULL;
-    }
+    if (gstate == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _cairo_gstate_init_copy (gstate, other);
     if (status) {
 	free (gstate);
-	return NULL;
+	return status;
     }
 
-    return gstate;
+    *out = gstate;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 /**
@@ -260,10 +259,11 @@ cairo_status_t
 _cairo_gstate_save (cairo_gstate_t **gstate)
 {
     cairo_gstate_t *top;
+    cairo_status_t status;
 
-    top = _cairo_gstate_clone (*gstate);
-    if (top == NULL)
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    status = _cairo_gstate_clone (*gstate, &top);
+    if (status)
+	return status;
 
     top->next = *gstate;
     *gstate = top;
commit 127d7f43ea7043bba1d276d9721e80a702d9fd46
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 21 15:56:34 2008 +0000

    [cairo-path-bounds] _cairo_path_fixed_bounds() can fail...
    
    I was wrong in my assertion that the call to
    _cairo_path_fixed_interpret_flat() could not possibly fail with the
    given _cairo_path_bounder_* callbacks - as I had missed the implicit
    spline decomposition. (An interesting exercise would be to avoid the
    spline allocation...) As a result we do have to check and propagate the
    status return through the call stack.

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 0a50cd3..29919f0 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -248,7 +248,11 @@ _cairo_analysis_surface_intersect_clip_path (void		*abstract_surface,
 	surface->current_clip.width  = surface->width;
 	surface->current_clip.height = surface->height;
     } else {
-	_cairo_path_fixed_bounds (path, &x1, &y1, &x2, &y2, tolerance);
+	cairo_status_t status;
+
+	status = _cairo_path_fixed_bounds (path, &x1, &y1, &x2, &y2, tolerance);
+	if (status)
+	    return status;
 
 	extent.x = floor (x1);
 	extent.y = floor (y1);
@@ -262,7 +266,7 @@ _cairo_analysis_surface_intersect_clip_path (void		*abstract_surface,
 }
 
 static cairo_int_status_t
-_cairo_analysis_surface_get_extents (void	 		*abstract_surface,
+_cairo_analysis_surface_get_extents (void			*abstract_surface,
 				     cairo_rectangle_int_t	*rectangle)
 {
     cairo_analysis_surface_t *surface = abstract_surface;
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index b6ddcb3..fef7d4f 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -818,15 +818,21 @@ _cairo_gstate_stroke_to_path (cairo_gstate_t *gstate)
 }
 */
 
-void
+cairo_status_t
 _cairo_gstate_path_extents (cairo_gstate_t     *gstate,
 			    cairo_path_fixed_t *path,
 			    double *x1, double *y1,
 			    double *x2, double *y2)
 {
-    _cairo_path_fixed_bounds (path, x1, y1, x2, y2, gstate->tolerance);
-    
+    cairo_status_t status;
+
+    status = _cairo_path_fixed_bounds (path, x1, y1, x2, y2, gstate->tolerance);
+    if (status)
+	return status;
+
     _cairo_gstate_backend_to_user_rectangle (gstate, x1, y1, x2, y2, NULL);
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c
index 581244b..70867e3 100644
--- a/src/cairo-path-bounds.c
+++ b/src/cairo-path-bounds.c
@@ -138,15 +138,14 @@ _cairo_path_bounder_close_path (void *closure)
 }
 
 /* XXX: Perhaps this should compute a PixRegion rather than 4 doubles */
-void
+cairo_status_t
 _cairo_path_fixed_bounds (cairo_path_fixed_t *path,
 			  double *x1, double *y1,
 			  double *x2, double *y2,
 			  double tolerance)
 {
-    cairo_status_t status;
-
     cairo_path_bounder_t bounder;
+    cairo_status_t status;
 
     _cairo_path_bounder_init (&bounder);
 
@@ -156,9 +155,8 @@ _cairo_path_fixed_bounds (cairo_path_fixed_t *path,
 					       _cairo_path_bounder_close_path,
 					       &bounder,
 					       tolerance);
-    assert (status == CAIRO_STATUS_SUCCESS);
 
-    if (bounder.has_point) {
+    if (status == CAIRO_STATUS_SUCCESS && bounder.has_point) {
 	*x1 = _cairo_fixed_to_double (bounder.min_x);
 	*y1 = _cairo_fixed_to_double (bounder.min_y);
 	*x2 = _cairo_fixed_to_double (bounder.max_x);
@@ -171,4 +169,6 @@ _cairo_path_fixed_bounds (cairo_path_fixed_t *path,
     }
 
     _cairo_path_bounder_fini (&bounder);
+
+    return status;
 }
diff --git a/src/cairo.c b/src/cairo.c
index 68b5d55..a0fbb49 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -1898,6 +1898,8 @@ void
 cairo_path_extents (cairo_t *cr,
 		    double *x1, double *y1, double *x2, double *y2)
 {
+    cairo_status_t status;
+
     if (cr->status) {
 	if (x1)
 	    *x1 = 0.0;
@@ -1911,9 +1913,11 @@ cairo_path_extents (cairo_t *cr,
 	return;
     }
 
-    _cairo_gstate_path_extents (cr->gstate,
-				cr->path,
-				x1, y1, x2, y2);
+    status = _cairo_gstate_path_extents (cr->gstate,
+				         cr->path,
+					 x1, y1, x2, y2);
+    if (status)
+	_cairo_set_error (cr, status);
 }
 slim_hidden_def (cairo_path_extents);
 
diff --git a/src/cairoint.h b/src/cairoint.h
index 5f68e0d..773daf6 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1027,7 +1027,7 @@ _cairo_gstate_backend_to_user_rectangle (cairo_gstate_t *gstate,
                                          double *x2, double *y2,
                                          cairo_bool_t *is_tight);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_gstate_path_extents (cairo_gstate_t     *gstate,
 			    cairo_path_fixed_t *path,
 			    double *x1, double *y1,
@@ -1382,7 +1382,7 @@ _cairo_path_fixed_interpret_flat (cairo_path_fixed_t	  *path,
 		       void				  *closure,
 		       double				  tolerance);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_path_fixed_bounds (cairo_path_fixed_t *path,
 			  double *x1, double *y1,
 			  double *x2, double *y2,


More information about the cairo-commit mailing list