Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/voyager use glyphcache for anti-aliased fonts



details:   https://anonhg.NetBSD.org/src/rev/a348c8e616bb
branches:  trunk
changeset: 777515:a348c8e616bb
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Feb 21 15:26:20 2012 +0000

description:
use glyphcache for anti-aliased fonts

diffstat:

 sys/dev/pci/voyager/files.voyager |   2 +-
 sys/dev/pci/voyager/voyagerfb.c   |  36 ++++++++++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 7 deletions(-)

diffs (148 lines):

diff -r ca7a101de669 -r a348c8e616bb sys/dev/pci/voyager/files.voyager
--- a/sys/dev/pci/voyager/files.voyager Tue Feb 21 15:01:51 2012 +0000
+++ b/sys/dev/pci/voyager/files.voyager Tue Feb 21 15:26:20 2012 +0000
@@ -3,7 +3,7 @@
 define voyagerbus {}
 
 # the graphics part
-device voyagerfb: wsemuldisplaydev, rasops8, rasops16, rasops32, vcons, videomode, iic, i2c_bitbang
+device voyagerfb: wsemuldisplaydev, rasops8, rasops16, rasops32, vcons, videomode, iic, i2c_bitbang, glyphcache
 attach voyagerfb at voyagerbus
 file   dev/pci/voyager/voyagerfb.c             voyagerfb needs-flag
 defflag        opt_voyagerfb.h VOYAGERFB_DEBUG VOYAGERFB_ANTIALIAS
diff -r ca7a101de669 -r a348c8e616bb sys/dev/pci/voyager/voyagerfb.c
--- a/sys/dev/pci/voyager/voyagerfb.c   Tue Feb 21 15:01:51 2012 +0000
+++ b/sys/dev/pci/voyager/voyagerfb.c   Tue Feb 21 15:26:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: voyagerfb.c,v 1.16 2012/01/11 16:07:29 macallan Exp $  */
+/*     $NetBSD: voyagerfb.c,v 1.17 2012/02/21 15:26:20 macallan Exp $  */
 
 /*
  * Copyright (c) 2009, 2011 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.16 2012/01/11 16:07:29 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.17 2012/02/21 15:26:20 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,6 +58,7 @@
 
 #include <dev/i2c/i2cvar.h>
 #include <dev/pci/voyagervar.h>
+#include <dev/wscons/wsdisplay_glyphcachevar.h>
 
 #include "opt_voyagerfb.h"
 
@@ -107,6 +108,8 @@
        u_char sc_cmap_red[256];
        u_char sc_cmap_green[256];
        u_char sc_cmap_blue[256];
+
+       glyphcache sc_gc;
 };
 
 static int     voyagerfb_match(device_t, cfdata_t, void *);
@@ -135,7 +138,7 @@
 
 static void    voyagerfb_rectfill(struct voyagerfb_softc *, int, int, int, int,
                            uint32_t);
-static void    voyagerfb_bitblt(struct voyagerfb_softc *, int, int, int, int,
+static void    voyagerfb_bitblt(void *, int, int, int, int,
                            int, int, int);
 
 static void    voyagerfb_cursor(void *, int, int, int);
@@ -273,6 +276,9 @@
 
        ri = &sc->sc_console_screen.scr_ri;
 
+       sc->sc_gc.gc_bitblt = voyagerfb_bitblt;
+       sc->sc_gc.gc_blitcookie = sc;
+       sc->sc_gc.gc_rop = ROP_COPY;
        if (is_console) {
                vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
                    &defattr);
@@ -282,8 +288,6 @@
                sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
                sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
                sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
-               wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
-                   defattr);
        } else {
                /*
                 * since we're not the console we can postpone the rest
@@ -291,6 +295,15 @@
                 */
                (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
        }
+       glyphcache_init(&sc->sc_gc, sc->sc_height,
+                       sc->sc_width,
+                       (sc->sc_fbsize / sc->sc_stride) - sc->sc_height,
+                       ri->ri_font->fontwidth,
+                       ri->ri_font->fontheight,
+                       defattr);
+       if (is_console)
+               wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
+                   defattr);
 
        j = 0;
        if (sc->sc_depth <= 8) {
@@ -376,6 +389,7 @@
 #else
                                sc->sc_depth = 8;
 #endif
+                               glyphcache_wipe(&sc->sc_gc);
                                voyagerfb_init(sc);
                                voyagerfb_restore_palette(sc);
                                vcons_redraw_screen(ms);
@@ -736,9 +750,10 @@
 }
 
 static void
-voyagerfb_bitblt(struct voyagerfb_softc *sc, int xs, int ys, int xd, int yd,
+voyagerfb_bitblt(void *cookie, int xs, int ys, int xd, int yd,
     int wi, int he, int rop)
 {
+       struct voyagerfb_softc *sc = cookie;
        uint32_t cmd;
 
        cmd = (rop & 0xf) | SM502_CTRL_USE_ROP2 | SM502_CTRL_CMD_BITBLT |
@@ -841,6 +856,7 @@
        int fg, bg;
        uint8_t *data;
        int x, y, wi, he;
+       int rv;
 
        if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL)
                return;
@@ -859,6 +875,7 @@
                voyagerfb_rectfill(sc, x, y, wi, he, bg);
                return;
        }
+
        data = WSFONT_GLYPH(c, font);
        if (!FONT_IS_ALPHA(font)) {
                /* this is a mono font */
@@ -902,6 +919,10 @@
                int rf, gf, bf, rb, gb, bb;
                uint32_t pixel;
 
+               rv = glyphcache_try(&sc->sc_gc, c, x, y, attr);
+               if (rv == GC_OK)
+                       return;
+
                cmd = ROP_COPY |
                      SM502_CTRL_USE_ROP2 |
                      SM502_CTRL_CMD_HOSTWRT |
@@ -945,6 +966,9 @@
                                bus_space_write_4(sc->sc_memt, sc->sc_regh,
                                    SM502_DATAPORT, 0);
                }
+               if (rv == GC_ADD) {
+                       glyphcache_add(&sc->sc_gc, c, x, y);
+               }
        }
 }
 



Home | Main Index | Thread Index | Old Index