mesa: move _mesa_base_format_has_channel() into image.c
authorBrian Paul <brianp@vmware.com>
Wed, 23 Nov 2011 22:33:46 +0000 (15:33 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 28 Nov 2011 15:07:32 +0000 (08:07 -0700)
This is where other format-related functions live.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/fbobject.c
src/mesa/main/image.c
src/mesa/main/image.h
src/mesa/main/texparam.c
src/mesa/main/texparam.h

index 2b4c70afbf7785be24c2626307e906ca70ba3717..9111caa1b56a93144118ae8a858e40ae1a5b3e58 100644 (file)
@@ -39,6 +39,7 @@
 #include "formats.h"
 #include "framebuffer.h"
 #include "hash.h"
+#include "image.h"
 #include "macros.h"
 #include "mfeatures.h"
 #include "mtypes.h"
@@ -46,7 +47,6 @@
 #include "state.h"
 #include "teximage.h"
 #include "texobj.h"
-#include "texparam.h"
 
 
 /** Set this to 1 to help debug FBO incompleteness problems */
index f32ca921a8dfd5055c335e13e1e7014abc7e314c..9b9e83802936248918b5bb97a82bb601b69c1ccd 100644 (file)
@@ -1070,6 +1070,93 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
 }
 
 
+/**
+ * Does the given base texture/renderbuffer format have the channel
+ * named by 'pname'?
+ */
+GLboolean
+_mesa_base_format_has_channel(GLenum base_format, GLenum pname)
+{
+   switch (pname) {
+   case GL_TEXTURE_RED_SIZE:
+   case GL_TEXTURE_RED_TYPE:
+   case GL_RENDERBUFFER_RED_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+      if (base_format == GL_RED ||
+         base_format == GL_RG ||
+         base_format == GL_RGB ||
+         base_format == GL_RGBA) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_TEXTURE_GREEN_SIZE:
+   case GL_TEXTURE_GREEN_TYPE:
+   case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+      if (base_format == GL_RG ||
+         base_format == GL_RGB ||
+         base_format == GL_RGBA) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_TEXTURE_BLUE_SIZE:
+   case GL_TEXTURE_BLUE_TYPE:
+   case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+      if (base_format == GL_RGB ||
+         base_format == GL_RGBA) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_TEXTURE_ALPHA_SIZE:
+   case GL_TEXTURE_ALPHA_TYPE:
+   case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+      if (base_format == GL_RGBA ||
+         base_format == GL_ALPHA ||
+         base_format == GL_LUMINANCE_ALPHA) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_TEXTURE_LUMINANCE_SIZE:
+   case GL_TEXTURE_LUMINANCE_TYPE:
+      if (base_format == GL_LUMINANCE ||
+         base_format == GL_LUMINANCE_ALPHA) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_TEXTURE_INTENSITY_SIZE:
+   case GL_TEXTURE_INTENSITY_TYPE:
+      if (base_format == GL_INTENSITY) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_TEXTURE_DEPTH_SIZE:
+   case GL_TEXTURE_DEPTH_TYPE:
+   case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+      if (base_format == GL_DEPTH_STENCIL ||
+         base_format == GL_DEPTH_COMPONENT) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+   case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+      if (base_format == GL_DEPTH_STENCIL ||
+         base_format == GL_STENCIL_INDEX) {
+        return GL_TRUE;
+      }
+      return GL_FALSE;
+   default:
+      _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
+                   __FUNCTION__, pname);
+      return GL_FALSE;
+   }
+
+   return GL_FALSE;
+}
+
+
 /**
  * Return the address of a specific pixel in an image (1D, 2D or 3D).
  *
index 46adaec4149c82d45b09755cbb519d1a93f944e9..b606545b7fb18a50020c626a7f0574f017b6d24a 100644 (file)
@@ -84,6 +84,9 @@ _mesa_is_integer_format(GLenum format);
 extern GLboolean
 _mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
 
+extern GLboolean
+_mesa_base_format_has_channel(GLenum base_format, GLenum pname);
+
 extern GLvoid *
 _mesa_image_address( GLuint dimensions,
                      const struct gl_pixelstore_attrib *packing,
index 99a4b432b412739ad02f06003aaf61623456be05..f4ec6338866b3d360174c7b75d448d70bdec4832 100644 (file)
@@ -35,6 +35,7 @@
 #include "main/context.h"
 #include "main/enums.h"
 #include "main/formats.h"
+#include "main/image.h"
 #include "main/macros.h"
 #include "main/mfeatures.h"
 #include "main/mtypes.h"
@@ -884,89 +885,6 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
 }
 
 
-GLboolean
-_mesa_base_format_has_channel(GLenum base_format, GLenum pname)
-{
-   switch (pname) {
-   case GL_TEXTURE_RED_SIZE:
-   case GL_TEXTURE_RED_TYPE:
-   case GL_RENDERBUFFER_RED_SIZE_EXT:
-   case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
-      if (base_format == GL_RED ||
-         base_format == GL_RG ||
-         base_format == GL_RGB ||
-         base_format == GL_RGBA) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_TEXTURE_GREEN_SIZE:
-   case GL_TEXTURE_GREEN_TYPE:
-   case GL_RENDERBUFFER_GREEN_SIZE_EXT:
-   case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
-      if (base_format == GL_RG ||
-         base_format == GL_RGB ||
-         base_format == GL_RGBA) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_TEXTURE_BLUE_SIZE:
-   case GL_TEXTURE_BLUE_TYPE:
-   case GL_RENDERBUFFER_BLUE_SIZE_EXT:
-   case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
-      if (base_format == GL_RGB ||
-         base_format == GL_RGBA) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_TEXTURE_ALPHA_SIZE:
-   case GL_TEXTURE_ALPHA_TYPE:
-   case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
-   case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
-      if (base_format == GL_RGBA ||
-         base_format == GL_ALPHA ||
-         base_format == GL_LUMINANCE_ALPHA) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_TEXTURE_LUMINANCE_SIZE:
-   case GL_TEXTURE_LUMINANCE_TYPE:
-      if (base_format == GL_LUMINANCE ||
-         base_format == GL_LUMINANCE_ALPHA) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_TEXTURE_INTENSITY_SIZE:
-   case GL_TEXTURE_INTENSITY_TYPE:
-      if (base_format == GL_INTENSITY) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_TEXTURE_DEPTH_SIZE:
-   case GL_TEXTURE_DEPTH_TYPE:
-   case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
-   case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
-      if (base_format == GL_DEPTH_STENCIL ||
-         base_format == GL_DEPTH_COMPONENT) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
-   case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
-      if (base_format == GL_DEPTH_STENCIL ||
-         base_format == GL_STENCIL_INDEX) {
-        return GL_TRUE;
-      }
-      return GL_FALSE;
-   default:
-      _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
-                   __FUNCTION__, pname);
-      return GL_FALSE;
-   }
-
-   return GL_FALSE;
-}
-
-
 void GLAPIENTRY
 _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
                               GLenum pname, GLfloat *params )
index 6c6b7fa671ed2b7453b7f0b69d134c4a7fb88f58..19b4116c0b6fdf756781a2382eca23f94e8e3fcc 100644 (file)
@@ -30,9 +30,6 @@
 #include "main/glheader.h"
 
 
-extern GLboolean
-_mesa_base_format_has_channel(GLenum base_format, GLenum pname);
-
 extern void GLAPIENTRY
 _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
                               GLenum pname, GLfloat *params );