Browse Source

move _swrast_texture_table_lookup() to _mesa_lookup_rgba_chan()

tags/R300_DRIVER_0
Brian Paul 21 years ago
parent
commit
d0582776a6

+ 9
- 9
src/mesa/main/image.c View File

} }
/* GL_COLOR_TABLE lookup */ /* GL_COLOR_TABLE lookup */
if (transferOps & IMAGE_COLOR_TABLE_BIT) { if (transferOps & IMAGE_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba);
} }
/* convolution */ /* convolution */
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
} }
/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba);
} }
/* color matrix transform */ /* color matrix transform */
if (transferOps & IMAGE_COLOR_MATRIX_BIT) { if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
} }
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba);
} }
/* update histogram count */ /* update histogram count */
if (transferOps & IMAGE_HISTOGRAM_BIT) { if (transferOps & IMAGE_HISTOGRAM_BIT) {
if (transferOps) { if (transferOps) {
/* GL_COLOR_TABLE lookup */ /* GL_COLOR_TABLE lookup */
if (transferOps & IMAGE_COLOR_TABLE_BIT) { if (transferOps & IMAGE_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba);
} }
/* convolution */ /* convolution */
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
} }
/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba);
} }
/* color matrix transform */ /* color matrix transform */
if (transferOps & IMAGE_COLOR_MATRIX_BIT) { if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
} }
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba);
} }
/* update histogram count */ /* update histogram count */
if (transferOps & IMAGE_HISTOGRAM_BIT) { if (transferOps & IMAGE_HISTOGRAM_BIT) {
if (transferOps) { if (transferOps) {
/* GL_COLOR_TABLE lookup */ /* GL_COLOR_TABLE lookup */
if (transferOps & IMAGE_COLOR_TABLE_BIT) { if (transferOps & IMAGE_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba);
} }
/* convolution */ /* convolution */
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
} }
/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba);
} }
/* color matrix transform */ /* color matrix transform */
if (transferOps & IMAGE_COLOR_MATRIX_BIT) { if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
} }
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
_mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba);
} }
/* update histogram count */ /* update histogram count */
if (transferOps & IMAGE_HISTOGRAM_BIT) { if (transferOps & IMAGE_HISTOGRAM_BIT) {

+ 321
- 52
src/mesa/main/pixel.c View File


/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
} }




