[cairo-commit] 6 commits - boilerplate/Makefile.win32.features build/Makefile.win32.features-h src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-surface.c src/cairo-svg-surface.c src/cairo-xcb-surface.c src/cairo-xlib-surface.c src/cairo-xlib-xcb-surface.c src/Makefile.win32.features

Chris Wilson ickle at kemper.freedesktop.org
Wed Apr 14 11:42:39 PDT 2010


 boilerplate/Makefile.win32.features |    8 +++
 build/Makefile.win32.features-h     |    1 
 src/Makefile.win32.features         |    8 +++
 src/cairo-pdf-surface.c             |   43 ++++++++++----------
 src/cairo-ps-surface.c              |   74 +++++++++++++-----------------------
 src/cairo-surface.c                 |    3 +
 src/cairo-svg-surface.c             |   37 ++++++++++--------
 src/cairo-xcb-surface.c             |    3 +
 src/cairo-xlib-surface.c            |    6 ++
 src/cairo-xlib-xcb-surface.c        |    6 ++
 10 files changed, 105 insertions(+), 84 deletions(-)

New commits:
commit b0383d0cd2b40185b1676d9c88d3647cecc1d7fd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 14 19:33:34 2010 +0100

    svg: Don't write error status to the inert object.
    
    Reported-by: Benjamin Otte <otte at redhat.com>

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 97eb457..6ba3f31 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -251,30 +251,39 @@ _cairo_surface_is_svg (cairo_surface_t *surface)
 
 /* If the abstract_surface is a paginated surface, and that paginated
  * surface's target is a svg_surface, then set svg_surface to that
- * target. Otherwise return %CAIRO_STATUS_SURFACE_TYPE_MISMATCH.
+ * target. Otherwise return FALSE.
  */
-static cairo_status_t
+static cairo_bool_t
 _extract_svg_surface (cairo_surface_t		 *surface,
 		      cairo_svg_surface_t	**svg_surface)
 {
     cairo_surface_t *target;
+    cairo_status_t status_ignored;
 
     if (surface->status)
-	return surface->status;
+	return FALSE;
 
-    if (! _cairo_surface_is_paginated (surface))
-	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+    if (! _cairo_surface_is_paginated (surface)) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+	return FALSE;
+    }
 
     target = _cairo_paginated_surface_get_target (surface);
-    if (target->status)
-	return target->status;
+    if (target->status) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   target->status);
+	return FALSE;
+    }
 
-    if (! _cairo_surface_is_svg (target))
-	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+    if (! _cairo_surface_is_svg (target)) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+	return FALSE;
+    }
 
     *svg_surface = (cairo_svg_surface_t *) target;
-
-    return CAIRO_STATUS_SUCCESS;
+    return TRUE;
 }
 
 /**
@@ -297,13 +306,9 @@ cairo_svg_surface_restrict_to_version (cairo_surface_t		*abstract_surface,
 				       cairo_svg_version_t	 version)
 {
     cairo_svg_surface_t *surface = NULL; /* hide compiler warning */
-    cairo_status_t status;
 
-    status = _extract_svg_surface (abstract_surface, &surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (abstract_surface, status);
+    if (! _extract_svg_surface (abstract_surface, &surface))
 	return;
-    }
 
     if (version < CAIRO_SVG_VERSION_LAST)
 	surface->document->svg_version = version;
