summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2003-12-23 21:43:54 +0000
committerBrian Paul <[email protected]>2003-12-23 21:43:54 +0000
commitf903e1142d2c1c22071c4f620229de27e73199a2 (patch)
tree20043ead4542ac3e558e920d729d0fbb1dd4477d /src
parent0ee5f6203c125898fdffbec8d5eea9269aa1559e (diff)
the optimized UNCLAMPED_FLOAT_TO_UBYTE macro was broken
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/imports.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 0c0a291e164..5cdac06ba82 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -8,9 +8,9 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.0
*
- * 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"),
@@ -510,8 +510,8 @@ static INLINE int iceil(float f)
/***
- *** UNCLAMPED_FLOAT_TO_UBYTE: map float from {0,1} to ubyte in [0,255]
- *** CLAMPED_FLOAT_TO_UBYTE: map float in [0,1] to ubyte in [0,255]
+ *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
+ *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
***/
#if defined(USE_IEEE) && !defined(DEBUG)
#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
@@ -522,13 +522,21 @@ static INLINE int iceil(float f)
do { \
fi_type __tmp; \
__tmp.f = (F); \
- UB = ((__tmp.i >= IEEE_0996) \
- ? ((GLint)__tmp.i < 0) ? (GLubyte)0 : (GLubyte)255 \
- : (__tmp.f = __tmp.f*(255.0F/256.0F) + 32768.0F, \
- (GLubyte)__tmp.i)); \
+ if (__tmp.i < 0) \
+ UB = (GLubyte) 0; \
+ else if (__tmp.i >= IEEE_0996) \
+ UB = (GLubyte) 255; \
+ else { \
+ __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \
+ UB = (GLubyte) __tmp.i; \
+ } \
+ } while (0)
+#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \
+ UB = (GLubyte) __tmp.i; \
} while (0)
-#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
- UNCLAMPED_FLOAT_TO_UBYTE(ub, f)
#else
#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))