mesa: remove GL_SGI_texture_color_table support
[mesa.git] / src / mesa / main / colortab.c
index 5ede76c1fb1a90048ef05233358e0f268424a790..026fa48786dc89c3e3f2cda64741133bfbed9fcd 100644 (file)
 #include "context.h"
 #include "image.h"
 #include "macros.h"
+#include "mfeatures.h"
+#include "mtypes.h"
+#include "pack.h"
 #include "state.h"
 #include "teximage.h"
 #include "texstate.h"
-#include "glapi/dispatch.h"
+#include "main/dispatch.h"
 
 
 #if FEATURE_colortable
@@ -176,7 +179,7 @@ set_component_sizes( struct gl_color_table *table )
  * \param [rgba]Bias - RGBA bias factors
  */
 static void
-store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
+store_colortable_entries(struct gl_context *ctx, struct gl_color_table *table,
                         GLsizei start, GLsizei count,
                         GLenum format, GLenum type, const GLvoid *data,
                         GLfloat rScale, GLfloat rBias,
@@ -297,50 +300,6 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
-      case GL_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
-         scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
-         bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
-         break;
-      case GL_PROXY_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION];
-         proxy = GL_TRUE;
-         break;
-      case GL_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
-            return;
-         }
-         table = &(texUnit->ColorTable);
-         scale = ctx->Pixel.TextureColorTableScale;
-         bias = ctx->Pixel.TextureColorTableBias;
-         break;
-      case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
-            return;
-         }
-         table = &(texUnit->ProxyColorTable);
-         proxy = GL_TRUE;
-         break;
-      case GL_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
-         scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
-         bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
-         break;
-      case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION];
-         proxy = GL_TRUE;
-         break;
-      case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
-         scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
-         bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
-         break;
-      case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
-         proxy = GL_TRUE;
-         break;
       default:
          /* try texture targets */
          {
@@ -407,8 +366,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
       _mesa_free_colortable_data(table);
 
       if (width > 0) {
-         table->TableF = (GLfloat *) _mesa_malloc(comps * width * sizeof(GLfloat));
-         table->TableUB = (GLubyte *) _mesa_malloc(comps * width * sizeof(GLubyte));
+         table->TableF = (GLfloat *) malloc(comps * width * sizeof(GLfloat));
+         table->TableUB = (GLubyte *) malloc(comps * width * sizeof(GLubyte));
 
         if (!table->TableF || !table->TableUB) {
            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
@@ -459,30 +418,6 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
-      case GL_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
-         scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
-         bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
-         break;
-      case GL_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
-            return;
-         }
-         table = &(texUnit->ColorTable);
-         scale = ctx->Pixel.TextureColorTableScale;
-         bias = ctx->Pixel.TextureColorTableBias;
-         break;
-      case GL_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
-         scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
-         bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
-         break;
-      case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
-         scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
-         bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
-         break;
       default:
          /* try texture targets */
          texObj = _mesa_select_tex_object(ctx, texUnit, target);
@@ -590,22 +525,6 @@ _mesa_GetColorTable( GLenum target, GLenum format,
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
-      case GL_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
-         break;
-      case GL_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
-            return;
-         }
-         table = &(texUnit->ColorTable);
-         break;
-      case GL_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
-         break;
-      case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
-         break;
       default:
          /* try texture targets */
          {
@@ -684,7 +603,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
       }
       break;
    case GL_RGBA:
-      _mesa_memcpy(rgba, table->TableF, 4 * table->Size * sizeof(GLfloat));
+      memcpy(rgba, table->TableF, 4 * table->Size * sizeof(GLfloat));
       break;
    default:
       _mesa_problem(ctx, "bad table format in glGetColorTable");
@@ -714,22 +633,6 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    switch (target) {
-   case GL_COLOR_TABLE_SGI:
-      scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
-      bias  = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
-      break;
-   case GL_TEXTURE_COLOR_TABLE_SGI:
-      scale = ctx->Pixel.TextureColorTableScale;
-      bias  = ctx->Pixel.TextureColorTableBias;
-      break;
-   case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
-      scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
-      bias  = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
-      break;
-   case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
-      scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
-      bias  = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
-      break;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
       return;
@@ -755,20 +658,7 @@ static void GLAPIENTRY
 _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 {
    GLfloat fparams[4];
-   if (pname == GL_COLOR_TABLE_SGI ||
-       pname == GL_TEXTURE_COLOR_TABLE_SGI ||
-       pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
-       pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
-      /* four values */
-      fparams[0] = (GLfloat) params[0];
-      fparams[1] = (GLfloat) params[1];
-      fparams[2] = (GLfloat) params[2];
-      fparams[3] = (GLfloat) params[3];
-   }
-   else {
-      /* one values */
-      fparams[0] = (GLfloat) params[0];
-   }
+   fparams[0] = (GLfloat) params[0];
    _mesa_ColorTableParameterfv(target, pname, fparams);
 }
 
@@ -786,70 +676,6 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
-      case GL_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]);
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]);
-            return;
-         }
-         break;
-      case GL_PROXY_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION];
-         break;
-      case GL_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
-            return;
-         }
-         table = &(texUnit->ColorTable);
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(params, ctx->Pixel.TextureColorTableScale);
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(params, ctx->Pixel.TextureColorTableBias);
-            return;
-         }
-         break;
-      case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
-            return;
-         }
-         table = &(texUnit->ProxyColorTable);
-         break;
-      case GL_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]);
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]);
-            return;
-         }
-         break;
-      case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION];
-         break;
-      case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]);
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]);
-            return;
-         }
-         break;
-      case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
-         break;
       default:
          /* try texture targets */
          {
@@ -913,100 +739,6 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
-      case GL_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION];
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
-            params[0] = (GLint) scale[0];
-            params[1] = (GLint) scale[1];
-            params[2] = (GLint) scale[2];
-            params[3] = (GLint) scale[3];
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
-            params[0] = (GLint) bias[0];
-            params[1] = (GLint) bias[1];
-            params[2] = (GLint) bias[2];
-            params[3] = (GLint) bias[3];
-            return;
-         }
-         break;
-      case GL_PROXY_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION];
-         break;
-      case GL_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
-            return;
-         }
-         table = &(texUnit->ColorTable);
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0];
-            params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1];
-            params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2];
-            params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3];
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0];
-            params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1];
-            params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2];
-            params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3];
-            return;
-         }
-         break;
-      case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
-            return;
-         }
-         table = &(texUnit->ProxyColorTable);
-         break;
-      case GL_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION];
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
-            params[0] = (GLint) scale[0];
-            params[1] = (GLint) scale[1];
-            params[2] = (GLint) scale[2];
-            params[3] = (GLint) scale[3];
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
-            params[0] = (GLint) bias[0];
-            params[1] = (GLint) bias[1];
-            params[2] = (GLint) bias[2];
-            params[3] = (GLint) bias[3];
-            return;
-         }
-         break;
-      case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION];
-         break;
-      case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
-            params[0] = (GLint) scale[0];
-            params[0] = (GLint) scale[1];
-            params[0] = (GLint) scale[2];
-            params[0] = (GLint) scale[3];
-            return;
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            GLfloat *bias = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
-            params[0] = (GLint) bias[0];
-            params[1] = (GLint) bias[1];
-            params[2] = (GLint) bias[2];
-            params[3] = (GLint) bias[3];
-            return;
-         }
-         break;
-      case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
-         table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
-         break;
       default:
          /* Try texture targets */
          {
@@ -1095,39 +827,11 @@ void
 _mesa_free_colortable_data( struct gl_color_table *p )
 {
    if (p->TableF) {
-      _mesa_free(p->TableF);
+      free(p->TableF);
       p->TableF = NULL;
    }
    if (p->TableUB) {
-      _mesa_free(p->TableUB);
+      free(p->TableUB);
       p->TableUB = NULL;
    }
 }
-
-
-/*
- * Initialize all colortables for a context.
- */
-void
-_mesa_init_colortables( GLcontext * ctx )
-{
-   GLuint i;
-   for (i = 0; i < COLORTABLE_MAX; i++) {
-      _mesa_init_colortable(&ctx->ColorTable[i]);
-      _mesa_init_colortable(&ctx->ProxyColorTable[i]);
-   }
-}
-
-
-/*
- * Free all colortable data for a context
- */
-void
-_mesa_free_colortables_data( GLcontext *ctx )
-{
-   GLuint i;
-   for (i = 0; i < COLORTABLE_MAX; i++) {
-      _mesa_free_colortable_data(&ctx->ColorTable[i]);
-      _mesa_free_colortable_data(&ctx->ProxyColorTable[i]);
-   }
-}