commit 5274b63adb9ad808f94e6ea04707991ec1192694
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 14 19:33:34 2010 +0100

    ps: Don't write error status to the inert object.
    
    Reported-by: Benjamin Otte <otte at redhat.com>

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 80639e7..ce1a802 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -541,7 +541,6 @@ cairo_pdf_surface_restrict_to_version (cairo_surface_t 		*abstract_surface,
 				       cairo_pdf_version_t  	 version)
 {
     cairo_pdf_surface_t *surface = NULL; /* hide compiler warning */
-    cairo_status_t status;
 
     if (! _extract_pdf_surface (abstract_surface, &surface))
 	return;
@@ -618,7 +617,6 @@ cairo_pdf_surface_set_size (cairo_surface_t	*surface,
 			    double		 height_in_points)
 {
     cairo_pdf_surface_t *pdf_surface = NULL; /* hide compiler warning */
-    cairo_status_t status;
 
     if (! _extract_pdf_surface (surface, &pdf_surface))
 	return;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 4c7ca90..fa0979b 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1097,30 +1097,38 @@ _cairo_surface_is_ps (cairo_surface_t *surface)
 
 /* If the abstract_surface is a paginated surface, and that paginated
  * surface's target is a ps_surface, then set ps_surface to that
- * target. Otherwise return %CAIRO_STATUS_SURFACE_TYPE_MISMATCH.
+ * target. Otherwise return FALSE.
  */
-static cairo_status_t
+static cairo_bool_t
 _extract_ps_surface (cairo_surface_t	 *surface,
 		     cairo_ps_surface_t **ps_surface)
 {
     cairo_surface_t *target;
+    cairo_status_t status_ignored;
 
     if (surface->status)
-	return surface->status;
+	return FALSE;
 
-    if (! _cairo_surface_is_paginated (surface))
-	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+    if (! _cairo_surface_is_paginated (surface)) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+	return FALSE;
+    }
 
     target = _cairo_paginated_surface_get_target (surface);
-    if (target->status)
-	return target->status;
+    if (target->status) {
+	status_ignored = _cairo_surface_set_error (surface, target->status);
+	return FALSE;
+    }
 
-    if (! _cairo_surface_is_ps (target))
-	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+    if (! _cairo_surface_is_ps (target)) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+	return FALSE;
+    }
 
     *ps_surface = (cairo_ps_surface_t *) target;
-
-    return CAIRO_STATUS_SUCCESS;
+    return TRUE;
 }
 
 /**
@@ -1144,13 +1152,9 @@ cairo_ps_surface_restrict_to_level (cairo_surface_t  *surface,
                                     cairo_ps_level_t  level)
 {
     cairo_ps_surface_t *ps_surface = NULL;
-    cairo_status_t status;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return;
-    }
 
     if (level < CAIRO_PS_LEVEL_LAST)
 	ps_surface->ps_level = level;
@@ -1219,13 +1223,9 @@ cairo_ps_surface_set_eps (cairo_surface_t	*surface,
 			  cairo_bool_t           eps)
 {
     cairo_ps_surface_t *ps_surface = NULL;
-    cairo_status_t status;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return;
-    }
 
     ps_surface->eps = eps;
 }
@@ -1244,13 +1244,10 @@ cairo_public cairo_bool_t
 cairo_ps_surface_get_eps (cairo_surface_t	*surface)
 {
     cairo_ps_surface_t *ps_surface = NULL;
-    cairo_status_t status;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    /* XXX this should not call _cairo_surface_set_error on error */
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return FALSE;
-    }
 
     return ps_surface->eps;
 }
@@ -1278,13 +1275,9 @@ cairo_ps_surface_set_size (cairo_surface_t	*surface,
 			   double		 height_in_points)
 {
     cairo_ps_surface_t *ps_surface = NULL;
-    cairo_status_t status;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return;
-    }
 
     ps_surface->width = width_in_points;
     ps_surface->height = height_in_points;
@@ -1389,11 +1382,8 @@ cairo_ps_surface_dsc_comment (cairo_surface_t	*surface,
     cairo_status_t status;
     char *comment_copy;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return;
-    }
 
     /* A couple of sanity checks on the comment value. */
     if (comment == NULL) {
@@ -1441,18 +1431,12 @@ void
 cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface)
 {
     cairo_ps_surface_t *ps_surface = NULL;
-    cairo_status_t status;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return;
-    }
 
     if (ps_surface->dsc_comment_target == &ps_surface->dsc_header_comments)
