Home | History | Annotate | Line # | Download | only in rasops
rasops15.c revision 1.27
      1 /* 	$NetBSD: rasops15.c,v 1.27 2019/07/25 03:02:44 rin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Andrew Doran.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include <sys/cdefs.h>
     33 __KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.27 2019/07/25 03:02:44 rin Exp $");
     34 
     35 #include "opt_rasops.h"
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/time.h>
     40 
     41 #include <dev/wscons/wsdisplayvar.h>
     42 #include <dev/wscons/wsconsio.h>
     43 #include <dev/rasops/rasops.h>
     44 
     45 static void 	rasops15_putchar(void *, int, int, u_int, long attr);
     46 static void 	rasops15_putchar_aa(void *, int, int, u_int, long attr);
     47 #ifndef RASOPS_SMALL
     48 static void 	rasops15_putchar8(void *, int, int, u_int, long attr);
     49 static void 	rasops15_putchar12(void *, int, int, u_int, long attr);
     50 static void 	rasops15_putchar16(void *, int, int, u_int, long attr);
     51 static void	rasops15_makestamp(struct rasops_info *, long);
     52 #endif
     53 
     54 #ifndef RASOPS_SMALL
     55 /*
     56  * (2x2)x1 stamp for optimized character blitting
     57  */
     58 static uint32_t	stamp[32];
     59 static long	stamp_attr;
     60 static int	stamp_mutex;	/* XXX see note in readme */
     61 
     62 /*
     63  * XXX this confuses the hell out of gcc2 (not egcs) which always insists
     64  * that the shift count is negative.
     65  *
     66  * offset = STAMP_SHIFT(fontbits, nibble #) & STAMP_MASK
     67  * destination uint32_t[0] = STAMP_READ(offset)
     68  * destination uint32_t[1] = STAMP_READ(offset + 4)
     69  */
     70 #define STAMP_SHIFT(fb,n)	((n*4-3) >= 0 ? (fb)>>(n*4-3):(fb)<<-(n*4-3))
     71 #define STAMP_MASK		(15 << 3)
     72 #define STAMP_READ(o)		(*(uint32_t *)((char *)stamp + (o)))
     73 #endif
     74 
     75 /*
     76  * Initialize rasops_info struct for this colordepth.
     77  */
     78 void
     79 rasops15_init(struct rasops_info *ri)
     80 {
     81 
     82 	if (FONT_IS_ALPHA(ri->ri_font)) {
     83 		ri->ri_ops.putchar = rasops15_putchar_aa;
     84 	} else {
     85 		switch (ri->ri_font->fontwidth) {
     86 #ifndef RASOPS_SMALL
     87 		case 8:
     88 			ri->ri_ops.putchar = rasops15_putchar8;
     89 			break;
     90 
     91 		case 12:
     92 			ri->ri_ops.putchar = rasops15_putchar12;
     93 			break;
     94 
     95 		case 16:
     96 			ri->ri_ops.putchar = rasops15_putchar16;
     97 			break;
     98 #endif	/* !RASOPS_SMALL */
     99 		default:
    100 			ri->ri_ops.putchar = rasops15_putchar;
    101 			break;
    102 		}
    103 	}
    104 
    105 	if (ri->ri_rnum == 0) {
    106 		ri->ri_rnum = 5;
    107 		ri->ri_rpos = 10 + (ri->ri_depth == 16);
    108 		ri->ri_gnum = 5 + (ri->ri_depth == 16);
    109 		ri->ri_gpos = 5;
    110 		ri->ri_bnum = 5;
    111 		ri->ri_bpos = 0;
    112 	}
    113 }
    114 
    115 /*
    116  * Paint a single character.
    117  */
    118 static void
    119 rasops15_putchar(void *cookie, int row, int col, u_int uc, long attr)
    120 {
    121 	int fb, width, height, cnt, clr[2];
    122 	struct rasops_info *ri = (struct rasops_info *)cookie;
    123 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    124 	uint8_t *dp, *rp, *hp, *hrp, *fr;
    125 
    126 	hp = hrp = NULL;
    127 
    128 #ifdef RASOPS_CLIPPING
    129 	/* Catches 'row < 0' case too */
    130 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    131 		return;
    132 
    133 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    134 		return;
    135 #endif
    136 
    137 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    138 	if (ri->ri_hwbits)
    139 		hrp = ri->ri_hwbits + row * ri->ri_yscale +
    140 		    col * ri->ri_xscale;
    141 	height = font->fontheight;
    142 	width = font->fontwidth;
    143 
    144 	clr[1] = ri->ri_devcmap[((u_int)attr >> 24) & 0xf];
    145 	clr[0] = ri->ri_devcmap[((u_int)attr >> 16) & 0xf];
    146 
    147 	if (uc == ' ') {
    148 		uint16_t c = (uint16_t)clr[0];
    149 		while (height--) {
    150 			dp = rp;
    151 			rp += ri->ri_stride;
    152 			if (ri->ri_hwbits) {
    153 				hp = hrp;
    154 				hrp += ri->ri_stride;
    155 			}
    156 
    157 			for (cnt = width; cnt; cnt--) {
    158 				*(uint16_t *)dp = c;
    159 				dp += 2;
    160 				if (ri->ri_hwbits) {
    161 					*(uint16_t *)hp = c;
    162 					hp += 2;
    163 				}
    164 			}
    165 		}
    166 	} else {
    167 		fr = FONT_GLYPH(uc, font, ri);
    168 
    169 		while (height--) {
    170 			dp = rp;
    171 			fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) |
    172 			    (fr[0] << 24);
    173 			fr += font->stride;
    174 			rp += ri->ri_stride;
    175 			if (ri->ri_hwbits) {
    176 				hp = hrp;
    177 				hrp += ri->ri_stride;
    178 			}
    179 
    180 			for (cnt = width; cnt; cnt--) {
    181 				*(uint16_t *)dp = (uint16_t)clr[(fb >> 31) & 1];
    182 				if (ri->ri_hwbits)
    183 					*(uint16_t *)hp =
    184 					    (uint16_t)clr[(fb >> 31) & 1];
    185 				fb <<= 1;
    186 				dp += 2;
    187 				if (ri->ri_hwbits)
    188 					hp += 2;
    189 			}
    190 		}
    191 	}
    192 
    193 	/* Do underline */
    194 	if ((attr & WSATTR_UNDERLINE) != 0) {
    195 		uint16_t c = (uint16_t)clr[1];
    196 		rp -= ri->ri_stride << 1;
    197 		if (ri->ri_hwbits)
    198 			hrp -= ri->ri_stride << 1;
    199 
    200 		while (width--) {
    201 			*(uint16_t *)rp = c;
    202 			rp += 2;
    203 			if (ri->ri_hwbits) {
    204 				*(uint16_t *)hrp = c;
    205 				hrp += 2;
    206 			}
    207 		}
    208 	}
    209 }
    210 
    211 static void
    212 rasops15_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
    213 {
    214 	int width, height, cnt, clr[2];
    215 	struct rasops_info *ri = (struct rasops_info *)cookie;
    216 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    217 	uint16_t *dp, *rp;
    218 	uint8_t *rrp;
    219 	uint8_t *fr;
    220 	uint16_t buffer[64]; /* XXX */
    221 	int x, y, r, g, b, aval;
    222 	int r1, g1, b1, r0, g0, b0, fgo, bgo;
    223 
    224 
    225 #ifdef RASOPS_CLIPPING
    226 	/* Catches 'row < 0' case too */
    227 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    228 		return;
    229 
    230 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    231 		return;
    232 #endif
    233 
    234 	/* check if character fits into font limits */
    235 	if (!CHAR_IN_FONT(uc, font))
    236 		return;
    237 
    238 	rrp = (ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    239 	rp = (uint16_t *)rrp;
    240 
    241 	height = font->fontheight;
    242 	width = font->fontwidth;
    243 
    244 	clr[0] = ri->ri_devcmap[(attr >> 16) & 0xf];
    245 	clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
    246 
    247 	if (uc == ' ') {
    248 	        for (cnt = 0; cnt < width; cnt++)
    249 	                buffer[cnt] = clr[0];
    250 		while (height--) {
    251 			dp = rp;
    252 			DELTA(rp, ri->ri_stride, uint16_t *);
    253 			memcpy(dp, buffer, width << 1);
    254 		}
    255 	} else {
    256 		fr = FONT_GLYPH(uc, font, ri);
    257 
    258 		fgo = ((attr >> 24) & 0xf) * 3;
    259 		bgo = ((attr >> 16) & 0xf) * 3;
    260 
    261 		r0 = rasops_cmap[bgo];
    262 		r1 = rasops_cmap[fgo];
    263 		g0 = rasops_cmap[bgo + 1];
    264 		g1 = rasops_cmap[fgo + 1];
    265 		b0 = rasops_cmap[bgo + 2];
    266 		b1 = rasops_cmap[fgo + 2];
    267 
    268 		for (y = 0; y < height; y++) {
    269 			dp = (uint16_t *)(rrp + ri->ri_stride * y);
    270 			for (x = 0; x < width; x++) {
    271 				aval = *fr;
    272 				if (aval == 0) {
    273 					buffer[x] = clr[0];
    274 				} else if (aval == 255) {
    275 					buffer[x] = clr[1];
    276 				} else {
    277 					r = aval * r1 + (255 - aval) * r0;
    278 					g = aval * g1 + (255 - aval) * g0;
    279 					b = aval * b1 + (255 - aval) * b0;
    280 					buffer[x] =
    281 					    ((r >> (16 - ri->ri_rnum)) <<
    282 						ri->ri_rpos) |
    283 					    ((g >> (16 - ri->ri_gnum)) <<
    284 					        ri->ri_gpos) |
    285 					    ((b >> (16 - ri->ri_bnum)) <<
    286 						ri->ri_bpos);
    287 				}
    288 				fr++;
    289 			}
    290 			memcpy(dp, buffer, width << 1);
    291 		}
    292 	}
    293 
    294 	/* Do underline */
    295 	if ((attr & WSATTR_UNDERLINE) != 0) {
    296 	        rp = (uint16_t *)rrp;
    297 		DELTA(rp, (ri->ri_stride * (height - 2)), uint16_t *);
    298 		while (width--)
    299 			*rp++ = clr[1];
    300 	}
    301 }
    302 
    303 #ifndef RASOPS_SMALL
    304 /*
    305  * Recompute the (2x2)x1 blitting stamp.
    306  */
    307 static void
    308 rasops15_makestamp(struct rasops_info *ri, long attr)
    309 {
    310 	uint32_t fg, bg;
    311 	int i;
    312 
    313 	fg = ri->ri_devcmap[((u_int)attr >> 24) & 0xf] & 0xffff;
    314 	bg = ri->ri_devcmap[((u_int)attr >> 16) & 0xf] & 0xffff;
    315 	stamp_attr = attr;
    316 
    317 	for (i = 0; i < 32; i += 2) {
    318 #if BYTE_ORDER == LITTLE_ENDIAN
    319 		stamp[i] = (i & 16 ? fg : bg);
    320 		stamp[i] |= ((i & 8 ? fg : bg) << 16);
    321 		stamp[i + 1] = (i & 4 ? fg : bg);
    322 		stamp[i + 1] |= ((i & 2 ? fg : bg) << 16);
    323 #else
    324 		stamp[i] = (i & 8 ? fg : bg);
    325 		stamp[i] |= ((i & 16 ? fg : bg) << 16);
    326 		stamp[i + 1] = (i & 2 ? fg : bg);
    327 		stamp[i + 1] |= ((i & 4 ? fg : bg) << 16);
    328 #endif
    329 	}
    330 }
    331 
    332 /*
    333  * Paint a single character. This is for 8-pixel wide fonts.
    334  */
    335 static void
    336 rasops15_putchar8(void *cookie, int row, int col, u_int uc, long attr)
    337 {
    338 	struct rasops_info *ri = (struct rasops_info *)cookie;
    339 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    340 	int height, so, fs;
    341 	uint32_t *rp, *hrp;
    342 	uint8_t *fr;
    343 
    344 	/* Can't risk remaking the stamp if it's already in use */
    345 	if (stamp_mutex++) {
    346 		stamp_mutex--;
    347 		rasops15_putchar(cookie, row, col, uc, attr);
    348 		return;
    349 	}
    350 
    351 	hrp = NULL;
    352 
    353 #ifdef RASOPS_CLIPPING
    354 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    355 		stamp_mutex--;
    356 		return;
    357 	}
    358 
    359 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    360 		stamp_mutex--;
    361 		return;
    362 	}
    363 #endif
    364 
    365 	/* Recompute stamp? */
    366 	if (attr != stamp_attr)
    367 		rasops15_makestamp(ri, attr);
    368 
    369 	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    370 	if (ri->ri_hwbits)
    371 		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    372 		    col*ri->ri_xscale);
    373 	height = font->fontheight;
    374 
    375 	if (uc == (u_int)-1) {
    376 		while (height--) {
    377 			rp[0] = rp[1] = rp[2] = rp[3] = stamp[0];
    378 			DELTA(rp, ri->ri_stride, uint32_t *);
    379 			if (ri->ri_hwbits) {
    380 				hrp[0] = hrp[1] = hrp[2] = hrp[3] = stamp[0];
    381 				DELTA(hrp, ri->ri_stride, uint32_t *);
    382 			}
    383 		}
    384 	} else {
    385 		fr = FONT_GLYPH(uc, font, ri);
    386 		fs = font->stride;
    387 
    388 		while (height--) {
    389 			so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
    390 			rp[0] = STAMP_READ(so);
    391 			rp[1] = STAMP_READ(so + 4);
    392 			if (ri->ri_hwbits) {
    393 				hrp[0] = STAMP_READ(so);
    394 				hrp[1] = STAMP_READ(so + 4);
    395 			}
    396 
    397 			so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
    398 			rp[2] = STAMP_READ(so);
    399 			rp[3] = STAMP_READ(so + 4);
    400 			if (ri->ri_hwbits) {
    401 				hrp[2] = STAMP_READ(so);
    402 				hrp[3] = STAMP_READ(so + 4);
    403 			}
    404 
    405 			fr += fs;
    406 			DELTA(rp, ri->ri_stride, uint32_t *);
    407 			if (ri->ri_hwbits)
    408 				DELTA(hrp, ri->ri_stride, uint32_t *);
    409 		}
    410 	}
    411 
    412 	/* Do underline */
    413 	if ((attr & WSATTR_UNDERLINE) != 0) {
    414 		uint32_t c = STAMP_READ(28);
    415 
    416 		DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
    417 		rp[0] = rp[1] = rp[2] = rp[3] = c;
    418 		if (ri->ri_hwbits) {
    419 			DELTA(hrp, -(ri->ri_stride << 1), uint32_t *);
    420 			hrp[0] = hrp[1] = hrp[2] = hrp[3] = c;
    421 		}
    422 	}
    423 
    424 	stamp_mutex--;
    425 }
    426 
    427 /*
    428  * Paint a single character. This is for 12-pixel wide fonts.
    429  */
    430 static void
    431 rasops15_putchar12(void *cookie, int row, int col, u_int uc, long attr)
    432 {
    433 	struct rasops_info *ri = (struct rasops_info *)cookie;
    434 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    435 	int height, so, fs;
    436 	uint32_t *rp, *hrp;
    437 	uint8_t *fr;
    438 
    439 	/* Can't risk remaking the stamp if it's already in use */
    440 	if (stamp_mutex++) {
    441 		stamp_mutex--;
    442 		rasops15_putchar(cookie, row, col, uc, attr);
    443 		return;
    444 	}
    445 
    446 	hrp = NULL;
    447 
    448 #ifdef RASOPS_CLIPPING
    449 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    450 		stamp_mutex--;
    451 		return;
    452 	}
    453 
    454 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    455 		stamp_mutex--;
    456 		return;
    457 	}
    458 #endif
    459 
    460 	/* Recompute stamp? */
    461 	if (attr != stamp_attr)
    462 		rasops15_makestamp(ri, attr);
    463 
    464 	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    465 	if (ri->ri_hwbits)
    466 		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    467 		    col*ri->ri_xscale);
    468 	height = font->fontheight;
    469 
    470 	if (uc == (u_int)-1) {
    471 		while (height--) {
    472 			rp[0] = rp[1] = rp[2] = rp[3] = rp[4] = rp[5] =
    473 			    stamp[0];
    474 			DELTA(rp, ri->ri_stride, uint32_t *);
    475 			if (ri->ri_hwbits) {
    476 				hrp[0] = hrp[1] = hrp[2] = hrp[3] = hrp[4] =
    477 				    hrp[5] = stamp[0];
    478 				DELTA(hrp, ri->ri_stride, uint32_t *);
    479 			}
    480 		}
    481 	} else {
    482 		fr = FONT_GLYPH(uc, font, ri);
    483 		fs = font->stride;
    484 
    485 		while (height--) {
    486 			so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
    487 			rp[0] = STAMP_READ(so);
    488 			rp[1] = STAMP_READ(so + 4);
    489 			if (ri->ri_hwbits) {
    490 				hrp[0] = STAMP_READ(so);
    491 				hrp[1] = STAMP_READ(so + 4);
    492 			}
    493 
    494 			so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
    495 			rp[2] = STAMP_READ(so);
    496 			rp[3] = STAMP_READ(so + 4);
    497 			if (ri->ri_hwbits) {
    498 				hrp[2] = STAMP_READ(so);
    499 				hrp[3] = STAMP_READ(so + 4);
    500 			}
    501 
    502 			so = STAMP_SHIFT(fr[1], 1) & STAMP_MASK;
    503 			rp[4] = STAMP_READ(so);
    504 			rp[5] = STAMP_READ(so + 4);
    505 			if (ri->ri_hwbits) {
    506 				hrp[4] = STAMP_READ(so);
    507 				hrp[5] = STAMP_READ(so + 4);
    508 			}
    509 
    510 			fr += fs;
    511 			DELTA(rp, ri->ri_stride, uint32_t *);
    512 			if (ri->ri_hwbits)
    513 				DELTA(hrp, ri->ri_stride, uint32_t *);
    514 		}
    515 	}
    516 
    517 	/* Do underline */
    518 	if (attr & WSATTR_UNDERLINE) {
    519 		uint32_t c = STAMP_READ(28);
    520 
    521 		DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
    522 		rp[0] = rp[1] = rp[2] = rp[3] = rp[4] = rp[5] = c;
    523 		if (ri->ri_hwbits) {
    524 			DELTA(hrp, -(ri->ri_stride << 1), uint32_t *);
    525 			hrp[0] = hrp[1] = hrp[2] = hrp[3] = hrp[4] = hrp[5] = c;
    526 		}
    527 	}
    528 
    529 	stamp_mutex--;
    530 }
    531 
    532 /*
    533  * Paint a single character. This is for 16-pixel wide fonts.
    534  */
    535 static void
    536 rasops15_putchar16(void *cookie, int row, int col, u_int uc, long attr)
    537 {
    538 	struct rasops_info *ri = (struct rasops_info *)cookie;
    539 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    540 	int height, so, fs;
    541 	uint32_t *rp, *hrp;
    542 	uint8_t *fr;
    543 
    544 	/* Can't risk remaking the stamp if it's already in use */
    545 	if (stamp_mutex++) {
    546 		stamp_mutex--;
    547 		rasops15_putchar(cookie, row, col, uc, attr);
    548 		return;
    549 	}
    550 
    551 	hrp = NULL;
    552 
    553 #ifdef RASOPS_CLIPPING
    554 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    555 		stamp_mutex--;
    556 		return;
    557 	}
    558 
    559 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    560 		stamp_mutex--;
    561 		return;
    562 	}
    563 #endif
    564 
    565 	/* Recompute stamp? */
    566 	if (attr != stamp_attr)
    567 		rasops15_makestamp(ri, attr);
    568 
    569 	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    570 	if (ri->ri_hwbits)
    571 		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    572 		    col*ri->ri_xscale);
    573 	height = font->fontheight;
    574 
    575 	if (uc == (u_int)-1) {
    576 		while (height--) {
    577 			rp[0] = rp[1] = rp[2] = rp[3] =
    578 			rp[4] = rp[5] = rp[6] = rp[7] = stamp[0];
    579 			DELTA(rp, ri->ri_stride, uint32_t *);
    580 			if (ri->ri_hwbits) {
    581 				hrp[0] = hrp[1] = hrp[2] = hrp[3] =
    582 				hrp[4] = hrp[5] = hrp[6] = hrp[7] = stamp[0];
    583 				DELTA(hrp, ri->ri_stride, uint32_t *);
    584 			}
    585 		}
    586 	} else {
    587 		fr = FONT_GLYPH(uc, font, ri);
    588 		fs = font->stride;
    589 
    590 		while (height--) {
    591 			so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
    592 			rp[0] = STAMP_READ(so);
    593 			rp[1] = STAMP_READ(so + 4);
    594 			if (ri->ri_hwbits) {
    595 				hrp[0] = STAMP_READ(so);
    596 				hrp[1] = STAMP_READ(so + 4);
    597 			}
    598 
    599 			so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
    600 			rp[2] = STAMP_READ(so);
    601 			rp[3] = STAMP_READ(so + 4);
    602 			if (ri->ri_hwbits) {
    603 				hrp[2] = STAMP_READ(so);
    604 				hrp[3] = STAMP_READ(so + 4);
    605 			}
    606 
    607 			so = STAMP_SHIFT(fr[1], 1) & STAMP_MASK;
    608 			rp[4] = STAMP_READ(so);
    609 			rp[5] = STAMP_READ(so + 4);
    610 			if (ri->ri_hwbits) {
    611 				hrp[4] = STAMP_READ(so);
    612 				hrp[5] = STAMP_READ(so + 4);
    613 			}
    614 
    615 			so = STAMP_SHIFT(fr[1], 0) & STAMP_MASK;
    616 			rp[6] = STAMP_READ(so);
    617 			rp[7] = STAMP_READ(so + 4);
    618 			if (ri->ri_hwbits) {
    619 				hrp[6] = STAMP_READ(so);
    620 				hrp[7] = STAMP_READ(so + 4);
    621 			}
    622 
    623 			DELTA(rp, ri->ri_stride, uint32_t *);
    624 			if (ri->ri_hwbits)
    625 				DELTA(hrp, ri->ri_stride, uint32_t *);
    626 			fr += fs;
    627 		}
    628 	}
    629 
    630 	/* Do underline */
    631 	if (attr & WSATTR_UNDERLINE) {
    632 		uint32_t c = STAMP_READ(28);
    633 
    634 		DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
    635 		rp[0] = rp[1] = rp[2] = rp[3] =
    636 		rp[4] = rp[5] = rp[6] = rp[7] = c;
    637 		if (ri->ri_hwbits) {
    638 			DELTA(hrp, -(ri->ri_stride << 1), uint32_t *);
    639 			hrp[0] = hrp[1] = hrp[2] = hrp[3] =
    640 			hrp[4] = hrp[5] = hrp[6] = hrp[7] = c;
    641 		}
    642 	}
    643 
    644 	stamp_mutex--;
    645 }
    646 #endif	/* !RASOPS_SMALL */
    647