rasops4.c revision 1.1.2.2 1 1.1.2.2 bouyer /* $NetBSD: rasops4.c,v 1.1.2.2 2001/02/11 19:16:18 bouyer Exp $ */
2 1.1.2.2 bouyer
3 1.1.2.2 bouyer /*-
4 1.1.2.2 bouyer * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 1.1.2.2 bouyer * All rights reserved.
6 1.1.2.2 bouyer *
7 1.1.2.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.2 bouyer * by Andrew Doran.
9 1.1.2.2 bouyer *
10 1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
11 1.1.2.2 bouyer * modification, are permitted provided that the following conditions
12 1.1.2.2 bouyer * are met:
13 1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer.
15 1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.1.2.2 bouyer * documentation and/or other materials provided with the distribution.
18 1.1.2.2 bouyer * 3. All advertising materials mentioning features or use of this software
19 1.1.2.2 bouyer * must display the following acknowledgement:
20 1.1.2.2 bouyer * This product includes software developed by the NetBSD
21 1.1.2.2 bouyer * Foundation, Inc. and its contributors.
22 1.1.2.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.2.2 bouyer * contributors may be used to endorse or promote products derived
24 1.1.2.2 bouyer * from this software without specific prior written permission.
25 1.1.2.2 bouyer *
26 1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.2.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.2.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.2.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.2.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.2.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.2.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.2.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.2.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.2.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.2.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
37 1.1.2.2 bouyer */
38 1.1.2.2 bouyer
39 1.1.2.2 bouyer #include "opt_rasops.h"
40 1.1.2.2 bouyer #include <sys/cdefs.h>
41 1.1.2.2 bouyer __KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.1.2.2 2001/02/11 19:16:18 bouyer Exp $");
42 1.1.2.2 bouyer
43 1.1.2.2 bouyer #include <sys/types.h>
44 1.1.2.2 bouyer #include <sys/param.h>
45 1.1.2.2 bouyer #include <sys/systm.h>
46 1.1.2.2 bouyer #include <sys/time.h>
47 1.1.2.2 bouyer #include <machine/endian.h>
48 1.1.2.2 bouyer
49 1.1.2.2 bouyer #include <dev/wscons/wsdisplayvar.h>
50 1.1.2.2 bouyer #include <dev/wscons/wsconsio.h>
51 1.1.2.2 bouyer #include <dev/rasops/rasops.h>
52 1.1.2.2 bouyer #include <dev/rasops/rasops_masks.h>
53 1.1.2.2 bouyer
54 1.1.2.2 bouyer static void rasops4_copycols __P((void *, int, int, int, int));
55 1.1.2.2 bouyer static void rasops4_erasecols __P((void *, int, int, int, long));
56 1.1.2.2 bouyer static void rasops4_do_cursor __P((struct rasops_info *));
57 1.1.2.2 bouyer static void rasops4_putchar __P((void *, int, int col, u_int, long));
58 1.1.2.2 bouyer #ifndef RASOPS_SMALL
59 1.1.2.2 bouyer static void rasops4_putchar8 __P((void *, int, int col, u_int, long));
60 1.1.2.2 bouyer static void rasops4_putchar12 __P((void *, int, int col, u_int, long));
61 1.1.2.2 bouyer static void rasops4_putchar16 __P((void *, int, int col, u_int, long));
62 1.1.2.2 bouyer static void rasops4_makestamp __P((struct rasops_info *, long));
63 1.1.2.2 bouyer #endif
64 1.1.2.2 bouyer
65 1.1.2.2 bouyer /*
66 1.1.2.2 bouyer * 4x1 stamp for optimized character blitting
67 1.1.2.2 bouyer */
68 1.1.2.2 bouyer static u_int16_t stamp[16];
69 1.1.2.2 bouyer static long stamp_attr;
70 1.1.2.2 bouyer static int stamp_mutex; /* XXX see note in README */
71 1.1.2.2 bouyer
72 1.1.2.2 bouyer /*
73 1.1.2.2 bouyer * Initialize rasops_info struct for this colordepth.
74 1.1.2.2 bouyer */
75 1.1.2.2 bouyer void
76 1.1.2.2 bouyer rasops4_init(ri)
77 1.1.2.2 bouyer struct rasops_info *ri;
78 1.1.2.2 bouyer {
79 1.1.2.2 bouyer
80 1.1.2.2 bouyer switch (ri->ri_font->fontwidth) {
81 1.1.2.2 bouyer #ifndef RASOPS_SMALL
82 1.1.2.2 bouyer case 8:
83 1.1.2.2 bouyer ri->ri_ops.putchar = rasops4_putchar8;
84 1.1.2.2 bouyer break;
85 1.1.2.2 bouyer case 12:
86 1.1.2.2 bouyer ri->ri_ops.putchar = rasops4_putchar12;
87 1.1.2.2 bouyer break;
88 1.1.2.2 bouyer case 16:
89 1.1.2.2 bouyer ri->ri_ops.putchar = rasops4_putchar16;
90 1.1.2.2 bouyer break;
91 1.1.2.2 bouyer #endif /* !RASOPS_SMALL */
92 1.1.2.2 bouyer default:
93 1.1.2.2 bouyer panic("fontwidth not 8/12/16 or RASOPS_SMALL - fixme!");
94 1.1.2.2 bouyer ri->ri_ops.putchar = rasops4_putchar;
95 1.1.2.2 bouyer break;
96 1.1.2.2 bouyer }
97 1.1.2.2 bouyer
98 1.1.2.2 bouyer if ((ri->ri_font->fontwidth & 1) != 0) {
99 1.1.2.2 bouyer ri->ri_ops.erasecols = rasops4_erasecols;
100 1.1.2.2 bouyer ri->ri_ops.copycols = rasops4_copycols;
101 1.1.2.2 bouyer ri->ri_do_cursor = rasops4_do_cursor;
102 1.1.2.2 bouyer }
103 1.1.2.2 bouyer }
104 1.1.2.2 bouyer
105 1.1.2.2 bouyer #ifdef notyet
106 1.1.2.2 bouyer /*
107 1.1.2.2 bouyer * Paint a single character. This is the generic version, this is ugly.
108 1.1.2.2 bouyer */
109 1.1.2.2 bouyer static void
110 1.1.2.2 bouyer rasops4_putchar(cookie, row, col, uc, attr)
111 1.1.2.2 bouyer void *cookie;
112 1.1.2.2 bouyer int row, col;
113 1.1.2.2 bouyer u_int uc;
114 1.1.2.2 bouyer long attr;
115 1.1.2.2 bouyer {
116 1.1.2.2 bouyer int height, width, fs, rs, fb, bg, fg, lmask, rmask;
117 1.1.2.2 bouyer struct rasops_info *ri;
118 1.1.2.2 bouyer int32_t *rp;
119 1.1.2.2 bouyer u_char *fr;
120 1.1.2.2 bouyer
121 1.1.2.2 bouyer ri = (struct rasops_info *)cookie;
122 1.1.2.2 bouyer
123 1.1.2.2 bouyer #ifdef RASOPS_CLIPPING
124 1.1.2.2 bouyer /* Catches 'row < 0' case too */
125 1.1.2.2 bouyer if ((unsigned)row >= (unsigned)ri->ri_rows)
126 1.1.2.2 bouyer return;
127 1.1.2.2 bouyer
128 1.1.2.2 bouyer if ((unsigned)col >= (unsigned)ri->ri_cols)
129 1.1.2.2 bouyer return;
130 1.1.2.2 bouyer #endif
131 1.1.2.2 bouyer
132 1.1.2.2 bouyer width = ri->ri_font->fontwidth << 1;
133 1.1.2.2 bouyer height = ri->ri_font->fontheight;
134 1.1.2.2 bouyer col *= width;
135 1.1.2.2 bouyer rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
136 1.1.2.2 bouyer col = col & 31;
137 1.1.2.2 bouyer rs = ri->ri_stride;
138 1.1.2.2 bouyer
139 1.1.2.2 bouyer bg = ri->ri_devcmap[(attr >> 16) & 0xf];
140 1.1.2.2 bouyer fg = ri->ri_devcmap[(attr >> 24) & 0xf];
141 1.1.2.2 bouyer
142 1.1.2.2 bouyer /* If fg and bg match this becomes a space character */
143 1.1.2.2 bouyer if (fg == bg || uc == ' ') {
144 1.1.2.2 bouyer uc = (u_int)-1;
145 1.1.2.2 bouyer fr = 0; /* shutup gcc */
146 1.1.2.2 bouyer fs = 0; /* shutup gcc */
147 1.1.2.2 bouyer } else {
148 1.1.2.2 bouyer uc -= ri->ri_font->firstchar;
149 1.1.2.2 bouyer fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
150 1.1.2.2 bouyer fs = ri->ri_font->stride;
151 1.1.2.2 bouyer }
152 1.1.2.2 bouyer
153 1.1.2.2 bouyer /* Single word, one mask */
154 1.1.2.2 bouyer if ((col + width) <= 32) {
155 1.1.2.2 bouyer rmask = rasops_pmask[col][width];
156 1.1.2.2 bouyer lmask = ~rmask;
157 1.1.2.2 bouyer
158 1.1.2.2 bouyer if (uc == (u_int)-1) {
159 1.1.2.2 bouyer bg &= rmask;
160 1.1.2.2 bouyer
161 1.1.2.2 bouyer while (height--) {
162 1.1.2.2 bouyer *rp = (*rp & lmask) | bg;
163 1.1.2.2 bouyer DELTA(rp, rs, int32_t *);
164 1.1.2.2 bouyer }
165 1.1.2.2 bouyer } else {
166 1.1.2.2 bouyer while (height--) {
167 1.1.2.2 bouyer /* get bits, mask */
168 1.1.2.2 bouyer /* compose sl */
169 1.1.2.2 bouyer /* mask sl */
170 1.1.2.2 bouyer /* put word */
171 1.1.2.2 bouyer }
172 1.1.2.2 bouyer }
173 1.1.2.2 bouyer
174 1.1.2.2 bouyer /* Do underline */
175 1.1.2.2 bouyer if (attr & 1) {
176 1.1.2.2 bouyer DELTA(rp, -(ri->ri_stride << 1), int32_t *);
177 1.1.2.2 bouyer *rp = (*rp & lmask) | (fg & rmask);
178 1.1.2.2 bouyer }
179 1.1.2.2 bouyer } else {
180 1.1.2.2 bouyer lmask = ~rasops_lmask[col];
181 1.1.2.2 bouyer rmask = ~rasops_rmask[(col + width) & 31];
182 1.1.2.2 bouyer
183 1.1.2.2 bouyer if (uc == (u_int)-1) {
184 1.1.2.2 bouyer bg = bg & ~lmask;
185 1.1.2.2 bouyer width = bg & ~rmask;
186 1.1.2.2 bouyer
187 1.1.2.2 bouyer while (height--) {
188 1.1.2.2 bouyer rp[0] = (rp[0] & lmask) | bg;
189 1.1.2.2 bouyer rp[1] = (rp[1] & rmask) | width;
190 1.1.2.2 bouyer DELTA(rp, rs, int32_t *);
191 1.1.2.2 bouyer }
192 1.1.2.2 bouyer } else {
193 1.1.2.2 bouyer width = 32 - col;
194 1.1.2.2 bouyer
195 1.1.2.2 bouyer /* NOT fontbits if bg is white */
196 1.1.2.2 bouyer while (height--) {
197 1.1.2.2 bouyer fb = ~(fr[3] | (fr[2] << 8) |
198 1.1.2.2 bouyer (fr[1] << 16) | (fr[0] << 24));
199 1.1.2.2 bouyer
200 1.1.2.2 bouyer rp[0] = (rp[0] & lmask)
201 1.1.2.2 bouyer | MBE((u_int)fb >> col);
202 1.1.2.2 bouyer
203 1.1.2.2 bouyer rp[1] = (rp[1] & rmask)
204 1.1.2.2 bouyer | (MBE((u_int)fb << width) & ~rmask);
205 1.1.2.2 bouyer
206 1.1.2.2 bouyer fr += fs;
207 1.1.2.2 bouyer DELTA(rp, rs, int32_t *);
208 1.1.2.2 bouyer }
209 1.1.2.2 bouyer }
210 1.1.2.2 bouyer
211 1.1.2.2 bouyer /* Do underline */
212 1.1.2.2 bouyer if (attr & 1) {
213 1.1.2.2 bouyer DELTA(rp, -(ri->ri_stride << 1), int32_t *);
214 1.1.2.2 bouyer rp[0] = (rp[0] & lmask) | (fg & ~lmask);
215 1.1.2.2 bouyer rp[1] = (rp[1] & rmask) | (fg & ~rmask);
216 1.1.2.2 bouyer }
217 1.1.2.2 bouyer }
218 1.1.2.2 bouyer }
219 1.1.2.2 bouyer #endif
220 1.1.2.2 bouyer
221 1.1.2.2 bouyer /*
222 1.1.2.2 bouyer * Put a single character. This is the generic version.
223 1.1.2.2 bouyer */
224 1.1.2.2 bouyer static void
225 1.1.2.2 bouyer rasops4_putchar(cookie, row, col, uc, attr)
226 1.1.2.2 bouyer void *cookie;
227 1.1.2.2 bouyer int row, col;
228 1.1.2.2 bouyer u_int uc;
229 1.1.2.2 bouyer long attr;
230 1.1.2.2 bouyer {
231 1.1.2.2 bouyer
232 1.1.2.2 bouyer /* XXX punt */
233 1.1.2.2 bouyer }
234 1.1.2.2 bouyer
235 1.1.2.2 bouyer #ifndef RASOPS_SMALL
236 1.1.2.2 bouyer /*
237 1.1.2.2 bouyer * Recompute the blitting stamp.
238 1.1.2.2 bouyer */
239 1.1.2.2 bouyer static void
240 1.1.2.2 bouyer rasops4_makestamp(ri, attr)
241 1.1.2.2 bouyer struct rasops_info *ri;
242 1.1.2.2 bouyer long attr;
243 1.1.2.2 bouyer {
244 1.1.2.2 bouyer int i, fg, bg;
245 1.1.2.2 bouyer
246 1.1.2.2 bouyer fg = ri->ri_devcmap[(attr >> 24) & 0xf] & 0xf;
247 1.1.2.2 bouyer bg = ri->ri_devcmap[(attr >> 16) & 0xf] & 0xf;
248 1.1.2.2 bouyer stamp_attr = attr;
249 1.1.2.2 bouyer
250 1.1.2.2 bouyer for (i = 0; i < 16; i++) {
251 1.1.2.2 bouyer stamp[i] = (i & 1 ? fg : bg) << 8;
252 1.1.2.2 bouyer stamp[i] |= (i & 2 ? fg : bg) << 12;
253 1.1.2.2 bouyer stamp[i] |= (i & 4 ? fg : bg) << 0;
254 1.1.2.2 bouyer stamp[i] |= (i & 8 ? fg : bg) << 4;
255 1.1.2.2 bouyer }
256 1.1.2.2 bouyer }
257 1.1.2.2 bouyer
258 1.1.2.2 bouyer /*
259 1.1.2.2 bouyer * Put a single character. This is for 8-pixel wide fonts.
260 1.1.2.2 bouyer */
261 1.1.2.2 bouyer static void
262 1.1.2.2 bouyer rasops4_putchar8(cookie, row, col, uc, attr)
263 1.1.2.2 bouyer void *cookie;
264 1.1.2.2 bouyer int row, col;
265 1.1.2.2 bouyer u_int uc;
266 1.1.2.2 bouyer long attr;
267 1.1.2.2 bouyer {
268 1.1.2.2 bouyer struct rasops_info *ri;
269 1.1.2.2 bouyer int height, fs, rs;
270 1.1.2.2 bouyer u_char *fr;
271 1.1.2.2 bouyer u_int16_t *rp;
272 1.1.2.2 bouyer
273 1.1.2.2 bouyer /* Can't risk remaking the stamp if it's already in use */
274 1.1.2.2 bouyer if (stamp_mutex++) {
275 1.1.2.2 bouyer stamp_mutex--;
276 1.1.2.2 bouyer rasops4_putchar(cookie, row, col, uc, attr);
277 1.1.2.2 bouyer return;
278 1.1.2.2 bouyer }
279 1.1.2.2 bouyer
280 1.1.2.2 bouyer ri = (struct rasops_info *)cookie;
281 1.1.2.2 bouyer
282 1.1.2.2 bouyer #ifdef RASOPS_CLIPPING
283 1.1.2.2 bouyer /* Catches 'row < 0' case too */
284 1.1.2.2 bouyer if ((unsigned)row >= (unsigned)ri->ri_rows) {
285 1.1.2.2 bouyer stamp_mutex--;
286 1.1.2.2 bouyer return;
287 1.1.2.2 bouyer }
288 1.1.2.2 bouyer
289 1.1.2.2 bouyer if ((unsigned)col >= (unsigned)ri->ri_cols) {
290 1.1.2.2 bouyer stamp_mutex--;
291 1.1.2.2 bouyer return;
292 1.1.2.2 bouyer }
293 1.1.2.2 bouyer #endif
294 1.1.2.2 bouyer
295 1.1.2.2 bouyer rp = (u_int16_t *)(ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale);
296 1.1.2.2 bouyer height = ri->ri_font->fontheight;
297 1.1.2.2 bouyer rs = ri->ri_stride / sizeof(*rp);
298 1.1.2.2 bouyer
299 1.1.2.2 bouyer /* Recompute stamp? */
300 1.1.2.2 bouyer if (attr != stamp_attr)
301 1.1.2.2 bouyer rasops4_makestamp(ri, attr);
302 1.1.2.2 bouyer
303 1.1.2.2 bouyer if (uc == ' ') {
304 1.1.2.2 bouyer u_int16_t c = stamp[0];
305 1.1.2.2 bouyer while (height--) {
306 1.1.2.2 bouyer rp[0] = c;
307 1.1.2.2 bouyer rp[1] = c;
308 1.1.2.2 bouyer rp += rs;
309 1.1.2.2 bouyer }
310 1.1.2.2 bouyer } else {
311 1.1.2.2 bouyer uc -= ri->ri_font->firstchar;
312 1.1.2.2 bouyer fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
313 1.1.2.2 bouyer fs = ri->ri_font->stride;
314 1.1.2.2 bouyer
315 1.1.2.2 bouyer while (height--) {
316 1.1.2.2 bouyer rp[0] = stamp[(*fr >> 4) & 0xf];
317 1.1.2.2 bouyer rp[1] = stamp[*fr & 0xf];
318 1.1.2.2 bouyer fr += fs;
319 1.1.2.2 bouyer rp += rs;
320 1.1.2.2 bouyer }
321 1.1.2.2 bouyer }
322 1.1.2.2 bouyer
323 1.1.2.2 bouyer /* Do underline */
324 1.1.2.2 bouyer if ((attr & 1) != 0) {
325 1.1.2.2 bouyer rp -= (rs << 1);
326 1.1.2.2 bouyer rp[0] = stamp[15];
327 1.1.2.2 bouyer rp[1] = stamp[15];
328 1.1.2.2 bouyer }
329 1.1.2.2 bouyer
330 1.1.2.2 bouyer stamp_mutex--;
331 1.1.2.2 bouyer }
332 1.1.2.2 bouyer
333 1.1.2.2 bouyer /*
334 1.1.2.2 bouyer * Put a single character. This is for 12-pixel wide fonts.
335 1.1.2.2 bouyer */
336 1.1.2.2 bouyer static void
337 1.1.2.2 bouyer rasops4_putchar12(cookie, row, col, uc, attr)
338 1.1.2.2 bouyer void *cookie;
339 1.1.2.2 bouyer int row, col;
340 1.1.2.2 bouyer u_int uc;
341 1.1.2.2 bouyer long attr;
342 1.1.2.2 bouyer {
343 1.1.2.2 bouyer struct rasops_info *ri;
344 1.1.2.2 bouyer int height, fs, rs;
345 1.1.2.2 bouyer u_char *fr;
346 1.1.2.2 bouyer u_int16_t *rp;
347 1.1.2.2 bouyer
348 1.1.2.2 bouyer /* Can't risk remaking the stamp if it's already in use */
349 1.1.2.2 bouyer if (stamp_mutex++) {
350 1.1.2.2 bouyer stamp_mutex--;
351 1.1.2.2 bouyer rasops4_putchar(cookie, row, col, uc, attr);
352 1.1.2.2 bouyer return;
353 1.1.2.2 bouyer }
354 1.1.2.2 bouyer
355 1.1.2.2 bouyer ri = (struct rasops_info *)cookie;
356 1.1.2.2 bouyer
357 1.1.2.2 bouyer #ifdef RASOPS_CLIPPING
358 1.1.2.2 bouyer /* Catches 'row < 0' case too */
359 1.1.2.2 bouyer if ((unsigned)row >= (unsigned)ri->ri_rows) {
360 1.1.2.2 bouyer stamp_mutex--;
361 1.1.2.2 bouyer return;
362 1.1.2.2 bouyer }
363 1.1.2.2 bouyer
364 1.1.2.2 bouyer if ((unsigned)col >= (unsigned)ri->ri_cols) {
365 1.1.2.2 bouyer stamp_mutex--;
366 1.1.2.2 bouyer return;
367 1.1.2.2 bouyer }
368 1.1.2.2 bouyer #endif
369 1.1.2.2 bouyer
370 1.1.2.2 bouyer rp = (u_int16_t *)(ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale);
371 1.1.2.2 bouyer height = ri->ri_font->fontheight;
372 1.1.2.2 bouyer rs = ri->ri_stride / sizeof(*rp);
373 1.1.2.2 bouyer
374 1.1.2.2 bouyer /* Recompute stamp? */
375 1.1.2.2 bouyer if (attr != stamp_attr)
376 1.1.2.2 bouyer rasops4_makestamp(ri, attr);
377 1.1.2.2 bouyer
378 1.1.2.2 bouyer if (uc == ' ') {
379 1.1.2.2 bouyer u_int16_t c = stamp[0];
380 1.1.2.2 bouyer while (height--) {
381 1.1.2.2 bouyer rp[0] = c;
382 1.1.2.2 bouyer rp[1] = c;
383 1.1.2.2 bouyer rp[2] = c;
384 1.1.2.2 bouyer rp += rs;
385 1.1.2.2 bouyer }
386 1.1.2.2 bouyer } else {
387 1.1.2.2 bouyer uc -= ri->ri_font->firstchar;
388 1.1.2.2 bouyer fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
389 1.1.2.2 bouyer fs = ri->ri_font->stride;
390 1.1.2.2 bouyer
391 1.1.2.2 bouyer while (height--) {
392 1.1.2.2 bouyer rp[0] = stamp[(fr[0] >> 4) & 0xf];
393 1.1.2.2 bouyer rp[1] = stamp[fr[0] & 0xf];
394 1.1.2.2 bouyer rp[2] = stamp[(fr[1] >> 4) & 0xf];
395 1.1.2.2 bouyer fr += fs;
396 1.1.2.2 bouyer rp += rs;
397 1.1.2.2 bouyer }
398 1.1.2.2 bouyer }
399 1.1.2.2 bouyer
400 1.1.2.2 bouyer /* Do underline */
401 1.1.2.2 bouyer if ((attr & 1) != 0) {
402 1.1.2.2 bouyer rp -= (rs << 1);
403 1.1.2.2 bouyer rp[0] = stamp[15];
404 1.1.2.2 bouyer rp[1] = stamp[15];
405 1.1.2.2 bouyer rp[2] = stamp[15];
406 1.1.2.2 bouyer }
407 1.1.2.2 bouyer
408 1.1.2.2 bouyer stamp_mutex--;
409 1.1.2.2 bouyer }
410 1.1.2.2 bouyer
411 1.1.2.2 bouyer /*
412 1.1.2.2 bouyer * Put a single character. This is for 16-pixel wide fonts.
413 1.1.2.2 bouyer */
414 1.1.2.2 bouyer static void
415 1.1.2.2 bouyer rasops4_putchar16(cookie, row, col, uc, attr)
416 1.1.2.2 bouyer void *cookie;
417 1.1.2.2 bouyer int row, col;
418 1.1.2.2 bouyer u_int uc;
419 1.1.2.2 bouyer long attr;
420 1.1.2.2 bouyer {
421 1.1.2.2 bouyer struct rasops_info *ri;
422 1.1.2.2 bouyer int height, fs, rs;
423 1.1.2.2 bouyer u_char *fr;
424 1.1.2.2 bouyer u_int16_t *rp;
425 1.1.2.2 bouyer
426 1.1.2.2 bouyer /* Can't risk remaking the stamp if it's already in use */
427 1.1.2.2 bouyer if (stamp_mutex++) {
428 1.1.2.2 bouyer stamp_mutex--;
429 1.1.2.2 bouyer rasops4_putchar(cookie, row, col, uc, attr);
430 1.1.2.2 bouyer return;
431 1.1.2.2 bouyer }
432 1.1.2.2 bouyer
433 1.1.2.2 bouyer ri = (struct rasops_info *)cookie;
434 1.1.2.2 bouyer
435 1.1.2.2 bouyer #ifdef RASOPS_CLIPPING
436 1.1.2.2 bouyer /* Catches 'row < 0' case too */
437 1.1.2.2 bouyer if ((unsigned)row >= (unsigned)ri->ri_rows) {
438 1.1.2.2 bouyer stamp_mutex--;
439 1.1.2.2 bouyer return;
440 1.1.2.2 bouyer }
441 1.1.2.2 bouyer
442 1.1.2.2 bouyer if ((unsigned)col >= (unsigned)ri->ri_cols) {
443 1.1.2.2 bouyer stamp_mutex--;
444 1.1.2.2 bouyer return;
445 1.1.2.2 bouyer }
446 1.1.2.2 bouyer #endif
447 1.1.2.2 bouyer
448 1.1.2.2 bouyer rp = (u_int16_t *)(ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale);
449 1.1.2.2 bouyer height = ri->ri_font->fontheight;
450 1.1.2.2 bouyer rs = ri->ri_stride / sizeof(*rp);
451 1.1.2.2 bouyer
452 1.1.2.2 bouyer /* Recompute stamp? */
453 1.1.2.2 bouyer if (attr != stamp_attr)
454 1.1.2.2 bouyer rasops4_makestamp(ri, attr);
455 1.1.2.2 bouyer
456 1.1.2.2 bouyer if (uc == ' ') {
457 1.1.2.2 bouyer u_int16_t c = stamp[0];
458 1.1.2.2 bouyer while (height--) {
459 1.1.2.2 bouyer rp[0] = c;
460 1.1.2.2 bouyer rp[1] = c;
461 1.1.2.2 bouyer rp[2] = c;
462 1.1.2.2 bouyer rp[3] = c;
463 1.1.2.2 bouyer rp += rs;
464 1.1.2.2 bouyer }
465 1.1.2.2 bouyer } else {
466 1.1.2.2 bouyer uc -= ri->ri_font->firstchar;
467 1.1.2.2 bouyer fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
468 1.1.2.2 bouyer fs = ri->ri_font->stride;
469 1.1.2.2 bouyer
470 1.1.2.2 bouyer while (height--) {
471 1.1.2.2 bouyer rp[0] = stamp[(fr[0] >> 4) & 0xf];
472 1.1.2.2 bouyer rp[1] = stamp[fr[0] & 0xf];
473 1.1.2.2 bouyer rp[2] = stamp[(fr[1] >> 4) & 0xf];
474 1.1.2.2 bouyer rp[3] = stamp[fr[1] & 0xf];
475 1.1.2.2 bouyer fr += fs;
476 1.1.2.2 bouyer rp += rs;
477 1.1.2.2 bouyer }
478 1.1.2.2 bouyer }
479 1.1.2.2 bouyer
480 1.1.2.2 bouyer /* Do underline */
481 1.1.2.2 bouyer if ((attr & 1) != 0) {
482 1.1.2.2 bouyer rp -= (rs << 1);
483 1.1.2.2 bouyer rp[0] = stamp[15];
484 1.1.2.2 bouyer rp[1] = stamp[15];
485 1.1.2.2 bouyer rp[2] = stamp[15];
486 1.1.2.2 bouyer rp[3] = stamp[15];
487 1.1.2.2 bouyer }
488 1.1.2.2 bouyer
489 1.1.2.2 bouyer stamp_mutex--;
490 1.1.2.2 bouyer }
491 1.1.2.2 bouyer #endif /* !RASOPS_SMALL */
492 1.1.2.2 bouyer
493 1.1.2.2 bouyer /*
494 1.1.2.2 bouyer * Grab routines common to depths where (bpp < 8)
495 1.1.2.2 bouyer */
496 1.1.2.2 bouyer #define NAME(ident) rasops4_##ident
497 1.1.2.2 bouyer #define PIXEL_SHIFT 3
498 1.1.2.2 bouyer
499 1.1.2.2 bouyer #include <dev/rasops/rasops_bitops.h>
500