summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/colormac.h23
-rw-r--r--src/mesa/main/image.c14
-rw-r--r--src/mesa/main/pixel.c18
3 files changed, 32 insertions, 23 deletions
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index 6101ab02256..94e4af51ece 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,4 +1,4 @@
-/* $Id: colormac.h,v 1.5 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: colormac.h,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -52,7 +52,6 @@
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))
#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)
-#define FLOAT_TO_CHAN(f) ( (GLchan) IROUND((f) * CHAN_MAXF) )
#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f)
@@ -72,7 +71,6 @@
#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF) + 0.5F))
-#define FLOAT_TO_CHAN(f) ((GLchan) IROUND((f) * CHAN_MAXF))
#define CLAMPED_FLOAT_TO_CHAN(c, f) \
c = ((GLchan) IROUND((f) * CHAN_MAXF))
@@ -95,9 +93,8 @@
#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
#define CHAN_TO_FLOAT(c) (c)
-#define FLOAT_TO_CHAN(f) (f)
-#define CLAMPED_FLOAT_COLOR_TO_CHAN(c, f) c = (f)
+#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
@@ -115,12 +112,24 @@
/*
* Convert 3 channels at once.
*/
-#define FLOAT_RGB_TO_CHAN_RGB(dst, f) \
+#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \
do { \
UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
-} while(0)
+} while (0)
+
+
+/*
+ * Convert 4 channels at once.
+ */
+#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]); \
+} while (0)
#endif /* COLORMAC_H */
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 6c50fed23e4..de56f0be9d0 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.51 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: image.c,v 1.52 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -2721,7 +2721,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstRedIndex] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstRedIndex], rgba[i][RCOMP]);
dst += dstComponents;
}
}
@@ -2730,7 +2730,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstGreenIndex] = FLOAT_TO_CHAN(rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstGreenIndex], rgba[i][GCOMP]);
dst += dstComponents;
}
}
@@ -2739,7 +2739,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstBlueIndex] = FLOAT_TO_CHAN(rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstBlueIndex], rgba[i][BCOMP]);
dst += dstComponents;
}
}
@@ -2748,7 +2748,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstAlphaIndex] = FLOAT_TO_CHAN(rgba[i][ACOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstAlphaIndex], rgba[i][ACOMP]);
dst += dstComponents;
}
}
@@ -2760,7 +2760,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
assert(dstComponents == 1);
for (i = 0; i < n; i++) {
/* Intensity comes from red channel */
- dst[i] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]);
}
}
@@ -2770,7 +2770,7 @@ _mesa_unpack_chan_color_span( GLcontext *ctx,
assert(dstLuminanceIndex == 0);
for (i = 0; i < n; i++) {
/* Luminance comes from red channel */
- dst[0] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]);
dst += dstComponents;
}
}
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 6bbbbdfe3ec..270cbc7e8cb 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.22 2000/12/26 05:09:29 keithw Exp $ */
+/* $Id: pixel.c,v 1.23 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1126,10 +1126,10 @@ _mesa_map_ci_to_rgba_chan( const GLcontext *ctx, GLuint n,
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]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
}
#endif
}
@@ -1194,10 +1194,10 @@ _mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
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]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
}
#endif
}