diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2000-10-29 18:12:14 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2000-10-29 18:12:14 +0000 |
commit | 699bc7b73d2fede77d3290f66c1ec355afd0373e (patch) | |
tree | e4db02b4dd9aa40fadf922c094014ed6541726c4 /src/mesa/main/pixel.c | |
parent | c893a015d8a50a38cd3f727d99835e7e7e2ccea9 (diff) |
More GLchan color channel changes.
Some header file re-org:
Move matrix, vertex buffer structs to types.h to fix #include mess.
Remove typedef, extern declarations from config.h
Diffstat (limited to 'src/mesa/main/pixel.c')
-rw-r--r-- | src/mesa/main/pixel.c | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 8a1d598200..131db1dfdd 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,4 +1,4 @@ -/* $Id: pixel.c,v 1.15 2000/10/28 20:41:14 brianp Exp $ */ +/* $Id: pixel.c,v 1.16 2000/10/29 18:12:15 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -755,11 +755,11 @@ _mesa_lookup_rgba(const struct gl_color_table *table, /* replace RGBA with I */ if (!table->FloatTable) { const GLfloat scale = (GLfloat) (table->Size - 1); - const GLubyte *lut = (const GLubyte *) table->Table; + const GLchan *lut = (const GLchan *) table->Table; GLuint i; for (i = 0; i < n; i++) { GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); - GLfloat c = lut[j] * (1.0F / 255.0F); + GLfloat c = CHAN_TO_FLOAT(lut[j]); rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = c; } @@ -781,11 +781,11 @@ _mesa_lookup_rgba(const struct gl_color_table *table, /* replace RGB with L */ if (!table->FloatTable) { const GLfloat scale = (GLfloat) (table->Size - 1); - const GLubyte *lut = (const GLubyte *) table->Table; + const GLchan *lut = (const GLchan *) table->Table; GLuint i; for (i = 0; i < n; i++) { GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); - GLfloat c = lut[j] * (1.0F / 255.0F); + GLfloat c = CHAN_TO_FLOAT(lut[j]); rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; } } @@ -804,11 +804,11 @@ _mesa_lookup_rgba(const struct gl_color_table *table, /* replace A with A */ if (!table->FloatTable) { const GLfloat scale = (GLfloat) (table->Size - 1); - const GLubyte *lut = (const GLubyte *) table->Table; + const GLchan *lut = (const GLchan *) table->Table; GLuint i; for (i = 0; i < n; i++) { GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F); - rgba[i][ACOMP] = lut[j] * (1.0F / 255.0F); + rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[j]); } } else { @@ -825,13 +825,13 @@ _mesa_lookup_rgba(const struct gl_color_table *table, /* replace RGBA with LLLA */ if (!table->FloatTable) { const GLfloat scale = (GLfloat) (table->Size - 1); - const GLubyte *lut = (const GLubyte *) table->Table; + const GLchan *lut = (const GLchan *) table->Table; GLuint i; for (i = 0; i < n; i++) { GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F); GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); - GLfloat luminance = lut[jL * 2 + 0] * (1.0F / 255.0F); - GLfloat alpha = lut[jA * 2 + 1] * (1.0F / 255.0F); + GLfloat luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]); + GLfloat alpha = CHAN_TO_FLOAT(lut[jA * 2 + 1]); rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; rgba[i][ACOMP] = alpha;; } @@ -854,15 +854,15 @@ _mesa_lookup_rgba(const struct gl_color_table *table, /* replace RGB with RGB */ if (!table->FloatTable) { const GLfloat scale = (GLfloat) (table->Size - 1); - const GLubyte *lut = (const GLubyte *) table->Table; + const GLchan *lut = (const GLchan *) table->Table; GLuint i; for (i = 0; i < n; i++) { GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); - rgba[i][RCOMP] = lut[jR * 3 + 0] * (1.0F / 255.0F); - rgba[i][GCOMP] = lut[jG * 3 + 1] * (1.0F / 255.0F); - rgba[i][BCOMP] = lut[jB * 3 + 2] * (1.0F / 255.0F); + 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]); } } else { @@ -883,17 +883,17 @@ _mesa_lookup_rgba(const struct gl_color_table *table, /* replace RGBA with RGBA */ if (!table->FloatTable) { const GLfloat scale = (GLfloat) (table->Size - 1); - const GLubyte *lut = (const GLubyte *) table->Table; + const GLchan *lut = (const GLchan *) table->Table; GLuint i; for (i = 0; i < n; i++) { GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); - rgba[i][RCOMP] = lut[jR * 4 + 0] * (1.0F / 255.0F); - rgba[i][GCOMP] = lut[jG * 4 + 1] * (1.0F / 255.0F); - rgba[i][BCOMP] = lut[jB * 4 + 2] * (1.0F / 255.0F); - rgba[i][ACOMP] = lut[jA * 4 + 3] * (1.0F / 255.0F); + 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]); } } else { @@ -966,9 +966,10 @@ _mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) * Map color indexes to rgba values. */ void -_mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n, - const GLuint index[], GLubyte rgba[][4] ) +_mesa_map_ci_to_rgba_chan( const GLcontext *ctx, GLuint n, + const GLuint index[], GLchan rgba[][4] ) { +#if CHAN_BITS == 8 GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; GLuint bmask = ctx->Pixel.MapItoBsize - 1; @@ -984,6 +985,23 @@ _mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n, rgba[i][BCOMP] = bMap[index[i] & bmask]; rgba[i][ACOMP] = aMap[index[i] & amask]; } +#else + GLuint rmask = ctx->Pixel.MapItoRsize - 1; + GLuint gmask = ctx->Pixel.MapItoGsize - 1; + GLuint bmask = ctx->Pixel.MapItoBsize - 1; + GLuint amask = ctx->Pixel.MapItoAsize - 1; + const GLfloat *rMap = ctx->Pixel.MapItoR; + const GLfloat *gMap = ctx->Pixel.MapItoG; + const GLfloat *bMap = ctx->Pixel.MapItoB; + const GLfloat *aMap = ctx->Pixel.MapItoA; + GLuint i; + for (i=0;i<n;i++) { + rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]); + rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]); + rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]); + rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]); + } +#endif } @@ -1017,8 +1035,9 @@ _mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n, */ void _mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], - GLubyte rgba[][4] ) + GLchan rgba[][4] ) { +#if CHAN_BITS == 8 GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; GLuint bmask = ctx->Pixel.MapItoBsize - 1; @@ -1034,6 +1053,23 @@ _mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], rgba[i][BCOMP] = bMap[index[i] & bmask]; rgba[i][ACOMP] = aMap[index[i] & amask]; } +#else + GLuint rmask = ctx->Pixel.MapItoRsize - 1; + GLuint gmask = ctx->Pixel.MapItoGsize - 1; + GLuint bmask = ctx->Pixel.MapItoBsize - 1; + GLuint amask = ctx->Pixel.MapItoAsize - 1; + const GLfloat *rMap = ctx->Pixel.MapItoR8; + const GLfloat *gMap = ctx->Pixel.MapItoG8; + const GLfloat *bMap = ctx->Pixel.MapItoB8; + const GLfloat *aMap = ctx->Pixel.MapItoA8; + GLuint i; + for (i=0;i<n;i++) { + rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]); + rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]); + rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]); + rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]); + } +#endif } |