mesa: define, use _mesa_is_cube_face() in several places
authorBrian Paul <brianp@vmware.com>
Sat, 19 Nov 2011 00:39:00 +0000 (17:39 -0700)
committerBrian Paul <brianp@vmware.com>
Sat, 19 Nov 2011 14:28:07 +0000 (07:28 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/fbobject.c
src/mesa/main/texgetimage.c
src/mesa/main/teximage.c
src/mesa/main/teximage.h

index f8b148cee8bc62200debb8a0d8aea0cf6eb7f0f6..5b329f5c3e564c8d0aeea6940c069e4130d7d813 100644 (file)
@@ -78,14 +78,6 @@ static struct gl_renderbuffer DummyRenderbuffer;
 static struct gl_framebuffer IncompleteFramebuffer;
 
 
-static inline GLboolean
-is_cube_face(GLenum target)
-{
-   return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
-           target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
-}
-
-
 /**
  * Is the given FBO a user-created FBO?
  */
@@ -2008,7 +2000,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
          }
          else {
             err = (texObj->Target == GL_TEXTURE_CUBE_MAP)
-                ? !is_cube_face(textarget)
+                ? !_mesa_is_cube_face(textarget)
                 : (texObj->Target != textarget);
          }
       }
index 31d49f2d8236525b320976dafe32a31b7196c89b..06506594d6313e96e4b8a0f93e936cade5bf7459 100644 (file)
@@ -386,11 +386,10 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type,
     * so we don't have to worry about those.
     * XXX more format combinations could be supported here.
     */
-   if ((target == GL_TEXTURE_1D ||
-        target == GL_TEXTURE_2D ||
-        target == GL_TEXTURE_RECTANGLE ||
-        (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
-         target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
+   if (target == GL_TEXTURE_1D ||
+       target == GL_TEXTURE_2D ||
+       target == GL_TEXTURE_RECTANGLE ||
+       _mesa_is_cube_face(target)) {
       if ((texImage->TexFormat == MESA_FORMAT_ARGB8888 ||
              texImage->TexFormat == MESA_FORMAT_SARGB8) &&
           format == GL_BGRA &&
index a84d6873d3d8f0043aff97ee347094a68157d714..c8ea4329fe40c7174d9df2045c1646400b268425 100644 (file)
@@ -522,8 +522,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
 GLuint
 _mesa_tex_target_to_face(GLenum target)
 {
-   if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
-       target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)
+   if (_mesa_is_cube_face(target))
       return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
    else
       return 0;
@@ -3094,8 +3093,7 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
    }
 
    /* For cube map, width must equal height */
-   if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
-       target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) {
+   if (_mesa_is_cube_face(target) && width != height) {
       *reason = "width != height";
       return GL_INVALID_VALUE;
    }
@@ -3183,8 +3181,7 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions,
             return GL_INVALID_ENUM; /*target*/
          maxLevels = ctx->Const.MaxCubeTextureLevels;
       }
-      else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
-               target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+      else if (_mesa_is_cube_face(target)) {
          if (!ctx->Extensions.ARB_texture_cube_map)
             return GL_INVALID_ENUM; /*target*/
          maxLevels = ctx->Const.MaxCubeTextureLevels;
index fd315bea3db3b16716d0c3ce5b5cd0b4bcc4b251..9cc7d5a543e75b027b83adffad89e30ffd8dfdba 100644 (file)
 #include "formats.h"
 
 
+/** Is the given value one of the 6 cube faces? */
+static inline GLboolean
+_mesa_is_cube_face(GLenum target)
+{
+   return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+           target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
+}
+
+
+
 /** \name Internal functions */
 /*@{*/