[cairo-commit] 2 commits - src/cairo.c src/cairo-gstate.c src/cairo-ps-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Wed May 30 06:18:51 PDT 2007


 src/cairo-gstate.c     |    2 +-
 src/cairo-ps-surface.c |   14 ++++++++++----
 src/cairo.c            |   12 +++++-------
 3 files changed, 16 insertions(+), 12 deletions(-)

New commits:
diff-tree de4dd4263cb5183b128a8fc80576ed7ddb239319 (from 9f4efa8a3ae6cbc194d89012286990582a6c8f5d)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 11 15:15:11 2007 +0100

    [cairo] Propagate surface->status on cairo_t creation.
    
    Set the cairo_t status to be the surface->status when the context is
    created, and special case the NO_MEMORY status in order to avoid a
    redundant allocation.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 7d38b88..fc8c545 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -96,7 +96,7 @@ _cairo_gstate_init (cairo_gstate_t  *gst
     if (gstate->source->status)
 	return CAIRO_STATUS_NO_MEMORY;
 
-    return CAIRO_STATUS_SUCCESS;
+    return target ? target->status : CAIRO_STATUS_NULL_POINTER;
 }
 
 /**
diff --git a/src/cairo.c b/src/cairo.c
index 5f251c8..6859e45 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -191,6 +191,10 @@ cairo_create (cairo_surface_t *target)
     cairo_t *cr;
     cairo_status_t status;
 
+    /* special case OOM in order to avoid another allocation */
+    if (target && target->status == CAIRO_STATUS_NO_MEMORY)
+	return (cairo_t *) &_cairo_nil;
+
     cr = malloc (sizeof (cairo_t));
     if (cr == NULL)
 	return (cairo_t *) &_cairo_nil;
@@ -200,17 +204,11 @@ cairo_create (cairo_surface_t *target)
     cr->status = CAIRO_STATUS_SUCCESS;
 
     _cairo_user_data_array_init (&cr->user_data);
+    _cairo_path_fixed_init (cr->path);
 
     cr->gstate = cr->gstate_tail;
     status = _cairo_gstate_init (cr->gstate, target);
 
-    _cairo_path_fixed_init (cr->path);
-
-    if (target == NULL) {
-	/* override status with user error */
-	status = CAIRO_STATUS_NULL_POINTER;
-    }
-
     if (status)
 	_cairo_set_error (cr, status);
 
diff-tree 9f4efa8a3ae6cbc194d89012286990582a6c8f5d (from 8010d46de4056e6c15b6891a06ef3d784c641b82)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 11 09:48:47 2007 +0100

    [cairo-ps-surface] Check status of glyph_lookup.
    
    Check for failure of _cairo_scaled_glyph_lookup() before preceeding to
    access the glyph and propagate the failure up the callstack as far as
    possible.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 87566d2..919a498 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -547,6 +547,8 @@ _cairo_ps_surface_emit_bitmap_glyph_data
 					 CAIRO_SCALED_GLYPH_INFO_METRICS|
 					 CAIRO_SCALED_GLYPH_INFO_SURFACE,
 					 &scaled_glyph);
+    if (status)
+	return status;
 
     image = scaled_glyph->surface;
     if (image->format != CAIRO_FORMAT_A1) {
@@ -602,7 +604,7 @@ _cairo_ps_surface_emit_bitmap_glyph_data
     return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 _cairo_ps_surface_emit_glyph (cairo_ps_surface_t	*surface,
 			      cairo_scaled_font_t	*scaled_font,
 			      unsigned long		 scaled_font_glyph_index,
@@ -626,6 +628,8 @@ _cairo_ps_surface_emit_glyph (cairo_ps_s
 
     if (status)
 	_cairo_surface_set_error (&surface->base, status);
+
+    return status;
 }
 
 static cairo_status_t
@@ -662,9 +666,11 @@ _cairo_ps_surface_emit_type3_font_subset
 				 -matrix.yy);
 
     for (i = 0; i < font_subset->num_glyphs; i++) {
-	_cairo_ps_surface_emit_glyph (surface,
-				      font_subset->scaled_font,
-				      font_subset->glyphs[i], i);
+	status = _cairo_ps_surface_emit_glyph (surface,
+				               font_subset->scaled_font,
+					       font_subset->glyphs[i], i);
+	if (status)
+	    return status;
     }
 
     _cairo_output_stream_printf (surface->final_stream,


More information about the cairo-commit mailing list