/*
* Apply a color table lookup to an array of colors.
* XXX merge with _swrast_texture_table_lookup in s_texture.c
/**
* Apply a color table lookup to an array of floating point RGBA colors.
*/ */
void void
_mesa_lookup_rgba(const struct gl_color_table *table,
GLuint n, GLfloat rgba[][4])
_mesa_lookup_rgba_float(const struct gl_color_table *table,
GLuint n, GLfloat rgba[][4])
{ {
if (!table->Table || table->Size == 0) if (!table->Table || table->Size == 0)
return; return;
switch (table->Format) { switch (table->Format) {
case GL_INTENSITY: case GL_INTENSITY:
/* replace RGBA with I */ /* replace RGBA with I */
if (table->Type != GL_FLOAT) {
if (table->Type == GL_FLOAT) {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint j = IROUND(rgba[i][RCOMP] * scale); GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
GLfloat c = lut[CLAMP(j, 0, max)];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c; rgba[i][BCOMP] = rgba[i][ACOMP] = c;
} }
else { else {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLfloat *lut = (const GLfloat *) table->Table;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint j = IROUND(rgba[i][RCOMP] * scale); GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = lut[CLAMP(j, 0, max)];
GLfloat c = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c; rgba[i][BCOMP] = rgba[i][ACOMP] = c;
} }
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
/* replace RGB with L */ /* replace RGB with L */
if (table->Type != GL_FLOAT) {
if (table->Type == GL_FLOAT) {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint j = IROUND(rgba[i][RCOMP] * scale); GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
GLfloat c = lut[CLAMP(j, 0, max)];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
} }
} }
else { else {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLfloat *lut = (const GLfloat *) table->Table;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint j = IROUND(rgba[i][RCOMP] * scale); GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = lut[CLAMP(j, 0, max)];
GLfloat c = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
} }
} }
break; break;
case GL_ALPHA: case GL_ALPHA:
/* replace A with A */ /* replace A with A */
if (table->Type != GL_FLOAT) {
if (table->Type == GL_FLOAT) {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint j = IROUND(rgba[i][ACOMP] * scale); GLint j = IROUND(rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
rgba[i][ACOMP] = lut[CLAMP(j, 0, max)];
} }
} }
else {
else {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLfloat *lut = (const GLfloat *) table->Table;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint j = IROUND(rgba[i][ACOMP] * scale); GLint j = IROUND(rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = lut[CLAMP(j, 0, max)];
rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
} }
} }
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
/* replace RGBA with LLLA */ /* replace RGBA with LLLA */
if (table->Type != GL_FLOAT) {
if (table->Type == GL_FLOAT) {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint jL = IROUND(rgba[i][RCOMP] * scale); GLint jL = IROUND(rgba[i][RCOMP] * scale);
GLfloat luminance, alpha; GLfloat luminance, alpha;
jL = CLAMP(jL, 0, max); jL = CLAMP(jL, 0, max);
jA = CLAMP(jA, 0, max); jA = CLAMP(jA, 0, max);
luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]);
alpha = CHAN_TO_FLOAT(lut[jA * 2 + 1]);
luminance = lut[jL * 2 + 0];
alpha = lut[jA * 2 + 1];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;; rgba[i][ACOMP] = alpha;;
} }
else { else {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLfloat *lut = (const GLfloat *) table->Table;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint jL = IROUND(rgba[i][RCOMP] * scale); GLint jL = IROUND(rgba[i][RCOMP] * scale);
GLfloat luminance, alpha; GLfloat luminance, alpha;
jL = CLAMP(jL, 0, max); jL = CLAMP(jL, 0, max);
jA = CLAMP(jA, 0, max); jA = CLAMP(jA, 0, max);
luminance = lut[jL * 2 + 0];
alpha = lut[jA * 2 + 1];
luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]);
alpha = CHAN_TO_FLOAT(lut[jA * 2 + 1]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;; rgba[i][ACOMP] = alpha;;
} }
break; break;
case GL_RGB: case GL_RGB:
/* replace RGB with RGB */ /* replace RGB with RGB */
if (table->Type != GL_FLOAT) {
if (table->Type == GL_FLOAT) {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint jR = IROUND(rgba[i][RCOMP] * scale); GLint jR = IROUND(rgba[i][RCOMP] * scale);
jR = CLAMP(jR, 0, max); jR = CLAMP(jR, 0, max);
jG = CLAMP(jG, 0, max); jG = CLAMP(jG, 0, max);
jB = CLAMP(jB, 0, max); jB = CLAMP(jB, 0, max);
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 3 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 3 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 3 + 2]);
rgba[i][RCOMP] = lut[jR * 3 + 0];
rgba[i][GCOMP] = lut[jG * 3 + 1];
rgba[i][BCOMP] = lut[jB * 3 + 2];
} }
} }
else { else {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLfloat *lut = (const GLfloat *) table->Table;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint jR = IROUND(rgba[i][RCOMP] * scale); GLint jR = IROUND(rgba[i][RCOMP] * scale);
jR = CLAMP(jR, 0, max); jR = CLAMP(jR, 0, max);
jG = CLAMP(jG, 0, max); jG = CLAMP(jG, 0, max);
jB = CLAMP(jB, 0, max); jB = CLAMP(jB, 0, max);
rgba[i][RCOMP] = lut[jR * 3 + 0];
rgba[i][GCOMP] = lut[jG * 3 + 1];
rgba[i][BCOMP] = lut[jB * 3 + 2];
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 3 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 3 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 3 + 2]);
} }
} }
break; break;
case GL_RGBA: case GL_RGBA:
/* replace RGBA with RGBA */ /* replace RGBA with RGBA */
if (table->Type != GL_FLOAT) {
if (table->Type == GL_FLOAT) {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLchan *lut = (const GLchan *) table->Table;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint jR = IROUND(rgba[i][RCOMP] * scale); GLint jR = IROUND(rgba[i][RCOMP] * scale);
jG = CLAMP(jG, 0, max); jG = CLAMP(jG, 0, max);
jB = CLAMP(jB, 0, max); jB = CLAMP(jB, 0, max);
jA = CLAMP(jA, 0, max); jA = CLAMP(jA, 0, max);
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 4 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 4 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 4 + 2]);
rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[jA * 4 + 3]);
rgba[i][RCOMP] = lut[jR * 4 + 0];
rgba[i][GCOMP] = lut[jG * 4 + 1];
rgba[i][BCOMP] = lut[jB * 4 + 2];
rgba[i][ACOMP] = lut[jA * 4 + 3];
} }
} }
else { else {
const GLint max = table->Size - 1; const GLint max = table->Size - 1;
const GLfloat scale = (GLfloat) max; const GLfloat scale = (GLfloat) max;
const GLfloat *lut = (const GLfloat *) table->Table;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GLint jR = IROUND(rgba[i][RCOMP] * scale); GLint jR = IROUND(rgba[i][RCOMP] * scale);
jG = CLAMP(jG, 0, max); jG = CLAMP(jG, 0, max);
jB = CLAMP(jB, 0, max); jB = CLAMP(jB, 0, max);
jA = CLAMP(jA, 0, max); jA = CLAMP(jA, 0, max);
rgba[i][RCOMP] = lut[jR * 4 + 0];
rgba[i][GCOMP] = lut[jG * 4 + 1];
rgba[i][BCOMP] = lut[jB * 4 + 2];
rgba[i][ACOMP] = lut[jA * 4 + 3];
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 4 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 4 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 4 + 2]);
rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[jA * 4 + 3]);
}
}
break;
default:
_mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_float");
return;
}
}



