diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-09-15 20:23:11 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-09-15 20:23:11 +0000 |
commit | 6759b09d281d276d3b3d54ffbef1c9980df9d67f (patch) | |
tree | 4a4c5917557819414a798bb184a102c0bf525cef /sys/dev/wsfont | |
parent | 64393cf110217509a46347626cda13bdde46cf22 (diff) |
Stop compiling the texte console rotation code #ifdef __zaurus__, but use
a flag in the rasops_info structure; drivers which may use it shall declare
a specific attribute for the config(8) machinery, so that the necessary code
is compiled in.
In addition to this, rotated font computation is now done on-demand, and a
list of unrotated-rotated font cookie pairs is kept, rather than rotating all
built-in wsfonts at initialization time.
No user-perceptible functional change.
Tested matthieu@ uwe@, ok uwe@
Diffstat (limited to 'sys/dev/wsfont')
-rw-r--r-- | sys/dev/wsfont/files.wsfont | 10 | ||||
-rw-r--r-- | sys/dev/wsfont/wsfont.c | 112 | ||||
-rw-r--r-- | sys/dev/wsfont/wsfont.h | 3 |
3 files changed, 77 insertions, 48 deletions
diff --git a/sys/dev/wsfont/files.wsfont b/sys/dev/wsfont/files.wsfont index eeda2ba84e0..354a2c9882a 100644 --- a/sys/dev/wsfont/files.wsfont +++ b/sys/dev/wsfont/files.wsfont @@ -1,4 +1,10 @@ -# $OpenBSD: files.wsfont,v 1.2 2003/04/14 10:42:28 miod Exp $ +# $OpenBSD: files.wsfont,v 1.3 2005/09/15 20:23:10 miod Exp $ # $NetBSD: files.wsfont,v 1.7 2000/11/21 11:44:45 tsutsui Exp $ -file dev/wsfont/wsfont.c wsdisplay +# Note: `wsfont_glue' is only here to force the header file's name +# hence it must be mentioned first. +# This is similar to what rasops does - actually we are only interested +# in getting the rasops_rotation attribute, without having to depend +# on rasops being configured. +file dev/wsfont/wsfont.c ((wsfont_glue & rasops_rotation) | wsdisplay) + needs-flag diff --git a/sys/dev/wsfont/wsfont.c b/sys/dev/wsfont/wsfont.c index 2dfafcf1a81..28cd255d8dd 100644 --- a/sys/dev/wsfont/wsfont.c +++ b/sys/dev/wsfont/wsfont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfont.c,v 1.13 2005/05/05 23:32:48 miod Exp $ */ +/* $OpenBSD: wsfont.c,v 1.14 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $ */ /*- @@ -37,9 +37,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -//__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $"); - #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> @@ -50,6 +47,8 @@ #include <dev/wscons/wsconsio.h> #include <dev/wsfont/wsfont.h> +#include "wsfont_glue.h" /* NRASOPS_ROTATION */ + #undef HAVE_FONT #ifdef FONT_QVSS8x15 @@ -129,10 +128,6 @@ #include <dev/wsfont/gallant12x22.h> #endif -#ifdef __zaurus__ -void wsfont_rotate(struct wsdisplay_font *, int); -#endif - /* Placeholder struct used for linked list */ struct font { struct font *next; @@ -217,7 +212,7 @@ static const u_char reverse[256] = { 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; -static struct font *wsfont_find0(int); +static struct font *wsfont_find0(int); static void wsfont_revbit(struct wsdisplay_font *); static void wsfont_revbyte(struct wsdisplay_font *); @@ -289,19 +284,35 @@ wsfont_enum(cb) splx(s); } -#ifdef __zaurus__ -void wsfont_rotate(struct wsdisplay_font *font, int static_orig) +#if NRASOPS_ROTATION > 0 + +struct wsdisplay_font *wsfont_rotate_internal(struct wsdisplay_font *); + +struct wsdisplay_font * +wsfont_rotate_internal(struct wsdisplay_font *font) { int b, n, r, newstride; - char *newfont; + struct wsdisplay_font *newfont; + char *newbits; + + /* Duplicate the existing font... */ + newfont = malloc(sizeof *font, M_DEVBUF, M_WAITOK); + if (newfont == NULL) + return (NULL); + + bcopy(font, newfont, sizeof *font); + newfont->cookie = NULL; /* Allocate a buffer big enough for the rotated font. */ newstride = (font->fontheight + 7) / 8; - newfont = malloc(newstride * font->fontwidth * font->numchars, + newbits = malloc(newstride * font->fontwidth * font->numchars, M_DEVBUF, M_WAITOK); - if (newfont == NULL) - return; - bzero(newfont, newstride * font->fontwidth * font->numchars); + if (newbits == NULL) { + free(newfont, M_DEVBUF); + return (NULL); + } + + bzero(newbits, newstride * font->fontwidth * font->numchars); /* Rotate the font a bit at a time. */ for (n = 0; n < font->numchars; n++) { @@ -315,7 +326,7 @@ void wsfont_rotate(struct wsdisplay_font *font, int static_orig) if (*rb & (0x80 >> (b % 8))) { unsigned char *rrb; - rrb = newfont + newstride - 1 - (r / 8) + rrb = newbits + newstride - 1 - (r / 8) + (n * newstride * font->fontwidth) + (newstride * b); *rrb |= (1 << (r % 8)); @@ -324,28 +335,48 @@ void wsfont_rotate(struct wsdisplay_font *font, int static_orig) } } - /* - * If the rotated font will fit into the memory the font originally - * used, copy it into there, otherwise use our new buffer. - */ - if ((newstride * font->fontwidth * font->numchars) <= - (font->stride * font->fontheight * font->numchars)) { - memcpy(font->data, newfont, newstride * - font->fontwidth * font->numchars); + newfont->data = newbits; + + /* Update font sizes. */ + newfont->stride = newstride; + newfont->fontwidth = font->fontheight; + newfont->fontheight = font->fontwidth; + + if (wsfont_add(newfont, 0) != 0) { + /* + * If we seem to have rotated this font already, drop the + * new one... + */ + free(newbits, M_DEVBUF); free(newfont, M_DEVBUF); - } else { - if (!static_orig) - free(font->data, M_DEVBUF); - font->data = newfont; + newfont = NULL; } - /* Update font sizes. */ - font->stride = newstride; - newstride = font->fontwidth; /* temp */ - font->fontwidth = font->fontheight; - font->fontheight = newstride; + return (newfont); } -#endif + +int +wsfont_rotate(int cookie) +{ + int s, ncookie; + struct wsdisplay_font *font; + struct font *origfont; + + s = splhigh(); + origfont = wsfont_find0(cookie); + splx(s); + + font = wsfont_rotate_internal(origfont->font); + if (font == NULL) + return (-1); + + ncookie = wsfont_find(font->name, font->fontwidth, font->fontheight, + font->stride); + + return (ncookie); +} + +#endif /* NRASOPS_ROTATION */ /* * Initialize list with WSFONT_BUILTIN fonts @@ -360,11 +391,6 @@ wsfont_init(void) return; again = 1; -#ifdef __zaurus__ - for (i = 0; builtin_fonts[i].font != NULL; i++) - wsfont_rotate(builtin_fonts[i].font, 1); -#endif - for (i = 0; builtin_fonts[i].font != NULL; i++) { builtin_fonts[i].next = list; list = &builtin_fonts[i]; @@ -466,16 +492,12 @@ wsfont_add(font, copy) ent->flg = 0; } -#ifdef __zaurus__ - wsfont_rotate(ent->font, 0); -#endif - /* Now link into the list and return */ list = ent; splx(s); return (0); } - + /* * Remove a font. */ diff --git a/sys/dev/wsfont/wsfont.h b/sys/dev/wsfont/wsfont.h index 2770e201410..000d53d1a42 100644 --- a/sys/dev/wsfont/wsfont.h +++ b/sys/dev/wsfont/wsfont.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfont.h,v 1.3 2002/03/14 03:16:08 millert Exp $ */ +/* $OpenBSD: wsfont.h,v 1.4 2005/09/15 20:23:10 miod Exp $ */ /* $NetBSD: wsfont.h,v 1.12 2000/06/13 13:37:07 ad Exp $ */ /*- @@ -82,5 +82,6 @@ int wsfont_lock(int, struct wsdisplay_font **, int, int); int wsfont_unlock(int); int wsfont_getflg(int, int *, int *); int wsfont_map_unichar(struct wsdisplay_font *, int); +int wsfont_rotate(int); #endif /* !_WSFONT_H_ */ |