[Mesa-dev] [PATCH 1/3] mesa: define, use _mesa_is_cube_face() in several places

2011-11-18 Thread Brian Paul
---
 src/mesa/main/fbobject.c|   10 +-
 src/mesa/main/texgetimage.c |9 -
 src/mesa/main/teximage.c|9 +++--
 src/mesa/main/teximage.h|   10 ++
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f8b148c..5b329f5 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -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);
  }
   }
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 31d49f2..0650659 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -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_ARGB ||
  texImage-TexFormat == MESA_FORMAT_SARGB8) 
   format == GL_BGRA 
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index a84d687..c8ea432 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -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;
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index fd315be..9cc7d5a 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -36,6 +36,16 @@
 #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 */
 /*@{*/
 
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] mesa: define, use _mesa_is_cube_face() in several places

2011-11-18 Thread Kenneth Graunke
On 11/18/2011 04:39 PM, Brian Paul wrote:
 ---
  src/mesa/main/fbobject.c|   10 +-
  src/mesa/main/texgetimage.c |9 -
  src/mesa/main/teximage.c|9 +++--
  src/mesa/main/teximage.h|   10 ++
  4 files changed, 18 insertions(+), 20 deletions(-)

For the series:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev