[cairo-commit] 2 commits - src/cairoint.h src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-surface.c src/cairo-svg-surface.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Feb 8 15:31:41 PST 2007


 src/cairo-pdf-surface.c |    4 +
 src/cairo-ps-surface.c  |    4 +
 src/cairo-surface.c     |  140 +++++++++++++-----------------------------------
 src/cairo-svg-surface.c |    4 +
 src/cairoint.h          |    1 
 5 files changed, 49 insertions(+), 104 deletions(-)

New commits:
diff-tree a37f21cb17a24643f7513dff06bc2b5fd38e2583 (from bf3cbe7660f03f6b4139f4cf79a4007c682a84bd)
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Feb 8 15:29:58 2007 -0800

    [PS/PDF/SVG] Return a write_error nil surface on write errors

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 3e6aa58..490f9f7 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -379,7 +379,9 @@ cairo_pdf_surface_create (const char		*f
     status = _cairo_output_stream_get_status (output);
     if (status) {
 	_cairo_error (status);
-	return (cairo_surface_t*) &_cairo_surface_nil;
+	return (status == CAIRO_STATUS_WRITE_ERROR) ?
+		(cairo_surface_t*) &_cairo_surface_nil_write_error :
+		(cairo_surface_t*) &_cairo_surface_nil;
     }
 
     return _cairo_pdf_surface_create_for_stream_internal (output,
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index da10a5c..3da530e 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -868,7 +868,9 @@ cairo_ps_surface_create (const char		*fi
     status = _cairo_output_stream_get_status (stream);
     if (status) {
 	_cairo_error (status);
-	return (cairo_surface_t*) &_cairo_surface_nil;
+	return (status == CAIRO_STATUS_WRITE_ERROR) ?
+		(cairo_surface_t*) &_cairo_surface_nil_write_error :
+		(cairo_surface_t*) &_cairo_surface_nil;
     }
 
     return _cairo_ps_surface_create_for_stream_internal (stream,
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 4f32e83..ec19c8b 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -79,6 +79,7 @@ const cairo_surface_t name = {					\
 DEFINE_NIL_SURFACE(CAIRO_STATUS_NO_MEMORY, _cairo_surface_nil);
 DEFINE_NIL_SURFACE(CAIRO_STATUS_FILE_NOT_FOUND, _cairo_surface_nil_file_not_found);
 DEFINE_NIL_SURFACE(CAIRO_STATUS_READ_ERROR, _cairo_surface_nil_read_error);
+DEFINE_NIL_SURFACE(CAIRO_STATUS_WRITE_ERROR, _cairo_surface_nil_write_error);
 
 static void
 _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t *pattern,
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 534ba01..5f25015 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -240,7 +240,9 @@ cairo_svg_surface_create (const char	*fi
     status = _cairo_output_stream_get_status (stream);
     if (status) {
 	_cairo_error (status);
-	return (cairo_surface_t *) &_cairo_surface_nil;
+	return (status == CAIRO_STATUS_WRITE_ERROR) ?
+		(cairo_surface_t *) &_cairo_surface_nil_write_error :
+		(cairo_surface_t *) &_cairo_surface_nil;
     }
 
     return _cairo_svg_surface_create_for_stream_internal (stream, width, height, CAIRO_SVG_VERSION_1_1);
diff --git a/src/cairoint.h b/src/cairoint.h
index fd78468..20160fd 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1831,6 +1831,7 @@ _cairo_stroke_style_fini (cairo_stroke_s
 
 extern const cairo_private cairo_surface_t _cairo_surface_nil;
 extern const cairo_private cairo_surface_t _cairo_surface_nil_read_error;
+extern const cairo_private cairo_surface_t _cairo_surface_nil_write_error;
 extern const cairo_private cairo_surface_t _cairo_surface_nil_file_not_found;
 
 cairo_private void
diff-tree bf3cbe7660f03f6b4139f4cf79a4007c682a84bd (from aea0831d24c3fca59b9eb9dd8acce9d9cdd13f26)
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Feb 8 15:28:14 2007 -0800

    [cairo-surface] Use a macro definition for all nil surfaces

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 6f48a68..4f32e83 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -41,107 +41,44 @@
 #include "cairo-surface-fallback-private.h"
 #include "cairo-clip-private.h"
 
-const cairo_surface_t _cairo_surface_nil = {
-    &cairo_image_surface_backend,	/* backend */
-    CAIRO_SURFACE_TYPE_IMAGE,
-    CAIRO_CONTENT_COLOR,
-    CAIRO_REF_COUNT_INVALID,		/* ref_count */
-    CAIRO_STATUS_NO_MEMORY,		/* status */
-    FALSE,				/* finished */
-    { 0,	/* size */
-      0,	/* num_elements */
-      0,	/* element_size */
-      NULL,	/* elements */
-    },					/* user_data */
-    { 1.0, 0.0,
-      0.0, 1.0,
-      0.0, 0.0
-    },					/* device_transform */
-    { 1.0, 0.0,
-      0.0, 1.0,
-      0.0, 0.0
-    },					/* device_transform_inverse */
-    0.0,				/* x_fallback_resolution */
-    0.0,				/* y_fallback_resolution */
-    NULL,				/* clip */
-    0,					/* next_clip_serial */
-    0,					/* current_clip_serial */
-    FALSE,				/* is_snapshot */
-    FALSE,				/* has_font_options */
-    { CAIRO_ANTIALIAS_DEFAULT,
-      CAIRO_SUBPIXEL_ORDER_DEFAULT,
-      CAIRO_HINT_STYLE_DEFAULT,
-      CAIRO_HINT_METRICS_DEFAULT
-    }					/* font_options */
-};
-
-const cairo_surface_t _cairo_surface_nil_file_not_found = {
-    &cairo_image_surface_backend,	/* backend */
-    CAIRO_SURFACE_TYPE_IMAGE,
-    CAIRO_CONTENT_COLOR,
-    CAIRO_REF_COUNT_INVALID,		/* ref_count */
-    CAIRO_STATUS_FILE_NOT_FOUND,	/* status */
-    FALSE,				/* finished */
-    { 0,	/* size */
-      0,	/* num_elements */
-      0,	/* element_size */
-      NULL,	/* elements */
-    },					/* user_data */
-    { 1.0, 0.0,
-      0.0, 1.0,
-      0.0, 0.0
-    },					/* device_transform */
-    { 1.0, 0.0,
-      0.0, 1.0,
-      0.0, 0.0
-    },					/* device_transform_inverse */
-    0.0,				/* x_fallback_resolution */
-    0.0,				/* y_fallback_resolution */
-    NULL,				/* clip */
-    0,					/* next_clip_serial */
-    0,					/* current_clip_serial */
-    FALSE,				/* is_snapshot */
-    FALSE,				/* has_font_options */
-    { CAIRO_ANTIALIAS_DEFAULT,
-      CAIRO_SUBPIXEL_ORDER_DEFAULT,
-      CAIRO_HINT_STYLE_DEFAULT,
-      CAIRO_HINT_METRICS_DEFAULT
-    }					/* font_options */
-};
-
-const cairo_surface_t _cairo_surface_nil_read_error = {
-    &cairo_image_surface_backend,	/* backend */
-    CAIRO_SURFACE_TYPE_IMAGE,
-    CAIRO_CONTENT_COLOR,
-    CAIRO_REF_COUNT_INVALID,		/* ref_count */
-    CAIRO_STATUS_READ_ERROR,		/* status */
-    FALSE,				/* finished */
-    { 0,	/* size */
-      0,	/* num_elements */
-      0,	/* element_size */
-      NULL,	/* elements */
-    },					/* user_data */
-    { 1.0, 0.0,
-      0.0, 1.0,
-      0.0, 0.0
-    },					/* device_transform */
-    { 1.0, 0.0,
-      0.0, 1.0,
-      0.0, 0.0
-    },					/* device_transform_inverse */
-    0.0,				/* x_fallback_resolution */
-    0.0,				/* y_fallback_resolution */
-    NULL,				/* clip */
-    0,					/* next_clip_serial */
-    0,					/* current_clip_serial */
-    FALSE,				/* is_snapshot */
-    FALSE,				/* has_font_options */
-    { CAIRO_ANTIALIAS_DEFAULT,
-      CAIRO_SUBPIXEL_ORDER_DEFAULT,
-      CAIRO_HINT_STYLE_DEFAULT,
-      CAIRO_HINT_METRICS_DEFAULT
-    }					/* font_options */
-};
+#define DEFINE_NIL_SURFACE(status, name)			\
+const cairo_surface_t name = {					\
+    &cairo_image_surface_backend,	/* backend */		\
+    CAIRO_SURFACE_TYPE_IMAGE,					\
+    CAIRO_CONTENT_COLOR,					\
+    CAIRO_REF_COUNT_INVALID,		/* ref_count */		\
+    status,				/* status */		\
+    FALSE,				/* finished */		\
+    { 0,	/* size */					\
+      0,	/* num_elements */				\
+      0,	/* element_size */				\
+      NULL,	/* elements */					\
+    },					/* user_data */		\
+    { 1.0, 0.0,							\
+      0.0, 1.0,							\
+      0.0, 0.0							\
+    },					/* device_transform */	\
+    { 1.0, 0.0,							\
+      0.0, 1.0,							\
+      0.0, 0.0							\
+    },					/* device_transform_inverse */	\
+    0.0,				/* x_fallback_resolution */	\
+    0.0,				/* y_fallback_resolution */	\
+    NULL,				/* clip */		\
+    0,					/* next_clip_serial */	\
+    0,					/* current_clip_serial */	\
+    FALSE,				/* is_snapshot */	\
+    FALSE,				/* has_font_options */	\
+    { CAIRO_ANTIALIAS_DEFAULT,					\
+      CAIRO_SUBPIXEL_ORDER_DEFAULT,				\
+      CAIRO_HINT_STYLE_DEFAULT,					\
+      CAIRO_HINT_METRICS_DEFAULT				\
+    }					/* font_options */	\
+}
+
+DEFINE_NIL_SURFACE(CAIRO_STATUS_NO_MEMORY, _cairo_surface_nil);
+DEFINE_NIL_SURFACE(CAIRO_STATUS_FILE_NOT_FOUND, _cairo_surface_nil_file_not_found);
+DEFINE_NIL_SURFACE(CAIRO_STATUS_READ_ERROR, _cairo_surface_nil_read_error);
 
 static void
 _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t *pattern,


More information about the cairo-commit mailing list