| @@ -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)) | |||