/**
* Apply a color table lookup to an array of GLchan RGBA colors.
*/
void
_mesa_lookup_rgba_chan(const struct gl_color_table *table,
GLuint n, GLchan rgba[][4])
{
if (!table->Table || table->Size == 0)
return;

switch (table->Format) {
case GL_INTENSITY:
/* replace RGBA with I */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
const GLchan c = lut[rgba[i][RCOMP]];
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = lut[j];
}
}
}
break;
case GL_LUMINANCE:
/* replace RGB with L */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
const GLchan c = lut[rgba[i][RCOMP]];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = lut[j];
}
}
}
break;
case GL_ALPHA:
/* replace A with A */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][ACOMP] = c;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
rgba[i][ACOMP] = lut[rgba[i][ACOMP]];
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = lut[j];
}
}
}
break;
case GL_LUMINANCE_ALPHA:
/* replace RGBA with LLLA */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan luminance, alpha;
CLAMPED_FLOAT_TO_CHAN(luminance, lut[jL * 2 + 0]);
CLAMPED_FLOAT_TO_CHAN(alpha, lut[jA * 2 + 1]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLchan l = lut[rgba[i][RCOMP] * 2 + 0];
GLchan a = lut[rgba[i][ACOMP] * 2 + 1];;
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = l;
rgba[i][ACOMP] = a;
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan luminance = lut[jL * 2 + 0];
GLchan alpha = lut[jA * 2 + 1];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;
}
}
}
break;
case GL_RGB:
/* replace RGB with RGB */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 3 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 3 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 3 + 2]);
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 3 + 0];
rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 3 + 1];
rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 3 + 2];
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
rgba[i][RCOMP] = lut[jR * 3 + 0];
rgba[i][GCOMP] = lut[jG * 3 + 1];
rgba[i][BCOMP] = lut[jB * 3 + 2];
}
}
}
break;
case GL_RGBA:
/* replace RGBA with RGBA */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 4 + 0];
rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 4 + 1];
rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 4 + 2];
rgba[i][ACOMP] = lut[rgba[i][ACOMP] * 4 + 3];
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
}
} }
} }
break; break;
default: default:
_mesa_problem(NULL, "Bad format in _mesa_lookup_rgba");
_mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_chan");
return; return;
} }
} }

+ 8
- 4
src/mesa/main/pixel.h View File



/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),




extern void extern void
_mesa_lookup_rgba(const struct gl_color_table *table,
GLuint n, GLfloat rgba[][4]);
_mesa_lookup_rgba_float(const struct gl_color_table *table,
GLuint n, GLfloat rgba[][4]);

extern void
_mesa_lookup_rgba_chan(const struct gl_color_table *table,
GLuint n, GLchan rgba[][4]);




extern void extern void

+ 6
- 6
src/mesa/swrast/s_copypix.c View File

} }
/* GL_COLOR_TABLE lookup */ /* GL_COLOR_TABLE lookup */
if (transferOps & IMAGE_COLOR_TABLE_BIT) { if (transferOps & IMAGE_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->ColorTable, width, rgba);
_mesa_lookup_rgba_float(&ctx->ColorTable, width, rgba);
} }
} }