-    {
 	ps_surface->dsc_comment_target = &ps_surface->dsc_setup_comments;
-    }
 }
 
 /**
@@ -1476,13 +1460,9 @@ void
 cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface)
 {
     cairo_ps_surface_t *ps_surface = NULL;
-    cairo_status_t status;
 
-    status = _extract_ps_surface (surface, &ps_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_ps_surface (surface, &ps_surface))
 	return;
-    }
 
     if (ps_surface->dsc_comment_target == &ps_surface->dsc_header_comments ||
 	ps_surface->dsc_comment_target == &ps_surface->dsc_setup_comments)
commit 45d23b8a791d5845025a1a4d93f99030ec9e0115
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 14 19:33:34 2010 +0100

    pdf: Don't write error status to the inert object.
    
    Reported-by: Benjamin Otte <otte at redhat.com>

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index f0bdebd..80639e7 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -486,30 +486,39 @@ _cairo_surface_is_pdf (cairo_surface_t *surface)
 
 /* If the abstract_surface is a paginated surface, and that paginated
  * surface's target is a pdf_surface, then set pdf_surface to that
- * target. Otherwise return %CAIRO_STATUS_SURFACE_TYPE_MISMATCH.
+ * target. Otherwise return FALSE.
  */
-static cairo_status_t
+static cairo_bool_t
 _extract_pdf_surface (cairo_surface_t		 *surface,
 		      cairo_pdf_surface_t	**pdf_surface)
 {
     cairo_surface_t *target;
+    cairo_status_t status_ignored;
 
     if (surface->status)
-	return surface->status;
+	return FALSE;
 
-    if (! _cairo_surface_is_paginated (surface))
-	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+    if (! _cairo_surface_is_paginated (surface)) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+	return FALSE;
+    }
 
     target = _cairo_paginated_surface_get_target (surface);
-    if (target->status)
-	return target->status;
+    if (target->status) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   target->status);
+	return FALSE;
+    }
 
-    if (! _cairo_surface_is_pdf (target))
-	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+    if (! _cairo_surface_is_pdf (target)) {
+	status_ignored = _cairo_surface_set_error (surface,
+						   _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
+	return FALSE;
+    }
 
     *pdf_surface = (cairo_pdf_surface_t *) target;
-
-    return CAIRO_STATUS_SUCCESS;
+    return TRUE;
 }
 
 /**
@@ -534,11 +543,8 @@ cairo_pdf_surface_restrict_to_version (cairo_surface_t 		*abstract_surface,
     cairo_pdf_surface_t *surface = NULL; /* hide compiler warning */
     cairo_status_t status;
 
-    status = _extract_pdf_surface (abstract_surface, &surface);
-    if (status) {
-	status = _cairo_surface_set_error (abstract_surface, status);
+    if (! _extract_pdf_surface (abstract_surface, &surface))
 	return;
-    }
 
     if (version < CAIRO_PDF_VERSION_LAST)
 	surface->pdf_version = version;
@@ -614,11 +620,8 @@ cairo_pdf_surface_set_size (cairo_surface_t	*surface,
     cairo_pdf_surface_t *pdf_surface = NULL; /* hide compiler warning */
     cairo_status_t status;
 
-    status = _extract_pdf_surface (surface, &pdf_surface);
-    if (unlikely (status)) {
-	status = _cairo_surface_set_error (surface, status);
+    if (! _extract_pdf_surface (surface, &pdf_surface))
 	return;
-    }
 
     _cairo_pdf_surface_set_size_internal (pdf_surface,
 					  width_in_points,
commit 4351304b5110200b77e6851995cf533a929ba17e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 14 19:29:07 2010 +0100

    Win32 features update.

diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index 31bd4e0..4781d8a 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -199,6 +199,14 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_png_private)
 enabled_cairo_boilerplate_sources += $(cairo_boilerplate_png_sources)
 endif
 
+supported_cairo_boilerplate_headers += $(cairo_boilerplate_glew_headers)
+all_cairo_boilerplate_headers += $(cairo_boilerplate_glew_headers)
+all_cairo_boilerplate_private += $(cairo_boilerplate_glew_private)
+all_cairo_boilerplate_sources += $(cairo_boilerplate_glew_sources)
+enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glew_headers)
+enabled_cairo_boilerplate_private += $(cairo_boilerplate_glew_private)
+enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glew_sources)
+
 unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
 all_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
 all_cairo_boilerplate_private += $(cairo_boilerplate_gl_private)
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index f7c07ac..c2a5332 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -59,6 +59,7 @@ endif
 ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
 	@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> src/cairo-features.h
 endif
