swrast: simplify the condition test for _swrast_choose_texture_sample_func
authorYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 2 Nov 2011 06:46:06 +0000 (14:46 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Thu, 3 Nov 2011 02:24:28 +0000 (10:24 +0800)
remove another long if condition test. I don't feel a strong need of
this patch. But for it make the code a little simpler(I do think so),
I send it out.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/swrast/s_texfilter.c

index 9de5c0276e14eaa27bd0b613524d5237da0310ef..5662625574400dfe04ca38163b5ff8b9d1b1f109 100644 (file)
@@ -3647,25 +3647,21 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
             const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
             const struct swrast_texture_image *swImg =
                swrast_texture_image_const(img);
+            texture_sample_func func;
 
             ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+            func = &sample_nearest_2d;
             if (t->Sampler.WrapS == GL_REPEAT &&
                 t->Sampler.WrapT == GL_REPEAT &&
                 swImg->_IsPowerOfTwo &&
-                img->Border == 0 &&
-                img->TexFormat == MESA_FORMAT_RGB888) {
-               return &opt_sample_rgb_2d;
-            }
-            else if (t->Sampler.WrapS == GL_REPEAT &&
-                     t->Sampler.WrapT == GL_REPEAT &&
-                     swImg->_IsPowerOfTwo &&
-                     img->Border == 0 &&
-                     img->TexFormat == MESA_FORMAT_RGBA8888) {
-               return &opt_sample_rgba_2d;
-            }
-            else {
-               return &sample_nearest_2d;
+                img->Border == 0) {
+               if (img->TexFormat == MESA_FORMAT_RGB888)
+                  func = &opt_sample_rgb_2d;
+               else if (img->TexFormat == MESA_FORMAT_RGBA8888)
+                  func = &opt_sample_rgba_2d;
             }
+
+            return func;
          }
       case GL_TEXTURE_3D:
          if (needLambda) {