/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgba);
_mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, width, rgba);
} }
/* color matrix */ /* color matrix */
if (transferOps & IMAGE_COLOR_MATRIX_BIT) { if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
} }
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, width, rgba);
_mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, width, rgba);
} }
/* update histogram count */ /* update histogram count */
if (transferOps & IMAGE_HISTOGRAM_BIT) { if (transferOps & IMAGE_HISTOGRAM_BIT) {
} }
/* GL_COLOR_TABLE lookup */ /* GL_COLOR_TABLE lookup */
if (transferOps & IMAGE_COLOR_TABLE_BIT) { if (transferOps & IMAGE_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->ColorTable, width, rgbaFloat);
_mesa_lookup_rgba_float(&ctx->ColorTable, width, rgbaFloat);
} }
/* convolution */ /* convolution */
if (transferOps & IMAGE_CONVOLUTION_BIT) { if (transferOps & IMAGE_CONVOLUTION_BIT) {
} }
/* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgbaFloat);
_mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, width, rgbaFloat);
} }
/* color matrix */ /* color matrix */
if (transferOps & IMAGE_COLOR_MATRIX_BIT) { if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
} }
/* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
_mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, width, rgbaFloat);
_mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, width, rgbaFloat);
} }
/* update histogram count */ /* update histogram count */
if (transferOps & IMAGE_HISTOGRAM_BIT) { if (transferOps & IMAGE_HISTOGRAM_BIT) {

+ 2
- 272
src/mesa/swrast/s_texture.c View File

#include "colormac.h" #include "colormac.h"
#include "macros.h" #include "macros.h"
#include "imports.h" #include "imports.h"
#include "pixel.h"
#include "texformat.h" #include "texformat.h"
#include "teximage.h" #include "teximage.h"


#define K1BIT 32 #define K1BIT 32




/*
* 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,
GLuint n, GLchan rgba[][4])
{
if (!table->Table || table->Size == 0)
return;

switch (table->Format) {
case GL_INTENSITY:
/* replace RGBA with I */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
const GLchan c = lut[rgba[i][RCOMP]];
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = lut[j];
}
}
}
break;
case GL_LUMINANCE:
/* replace RGB with L */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
const GLchan c = lut[rgba[i][RCOMP]];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = lut[j];
}
}
}
break;
case GL_ALPHA:
/* replace A with A */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][ACOMP] = c;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
rgba[i][ACOMP] = lut[rgba[i][ACOMP]];
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = lut[j];
}
}
}
break;
case GL_LUMINANCE_ALPHA:
/* replace RGBA with LLLA */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan luminance, alpha;
CLAMPED_FLOAT_TO_CHAN(luminance, lut[jL * 2 + 0]);
CLAMPED_FLOAT_TO_CHAN(alpha, lut[jA * 2 + 1]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;;
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLchan l = lut[rgba[i][RCOMP] * 2 + 0];
GLchan a = lut[rgba[i][ACOMP] * 2 + 1];;
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = l;
rgba[i][ACOMP] = a;
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan luminance = lut[jL * 2 + 0];
GLchan alpha = lut[jA * 2 + 1];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
rgba[i][ACOMP] = alpha;
}
}
}
break;
case GL_RGB:
/* replace RGB with RGB */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 3 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 3 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 3 + 2]);
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 3 + 0];
rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 3 + 1];
rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 3 + 2];
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
rgba[i][RCOMP] = lut[jR * 3 + 0];
rgba[i][GCOMP] = lut[jG * 3 + 1];
rgba[i][BCOMP] = lut[jB * 3 + 2];
}
}
}
break;
case GL_RGBA:
/* replace RGBA with RGBA */
if (table->Type == GL_FLOAT) {
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
}
}
else {
#if CHAN_TYPE == GL_UNSIGNED_BYTE
if (table->Size == 256) {
/* common case */
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 4 + 0];
rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 4 + 1];
rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 4 + 2];
rgba[i][ACOMP] = lut[rgba[i][ACOMP] * 4 + 3];
}
}
else
#endif
{
const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
}
}
}
break;
default:
_mesa_problem(NULL, "Bad format in _swrast_texture_table_lookup");
return;
}
}




/* /*
* Get texture palette entry. * Get texture palette entry.


/* GL_SGI_texture_color_table */ /* GL_SGI_texture_color_table */
if (texUnit->ColorTableEnabled) { if (texUnit->ColorTableEnabled) {
_swrast_texture_table_lookup(&texUnit->ColorTable, span->end, texels);
_mesa_lookup_rgba_chan(&texUnit->ColorTable, span->end, texels);
} }
} }
} }

+ 2
- 7
src/mesa/swrast/s_texture.h View File


/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
#include "swrast.h" #include "swrast.h"




extern void
_swrast_texture_table_lookup( const struct gl_color_table *table,
GLuint n, GLchan rgba[][4] );

extern texture_sample_func extern texture_sample_func
_swrast_choose_texture_sample_func( GLcontext *ctx, _swrast_choose_texture_sample_func( GLcontext *ctx,
const struct gl_texture_object *tObj ); const struct gl_texture_object *tObj );

Loading…
Cancel
Save