diff mbox

[1/2] gl: Simplify GL wrap parameter setting code

Message ID b73e898303de03780d065b972a09b45dc1381201.1336038723.git.alexandros.frantzis@linaro.org
State Superseded
Headers show

Commit Message

alexandros.frantzis@linaro.org May 3, 2012, 10:04 a.m. UTC
From: Alexandros Frantzis <alexandros.frantzis@linaro.org>

---
 src/cairo-gl-composite.c |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index bd7c675..633d229 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -153,32 +153,33 @@  _cairo_gl_texture_set_extend (cairo_gl_context_t *ctx,
                               GLuint              target,
                               cairo_extend_t      extend)
 {
+    GLint wrap_mode;
     assert (! _cairo_gl_device_requires_power_of_two_textures (&ctx->base) ||
             (extend != CAIRO_EXTEND_REPEAT && extend != CAIRO_EXTEND_REFLECT));
 
     switch (extend) {
     case CAIRO_EXTEND_NONE:
-	if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES) {
-	    glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	    glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	}
-	else {
-	    glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
-	    glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
-	}
+	if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES)
+	    wrap_mode = GL_CLAMP_TO_EDGE;
+	else
+	    wrap_mode = GL_CLAMP_TO_BORDER;
 	break;
     case CAIRO_EXTEND_PAD:
-	glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	wrap_mode = GL_CLAMP_TO_EDGE;
 	break;
     case CAIRO_EXTEND_REPEAT:
-	glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_REPEAT);
-	glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_REPEAT);
+	wrap_mode = GL_REPEAT;
 	break;
     case CAIRO_EXTEND_REFLECT:
-	glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
-	glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
+	wrap_mode = GL_MIRRORED_REPEAT;
 	break;
+    default:
+	wrap_mode = 0;
+    }
+
+    if (likely (wrap_mode)) {
+	glTexParameteri (target, GL_TEXTURE_WRAP_S, wrap_mode);
+	glTexParameteri (target, GL_TEXTURE_WRAP_T, wrap_mode);
     }
 }