summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog4
-rw-r--r--debian/patches/81-gl-Fail-if-GL-implementation-doesn-t-support-shaders.patch42
-rw-r--r--debian/patches/82-gl-Remove-unnecessary-checks-for-NULL-shader-impleme.patch81
-rw-r--r--debian/patches/83-gl-Remove-fixed-function-related-code-paths.patch245
-rw-r--r--debian/patches/84-gl-Add-entry-for-UniformMatrix4fv-in-the-gl-dispatch.patch43
-rw-r--r--debian/patches/85-gl-Add-function-to-bind-a-4x4-float-matrix-shader-un.patch92
-rw-r--r--debian/patches/86-gl-Replace-ftransform-with-manual-coordinate-calcula.patch33
-rw-r--r--debian/patches/87-gl-Use-a-custom-shader-uniform-for-the-ModelViewProj.patch137
-rw-r--r--debian/patches/88-gl-Add-gl-dispatch-entries-for-functions-related-to-.patch56
-rw-r--r--debian/patches/89-gl-Replace-built-in-vertex-attributes-with-custom-at.patch230
-rw-r--r--debian/patches/90-gl-Don-t-reset-the-FBO-draw-readbuffers-every-time-w.patch45
-rw-r--r--debian/patches/91-egl-Fix-eglMakeCurrent-for-egl-surfaces.patch28
-rw-r--r--debian/patches/92-egl-Ensure-that-the-dummy-pbuffer-surface-is-compati.patch64
-rw-r--r--debian/patches/93-boilerplate-egl-Ensure-that-we-are-using-an-RGBA32-e.patch58
-rw-r--r--debian/patches/94-gl-Add-a-first-bit-of-general-documentation-on-cairo.patch56
-rw-r--r--debian/patches/95-gl-Take-advantage-of-GLX_MESA_multithread_makecurren.patch71
-rw-r--r--debian/patches/96-gl-Bind-samplers-just-once-at-program-compile-time.patch163
-rw-r--r--debian/patches/series17
18 files changed, 1465 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 94b6e1d..175fe71 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,10 @@ cairo (1.11.2-1) UNRELEASED; urgency=low
+ Add cairo_pattern_create_mesh and cairo_pattern_mesh_* symbols.
* debian/rules:
+ Bump shlibs for libcairo2 due to new symbols.
+ * debian/patches:
+ + Add 8*.patch and 9*.patch, cherry-picked from upstream between
+ 1.11.2 and 17169a1e51 to make wayland-demos mostly work).
+ Closes: #630811.
-- Cyril Brulebois <kibi@debian.org> Sun, 19 Jun 2011 22:42:20 +0200
diff --git a/debian/patches/81-gl-Fail-if-GL-implementation-doesn-t-support-shaders.patch b/debian/patches/81-gl-Fail-if-GL-implementation-doesn-t-support-shaders.patch
new file mode 100644
index 0000000..bcc4223
--- /dev/null
+++ b/debian/patches/81-gl-Fail-if-GL-implementation-doesn-t-support-shaders.patch
@@ -0,0 +1,42 @@
+From d9124cb697d5f0f40a49ce53339a199f2b92ecc9 Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Fri, 28 Jan 2011 15:02:52 +0200
+Subject: [PATCH 01/16] gl: Fail if GL implementation doesn't support shaders
+
+The non-shaders implementation was never tuned for fixed-function GL
+implementation, the maintainers are not interested in supporting it,
+and the hardware is rather rare at this point. This lets us focus on
+the implementation for modern hardware, which needs plenty of work
+still.
+
+Reviewed-by: Eric Anholt <eric@anholt.net>
+(cherry picked from commit 037c9ba7e27bdd33a4fefa43dad68ce0d25e35ad)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-shaders.c | 6 ++++++
+ 1 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index 2b31bfc..6a42fd1 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -359,9 +359,15 @@ _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx)
+ (_cairo_gl_has_extension ("GL_ARB_shader_objects") &&
+ _cairo_gl_has_extension ("GL_ARB_fragment_shader") &&
+ _cairo_gl_has_extension ("GL_ARB_vertex_shader")))
++ {
+ ctx->shader_impl = &shader_impl_core_2_0;
++ }
+ else
++ {
+ ctx->shader_impl = NULL;
++ fprintf (stderr, "Error: The cairo gl backend requires shader support!\n");
++ return CAIRO_STATUS_DEVICE_ERROR;
++ }
+
+ memset (ctx->vertex_shaders, 0, sizeof (ctx->vertex_shaders));
+
+--
+1.7.5.4
+
diff --git a/debian/patches/82-gl-Remove-unnecessary-checks-for-NULL-shader-impleme.patch b/debian/patches/82-gl-Remove-unnecessary-checks-for-NULL-shader-impleme.patch
new file mode 100644
index 0000000..d78cf50
--- /dev/null
+++ b/debian/patches/82-gl-Remove-unnecessary-checks-for-NULL-shader-impleme.patch
@@ -0,0 +1,81 @@
+From f3c397add214a40e254e0df169eb809055cc507d Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Fri, 28 Jan 2011 15:02:53 +0200
+Subject: [PATCH 02/16] gl: Remove unnecessary checks for NULL shader
+ implementation
+
+Due to the fact that we fail if the system doesn't support shaders, we
+now always have a valid shader implementation.
+
+Reviewed-by: Eric Anholt <eric@anholt.net>
+(cherry picked from commit f6ca11694b7935408446b36a17bfee024237dbbf)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-shaders.c | 29 ++++++++---------------------
+ 1 files changed, 8 insertions(+), 21 deletions(-)
+
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index 6a42fd1..a39883d 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -379,16 +379,14 @@ _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx)
+ if (unlikely (status))
+ return status;
+
+- if (ctx->shader_impl != NULL) {
+- _cairo_gl_shader_init (&ctx->fill_rectangles_shader);
+- status = _cairo_gl_shader_compile (ctx,
+- &ctx->fill_rectangles_shader,
+- CAIRO_GL_VAR_NONE,
+- CAIRO_GL_VAR_NONE,
+- fill_fs_source);
+- if (unlikely (status))
+- return status;
+- }
++ _cairo_gl_shader_init (&ctx->fill_rectangles_shader);
++ status = _cairo_gl_shader_compile (ctx,
++ &ctx->fill_rectangles_shader,
++ CAIRO_GL_VAR_NONE,
++ CAIRO_GL_VAR_NONE,
++ fill_fs_source);
++ if (unlikely (status))
++ return status;
+
+ return CAIRO_STATUS_SUCCESS;
+ }
+@@ -719,9 +717,6 @@ _cairo_gl_shader_compile (cairo_gl_context_t *ctx,
+ unsigned int vertex_shader;
+ cairo_status_t status;
+
+- if (ctx->shader_impl == NULL)
+- return CAIRO_STATUS_SUCCESS;
+-
+ assert (shader->program == 0);
+
+ vertex_shader = cairo_gl_var_type_hash (src, mask, CAIRO_GL_VAR_NONE);
+@@ -813,9 +808,6 @@ void
+ _cairo_gl_set_shader (cairo_gl_context_t *ctx,
+ cairo_gl_shader_t *shader)
+ {
+- if (ctx->shader_impl == NULL)
+- return;
+-
+ if (ctx->current_shader == shader)
+ return;
+
+@@ -835,11 +827,6 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
+ char *fs_source;
+ cairo_status_t status;
+
+- if (ctx->shader_impl == NULL) {
+- *shader = NULL;
+- return CAIRO_STATUS_SUCCESS;
+- }
+-
+ lookup.src = source;
+ lookup.mask = mask;
+ lookup.dest = CAIRO_GL_OPERAND_NONE;
+--
+1.7.5.4
+
diff --git a/debian/patches/83-gl-Remove-fixed-function-related-code-paths.patch b/debian/patches/83-gl-Remove-fixed-function-related-code-paths.patch
new file mode 100644
index 0000000..f45cfa2
--- /dev/null
+++ b/debian/patches/83-gl-Remove-fixed-function-related-code-paths.patch
@@ -0,0 +1,245 @@
+From 05035c4b928ab4fcffefcdd8e996989090dae936 Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Fri, 28 Jan 2011 15:02:54 +0200
+Subject: [PATCH 03/16] gl: Remove fixed-function related code paths
+
+Fixed-function related code paths are no longer used, as we require shader
+support for the gl backend.
+
+Reviewed-by: Eric Anholt <eric@anholt.net>
+(cherry picked from commit 7f15319621a71fb01ea41c4efc34bf1f54505ef5)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-composite.c | 106 +--------------------------------------------
+ src/cairo-gl-device.c | 6 ---
+ src/cairo-gl-private.h | 1 -
+ 3 files changed, 3 insertions(+), 110 deletions(-)
+
+diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
+index 5017f55..a32e00d 100644
+--- a/src/cairo-gl-composite.c
++++ b/src/cairo-gl-composite.c
+@@ -414,9 +414,6 @@ static void
+ _cairo_gl_composite_bind_to_shader (cairo_gl_context_t *ctx,
+ cairo_gl_composite_t *setup)
+ {
+- if (ctx->current_shader == NULL)
+- return;
+-
+ _cairo_gl_operand_bind_to_shader (ctx, &setup->src, CAIRO_GL_TEX_SOURCE);
+ _cairo_gl_operand_bind_to_shader (ctx, &setup->mask, CAIRO_GL_TEX_MASK);
+ }
+@@ -472,68 +469,6 @@ _cairo_gl_texture_set_filter (cairo_gl_context_t *ctx,
+ }
+ }
+
+-static void
+-_cairo_gl_operand_setup_fixed (cairo_gl_operand_t *operand,
+- cairo_gl_tex_t tex_unit)
+-{
+- switch (operand->type) {
+- case CAIRO_GL_OPERAND_CONSTANT:
+- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, operand->constant.color);
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB, GL_CONSTANT);
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_CONSTANT);
+- break;
+- case CAIRO_GL_OPERAND_TEXTURE:
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE0 + tex_unit);
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE0 + tex_unit);
+- break;
+- case CAIRO_GL_OPERAND_SPANS:
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR);
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR);
+- break;
+- case CAIRO_GL_OPERAND_COUNT:
+- default:
+- ASSERT_NOT_REACHED;
+- case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
+- case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
+- case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
+- case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
+- case CAIRO_GL_OPERAND_NONE:
+- return;
+- }
+-
+- switch (tex_unit) {
+- case CAIRO_GL_TEX_TEMP:
+- default:
+- ASSERT_NOT_REACHED;
+- break;
+- case CAIRO_GL_TEX_SOURCE:
+- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
+- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+- break;
+-
+- case CAIRO_GL_TEX_MASK:
+- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
+- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+-
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
+- glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS);
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+-
+- if (operand->type == CAIRO_GL_OPERAND_TEXTURE &&
+- operand->texture.attributes.has_component_alpha)
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+- else
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_ALPHA);
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+- break;
+- }
+-}
+-
+ static cairo_bool_t
+ _cairo_gl_operand_needs_setup (cairo_gl_operand_t *dest,
+ cairo_gl_operand_t *source,
+@@ -577,8 +512,7 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ cairo_gl_tex_t tex_unit,
+ cairo_gl_operand_t *operand,
+ unsigned int vertex_size,
+- unsigned int vertex_offset,
+- cairo_bool_t use_shaders)
++ unsigned int vertex_offset)
+ {
+ cairo_bool_t needs_setup;
+
+@@ -612,17 +546,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ glEnableClientState (GL_COLOR_ARRAY);
+ /* fall through */
+ case CAIRO_GL_OPERAND_CONSTANT:
+- if (! use_shaders) {
+- glActiveTexture (GL_TEXTURE0 + tex_unit);
+- /* Have to have a dummy texture bound in order to use the combiner unit. */
+- glBindTexture (ctx->tex_target, ctx->dummy_tex);
+- glEnable (ctx->tex_target);
+- }
+ break;
+ case CAIRO_GL_OPERAND_TEXTURE:
+ glActiveTexture (GL_TEXTURE0 + tex_unit);
+ glBindTexture (ctx->tex_target, operand->texture.tex);
+- glEnable (ctx->tex_target);
+ _cairo_gl_texture_set_extend (ctx, ctx->tex_target,
+ operand->texture.attributes.extend);
+ _cairo_gl_texture_set_filter (ctx, ctx->tex_target,
+@@ -642,7 +569,6 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ glBindTexture (GL_TEXTURE_1D, operand->gradient.gradient->tex);
+ _cairo_gl_texture_set_extend (ctx, GL_TEXTURE_1D, operand->gradient.extend);
+ _cairo_gl_texture_set_filter (ctx, GL_TEXTURE_1D, CAIRO_FILTER_BILINEAR);
+- glEnable (GL_TEXTURE_1D);
+
+ glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+ glTexCoordPointer (2, GL_FLOAT, vertex_size,
+@@ -650,9 +576,6 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+ break;
+ }
+-
+- if (! use_shaders)
+- _cairo_gl_operand_setup_fixed (operand, tex_unit);
+ }
+
+ void
+@@ -671,14 +594,9 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
+ glDisableClientState (GL_COLOR_ARRAY);
+ /* fall through */
+ case CAIRO_GL_OPERAND_CONSTANT:
+- if (ctx->current_shader == NULL) {
+- glActiveTexture (GL_TEXTURE0 + tex_unit);
+- glDisable (ctx->tex_target);
+- }
+ break;
+ case CAIRO_GL_OPERAND_TEXTURE:
+ glActiveTexture (GL_TEXTURE0 + tex_unit);
+- glDisable (ctx->tex_target);
+ glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+ glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+ break;
+@@ -688,7 +606,6 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
+ _cairo_gl_gradient_destroy (ctx->operands[tex_unit].gradient.gradient);
+ glActiveTexture (GL_TEXTURE0 + tex_unit);
+- glDisable (GL_TEXTURE_1D);
+ glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+ glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+ break;
+@@ -697,21 +614,6 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
+ memset (&ctx->operands[tex_unit], 0, sizeof (cairo_gl_operand_t));
+ }
+
+-/* Swizzles the source for creating the "source alpha" value
+- * (src.aaaa * mask.argb) required by component alpha rendering.
+- */
+-static void
+-_cairo_gl_set_src_alpha (cairo_gl_context_t *ctx,
+- cairo_bool_t activate)
+-{
+- if (ctx->current_shader)
+- return;
+-
+- glActiveTexture (GL_TEXTURE0);
+-
+- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, activate ? GL_SRC_ALPHA : GL_SRC_COLOR);
+-}
+-
+ static void
+ _cairo_gl_set_operator (cairo_gl_context_t *ctx,
+ cairo_operator_t op,
+@@ -962,8 +864,8 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
+ glEnableClientState (GL_VERTEX_ARRAY);
+ }
+
+- _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src, vertex_size, dst_size, shader != NULL);
+- _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_MASK, &setup->mask, vertex_size, dst_size + src_size, shader != NULL);
++ _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src, vertex_size, dst_size);
++ _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_MASK, &setup->mask, vertex_size, dst_size + src_size);
+
+ _cairo_gl_set_operator (ctx,
+ setup->op,
+@@ -1010,9 +912,7 @@ _cairo_gl_composite_draw (cairo_gl_context_t *ctx,
+
+ _cairo_gl_set_shader (ctx, ctx->pre_shader);
+ _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_DEST_OUT, TRUE);
+- _cairo_gl_set_src_alpha (ctx, TRUE);
+ glDrawArrays (GL_TRIANGLES, 0, count);
+- _cairo_gl_set_src_alpha (ctx, FALSE);
+
+ _cairo_gl_set_shader (ctx, prev_shader);
+ _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_ADD, TRUE);
+diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
+index 048d48b..25423e0 100644
+--- a/src/cairo-gl-device.c
++++ b/src/cairo-gl-device.c
+@@ -196,12 +196,6 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
+ if (unlikely (status))
+ return status;
+
+- /* Set up the dummy texture for tex_env_combine with constant color. */
+- glGenTextures (1, &ctx->dummy_tex);
+- glBindTexture (ctx->tex_target, ctx->dummy_tex);
+- glTexImage2D (ctx->tex_target, 0, GL_RGBA, 1, 1, 0,
+- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+-
+ /* PBO for any sort of texture upload */
+ dispatch->GenBuffers (1, &ctx->texture_load_pbo);
+ dispatch->GenBuffers (1, &ctx->vbo);
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index ace4032..6cea8c0 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -225,7 +225,6 @@ typedef struct _cairo_gl_dispatch {
+ struct _cairo_gl_context {
+ cairo_device_t base;
+
+- GLuint dummy_tex;
+ GLuint texture_load_pbo;
+ GLuint vbo;
+ GLint max_framebuffer_size;
+--
+1.7.5.4
+
diff --git a/debian/patches/84-gl-Add-entry-for-UniformMatrix4fv-in-the-gl-dispatch.patch b/debian/patches/84-gl-Add-entry-for-UniformMatrix4fv-in-the-gl-dispatch.patch
new file mode 100644
index 0000000..2367d38
--- /dev/null
+++ b/debian/patches/84-gl-Add-entry-for-UniformMatrix4fv-in-the-gl-dispatch.patch
@@ -0,0 +1,43 @@
+From eab4449330d0323d0e78a14d72f5bfbf79b5380b Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Mon, 31 Jan 2011 15:55:07 +0200
+Subject: [PATCH 04/16] gl: Add entry for UniformMatrix4fv in the gl dispatch
+ table
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+(cherry picked from commit 966e4a1738c5dc97149ff7bd58e54fa86f048c16)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-dispatch-private.h | 1 +
+ src/cairo-gl-private.h | 2 ++
+ 2 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/src/cairo-gl-dispatch-private.h b/src/cairo-gl-dispatch-private.h
+index f3245ed..bd444a5 100644
+--- a/src/cairo-gl-dispatch-private.h
++++ b/src/cairo-gl-dispatch-private.h
+@@ -83,6 +83,7 @@ cairo_private cairo_gl_dispatch_entry_t dispatch_shaders_entries[] = {
+ DISPATCH_ENTRY_ARB (Uniform3f),
+ DISPATCH_ENTRY_ARB (Uniform4f),
+ DISPATCH_ENTRY_ARB (UniformMatrix3fv),
++ DISPATCH_ENTRY_ARB (UniformMatrix4fv),
+ DISPATCH_ENTRY_ARB (Uniform1i),
+ DISPATCH_ENTRY_LAST
+ };
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index 6cea8c0..04322f2 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -210,6 +210,8 @@ typedef struct _cairo_gl_dispatch {
+ GLfloat w);
+ void (*UniformMatrix3fv) (GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
++ void (*UniformMatrix4fv) (GLint location, GLsizei count,
++ GLboolean transpose, const GLfloat *value);
+ void (*Uniform1i) (GLint location, GLint x);
+
+ /* Framebuffer objects */
+--
+1.7.5.4
+
diff --git a/debian/patches/85-gl-Add-function-to-bind-a-4x4-float-matrix-shader-un.patch b/debian/patches/85-gl-Add-function-to-bind-a-4x4-float-matrix-shader-un.patch
new file mode 100644
index 0000000..e22284a
--- /dev/null
+++ b/debian/patches/85-gl-Add-function-to-bind-a-4x4-float-matrix-shader-un.patch
@@ -0,0 +1,92 @@
+From 5381425d07518c8c8772766fa74e7374649f9b8b Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Mon, 31 Jan 2011 16:18:29 +0200
+Subject: [PATCH 05/16] gl: Add function to bind a 4x4 float matrix shader
+ uniform
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+(cherry picked from commit b13198348ce053445ca97b513611207e34aa4528)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-private.h | 5 +++++
+ src/cairo-gl-shaders.c | 26 ++++++++++++++++++++++++++
+ 2 files changed, 31 insertions(+), 0 deletions(-)
+
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index 04322f2..3dd75f8 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -523,6 +523,11 @@ _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx,
+ cairo_matrix_t* m);
+
+ cairo_private void
++_cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
++ const char *name,
++ GLfloat* gl_m);
++
++cairo_private void
+ _cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx,
+ const char *name,
+ GLuint tex_unit);
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index a39883d..1b10b04 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -93,6 +93,12 @@ typedef struct cairo_gl_shader_impl {
+ cairo_matrix_t* m);
+
+ void
++ (*bind_matrix4f) (cairo_gl_context_t *ctx,
++ cairo_gl_shader_t *shader,
++ const char *name,
++ GLfloat* gl_m);
++
++ void
+ (*bind_texture) (cairo_gl_context_t *ctx,
+ cairo_gl_shader_t *shader,
+ const char *name,
+@@ -263,6 +269,18 @@ bind_matrix_core_2_0 (cairo_gl_context_t *ctx,
+ }
+
+ static void
++bind_matrix4f_core_2_0 (cairo_gl_context_t *ctx,
++ cairo_gl_shader_t *shader,
++ const char *name,
++ GLfloat* gl_m)
++{
++ cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
++ GLint location = dispatch->GetUniformLocation (shader->program, name);
++ assert (location != -1);
++ dispatch->UniformMatrix4fv (location, 1, GL_FALSE, gl_m);
++}
++
++static void
+ bind_texture_core_2_0 (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader,
+ const char *name, cairo_gl_tex_t tex_unit)
+ {
+@@ -292,6 +310,7 @@ static const cairo_gl_shader_impl_t shader_impl_core_2_0 = {
+ bind_vec3_core_2_0,
+ bind_vec4_core_2_0,
+ bind_matrix_core_2_0,
++ bind_matrix4f_core_2_0,
+ bind_texture_core_2_0,
+ use_program_core_2_0,
+ };
+@@ -798,6 +817,13 @@ _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx,
+ }
+
+ void
++_cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
++ const char *name, GLfloat* gl_m)
++{
++ ctx->shader_impl->bind_matrix4f (ctx, ctx->current_shader, name, gl_m);
++}
++
++void
+ _cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx,
+ const char *name, GLuint tex_unit)
+ {
+--
+1.7.5.4
+
diff --git a/debian/patches/86-gl-Replace-ftransform-with-manual-coordinate-calcula.patch b/debian/patches/86-gl-Replace-ftransform-with-manual-coordinate-calcula.patch
new file mode 100644
index 0000000..4543e13
--- /dev/null
+++ b/debian/patches/86-gl-Replace-ftransform-with-manual-coordinate-calcula.patch
@@ -0,0 +1,33 @@
+From f41607b1b5501c7979ec26f8e9f8f7ff08ffc63a Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Thu, 27 Jan 2011 16:10:38 +0200
+Subject: [PATCH 06/16] gl: Replace ftransform() with manual coordinate
+ calculation in shaders
+
+The ftransform() shader function was deprecated and removed in recent
+GLSL versions and is not included at all in GLSL ES.
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+(cherry picked from commit d88ada384fcb045cc9899339f9e8c1cbb8280c16)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-shaders.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index 1b10b04..13efccb 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -520,7 +520,7 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src,
+ _cairo_output_stream_printf (stream,
+ "void main()\n"
+ "{\n"
+- " gl_Position = ftransform();\n");
++ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n");
+
+ cairo_gl_shader_emit_vertex (stream, src, CAIRO_GL_TEX_SOURCE);
+ cairo_gl_shader_emit_vertex (stream, mask, CAIRO_GL_TEX_MASK);
+--
+1.7.5.4
+
diff --git a/debian/patches/87-gl-Use-a-custom-shader-uniform-for-the-ModelViewProj.patch b/debian/patches/87-gl-Use-a-custom-shader-uniform-for-the-ModelViewProj.patch
new file mode 100644
index 0000000..2a76de7
--- /dev/null
+++ b/debian/patches/87-gl-Use-a-custom-shader-uniform-for-the-ModelViewProj.patch
@@ -0,0 +1,137 @@
+From ed7add8f124c7307bb9fc9616ea5dcef4addb9ba Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Mon, 31 Jan 2011 18:02:02 +0200
+Subject: [PATCH 07/16] gl: Use a custom shader uniform for the
+ ModelViewProjection matrix
+
+The built-in gl_ModelViewProjectionMatrix uniform (and others) has been
+deprecated and removed in recent GLSL versions and is not supported
+at all in GLSL ES. A custom uniform for the same purpose works across
+all versions.
+
+[ickle: base _gl_identity_ortho on the 2D variant of glOrtho i.e. with
+ fixed near/far values of [-1, 1]]
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+(cherry picked from commit 80a92b6d799900057ac40c0c0bb63be48eece9ef)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-composite.c | 2 +
+ src/cairo-gl-device.c | 51 +++++++++++++++++++++++++++++++++++++++------
+ src/cairo-gl-private.h | 1 +
+ src/cairo-gl-shaders.c | 3 +-
+ 4 files changed, 49 insertions(+), 8 deletions(-)
+
+diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
+index a32e00d..7cbe894 100644
+--- a/src/cairo-gl-composite.c
++++ b/src/cairo-gl-composite.c
+@@ -414,6 +414,8 @@ static void
+ _cairo_gl_composite_bind_to_shader (cairo_gl_context_t *ctx,
+ cairo_gl_composite_t *setup)
+ {
++ _cairo_gl_shader_bind_matrix4f(ctx, "ModelViewProjectionMatrix",
++ ctx->modelviewprojection_matrix);
+ _cairo_gl_operand_bind_to_shader (ctx, &setup->src, CAIRO_GL_TEX_SOURCE);
+ _cairo_gl_operand_bind_to_shader (ctx, &setup->mask, CAIRO_GL_TEX_MASK);
+ }
+diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
+index 25423e0..3537dc9 100644
+--- a/src/cairo-gl-device.c
++++ b/src/cairo-gl-device.c
+@@ -269,6 +269,46 @@ _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx,
+ }
+ }
+
++/*
++ * Stores a parallel projection transformation in matrix 'm',
++ * using column-major order.
++ *
++ * This is equivalent to:
++ *
++ * glLoadIdentity()
++ * gluOrtho2D()
++ *
++ * The calculation for the ortho tranformation was taken from the
++ * mesa source code.
++ */
++static void
++_gl_identity_ortho (GLfloat *m,
++ GLfloat left, GLfloat right,
++ GLfloat bottom, GLfloat top)
++{
++#define M(row,col) m[col*4+row]
++ M(0,0) = 2.f / (right - left);
++ M(0,1) = 0.f;
++ M(0,2) = 0.f;
++ M(0,3) = -(right + left) / (right - left);
++
++ M(1,0) = 0.f;
++ M(1,1) = 2.f / (top - bottom);
++ M(1,2) = 0.f;
++ M(1,3) = -(top + bottom) / (top - bottom);
++
++ M(2,0) = 0.f;
++ M(2,1) = 0.f;
++ M(2,2) = -1.f;
++ M(2,3) = 0.f;
++
++ M(3,0) = 0.f;
++ M(3,1) = 0.f;
++ M(3,2) = 0.f;
++ M(3,3) = 1.f;
++#undef M
++}
++
+ void
+ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
+ cairo_gl_surface_t *surface)
+@@ -295,13 +335,10 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
+
+ glViewport (0, 0, surface->width, surface->height);
+
+- glMatrixMode (GL_PROJECTION);
+- glLoadIdentity ();
+ if (_cairo_gl_surface_is_texture (surface))
+- glOrtho (0, surface->width, 0, surface->height, -1.0, 1.0);
++ _gl_identity_ortho (ctx->modelviewprojection_matrix,
++ 0, surface->width, 0, surface->height);
+ else
+- glOrtho (0, surface->width, surface->height, 0, -1.0, 1.0);
+-
+- glMatrixMode (GL_MODELVIEW);
+- glLoadIdentity ();
++ _gl_identity_ortho (ctx->modelviewprojection_matrix,
++ 0, surface->width, surface->height, 0);
+ }
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index 3dd75f8..61c382d 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -259,6 +259,7 @@ struct _cairo_gl_context {
+
+ cairo_bool_t has_mesa_pack_invert;
+ cairo_gl_dispatch_t dispatch;
++ GLfloat modelviewprojection_matrix[16];
+
+ void (*acquire) (void *ctx);
+ void (*release) (void *ctx);
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index 13efccb..6a3a606 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -518,9 +518,10 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src,
+ cairo_gl_shader_emit_variable (stream, mask, CAIRO_GL_TEX_MASK);
+
+ _cairo_output_stream_printf (stream,
++ "uniform mat4 ModelViewProjectionMatrix;\n"
+ "void main()\n"
+ "{\n"
+- " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n");
++ " gl_Position = ModelViewProjectionMatrix * gl_Vertex;\n");
+
+ cairo_gl_shader_emit_vertex (stream, src, CAIRO_GL_TEX_SOURCE);
+ cairo_gl_shader_emit_vertex (stream, mask, CAIRO_GL_TEX_MASK);
+--
+1.7.5.4
+
diff --git a/debian/patches/88-gl-Add-gl-dispatch-entries-for-functions-related-to-.patch b/debian/patches/88-gl-Add-gl-dispatch-entries-for-functions-related-to-.patch
new file mode 100644
index 0000000..823e290
--- /dev/null
+++ b/debian/patches/88-gl-Add-gl-dispatch-entries-for-functions-related-to-.patch
@@ -0,0 +1,56 @@
+From c23065f7c146022f8e067b8e088da477a3339f4f Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Thu, 3 Feb 2011 22:06:27 +0200
+Subject: [PATCH 08/16] gl: Add gl dispatch entries for functions related to
+ vertex attributes
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+(cherry picked from commit e68062d9caafe21b53af22173fff40ad973a8d73)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-dispatch-private.h | 7 +++++++
+ src/cairo-gl-private.h | 9 +++++++++
+ 2 files changed, 16 insertions(+), 0 deletions(-)
+
+diff --git a/src/cairo-gl-dispatch-private.h b/src/cairo-gl-dispatch-private.h
+index bd444a5..0795e70 100644
+--- a/src/cairo-gl-dispatch-private.h
++++ b/src/cairo-gl-dispatch-private.h
+@@ -85,6 +85,13 @@ cairo_private cairo_gl_dispatch_entry_t dispatch_shaders_entries[] = {
+ DISPATCH_ENTRY_ARB (UniformMatrix3fv),
+ DISPATCH_ENTRY_ARB (UniformMatrix4fv),
+ DISPATCH_ENTRY_ARB (Uniform1i),
++
++ /* Attributes */
++ DISPATCH_ENTRY_ARB (BindAttribLocation),
++ DISPATCH_ENTRY_ARB (VertexAttribPointer),
++ DISPATCH_ENTRY_ARB (EnableVertexAttribArray),
++ DISPATCH_ENTRY_ARB (DisableVertexAttribArray),
++
+ DISPATCH_ENTRY_LAST
+ };
+
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index 61c382d..fd1af87 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -214,6 +214,15 @@ typedef struct _cairo_gl_dispatch {
+ GLboolean transpose, const GLfloat *value);
+ void (*Uniform1i) (GLint location, GLint x);
+
++ /* Attributes */
++ void (*BindAttribLocation) (GLuint program, GLuint index,
++ const GLchar *name);
++ void (*VertexAttribPointer) (GLuint index, GLint size, GLenum type,
++ GLboolean normalized, GLsizei stride,
++ const GLvoid *pointer);
++ void (*EnableVertexAttribArray) (GLuint index);
++ void (*DisableVertexAttribArray) (GLuint index);
++
+ /* Framebuffer objects */
+ void (*GenFramebuffers) (GLsizei n, GLuint* framebuffers);
+ void (*BindFramebuffer) (GLenum target, GLuint framebuffer);
+--
+1.7.5.4
+
diff --git a/debian/patches/89-gl-Replace-built-in-vertex-attributes-with-custom-at.patch b/debian/patches/89-gl-Replace-built-in-vertex-attributes-with-custom-at.patch
new file mode 100644
index 0000000..386f0c7
--- /dev/null
+++ b/debian/patches/89-gl-Replace-built-in-vertex-attributes-with-custom-at.patch
@@ -0,0 +1,230 @@
+From d7a13c608ac6b43da131b5a6a23fd149aeffb723 Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Thu, 3 Feb 2011 23:06:26 +0200
+Subject: [PATCH 09/16] gl: Replace built-in vertex attributes with custom
+ attributes
+
+Built-in vertex attributes like gl_Vertex and gl_Color, have been obsoleted
+and removed in recent GL versions and they are not supported at all in GLES2.0.
+Custom attributes are supported in all GL versions >= 2.0, in GL 1.x with
+ARB shader extensions and in GLES2.0.
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+(cherry picked from commit e4fdd9a1cd4c0d074dd20417e66de5856b6ba5a7)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-composite.c | 42 ++++++++++++++++++++++--------------------
+ src/cairo-gl-private.h | 10 ++++++++++
+ src/cairo-gl-shaders.c | 20 +++++++++++++++++---
+ 3 files changed, 49 insertions(+), 23 deletions(-)
+
+diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
+index 7cbe894..d5b3c5c 100644
+--- a/src/cairo-gl-composite.c
++++ b/src/cairo-gl-composite.c
+@@ -3,6 +3,7 @@
+ * Copyright © 2009 Eric Anholt
+ * Copyright © 2009 Chris Wilson
+ * Copyright © 2005,2010 Red Hat, Inc
++ * Copyright © 2011 Linaro Limited
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+@@ -36,6 +37,7 @@
+ * Carl Worth <cworth@cworth.org>
+ * Chris Wilson <chris@chris-wilson.co.uk>
+ * Eric Anholt <eric@anholt.net>
++ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ */
+
+ #include "cairoint.h"
+@@ -516,6 +518,7 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ unsigned int vertex_size,
+ unsigned int vertex_offset)
+ {
++ cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
+ cairo_bool_t needs_setup;
+
+ /* XXX: we need to do setup when switching from shaders
+@@ -543,9 +546,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ case CAIRO_GL_OPERAND_NONE:
+ break;
+ case CAIRO_GL_OPERAND_SPANS:
+- glColorPointer (4, GL_UNSIGNED_BYTE, vertex_size,
+- (void *) (uintptr_t) vertex_offset);
+- glEnableClientState (GL_COLOR_ARRAY);
++ dispatch->VertexAttribPointer (CAIRO_GL_COLOR_ATTRIB_INDEX, 4,
++ GL_UNSIGNED_BYTE, GL_TRUE, vertex_size,
++ (void *) (uintptr_t) vertex_offset);
++ dispatch->EnableVertexAttribArray (CAIRO_GL_COLOR_ATTRIB_INDEX);
+ /* fall through */
+ case CAIRO_GL_OPERAND_CONSTANT:
+ break;
+@@ -557,10 +561,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ _cairo_gl_texture_set_filter (ctx, ctx->tex_target,
+ operand->texture.attributes.filter);
+
+- glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+- glTexCoordPointer (2, GL_FLOAT, vertex_size,
+- (void *) (uintptr_t) vertex_offset);
+- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
++ dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2,
++ GL_FLOAT, GL_FALSE, vertex_size,
++ (void *) (uintptr_t) vertex_offset);
++ dispatch->EnableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
+ break;
+ case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
+@@ -572,10 +576,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
+ _cairo_gl_texture_set_extend (ctx, GL_TEXTURE_1D, operand->gradient.extend);
+ _cairo_gl_texture_set_filter (ctx, GL_TEXTURE_1D, CAIRO_FILTER_BILINEAR);
+
+- glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+- glTexCoordPointer (2, GL_FLOAT, vertex_size,
+- (void *) (uintptr_t) vertex_offset);
+- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
++ dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2,
++ GL_FLOAT, GL_FALSE, vertex_size,
++ (void *) (uintptr_t) vertex_offset);
++ dispatch->EnableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
+ break;
+ }
+ }
+@@ -584,6 +588,7 @@ void
+ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
+ cairo_gl_tex_t tex_unit)
+ {
++ cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
+ assert (_cairo_gl_context_is_flushed (ctx));
+
+ switch (ctx->operands[tex_unit].type) {
+@@ -593,23 +598,19 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
+ case CAIRO_GL_OPERAND_NONE:
+ break;
+ case CAIRO_GL_OPERAND_SPANS:
+- glDisableClientState (GL_COLOR_ARRAY);
++ dispatch->DisableVertexAttribArray (CAIRO_GL_COLOR_ATTRIB_INDEX);
+ /* fall through */
+ case CAIRO_GL_OPERAND_CONSTANT:
+ break;
+ case CAIRO_GL_OPERAND_TEXTURE:
+- glActiveTexture (GL_TEXTURE0 + tex_unit);
+- glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
++ dispatch->DisableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
+ break;
+ case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
+ _cairo_gl_gradient_destroy (ctx->operands[tex_unit].gradient.gradient);
+- glActiveTexture (GL_TEXTURE0 + tex_unit);
+- glClientActiveTexture (GL_TEXTURE0 + tex_unit);
+- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
++ dispatch->DisableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
+ break;
+ }
+
+@@ -862,8 +863,9 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
+ if (_cairo_gl_context_is_flushed (ctx)) {
+ ctx->dispatch.BindBuffer (GL_ARRAY_BUFFER, ctx->vbo);
+
+- glVertexPointer (2, GL_FLOAT, vertex_size, NULL);
+- glEnableClientState (GL_VERTEX_ARRAY);
++ ctx->dispatch.VertexAttribPointer (CAIRO_GL_VERTEX_ATTRIB_INDEX, 2,
++ GL_FLOAT, GL_FALSE, vertex_size, NULL);
++ ctx->dispatch.EnableVertexAttribArray (CAIRO_GL_VERTEX_ATTRIB_INDEX);
+ }
+
+ _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src, vertex_size, dst_size);
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index fd1af87..475f14a 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -3,6 +3,7 @@
+ * Copyright © 2009 Eric Anholt
+ * Copyright © 2009 Chris Wilson
+ * Copyright © 2005,2010 Red Hat, Inc
++ * Copyright © 2011 Linaro Limited
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+@@ -37,6 +38,7 @@
+ * Chris Wilson <chris@chris-wilson.co.uk>
+ * Eric Anholt <eric@anholt.net>
+ * T. Zachary Laine <whatwasthataddress@gmail.com>
++ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ */
+
+ #ifndef CAIRO_GL_PRIVATE_H
+@@ -84,6 +86,14 @@
+ /* VBO size that we allocate, smaller size means we gotta flush more often */
+ #define CAIRO_GL_VBO_SIZE 16384
+
++/* Indices for vertex attributes used by BindAttribLocation etc */
++enum {
++ CAIRO_GL_VERTEX_ATTRIB_INDEX = 0,
++ CAIRO_GL_COLOR_ATTRIB_INDEX = 1,
++ CAIRO_GL_TEXCOORD0_ATTRIB_INDEX = 2,
++ CAIRO_GL_TEXCOORD1_ATTRIB_INDEX = CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + 1
++};
++
+ typedef struct _cairo_gl_surface {
+ cairo_surface_t base;
+
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index 6a3a606..a17491e 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -163,6 +163,16 @@ link_shader_core_2_0 (cairo_gl_context_t *ctx, GLuint *program,
+ *program = dispatch->CreateProgram ();
+ dispatch->AttachShader (*program, vert);
+ dispatch->AttachShader (*program, frag);
++
++ dispatch->BindAttribLocation (*program, CAIRO_GL_VERTEX_ATTRIB_INDEX,
++ "Vertex");
++ dispatch->BindAttribLocation (*program, CAIRO_GL_COLOR_ATTRIB_INDEX,
++ "Color");
++ dispatch->BindAttribLocation (*program, CAIRO_GL_TEXCOORD0_ATTRIB_INDEX,
++ "MultiTexCoord0");
++ dispatch->BindAttribLocation (*program, CAIRO_GL_TEXCOORD1_ATTRIB_INDEX,
++ "MultiTexCoord1");
++
+ dispatch->LinkProgram (*program);
+ dispatch->GetProgramiv (*program, GL_LINK_STATUS, &gl_status);
+ if (gl_status == GL_FALSE) {
+@@ -492,12 +502,12 @@ cairo_gl_shader_emit_vertex (cairo_output_stream_t *stream,
+ break;
+ case CAIRO_GL_VAR_TEXCOORDS:
+ _cairo_output_stream_printf (stream,
+- " %s_texcoords = gl_MultiTexCoord%d.xy;\n",
++ " %s_texcoords = MultiTexCoord%d.xy;\n",
+ operand_names[name], name);
+ break;
+ case CAIRO_GL_VAR_COVERAGE:
+ _cairo_output_stream_printf (stream,
+- " %s_coverage = gl_Color.a;\n",
++ " %s_coverage = Color.a;\n",
+ operand_names[name]);
+ break;
+ }
+@@ -518,10 +528,14 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src,
+ cairo_gl_shader_emit_variable (stream, mask, CAIRO_GL_TEX_MASK);
+
+ _cairo_output_stream_printf (stream,
++ "attribute vec4 Vertex;\n"
++ "attribute vec4 Color;\n"
++ "attribute vec4 MultiTexCoord0;\n"
++ "attribute vec4 MultiTexCoord1;\n"
+ "uniform mat4 ModelViewProjectionMatrix;\n"
+ "void main()\n"
+ "{\n"
+- " gl_Position = ModelViewProjectionMatrix * gl_Vertex;\n");
++ " gl_Position = ModelViewProjectionMatrix * Vertex;\n");
+
+ cairo_gl_shader_emit_vertex (stream, src, CAIRO_GL_TEX_SOURCE);
+ cairo_gl_shader_emit_vertex (stream, mask, CAIRO_GL_TEX_MASK);
+--
+1.7.5.4
+
diff --git a/debian/patches/90-gl-Don-t-reset-the-FBO-draw-readbuffers-every-time-w.patch b/debian/patches/90-gl-Don-t-reset-the-FBO-draw-readbuffers-every-time-w.patch
new file mode 100644
index 0000000..fad6f44
--- /dev/null
+++ b/debian/patches/90-gl-Don-t-reset-the-FBO-draw-readbuffers-every-time-w.patch
@@ -0,0 +1,45 @@
+From 4f8a57aaa0aa1c259b056ca5711867a327706962 Mon Sep 17 00:00:00 2001
+From: Eric Anholt <eric@anholt.net>
+Date: Sun, 30 Jan 2011 20:11:11 -0800
+Subject: [PATCH 10/16] gl: Don't reset the FBO draw/readbuffers every time we
+ bind the FBO.
+
+Draw/readbuffers are a property of the framebuffer, not of the
+context. So we can leave them in place across bindings. I left the
+window drawbuffer setting in place until we decide how to handle
+interoperating of cairo-gl with normal GL usage.
+
+[ 0] before firefox-talos-gfx 67.552 67.561 0.22% 3/3
+[ 0] after firefox-talos-gfx 66.689 66.913 0.41% 3/3
+(cherry picked from commit 81d2434b7595095e485019b38f8a348153c6bc93)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-device.c | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
+index 3537dc9..d206da8 100644
+--- a/src/cairo-gl-device.c
++++ b/src/cairo-gl-device.c
+@@ -248,6 +248,8 @@ _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx,
+ ctx->tex_target,
+ surface->tex,
+ 0);
++ glDrawBuffer (GL_COLOR_ATTACHMENT0);
++ glReadBuffer (GL_COLOR_ATTACHMENT0);
+
+ status = dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE) {
+@@ -324,8 +326,6 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
+ if (_cairo_gl_surface_is_texture (surface)) {
+ _cairo_gl_ensure_framebuffer (ctx, surface);
+ ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb);
+- glDrawBuffer (GL_COLOR_ATTACHMENT0);
+- glReadBuffer (GL_COLOR_ATTACHMENT0);
+ } else {
+ ctx->make_current (ctx, surface);
+ ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, 0);
+--
+1.7.5.4
+
diff --git a/debian/patches/91-egl-Fix-eglMakeCurrent-for-egl-surfaces.patch b/debian/patches/91-egl-Fix-eglMakeCurrent-for-egl-surfaces.patch
new file mode 100644
index 0000000..9cdc383
--- /dev/null
+++ b/debian/patches/91-egl-Fix-eglMakeCurrent-for-egl-surfaces.patch
@@ -0,0 +1,28 @@
+From 658718b18d03478c477e6d673c23c49e969598c1 Mon Sep 17 00:00:00 2001
+From: Benjamin Franzke <benjaminfranzke@googlemail.com>
+Date: Thu, 10 Feb 2011 18:07:43 +0200
+Subject: [PATCH 11/16] egl: Fix eglMakeCurrent for egl surfaces (cherry
+ picked from commit
+ 3245d6e120a1b8502cf36c3869db40341fb20b2e)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-egl-context.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
+index b4c18fc..9f14633 100644
+--- a/src/cairo-egl-context.c
++++ b/src/cairo-egl-context.c
+@@ -73,7 +73,7 @@ _egl_acquire (void *abstract_ctx)
+ }
+
+ eglMakeCurrent (ctx->display,
+- ctx->dummy_surface, ctx->dummy_surface, ctx->context);
++ current_surface, current_surface, ctx->context);
+ }
+
+ static void
+--
+1.7.5.4
+
diff --git a/debian/patches/92-egl-Ensure-that-the-dummy-pbuffer-surface-is-compati.patch b/debian/patches/92-egl-Ensure-that-the-dummy-pbuffer-surface-is-compati.patch
new file mode 100644
index 0000000..c0d597e
--- /dev/null
+++ b/debian/patches/92-egl-Ensure-that-the-dummy-pbuffer-surface-is-compati.patch
@@ -0,0 +1,64 @@
+From 9e38b1e7ebf9d206a4de0e94a035c84cc59a9130 Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Fri, 11 Feb 2011 16:11:43 +0200
+Subject: [PATCH 12/16] egl: Ensure that the dummy pbuffer surface is
+ compatible with the supplied context
+
+In order to be able to make an egl context current when using a
+pbuffer surface, that surface must have been created with a config
+that is compatible with the context config. For Mesa, this means that
+the configs must be the same.
+(cherry picked from commit 2181a53f61c08c3461c74932add4bac7bfa0cf27)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-egl-context.c | 26 ++++++++++++++++----------
+ 1 files changed, 16 insertions(+), 10 deletions(-)
+
+diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
+index 9f14633..ec23852 100644
+--- a/src/cairo-egl-context.c
++++ b/src/cairo-egl-context.c
+@@ -140,7 +140,7 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl)
+ EGL_HEIGHT, 1,
+ EGL_NONE,
+ };
+- EGLConfig *configs;
++ EGLConfig config;
+ EGLint numConfigs;
+
+ ctx = calloc (1, sizeof (cairo_egl_context_t));
+@@ -158,15 +158,21 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl)
+
+ if (!_egl_make_current_surfaceless (ctx)) {
+ /* Fall back to dummy surface, meh. */
+- eglGetConfigs (dpy, NULL, 0, &numConfigs);
+- configs = malloc (sizeof(*configs) *numConfigs);
+- if (configs == NULL) {
+- free (ctx);
+- return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY);
+- }
+- eglGetConfigs (dpy, configs, numConfigs, &numConfigs);
+- ctx->dummy_surface = eglCreatePbufferSurface (dpy, configs[0], attribs);
+- free (configs);
++ EGLint config_attribs[] = {
++ EGL_CONFIG_ID, 0,
++ EGL_NONE
++ };
++
++ /*
++ * In order to be able to make an egl context current when using a
++ * pbuffer surface, that surface must have been created with a config
++ * that is compatible with the context config. For Mesa, this means
++ * that the configs must be the same.
++ */
++ eglQueryContext (dpy, egl, EGL_CONFIG_ID, &config_attribs[1]);
++ eglChooseConfig (dpy, config_attribs, &config, 1, &numConfigs);
++
++ ctx->dummy_surface = eglCreatePbufferSurface (dpy, config, attribs);
+
+ if (ctx->dummy_surface == NULL) {
+ free (ctx);
+--
+1.7.5.4
+
diff --git a/debian/patches/93-boilerplate-egl-Ensure-that-we-are-using-an-RGBA32-e.patch b/debian/patches/93-boilerplate-egl-Ensure-that-we-are-using-an-RGBA32-e.patch
new file mode 100644
index 0000000..faeb34e
--- /dev/null
+++ b/debian/patches/93-boilerplate-egl-Ensure-that-we-are-using-an-RGBA32-e.patch
@@ -0,0 +1,58 @@
+From 3bfc03cb893e820a1f9d0aebc94ea4cfb8f23de9 Mon Sep 17 00:00:00 2001
+From: Alexandros Frantzis <alexandros.frantzis@linaro.org>
+Date: Fri, 11 Feb 2011 17:46:51 +0200
+Subject: [PATCH 13/16] boilerplate/egl: Ensure that we are using an RGBA32
+ egl config (cherry picked from commit
+ 00ffb09593b25a603cb5c1ad6d3712ea7776a027)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ boilerplate/cairo-boilerplate-egl.c | 17 ++++++++++++-----
+ 1 files changed, 12 insertions(+), 5 deletions(-)
+
+diff --git a/boilerplate/cairo-boilerplate-egl.c b/boilerplate/cairo-boilerplate-egl.c
+index 75439a9..1a5abec 100644
+--- a/boilerplate/cairo-boilerplate-egl.c
++++ b/boilerplate/cairo-boilerplate-egl.c
+@@ -73,8 +73,17 @@ _cairo_boilerplate_egl_create_surface (const char *name,
+ egl_target_closure_t *gltc;
+ cairo_surface_t *surface;
+ int major, minor;
+- EGLConfig *configs;
++ EGLConfig config;
+ EGLint numConfigs;
++ EGLint config_attribs[] = {
++ EGL_RED_SIZE, 8,
++ EGL_GREEN_SIZE, 8,
++ EGL_BLUE_SIZE, 8,
++ EGL_ALPHA_SIZE, 8,
++ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
++ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
++ EGL_NONE
++ };
+
+ gltc = xcalloc (1, sizeof (egl_target_closure_t));
+ *closure = gltc;
+@@ -86,17 +95,15 @@ _cairo_boilerplate_egl_create_surface (const char *name,
+ return NULL;
+ }
+
+- eglGetConfigs (gltc->dpy, NULL, 0, &numConfigs);
++ eglChooseConfig (gltc->dpy, config_attribs, &config, 1, &numConfigs);
+ if (numConfigs == 0) {
+ free (gltc);
+ return NULL;
+ }
+- configs = xmalloc(sizeof(*configs) *numConfigs);
+- eglGetConfigs (gltc->dpy, configs, numConfigs, &numConfigs);
+
+ eglBindAPI (EGL_OPENGL_API);
+
+- gltc->ctx = eglCreateContext (gltc->dpy, configs[0], EGL_NO_CONTEXT, NULL);
++ gltc->ctx = eglCreateContext (gltc->dpy, config, EGL_NO_CONTEXT, NULL);
+ if (gltc->ctx == EGL_NO_CONTEXT) {
+ eglTerminate (gltc->dpy);
+ free (gltc);
+--
+1.7.5.4
+
diff --git a/debian/patches/94-gl-Add-a-first-bit-of-general-documentation-on-cairo.patch b/debian/patches/94-gl-Add-a-first-bit-of-general-documentation-on-cairo.patch
new file mode 100644
index 0000000..3c48cad
--- /dev/null
+++ b/debian/patches/94-gl-Add-a-first-bit-of-general-documentation-on-cairo.patch
@@ -0,0 +1,56 @@
+From 0bcb69c16d1146c22c3b87be1e19492a5d763257 Mon Sep 17 00:00:00 2001
+From: Eric Anholt <eric@anholt.net>
+Date: Sun, 30 Jan 2011 23:41:39 -0800
+Subject: [PATCH 14/16] gl: Add a first bit of general documentation on
+ cairo-gl usage.
+
+Since its inception, cairo-gl has been plagued by the "how am I really
+supposed to use it?" problem. This lays down my expectations for how
+cairo-gl will interact with other usage of the GL API.
+(cherry picked from commit 2e67809be0a2febd52c75948fabd7ac81227e5e3)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl.h | 26 ++++++++++++++++++++++++++
+ 1 files changed, 26 insertions(+), 0 deletions(-)
+
+diff --git a/src/cairo-gl.h b/src/cairo-gl.h
+index 131d114..9efde43 100644
+--- a/src/cairo-gl.h
++++ b/src/cairo-gl.h
+@@ -31,6 +31,32 @@
+ * The Initial Developer of the Original Code is Eric Anholt.
+ */
+
++/**
++ * @file cairo-gl.h
++ *
++ * The cairo-gl backend provides an implementation of possibly
++ * hardware-accelerated cairo rendering by targeting the OpenGL API.
++ * The goal of the cairo-gl backend is to provide better performance
++ * with equal functionality to cairo-image where possible. It does
++ * not directly provide for applying additional OpenGL effects to
++ * cairo surfaces.
++ *
++ * Cairo-gl allows interoperability with other GL rendering through GL
++ * context sharing. Cairo-gl surfaces are created in reference to a
++ * cairo_device_t, which represents an GL context created by the user.
++ * When that GL context is created with its sharePtr set to another
++ * context (or vice versa), its objects (textures backing cairo-gl
++ * surfaces) can be accessed in the other OpenGL context. This allows
++ * cairo-gl to maintain its drawing state in one context while the
++ * user's 3D rendering occurs in the user's other context.
++ *
++ * However, as only one context can be current to a thread at a time,
++ * cairo-gl may make its context current to the thread on any cairo
++ * call which interacts with a cairo-gl surface or the cairo-gl
++ * device. As a result, the user must make their own context current
++ * between any cairo calls and their own OpenGL rendering.
++ */
++
+ #ifndef CAIRO_GL_H
+ #define CAIRO_GL_H
+
+--
+1.7.5.4
+
diff --git a/debian/patches/95-gl-Take-advantage-of-GLX_MESA_multithread_makecurren.patch b/debian/patches/95-gl-Take-advantage-of-GLX_MESA_multithread_makecurren.patch
new file mode 100644
index 0000000..daabcb6
--- /dev/null
+++ b/debian/patches/95-gl-Take-advantage-of-GLX_MESA_multithread_makecurren.patch
@@ -0,0 +1,71 @@
+From 1085971717af280f6d12a5fbf3d11f8586a74357 Mon Sep 17 00:00:00 2001
+From: Eric Anholt <eric@anholt.net>
+Date: Mon, 31 Jan 2011 20:47:15 -0800
+Subject: [PATCH 15/16] gl: Take advantage of GLX_MESA_multithread_makecurrent
+ to avoid unbinding.
+
+Because of GLX's unfortunate requirement that only one context have a
+thread current at a time, we had to unbind the context, triggering a
+flush, and eating of all the CPU. With a small tweak to the GLX spec
+by GLX_MESA_multithread_makecurrent, and a small tweak to Mesa that
+consisted mostly of deleting the "is this thread already bound
+elsewhere?" check, we can bind our context to any thread and use it
+safely as long as our usage of it is mutexed, which cairo-gl should
+already be doing.
+
+[ 0] before firefox-talos-gfx 50.260 50.525 0.25% 3/3
+[ 0] after firefox-talos-gfx 32.091 32.422 0.65% 3/3
+(cherry picked from commit 2fae22a3f2914a6e79436bafe94d19100d7cf6bf)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-glx-context.c | 12 +++++++++++-
+ 1 files changed, 11 insertions(+), 1 deletions(-)
+
+diff --git a/src/cairo-glx-context.c b/src/cairo-glx-context.c
+index 83963fb..f89fa32 100644
+--- a/src/cairo-glx-context.c
++++ b/src/cairo-glx-context.c
+@@ -52,6 +52,8 @@ typedef struct _cairo_glx_context {
+ Display *display;
+ Window dummy_window;
+ GLXContext context;
++
++ cairo_bool_t has_multithread_makecurrent;
+ } cairo_glx_context_t;
+
+ typedef struct _cairo_glx_surface {
+@@ -92,7 +94,9 @@ _glx_release (void *abstract_ctx)
+ {
+ cairo_glx_context_t *ctx = abstract_ctx;
+
+- glXMakeCurrent (ctx->display, None, None);
++ if (!ctx->has_multithread_makecurrent) {
++ glXMakeCurrent (ctx->display, None, None);
++ }
+ }
+
+ static void
+@@ -174,6 +178,7 @@ cairo_glx_device_create (Display *dpy, GLXContext gl_ctx)
+ cairo_glx_context_t *ctx;
+ cairo_status_t status;
+ Window dummy = None;
++ const char *glx_extensions;
+
+ status = _glx_dummy_ctx (dpy, gl_ctx, &dummy);
+ if (unlikely (status))
+@@ -206,6 +211,11 @@ cairo_glx_device_create (Display *dpy, GLXContext gl_ctx)
+ return _cairo_gl_context_create_in_error (status);
+ }
+
++ glx_extensions = glXQueryExtensionsString (dpy, DefaultScreen (dpy));
++ if (strstr(glx_extensions, "GLX_MESA_multithread_makecurrent")) {
++ ctx->has_multithread_makecurrent = TRUE;
++ }
++
+ ctx->base.release (ctx);
+
+ return &ctx->base.base;
+--
+1.7.5.4
+
diff --git a/debian/patches/96-gl-Bind-samplers-just-once-at-program-compile-time.patch b/debian/patches/96-gl-Bind-samplers-just-once-at-program-compile-time.patch
new file mode 100644
index 0000000..f95ba54
--- /dev/null
+++ b/debian/patches/96-gl-Bind-samplers-just-once-at-program-compile-time.patch
@@ -0,0 +1,163 @@
+From 0c10137ff4bed8ffd04b660bafe3cfbff5781254 Mon Sep 17 00:00:00 2001
+From: Eric Anholt <eric@anholt.net>
+Date: Mon, 21 Feb 2011 13:37:00 -0800
+Subject: [PATCH 16/16] gl: Bind samplers just once at program compile time.
+
+We never bound any other value to the sampler uniforms, so why bother
+resetting them all the time?
+
+[ 0] before firefox-talos-gfx 29.972 30.493 0.89% 3/3
+[ 0] after firefox-talos-gfx 29.397 29.599 1.27% 3/3
+
+Signed-off-by: Eric Anholt <eric@anholt.net>
+(cherry picked from commit 17169a1e5130b8a287f07eb43d41f0b51307cc57)
+
+Signed-off-by: Cyril Brulebois <kibi@debian.org>
+---
+ src/cairo-gl-composite.c | 6 +----
+ src/cairo-gl-private.h | 5 ----
+ src/cairo-gl-shaders.c | 58 +++++++++++++++++++++++++++-------------------
+ 3 files changed, 35 insertions(+), 34 deletions(-)
+
+diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
+index d5b3c5c..c8f84a9 100644
+--- a/src/cairo-gl-composite.c
++++ b/src/cairo-gl-composite.c
+@@ -401,13 +401,9 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx,
+ _cairo_gl_shader_bind_float (ctx,
+ uniform_name,
+ operand->gradient.radius_0);
+- /* fall through */
++ break;
+ case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
+ case CAIRO_GL_OPERAND_TEXTURE:
+- strcpy (custom_part, "_sampler");
+- _cairo_gl_shader_bind_texture(ctx,
+- uniform_name,
+- tex_unit);
+ break;
+ }
+ }
+diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
+index 475f14a..73818b1 100644
+--- a/src/cairo-gl-private.h
++++ b/src/cairo-gl-private.h
+@@ -548,11 +548,6 @@ _cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
+ GLfloat* gl_m);
+
+ cairo_private void
+-_cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx,
+- const char *name,
+- GLuint tex_unit);
+-
+-cairo_private void
+ _cairo_gl_set_shader (cairo_gl_context_t *ctx,
+ cairo_gl_shader_t *shader);
+
+diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
+index a17491e..39e4e30 100644
+--- a/src/cairo-gl-shaders.c
++++ b/src/cairo-gl-shaders.c
+@@ -99,12 +99,6 @@ typedef struct cairo_gl_shader_impl {
+ GLfloat* gl_m);
+
+ void
+- (*bind_texture) (cairo_gl_context_t *ctx,
+- cairo_gl_shader_t *shader,
+- const char *name,
+- cairo_gl_tex_t tex_unit);
+-
+- void
+ (*use) (cairo_gl_context_t *ctx,
+ cairo_gl_shader_t *shader);
+ } shader_impl_t;
+@@ -291,16 +285,6 @@ bind_matrix4f_core_2_0 (cairo_gl_context_t *ctx,
+ }
+
+ static void
+-bind_texture_core_2_0 (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader,
+- const char *name, cairo_gl_tex_t tex_unit)
+-{
+- cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
+- GLint location = dispatch->GetUniformLocation (shader->program, name);
+- assert (location != -1);
+- dispatch->Uniform1i (location, tex_unit);
+-}
+-
+-static void
+ use_program_core_2_0 (cairo_gl_context_t *ctx,
+ cairo_gl_shader_t *shader)
+ {
+@@ -321,7 +305,6 @@ static const cairo_gl_shader_impl_t shader_impl_core_2_0 = {
+ bind_vec4_core_2_0,
+ bind_matrix_core_2_0,
+ bind_matrix4f_core_2_0,
+- bind_texture_core_2_0,
+ use_program_core_2_0,
+ };
+
+@@ -788,6 +771,38 @@ _cairo_gl_shader_compile (cairo_gl_context_t *ctx,
+ return status;
+ }
+
++/* We always bind the source to texture unit 0 if present, and mask to
++ * texture unit 1 if present, so we can just initialize these once at
++ * compile time.
++ */
++static void
++_cairo_gl_shader_set_samplers (cairo_gl_context_t *ctx,
++ cairo_gl_shader_t *shader)
++{
++ cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
++ GLint location;
++ GLint saved_program;
++
++ /* We have to save/restore the current program because we might be
++ * asked for a different program while a shader is bound. This shouldn't
++ * be a performance issue, since this is only called once per compile.
++ */
++ glGetIntegerv (GL_CURRENT_PROGRAM, &saved_program);
++ dispatch->UseProgram (shader->program);
++
++ location = dispatch->GetUniformLocation (shader->program, "source_sampler");
++ if (location != -1) {
++ dispatch->Uniform1i (location, CAIRO_GL_TEX_SOURCE);
++ }
++
++ location = dispatch->GetUniformLocation (shader->program, "mask_sampler");
++ if (location != -1) {
++ dispatch->Uniform1i (location, CAIRO_GL_TEX_MASK);
++ }
++
++ dispatch->UseProgram (saved_program);
++}
++
+ void
+ _cairo_gl_shader_bind_float (cairo_gl_context_t *ctx,
+ const char *name,
+@@ -839,13 +854,6 @@ _cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
+ }
+
+ void
+-_cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx,
+- const char *name, GLuint tex_unit)
+-{
+- ctx->shader_impl->bind_texture (ctx, ctx->current_shader, name, tex_unit);
+-}
+-
+-void
+ _cairo_gl_set_shader (cairo_gl_context_t *ctx,
+ cairo_gl_shader_t *shader)
+ {
+@@ -913,6 +921,8 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
+ return status;
+ }
+
++ _cairo_gl_shader_set_samplers (ctx, &entry->shader);
++
+ status = _cairo_cache_insert (&ctx->shaders, &entry->base);
+ if (unlikely (status)) {
+ _cairo_gl_shader_fini (ctx, &entry->shader);
+--
+1.7.5.4
+
diff --git a/debian/patches/series b/debian/patches/series
index c4c2d60..f9b27f3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,20 @@
02_am-maintainer-mode.patch
03_export-symbols.patch
04-LD_PRELOAD-is-supported-on-Hurd.patch
+# Cherry-picked from upstream to make wayland-demos work:
+81-gl-Fail-if-GL-implementation-doesn-t-support-shaders.patch
+82-gl-Remove-unnecessary-checks-for-NULL-shader-impleme.patch
+83-gl-Remove-fixed-function-related-code-paths.patch
+84-gl-Add-entry-for-UniformMatrix4fv-in-the-gl-dispatch.patch
+85-gl-Add-function-to-bind-a-4x4-float-matrix-shader-un.patch
+86-gl-Replace-ftransform-with-manual-coordinate-calcula.patch
+87-gl-Use-a-custom-shader-uniform-for-the-ModelViewProj.patch
+88-gl-Add-gl-dispatch-entries-for-functions-related-to-.patch
+89-gl-Replace-built-in-vertex-attributes-with-custom-at.patch
+90-gl-Don-t-reset-the-FBO-draw-readbuffers-every-time-w.patch
+91-egl-Fix-eglMakeCurrent-for-egl-surfaces.patch
+92-egl-Ensure-that-the-dummy-pbuffer-surface-is-compati.patch
+93-boilerplate-egl-Ensure-that-we-are-using-an-RGBA32-e.patch
+94-gl-Add-a-first-bit-of-general-documentation-on-cairo.patch
+95-gl-Take-advantage-of-GLX_MESA_multithread_makecurren.patch
+96-gl-Bind-samplers-just-once-at-program-compile-time.patch