mesa: Move [UN]CLAMPED_FLOAT_TO_UBYTE from imports.h to macros.h.
authorVinson Lee <vlee@vmware.com>
Fri, 9 Jul 2010 22:06:19 +0000 (15:06 -0700)
committerVinson Lee <vlee@vmware.com>
Fri, 9 Jul 2010 22:06:19 +0000 (15:06 -0700)
The other similar integer/float conversion macros are in macros.h.

src/mesa/drivers/dri/r128/r128_state.c
src/mesa/drivers/dri/r128/r128_tex.c
src/mesa/drivers/dri/sis/sis_state.c
src/mesa/main/imports.h
src/mesa/main/macros.h

index 4d773feaaa86e6c67cb0de121fb6fa3b8a17531d..9ad25f7f46391671a584a05a4d3ae5fcaa68c9b5 100644 (file)
@@ -42,6 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "main/enums.h"
 #include "main/colormac.h"
+#include "main/macros.h"
 #include "swrast/swrast.h"
 #include "vbo/vbo.h"
 #include "tnl/tnl.h"
index 4ec4be9a47b188c59d349a9d20981b96f527e8e1..b5a19b510af49c0923a7d138c60113e45b3fbdba 100644 (file)
@@ -44,6 +44,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/texobj.h"
 #include "main/imports.h"
 #include "main/texobj.h"
+#include "main/macros.h"
 
 #include "xmlpool.h"
 
index a22195cccebb72f03f4a2582d727126dfcd43c56..6173231a82eee14e63a5fb1954ce5a49a2010702 100644 (file)
@@ -37,6 +37,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "sis_lock.h"
 
 #include "main/context.h"
+#include "main/macros.h"
 #include "swrast/swrast.h"
 #include "vbo/vbo.h"
 #include "tnl/tnl.h"
index da825a095ea586dc977cc5272f8fe3e3c84ad080..9c2ffd66d69908dc74ce0b19c520e448ee684c77 100644 (file)
@@ -444,42 +444,6 @@ _mesa_next_pow_two_64(uint64_t x)
 }
 
 
-/***
- *** 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 */
-/* This function/macro is sensitive to precision.  Test very carefully
- * if you change it!
- */
-#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F)                                        \
-        do {                                                           \
-           fi_type __tmp;                                              \
-           __tmp.f = (F);                                              \
-           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)
-#else
-#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
-       ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
-#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
-       ub = ((GLubyte) IROUND((f) * 255.0F))
-#endif
-
-
 /**
  * Return 1 if this is a little endian machine, 0 if big endian.
  */
index 40e17e53d6ce1f2bf383f39836609d2eb47e5ec1..b2ec0ba9b73fbf91c4ade70ec558eac29f0ffbf7 100644 (file)
@@ -130,6 +130,41 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
 #define UNCLAMPED_FLOAT_TO_SHORT(s, f)  \
         s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F) )
 
+/***
+ *** 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 */
+/* This function/macro is sensitive to precision.  Test very carefully
+ * if you change it!
+ */
+#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F)                                        \
+        do {                                                           \
+           fi_type __tmp;                                              \
+           __tmp.f = (F);                                              \
+           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)
+#else
+#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
+       ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
+#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
+       ub = ((GLubyte) IROUND((f) * 255.0F))
+#endif
+
 /*@}*/