mesa: Add missing include guards
[mesa.git] / src / mesa / main / texcompress_s3tc_tmp.h
index b67b7a299e7292b1c7fcb0adf2c8742f53130d9d..dbf8c871b7ab66ecc0f5a684cd1bd8f34968d76d 100644 (file)
@@ -22,6 +22,9 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#ifndef TEXCOMPRESS_S3TC_TMP_H
+#define TEXCOMPRESS_S3TC_TMP_H
+
 #ifdef __APPLE__
 #include <OpenGL/gl.h>
 #else
 #ifdef __APPLE__
 #include <OpenGL/gl.h>
 #else
@@ -36,19 +39,6 @@ typedef GLubyte GLchan;
 #define BCOMP 2
 #define ACOMP 3
 
 #define BCOMP 2
 #define ACOMP 3
 
-void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata,
-                            GLint i, GLint j, GLvoid *texel);
-void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata,
-                            GLint i, GLint j, GLvoid *texel);
-void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata,
-                            GLint i, GLint j, GLvoid *texel);
-void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
-                            GLint i, GLint j, GLvoid *texel);
-
-void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
-                     const GLubyte *srcPixData, GLenum destformat,
-                     GLubyte *dest, GLint dstRowStride);
-
 #define EXP5TO8R(packedcol)                                    \
    ((((packedcol) >> 8) & 0xf8) | (((packedcol) >> 13) & 0x7))
 
 #define EXP5TO8R(packedcol)                                    \
    ((((packedcol) >> 8) & 0xf8) | (((packedcol) >> 13) & 0x7))
 
@@ -118,7 +108,7 @@ static void dxt135_decode_imageblock ( const GLubyte *img_block_src,
 }
 
 
 }
 
 
-void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata,
+static void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata,
                          GLint i, GLint j, GLvoid *texel)
 {
    /* Extract the (i,j) pixel from pixdata and return it
                          GLint i, GLint j, GLvoid *texel)
 {
    /* Extract the (i,j) pixel from pixdata and return it
@@ -130,7 +120,7 @@ void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata,
 }
 
 
 }
 
 
-void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata,
+static void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata,
                          GLint i, GLint j, GLvoid *texel)
 {
    /* Extract the (i,j) pixel from pixdata and return it
                          GLint i, GLint j, GLvoid *texel)
 {
    /* Extract the (i,j) pixel from pixdata and return it
@@ -141,7 +131,7 @@ void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata,
    dxt135_decode_imageblock(blksrc, (i&3), (j&3), 1, texel);
 }
 
    dxt135_decode_imageblock(blksrc, (i&3), (j&3), 1, texel);
 }
 
-void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata,
+static void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata,
                          GLint i, GLint j, GLvoid *texel) {
 
    /* Extract the (i,j) pixel from pixdata and return it
                          GLint i, GLint j, GLvoid *texel) {
 
    /* Extract the (i,j) pixel from pixdata and return it
@@ -150,29 +140,12 @@ void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata,
 
    GLchan *rgba = (GLchan *) texel;
    const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 16);
 
    GLchan *rgba = (GLchan *) texel;
    const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 16);
-#if 0
-   /* Simple 32bit version. */
-/* that's pretty brain-dead for a single pixel, isn't it? */
-   const GLubyte bit_pos = 4 * ((j&3) * 4 + (i&3));
-   const GLuint alpha_low = blksrc[0] | (blksrc[1] << 8) | (blksrc[2] << 16) | (blksrc[3] << 24);
-   const GLuint alpha_high = blksrc[4] | (blksrc[5] << 8) | (blksrc[6] << 16) | (blksrc[7] << 24);
-
-   dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel);
-   if (bit_pos < 32)
-      rgba[ACOMP] = UBYTE_TO_CHAN( (GLubyte)(EXP4TO8((alpha_low >> bit_pos) & 15)) );
-   else
-      rgba[ACOMP] = UBYTE_TO_CHAN( (GLubyte)(EXP4TO8((alpha_high >> (bit_pos - 32)) & 15)) );
-#endif
-#if 1
-/* TODO test this! */
    const GLubyte anibble = (blksrc[((j&3) * 4 + (i&3)) / 2] >> (4 * (i&1))) & 0xf;
    dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel);
    rgba[ACOMP] = UBYTE_TO_CHAN( (GLubyte)(EXP4TO8(anibble)) );
    const GLubyte anibble = (blksrc[((j&3) * 4 + (i&3)) / 2] >> (4 * (i&1))) & 0xf;
    dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel);
    rgba[ACOMP] = UBYTE_TO_CHAN( (GLubyte)(EXP4TO8(anibble)) );
-#endif
-
 }
 
 }
 
