[cairo-commit] src/cairo-gl-glyphs.c

Benjamin Otte company at kemper.freedesktop.org
Tue Jun 22 13:02:09 PDT 2010


 src/cairo-gl-glyphs.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

New commits:
commit a4e292507cf7c2f960d040edd57b56a976c73da6
Author: Benjamin Otte <otte at redhat.com>
Date:   Tue Jun 22 22:01:25 2010 +0200

    gl: Propagate surface creation error instead of crashing

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index 140a9ea..4736e19 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -127,9 +127,10 @@ _cairo_gl_glyph_cache_lock (cairo_gl_glyph_cache_t *cache,
     return _cairo_rtree_pin (&cache->rtree, scaled_glyph->surface_private);
 }
 
-static cairo_gl_glyph_cache_t *
+static cairo_status_t
 cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
-				  cairo_format_t format)
+				  cairo_format_t format,
+                                  cairo_gl_glyph_cache_t **cache_out)
 {
     cairo_gl_glyph_cache_t *cache;
     cairo_content_t content;
@@ -148,7 +149,7 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
 	break;
     case CAIRO_FORMAT_INVALID:
 	ASSERT_NOT_REACHED;
-	return NULL;
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     }
 
     if (unlikely (cache->pattern.surface == NULL)) {
@@ -157,13 +158,19 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
                                            content,
                                            GLYPH_CACHE_WIDTH,
                                            GLYPH_CACHE_HEIGHT);
+        if (unlikely (surface->status)) {
+            cairo_status_t status = surface->status;
+            cairo_surface_destroy (surface);
+            return status;
+        }
         _cairo_surface_release_device_reference (surface);
         _cairo_pattern_init_for_surface (&cache->pattern, surface);
         cairo_surface_destroy (surface);
         cache->pattern.base.has_component_alpha = (content == CAIRO_CONTENT_COLOR_ALPHA);
     }
 
-    return cache;
+    *cache_out = cache;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -293,8 +300,11 @@ _render_glyphs (cairo_gl_surface_t	*dst,
 	}
 
 	if (scaled_glyph->surface->format != last_format) {
-	    cache = cairo_gl_context_get_glyph_cache (ctx,
-						      scaled_glyph->surface->format);
+	    status = cairo_gl_context_get_glyph_cache (ctx,
+						       scaled_glyph->surface->format,
+                                                       &cache);
+            if (unlikely (status))
+                goto FINISH;
 
 	    last_format = scaled_glyph->surface->format;
 


More information about the cairo-commit mailing list