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

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E0C34DDF9@SISAEX01SJ.sisa.samsung.com>
Hi, Alex

I could not apply your 1/2. 2/2 patches on latest snapshot.  Would you please check them?  I modified your 1/2 patch a little and that applies fine, but 2/2 patch has too much difference, hard to manually adjust.  

Thanks

Henry

________________________________________
From: [email protected] [[email protected]] on behalf of [email protected] [[email protected]]
Sent: Thursday, May 03, 2012 3:03 AM
To: [email protected]
Subject: [cairo] [PATCH 1/2] gl: Simplify GL wrap parameter setting code

From: Alexandros Frantzis <[email protected]>

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

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);
     }
 }

--
1.7.9.5

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.