Home | History | Annotate | Line # | Download | only in rasops
rasops8.c revision 1.22.24.1
      1  1.22.24.1        ad /* 	$NetBSD: rasops8.c,v 1.22.24.1 2007/12/26 19:47:21 ad 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.9        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.12     lukem #include <sys/cdefs.h>
     40  1.22.24.1        ad __KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.22.24.1 2007/12/26 19:47:21 ad Exp $");
     41       1.12     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.18     perry static void 	rasops8_putchar(void *, int, int, u_int, long attr);
     53        1.7        ad #ifndef RASOPS_SMALL
     54       1.18     perry static void 	rasops8_putchar8(void *, int, int, u_int, long attr);
     55       1.18     perry static void 	rasops8_putchar12(void *, int, int, u_int, long attr);
     56       1.18     perry static void 	rasops8_putchar16(void *, int, int, u_int, long attr);
     57       1.18     perry static void	rasops8_makestamp(struct rasops_info *ri, long);
     58        1.1        ad 
     59        1.8        pk /*
     60        1.8        pk  * 4x1 stamp for optimized character blitting
     61        1.1        ad  */
     62        1.1        ad static int32_t	stamp[16];
     63        1.1        ad static long	stamp_attr;
     64        1.1        ad static int	stamp_mutex;	/* XXX see note in README */
     65       1.10     bjh21 #endif
     66        1.1        ad 
     67        1.1        ad /*
     68        1.1        ad  * XXX this confuses the hell out of gcc2 (not egcs) which always insists
     69        1.1        ad  * that the shift count is negative.
     70        1.1        ad  *
     71        1.1        ad  * offset = STAMP_SHIFT(fontbits, nibble #) & STAMP_MASK
     72        1.1        ad  * destination = STAMP_READ(offset)
     73        1.1        ad  */
     74        1.1        ad #define STAMP_SHIFT(fb,n)	((n*4-2) >= 0 ? (fb)>>(n*4-2):(fb)<<-(n*4-2))
     75        1.8        pk #define STAMP_MASK		(0xf << 2)
     76       1.22  christos #define STAMP_READ(o)		(*(int32_t *)((char *)stamp + (o)))
     77        1.1        ad 
     78        1.1        ad /*
     79       1.11       wiz  * Initialize a 'rasops_info' descriptor for this depth.
     80        1.1        ad  */
     81        1.1        ad void
     82        1.1        ad rasops8_init(ri)
     83        1.1        ad 	struct rasops_info *ri;
     84        1.1        ad {
     85        1.8        pk 
     86        1.1        ad 	switch (ri->ri_font->fontwidth) {
     87        1.7        ad #ifndef RASOPS_SMALL
     88        1.1        ad 	case 8:
     89        1.1        ad 		ri->ri_ops.putchar = rasops8_putchar8;
     90        1.1        ad 		break;
     91        1.1        ad 	case 12:
     92        1.1        ad 		ri->ri_ops.putchar = rasops8_putchar12;
     93        1.1        ad 		break;
     94        1.1        ad 	case 16:
     95        1.1        ad 		ri->ri_ops.putchar = rasops8_putchar16;
     96        1.1        ad 		break;
     97        1.7        ad #endif /* !RASOPS_SMALL */
     98        1.1        ad 	default:
     99        1.1        ad 		ri->ri_ops.putchar = rasops8_putchar;
    100        1.1        ad 		break;
    101        1.1        ad 	}
    102        1.1        ad }
    103        1.1        ad 
    104        1.1        ad /*
    105        1.3        ad  * Put a single character.
    106        1.1        ad  */
    107        1.1        ad static void
    108        1.1        ad rasops8_putchar(cookie, row, col, uc, attr)
    109        1.1        ad 	void *cookie;
    110        1.1        ad 	int row, col;
    111        1.1        ad 	u_int uc;
    112        1.1        ad 	long attr;
    113        1.1        ad {
    114        1.7        ad 	int width, height, cnt, fs, fb;
    115       1.21  jmcneill 	u_char *dp, *rp, *hp, *hrp, *fr, clr[2];
    116        1.1        ad 	struct rasops_info *ri;
    117        1.8        pk 
    118        1.1        ad 	ri = (struct rasops_info *)cookie;
    119       1.21  jmcneill 	hp = hrp = NULL;
    120        1.1        ad 
    121       1.17    petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    122       1.17    petrov 		return;
    123       1.17    petrov 
    124        1.8        pk #ifdef RASOPS_CLIPPING
    125        1.8        pk 	/* Catches 'row < 0' case too */
    126        1.1        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    127        1.1        ad 		return;
    128        1.1        ad 
    129        1.1        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    130        1.1        ad 		return;
    131        1.1        ad #endif
    132        1.1        ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    133       1.21  jmcneill 	if (ri->ri_hwbits)
    134       1.21  jmcneill 		hrp = ri->ri_hwbits + row * ri->ri_yscale + col *
    135       1.21  jmcneill 		    ri->ri_xscale;
    136        1.1        ad 
    137        1.1        ad 	height = ri->ri_font->fontheight;
    138        1.1        ad 	width = ri->ri_font->fontwidth;
    139        1.8        pk 	clr[0] = (u_char)ri->ri_devcmap[(attr >> 16) & 0xf];
    140        1.8        pk 	clr[1] = (u_char)ri->ri_devcmap[(attr >> 24) & 0xf];
    141        1.8        pk 
    142        1.1        ad 	if (uc == ' ') {
    143        1.8        pk 		u_char c = clr[0];
    144        1.8        pk 
    145        1.1        ad 		while (height--) {
    146        1.1        ad 			dp = rp;
    147        1.1        ad 			rp += ri->ri_stride;
    148       1.21  jmcneill 			if (ri->ri_hwbits) {
    149       1.21  jmcneill 				hp = hrp;
    150       1.21  jmcneill 				hrp += ri->ri_stride;
    151       1.21  jmcneill 			}
    152        1.8        pk 
    153       1.21  jmcneill 			for (cnt = width; cnt; cnt--) {
    154        1.8        pk 				*dp++ = c;
    155       1.21  jmcneill 				if (ri->ri_hwbits)
    156       1.21  jmcneill 					*hp++ = c;
    157       1.21  jmcneill 			}
    158        1.1        ad 		}
    159        1.1        ad 	} else {
    160        1.1        ad 		uc -= ri->ri_font->firstchar;
    161        1.1        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    162        1.1        ad 		fs = ri->ri_font->stride;
    163        1.1        ad 
    164        1.1        ad 		while (height--) {
    165        1.1        ad 			dp = rp;
    166       1.21  jmcneill 			if (ri->ri_hwbits)
    167       1.21  jmcneill 				hp = hrp;
    168        1.1        ad 			fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) | (fr[0] << 24);
    169        1.1        ad 			fr += fs;
    170        1.1        ad 			rp += ri->ri_stride;
    171       1.21  jmcneill 			if (ri->ri_hwbits)
    172       1.21  jmcneill 				hrp += ri->ri_stride;
    173        1.8        pk 
    174        1.1        ad 			for (cnt = width; cnt; cnt--) {
    175        1.1        ad 				*dp++ = clr[(fb >> 31) & 1];
    176       1.21  jmcneill 				if (ri->ri_hwbits)
    177       1.21  jmcneill 					*hp++ = clr[(fb >> 31) & 1];
    178        1.1        ad 				fb <<= 1;
    179        1.1        ad 			}
    180        1.1        ad 		}
    181        1.8        pk 	}
    182        1.1        ad 
    183        1.1        ad 	/* Do underline */
    184        1.7        ad 	if ((attr & 1) != 0) {
    185        1.8        pk 		u_char c = clr[1];
    186        1.8        pk 
    187        1.1        ad 		rp -= (ri->ri_stride << 1);
    188       1.21  jmcneill 		if (ri->ri_hwbits)
    189       1.21  jmcneill 			hrp -= (ri->ri_stride << 1);
    190        1.1        ad 
    191       1.21  jmcneill 		while (width--) {
    192        1.8        pk 			*rp++ = c;
    193       1.21  jmcneill 			if (ri->ri_hwbits)
    194       1.21  jmcneill 				*hrp++ = c;
    195       1.21  jmcneill 		}
    196        1.8        pk 	}
    197        1.1        ad }
    198        1.1        ad 
    199        1.7        ad #ifndef RASOPS_SMALL
    200        1.1        ad /*
    201        1.1        ad  * Recompute the 4x1 blitting stamp.
    202        1.1        ad  */
    203        1.1        ad static void
    204        1.6        ad rasops8_makestamp(ri, attr)
    205        1.6        ad 	struct rasops_info *ri;
    206        1.3        ad 	long attr;
    207        1.1        ad {
    208        1.7        ad 	int32_t fg, bg;
    209        1.1        ad 	int i;
    210        1.5        ad 
    211        1.8        pk 	fg = ri->ri_devcmap[(attr >> 24) & 0xf] & 0xff;
    212        1.8        pk 	bg = ri->ri_devcmap[(attr >> 16) & 0xf] & 0xff;
    213        1.1        ad 	stamp_attr = attr;
    214        1.8        pk 
    215        1.1        ad 	for (i = 0; i < 16; i++) {
    216       1.16       uwe #if BYTE_ORDER == BIG_ENDIAN
    217       1.16       uwe #define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
    218        1.1        ad #else
    219       1.16       uwe #define NEED_LITTLE_ENDIAN_STAMP 0
    220        1.1        ad #endif
    221       1.16       uwe 		if ((ri->ri_flg & RI_BSWAP) == NEED_LITTLE_ENDIAN_STAMP) {
    222       1.16       uwe 			/* little endian */
    223       1.16       uwe 			stamp[i] = (i & 8 ? fg : bg);
    224       1.16       uwe 			stamp[i] |= ((i & 4 ? fg : bg) << 8);
    225       1.16       uwe 			stamp[i] |= ((i & 2 ? fg : bg) << 16);
    226       1.16       uwe 			stamp[i] |= ((i & 1 ? fg : bg) << 24);
    227       1.16       uwe 		} else {
    228       1.16       uwe 			/* big endian */
    229       1.16       uwe 			stamp[i] = (i & 1 ? fg : bg);
    230       1.16       uwe 			stamp[i] |= ((i & 2 ? fg : bg) << 8);
    231       1.16       uwe 			stamp[i] |= ((i & 4 ? fg : bg) << 16);
    232       1.16       uwe 			stamp[i] |= ((i & 8 ? fg : bg) << 24);
    233       1.16       uwe 		}
    234        1.1        ad 	}
    235        1.1        ad }
    236        1.1        ad 
    237        1.1        ad /*
    238        1.3        ad  * Put a single character. This is for 8-pixel wide fonts.
    239        1.1        ad  */
    240        1.1        ad static void
    241        1.1        ad rasops8_putchar8(cookie, row, col, uc, attr)
    242        1.1        ad 	void *cookie;
    243        1.1        ad 	int row, col;
    244        1.1        ad 	u_int uc;
    245        1.1        ad 	long attr;
    246        1.1        ad {
    247        1.1        ad 	struct rasops_info *ri;
    248        1.1        ad 	int height, fs;
    249       1.21  jmcneill 	int32_t *rp, *hp;
    250        1.1        ad 	u_char *fr;
    251        1.8        pk 
    252        1.1        ad 	/* Can't risk remaking the stamp if it's already in use */
    253        1.1        ad 	if (stamp_mutex++) {
    254        1.1        ad 		stamp_mutex--;
    255        1.1        ad 		rasops8_putchar(cookie, row, col, uc, attr);
    256        1.1        ad 		return;
    257        1.1        ad 	}
    258        1.1        ad 
    259        1.1        ad 	ri = (struct rasops_info *)cookie;
    260       1.21  jmcneill 	hp = NULL;
    261        1.1        ad 
    262       1.17    petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    263       1.17    petrov 		return;
    264       1.17    petrov 
    265        1.8        pk #ifdef RASOPS_CLIPPING
    266        1.1        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    267        1.1        ad 		stamp_mutex--;
    268        1.1        ad 		return;
    269        1.1        ad 	}
    270        1.1        ad 
    271        1.1        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    272        1.1        ad 		stamp_mutex--;
    273        1.1        ad 		return;
    274        1.1        ad 	}
    275        1.1        ad #endif
    276        1.1        ad 
    277        1.1        ad 	/* Recompute stamp? */
    278        1.1        ad 	if (attr != stamp_attr)
    279        1.6        ad 		rasops8_makestamp(ri, attr);
    280        1.8        pk 
    281        1.1        ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    282       1.21  jmcneill 	if (ri->ri_hwbits)
    283       1.21  jmcneill 		hp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    284       1.21  jmcneill 		    col*ri->ri_xscale);
    285        1.1        ad 	height = ri->ri_font->fontheight;
    286        1.8        pk 
    287        1.1        ad 	if (uc == ' ') {
    288        1.1        ad 		while (height--) {
    289        1.8        pk 			rp[0] = rp[1] = stamp[0];
    290        1.1        ad 			DELTA(rp, ri->ri_stride, int32_t *);
    291       1.21  jmcneill 			if (ri->ri_hwbits) {
    292  1.22.24.1        ad 				hp[0] = stamp[0];
    293  1.22.24.1        ad 				hp[1] = stamp[0];
    294       1.21  jmcneill 				DELTA(hp, ri->ri_stride, int32_t *);
    295       1.21  jmcneill 			}
    296        1.8        pk 		}
    297        1.1        ad 	} else {
    298        1.1        ad 		uc -= ri->ri_font->firstchar;
    299        1.1        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    300        1.1        ad 		fs = ri->ri_font->stride;
    301        1.8        pk 
    302        1.1        ad 		while (height--) {
    303        1.1        ad 			rp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    304        1.1        ad 			rp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    305       1.21  jmcneill 			if (ri->ri_hwbits) {
    306       1.21  jmcneill 				hp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) &
    307       1.21  jmcneill 				    STAMP_MASK);
    308       1.21  jmcneill 				hp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) &
    309       1.21  jmcneill 				    STAMP_MASK);
    310       1.21  jmcneill 			}
    311        1.1        ad 
    312        1.1        ad 			fr += fs;
    313        1.8        pk 			DELTA(rp, ri->ri_stride, int32_t *);
    314       1.21  jmcneill 			if (ri->ri_hwbits)
    315       1.21  jmcneill 				DELTA(hp, ri->ri_stride, int32_t *);
    316        1.1        ad 		}
    317        1.1        ad 	}
    318        1.1        ad 
    319        1.1        ad 	/* Do underline */
    320        1.7        ad 	if ((attr & 1) != 0) {
    321        1.8        pk 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    322        1.8        pk 		rp[0] = rp[1] = stamp[15];
    323       1.21  jmcneill 		if (ri->ri_hwbits) {
    324       1.21  jmcneill 			DELTA(hp, -(ri->ri_stride << 1), int32_t *);
    325  1.22.24.1        ad 			hp[0] = stamp[15];
    326  1.22.24.1        ad 			hp[1] = stamp[15];
    327       1.21  jmcneill 		}
    328        1.8        pk 	}
    329        1.8        pk 
    330        1.8        pk 	stamp_mutex--;
    331        1.1        ad }
    332        1.1        ad 
    333        1.1        ad /*
    334        1.3        ad  * Put a single character. This is for 12-pixel wide fonts.
    335        1.1        ad  */
    336        1.1        ad static void
    337        1.1        ad rasops8_putchar12(cookie, row, col, uc, attr)
    338        1.1        ad 	void *cookie;
    339        1.1        ad 	int row, col;
    340        1.1        ad 	u_int uc;
    341        1.1        ad 	long attr;
    342        1.1        ad {
    343        1.1        ad 	struct rasops_info *ri;
    344        1.1        ad 	int height, fs;
    345       1.21  jmcneill 	int32_t *rp,  *hrp;
    346        1.1        ad 	u_char *fr;
    347        1.8        pk 
    348        1.1        ad 	/* Can't risk remaking the stamp if it's already in use */
    349        1.1        ad 	if (stamp_mutex++) {
    350        1.1        ad 		stamp_mutex--;
    351        1.1        ad 		rasops8_putchar(cookie, row, col, uc, attr);
    352        1.1        ad 		return;
    353        1.1        ad 	}
    354        1.1        ad 
    355        1.1        ad 	ri = (struct rasops_info *)cookie;
    356       1.21  jmcneill 	hrp = NULL;
    357        1.1        ad 
    358       1.17    petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    359       1.17    petrov 	    return;
    360       1.17    petrov 
    361        1.8        pk #ifdef RASOPS_CLIPPING
    362        1.1        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    363        1.1        ad 		stamp_mutex--;
    364        1.1        ad 		return;
    365        1.1        ad 	}
    366        1.1        ad 
    367        1.1        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    368        1.1        ad 		stamp_mutex--;
    369        1.1        ad 		return;
    370        1.1        ad 	}
    371        1.1        ad #endif
    372        1.1        ad 
    373        1.1        ad 	/* Recompute stamp? */
    374        1.1        ad 	if (attr != stamp_attr)
    375        1.6        ad 		rasops8_makestamp(ri, attr);
    376        1.8        pk 
    377        1.1        ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    378       1.21  jmcneill 	if (ri->ri_hwbits)
    379       1.21  jmcneill 		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    380       1.21  jmcneill 		    col*ri->ri_xscale);
    381        1.1        ad 	height = ri->ri_font->fontheight;
    382        1.8        pk 
    383        1.1        ad 	if (uc == ' ') {
    384        1.1        ad 		while (height--) {
    385        1.8        pk 			int32_t c = stamp[0];
    386        1.8        pk 
    387        1.8        pk 			rp[0] = rp[1] = rp[2] = c;
    388        1.8        pk 			DELTA(rp, ri->ri_stride, int32_t *);
    389       1.21  jmcneill 			if (ri->ri_hwbits) {
    390  1.22.24.1        ad 				hrp[0] = c;
    391  1.22.24.1        ad 				hrp[1] = c;
    392  1.22.24.1        ad 				hrp[2] = c;
    393       1.21  jmcneill 				DELTA(hrp, ri->ri_stride, int32_t *);
    394       1.21  jmcneill 			}
    395        1.8        pk 		}
    396        1.1        ad 	} else {
    397        1.1        ad 		uc -= ri->ri_font->firstchar;
    398        1.1        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    399        1.1        ad 		fs = ri->ri_font->stride;
    400        1.8        pk 
    401        1.1        ad 		while (height--) {
    402        1.1        ad 			rp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    403        1.1        ad 			rp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    404        1.1        ad 			rp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    405       1.21  jmcneill 			if (ri->ri_hwbits) {
    406       1.21  jmcneill 				hrp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    407       1.21  jmcneill 				hrp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    408       1.21  jmcneill 				hrp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    409       1.21  jmcneill 			}
    410        1.8        pk 
    411        1.1        ad 			fr += fs;
    412        1.8        pk 			DELTA(rp, ri->ri_stride, int32_t *);
    413       1.21  jmcneill 			if (ri->ri_hwbits)
    414       1.21  jmcneill 				DELTA(hrp, ri->ri_stride, int32_t *);
    415        1.1        ad 		}
    416        1.8        pk 	}
    417        1.1        ad 
    418        1.1        ad 	/* Do underline */
    419        1.7        ad 	if ((attr & 1) != 0) {
    420        1.8        pk 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    421        1.8        pk 		rp[0] = rp[1] = rp[2] = stamp[15];
    422       1.21  jmcneill 		if (ri->ri_hwbits) {
    423       1.21  jmcneill 			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    424  1.22.24.1        ad 			hrp[0] = stamp[15];
    425  1.22.24.1        ad 			hrp[1] = stamp[15];
    426  1.22.24.1        ad 			hrp[2] = stamp[15];
    427       1.21  jmcneill 		}
    428        1.8        pk 	}
    429        1.8        pk 
    430        1.1        ad 	stamp_mutex--;
    431        1.1        ad }
    432        1.1        ad 
    433        1.1        ad /*
    434        1.3        ad  * Put a single character. This is for 16-pixel wide fonts.
    435        1.1        ad  */
    436        1.1        ad static void
    437        1.1        ad rasops8_putchar16(cookie, row, col, uc, attr)
    438        1.1        ad 	void *cookie;
    439        1.1        ad 	int row, col;
    440        1.1        ad 	u_int uc;
    441        1.1        ad 	long attr;
    442        1.1        ad {
    443        1.1        ad 	struct rasops_info *ri;
    444        1.1        ad 	int height, fs;
    445       1.21  jmcneill 	int32_t *rp, *hrp;
    446        1.1        ad 	u_char *fr;
    447        1.1        ad 
    448        1.1        ad 	/* Can't risk remaking the stamp if it's already in use */
    449        1.1        ad 	if (stamp_mutex++) {
    450        1.1        ad 		stamp_mutex--;
    451        1.1        ad 		rasops8_putchar(cookie, row, col, uc, attr);
    452        1.1        ad 		return;
    453        1.1        ad 	}
    454        1.1        ad 
    455        1.1        ad 	ri = (struct rasops_info *)cookie;
    456       1.21  jmcneill 	hrp = NULL;
    457        1.1        ad 
    458       1.17    petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    459       1.17    petrov 		return;
    460       1.17    petrov 
    461        1.8        pk #ifdef RASOPS_CLIPPING
    462        1.1        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    463        1.1        ad 		stamp_mutex--;
    464        1.1        ad 		return;
    465        1.1        ad 	}
    466        1.1        ad 
    467        1.1        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    468        1.1        ad 		stamp_mutex--;
    469        1.1        ad 		return;
    470        1.1        ad 	}
    471        1.1        ad #endif
    472        1.1        ad 
    473        1.1        ad 	/* Recompute stamp? */
    474        1.1        ad 	if (attr != stamp_attr)
    475        1.6        ad 		rasops8_makestamp(ri, attr);
    476        1.8        pk 
    477        1.1        ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    478       1.21  jmcneill 	if (ri->ri_hwbits)
    479       1.21  jmcneill 		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    480       1.21  jmcneill 		    col*ri->ri_xscale);
    481       1.21  jmcneill 
    482        1.1        ad 	height = ri->ri_font->fontheight;
    483        1.8        pk 
    484        1.1        ad 	if (uc == ' ') {
    485       1.21  jmcneill 		while (height--) {
    486        1.8        pk 			rp[0] = rp[1] = rp[2] = rp[3] = stamp[0];
    487  1.22.24.1        ad 			if (ri->ri_hwbits) {
    488  1.22.24.1        ad 				hrp[0] = stamp[0];
    489  1.22.24.1        ad 				hrp[1] = stamp[0];
    490  1.22.24.1        ad 				hrp[2] = stamp[0];
    491  1.22.24.1        ad 				hrp[3] = stamp[0];
    492  1.22.24.1        ad 			}
    493       1.21  jmcneill 		}
    494        1.1        ad 	} else {
    495        1.1        ad 		uc -= ri->ri_font->firstchar;
    496        1.1        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    497        1.1        ad 		fs = ri->ri_font->stride;
    498        1.8        pk 
    499        1.1        ad 		while (height--) {
    500        1.1        ad 			rp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    501        1.1        ad 			rp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    502        1.1        ad 			rp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    503        1.1        ad 			rp[3] = STAMP_READ(STAMP_SHIFT(fr[1], 0) & STAMP_MASK);
    504       1.21  jmcneill 			if (ri->ri_hwbits) {
    505       1.21  jmcneill 				hrp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    506       1.21  jmcneill 				hrp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    507       1.21  jmcneill 				hrp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    508       1.21  jmcneill 				hrp[3] = STAMP_READ(STAMP_SHIFT(fr[1], 0) & STAMP_MASK);
    509       1.21  jmcneill 			}
    510        1.1        ad 
    511        1.1        ad 			fr += fs;
    512        1.8        pk 			DELTA(rp, ri->ri_stride, int32_t *);
    513       1.21  jmcneill 			if (ri->ri_hwbits)
    514       1.21  jmcneill 				DELTA(hrp, ri->ri_stride, int32_t *);
    515        1.1        ad 		}
    516        1.8        pk 	}
    517        1.1        ad 
    518        1.1        ad 	/* Do underline */
    519        1.7        ad 	if ((attr & 1) != 0) {
    520        1.8        pk 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    521        1.8        pk 		rp[0] = rp[1] = rp[2] = rp[3] = stamp[15];
    522       1.21  jmcneill 		if (ri->ri_hwbits) {
    523       1.21  jmcneill 			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    524  1.22.24.1        ad 			hrp[0] = stamp[15];
    525  1.22.24.1        ad 			hrp[1] = stamp[15];
    526  1.22.24.1        ad 			hrp[2] = stamp[15];
    527  1.22.24.1        ad 			hrp[3] = stamp[15];
    528       1.21  jmcneill 		}
    529        1.8        pk 	}
    530        1.8        pk 
    531        1.1        ad 	stamp_mutex--;
    532        1.1        ad }
    533        1.7        ad #endif /* !RASOPS_SMALL */
    534