[cairo-commit] 5 commits - src/cairo-pdf-operators.c src/cairo-pdf-operators-private.h src/cairo-scaled-font-subsets.c src/cairo-surface.c src/.gitignore

Chris Wilson ickle at kemper.freedesktop.org
Wed Feb 20 03:25:08 PST 2008


 src/.gitignore                    |    1 
 src/cairo-pdf-operators-private.h |    2 -
 src/cairo-pdf-operators.c         |   10 ++++--
 src/cairo-scaled-font-subsets.c   |   57 ++++++++++++++++++++------------------
 src/cairo-surface.c               |   50 ++++++++++++++++++++++++++++++++-
 5 files changed, 88 insertions(+), 32 deletions(-)

New commits:
commit 9292c0a1b509ecea8415cdbc21415d9ce7615e04
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Feb 20 10:54:14 2008 +0000

    [gitignore] Ignore cairo-no-features.h
    
    Add the autogenerated header to the ignore list.

diff --git a/src/.gitignore b/src/.gitignore
index 33d29ca..551aa8f 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -9,6 +9,7 @@ Makefile.in
 *.loT
 *.pc
 cairo-features.h
+cairo-no-features.h
 cairo.def
 *.o
 *.obj
commit e6a8768a0446b9e537bb77bd309ad5719fe74451
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Feb 20 10:53:15 2008 +0000

    [cairo-scaled-font-subsets] Fix memleak on failure to reserve .notdef glyph.
    
    Remember to destroy the sub_font if we fail to reserve the .notdef glyph
    during construction.
    
    Whilst in the vicinity, adjust the function prototype to remove
    duplicated calls to _cairo_error().

diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 9121aab..310bafb 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -217,23 +217,22 @@ _cairo_sub_font_init_key (cairo_sub_font_t	*sub_font,
     }
 }
 