-void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
+static void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
                          GLint i, GLint j, GLvoid *texel) {
 
    /* Extract the (i,j) pixel from pixdata and return it
                          GLint i, GLint j, GLvoid *texel) {
 
    /* Extract the (i,j) pixel from pixdata and return it
@@ -183,74 +156,12 @@ void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
    const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 16);
    const GLubyte alpha0 = blksrc[0];
    const GLubyte alpha1 = blksrc[1];
    const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 16);
    const GLubyte alpha0 = blksrc[0];
    const GLubyte alpha1 = blksrc[1];
-#if 0
-   const GLubyte bit_pos = 3 * ((j&3) * 4 + (i&3));
-   /* simple 32bit version */
-   const GLuint bits_low = blksrc[2] | (blksrc[3] << 8) | (blksrc[4] << 16) | (blksrc[5] << 24);
-   const GLuint bits_high = blksrc[6] | (blksrc[7] << 8);
-   GLubyte code;
-
-   if (bit_pos < 30)
-      code = (GLubyte) ((bits_low >> bit_pos) & 7);
-   else if (bit_pos == 30)
-      code = (GLubyte) ((bits_low >> 30) & 3) | ((bits_high << 2) & 4);
-   else
-      code = (GLubyte) ((bits_high >> (bit_pos - 32)) & 7);
-#endif
-#if 1
-/* TODO test this! */
    const GLubyte bit_pos = ((j&3) * 4 + (i&3)) * 3;
    const GLubyte acodelow = blksrc[2 + bit_pos / 8];
    const GLubyte acodehigh = blksrc[3 + bit_pos / 8];
    const GLubyte code = (acodelow >> (bit_pos & 0x7) |
       (acodehigh  << (8 - (bit_pos & 0x7)))) & 0x7;
    const GLubyte bit_pos = ((j&3) * 4 + (i&3)) * 3;
    const GLubyte acodelow = blksrc[2 + bit_pos / 8];
    const GLubyte acodehigh = blksrc[3 + bit_pos / 8];
    const GLubyte code = (acodelow >> (bit_pos & 0x7) |
       (acodehigh  << (8 - (bit_pos & 0x7)))) & 0x7;
-#endif
    dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel);
    dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel);
-#if 0
-   if (alpha0 > alpha1) {
-      switch (code) {
-      case 0:
-         rgba[ACOMP] = UBYTE_TO_CHAN( alpha0 );
-         break;
-      case 1:
-         rgba[ACOMP] = UBYTE_TO_CHAN( alpha1 );
-         break;
-      case 2:
-      case 3:
-      case 4:
-      case 5:
-      case 6:
-      case 7:
-         rgba[ACOMP] = UBYTE_TO_CHAN( ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7) );
-         break;
-      }
-   }
-   else {
-      switch (code) {
-      case 0:
-         rgba[ACOMP] = UBYTE_TO_CHAN( alpha0 );
-         break;
-      case 1:
-         rgba[ACOMP] = UBYTE_TO_CHAN( alpha1 );
-         break;
-      case 2:
-      case 3:
-      case 4:
-      case 5:
-         rgba[ACOMP] = UBYTE_TO_CHAN( ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5) );
-         break;
-      case 6:
-         rgba[ACOMP] = 0;
-         break;
-      case 7:
-         rgba[ACOMP] = CHAN_MAX;
-         break;
-      }
-   }
-#endif
-/* not sure. Which version is faster? */
-#if 1
-/* TODO test this */
    if (code == 0)
       rgba[ACOMP] = UBYTE_TO_CHAN( alpha0 );
    else if (code == 1)
    if (code == 0)
       rgba[ACOMP] = UBYTE_TO_CHAN( alpha0 );
    else if (code == 1)
@@ -263,7 +174,6 @@ void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
       rgba[ACOMP] = 0;
    else
       rgba[ACOMP] = CHAN_MAX;
       rgba[ACOMP] = 0;
    else
       rgba[ACOMP] = CHAN_MAX;
-#endif
 }
 
 
 }
 
 
@@ -275,8 +185,8 @@ void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
 
 #define ALPHACUT 127
 
 
 #define ALPHACUT 127
 
-static void fancybasecolorsearch( GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLubyte *bestcolor[2],
-                           GLint numxpixels, GLint numypixels, GLint type, GLboolean haveAlpha)
+static void fancybasecolorsearch( UNUSED GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLubyte *bestcolor[2],
+                           GLint numxpixels, GLint numypixels, UNUSED GLint type, UNUSED GLboolean haveAlpha)
 {
    /* use same luminance-weighted distance metric to determine encoding as for finding the base colors */
 
 {
    /* use same luminance-weighted distance metric to determine encoding as for finding the base colors */
 
@@ -996,7 +906,7 @@ static void extractsrccolors( GLubyte srcpixels[4][4][4], const GLchan *srcaddr,
 }
 
 
 }
 
 
-void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData,
+static void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData,
                      GLenum destFormat, GLubyte *dest, GLint dstRowStride)
 {
       GLubyte *blkaddr = dest;
                      GLenum destFormat, GLubyte *dest, GLint dstRowStride)
 {
       GLubyte *blkaddr = dest;
@@ -1076,7 +986,9 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *
       }
       break;
    default:
       }
       break;
    default:
-      fprintf(stderr, "libdxtn: Bad dstFormat %d in tx_compress_dxtn\n", destFormat);
+      assert(false);
       return;
    }
 }
       return;
    }
 }
+
+#endif