rasops1.c revision 1.1 1 1.1 ad /* $NetBSD: rasops1.c,v 1.1 1999/04/13 00:17:59 ad Exp $ */
2 1.1 ad
3 1.1 ad /*-
4 1.1 ad * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 1.1 ad * All rights reserved.
6 1.1 ad *
7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1 ad * by Andy Doran <ad (at) NetBSD.org>.
9 1.1 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.1 ad * 3. All advertising materials mentioning features or use of this software
19 1.1 ad * must display the following acknowledgement:
20 1.1 ad * This product includes software developed by the NetBSD
21 1.1 ad * Foundation, Inc. and its contributors.
22 1.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 ad * contributors may be used to endorse or promote products derived
24 1.1 ad * from this software without specific prior written permission.
25 1.1 ad *
26 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1 ad */
38 1.1 ad #include "opt_rasops.h"
39 1.1 ad #ifdef RASOPS1
40 1.1 ad
41 1.1 ad #include <sys/cdefs.h>
42 1.1 ad __KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.1 1999/04/13 00:17:59 ad Exp $");
43 1.1 ad
44 1.1 ad #include <sys/types.h>
45 1.1 ad #include <sys/param.h>
46 1.1 ad #include <sys/systm.h>
47 1.1 ad #include <sys/time.h>
48 1.1 ad #include <machine/endian.h>
49 1.1 ad
50 1.1 ad #include <dev/wscons/wsdisplayvar.h>
51 1.1 ad #include <dev/rasops/rasops.h>
52 1.1 ad
53 1.1 ad static void rasops1_putchar __P((void *, int, int col, u_int, long));
54 1.1 ad static void rasops1_putchar8 __P((void *, int, int col, u_int, long));
55 1.1 ad static void rasops1_putchar16 __P((void *, int, int col, u_int, long));
56 1.1 ad static void rasops1_copycols __P((void *, int, int, int, int));
57 1.1 ad static void rasops1_erasecols __P((void *, int, int, int));
58 1.1 ad static void rasops1_erasecols8 __P((void *, int, int, int));
59 1.1 ad static void rasops1_eraserows __P((void *, int, int));
60 1.1 ad static int32_t rasops1_fg_color __P((long));
61 1.1 ad static int32_t rasops1_bg_color __P((long));
62 1.1 ad static void rasops1_do_cursor __P((struct rasops_info *));
63 1.1 ad static void rasops1_do_cursor8 __P((struct rasops_info *));
64 1.1 ad
65 1.1 ad void rasops1_init __P((struct rasops_info *ri));
66 1.1 ad
67 1.1 ad #if BYTE_ORDER == LITTLE_ENDIAN
68 1.1 ad static u_int32_t rightmask[32] = {
69 1.1 ad #else
70 1.1 ad static u_int32_t leftmask[32] = {
71 1.1 ad #endif
72 1.1 ad 0x00000000, 0x80000000, 0xc0000000, 0xe0000000,
73 1.1 ad 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000,
74 1.1 ad 0xff000000, 0xff800000, 0xffc00000, 0xffe00000,
75 1.1 ad 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000,
76 1.1 ad 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000,
77 1.1 ad 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
78 1.1 ad 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
79 1.1 ad 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe,
80 1.1 ad };
81 1.1 ad
82 1.1 ad #if BYTE_ORDER == LITTLE_ENDIAN
83 1.1 ad static u_int32_t leftmask[32] = {
84 1.1 ad #else
85 1.1 ad static u_int32_t rightmask[32] = {
86 1.1 ad #endif
87 1.1 ad 0x00000000, 0x00000001, 0x00000003, 0x00000007,
88 1.1 ad 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
89 1.1 ad 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
90 1.1 ad 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
91 1.1 ad 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
92 1.1 ad 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
93 1.1 ad 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
94 1.1 ad 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
95 1.1 ad };
96 1.1 ad
97 1.1 ad
98 1.1 ad /*
99 1.1 ad * Initalize rasops_info struct for this colordepth.
100 1.1 ad */
101 1.1 ad void
102 1.1 ad rasops1_init(ri)
103 1.1 ad struct rasops_info *ri;
104 1.1 ad {
105 1.1 ad
106 1.1 ad switch (ri->ri_font->fontwidth) {
107 1.1 ad case 8:
108 1.1 ad ri->ri_ops.putchar = rasops1_putchar8;
109 1.1 ad break;
110 1.1 ad case 16:
111 1.1 ad ri->ri_ops.putchar = rasops1_putchar16;
112 1.1 ad break;
113 1.1 ad default:
114 1.1 ad /*
115 1.1 ad * XXX we don't support anything other than 8 and 16 pel
116 1.1 ad * wide fonts yet. rasops1_copycols needs to be finished, the
117 1.1 ad * other routines will need to be checked.
118 1.1 ad */
119 1.1 ad panic("rasops1_init: not completed - see this location in src for details");
120 1.1 ad ri->ri_ops.putchar = rasops1_putchar;
121 1.1 ad break;
122 1.1 ad }
123 1.1 ad
124 1.1 ad if (ri->ri_font->fontwidth & 7) {
125 1.1 ad ri->ri_ops.erasecols = rasops1_erasecols;
126 1.1 ad ri->ri_ops.copycols = rasops1_copycols;
127 1.1 ad ri->ri_do_cursor = rasops1_do_cursor;
128 1.1 ad } else {
129 1.1 ad ri->ri_ops.erasecols = rasops1_erasecols8;
130 1.1 ad /* use default copycols */
131 1.1 ad ri->ri_do_cursor = rasops1_do_cursor8;
132 1.1 ad }
133 1.1 ad
134 1.1 ad ri->ri_ops.eraserows = rasops1_eraserows;
135 1.1 ad }
136 1.1 ad
137 1.1 ad
138 1.1 ad /*
139 1.1 ad * Get foreground color from attribute and copy across all 4 bytes
140 1.1 ad * in a int32_t.
141 1.1 ad */
142 1.1 ad static __inline__ int32_t
143 1.1 ad rasops1_fg_color(long attr)
144 1.1 ad {
145 1.1 ad
146 1.1 ad return (attr & 0x0f000000) ? 0xffffffff : 0;
147 1.1 ad }
148 1.1 ad
149 1.1 ad
150 1.1 ad /*
151 1.1 ad * Get background color from attribute and copy across all 4 bytes
152 1.1 ad * in a int32_t.
153 1.1 ad */
154 1.1 ad static __inline__ int32_t
155 1.1 ad rasops1_bg_color(long attr)
156 1.1 ad {
157 1.1 ad
158 1.1 ad return (attr & 0x000f0000) ? 0xffffffff : 0;
159 1.1 ad }
160 1.1 ad
161 1.1 ad
162 1.1 ad /*
163 1.1 ad * Paint a single character. This is the generic version.
164 1.1 ad */
165 1.1 ad static void
166 1.1 ad rasops1_putchar(cookie, row, col, uc, attr)
167 1.1 ad void *cookie;
168 1.1 ad int row, col;
169 1.1 ad u_int uc;
170 1.1 ad long attr;
171 1.1 ad {
172 1.1 ad
173 1.1 ad /* XXX i need implemention */
174 1.1 ad }
175 1.1 ad
176 1.1 ad
177 1.1 ad /*
178 1.1 ad * Paint a single character. This is for 8-pixel wide fonts.
179 1.1 ad */
180 1.1 ad static void
181 1.1 ad rasops1_putchar8(cookie, row, col, uc, attr)
182 1.1 ad void *cookie;
183 1.1 ad int row, col;
184 1.1 ad u_int uc;
185 1.1 ad long attr;
186 1.1 ad {
187 1.1 ad int height, fs, rs, bg, fg;
188 1.1 ad struct rasops_info *ri;
189 1.1 ad u_char *fr, *rp;
190 1.1 ad
191 1.1 ad ri = (struct rasops_info *)cookie;
192 1.1 ad
193 1.1 ad #ifdef RASOPS_CLIPPING
194 1.1 ad if (row < 0 || row >= ri->ri_rows)
195 1.1 ad return;
196 1.1 ad
197 1.1 ad if (col < 0 || col >= ri->ri_cols)
198 1.1 ad return;
199 1.1 ad #endif
200 1.1 ad
201 1.1 ad rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
202 1.1 ad height = ri->ri_font->fontheight;
203 1.1 ad rs = ri->ri_stride;
204 1.1 ad
205 1.1 ad bg = (attr & 0x000f0000) ? 0xff : 0;
206 1.1 ad fg = (attr & 0x0f000000) ? 0xff : 0;
207 1.1 ad
208 1.1 ad /* If fg and bg match this becomes a space character */
209 1.1 ad if (fg == bg || uc == ' ') {
210 1.1 ad while (height--) {
211 1.1 ad *rp = bg;
212 1.1 ad rp += rs;
213 1.1 ad }
214 1.1 ad } else {
215 1.1 ad uc -= ri->ri_font->firstchar;
216 1.1 ad fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
217 1.1 ad fs = ri->ri_font->stride;
218 1.1 ad
219 1.1 ad /* NOT fontbits if bg is white */
220 1.1 ad if (bg) {
221 1.1 ad while (height--) {
222 1.1 ad *rp = ~*fr;
223 1.1 ad fr += fs;
224 1.1 ad rp += rs;
225 1.1 ad }
226 1.1 ad } else {
227 1.1 ad while (height--) {
228 1.1 ad *rp = *fr;
229 1.1 ad fr += fs;
230 1.1 ad rp += rs;
231 1.1 ad }
232 1.1 ad }
233 1.1 ad }
234 1.1 ad
235 1.1 ad /* Do underline */
236 1.1 ad if (attr & 1)
237 1.1 ad rp[-(ri->ri_stride << 1)] = fg;
238 1.1 ad }
239 1.1 ad
240 1.1 ad
241 1.1 ad /*
242 1.1 ad * Paint a single character. This is for 16-pixel wide fonts.
243 1.1 ad */
244 1.1 ad static void
245 1.1 ad rasops1_putchar16(cookie, row, col, uc, attr)
246 1.1 ad void *cookie;
247 1.1 ad int row, col;
248 1.1 ad u_int uc;
249 1.1 ad long attr;
250 1.1 ad {
251 1.1 ad int height, fs, rs, bg, fg;
252 1.1 ad struct rasops_info *ri;
253 1.1 ad u_char *fr, *rp;
254 1.1 ad
255 1.1 ad ri = (struct rasops_info *)cookie;
256 1.1 ad
257 1.1 ad #ifdef RASOPS_CLIPPING
258 1.1 ad if (row < 0 || row >= ri->ri_rows)
259 1.1 ad return;
260 1.1 ad
261 1.1 ad if (col < 0 || col >= ri->ri_cols)
262 1.1 ad return;
263 1.1 ad #endif
264 1.1 ad
265 1.1 ad rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
266 1.1 ad height = ri->ri_font->fontheight;
267 1.1 ad rs = ri->ri_stride;
268 1.1 ad
269 1.1 ad bg = (attr & 0x000f0000) ? 0xffff : 0;
270 1.1 ad fg = (attr & 0x0f000000) ? 0xffff : 0;
271 1.1 ad
272 1.1 ad /* If fg and bg match this becomes a space character */
273 1.1 ad if (fg == bg || uc == ' ') {
274 1.1 ad while (height--) {
275 1.1 ad *(int16_t *)rp = bg;
276 1.1 ad rp += rs;
277 1.1 ad }
278 1.1 ad } else {
279 1.1 ad uc -= ri->ri_font->firstchar;
280 1.1 ad fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
281 1.1 ad fs = ri->ri_font->stride;
282 1.1 ad
283 1.1 ad /* NOT fontbits if bg is white */
284 1.1 ad if (bg) {
285 1.1 ad while (height--) {
286 1.1 ad rp[0] = ~fr[0];
287 1.1 ad rp[1] = ~fr[1];
288 1.1 ad fr += fs;
289 1.1 ad rp += rs;
290 1.1 ad }
291 1.1 ad } else {
292 1.1 ad while (height--) {
293 1.1 ad rp[0] = fr[0];
294 1.1 ad rp[1] = fr[1];
295 1.1 ad fr += fs;
296 1.1 ad rp += rs;
297 1.1 ad }
298 1.1 ad }
299 1.1 ad }
300 1.1 ad
301 1.1 ad /* Do underline */
302 1.1 ad if (attr & 1)
303 1.1 ad *(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
304 1.1 ad }
305 1.1 ad
306 1.1 ad
307 1.1 ad /*
308 1.1 ad * Erase columns.
309 1.1 ad */
310 1.1 ad static void
311 1.1 ad rasops1_erasecols(cookie, row, col, num, attr)
312 1.1 ad void *cookie;
313 1.1 ad int row, num;
314 1.1 ad long attr;
315 1.1 ad {
316 1.1 ad int32_t *dp, *rp, lmask, rmask, lclr, rclr, clr;
317 1.1 ad struct rasops_info *ri;
318 1.1 ad int nint, height, cnt;
319 1.1 ad
320 1.1 ad ri = (struct rasops_info *)cookie;
321 1.1 ad
322 1.1 ad #ifdef RASOPS_CLIPPING
323 1.1 ad if (row < 0 || row > ri->ri_rows)
324 1.1 ad return;
325 1.1 ad
326 1.1 ad if (col < 0) {
327 1.1 ad num += col;
328 1.1 ad col = 0;
329 1.1 ad }
330 1.1 ad
331 1.1 ad if ((col + num) > ri->ri_cols)
332 1.1 ad num = ri->ri_cols - col;
333 1.1 ad
334 1.1 ad if (num <= 0)
335 1.1 ad return;
336 1.1 ad #endif
337 1.1 ad col *= ri->ri_fontwidth;
338 1.1 ad num *= ri->ri_fontwidth;
339 1.1 ad
340 1.1 ad /*
341 1.1 ad * lmask: mask for leftmost int32
342 1.1 ad * rmask: mask for rightmost int32
343 1.1 ad * nint: number of full int32s
344 1.1 ad */
345 1.1 ad lmask = leftmask[col & 31];
346 1.1 ad rmask = rightmask[(col + num) & 31];
347 1.1 ad nint = ((col + num) & ~31) - ((col + 31) & ~31) >> 5;
348 1.1 ad
349 1.1 ad /* Merge both masks if the span is encapsulated within one int32 */
350 1.1 ad if (col & ~31 == (col + num) & ~31) {
351 1.1 ad lmask &= rmask;
352 1.1 ad rmask = 0;
353 1.1 ad }
354 1.1 ad
355 1.1 ad clr = rasops1_bg_color(attr);
356 1.1 ad lclr = clr & lmask;
357 1.1 ad rclr = clr & rmask;
358 1.1 ad lmask = ~lmask;
359 1.1 ad rmask = ~rmask;
360 1.1 ad height = ri->ri_fontheight;
361 1.1 ad rp = ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3);
362 1.1 ad
363 1.1 ad while (height--) {
364 1.1 ad dp = rp;
365 1.1 ad DELTA(rp, ri->ri_stride, int32_t *);
366 1.1 ad
367 1.1 ad if (lmask != 0xffffffffU)
368 1.1 ad *dp++ = (*dp & lmask) | lclr;
369 1.1 ad
370 1.1 ad for (cnt = nint; cnt; cnt--)
371 1.1 ad *dp++ = clr;
372 1.1 ad
373 1.1 ad if (rmask != 0xffffffffU)
374 1.1 ad *dp = (*dp & rmask) | rclr;
375 1.1 ad }
376 1.1 ad }
377 1.1 ad
378 1.1 ad
379 1.1 ad /*
380 1.1 ad * Erase columns for fonts that are a multiple of 8 pels in width.
381 1.1 ad */
382 1.1 ad static void
383 1.1 ad rasops1_erasecols8(cookie, row, col, num, attr)
384 1.1 ad void *cookie;
385 1.1 ad int row, col, num;
386 1.1 ad long attr;
387 1.1 ad {
388 1.1 ad struct rasops_info *ri;
389 1.1 ad int32_t *dst;
390 1.1 ad u_char *dstb, *rp;
391 1.1 ad int clr, height, cnt, slop1, slop2;
392 1.1 ad
393 1.1 ad ri = (struct rasops_info *)cookie;
394 1.1 ad
395 1.1 ad #ifdef RASOPS_CLIPPING
396 1.1 ad if (row < 0 || row >= ri->ri_rows)
397 1.1 ad return;
398 1.1 ad
399 1.1 ad if (col < 0) {
400 1.1 ad num += col;
401 1.1 ad col = 0;
402 1.1 ad }
403 1.1 ad
404 1.1 ad if ((col + num) > ri->ri_cols)
405 1.1 ad num = ri->ri_cols - col;
406 1.1 ad
407 1.1 ad if (num <= 0)
408 1.1 ad return;
409 1.1 ad #endif
410 1.1 ad
411 1.1 ad num = num * ri->ri_xscale;
412 1.1 ad rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
413 1.1 ad clr = rasops1_bg_color(attr);
414 1.1 ad height = ri->ri_font->fontheight;
415 1.1 ad
416 1.1 ad slop1 = (int)rp & 3;
417 1.1 ad slop2 = (num - slop1) & 3;
418 1.1 ad num = (num - slop1 - slop2) >> 2;
419 1.1 ad
420 1.1 ad while (height--) {
421 1.1 ad dstb = rp;
422 1.1 ad rp += ri->ri_stride;
423 1.1 ad
424 1.1 ad /* Align span to 4 bytes */
425 1.1 ad for (cnt = slop1; cnt; cnt--)
426 1.1 ad *dstb++ = (u_char)clr;
427 1.1 ad
428 1.1 ad dst = (int32_t *)dstb;
429 1.1 ad
430 1.1 ad /* Write 4 bytes per loop */
431 1.1 ad for (cnt = num; cnt; cnt--)
432 1.1 ad *dst++ = clr;
433 1.1 ad
434 1.1 ad /* Write unaligned trailing slop */
435 1.1 ad if (slop2 == 0)
436 1.1 ad continue;
437 1.1 ad
438 1.1 ad dstb = (u_char *)dst;
439 1.1 ad
440 1.1 ad for (cnt = slop2; cnt; cnt--)
441 1.1 ad *dstb++ = (u_char)clr;
442 1.1 ad }
443 1.1 ad }
444 1.1 ad
445 1.1 ad
446 1.1 ad /*
447 1.1 ad * Actually paint the cursor.
448 1.1 ad */
449 1.1 ad static void
450 1.1 ad rasops1_do_cursor(ri)
451 1.1 ad struct rasops_info *ri;
452 1.1 ad {
453 1.1 ad int32_t *dp, *rp, lmask, rmask;
454 1.1 ad int height, row, col;
455 1.1 ad
456 1.1 ad row = ri->ri_crow;
457 1.1 ad col = ri->ri_ccol * ri->ri_fontwidth;
458 1.1 ad
459 1.1 ad /*
460 1.1 ad * lmask: mask for leftmost int32
461 1.1 ad * rmask: mask for rightmost int32
462 1.1 ad */
463 1.1 ad lmask = leftmask[col & 31];
464 1.1 ad rmask = rightmask[(col + ri->ri_fontwidth) & 31];
465 1.1 ad
466 1.1 ad /* Merge both masks if the span is encapsulated within one int32 */
467 1.1 ad if (col & ~31 == (col + ri->ri_fontwidth) & ~31) {
468 1.1 ad lmask &= rmask;
469 1.1 ad rmask = 0;
470 1.1 ad }
471 1.1 ad
472 1.1 ad lmask = ~lmask;
473 1.1 ad rmask = ~rmask;
474 1.1 ad height = ri->ri_fontheight;
475 1.1 ad rp = ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3);
476 1.1 ad
477 1.1 ad while (height--) {
478 1.1 ad dp = rp;
479 1.1 ad DELTA(rp, ri->ri_stride, int32_t *);
480 1.1 ad
481 1.1 ad *dp++ = ((*dp & lmask) ^ lmask) | (*dp & ~lmask);
482 1.1 ad
483 1.1 ad if (rmask != 0xffffffffU)
484 1.1 ad *dp = ((*dp & rmask) ^ rmask) | (*dp & ~rmask);
485 1.1 ad }
486 1.1 ad }
487 1.1 ad
488 1.1 ad
489 1.1 ad /*
490 1.1 ad * Paint cursors that are a multiple of 8 pels in size.
491 1.1 ad */
492 1.1 ad static void
493 1.1 ad rasops1_do_cursor8(ri)
494 1.1 ad struct rasops_info *ri;
495 1.1 ad {
496 1.1 ad int width, height, cnt;
497 1.1 ad u_char *dp, *rp;
498 1.1 ad
499 1.1 ad height = ri->ri_fontheight;
500 1.1 ad width = ri->ri_fontwidth >> 3;
501 1.1 ad rp = ri->ri_bits + ri->ri_crow * ri->ri_yscale +
502 1.1 ad ri->ri_ccol * ri->ri_xscale;
503 1.1 ad
504 1.1 ad while (height--) {
505 1.1 ad dp = rp;
506 1.1 ad rp += ri->ri_stride;
507 1.1 ad
508 1.1 ad for (cnt = width; cnt; cnt--)
509 1.1 ad *dp++ ^= 0xff;
510 1.1 ad }
511 1.1 ad }
512 1.1 ad
513 1.1 ad
514 1.1 ad /*
515 1.1 ad * Erase rows.
516 1.1 ad */
517 1.1 ad static void
518 1.1 ad rasops1_eraserows(cookie, row, num, attr)
519 1.1 ad void *cookie;
520 1.1 ad int row, num;
521 1.1 ad long attr;
522 1.1 ad {
523 1.1 ad struct rasops_info *ri;
524 1.1 ad int32_t *dp, clr;
525 1.1 ad int n8, n1, cnt;
526 1.1 ad
527 1.1 ad ri = (struct rasops_info *)cookie;
528 1.1 ad
529 1.1 ad #ifdef RASOPS_CLIPPING
530 1.1 ad if (row < 0) {
531 1.1 ad num += row;
532 1.1 ad row = 0;
533 1.1 ad }
534 1.1 ad
535 1.1 ad if ((row + num) > ri->ri_rows)
536 1.1 ad num = ri->ri_rows - row;
537 1.1 ad
538 1.1 ad if (num <= 0)
539 1.1 ad return;
540 1.1 ad #endif
541 1.1 ad
542 1.1 ad num *= ri->ri_font->fontheight;
543 1.1 ad dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
544 1.1 ad clr = rasops1_bg_color(attr);
545 1.1 ad
546 1.1 ad n8 = ri->ri_emustride >> 5;
547 1.1 ad n1 = (ri->ri_emustride >> 2) & 7;
548 1.1 ad
549 1.1 ad while (num--) {
550 1.1 ad for (cnt = n8; cnt; cnt--) {
551 1.1 ad dp[0] = clr;
552 1.1 ad dp[1] = clr;
553 1.1 ad dp[2] = clr;
554 1.1 ad dp[3] = clr;
555 1.1 ad dp[4] = clr;
556 1.1 ad dp[5] = clr;
557 1.1 ad dp[6] = clr;
558 1.1 ad dp[7] = clr;
559 1.1 ad dp += 8;
560 1.1 ad }
561 1.1 ad
562 1.1 ad for (cnt = n1; cnt; cnt--)
563 1.1 ad *dp++ = clr;
564 1.1 ad
565 1.1 ad DELTA(dp, ri->ri_delta, int32_t *);
566 1.1 ad }
567 1.1 ad }
568 1.1 ad
569 1.1 ad
570 1.1 ad /*
571 1.1 ad * Copy columns. This is slow. Ick! You'd better use a font with
572 1.1 ad * a width that's a multiple of 8 pels, otherwise this is used...
573 1.1 ad */
574 1.1 ad static void
575 1.1 ad rasops1_copycols(cookie, row, src, src)
576 1.1 ad void *cookie;
577 1.1 ad int row, src, dst;
578 1.1 ad {
579 1.1 ad #ifdef notyet
580 1.1 ad struct rasops_info *ri;
581 1.1 ad int32_t *dp, *drp, *sp, *srp, lmask, rmask;
582 1.1 ad int nint, height, cnt;
583 1.1 ad
584 1.1 ad ri = (struct rasops_info *)cookie;
585 1.1 ad
586 1.1 ad #ifdef RASOPS_CLIPPING
587 1.1 ad if (row < 0 || row >= ri->ri_rows)
588 1.1 ad return;
589 1.1 ad
590 1.1 ad if (col < 0) {
591 1.1 ad num += col;
592 1.1 ad col = 0;
593 1.1 ad }
594 1.1 ad
595 1.1 ad if ((col + num) > ri->ri_cols)
596 1.1 ad num = ri->ri_cols - col;
597 1.1 ad
598 1.1 ad if (num <= 0)
599 1.1 ad return;
600 1.1 ad #endif
601 1.1 ad src *= ri->ri_fontwidth;
602 1.1 ad dst *= ri->ri_fontwidth;
603 1.1 ad num *= ri->ri_fontwidth;
604 1.1 ad
605 1.1 ad /*
606 1.1 ad * lmask: mask for leftmost int32
607 1.1 ad * rmask: mask for rightmost int32
608 1.1 ad * nint: number of full int32s
609 1.1 ad */
610 1.1 ad lmask = leftmask[col & 31];
611 1.1 ad rmask = rightmask[(col + num) & 31];
612 1.1 ad nint = ((col + num) & ~31) - ((col + 31) & ~31) >> 5;
613 1.1 ad
614 1.1 ad /* Merge both masks if the span is encapsulated within one int32 */
615 1.1 ad if (col & ~31 == (col + num) & ~31) {
616 1.1 ad lmask &= rmask;
617 1.1 ad rmask = 0;
618 1.1 ad }
619 1.1 ad
620 1.1 ad lmask = ~lmask;
621 1.1 ad rmask = ~rmask;
622 1.1 ad height = ri->ri_fontheight;
623 1.1 ad drp = ri->ri_bits + row*ri->ri_yscale + ((dst >> 3) & ~3);
624 1.1 ad srp = ri->ri_bits + row*ri->ri_yscale + ((src >> 3) & ~3);
625 1.1 ad
626 1.1 ad while (height--) {
627 1.1 ad dp = rp;
628 1.1 ad DELTA(rp, ri->ri_stride, int32_t *);
629 1.1 ad
630 1.1 ad if (lmask != 0xffffffffU)
631 1.1 ad *dp++ = (*dp & lmask) | lclr;
632 1.1 ad
633 1.1 ad for (cnt = nint; cnt; cnt--)
634 1.1 ad *dp++ = clr;
635 1.1 ad
636 1.1 ad if (rmask != 0xffffffffU)
637 1.1 ad *dp = (*dp & rmask) | rclr;
638 1.1 ad }
639 1.1 ad #endif
640 1.1 ad }
641 1.1 ad
642 1.1 ad #endif /* RASOPS1 */
643