From 33143303feaf84afbef2e63ac0adab2d70b3c344 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 10 Apr 2001 15:25:45 +0000 Subject: Added IROUND_POS() macro to mmath.h and use where appropriate. (Klaus Niederkrueger) --- src/mesa/main/pixel.c | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'src/mesa/main/pixel.c') diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 6a31d5a59fe..dc8f5be3073 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,4 +1,4 @@ -/* $Id: pixel.c,v 1.27 2001/03/12 00:48:38 gareth Exp $ */ +/* $Id: pixel.c,v 1.28 2001/04/10 15:25:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -832,10 +832,10 @@ _mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) const GLfloat *aMap = ctx->Pixel.MapAtoA; GLuint i; for (i=0;iTable; GLuint i; for (i = 0; i < n; i++) { - GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint j = IROUND(rgba[i][RCOMP] * scale); GLfloat c = CHAN_TO_FLOAT(lut[j]); rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = c; @@ -900,7 +900,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table, const GLfloat *lut = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < n; i++) { - GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint j = IROUND(rgba[i][RCOMP] * scale); GLfloat c = lut[j]; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = c; @@ -914,7 +914,7 @@ _mesa_lookup_rgba(const struct gl_color_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); + GLint j = IROUND(rgba[i][RCOMP] * scale); GLfloat c = CHAN_TO_FLOAT(lut[j]); rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; } @@ -924,7 +924,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table, const GLfloat *lut = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < n; i++) { - GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint j = IROUND(rgba[i][RCOMP] * scale); GLfloat c = lut[j]; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; } @@ -937,7 +937,7 @@ _mesa_lookup_rgba(const struct gl_color_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); + GLint j = IROUND(rgba[i][ACOMP] * scale); rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[j]); } } @@ -946,7 +946,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table, const GLfloat *lut = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < n; i++) { - GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + GLint j = IROUND(rgba[i][ACOMP] * scale); rgba[i][ACOMP] = lut[j]; } } @@ -958,8 +958,8 @@ _mesa_lookup_rgba(const struct gl_color_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); + GLint jL = IROUND(rgba[i][RCOMP] * scale); + GLint jA = IROUND(rgba[i][ACOMP] * scale); 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; @@ -971,8 +971,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table, const GLfloat *lut = (const GLfloat *) 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); + GLint jL = IROUND(rgba[i][RCOMP] * scale); + GLint jA = IROUND(rgba[i][ACOMP] * scale); GLfloat luminance = lut[jL * 2 + 0]; GLfloat alpha = lut[jA * 2 + 1]; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; @@ -987,9 +987,9 @@ _mesa_lookup_rgba(const struct gl_color_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 jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + GLint jB = IROUND(rgba[i][BCOMP] * scale); 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]); @@ -1000,9 +1000,9 @@ _mesa_lookup_rgba(const struct gl_color_table *table, const GLfloat *lut = (const GLfloat *) 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 jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + GLint jB = IROUND(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]; @@ -1016,10 +1016,10 @@ _mesa_lookup_rgba(const struct gl_color_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); + GLint jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + GLint jB = IROUND(rgba[i][BCOMP] * scale); + GLint jA = IROUND(rgba[i][ACOMP] * scale); 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]); @@ -1031,10 +1031,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table, const GLfloat *lut = (const GLfloat *) 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); + GLint jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + GLint jB = IROUND(rgba[i][BCOMP] * scale); + GLint jA = IROUND(rgba[i][ACOMP] * scale); rgba[i][RCOMP] = lut[jR * 4 + 0]; rgba[i][GCOMP] = lut[jG * 4 + 1]; rgba[i][BCOMP] = lut[jB * 4 + 2]; -- cgit v1.2.3