summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/glide/fxddtex.c2
-rw-r--r--src/mesa/main/colortab.c84
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/pixel.c13
-rw-r--r--src/mesa/swrast/s_texture.c17
5 files changed, 69 insertions, 51 deletions
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c
index baaba8e6e31..bbf7dfad793 100644
--- a/src/mesa/drivers/glide/fxddtex.c
+++ b/src/mesa/drivers/glide/fxddtex.c
@@ -407,7 +407,7 @@ convertPalette(const fxMesaContext fxMesa, FxU32 data[256], const struct gl_colo
FxU32 r, g, b, a;
GLint i;
- ASSERT(!table->FloatTable);
+ ASSERT(table->Type == GL_UNSIGNED_BYTE);
switch (table->Format) {
case GL_INTENSITY:
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index a44f9a01c54..d0fa323c39b 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -99,12 +98,29 @@ base_colortab_format( GLenum format )
static void
set_component_sizes( struct gl_color_table *table )
{
+ GLubyte sz;
+
+ switch (table->Type) {
+ case GL_UNSIGNED_BYTE:
+ sz = sizeof(GLubyte);
+ break;
+ case GL_UNSIGNED_SHORT:
+ sz = sizeof(GLushort);
+ break;
+ case GL_FLOAT:
+ sz = sizeof(GLfloat);
+ break;
+ default:
+ _mesa_problem(NULL, "bad color table type in set_component_sizes 0x%x", table->Type);
+ return;
+ }
+
switch (table->Format) {
case GL_ALPHA:
table->RedSize = 0;
table->GreenSize = 0;
table->BlueSize = 0;
- table->AlphaSize = CHAN_BITS;
+ table->AlphaSize = sz;
table->IntensitySize = 0;
table->LuminanceSize = 0;
break;
@@ -114,37 +130,37 @@ set_component_sizes( struct gl_color_table *table )
table->BlueSize = 0;
table->AlphaSize = 0;
table->IntensitySize = 0;
- table->LuminanceSize = CHAN_BITS;
+ table->LuminanceSize = sz;
break;
case GL_LUMINANCE_ALPHA:
table->RedSize = 0;
table->GreenSize = 0;
table->BlueSize = 0;
- table->AlphaSize = CHAN_BITS;
+ table->AlphaSize = sz;
table->IntensitySize = 0;
- table->LuminanceSize = CHAN_BITS;
+ table->LuminanceSize = sz;
break;
case GL_INTENSITY:
table->RedSize = 0;
table->GreenSize = 0;
table->BlueSize = 0;
table->AlphaSize = 0;
- table->IntensitySize = CHAN_BITS;
+ table->IntensitySize = sz;
table->LuminanceSize = 0;
break;
case GL_RGB:
- table->RedSize = CHAN_BITS;
- table->GreenSize = CHAN_BITS;
- table->BlueSize = CHAN_BITS;
+ table->RedSize = sz;
+ table->GreenSize = sz;
+ table->BlueSize = sz;
table->AlphaSize = 0;
table->IntensitySize = 0;
table->LuminanceSize = 0;
break;
case GL_RGBA:
- table->RedSize = CHAN_BITS;
- table->GreenSize = CHAN_BITS;
- table->BlueSize = CHAN_BITS;
- table->AlphaSize = CHAN_BITS;
+ table->RedSize = sz;
+ table->GreenSize = sz;
+ table->BlueSize = sz;
+ table->AlphaSize = sz;
table->IntensitySize = 0;
table->LuminanceSize = 0;
break;
@@ -168,7 +184,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
GLint baseFormat;
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
- GLboolean floatTable = GL_FALSE;
+ GLenum tableType = CHAN_TYPE;
GLint comps;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
@@ -221,7 +237,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
break;
case GL_COLOR_TABLE:
table = &ctx->ColorTable;
- floatTable = GL_TRUE;
+ tableType = GL_FLOAT;
rScale = ctx->Pixel.ColorTableScale[0];
gScale = ctx->Pixel.ColorTableScale[1];
bScale = ctx->Pixel.ColorTableScale[2];
@@ -241,7 +257,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
return;
}
table = &(texUnit->ColorTable);
- floatTable = GL_TRUE;
+ tableType = GL_FLOAT;
rScale = ctx->Pixel.TextureColorTableScale[0];
gScale = ctx->Pixel.TextureColorTableScale[1];
bScale = ctx->Pixel.TextureColorTableScale[2];
@@ -261,7 +277,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
- floatTable = GL_TRUE;
+ tableType = GL_FLOAT;
rScale = ctx->Pixel.PCCTscale[0];
gScale = ctx->Pixel.PCCTscale[1];
bScale = ctx->Pixel.PCCTscale[2];
@@ -277,7 +293,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
break;
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
table = &ctx->PostColorMatrixColorTable;
- floatTable = GL_TRUE;
+ tableType = GL_FLOAT;
rScale = ctx->Pixel.PCMCTscale[0];
gScale = ctx->Pixel.PCMCTscale[1];
bScale = ctx->Pixel.PCMCTscale[2];
@@ -350,7 +366,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
table->Table = NULL;
}
if (width > 0) {
- if (floatTable) {
+ if (tableType == GL_FLOAT) {
GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
GLfloat *tableF;
GLint i;
@@ -360,7 +376,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
format, type, data, &ctx->Unpack,
0, GL_FALSE);
- table->FloatTable = GL_TRUE;
+ table->Type = GL_FLOAT;
table->Table = MALLOC(comps * width * sizeof(GLfloat));
if (!table->Table) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
@@ -413,7 +429,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
}
else {
/* store GLchan table */
- table->FloatTable = GL_FALSE;
+ table->Type = CHAN_TYPE;
table->Table = MALLOC(comps * width * sizeof(GLchan));
if (!table->Table) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
@@ -423,7 +439,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
(GLchan *) table->Table, /* dest */
format, type, data,
&ctx->Unpack, 0);
- } /* floatTable */
+ } /* type==GL_FLOAT */
} /* width > 0 */
} /* proxy */
@@ -556,7 +572,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
return;
}
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
GLchan *dest = (GLchan *) table->Table + start * comps * sizeof(GLchan);
_mesa_unpack_chan_color_span(ctx, count, table->Format, dest,
format, type, data, &ctx->Unpack, 0);
@@ -566,7 +582,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
GLfloat *tableF;
GLint i;
- ASSERT(table->FloatTable);
+ ASSERT(table->Type == GL_FLOAT);
_mesa_unpack_float_color_span(ctx, count, table->Format,
tempTab, /* dest */
@@ -718,11 +734,11 @@ _mesa_GetColorTable( GLenum target, GLenum format,
return;
}
- assert(table);
+ ASSERT(table);
switch (table->Format) {
case GL_ALPHA:
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
@@ -744,7 +760,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
}
break;
case GL_LUMINANCE:
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
@@ -766,7 +782,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
}
break;
case GL_LUMINANCE_ALPHA:
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
@@ -788,7 +804,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
}
break;
case GL_INTENSITY:
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
@@ -810,7 +826,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
}
break;
case GL_RGB:
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
@@ -832,7 +848,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
}
break;
case GL_RGBA:
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
@@ -1334,7 +1350,7 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
void
_mesa_init_colortable( struct gl_color_table *p )
{
- p->FloatTable = GL_FALSE;
+ p->Type = CHAN_TYPE;
p->Table = NULL;
p->Size = 0;
p->IntFormat = GL_RGBA;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 84fa39f261a..18e15631021 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -252,8 +252,8 @@ struct gl_color_table {
GLenum Format; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
GLenum IntFormat;
GLuint Size; /**< number of entries (rows) in table */
- GLvoid *Table; /**< either GLfloat * or GLchan * */
- GLboolean FloatTable; /**< are entries stored as floats? */
+ GLvoid *Table; /**< points to data of <Type> */
+ GLenum Type; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
GLubyte RedSize;
GLubyte GreenSize;
GLubyte BlueSize;
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 61c7e570da1..f211af91703 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -877,6 +877,7 @@ _mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4])
/*
* Apply a color table lookup to an array of colors.
+ * XXX merge with _swrast_texture_table_lookup in s_texture.c
*/
void
_mesa_lookup_rgba(const struct gl_color_table *table,
@@ -888,7 +889,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
switch (table->Format) {
case GL_INTENSITY:
/* replace RGBA with I */
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
@@ -915,7 +916,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
break;
case GL_LUMINANCE:
/* replace RGB with L */
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
@@ -940,7 +941,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
break;
case GL_ALPHA:
/* replace A with A */
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
@@ -963,7 +964,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
break;
case GL_LUMINANCE_ALPHA:
/* replace RGBA with LLLA */
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
@@ -1000,7 +1001,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
break;
case GL_RGB:
/* replace RGB with RGB */
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
@@ -1037,7 +1038,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
break;
case GL_RGBA:
/* replace RGBA with RGBA */
- if (!table->FloatTable) {
+ if (table->Type != GL_FLOAT) {
const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 496812f203d..5dff9874d52 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -346,6 +346,7 @@ repeat_remainder(GLint a, GLint b)
/*
* Do the lookup for GL_SGI_texture_color_table.
+ * XXX merge with _mesa_lookup_rgba in pixel.c
*/
void
_swrast_texture_table_lookup(const struct gl_color_table *table,
@@ -357,7 +358,7 @@ _swrast_texture_table_lookup(const struct gl_color_table *table,
switch (table->Format) {
case GL_INTENSITY:
/* replace RGBA with I */
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
@@ -397,7 +398,7 @@ _swrast_texture_table_lookup(const struct gl_color_table *table,
break;
case GL_LUMINANCE:
/* replace RGB with L */
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
@@ -434,7 +435,7 @@ _swrast_texture_table_lookup(const struct gl_color_table *table,
break;
case GL_ALPHA:
/* replace A with A */
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
@@ -470,7 +471,7 @@ _swrast_texture_table_lookup(const struct gl_color_table *table,
break;
case GL_LUMINANCE_ALPHA:
/* replace RGBA with LLLA */
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
@@ -516,7 +517,7 @@ _swrast_texture_table_lookup(const struct gl_color_table *table,
break;
case GL_RGB:
/* replace RGB with RGB */
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
@@ -560,7 +561,7 @@ _swrast_texture_table_lookup(const struct gl_color_table *table,
break;
case GL_RGBA:
/* replace RGBA with RGBA */
- if (table->FloatTable) {
+ if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
@@ -627,12 +628,12 @@ palette_sample(const GLcontext *ctx,
GLenum format;
if (ctx->Texture.SharedPalette) {
- ASSERT(!ctx->Texture.Palette.FloatTable);
+ ASSERT(ctx->Texture.Palette.Type != GL_FLOAT);
palette = (const GLchan *) ctx->Texture.Palette.Table;
format = ctx->Texture.Palette.Format;
}
else {
- ASSERT(!tObj->Palette.FloatTable);
+ ASSERT(tObj->Palette.Type != GL_FLOAT);
palette = (const GLchan *) tObj->Palette.Table;
format = tObj->Palette.Format;
}