From c8eda1f0576320b4deb0661454eb01fc7709355a Mon Sep 17 00:00:00 2001
From: Luca Barbato <lu_zero@gentoo.org>
Date: Wed, 24 Nov 2010 18:05:01 +0100
Subject: [PATCH 1/2] Remove ARB implementation

---
 src/cairo-gl-shaders.c |  176 ------------------------------------------------
 1 files changed, 0 insertions(+), 176 deletions(-)

diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index abb4dd2..0a5275a 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -100,164 +100,6 @@ _cairo_gl_shader_compile (cairo_gl_context_t *ctx,
 			  cairo_gl_var_type_t mask,
 			  const char *fragment_text);
 
-/* ARB_shader_objects / ARB_vertex_shader / ARB_fragment_shader extensions
-   API. */
-static void
-compile_shader_arb (GLuint *shader, GLenum type, const char *text)
-{
-    const char* strings[1] = { text };
-    GLint gl_status;
-
-    *shader = glCreateShaderObjectARB (type);
-    glShaderSourceARB (*shader, 1, strings, 0);
-    glCompileShaderARB (*shader);
-    glGetObjectParameterivARB (*shader, GL_OBJECT_COMPILE_STATUS_ARB, &gl_status);
-    if (gl_status == GL_FALSE) {
-        GLint log_size;
-        glGetObjectParameterivARB (*shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &log_size);
-        if (0 < log_size) {
-            char *log = _cairo_malloc (log_size);
-            GLint chars;
-
-            log[log_size - 1] = '\0';
-            glGetInfoLogARB (*shader, log_size, &chars, log);
-            printf ("OpenGL shader compilation failed.  Shader:\n"
-                    "%s\n"
-                    "OpenGL compilation log:\n"
-                    "%s\n",
-                    text, log);
-
-            free (log);
-        } else {
-            printf ("OpenGL shader compilation failed.\n");
-        }
-
-	ASSERT_NOT_REACHED;
-    }
-}
-
-static void
-link_shader_arb (GLuint *program, GLuint vert, GLuint frag)
-{
-    GLint gl_status;
-
-    *program = glCreateProgramObjectARB ();
-    glAttachObjectARB (*program, vert);
-    glAttachObjectARB (*program, frag);
-    glLinkProgramARB (*program);
-    glGetObjectParameterivARB (*program, GL_OBJECT_LINK_STATUS_ARB, &gl_status);
-    if (gl_status == GL_FALSE) {
-        GLint log_size;
-        glGetObjectParameterivARB (*program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &log_size);
-        if (0 < log_size) {
-            char *log = _cairo_malloc (log_size);
-            GLint chars;
-
-            log[log_size - 1] = '\0';
-            glGetInfoLogARB (*program, log_size, &chars, log);
-            printf ("OpenGL shader link failed:\n%s\n", log);
-
-            free (log);
-        } else {
-            printf ("OpenGL shader link failed.\n");
-        }
-
-	ASSERT_NOT_REACHED;
-    }
-}
-
-static void
-destroy_shader_arb (GLuint shader)
-{
-  glDeleteObjectARB (shader);
-}
-
-static void
-destroy_program_arb (GLuint shader)
-{
-  glDeleteObjectARB (shader);
-}
-
-static void
-bind_float_arb (cairo_gl_shader_t *shader,
-		const char *name,
-		float value)
-{
-    GLint location = glGetUniformLocationARB (shader->program, name);
-    assert (location != -1);
-    glUniform1fARB (location, value);
-}
-
-static void
-bind_vec2_arb (cairo_gl_shader_t *shader,
-	       const char *name,
-	       float value0,
-	       float value1)
-{
-    GLint location = glGetUniformLocationARB (shader->program, name);
-    assert (location != -1);
-    glUniform2fARB (location, value0, value1);
-}
-
-static void
-bind_vec3_arb (cairo_gl_shader_t *shader,
-	       const char *name,
-	       float value0,
-	       float value1,
-	       float value2)
-{
-    GLint location = glGetUniformLocationARB (shader->program, name);
-    assert (location != -1);
-    glUniform3fARB (location, value0, value1, value2);
-}
-
-static void
-bind_vec4_arb (cairo_gl_shader_t *shader,
-	       const char *name,
-	       float value0,
-	       float value1,
-	       float value2,
-	       float value3)
-{
-    GLint location = glGetUniformLocationARB (shader->program, name);
-    assert (location != -1);
-    glUniform4fARB (location, value0, value1, value2, value3);
-}
-
-static void
-bind_matrix_arb (cairo_gl_shader_t *shader,
-		 const char *name,
-		 cairo_matrix_t* m)
-{
-    GLint location = glGetUniformLocationARB (shader->program, name);
-    float gl_m[9] = {
-        m->xx, m->xy, m->x0,
-        m->yx, m->yy, m->y0,
-        0,     0,     1
-    };
-    assert (location != -1);
-    glUniformMatrix3fvARB (location, 1, GL_TRUE, gl_m);
-}
-
-static void
-bind_texture_arb (cairo_gl_shader_t *shader,
-		  const char *name,
-		  cairo_gl_tex_t tex_unit)
-{
-    GLint location = glGetUniformLocationARB (shader->program, name);
-    assert (location != -1);
-    glUniform1iARB (location, tex_unit);
-}
-
-static void
-use_program_arb (cairo_gl_shader_t *shader)
-{
-    if (shader)
-	glUseProgramObjectARB (shader->program);
-    else
-	glUseProgramObjectARB (0);
-}
-
 /* OpenGL Core 2.0 API. */
 static void
 compile_shader_core_2_0 (GLuint *shader, GLenum type, const char *text)
@@ -425,20 +267,6 @@ static const cairo_gl_shader_impl_t shader_impl_core_2_0 = {
     use_program_core_2_0,
 };
 
-static const cairo_gl_shader_impl_t shader_impl_arb = {
-    compile_shader_arb,
-    link_shader_arb,
-    destroy_shader_arb,
-    destroy_program_arb,
-    bind_float_arb,
-    bind_vec2_arb,
-    bind_vec3_arb,
-    bind_vec4_arb,
-    bind_matrix_arb,
-    bind_texture_arb,
-    use_program_arb,
-};
-
 typedef struct _cairo_shader_cache_entry {
     cairo_cache_entry_t base;
 
@@ -501,10 +329,6 @@ _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx)
     /* XXX multiple device support? */
     if (GLEW_VERSION_2_0) {
         ctx->shader_impl = &shader_impl_core_2_0;
-    } else if (GLEW_ARB_shader_objects &&
-               GLEW_ARB_fragment_shader &&
-               GLEW_ARB_vertex_program) {
-        ctx->shader_impl = &shader_impl_arb;
     } else {
         ctx->shader_impl = NULL;
     }
-- 
1.7.0.2
