X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fcolortab.c;h=b0ba31c732f069e0670c0818b935611198a44df1;hb=e9ff76aa81d9bd973d46b7e46f1e4ece2112a5b7;hp=5ede76c1fb1a90048ef05233358e0f268424a790;hpb=d0b7ff551ab25153e3023871af3daa65b394a828;p=mesa.git diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 5ede76c1fb1..b0ba31c732f 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -29,10 +29,13 @@ #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,15 +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)"); @@ -323,24 +317,6 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, 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 +383,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,11 +435,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)"); @@ -473,16 +444,6 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, 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,9 +551,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)"); @@ -600,12 +558,6 @@ _mesa_GetColorTable( GLenum target, GLenum format, } 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 +636,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 +666,10 @@ _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,10 +695,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) { + if (pname == GL_TEXTURE_COLOR_TABLE_SGI) { /* four values */ fparams[0] = (GLfloat) params[0]; fparams[1] = (GLfloat) params[1]; @@ -786,20 +723,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)"); @@ -822,34 +745,6 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) } 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,28 +808,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)"); @@ -963,50 +836,6 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) } 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 +924,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]); - } -}