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