+	@echo "#define CAIRO_HAS_GLEW_FUNCTIONS 1" >> src/cairo-features.h
 ifeq ($(CAIRO_HAS_GL_SURFACE),1)
 	@echo "#define CAIRO_HAS_GL_SURFACE 1" >> src/cairo-features.h
 endif
commit bd17b898b1c249aa0dc443bc303bad4fea8690bc
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 14 19:11:15 2010 +0100

    surface: Propagate the error status to _cairo_surface_get_device()
    
    If the surface is in error, the appropriate action is report the error
    using an inert error cairo_device_t.
    
    Reported-by: Benjamin Otte <otte at redhat.com>

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 9a3d329..865462d 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -231,6 +231,9 @@ _cairo_surface_allocate_unique_id (void)
 cairo_device_t *
 cairo_surface_get_device (cairo_surface_t *surface)
 {
+    if (unlikely (surface->status))
+	return _cairo_device_create_in_error (surface->status);
+
     return surface->device;
 }
 
commit 005596907fc9b62fa4bf72ec35e0d1a1a242ef93
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 14 19:05:09 2010 +0100

    xlib: Don't operate on an error object inside setters.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=599574
    
    The backend API manipulated the surface prior to checking whether it was
    an inert error surface - and in the event of an error surface, tried to
    overwrite it's error status.

diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index 42fb696..05efd04 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -273,6 +273,14 @@ ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
 enabled_cairo_pkgconf += cairo-png.pc
 endif
 
+supported_cairo_headers += $(cairo_glew_headers)
+all_cairo_headers += $(cairo_glew_headers)
+all_cairo_private += $(cairo_glew_private)
+all_cairo_sources += $(cairo_glew_sources)
+enabled_cairo_headers += $(cairo_glew_headers)
+enabled_cairo_private += $(cairo_glew_private)
+enabled_cairo_sources += $(cairo_glew_sources)
+
 unsupported_cairo_headers += $(cairo_gl_headers)
 all_cairo_headers += $(cairo_gl_headers)
 all_cairo_private += $(cairo_gl_private)
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 5f91ef6..9852423 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1322,6 +1322,9 @@ cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface,
     cairo_xcb_surface_t *surface;
     cairo_status_t status_ignored;
 
+    if (unlikely (abstract_surface->status))
+	return;
+
     if (abstract_surface->type != CAIRO_SURFACE_TYPE_XCB) {
 	status_ignored = _cairo_surface_set_error (abstract_surface,
 						   CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index c2aad95..27ced5b 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3262,6 +3262,9 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface,
     cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
     cairo_status_t status;
 
+    if (unlikely (abstract_surface->status))
+	return;
+
     if (! _cairo_surface_is_xlib (abstract_surface)) {
 	status = _cairo_surface_set_error (abstract_surface,
 		                           CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
@@ -3300,6 +3303,9 @@ cairo_xlib_surface_set_drawable (cairo_surface_t   *abstract_surface,
     cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
     cairo_status_t status;
 
+    if (unlikely (abstract_surface->status))
+	return;
+
     if (! _cairo_surface_is_xlib (abstract_surface)) {
 	status = _cairo_surface_set_error (abstract_surface,
 		                           CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index a8e0cde..3dbb9bd 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -396,6 +396,9 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface,
     cairo_xlib_xcb_surface_t *surface = (cairo_xlib_xcb_surface_t *) abstract_surface;
     cairo_status_t status;
 
+    if (unlikely (abstract_surface->status))
+	return;
+
     if (surface->base.type != CAIRO_SURFACE_TYPE_XLIB) {
 	status = _cairo_surface_set_error (abstract_surface,
 		                           CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
@@ -414,6 +417,9 @@ cairo_xlib_surface_set_drawable (cairo_surface_t   *abstract_surface,
     cairo_xlib_xcb_surface_t *surface = (cairo_xlib_xcb_surface_t *)abstract_surface;
     cairo_status_t status;
 
+    if (unlikely (abstract_surface->status))
+	return;
+
     if (surface->base.type != CAIRO_SURFACE_TYPE_XLIB) {
 	status = _cairo_surface_set_error (abstract_surface,
 		                           CAIRO_STATUS_SURFACE_TYPE_MISMATCH);


More information about the cairo-commit mailing list