Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencolormac.h
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.3 00004 * 00005 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 00032 #ifndef COLORMAC_H 00033 #define COLORMAC_H 00034 00035 00036 #include "imports.h" 00037 #include "config.h" 00038 #include "macros.h" 00039 00040 00077 #if CHAN_BITS == 8 00078 00079 #define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b)) 00080 #define UBYTE_TO_CHAN(b) (b) 00081 #define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) ((s) >> 7)) 00082 #define USHORT_TO_CHAN(s) ((GLchan) ((s) >> 8)) 00083 #define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23)) 00084 #define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24)) 00085 00086 #define CHAN_TO_UBYTE(c) (c) 00087 #define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) 00088 00089 #define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) 00090 #define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f) 00091 00092 #define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC) 00093 00094 #define CHAN_PRODUCT(a, b) ((GLubyte) (((GLint)(a) * ((GLint)(b) + 1)) >> 8)) 00095 00096 #elif CHAN_BITS == 16 00097 00098 #define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (((GLchan) (b)) * 516)) 00099 #define UBYTE_TO_CHAN(b) ((((GLchan) (b)) << 8) | ((GLchan) (b))) 00100 #define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) (s)) 00101 #define USHORT_TO_CHAN(s) (s) 00102 #define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15)) 00103 #define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16)) 00104 00105 #define CHAN_TO_UBYTE(c) ((c) >> 8) 00106 #define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF))) 00107 00108 #define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f) 00109 #define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f) 00110 00111 #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) 00112 00113 #define CHAN_PRODUCT(a, b) ((GLchan) ((((GLuint) (a)) * ((GLuint) (b))) / 65535)) 00114 00115 #elif CHAN_BITS == 32 00116 00117 /* XXX floating-point color channels not fully thought-out */ 00118 #define BYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 127.0F))) 00119 #define UBYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 255.0F))) 00120 #define SHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 32767.0F))) 00121 #define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F))) 00122 #define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F))) 00123 #define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F))) 00124 00125 #define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c) 00126 #define CHAN_TO_FLOAT(c) (c) 00127 00128 #define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f) 00129 #define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f) 00130 00131 #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) 00132 00133 #define CHAN_PRODUCT(a, b) ((a) * (b)) 00134 00135 #else 00136 00137 #error unexpected CHAN_BITS size 00138 00139 #endif 00140 00141 00150 #define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \ 00151 do { \ 00152 UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \ 00153 UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \ 00154 UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \ 00155 } while (0) 00156 00157 00166 #define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \ 00167 do { \ 00168 UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \ 00169 UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \ 00170 UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \ 00171 UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]); \ 00172 } while (0) 00173 00174 00175 00182 00183 #define PACK_COLOR_8888( X, Y, Z, W ) \ 00184 (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W)) 00185 00186 #define PACK_COLOR_8888_REV( X, Y, Z, W ) \ 00187 (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X)) 00188 00189 #define PACK_COLOR_888( X, Y, Z ) \ 00190 (((X) << 16) | ((Y) << 8) | (Z)) 00191 00192 #define PACK_COLOR_565( X, Y, Z ) \ 00193 ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3)) 00194 00195 #define PACK_COLOR_565_REV( X, Y, Z ) \ 00196 (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5)) 00197 00198 #define PACK_COLOR_5551( R, G, B, A ) \ 00199 ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \ 00200 ((A) ? 1 : 0)) 00201 00202 #define PACK_COLOR_1555( A, B, G, R ) \ 00203 ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ 00204 ((A) ? 0x8000 : 0)) 00205 00206 #define PACK_COLOR_1555_REV( A, B, G, R ) \ 00207 ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \ 00208 ((A) ? 0x80 : 0)) 00209 00210 #define PACK_COLOR_4444( R, G, B, A ) \ 00211 ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4)) 00212 00213 #define PACK_COLOR_4444_REV( R, G, B, A ) \ 00214 ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4)) 00215 00216 #define PACK_COLOR_88( L, A ) \ 00217 (((L) << 8) | (A)) 00218 00219 #define PACK_COLOR_88_REV( L, A ) \ 00220 (((A) << 8) | (L)) 00221 00222 #define PACK_COLOR_332( R, G, B ) \ 00223 (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6)) 00224 00225 #define PACK_COLOR_233( B, G, R ) \ 00226 (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5)) 00227 00231 #endif /* COLORMAC_H */ Generated on Sat May 26 2012 04:18:58 for ReactOS by
1.7.6.1
|