diff options
author | Benjamin Otte <otte@redhat.com> | 2010-06-22 22:01:25 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-06-22 22:01:25 +0200 |
commit | a4e292507cf7c2f960d040edd57b56a976c73da6 (patch) | |
tree | 6ce326fe181b9d08c3868f51ab2eb02a7c8dddd4 | |
parent | faa4e6761c8f74a1acaa7ccc5bc8bb23b2f5cdb1 (diff) |
gl: Propagate surface creation error instead of crashing
-rw-r--r-- | src/cairo-gl-glyphs.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c index 140a9ea5..4736e190 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; |