Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops autogenerate box drawing characters for fonts...
details: https://anonhg.NetBSD.org/src/rev/1912faf9aa20
branches: trunk
changeset: 754556:1912faf9aa20
user: macallan <macallan%NetBSD.org@localhost>
date: Tue May 04 04:57:34 2010 +0000
description:
autogenerate box drawing characters for fonts that don't have them, put them
into an alternate font pointed at by the recently added mappings in wsfont,
adapt all putchar() methods except the rotated ones to use them
XXX no attempt has been made to make this work with rotation
diffstat:
sys/dev/rasops/rasops.c | 214 +++++++++++++++++++++++++++++++++++++++------
sys/dev/rasops/rasops.h | 12 +-
sys/dev/rasops/rasops1.c | 51 +++++-----
sys/dev/rasops/rasops15.c | 54 +++++-----
sys/dev/rasops/rasops2.c | 42 ++++----
sys/dev/rasops/rasops24.c | 58 +++++------
sys/dev/rasops/rasops32.c | 22 ++--
sys/dev/rasops/rasops4.c | 58 +++++------
sys/dev/rasops/rasops8.c | 62 ++++++------
9 files changed, 365 insertions(+), 208 deletions(-)
diffs (truncated from 1472 to 300 lines):
diff -r 6167305f8ab4 -r 1912faf9aa20 sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c Tue May 04 04:53:59 2010 +0000
+++ b/sys/dev/rasops/rasops.c Tue May 04 04:57:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.c,v 1.62 2010/04/17 13:36:22 nonaka Exp $ */
+/* $NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.62 2010/04/17 13:36:22 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $");
#include "opt_rasops.h"
#include "rasops_glue.h"
@@ -39,6 +39,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/kmem.h>
#include <sys/bswap.h>
#include <machine/endian.h>
@@ -158,6 +159,10 @@
};
#endif /* NRASOPS_ROTATION > 0 */
+void rasops_make_box_chars_8(struct rasops_info *);
+void rasops_make_box_chars_16(struct rasops_info *);
+void rasops_make_box_chars_32(struct rasops_info *);
+
/*
* Initialize a 'rasops_info' descriptor.
*/
@@ -165,6 +170,7 @@
rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
{
+ memset (&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
#ifdef _KERNEL
/* Select a font if the caller doesn't care */
if (ri->ri_font == NULL) {
@@ -232,10 +238,40 @@
int
rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols)
{
- int bpp, s;
+ int bpp, s, len;
s = splhigh();
+ /* throw away old line drawing character bitmaps, if we have any */
+ if (ri->ri_optfont.data != NULL) {
+ kmem_free(ri->ri_optfont.data, ri->ri_optfont.stride *
+ ri->ri_optfont.fontheight * ri->ri_optfont.numchars);
+ ri->ri_optfont.data = NULL;
+ }
+
+ /* autogenerate box drawing characters */
+ ri->ri_optfont.fontwidth = ri->ri_font->fontwidth;
+ ri->ri_optfont.fontheight = ri->ri_font->fontheight;
+ ri->ri_optfont.stride = ri->ri_font->stride;
+ ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
+ ri->ri_optfont.numchars = 16;
+
+ len = ri->ri_optfont.fontheight * ri->ri_optfont.stride *
+ ri->ri_optfont.numchars;
+ if ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL) {
+ switch (ri->ri_optfont.stride) {
+ case 1:
+ rasops_make_box_chars_8(ri);
+ break;
+ case 2:
+ rasops_make_box_chars_16(ri);
+ break;
+ case 4:
+ rasops_make_box_chars_32(ri);
+ break;
+ }
+ }
+
if (ri->ri_font->fontwidth > 32 || ri->ri_font->fontwidth < 4)
panic("rasops_init: fontwidth assumptions botched!");
@@ -421,12 +457,9 @@
panic("rasops_mapchar: no font selected");
#endif
- if (ri->ri_font->encoding != WSDISPLAY_FONTENC_ISO) {
- if ( (c = wsfont_map_unichar(ri->ri_font, c)) < 0) {
- *cp = ' ';
- return (0);
-
- }
+ if ( (c = wsfont_map_unichar(ri->ri_font, c)) < 0) {
+ *cp = ' ';
+ return (0);
}
if (c < ri->ri_font->firstchar) {
@@ -434,11 +467,12 @@
return (0);
}
+#if 0
if (c - ri->ri_font->firstchar >= ri->ri_font->numchars) {
*cp = ' ';
return (0);
}
-
+#endif
*cp = c;
return (5);
}
@@ -904,7 +938,7 @@
rasops_do_cursor(struct rasops_info *ri)
{
int full1, height, cnt, slop1, slop2, row, col;
- u_char *dp, *rp, *hrp, *hp;
+ u_char *dp, *rp, *hrp, *hp, tmp = 0;
hrp = hp = NULL;
@@ -943,6 +977,7 @@
full1 = (ri->ri_xscale - slop1 - slop2) >> 2;
if ((slop1 | slop2) == 0) {
+ uint32_t tmp32;
/* A common case */
while (height--) {
dp = rp;
@@ -953,17 +988,18 @@
}
for (cnt = full1; cnt; cnt--) {
- *(int32_t *)dp ^= ~0;
+ tmp32 = *(int32_t *)dp ^ ~0;
+ *(int32_t *)dp = tmp32;
dp += 4;
if (ri->ri_hwbits) {
- dp -= 4;
- *(int32_t *)hp = *(int32_t *)dp;
+ *(int32_t *)hp = tmp32;
hp += 4;
- dp += 4;
}
}
}
} else {
+ uint16_t tmp16;
+ uint32_t tmp32;
/* XXX this is stupid.. use masks instead */
while (height--) {
dp = rp;
@@ -974,44 +1010,47 @@
}
if (slop1 & 1) {
- *dp++ ^= ~0;
+ tmp = *dp ^ ~0;
+ *dp = tmp;
+ dp++;
if (ri->ri_hwbits) {
- *hp++ = *(dp - 1);
+ *hp++ = tmp;
}
}
if (slop1 & 2) {
- *(int16_t *)dp ^= ~0;
+ tmp16 = *(int16_t *)dp ^ ~0;
+ *(uint16_t *)dp = tmp16;
dp += 2;
if (ri->ri_hwbits) {
- dp -= 2;
- *(int16_t *)hp = *(int16_t *)dp;
+ *(int16_t *)hp = tmp16;
hp += 2;
- dp += 2;
}
}
for (cnt = full1; cnt; cnt--) {
- *(int32_t *)dp ^= ~0;
+ tmp32 = *(int32_t *)dp ^ ~0;
+ *(uint32_t *)dp = tmp32;
dp += 4;
if (ri->ri_hwbits) {
- dp -= 4;
- *(int32_t *)hp = *(int32_t *)dp;
+ *(int32_t *)hp = tmp32;
hp += 4;
- dp += 4;
}
}
if (slop2 & 1) {
- *dp++ ^= ~0;
+ tmp = *dp ^ ~0;
+ *dp = tmp;
+ dp++;
if (ri->ri_hwbits)
- *hp++ = *(dp - 1);
+ *hp++ = tmp;
}
if (slop2 & 2) {
- *(int16_t *)dp ^= ~0;
+ tmp16 = *(int16_t *)dp ^ ~0;
+ *(uint16_t *)dp = tmp16;
if (ri->ri_hwbits)
- *(int16_t *)hp = *(int16_t *)(dp - 2);
+ *(int16_t *)hp = tmp16;
}
}
}
@@ -1459,3 +1498,120 @@
src + coff, dst + coff);
}
#endif /* NRASOPS_ROTATION */
+
+void
+rasops_make_box_chars_16(struct rasops_info *ri)
+{
+ uint16_t vert_mask, hmask_left, hmask_right;
+ uint16_t *data = (uint16_t *)ri->ri_optfont.data;
+ int c, i, mid;
+
+ vert_mask = 0xc000 >> ((ri->ri_font->fontwidth >> 1) - 1);
+ hmask_left = 0xff00 << (8 - (ri->ri_font->fontwidth >> 1));
+ hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1)>> 1);
+ mid = (ri->ri_font->fontheight + 1) >> 1;
+
+ /* 0x00 would be empty anyway so don't bother */
+ for (c = 1; c < 16; c++) {
+ data += ri->ri_font->fontheight;
+ if (c & 1) {
+ /* upper segment */
+ for (i = 0; i < mid; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 4) {
+ /* lower segment */
+ for (i = mid; i < ri->ri_font->fontheight; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 2) {
+ /* right segment */
+ i = ri->ri_font->fontheight >> 1;
+ data[mid - 1] |= hmask_right;
+ data[mid] |= hmask_right;
+ }
+ if (c & 8) {
+ /* left segment */
+ data[mid - 1] |= hmask_left;
+ data[mid] |= hmask_left;
+ }
+ }
+}
+
+void
+rasops_make_box_chars_8(struct rasops_info *ri)
+{
+ uint8_t vert_mask, hmask_left, hmask_right;
+ uint8_t *data = (uint8_t *)ri->ri_optfont.data;
+ int c, i, mid;
+
+ vert_mask = 0xc0 >> ((ri->ri_font->fontwidth >> 1) - 1);
+ hmask_left = 0xf0 << (4 - (ri->ri_font->fontwidth >> 1));
+ hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1)>> 1);
+ mid = (ri->ri_font->fontheight + 1) >> 1;
+
+ /* 0x00 would be empty anyway so don't bother */
+ for (c = 1; c < 16; c++) {
+ data += ri->ri_font->fontheight;
+ if (c & 1) {
+ /* upper segment */
+ for (i = 0; i < mid; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 4) {
+ /* lower segment */
+ for (i = mid; i < ri->ri_font->fontheight; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 2) {
+ /* right segment */
+ i = ri->ri_font->fontheight >> 1;
+ data[mid - 1] |= hmask_right;
+ data[mid] |= hmask_right;
+ }
+ if (c & 8) {
+ /* left segment */
+ data[mid - 1] |= hmask_left;
+ data[mid] |= hmask_left;
+ }
+ }
Home |
Main Index |
Thread Index |
Old Index