VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.4.2/cfb8bit.h@ 99743

Last change on this file since 99743 was 43272, checked in by vboxsync, 12 years ago

Additions/x11: more original X server headers.

  • Property svn:eol-style set to native
File size: 49.7 KB
Line 
1/*
2 * cfb8bit.h
3 *
4 * Defines which are only useful to 8 bit color frame buffers
5 *
6 * That doesn't seem to be true any more. Some of the macros in here
7 * are used for depths other than 8. Perhaps the file should be
8 * renamed. dpw
9 */
10
11/*
12
13Copyright 1989, 1998 The Open Group
14
15Permission to use, copy, modify, distribute, and sell this software and its
16documentation for any purpose is hereby granted without fee, provided that
17the above copyright notice appear in all copies and that both that
18copyright notice and this permission notice appear in supporting
19documentation.
20
21The above copyright notice and this permission notice shall be included in
22all copies or substantial portions of the Software.
23
24THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
31Except as contained in this notice, the name of The Open Group shall not be
32used in advertising or otherwise to promote the sale, use or other dealings
33in this Software without prior written authorization from The Open Group.
34*/
35
36
37#ifdef HAVE_DIX_CONFIG_H
38#include <dix-config.h>
39#endif
40
41#include "servermd.h"
42
43#if (BITMAP_BIT_ORDER == MSBFirst)
44#define GetBitGroup(x) (((PixelGroup) (x)) >> (PGSZ - PGSZB))
45#define NextBitGroup(x) ((x) <<= PGSZB)
46#define NextSomeBits(x,n) ((x) <<= (n))
47#else
48#define GetBitGroup(x) ((x) & PGSZBMSK)
49#define NextBitGroup(x) ((x) >>= PGSZB)
50#define NextSomeBits(x,n) ((x) >>= (n))
51#endif
52
53#define RotBitsLeft(x,k) ((x) = BitLeft (x,k) | \
54 BitRight (x, PGSZ-(k)))
55
56#if defined(__GNUC__) && defined(mc68020)
57#undef RotBitsLeft
58#define RotBitsLeft(x,k) asm("rol%.l %2,%0" \
59 : "=d" (x) \
60 : "0" (x), "dI" (k))
61#endif
62
63#if PSZ == 8
64
65#define GetPixelGroup(x) (cfb8StippleXor[GetBitGroup(x)])
66#define RRopPixels(dst,x) (DoRRop(dst,cfb8StippleAnd[x], cfb8StippleXor[x]))
67#define RRopPixelGroup(dst,x) (RRopPixels(dst,GetBitGroup(x)))
68#define MaskRRopPixels(dst,x,mask) (DoMaskRRop(dst,cfb8StippleAnd[x], cfb8StippleXor[x], mask))
69
70#define NUM_MASKS (1<<PPW) /* XXX goes in cfbmskbits.h? */
71extern int cfb8StippleMode, cfb8StippleAlu;
72extern PixelGroup cfb8StippleFg, cfb8StippleBg, cfb8StipplePm;
73extern PixelGroup cfb8StippleMasks[NUM_MASKS];
74extern PixelGroup cfb8StippleAnd[NUM_MASKS], cfb8StippleXor[NUM_MASKS];
75extern int cfb8StippleRRop;
76
77#define cfb8PixelMasks cfb8StippleMasks
78#define cfb8Pixels cfb8StippleXor
79
80#define cfb8CheckPixels(fg, bg) \
81 (FillOpaqueStippled == cfb8StippleMode && \
82 GXcopy == cfb8StippleAlu && \
83 ((fg) & PMSK) == cfb8StippleFg && \
84 ((bg) & PMSK) == cfb8StippleBg && \
85 PMSK == cfb8StipplePm)
86
87#define cfb8CheckOpaqueStipple(alu,fg,bg,pm) \
88 ((FillOpaqueStippled == cfb8StippleMode && \
89 (alu) == cfb8StippleAlu && \
90 ((fg) & PMSK) == cfb8StippleFg && \
91 ((bg) & PMSK) == cfb8StippleBg && \
92 ((pm) & PMSK) == cfb8StipplePm) ? 0 : cfb8SetOpaqueStipple(alu,fg,bg,pm))
93
94#define cfb8CheckStipple(alu,fg,pm) \
95 ((FillStippled == cfb8StippleMode && \
96 (alu) == cfb8StippleAlu && \
97 ((fg) & PMSK) == cfb8StippleFg && \
98 ((pm) & PMSK) == cfb8StipplePm) ? 0 : cfb8SetStipple(alu,fg,pm))
99
100#define cfb8SetPixels(fg,bg) cfb8SetOpaqueStipple(GXcopy,fg,bg,PMSK)
101
102/*
103 * These macros are shared between the unnatural spans code
104 * and the unnatural rectangle code. No reasonable person
105 * would attempt to use them anyplace else.
106 */
107
108#define NextUnnaturalStippleWord \
109 if (bitsLeft >= MFB_PPW) \
110 { \
111 inputBits = *srcTemp++; \
112 bitsLeft -= MFB_PPW; \
113 partBitsLeft = MFB_PPW; \
114 } \
115 else \
116 { \
117 inputBits = 0; \
118 if (bitsLeft) \
119 inputBits = *srcTemp & ~cfb8BitLenMasks[bitsLeft]; \
120 srcTemp = srcStart; \
121 partBitsLeft = bitsLeft; \
122 bitsLeft = bitsWhole; \
123 }
124
125#define NextUnnaturalStippleBits \
126 if (partBitsLeft >= PPW) { \
127 bits = GetBitGroup (inputBits); \
128 NextBitGroup (inputBits); \
129 partBitsLeft -= PPW; \
130 } else { \
131 bits = GetBitGroup (inputBits); \
132 nextPartBits = PPW - partBitsLeft; \
133 NextUnnaturalStippleWord \
134 if (partBitsLeft < nextPartBits) { \
135 if (partBitsLeft) {\
136 bits |= BitRight (GetBitGroup (inputBits), \
137 PPW - nextPartBits) & PPWMSK;\
138 nextPartBits -= partBitsLeft; \
139 } \
140 NextUnnaturalStippleWord \
141 } \
142 bits |= BitRight (GetBitGroup (inputBits), \
143 PPW - nextPartBits) & PPWMSK; \
144 NextSomeBits (inputBits, nextPartBits); \
145 partBitsLeft -= nextPartBits; \
146 }
147
148#define NextUnnaturalStippleBitsFast \
149 if (partBitsLeft >= PPW) { \
150 bits = GetBitGroup(inputBits); \
151 NextBitGroup(inputBits); \
152 partBitsLeft -= PPW; \
153 } else { \
154 bits = GetBitGroup (inputBits); \
155 nextPartBits = PPW - partBitsLeft; \
156 inputBits = *srcTemp++; \
157 bits |= BitRight (GetBitGroup (inputBits), \
158 partBitsLeft) & PPWMSK; \
159 NextSomeBits (inputBits, nextPartBits); \
160 partBitsLeft = MFB_PPW - nextPartBits; \
161 }
162
163/*
164 * WriteBitGroup takes the destination address, a pixel
165 * value (which must be 8 bits duplicated 4 time with PFILL)
166 * and the PPW bits to write, which must be in the low order
167 * bits of the register (probably from GetBitGroup) and writes
168 * the appropriate locations in memory with the pixel value. This
169 * is a copy-mode only operation.
170 */
171
172#define RRopBitGroup(dst,bits) \
173 { \
174 *(dst) = RRopPixels(*(dst),bits); \
175 }
176
177#define MaskRRopBitGroup(dst,bits,mask) \
178 { \
179 *(dst) = MaskRRopPixels(*(dst),bits,mask); \
180 }
181#endif /* PSZ == 8 */
182
183#if !defined(AVOID_MEMORY_READ) && PSZ == 8
184
185#define WriteBitGroup(dst,pixel,bits) \
186 { \
187 register PixelGroup _maskTmp = cfb8PixelMasks[(bits)]; \
188 *(dst) = (*(dst) & ~_maskTmp) | ((pixel) & _maskTmp); \
189 }
190
191#define SwitchBitGroup(dst,pixel,bits) \
192 { \
193 register PixelGroup _maskTmp = cfb8PixelMasks[(bits)]; \
194 register PixelGroup _pixTmp = ((pixel) & _maskTmp); \
195 _maskTmp = ~_maskTmp; \
196 SwitchBitsLoop (*(dst) = (*(dst) & _maskTmp) | _pixTmp;) \
197 }
198
199#else /* AVOID_MEMORY_READ */
200
201#if PGSZ == 32
202#if (BITMAP_BIT_ORDER == MSBFirst)
203#define SinglePixel0 3
204#define SinglePixel1 2
205#define SinglePixel2 1
206#define SinglePixel3 0
207#define SinglePixel4 7
208#define SinglePixel5 6
209#define SinglePixel6 5
210#define SinglePixel7 4
211#define SinglePixel8 0xB
212#define SinglePixel9 0xA
213#define DoublePixel0 1
214#define DoublePixel1 0
215#define DoublePixel2 3
216#define DoublePixel3 2
217#define DoublePixel4 5
218#define DoublePixel5 4
219#else
220#define SinglePixel0 0
221#define SinglePixel1 1
222#define SinglePixel2 2
223#define SinglePixel3 3
224#define SinglePixel4 4
225#define SinglePixel5 5
226#define SinglePixel6 6
227#define SinglePixel7 7
228#define SinglePixel8 8
229#define SinglePixel9 9
230#define DoublePixel0 0
231#define DoublePixel1 1
232#define DoublePixel2 2
233#define DoublePixel3 3
234#define DoublePixel4 4
235#define DoublePixel5 5
236#endif
237#define QuadPixel0 0
238#define QuadPixel1 1
239#define QuadPixel2 2
240#else /* PGSZ == 64 */
241#if (BITMAP_BIT_ORDER == MSBFirst)
242#define SinglePixel0 7
243#define SinglePixel1 6
244#define SinglePixel2 5
245#define SinglePixel3 4
246#define SinglePixel4 3
247#define SinglePixel5 2
248#define SinglePixel6 1
249#define SinglePixel7 0
250#define DoublePixel0 3
251#define DoublePixel1 2
252#define DoublePixel2 1
253#define DoublePixel3 0
254#define QuadPixel0 1
255#define QuadPixel1 0
256#else
257#define SinglePixel0 0
258#define SinglePixel1 1
259#define SinglePixel2 2
260#define SinglePixel3 3
261#define SinglePixel4 4
262#define SinglePixel5 5
263#define SinglePixel6 6
264#define SinglePixel7 7
265#define DoublePixel0 0
266#define DoublePixel1 1
267#define DoublePixel2 2
268#define DoublePixel3 3
269#define QuadPixel0 0
270#define QuadPixel1 1
271#endif
272#define OctaPixel0 0
273#endif /* PGSZ == 64 */
274
275#if PSZ == 8
276
277#if PGSZ == 32
278#define WriteBitGroup(dst,pixel,bits) \
279 switch (bits) { \
280 case 0: \
281 break; \
282 case 1: \
283 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
284 break; \
285 case 2: \
286 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
287 break; \
288 case 3: \
289 ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
290 break; \
291 case 4: \
292 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
293 break; \
294 case 5: \
295 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
296 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
297 break; \
298 case 6: \
299 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
300 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
301 break; \
302 case 7: \
303 ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
304 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
305 break; \
306 case 8: \
307 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
308 break; \
309 case 9: \
310 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
311 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
312 break; \
313 case 10: \
314 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
315 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
316 break; \
317 case 11: \
318 ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
319 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
320 break; \
321 case 12: \
322 ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
323 break; \
324 case 13: \
325 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
326 ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
327 break; \
328 case 14: \
329 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
330 ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
331 break; \
332 case 15: \
333 ((CARD32 *) (dst))[0] = (pixel); \
334 break; \
335 }
336#else /* PGSZ == 64 */
337#define WriteBitGroup(dst,pixel,bits) \
338 if ( bits == 0xff ) \
339 ((PixelGroup *) (dst))[OctaPixel0] = (pixel); \
340 else { \
341 switch (bits & 0x0f) { \
342 case 0: \
343 break; \
344 case 1: \
345 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
346 break; \
347 case 2: \
348 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
349 break; \
350 case 3: \
351 ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
352 break; \
353 case 4: \
354 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
355 break; \
356 case 5: \
357 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
358 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
359 break; \
360 case 6: \
361 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
362 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
363 break; \
364 case 7: \
365 ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
366 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
367 break; \
368 case 8: \
369 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
370 break; \
371 case 9: \
372 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
373 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
374 break; \
375 case 10: \
376 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
377 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
378 break; \
379 case 11: \
380 ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
381 ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
382 break; \
383 case 12: \
384 ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
385 break; \
386 case 13: \
387 ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
388 ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
389 break; \
390 case 14: \
391 ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
392 ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
393 break; \
394 case 15: \
395 ((CARD32 *) (dst))[QuadPixel0] = (pixel); \
396 break; \
397 } \
398 switch ((bits & 0xf0) >> 4) { \
399 case 0: \
400 break; \
401 case 1: \
402 ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
403 break; \
404 case 2: \
405 ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
406 break; \
407 case 3: \
408 ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
409 break; \
410 case 4: \
411 ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
412 break; \
413 case 5: \
414 ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
415 ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
416 break; \
417 case 6: \
418 ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
419 ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
420 break; \
421 case 7: \
422 ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
423 ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
424 break; \
425 case 8: \
426 ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
427 break; \
428 case 9: \
429 ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
430 ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
431 break; \
432 case 10: \
433 ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
434 ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
435 break; \
436 case 11: \
437 ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
438 ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
439 break; \
440 case 12: \
441 ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
442 break; \
443 case 13: \
444 ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
445 ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
446 break; \
447 case 14: \
448 ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
449 ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
450 break; \
451 case 15: \
452 ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
453 break; \
454 } \
455 }
456#endif /* PGSZ == 64 */
457
458#if PGSZ == 32
459#define SwitchBitGroup(dst,pixel,bits) { \
460 switch (bits) { \
461 case 0: \
462 break; \
463 case 1: \
464 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel);) \
465 break; \
466 case 2: \
467 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel);) \
468 break; \
469 case 3: \
470 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel);) \
471 break; \
472 case 4: \
473 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
474 break; \
475 case 5: \
476 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
477 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
478 break; \
479 case 6: \
480 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
481 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
482 break; \
483 case 7: \
484 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
485 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
486 break; \
487 case 8: \
488 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
489 break; \
490 case 9: \
491 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
492 ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
493 break; \
494 case 10: \
495 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
496 ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
497 break; \
498 case 11: \
499 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
500 ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
501 break; \
502 case 12: \
503 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel1] = (pixel);) \
504 break; \
505 case 13: \
506 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
507 ((CARD16 *) (dst))[DoublePixel1] = (pixel);) \
508 break; \
509 case 14: \
510 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
511 ((CARD16 *) (dst))[DoublePixel1] = (pixel);) \
512 break; \
513 case 15: \
514 SwitchBitsLoop (((CARD32 *) (dst))[0] = (pixel);) \
515 break; \
516 } \
517}
518#else /* PGSZ == 64 */
519#define SwitchBitGroup(dst,pixel,bits) { \
520 if ( bits == 0xff ) \
521 SwitchBitsLoop (((PixelGroup *) (dst))[OctaPixel0] = (pixel);) \
522 else { \
523 switch (bits & 0x0f) { \
524 case 0: \
525 break; \
526 case 1: \
527 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel);) \
528 break; \
529 case 2: \
530 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel);) \
531 break; \
532 case 3: \
533 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel);)\
534 break; \
535 case 4: \
536 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
537 break; \
538 case 5: \
539 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
540 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
541 break; \
542 case 6: \
543 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
544 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
545 break; \
546 case 7: \
547 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
548 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
549 break; \
550 case 8: \
551 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
552 break; \
553 case 9: \
554 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
555 ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
556 break; \
557 case 10: \
558 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
559 ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
560 break; \
561 case 11: \
562 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
563 ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
564 break; \
565 case 12: \
566 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel1] = (pixel);)\
567 break; \
568 case 13: \
569 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
570 ((CARD16 *) (dst))[DoublePixel1] = (pixel);)\
571 break; \
572 case 14: \
573 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
574 ((CARD16 *) (dst))[DoublePixel1] = (pixel);)\
575 break; \
576 case 15: \
577 SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel);) \
578 break; \
579 } \
580 switch ((bits & 0xf0) >> 4) { \
581 case 0: \
582 break; \
583 case 1: \
584 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel);) \
585 break; \
586 case 2: \
587 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel);) \
588 break; \
589 case 3: \
590 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel2] = (pixel);)\
591 break; \
592 case 4: \
593 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
594 break; \
595 case 5: \
596 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel); \
597 ((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
598 break; \
599 case 6: \
600 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel); \
601 ((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
602 break; \
603 case 7: \
604 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel2] = (pixel); \
605 ((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
606 break; \
607 case 8: \
608 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
609 break; \
610 case 9: \
611 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel); \
612 ((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
613 break; \
614 case 10: \
615 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel); \
616 ((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
617 break; \
618 case 11: \
619 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel2] = (pixel); \
620 ((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
621 break; \
622 case 12: \
623 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel3] = (pixel);)\
624 break; \
625 case 13: \
626 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel); \
627 ((CARD16 *) (dst))[DoublePixel3] = (pixel);)\
628 break; \
629 case 14: \
630 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel); \
631 ((CARD16 *) (dst))[DoublePixel3] = (pixel);)\
632 break; \
633 case 15: \
634 SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel1] = (pixel);) \
635 break; \
636 } \
637 } \
638}
639#endif /* PGSZ == 64 */
640#endif /* PSZ == 8 */
641
642#if PSZ == 16
643
644#if PGSZ == 32
645#define WriteBitGroup(dst,pixel,bits) \
646 switch (bits) { \
647 case 0: \
648 break; \
649 case 1: \
650 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
651 break; \
652 case 2: \
653 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
654 break; \
655 case 3: \
656 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
657 break; \
658 case 4: \
659 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
660 break; \
661 case 5: \
662 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
663 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
664 break; \
665 case 6: \
666 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
667 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
668 break; \
669 case 7: \
670 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
671 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
672 break; \
673 case 8: \
674 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
675 break; \
676 case 9: \
677 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
678 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
679 break; \
680 case 10: \
681 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
682 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
683 break; \
684 case 11: \
685 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
686 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
687 break; \
688 case 12: \
689 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
690 break; \
691 case 13: \
692 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
693 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
694 break; \
695 case 14: \
696 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
697 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
698 break; \
699 case 15: \
700 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
701 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
702 break; \
703 }
704#else /* PGSZ == 64 */
705#define WriteBitGroup(dst,pixel,bits) \
706 if ( bits == 0xff ) { \
707 ((PixelGroup *) (dst))[QuadPixel0] = (pixel); \
708 ((PixelGroup *) (dst))[QuadPixel1] = (pixel); \
709 } \
710 else { \
711 switch (bits & 0x0f) { \
712 case 0: \
713 break; \
714 case 1: \
715 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
716 break; \
717 case 2: \
718 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
719 break; \
720 case 3: \
721 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
722 break; \
723 case 4: \
724 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
725 break; \
726 case 5: \
727 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
728 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
729 break; \
730 case 6: \
731 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
732 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
733 break; \
734 case 7: \
735 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
736 ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
737 break; \
738 case 8: \
739 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
740 break; \
741 case 9: \
742 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
743 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
744 break; \
745 case 10: \
746 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
747 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
748 break; \
749 case 11: \
750 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
751 ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
752 break; \
753 case 12: \
754 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
755 break; \
756 case 13: \
757 ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
758 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
759 break; \
760 case 14: \
761 ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
762 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
763 break; \
764 case 15: \
765 ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
766 ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
767 break; \
768 } \
769 switch ((bits & 0xf0) >> 4) { \
770 case 0: \
771 break; \
772 case 1: \
773 ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
774 break; \
775 case 2: \
776 ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
777 break; \
778 case 3: \
779 ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
780 break; \
781 case 4: \
782 ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
783 break; \
784 case 5: \
785 ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
786 ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
787 break; \
788 case 6: \
789 ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
790 ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
791 break; \
792 case 7: \
793 ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
794 ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
795 break; \
796 case 8: \
797 ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
798 break; \
799 case 9: \
800 ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
801 ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
802 break; \
803 case 10: \
804 ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
805 ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
806 break; \
807 case 11: \
808 ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
809 ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
810 break; \
811 case 12: \
812 ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
813 break; \
814 case 13: \
815 ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
816 ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
817 break; \
818 case 14: \
819 ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
820 ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
821 break; \
822 case 15: \
823 ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
824 ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
825 break; \
826 } \
827 }
828#endif /* PGSZ */
829
830#if PGSZ == 32
831#define SwitchBitGroup(dst,pixel,bits) { \
832 switch (bits) { \
833 case 0: \
834 break; \
835 case 1: \
836 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel);) \
837 break; \
838 case 2: \
839 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel);) \
840 break; \
841 case 3: \
842 SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel);) \
843 break; \
844 case 4: \
845 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
846 break; \
847 case 5: \
848 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
849 ((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
850 break; \
851 case 6: \
852 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel); \
853 ((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
854 break; \
855 case 7: \
856 SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel); \
857 ((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
858 break; \
859 case 8: \
860 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
861 break; \
862 case 9: \
863 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
864 ((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
865 break; \
866 case 10: \
867 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel); \
868 ((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
869 break; \
870 case 11: \
871 SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel); \
872 ((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
873 break; \
874 case 12: \
875 SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
876 break; \
877 case 13: \
878 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
879 ((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
880 break; \
881 case 14: \
882 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel); \
883 ((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
884 break; \
885 case 15: \
886 SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel); \
887 ((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
888 break; \
889 } \
890}
891#else /* PGSZ == 64 */
892#define SwitchBitGroup(dst,pixel,bits) { \
893 cfb cannot hack 64-bit SwitchBitGroup psz=PSZ
894#endif /* PGSZ */
895
896#endif /* PSZ == 16 */
897
898#if PSZ == 24
899/* 32 000011112222*/
900/* 24 000111222333*/
901/* 16 001122334455*/
902/* 8 0123456789AB*/
903#if PGSZ == 32
904#define WriteBitGroup(dst,pixel,bits) \
905 { \
906 register CARD32 reg_pixel = (pixel); \
907 switch (bits) { \
908 case 0: \
909 break; \
910 case 1: \
911 ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
912 ((CARD8 *) (dst))[SinglePixel2] = ((reg_pixel>>16)&0xFF); \
913 break; \
914 case 2: \
915 ((CARD8 *) (dst))[SinglePixel3] = reg_pixel&0xFF; \
916 ((CARD16 *) (dst))[DoublePixel2] = (reg_pixel>>8)&0xFFFF; \
917 break; \
918 case 3: \
919 ((CARD8 *) (dst))[SinglePixel3] = reg_pixel & 0xFF; \
920 ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
921 ((CARD16 *) (dst))[DoublePixel2] = (reg_pixel>>8)&0xFFFF; \
922 ((CARD8 *) (dst))[SinglePixel2] = (reg_pixel>>16&0xFF); \
923 break; \
924 case 4: \
925 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
926 ((CARD8 *) (dst))[SinglePixel8] = (reg_pixel>>16)&0xFF; \
927 break; \
928 case 5: \
929 ((CARD16 *) (dst))[DoublePixel0] = \
930 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
931 reg_pixel >>= 16; \
932 ((CARD8 *) (dst))[SinglePixel2] = \
933 ((CARD8 *) (dst))[SinglePixel8] = reg_pixel&0xFF; \
934 break; \
935 case 6: \
936 ((CARD8 *) (dst))[SinglePixel3] = reg_pixel; \
937 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
938 reg_pixel >>= 8; \
939 ((CARD16 *) (dst))[DoublePixel2] = reg_pixel; \
940 reg_pixel >>= 8; \
941 ((CARD8 *) (dst))[SinglePixel8] = reg_pixel&0xFF; \
942 break; \
943 case 7: \
944 ((CARD16 *) (dst))[DoublePixel0] = \
945 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
946 ((CARD8 *) (dst))[SinglePixel3] = reg_pixel&0xFF; \
947 reg_pixel >>= 8; \
948 ((CARD16 *) (dst))[DoublePixel2] = reg_pixel; \
949 reg_pixel >>= 8; \
950 ((CARD8 *) (dst))[SinglePixel2] = \
951 ((CARD8 *) (dst))[SinglePixel8] = reg_pixel&0xFF; \
952 break; \
953 case 8: \
954 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel&0xFF; \
955 ((CARD16 *) (dst))[DoublePixel5] = (reg_pixel>>8); \
956 break; \
957 case 9: \
958 ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
959 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel&0xFF; \
960 reg_pixel >>= 8; \
961 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
962 reg_pixel >>= 8; \
963 ((CARD8 *) (dst))[SinglePixel2] = reg_pixel&0xFF; \
964 break; \
965 case 10: \
966 ((CARD8 *) (dst))[SinglePixel3] = \
967 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel&0xFF; \
968 reg_pixel >>= 8; \
969 ((CARD16 *) (dst))[DoublePixel2] = \
970 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
971 break; \
972 case 11: \
973 ((CARD8 *) (dst))[SinglePixel3] = \
974 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
975 ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
976 reg_pixel >>= 8; \
977 ((CARD16 *) (dst))[DoublePixel2] = \
978 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
979 reg_pixel >>= 8; \
980 ((CARD8 *) (dst))[SinglePixel2] = reg_pixel; \
981 break; \
982 case 12: \
983 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
984 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
985 reg_pixel >>= 8; \
986 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
987 reg_pixel >>= 8; \
988 ((CARD8 *) (dst))[SinglePixel8] = reg_pixel; \
989 break; \
990 case 13: \
991 ((CARD16 *) (dst))[DoublePixel0] = \
992 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
993 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
994 reg_pixel >>= 8; \
995 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
996 reg_pixel >>= 8; \
997 ((CARD8 *) (dst))[SinglePixel2] = \
998 ((CARD8 *) (dst))[SinglePixel8] = reg_pixel; \
999 break; \
1000 case 14: \
1001 ((CARD8 *) (dst))[SinglePixel3] = \
1002 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
1003 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
1004 reg_pixel >>= 8; \
1005 ((CARD16 *) (dst))[DoublePixel2] = \
1006 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
1007 reg_pixel >>= 8; \
1008 ((CARD8 *) (dst))[SinglePixel8] = reg_pixel; \
1009 break; \
1010 case 15: \
1011 ((CARD16 *) (dst))[DoublePixel0] = \
1012 ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
1013 ((CARD8 *) (dst))[SinglePixel3] = \
1014 ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
1015 reg_pixel >>= 8; \
1016 ((CARD16 *) (dst))[DoublePixel2] = \
1017 ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
1018 reg_pixel >>= 8; \
1019 ((CARD8 *) (dst))[SinglePixel8] = \
1020 ((CARD8 *) (dst))[SinglePixel2] = reg_pixel; \
1021 break; \
1022 } \
1023 }
1024#else /* PGSZ == 64 */
1025#define WriteBitGroup(dst,pixel,bits) \
1026 if ( bits == 0xff ) { \
1027 ((PixelGroup *) (dst))[DoublePixel0] = (pixel); \
1028 ((PixelGroup *) (dst))[DoublePixel1] = (pixel); \
1029 ((PixelGroup *) (dst))[DoublePixel2] = (pixel); \
1030 ((PixelGroup *) (dst))[DoublePixel3] = (pixel); \
1031 } \
1032 else { \
1033 switch (bits & 0x0f) { \
1034 case 0: \
1035 break; \
1036 case 1: \
1037 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1038 break; \
1039 case 2: \
1040 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1041 break; \
1042 case 3: \
1043 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1044 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1045 break; \
1046 case 4: \
1047 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1048 break; \
1049 case 5: \
1050 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1051 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1052 break; \
1053 case 6: \
1054 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1055 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1056 break; \
1057 case 7: \
1058 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1059 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1060 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1061 break; \
1062 case 8: \
1063 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1064 break; \
1065 case 9: \
1066 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1067 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1068 break; \
1069 case 10: \
1070 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1071 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1072 break; \
1073 case 11: \
1074 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1075 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1076 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1077 break; \
1078 case 12: \
1079 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1080 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1081 break; \
1082 case 13: \
1083 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1084 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1085 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1086 break; \
1087 case 14: \
1088 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1089 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1090 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1091 break; \
1092 case 15: \
1093 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1094 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1095 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1096 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1097 break; \
1098 } \
1099 switch ((bits & 0xf0) >> 4) { \
1100 case 0: \
1101 break; \
1102 case 1: \
1103 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1104 break; \
1105 case 2: \
1106 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1107 break; \
1108 case 3: \
1109 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1110 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1111 break; \
1112 case 4: \
1113 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1114 break; \
1115 case 5: \
1116 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1117 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1118 break; \
1119 case 6: \
1120 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1121 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1122 break; \
1123 case 7: \
1124 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1125 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1126 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1127 break; \
1128 case 8: \
1129 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1130 break; \
1131 case 9: \
1132 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1133 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1134 break; \
1135 case 10: \
1136 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1137 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1138 break; \
1139 case 11: \
1140 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1141 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1142 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1143 break; \
1144 case 12: \
1145 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1146 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1147 break; \
1148 case 13: \
1149 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1150 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1151 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1152 break; \
1153 case 14: \
1154 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1155 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1156 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1157 break; \
1158 case 15: \
1159 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1160 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1161 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1162 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1163 break; \
1164 } \
1165 }
1166#endif /* PGSZ */
1167
1168#if PGSZ == 32
1169#define SwitchBitGroup(dst,pixel,bits) { \
1170 switch (bits) { \
1171 case 0: \
1172 break; \
1173 case 1: \
1174 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
1175 ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
1176 break; \
1177 case 2: \
1178 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
1179 ((CARD16 *) (dst))[DoublePixel2] = (pixel);) \
1180 break; \
1181 case 3: \
1182 SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
1183 ((CARD16 *) (dst))[DoublePixel2] = (pixel);) \
1184 break; \
1185 case 4: \
1186 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel3] = (pixel); \
1187 ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
1188 break; \
1189 case 5: \
1190 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
1191 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
1192 ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
1193 ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
1194 break; \
1195 case 6: \
1196 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
1197 ((CARD32 *) (dst))[QuadPixel2] = (pixel); \
1198 ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
1199 break; \
1200 case 7: \
1201 SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
1202 ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
1203 ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
1204 break; \
1205 case 8: \
1206 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel9] = (pixel); \
1207 ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
1208 break; \
1209 case 9: \
1210 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
1211 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
1212 ((CARD8 *) (dst))[SinglePixel9] = (pixel); \
1213 ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
1214 break; \
1215 case 10: \
1216 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
1217 ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
1218 ((CARD8 *) (dst))[SinglePixel9] = (pixel); \
1219 ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
1220 break; \
1221 case 11: \
1222 SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
1223 ((CARD16 *) (dst))[DoublePixel3] = (pixel);) \
1224 ((CARD8 *) (dst))[SinglePixel9] = (pixel); \
1225 ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
1226 break; \
1227 case 12: \
1228 SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel3] = (pixel); \
1229 ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
1230 break; \
1231 case 13: \
1232 SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
1233 ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
1234 ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
1235 ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
1236 break; \
1237 case 14: \
1238 SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
1239 ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
1240 ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
1241 break; \
1242 case 15: \
1243 SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
1244 ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
1245 ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
1246 break; \
1247 } \
1248}
1249#else /* PGSZ == 64 */
1250#define SwitchBitGroup(dst,pixel,bits) { \
1251 cfb cannot hack 64-bit SwitchBitGroup psz=PSZ
1252#endif /* PGSZ */
1253
1254#endif /* PSZ == 24 */
1255
1256#if PSZ == 32
1257
1258#if PGSZ == 32
1259#define WriteBitGroup(dst,pixel,bits) \
1260 switch (bits) { \
1261 case 0: \
1262 break; \
1263 case 1: \
1264 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1265 break; \
1266 case 2: \
1267 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1268 break; \
1269 case 3: \
1270 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1271 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1272 break; \
1273 case 4: \
1274 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1275 break; \
1276 case 5: \
1277 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1278 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1279 break; \
1280 case 6: \
1281 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1282 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1283 break; \
1284 case 7: \
1285 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1286 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1287 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1288 break; \
1289 case 8: \
1290 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1291 break; \
1292 case 9: \
1293 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1294 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1295 break; \
1296 case 10: \
1297 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1298 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1299 break; \
1300 case 11: \
1301 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1302 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1303 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1304 break; \
1305 case 12: \
1306 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1307 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1308 break; \
1309 case 13: \
1310 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1311 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1312 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1313 break; \
1314 case 14: \
1315 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1316 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1317 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1318 break; \
1319 case 15: \
1320 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1321 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1322 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1323 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1324 break; \
1325 }
1326#else /* PGSZ == 64 */
1327#define WriteBitGroup(dst,pixel,bits) \
1328 if ( bits == 0xff ) { \
1329 ((PixelGroup *) (dst))[DoublePixel0] = (pixel); \
1330 ((PixelGroup *) (dst))[DoublePixel1] = (pixel); \
1331 ((PixelGroup *) (dst))[DoublePixel2] = (pixel); \
1332 ((PixelGroup *) (dst))[DoublePixel3] = (pixel); \
1333 } \
1334 else { \
1335 switch (bits & 0x0f) { \
1336 case 0: \
1337 break; \
1338 case 1: \
1339 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1340 break; \
1341 case 2: \
1342 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1343 break; \
1344 case 3: \
1345 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1346 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1347 break; \
1348 case 4: \
1349 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1350 break; \
1351 case 5: \
1352 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1353 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1354 break; \
1355 case 6: \
1356 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1357 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1358 break; \
1359 case 7: \
1360 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1361 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1362 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1363 break; \
1364 case 8: \
1365 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1366 break; \
1367 case 9: \
1368 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1369 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1370 break; \
1371 case 10: \
1372 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1373 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1374 break; \
1375 case 11: \
1376 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1377 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1378 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1379 break; \
1380 case 12: \
1381 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1382 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1383 break; \
1384 case 13: \
1385 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1386 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1387 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1388 break; \
1389 case 14: \
1390 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1391 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1392 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1393 break; \
1394 case 15: \
1395 ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1396 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1397 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1398 ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
1399 break; \
1400 } \
1401 switch ((bits & 0xf0) >> 4) { \
1402 case 0: \
1403 break; \
1404 case 1: \
1405 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1406 break; \
1407 case 2: \
1408 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1409 break; \
1410 case 3: \
1411 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1412 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1413 break; \
1414 case 4: \
1415 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1416 break; \
1417 case 5: \
1418 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1419 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1420 break; \
1421 case 6: \
1422 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1423 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1424 break; \
1425 case 7: \
1426 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1427 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1428 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1429 break; \
1430 case 8: \
1431 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1432 break; \
1433 case 9: \
1434 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1435 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1436 break; \
1437 case 10: \
1438 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1439 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1440 break; \
1441 case 11: \
1442 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1443 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1444 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1445 break; \
1446 case 12: \
1447 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1448 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1449 break; \
1450 case 13: \
1451 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1452 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1453 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1454 break; \
1455 case 14: \
1456 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1457 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1458 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1459 break; \
1460 case 15: \
1461 ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
1462 ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
1463 ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
1464 ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
1465 break; \
1466 } \
1467 }
1468#endif /* PGSZ */
1469
1470#if PGSZ == 32
1471#define SwitchBitGroup(dst,pixel,bits) { \
1472 switch (bits) { \
1473 case 0: \
1474 break; \
1475 case 1: \
1476 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel);) \
1477 break; \
1478 case 2: \
1479 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel);) \
1480 break; \
1481 case 3: \
1482 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1483 ((CARD32 *) (dst))[SinglePixel1] = (pixel);) \
1484 break; \
1485 case 4: \
1486 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
1487 break; \
1488 case 5: \
1489 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1490 ((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
1491 break; \
1492 case 6: \
1493 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1494 ((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
1495 break; \
1496 case 7: \
1497 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1498 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1499 ((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
1500 break; \
1501 case 8: \
1502 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1503 break; \
1504 case 9: \
1505 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1506 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1507 break; \
1508 case 10: \
1509 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1510 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1511 break; \
1512 case 11: \
1513 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1514 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1515 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1516 break; \
1517 case 12: \
1518 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1519 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1520 break; \
1521 case 13: \
1522 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1523 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1524 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1525 break; \
1526 case 14: \
1527 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1528 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1529 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1530 break; \
1531 case 15: \
1532 SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
1533 ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
1534 ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
1535 ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
1536 break; \
1537 } \
1538}
1539#else /* PGSZ == 64 */
1540#define SwitchBitGroup(dst,pixel,bits) { \
1541 cfb cannot hack 64-bit SwitchBitGroup psz=PSZ
1542#endif /* PGSZ */
1543
1544#endif /* PSZ == 32 */
1545#endif /* AVOID_MEMORY_READ */
1546
1547extern PixelGroup cfb8BitLenMasks[PGSZ];
1548
1549extern int cfb8SetStipple (
1550 int /*alu*/,
1551 CfbBits /*fg*/,
1552 CfbBits /*planemask*/
1553);
1554
1555extern int cfb8SetOpaqueStipple (
1556 int /*alu*/,
1557 CfbBits /*fg*/,
1558 CfbBits /*bg*/,
1559 CfbBits /*planemask*/
1560);
1561
1562extern int cfb8ComputeClipMasks32 (
1563 BoxPtr /*pBox*/,
1564 int /*numRects*/,
1565 int /*x*/,
1566 int /*y*/,
1567 int /*w*/,
1568 int /*h*/,
1569 CARD32 * /*clips*/
1570);
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette