[cairo-commit] src/cairo-gl-shaders.c src/cairo-gl-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Feb 22 06:57:36 PST 2010


 src/cairo-gl-shaders.c |   17 ++++++++++++-----
 src/cairo-gl-surface.c |    6 ++++++
 2 files changed, 18 insertions(+), 5 deletions(-)

New commits:
commit 668ac047e6c790b0f8f58c52f169c688caa81678
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Feb 22 14:57:01 2010 +0000

    gl: Avoid attempting to create a program on GLSL-incapable h/w for spans

diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index 81d80a3..0a23159 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 e9a2061..69b6dd3 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;
 


More information about the cairo-commit mailing list