From 668ac047e6c790b0f8f58c52f169c688caa81678 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 22 Feb 2010 14:57:01 +0000 Subject: gl: Avoid attempting to create a program on GLSL-incapable h/w for spans --- src/cairo-gl-shaders.c | 17 ++++++++++++----- src/cairo-gl-surface.c | 6 ++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index 81d80a36..0a231598 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -542,7 +542,13 @@ bind_texture_to_shader (GLuint program, const char *name, GLuint tex_unit) void _cairo_gl_use_program (cairo_gl_shader_program_t *program) { - get_impl()->use_program (program); + const shader_impl_t *impl; + + impl = get_impl (); + if (impl == NULL) + return; + + impl->use_program (program); } static const char *vs_no_coords = @@ -827,6 +833,9 @@ _cairo_gl_get_program (cairo_gl_context_t *ctx, if (program->build_failure) return CAIRO_INT_STATUS_UNSUPPORTED; + if (get_impl () == NULL) + return CAIRO_INT_STATUS_UNSUPPORTED; + source_source = source_sources[source]; mask_source = mask_sources[mask]; in_source = in_sources[in]; @@ -850,6 +859,8 @@ _cairo_gl_get_program (cairo_gl_context_t *ctx, strlen(mask_source) + strlen(in_source) + 1); + if (unlikely (fs_source == NULL)) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); if (source == CAIRO_GL_SHADER_SOURCE_CONSTANT || source == CAIRO_GL_SHADER_SOURCE_LINEAR_GRADIENT || @@ -873,9 +884,6 @@ _cairo_gl_get_program (cairo_gl_context_t *ctx, vs_source = vs_source_mask_coords; } - if (!fs_source) - return CAIRO_STATUS_NO_MEMORY; - sprintf(fs_source, "%s%s%s", source_source, mask_source, in_source); init_shader_program (program); @@ -902,6 +910,5 @@ _cairo_gl_get_program (cairo_gl_context_t *ctx, _cairo_gl_use_program (NULL); *out_program = program; - return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index e9a20611..69b6dd3e 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -2922,6 +2922,12 @@ _cairo_gl_surface_create_span_renderer (cairo_operator_t op, CAIRO_GL_SHADER_MASK_SPANS, CAIRO_GL_SHADER_IN_NORMAL, &renderer->setup.shader); + if (_cairo_status_is_error (status)) { + _cairo_gl_operand_destroy (&renderer->setup.src); + _cairo_gl_context_release (renderer->ctx); + free (renderer); + return _cairo_span_renderer_create_in_error (status); +} src_attributes = &renderer->setup.src.operand.texture.attributes; -- cgit v1.2.3