-static cairo_sub_font_t *
+static cairo_status_t
 _cairo_sub_font_create (cairo_scaled_font_subsets_t	*parent,
 			cairo_scaled_font_t		*scaled_font,
 			unsigned int			 font_id,
 			int				 max_glyphs_per_subset,
                         cairo_bool_t                     is_scaled,
-                        cairo_bool_t                     is_composite)
+			cairo_bool_t                     is_composite,
+			cairo_sub_font_t               **sub_font_out)
 {
     cairo_sub_font_t *sub_font;
     cairo_status_t status;
     cairo_scaled_font_subsets_glyph_t subset_glyph;
 
     sub_font = malloc (sizeof (cairo_sub_font_t));
-    if (sub_font == NULL) {
-	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-	return NULL;
-    }
+    if (sub_font == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     sub_font->is_scaled = is_scaled;
     sub_font->is_composite = is_composite;
@@ -248,19 +247,21 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t	*parent,
     sub_font->max_glyphs_per_subset = max_glyphs_per_subset;
 
     sub_font->sub_font_glyphs = _cairo_hash_table_create (_cairo_sub_font_glyphs_equal);
-    if (! sub_font->sub_font_glyphs) {
+    if (sub_font->sub_font_glyphs == NULL) {
 	free (sub_font);
-	return NULL;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     /* Reserve first glyph in subset for the .notdef glyph */
     status = _cairo_sub_font_map_glyph (sub_font, 0, &subset_glyph);
     if (status) {
-	_cairo_error_throw (status);
-	return NULL;
+	_cairo_hash_table_destroy (sub_font->sub_font_glyphs);
+	free (sub_font);
+	return status;
     }
 
-    return sub_font;
+    *sub_font_out = sub_font;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -584,15 +585,16 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t	*subsets,
                 subset_glyph->is_composite = FALSE;
             }
 
-            sub_font = _cairo_sub_font_create (subsets,
-                                               unscaled_font,
-                                               subsets->num_sub_fonts,
-                                               max_glyphs,
-                                               subset_glyph->is_scaled,
-                                               subset_glyph->is_composite);
-            if (sub_font == NULL) {
+            status = _cairo_sub_font_create (subsets,
+					     unscaled_font,
+					     subsets->num_sub_fonts,
+					     max_glyphs,
+					     subset_glyph->is_scaled,
+					     subset_glyph->is_composite,
+					     &sub_font);
+            if (status) {
 		cairo_scaled_font_destroy (unscaled_font);
-                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+                return status;
 	    }
 
             status = _cairo_hash_table_insert (subsets->unscaled_sub_fonts,
@@ -618,15 +620,16 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t	*subsets,
             else
                 max_glyphs = MAX_GLYPHS_PER_SIMPLE_FONT;
 
-            sub_font = _cairo_sub_font_create (subsets,
-                                               cairo_scaled_font_reference (scaled_font),
-                                               subsets->num_sub_fonts,
-                                               max_glyphs,
-                                               subset_glyph->is_scaled,
-                                               subset_glyph->is_composite);
-            if (sub_font == NULL) {
+            status = _cairo_sub_font_create (subsets,
+					     cairo_scaled_font_reference (scaled_font),
+					     subsets->num_sub_fonts,
+					     max_glyphs,
+					     subset_glyph->is_scaled,
+					     subset_glyph->is_composite,
+					     &sub_font);
+            if (status) {
 		cairo_scaled_font_destroy (scaled_font);
-                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+                return status;
 	    }
 
             status = _cairo_hash_table_insert (subsets->scaled_sub_fonts,
commit e208f31236af6b2012d725696485f96fe4acd863
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 19 15:14:37 2008 +0000

    [cairo-surface] Check surface status on internal paths as well.
    
    Return any error status on the surface to the caller.

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index ac594ae..42ee3ec 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -941,6 +941,9 @@ _cairo_surface_acquire_source_image (cairo_surface_t         *surface,
 {
     assert (!surface->finished);
 
+    if (surface->status)
+	return surface->status;
+
     if (surface->backend->acquire_source_image == NULL)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
@@ -1007,6 +1010,9 @@ _cairo_surface_acquire_dest_image (cairo_surface_t         *surface,
 {
     assert (!surface->finished);
 
+    if (surface->status)
+	return surface->status;
+
     if (surface->backend->acquire_dest_image == NULL)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
@@ -1077,6 +1083,9 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
     cairo_image_surface_t *image;
     void *image_extra;
 
+    if (surface->status)
+	return surface->status;
+
     if (surface->finished)
 	return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
 
@@ -1114,7 +1123,7 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
     if (*clone_out != src) {
         (*clone_out)->device_transform = src->device_transform;
         (*clone_out)->device_transform_inverse = src->device_transform_inverse;
-    }	
+    }
 
     return status;
 }
@@ -1139,6 +1148,9 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
 cairo_surface_t *
 _cairo_surface_snapshot (cairo_surface_t *surface)
 {
+    if (surface->status)
+	return _cairo_surface_create_in_error (surface->status);
+
     if (surface->finished)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
 
@@ -1298,6 +1310,9 @@ _cairo_surface_fill_region (cairo_surface_t	   *surface,
 
     assert (! surface->is_snapshot);
 
+    if (surface->status)
+	return surface->status;
+
     num_boxes = _cairo_region_num_boxes (region);
 
     if (num_boxes == 0)
@@ -1398,6 +1413,9 @@ _cairo_surface_paint (cairo_surface_t	*surface,
 
     assert (! surface->is_snapshot);
 
+    if (surface->status)
+	return surface->status;
+
     status = _cairo_surface_copy_pattern_for_destination (source, surface, &dev_source);
     if (status)
 	return _cairo_surface_set_error (surface, status);
@@ -1428,6 +1446,9 @@ _cairo_surface_mask (cairo_surface_t	*surface,
 
     assert (! surface->is_snapshot);
 
+    if (surface->status)
+	return surface->status;
+
     status = _cairo_surface_copy_pattern_for_destination (source, surface, &dev_source);
     if (status)
 	goto FINISH;
@@ -1471,6 +1492,9 @@ _cairo_surface_fill_stroke (cairo_surface_t	    *surface,
 {
     cairo_status_t status;
 
+    if (surface->status)
+	return surface->status;
+
     if (surface->backend->fill_stroke) {
 	cairo_pattern_t *dev_stroke_source;
 	cairo_pattern_t *dev_fill_source;
@@ -1534,6 +1558,9 @@ _cairo_surface_stroke (cairo_surface_t		*surface,
 
     assert (! surface->is_snapshot);
 
+    if (surface->status)
+	return surface->status;
+
     status = _cairo_surface_copy_pattern_for_destination (source, surface, &dev_source);
     if (status)
 	return _cairo_surface_set_error (surface, status);
@@ -1575,6 +1602,9 @@ _cairo_surface_fill (cairo_surface_t	*surface,
 
     assert (! surface->is_snapshot);
 
+    if (surface->status)
+	return surface->status;
+
     status = _cairo_surface_copy_pattern_for_destination (source, surface, &dev_source);
     if (status)
 	return _cairo_surface_set_error (surface, status);
@@ -1862,6 +1892,9 @@ _cairo_surface_set_clip_path_recursive (cairo_surface_t *surface,
 {
     cairo_status_t status;
 
+    if (surface->status)
+	return surface->status;
+
     if (clip_path == NULL)
 	return CAIRO_STATUS_SUCCESS;
 
@@ -1933,6 +1966,9 @@ _cairo_surface_set_empty_clip_path (cairo_surface_t *surface,
     cairo_path_fixed_t path;
     cairo_status_t status;
 
+    if (surface->status)
+	return surface->status;
+
     _cairo_path_fixed_init (&path);
 
     status = surface->backend->intersect_clip_path (surface,
@@ -2058,6 +2094,9 @@ _cairo_surface_show_glyphs (cairo_surface_t	*surface,
 
     assert (! surface->is_snapshot);
 
+    if (surface->status)
+	return surface->status;
+
     if (!num_glyphs)
 	return CAIRO_STATUS_SUCCESS;
 
@@ -2263,6 +2302,9 @@ _cairo_surface_composite_fixup_unbounded (cairo_surface_t            *dst,
 
     assert (! dst->is_snapshot);
 
+    if (dst->status)
+	return dst->status;
+
     /* The RENDER/libpixman operators are clipped to the bounds of the untransformed,
      * non-repeating sources and masks. Other sources and masks can be ignored.
      */
@@ -2338,6 +2380,9 @@ _cairo_surface_composite_shape_fixup_unbounded (cairo_surface_t            *dst,
 
     assert (! dst->is_snapshot);
 
+    if (dst->status)
+	return dst->status;
+
     /* The RENDER/libpixman operators are clipped to the bounds of the untransformed,
      * non-repeating sources and masks. Other sources and masks can be ignored.
      */
@@ -2413,6 +2458,9 @@ _cairo_surface_set_resolution (cairo_surface_t *surface,
 			       double x_res,
 			       double y_res)
 {
+    if (surface->status)
+	return;
+
     surface->x_resolution = x_res;
     surface->y_resolution = y_res;
 }
commit 1d59daecfe1078ba2ad56f80b35c934312dc4f6b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 19 15:13:53 2008 +0000

    [cairo-pdf-operators] Cleanup word_wrap_stream
    
    Ensure that the stream is destroyed on the error paths.

diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 191e26b..fb685b5 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -672,7 +672,7 @@ _cairo_pdf_operators_show_glyphs (cairo_pdf_operators_t		*pdf_operators,
     unsigned int current_subset_id = (unsigned int)-1;
     cairo_scaled_font_subsets_glyph_t subset_glyph;
     cairo_bool_t diagonal, in_TJ;
-    cairo_status_t status;
+    cairo_status_t status, status_ignored;
     double Tlm_x = 0, Tlm_y = 0;
     double Tm_x = 0, y;
     int i, hex_width;
@@ -700,8 +700,10 @@ _cairo_pdf_operators_show_glyphs (cairo_pdf_operators_t		*pdf_operators,
         status = _cairo_scaled_font_subsets_map_glyph (pdf_operators->font_subsets,
                                                        scaled_font, glyphs[i].index,
                                                        &subset_glyph);
-	if (status)
+	if (status) {
+	    status_ignored = _cairo_output_stream_destroy (word_wrap_stream);
             return status;
+	}
 
         if (subset_glyph.is_composite)
             hex_width = 4;
@@ -728,8 +730,10 @@ _cairo_pdf_operators_show_glyphs (cairo_pdf_operators_t		*pdf_operators,
 		status = pdf_operators->use_font_subset (subset_glyph.font_id,
 							 subset_glyph.subset_id,
 							 pdf_operators->use_font_subset_closure);
-		if (status)
+		if (status) {
+		    status_ignored = _cairo_output_stream_destroy (word_wrap_stream);
 		    return status;
+		}
 	    }
         }
 
commit aac5650beebb40068767a7d3ffedf634a3da5002
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 19 14:39:13 2008 +0000

    [pdf-operators] Missing private markup.
    
    Fixup make check by adding the required cairo_private markup.

diff --git a/src/cairo-pdf-operators-private.h b/src/cairo-pdf-operators-private.h
index 36bd2e1..e66839c 100644
--- a/src/cairo-pdf-operators-private.h
+++ b/src/cairo-pdf-operators-private.h
@@ -97,7 +97,7 @@ _cairo_pdf_operators_fill (cairo_pdf_operators_t 	*pdf_operators,
 			   cairo_path_fixed_t		*path,
 			   cairo_fill_rule_t	 	fill_rule);
 
-cairo_int_status_t
+cairo_private cairo_int_status_t
 _cairo_pdf_operators_fill_stroke (cairo_pdf_operators_t 	*pdf_operators,
 				  cairo_path_fixed_t		*path,
 				  cairo_fill_rule_t	 	 fill_rule,


More information about the cairo-commit mailing list