[cairo-commit] 3 commits - perf/cairo-stats.c src/cairo.c src/cairo-surface.c

Carl Worth cworth at kemper.freedesktop.org
Fri Mar 2 03:13:02 PST 2007


 perf/cairo-stats.c  |    2 +-
 src/cairo-surface.c |   11 +++++++++--
 src/cairo.c         |   32 +++++++++++++++++++++++---------
 3 files changed, 33 insertions(+), 12 deletions(-)

New commits:
diff-tree 4e0f0d9425e2677e75681b2416e7ee4c4e87440c (from b0c086fce45a72ea3bf0052641de63bf08e5e5d5)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 03:11:10 2007 -0800

    Don't crash if backend->create_similar returns a nil surface
    
    This fixes the bug reported here:
    
    	cairo crashes in cairo_create_simular if nil surface returned by other->backend->create_similar
    	https://bugs.freedesktop.org/show_bug.cgi?id=9844

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 934a667..19d2d08 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -219,10 +219,17 @@ _cairo_surface_create_similar_scratch (c
     if (other->status)
 	return (cairo_surface_t*) &_cairo_surface_nil;
 
-    if (other->backend->create_similar)
+    if (other->backend->create_similar) {
 	surface = other->backend->create_similar (other, content, width, height);
+	/* It's not an error if the backend didn't create a valid
+	 * surface---it may just not be supported. */
+	if (surface && surface->status) {
+	    cairo_surface_destroy (surface);
+	    surface = NULL;
+	}
+    }
 
-    if (!surface)
+    if (surface == NULL)
 	surface = cairo_image_surface_create (format, width, height);
 
     cairo_surface_get_font_options (other, &options);
diff-tree b0c086fce45a72ea3bf0052641de63bf08e5e5d5 (from 5f386bb15a234983090beb4f85dfee200dac1b4b)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 02:51:53 2007 -0800

    Update documentation for cairo_get_scaled_font and cairo_get_font_face
    
    There was some leftover cut-and-paste description of get_font_face
    in the documentation for get_scaled_font. That turned out to be a
    good thing as it alerted me to the fact that the get_font_face
    documentation was stale as well.
    
    Add description of the 'nil' object return values, rather than NULL.

diff --git a/src/cairo.c b/src/cairo.c
index d522032..b487bab 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2429,10 +2429,17 @@ cairo_set_font_face (cairo_t           *
  *
  * Gets the current font face for a #cairo_t.
  *
- * Return value: the current font object. Can return %NULL
- *   on out-of-memory or if the context is already in
- *   an error state. This object is owned by cairo. To keep
- *   a reference to it, you must call cairo_font_face_reference().
+ * Return value: the current font face.  This object is owned by
+ * cairo. To keep a reference to it, you must call
+ * cairo_font_face_reference.
+ *
+ * This function never returns %NULL. If memory cannot be allocated, a
+ * special "nil" #cairo_font_face_t object will be returned on which
+ * cairo_font_face_status() returns %CAIRO_STATUS_NO_MEMORY. Using
+ * this nil object will cause its error state to propagate to other
+ * objects it is passed to, (for example, calling
+ * cairo_set_font_face() with a nil font will trigger an error that
+ * will shutdown the cairo_t object).
  **/
 cairo_font_face_t *
 cairo_get_font_face (cairo_t *cr)
@@ -2599,12 +2606,19 @@ BAIL:
  * cairo_get_scaled_font:
  * @cr: a #cairo_t
  *
- * Gets the current font face for a #cairo_t.
+ * Gets the current scaled font for a #cairo_t.
  *
- * Return value: the current font object. Can return %NULL
- *   on out-of-memory or if the context is already in
- *   an error state. This object is owned by cairo. To keep
- *   a reference to it, you must call cairo_font_face_reference().
+ * Return value: the current scaled font. This object is owned by
+ * cairo. To keep a reference to it, you must call
+ * cairo_scaled_font_reference().
+ *
+ * This function never returns %NULL. If memory cannot be allocated, a
+ * special "nil" #cairo_scaled_font_t object will be returned on which
+ * cairo_scaled_font_status() returns %CAIRO_STATUS_NO_MEMORY. Using
+ * this nil object will cause its error state to propagate to other
+ * objects it is passed to, (for example, calling
+ * cairo_set_scaled_font() with a nil font will trigger an error that
+ * will shutdown the cairo_t object).
  *
  * Since: 1.4
  **/
diff-tree 5f386bb15a234983090beb4f85dfee200dac1b4b (from d48f31370172cddb85ae17a12faed2abf651ee83)
Author: Jeff Muizelaar <jeff at infidigm.net>
Date:   Wed Feb 28 13:37:21 2007 -0500

    Use a closed interval when eliminating outliers from performance measurements
    
    When choosing the samples that are not outliers we use a half-open interval
    (outlier_min <= x < outlier_max). This causes all of the samples to be
    discarded when the interquartile range is 0 because none of them are less
    than outlier_max. Fix the problem and make the test more consistent by
    using a closed interval (outliner_min <= x <= outlier_max).

diff --git a/perf/cairo-stats.c b/perf/cairo-stats.c
index ba652d0..2c6c7dc 100644
--- a/perf/cairo-stats.c
+++ b/perf/cairo-stats.c
@@ -75,7 +75,7 @@ _cairo_stats_compute (cairo_stats_t		*st
 
     i = min_valid;
     num_valid = 0;
-    while (i + num_valid < num_values && values[i+num_valid] < outlier_max)
+    while (i + num_valid < num_values && values[i+num_valid] <= outlier_max)
 	num_valid++;
 
     stats->iterations = num_valid;


More information about the cairo-commit mailing list