rasops24.c revision 1.4 1 /* $NetBSD: rasops24.c,v 1.4 1999/04/26 04:27:47 ad Exp $ */
2
3 /*
4 * Copyright (c) 1999 Andy Doran <ad (at) NetBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29
30 #include "opt_rasops.h"
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.4 1999/04/26 04:27:47 ad Exp $");
33
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/time.h>
38
39 #include <machine/endian.h>
40 #include <machine/bswap.h>
41
42 #include <dev/wscons/wsdisplayvar.h>
43 #include <dev/wscons/wsconsio.h>
44 #include <dev/rasops/rasops.h>
45
46 static void rasops24_putchar __P((void *, int, int, u_int, long attr));
47 static void rasops24_putchar8 __P((void *, int, int, u_int, long attr));
48 static void rasops24_putchar12 __P((void *, int, int, u_int, long attr));
49 static void rasops24_putchar16 __P((void *, int, int, u_int, long attr));
50 static void rasops24_erasecols __P((void *, int, int, int, long));
51 static void rasops24_eraserows __P((void *, int, int, long));
52 static void rasops24_makestamp __P((struct rasops_info *, long));
53
54 void rasops24_init __P((struct rasops_info *ri));
55
56 /*
57 * 4x1 stamp for optimized character blitting
58 */
59 static int32_t stamp[64];
60 static long stamp_attr;
61 static int stamp_mutex; /* XXX see note in readme */
62
63 /*
64 * XXX this confuses the hell out of gcc2 (not egcs) which always insists
65 * that the shift count is negative.
66 *
67 * offset = STAMP_SHIFT(fontbits, nibble #) & STAMP_MASK
68 * destination int32_t[0] = STAMP_READ(offset)
69 * destination int32_t[1] = STAMP_READ(offset + 4)
70 * destination int32_t[2] = STAMP_READ(offset + 8)
71 */
72 #define STAMP_SHIFT(fb,n) ((n*4-4) >= 0 ? (fb)>>(n*4-4):(fb)<<-(n*4-4))
73 #define STAMP_MASK (15 << 4)
74 #define STAMP_READ(o) (*(int32_t *)((caddr_t)stamp + (o)))
75
76
77 /*
78 * Initalize rasops_info struct for this colordepth.
79 */
80 void
81 rasops24_init(ri)
82 struct rasops_info *ri;
83 {
84
85 switch (ri->ri_font->fontwidth) {
86 case 8:
87 ri->ri_ops.putchar = rasops24_putchar8;
88 break;
89
90 case 12:
91 ri->ri_ops.putchar = rasops24_putchar12;
92 break;
93
94 case 16:
95 ri->ri_ops.putchar = rasops24_putchar16;
96 break;
97
98 default:
99 ri->ri_ops.putchar = rasops24_putchar;
100 break;
101 }
102
103 if (ri->ri_rnum == 0) {
104 ri->ri_rnum = 8;
105 ri->ri_rpos = 0;
106 ri->ri_gnum = 8;
107 ri->ri_gpos = 8;
108 ri->ri_bnum = 8;
109 ri->ri_bpos = 16;
110 }
111
112 ri->ri_ops.erasecols = rasops24_erasecols;
113 ri->ri_ops.eraserows = rasops24_eraserows;
114 }
115
116
117 /*
118 * Recompute the blitting stamp.
119 */
120 static void
121 rasops24_makestamp(ri, attr)
122 struct rasops_info *ri;
123 long attr;
124 {
125 u_int32_t fg, bg, c1, c2, c3, c4;
126 int i;
127
128 fg = ri->ri_devcmap[((u_int)attr >> 24) & 15] & 0xffffff;
129 bg = ri->ri_devcmap[((u_int)attr >> 16) & 15] & 0xffffff;
130 stamp_attr = attr;
131
132 for (i = 0; i < 64; i += 4) {
133 #if BYTE_ORDER == LITTLE_ENDIAN
134 c1 = (i & 32 ? fg : bg);
135 c2 = (i & 16 ? fg : bg);
136 c3 = (i & 8 ? fg : bg);
137 c4 = (i & 4 ? fg : bg);
138 #else
139 c1 = (i & 8 ? fg : bg);
140 c2 = (i & 4 ? fg : bg);
141 c3 = (i & 16 ? fg : bg);
142 c4 = (i & 32 ? fg : bg);
143 #endif
144 stamp[i+0] = (c1 << 8) | (c2 >> 16);
145 stamp[i+1] = (c2 << 16) | (c3 >> 8);
146 stamp[i+2] = (c3 << 24) | c4;
147
148 #if BYTE_ORDER == LITTLE_ENDIAN
149 if (!ri->ri_swab) {
150 #else
151 if (ri->ri_swab) {
152 #endif
153 stamp[i+0] = bswap32(stamp[i+0]);
154 stamp[i+1] = bswap32(stamp[i+1]);
155 stamp[i+2] = bswap32(stamp[i+2]);
156 }
157 }
158 }
159
160
161 /*
162 * Put a single character. This is the generic version.
163 * XXX this bites - we should use masks.
164 */
165 static void
166 rasops24_putchar(cookie, row, col, uc, attr)
167 void *cookie;
168 int row, col;
169 u_int uc;
170 long attr;
171 {
172 struct rasops_info *ri;
173 int fb, width, height, cnt, clr[2];
174 u_char *dp, *rp, *fr;
175
176 ri = (struct rasops_info *)cookie;
177
178 #ifdef RASOPS_CLIPPING
179 /* Catches 'row < 0' case too */
180 if ((unsigned)row >= (unsigned)ri->ri_rows)
181 return;
182
183 if ((unsigned)col >= (unsigned)ri->ri_cols)
184 return;
185 #endif
186
187 rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
188 height = ri->ri_font->fontheight;
189 width = ri->ri_font->fontwidth;
190
191 clr[1] = ri->ri_devcmap[((u_int)attr >> 24) & 15];
192 clr[0] = ri->ri_devcmap[((u_int)attr >> 16) & 15];
193
194 if (uc == ' ') {
195 while (height--) {
196 dp = rp;
197 rp += ri->ri_stride;
198
199 for (cnt = width; cnt; cnt--) {
200 *dp++ = clr[0] >> 16;
201 *dp++ = clr[0] >> 8;
202 *dp++ = clr[0];
203 }
204 }
205 } else {
206 uc -= ri->ri_font->firstchar;
207 fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
208
209 while (height--) {
210 dp = rp;
211 fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) | (fr[0] << 24);
212 fr += ri->ri_font->stride;
213 rp += ri->ri_stride;
214
215 for (cnt = width; cnt; cnt--, fb <<= 1) {
216 if ((fb >> 31) & 1) {
217 *dp++ = clr[1] >> 16;
218 *dp++ = clr[1] >> 8;
219 *dp++ = clr[1];
220 } else {
221 *dp++ = clr[0] >> 16;
222 *dp++ = clr[0] >> 8;
223 *dp++ = clr[0];
224 }
225 }
226 }
227 }
228
229 /* Do underline */
230 if (attr & 1) {
231 rp -= ri->ri_stride << 1;
232
233 while (width--) {
234 *rp++ = clr[1] >> 16;
235 *rp++ = clr[1] >> 8;
236 *rp++ = clr[1];
237 }
238 }
239 }
240
241
242 /*
243 * Put a single character. This is for 8-pixel wide fonts.
244 */
245 static void
246 rasops24_putchar8(cookie, row, col, uc, attr)
247 void *cookie;
248 int row, col;
249 u_int uc;
250 long attr;
251 {
252 struct rasops_info *ri;
253 int height, so, fs;
254 int32_t *rp;
255 u_char *fr;
256
257 /* Can't risk remaking the stamp if it's already in use */
258 if (stamp_mutex++) {
259 stamp_mutex--;
260 rasops24_putchar(cookie, row, col, uc, attr);
261 return;
262 }
263
264 ri = (struct rasops_info *)cookie;
265
266 #ifdef RASOPS_CLIPPING
267 if ((unsigned)row >= (unsigned)ri->ri_rows) {
268 stamp_mutex--;
269 return;
270 }
271
272 if ((unsigned)col >= (unsigned)ri->ri_cols) {
273 stamp_mutex--;
274 return;
275 }
276 #endif
277
278 /* Recompute stamp? */
279 if (attr != stamp_attr)
280 rasops24_makestamp(ri, attr);
281
282 rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
283 height = ri->ri_font->fontheight;
284
285 if (uc == (u_int)-1) {
286 while (height--) {
287 rp[0] = stamp[0];
288 rp[1] = stamp[0];
289 rp[2] = stamp[0];
290 rp[3] = stamp[0];
291 rp[4] = stamp[0];
292 rp[5] = stamp[0];
293 DELTA(rp, ri->ri_stride, int32_t *);
294 }
295 } else {
296 uc -= ri->ri_font->firstchar;
297 fr = (u_char *)ri->ri_font->data + uc*ri->ri_fontscale;
298 fs = ri->ri_font->stride;
299
300 while (height--) {
301 so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
302 rp[0] = STAMP_READ(so);
303 rp[1] = STAMP_READ(so + 4);
304 rp[2] = STAMP_READ(so + 8);
305
306 so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
307 rp[3] = STAMP_READ(so);
308 rp[4] = STAMP_READ(so + 4);
309 rp[5] = STAMP_READ(so + 8);
310
311 fr += fs;
312 DELTA(rp, ri->ri_stride, int32_t *);
313 }
314 }
315
316 /* Do underline */
317 if (attr & 1) {
318 DELTA(rp, -(ri->ri_stride << 1), int32_t *);
319 rp[0] = STAMP_READ(30);
320 rp[1] = STAMP_READ(30);
321 rp[2] = STAMP_READ(30);
322 rp[3] = STAMP_READ(30);
323 rp[4] = STAMP_READ(30);
324 rp[5] = STAMP_READ(30);
325 }
326
327 stamp_mutex--;
328 }
329
330
331 /*
332 * Put a single character. This is for 12-pixel wide fonts.
333 */
334 static void
335 rasops24_putchar12(cookie, row, col, uc, attr)
336 void *cookie;
337 int row, col;
338 u_int uc;
339 long attr;
340 {
341 struct rasops_info *ri;
342 int height, so, fs;
343 int32_t *rp;
344 u_char *fr;
345
346 /* Can't risk remaking the stamp if it's already in use */
347 if (stamp_mutex++) {
348 stamp_mutex--;
349 rasops24_putchar(cookie, row, col, uc, attr);
350 return;
351 }
352
353 ri = (struct rasops_info *)cookie;
354
355 #ifdef RASOPS_CLIPPING
356 if ((unsigned)row >= (unsigned)ri->ri_rows) {
357 stamp_mutex--;
358 return;
359 }
360
361 if ((unsigned)col >= (unsigned)ri->ri_cols) {
362 stamp_mutex--;
363 return;
364 }
365 #endif
366
367 /* Recompute stamp? */
368 if (attr != stamp_attr)
369 rasops24_makestamp(ri, attr);
370
371 rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
372 height = ri->ri_font->fontheight;
373
374 if (uc == (u_int)-1) {
375 while (height--) {
376 rp[0] = stamp[0];
377 rp[1] = stamp[0];
378 rp[2] = stamp[0];
379 rp[3] = stamp[0];
380 rp[4] = stamp[0];
381 rp[5] = stamp[0];
382 rp[6] = stamp[0];
383 rp[7] = stamp[0];
384 rp[8] = stamp[0];
385 DELTA(rp, ri->ri_stride, int32_t *);
386 }
387 } else {
388 uc -= ri->ri_font->firstchar;
389 fr = (u_char *)ri->ri_font->data + uc*ri->ri_fontscale;
390 fs = ri->ri_font->stride;
391
392 while (height--) {
393 so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
394 rp[0] = STAMP_READ(so);
395 rp[1] = STAMP_READ(so + 4);
396 rp[2] = STAMP_READ(so + 8);
397
398 so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
399 rp[3] = STAMP_READ(so);
400 rp[4] = STAMP_READ(so + 4);
401 rp[5] = STAMP_READ(so + 8);
402
403 so = STAMP_SHIFT(fr[1], 1) & STAMP_MASK;
404 rp[6] = STAMP_READ(so);
405 rp[7] = STAMP_READ(so + 4);
406 rp[8] = STAMP_READ(so + 8);
407
408 fr += fs;
409 DELTA(rp, ri->ri_stride, int32_t *);
410 }
411 }
412
413 /* Do underline */
414 if (attr & 1) {
415 DELTA(rp, -(ri->ri_stride << 1), int32_t *);
416 rp[0] = STAMP_READ(30);
417 rp[1] = STAMP_READ(30);
418 rp[2] = STAMP_READ(30);
419 rp[3] = STAMP_READ(30);
420 rp[4] = STAMP_READ(30);
421 rp[5] = STAMP_READ(30);
422 rp[6] = STAMP_READ(30);
423 rp[7] = STAMP_READ(30);
424 rp[8] = STAMP_READ(30);
425 }
426
427 stamp_mutex--;
428 }
429
430
431 /*
432 * Put a single character. This is for 16-pixel wide fonts.
433 */
434 static void
435 rasops24_putchar16(cookie, row, col, uc, attr)
436 void *cookie;
437 int row, col;
438 u_int uc;
439 long attr;
440 {
441 struct rasops_info *ri;
442 int height, so, fs;
443 int32_t *rp;
444 u_char *fr;
445
446 /* Can't risk remaking the stamp if it's already in use */
447 if (stamp_mutex++) {
448 stamp_mutex--;
449 rasops24_putchar(cookie, row, col, uc, attr);
450 return;
451 }
452
453 ri = (struct rasops_info *)cookie;
454
455 #ifdef RASOPS_CLIPPING
456 if ((unsigned)row >= (unsigned)ri->ri_rows) {
457 stamp_mutex--;
458 return;
459 }
460
461 if ((unsigned)col >= (unsigned)ri->ri_cols) {
462 stamp_mutex--;
463 return;
464 }
465 #endif
466
467 /* Recompute stamp? */
468 if (attr != stamp_attr) {
469 puts("putchar16 rms");
470 rasops24_makestamp(ri, attr);
471 }
472 rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
473 height = ri->ri_font->fontheight;
474
475 if (uc == (u_int)-1) {
476 while (height--) {
477 rp[0] = stamp[0];
478 rp[1] = stamp[0];
479 rp[2] = stamp[0];
480 rp[3] = stamp[0];
481 rp[4] = stamp[0];
482 rp[5] = stamp[0];
483 rp[6] = stamp[0];
484 rp[7] = stamp[0];
485 rp[8] = stamp[0];
486 rp[9] = stamp[0];
487 rp[10] = stamp[0];
488 rp[11] = stamp[0];
489 DELTA(rp, ri->ri_stride, int32_t *);
490 }
491 } else {
492 uc -= ri->ri_font->firstchar;
493 fr = (u_char *)ri->ri_font->data + uc*ri->ri_fontscale;
494 fs = ri->ri_font->stride;
495
496 while (height--) {
497 so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
498 rp[0] = STAMP_READ(so);
499 rp[1] = STAMP_READ(so + 4);
500 rp[2] = STAMP_READ(so + 8);
501
502 so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
503 rp[3] = STAMP_READ(so);
504 rp[4] = STAMP_READ(so + 4);
505 rp[5] = STAMP_READ(so + 8);
506
507 so = STAMP_SHIFT(fr[1], 1) & STAMP_MASK;
508 rp[6] = STAMP_READ(so);
509 rp[7] = STAMP_READ(so + 4);
510 rp[8] = STAMP_READ(so + 8);
511
512 so = STAMP_SHIFT(fr[1], 0) & STAMP_MASK;
513 rp[9] = STAMP_READ(so);
514 rp[10] = STAMP_READ(so + 4);
515 rp[11] = STAMP_READ(so + 8);
516
517 DELTA(rp, ri->ri_stride, int32_t *);
518 fr += fs;
519 }
520 }
521
522 /* Do underline */
523 if (attr & 1) {
524 DELTA(rp, -(ri->ri_stride << 1), int32_t *);
525 rp[0] = STAMP_READ(30);
526 rp[1] = STAMP_READ(30);
527 rp[2] = STAMP_READ(30);
528 rp[3] = STAMP_READ(30);
529 rp[4] = STAMP_READ(30);
530 rp[5] = STAMP_READ(30);
531 rp[6] = STAMP_READ(30);
532 rp[7] = STAMP_READ(30);
533 rp[8] = STAMP_READ(30);
534 rp[9] = STAMP_READ(30);
535 rp[10] = STAMP_READ(30);
536 rp[11] = STAMP_READ(30);
537 }
538
539 stamp_mutex--;
540 }
541
542
543 /*
544 * Erase rows. This is nice and easy due to alignment.
545 */
546 static void
547 rasops24_eraserows(cookie, row, num, attr)
548 void *cookie;
549 int row, num;
550 long attr;
551 {
552 struct rasops_info *ri;
553 u_int32_t *dp, clr, stamp[3];
554 int n9, n3, n1, cnt;
555
556 /*
557 * If the color is gray, we can cheat and use the generic routines
558 * (which are faster, hopefully) since the r,g,b values are the same.
559 */
560 if (attr & 4) {
561 rasops_eraserows(cookie, row, num, attr);
562 return;
563 }
564
565 ri = (struct rasops_info *)cookie;
566
567 #ifdef RASOPS_CLIPPING
568 if (row < 0) {
569 num += row;
570 row = 0;
571 }
572
573 if ((row + num) > ri->ri_rows)
574 num = ri->ri_rows - row;
575
576 if (num <= 0)
577 return;
578 #endif
579
580 clr = ri->ri_devcmap[(attr >> 16) & 15] & 0xffffff;
581 stamp[0] = (clr << 8) | (clr >> 16);
582 stamp[1] = (clr << 16) | (clr >> 8);
583 stamp[2] = (clr << 24) | clr;
584
585 #if BYTE_ORDER == LITTLE_ENDIAN
586 if (!ri->ri_swab) {
587 #else
588 if (ri->ri_swab) {
589 #endif
590 stamp[0] = bswap32(stamp[0]);
591 stamp[1] = bswap32(stamp[1]);
592 stamp[2] = bswap32(stamp[2]);
593 }
594
595 num *= ri->ri_font->fontheight;
596 dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
597
598 n9 = ri->ri_emustride / 36;
599 cnt = (n9 << 5) + (n9 << 2); /* (32*n9) + (4*n9) */
600 n3 = (ri->ri_emustride - cnt) / 12;
601 cnt += (n3 << 3) + (n3 << 2); /* (8*n3) + (4*n3) */
602 n1 = (ri->ri_emustride - cnt) >> 2;
603
604 while (num--) {
605 for (cnt = n9; cnt; cnt--) {
606 dp[0] = stamp[0];
607 dp[1] = stamp[1];
608 dp[2] = stamp[2];
609 dp[3] = stamp[0];
610 dp[4] = stamp[1];
611 dp[5] = stamp[2];
612 dp[6] = stamp[0];
613 dp[7] = stamp[1];
614 dp[8] = stamp[2];
615 dp += 9;
616 }
617
618 for (cnt = n3; cnt; cnt--) {
619 dp[0] = stamp[0];
620 dp[1] = stamp[1];
621 dp[2] = stamp[2];
622 dp += 3;
623 }
624
625 for (cnt = 0; cnt < n1; cnt++)
626 *dp++ = stamp[cnt];
627
628 DELTA(dp, ri->ri_delta, int32_t *);
629 }
630 }
631
632
633 /*
634 * Erase columns.
635 */
636 static void
637 rasops24_erasecols(cookie, row, col, num, attr)
638 void *cookie;
639 int row, col, num;
640 long attr;
641 {
642 int n12, n4, height, cnt, slop, clr, stamp[3];
643 struct rasops_info *ri;
644 int32_t *dp, *rp;
645 u_char *dbp;
646
647 /*
648 * If the color is gray, we can cheat and use the generic routines
649 * (which are faster, hopefully) since the r,g,b values are the same.
650 */
651 if (attr & 4) {
652 rasops_erasecols(cookie, row, col, num, attr);
653 return;
654 }
655
656 ri = (struct rasops_info *)cookie;
657
658 #ifdef RASOPS_CLIPPING
659 /* Catches 'row < 0' case too */
660 if ((unsigned)row >= (unsigned)ri->ri_rows)
661 return;
662
663 if (col < 0) {
664 num += col;
665 col = 0;
666 }
667
668 if ((col + num) > ri->ri_cols)
669 num = ri->ri_cols - col;
670
671 if (num <= 0)
672 return;
673 #endif
674
675 rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
676 num *= ri->ri_font->fontwidth;
677 height = ri->ri_font->fontheight;
678
679 clr = ri->ri_devcmap[(attr >> 16) & 15] & 0xffffff;
680 stamp[0] = (clr << 8) | (clr >> 16);
681 stamp[1] = (clr << 16) | (clr >> 8);
682 stamp[2] = (clr << 24) | clr;
683
684 #if BYTE_ORDER == LITTLE_ENDIAN
685 if (!ri->ri_swab) {
686 #else
687 if (ri->ri_swab) {
688 #endif
689 stamp[0] = bswap32(stamp[0]);
690 stamp[1] = bswap32(stamp[1]);
691 stamp[2] = bswap32(stamp[2]);
692 }
693
694 /*
695 * The current byte offset mod 4 tells us the number of 24-bit pels
696 * we need to write for alignment to 32-bits. Once we're aligned on
697 * a 32-bit boundary, we're also aligned on a 4 pixel boundary, so
698 * the stamp does not need to be rotated. The following shows the
699 * layout of 4 pels (a, b, and c) in a 3 word region and illustrates
700 * this:
701 *
702 * aaab bbcc cddd
703 */
704 slop = (int)rp & 3; num -= slop;
705 n12 = num / 12; num -= (n12 << 3) + (n12 << 2);
706 n4 = num >> 2; num &= 3;
707
708 while (height--) {
709 dbp = (u_char *)rp;
710 DELTA(rp, ri->ri_stride, int32_t *);
711
712 /* Align to 4 bytes */
713 /* XXX handle with masks, bring under control of ri_swab */
714 for (cnt = slop; cnt; cnt--) {
715 *dbp++ = (clr >> 16);
716 *dbp++ = (clr >> 8);
717 *dbp++ = clr;
718 }
719
720 dp = (int32_t *)dbp;
721
722 /* 12 pels per loop */
723 for (cnt = n12; cnt; cnt--) {
724 dp[0] = stamp[0];
725 dp[1] = stamp[1];
726 dp[2] = stamp[2];
727 dp[3] = stamp[0];
728 dp[4] = stamp[1];
729 dp[5] = stamp[2];
730 dp[6] = stamp[0];
731 dp[7] = stamp[1];
732 dp[8] = stamp[2];
733 dp += 9;
734 }
735
736 /* 4 pels per loop */
737 for (cnt = n4; cnt; cnt--) {
738 dp[0] = stamp[0];
739 dp[1] = stamp[1];
740 dp[2] = stamp[2];
741 dp += 3;
742 }
743
744 /* Trailing slop */
745 /* XXX handle with masks, bring under control of ri_swab */
746 dbp = (u_char *)dp;
747 for (cnt = num; cnt; cnt--) {
748 *dbp++ = (clr >> 16);
749 *dbp++ = (clr >> 8);
750 *dbp++ = clr;
751 }
752 }
753 }
754