Remove CVS keywords.
[mesa.git] / src / mesa / drivers / windows / gldirect / mesasw / colors.h
1 /* File name : colors.h
2 * Version : 2.3
3 *
4 * Header file for display driver for Mesa 2.3 under
5 * Windows95 and WindowsNT
6 * This file defines macros and global variables needed
7 * for converting color format
8 *
9 * Copyright (C) 1996- Li Wei
10 * Address : Institute of Artificial Intelligence
11 * : & Robotics
12 * : Xi'an Jiaotong University
13 * Email : liwei@aiar.xjtu.edu.cn
14 * Web page : http://sun.aiar.xjtu.edu.cn
15 *
16 * This file and its associations are partially based on the
17 * Windows NT driver for Mesa, written by Mark Leaming
18 * (mark@rsinc.com).
19 */
20
21 /*
22 * Macros for pixel format defined
23 */
24
25 /*
26 * Revision 1.1 2004/04/20 11:13:11 alanh
27 * add SciTech's GLDirect driver for Windows.
28 *
29 * This code is donated to Mesa which allows the usage of
30 * a Direct3D layer (DX7, DX8, DX9 or complete software fallback).
31 *
32 * No build system exists for this code yet, that will come.....
33 *
34 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
35 * Imported sources
36 *
37 * Revision 1.2 1999/01/03 03:08:57 brianp
38 * Ted Jump's changes
39 *
40 * Revision 1.1 1999/01/03 03:08:12 brianp
41 * Initial revision
42 *
43 * Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
44 * Add LUTs need for dithering
45 */
46
47 /*
48 * Revision 1.1 2004/04/20 11:13:11 alanh
49 * add SciTech's GLDirect driver for Windows.
50 *
51 * This code is donated to Mesa which allows the usage of
52 * a Direct3D layer (DX7, DX8, DX9 or complete software fallback).
53 *
54 * No build system exists for this code yet, that will come.....
55 *
56 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
57 * Imported sources
58 *
59 * Revision 1.2 1999/01/03 03:08:57 brianp
60 * Ted Jump's changes
61 *
62 * Revision 1.1 1999/01/03 03:08:12 brianp
63 * Initial revision
64 *
65 * Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
66 * Add BGR8 Macro
67 */
68
69 /*
70 * Revision 1.1 2004/04/20 11:13:11 alanh
71 * add SciTech's GLDirect driver for Windows.
72 *
73 * This code is donated to Mesa which allows the usage of
74 * a Direct3D layer (DX7, DX8, DX9 or complete software fallback).
75 *
76 * No build system exists for this code yet, that will come.....
77 *
78 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
79 * Imported sources
80 *
81 * Revision 1.2 1999/01/03 03:08:57 brianp
82 * Ted Jump's changes
83 *
84 * Revision 1.1 1999/01/03 03:08:12 brianp
85 * Initial revision
86 *
87 * Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
88 * Initial revision
89 */
90 /* Values for wmesa->pixelformat: */
91
92 #define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
93 #define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
94 #define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
95 #define PF_DITHER8 6 /* Dithered RGB using a lookup table */
96 #define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
97 #define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
98 #define PF_BADFORMAT 11
99 #define PF_INDEX8 12
100
101 char ColorMap16[] = {
102 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
103 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
104 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
105 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
106 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
107 0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
108 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
109 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
110 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
111 0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
112 0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
113 0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
114 0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
115 0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
116 0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
117 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
118 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
119 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
120 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
121 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
122 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
123 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
124 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
125 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
126 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
127 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
128 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
129 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
130 0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
131 0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
132 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
133 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
134
135 #define BGR8(r,g,b) (unsigned)(((BYTE)(b & 0xc0 | (g & 0xe0)>>2 | (r & 0xe0)>>5)))
136 #ifdef DDRAW
137 #define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
138 #else
139 #define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
140 #endif
141 #define BGR24(r,g,b) (unsigned long)(((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))) << 8)
142 #define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
143
144
145
146 /*
147 * If pixelformat==PF_8A8B8G8R:
148 */
149 #define PACK_8A8B8G8R( R, G, B, A ) \
150 ( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
151
152
153 /*
154 * If pixelformat==PF_8R8G8B:
155 */
156 #define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
157
158
159 /*
160 * If pixelformat==PF_5R6G5B:
161 */
162
163
164 #ifdef DDRAW
165 #define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
166 #else
167 #define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
168 #endif
169 /*----------------------------------------------------------------------------
170
171 Division lookup tables. These tables compute 0-255 divided by 51 and
172 modulo 51. These tables could approximate gamma correction.
173
174 */
175
176 char unsigned const aDividedBy51Rounded[256] =
177 {
178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
180 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
199 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
200 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
201 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
202 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
203 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
204 };
205
206 char unsigned const aModulo51[256] =
207 {
208 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
209 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
210 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
211 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
212 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
213 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
214 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
215 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
216 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
217 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
218 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
219 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
220 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
221 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
222 };
223
224 /*----------------------------------------------------------------------------
225
226 Multiplication LUTs. These compute 0-5 times 6 and 36.
227
228 */
229
230 char unsigned const aTimes6[6] =
231 {
232 0, 6, 12, 18, 24, 30
233 };
234
235 char unsigned const aTimes36[6] =
236 {
237 0, 36, 72, 108, 144, 180
238 };
239
240
241 /*----------------------------------------------------------------------------
242
243 Dither matrices for 8 bit to 2.6 bit halftones.
244
245 */
246
247 char unsigned const aHalftone16x16[256] =
248 {
249 0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
250 34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
251 38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
252 22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
253 2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
254 37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
255 40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
256 24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
257 2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
258 37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
259 40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
260 24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
261 1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
262 36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
263 39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
264 23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
265 };
266
267 char unsigned const aHalftone8x8[64] =
268 {
269 0, 38, 9, 47, 2, 40, 11, 50,
270 25, 12, 35, 22, 27, 15, 37, 24,
271 6, 44, 3, 41, 8, 47, 5, 43,
272 31, 19, 28, 15, 34, 21, 31, 18,
273 1, 39, 11, 49, 0, 39, 10, 48,
274 27, 14, 36, 23, 26, 13, 35, 23,
275 7, 46, 4, 43, 7, 45, 3, 42,
276 33, 20, 30, 17, 32, 19, 29, 16,
277 };
278
279 char unsigned const aHalftone4x4_1[16] =
280 {
281 0, 25, 6, 31,
282 38, 12, 44, 19,
283 9, 35, 3, 28,
284 47, 22, 41, 15
285 };
286
287 char unsigned const aHalftone4x4_2[16] =
288 {
289 41, 3, 9, 28,
290 35, 15, 22, 47,
291 6, 25, 38, 0,
292 19, 44, 31, 12
293 };
294
295 /***************************************************************************
296 aWinGHalftoneTranslation
297
298 Translates a 2.6 bit-per-pixel halftoned representation into the
299 slightly rearranged WinG Halftone Palette.
300 */
301
302 char unsigned const aWinGHalftoneTranslation[216] =
303 {
304 0,
305 29,
306 30,
307 31,
308 32,
309 249,
310 33,
311 34,
312 35,
313 36,
314 37,
315 38,
316 39,
317 40,
318 41,
319 42,
320 43,
321 44,
322 45,
323 46,
324 47,
325 48,
326 49,
327 50,
328 51,
329 52,
330 53,
331 54,
332 55,
333 56,
334 250,
335 250,
336 57,
337 58,
338 59,
339 251,
340 60,
341 61,
342 62,
343 63,
344 64,
345 65,
346 66,
347 67,
348 68,
349 69,
350 70,
351 71,
352 72,
353 73,
354 74,
355 75,
356 76,
357 77,
358 78,
359 79,
360 80,
361 81,
362 82,
363 83,
364 84,
365 85,
366 86,
367 87,
368 88,
369 89,
370 250,
371 90,
372 91,
373 92,
374 93,
375 94,
376 95,
377 96,
378 97,
379 98,
380 99,
381 100,
382 101,
383 102,
384 103,
385 104,
386 105,
387 106,
388 107,
389 108,
390 109,
391 110,
392 111,
393 227,
394 112,
395 113,
396 114,
397 115,
398 116,
399 117,
400 118,
401 119,
402 151,
403 120,
404 121,
405 122,
406 123,
407 124,
408 228,
409 125,
410 126,
411 229,
412 133,
413 162,
414 135,
415 131,
416 132,
417 137,
418 166,
419 134,
420 140,
421 130,
422 136,
423 143,
424 138,
425 139,
426 174,
427 141,
428 142,
429 177,
430 129,
431 144,
432 145,
433 146,
434 147,
435 148,
436 149,
437 150,
438 157,
439 152,
440 153,
441 154,
442 155,
443 156,
444 192,
445 158,
446 159,
447 160,
448 161,
449 196,
450 163,
451 164,
452 165,
453 127,
454 199,
455 167,
456 168,
457 169,
458 170,
459 171,
460 172,
461 173,
462 207,
463 175,
464 176,
465 210,
466 178,
467 179,
468 180,
469 181,
470 182,
471 183,
472 184,
473 185,
474 186,
475 187,
476 188,
477 189,
478 190,
479 191,
480 224,
481 193,
482 194,
483 195,
484 252,
485 252,
486 197,
487 198,
488 128,
489 253,
490 252,
491 200,
492 201,
493 202,
494 203,
495 204,
496 205,
497 206,
498 230,
499 208,
500 209,
501 231,
502 211,
503 212,
504 213,
505 214,
506 215,
507 216,
508 217,
509 218,
510 219,
511 220,
512 221,
513 222,
514 254,
515 223,
516 232,
517 225,
518 226,
519 255,
520 };