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

Chris Wilson ickle at kemper.freedesktop.org
Mon Apr 23 12:22:28 PDT 2012


 src/cairo-gl-gradient.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit e6a04c2f6749756bb032e9beb6c2ad0a12f8093d
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Mon Apr 23 17:15:31 2012 +0300

    gl: Fix creation of gradient ramps for GLESv2
    
    glTexImage2D is not allowed to perform an implicit format conversion
    with GLESv2, so fixup the internal format to match the incoming pixel
    format.

diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c
index ce7c0dd..5ac172f 100644
--- a/src/cairo-gl-gradient.c
+++ b/src/cairo-gl-gradient.c
@@ -206,6 +206,7 @@ _cairo_gl_gradient_create (cairo_gl_context_t           *ctx,
     cairo_gl_gradient_t *gradient;
     cairo_status_t status;
     int tex_width;
+    GLint internal_format;
     void *data;
 
     if ((unsigned int) ctx->max_texture_size / 2 <= n_stops)
@@ -247,7 +248,16 @@ _cairo_gl_gradient_create (cairo_gl_context_t           *ctx,
     if (unlikely (status))
 	goto cleanup_data;
 
-    glTexImage2D (ctx->tex_target, 0, GL_RGBA, tex_width, 1, 0,
+    /*
+     * In OpenGL ES 2.0 no format conversion is allowed i.e. 'internalFormat'
+     * must match 'format' in glTexImage2D.
+     */
+    if (_cairo_gl_get_flavor () == CAIRO_GL_FLAVOR_ES)
+	internal_format = GL_BGRA;
+    else
+	internal_format = GL_RGBA;
+
+    glTexImage2D (ctx->tex_target, 0, internal_format, tex_width, 1, 0,
 		  GL_BGRA, GL_UNSIGNED_BYTE, data);
 
     free (data);


More information about the cairo-commit mailing list