Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/dev support anti-aliased fonts, glyphcache etc.



details:   https://anonhg.NetBSD.org/src/rev/cb7f9dbb9526
branches:  trunk
changeset: 344966:cb7f9dbb9526
user:      macallan <macallan%NetBSD.org@localhost>
date:      Sat Apr 30 05:23:03 2016 +0000

description:
support anti-aliased fonts, glyphcache etc.

diffstat:

 sys/arch/sparc/dev/cgfourteen.c    |  289 +++++++++++++++++++-----------------
 sys/arch/sparc/dev/cgfourteenvar.h |    3 +-
 2 files changed, 151 insertions(+), 141 deletions(-)

diffs (truncated from 458 to 300 lines):

diff -r 166686000cb3 -r cb7f9dbb9526 sys/arch/sparc/dev/cgfourteen.c
--- a/sys/arch/sparc/dev/cgfourteen.c   Sat Apr 30 05:22:19 2016 +0000
+++ b/sys/arch/sparc/dev/cgfourteen.c   Sat Apr 30 05:23:03 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cgfourteen.c,v 1.79 2014/07/25 08:10:34 dholland Exp $ */
+/*     $NetBSD: cgfourteen.c,v 1.80 2016/04/30 05:23:03 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -96,6 +96,7 @@
 #include <dev/rasops/rasops.h>
 
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/wscons/wsdisplay_glyphcachevar.h>
 
 #include <sparc/sparc/asm.h>
 #include <sparc/dev/cgfourteenreg.h>
@@ -164,10 +165,9 @@
     uint32_t);
 static void cg14_invert(struct cgfourteen_softc *, int, int, int, int);
 static void cg14_bitblt(void *, int, int, int, int, int, int, int);
+static void cg14_bitblt_gc(void *, int, int, int, int, int, int, int);
 
-#if 0
 static void cg14_putchar_aa(void *, int, int, u_int, long);
-#endif
 static void cg14_cursor(void *, int, int, int);
 static void cg14_putchar(void *, int, int, u_int, long);
 static void cg14_copycols(void *, int, int, int, int);
@@ -595,74 +595,14 @@
 static void
 cg14_init(struct cgfourteen_softc *sc)
 {
-#if 0
-       volatile uint32_t *clut;
-       volatile uint8_t  *xlut;
-       int i;
-
-       /*
-        * We stash away the following to restore on close:
-        *
-        *      color look-up table 1   (sc->sc_saveclut)
-        *      x look-up table         (sc->sc_savexlut)
-        *      control register        (sc->sc_savectl)
-        *      cursor control register (sc->sc_savehwc)
-        */
-       sc->sc_savectl = sc->sc_ctl->ctl_mctl;
-       sc->sc_savehwc = sc->sc_hwc->curs_ctl;
-
-       clut = (volatile uint32_t *) sc->sc_clut1->clut_lut;
-       xlut = (volatile uint8_t *) sc->sc_xlut->xlut_lut;
-       for (i = 0; i < CG14_CLUT_SIZE; i++) {
-               sc->sc_saveclut.cm_chip[i] = clut[i];
-               sc->sc_savexlut[i] = xlut[i];
-       }
-
-       /*
-        * Enable the video and put it in 8 bit mode
-        */
-       sc->sc_ctl->ctl_mctl = CG14_MCTL_ENABLEVID | CG14_MCTL_PIXMODE_8 |
-               CG14_MCTL_POWERCTL;
-#else
        cg14_set_depth(sc, 32);
-#endif
 }
 
 static void
 /* Restore the state saved on cg14_init */
 cg14_reset(struct cgfourteen_softc *sc)
 {
-#if 0
-       volatile uint32_t *clut;
-       volatile uint8_t  *xlut;
-       int i;
-
-       /*
-        * We restore the following, saved in cg14_init:
-        *
-        *      color look-up table 1   (sc->sc_saveclut)
-        *      x look-up table         (sc->sc_savexlut)
-        *      control register        (sc->sc_savectl)
-        *      cursor control register (sc->sc_savehwc)
-        *
-        * Note that we don't touch the video enable bits in the
-        * control register; otherwise, screenblank wouldn't work.
-        */
-       sc->sc_ctl->ctl_mctl = (sc->sc_ctl->ctl_mctl & (CG14_MCTL_ENABLEVID |
-                                                       CG14_MCTL_POWERCTL)) |
-                               (sc->sc_savectl & ~(CG14_MCTL_ENABLEVID |
-                                                   CG14_MCTL_POWERCTL));
-       sc->sc_hwc->curs_ctl = sc->sc_savehwc;
-
-       clut = sc->sc_clut1->clut_lut;
-       xlut = sc->sc_xlut->xlut_lut;
-       for (i = 0; i < CG14_CLUT_SIZE; i++) {
-               clut[i] = sc->sc_saveclut.cm_chip[i];
-               xlut[i] = sc->sc_savexlut[i];
-       }
-#else
        cg14_set_depth(sc, 8);
-#endif
 }
 
 /* Enable/disable video display; power down monitor if DPMS-capable */
@@ -767,7 +707,6 @@
                *lutp++ = *colp++;
 }
 
-#if NWSDISPLAY > 0
 static void
 cg14_setup_wsdisplay(struct cgfourteen_softc *sc, int is_cons)
 {
@@ -793,20 +732,35 @@
 
        ri = &sc->sc_console_screen.scr_ri;
 
+       sc->sc_gc.gc_bitblt = cg14_bitblt_gc;
+       sc->sc_gc.gc_blitcookie = sc;
+       sc->sc_gc.gc_rop = 0xc;
        if (is_cons) {
                vcons_init_screen(&sc->sc_vd, &sc->sc_console_screen, 1,
                    &defattr);
 
                /* clear the screen with the default background colour */
-               memset(sc->sc_fb.fb_pixels,
-                      (defattr >> 16) & 0xff,
-                      ri->ri_stride * ri->ri_height);
+               if (sc->sc_sx != NULL) {
+                       cg14_rectfill(sc, 0, 0, ri->ri_width, ri->ri_height,
+                               ri->ri_devcmap[(defattr >> 16) & 0xf]);
+               } else {
+                       memset(sc->sc_fb.fb_pixels,
+                              ri->ri_devcmap[(defattr >> 16) & 0xf],
+                              ri->ri_stride * ri->ri_height);
+               }
                sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
 
                sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
                sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
                sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
                sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
+               glyphcache_init(&sc->sc_gc, sc->sc_fb.fb_type.fb_height + 5,
+                       (sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) - 
+                        sc->sc_fb.fb_type.fb_height - 5,
+                       sc->sc_fb.fb_type.fb_width,
+                       ri->ri_font->fontwidth,
+                       ri->ri_font->fontheight,
+                       defattr);
                wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
                    defattr);
                vcons_replay_msgbuf(&sc->sc_console_screen);
@@ -815,6 +769,13 @@
                 * since we're not the console we can postpone the rest
                 * until someone actually allocates a screen for us
                 */
+               glyphcache_init(&sc->sc_gc, sc->sc_fb.fb_type.fb_height + 5,
+                       (sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) -
+                        sc->sc_fb.fb_type.fb_height - 5,
+                       sc->sc_fb.fb_type.fb_width,
+                       ri->ri_font->fontwidth,
+                       ri->ri_font->fontheight,
+                       defattr);
        }
 
        cg14_init_cmap(sc);
@@ -830,13 +791,17 @@
 static void
 cg14_init_cmap(struct cgfourteen_softc *sc)
 {
+       struct rasops_info *ri = &sc->sc_console_screen.scr_ri;
        int i, j = 0;
+       uint8_t cmap[768];
+
+       rasops_get_cmap(ri, cmap, sizeof(cmap));
 
        for (i = 0; i < 256; i++) {
 
-               sc->sc_cmap.cm_map[i][3] = rasops_cmap[j];
-               sc->sc_cmap.cm_map[i][2] = rasops_cmap[j + 1];
-               sc->sc_cmap.cm_map[i][1] = rasops_cmap[j + 2];
+               sc->sc_cmap.cm_map[i][3] = cmap[j];
+               sc->sc_cmap.cm_map[i][2] = cmap[j + 1];
+               sc->sc_cmap.cm_map[i][1] = cmap[j + 2];
                j += 3;
        }
        cg14_load_hwcmap(sc, 0, 256);
@@ -1035,6 +1000,8 @@
 
        ri->ri_bits = (char *)sc->sc_fb.fb_pixels;
 #if NSX > 0
+       ri->ri_flg |= RI_8BIT_IS_RGB | RI_ENABLE_ALPHA;
+
        /*
         * unaligned copies with horizontal overlap are slow, so don't bother
         * handling them in cg14_bitblt() and use putchar() instead
@@ -1064,11 +1031,9 @@
                ri->ri_ops.eraserows = cg14_eraserows;
                ri->ri_ops.erasecols = cg14_erasecols;
                ri->ri_ops.cursor = cg14_cursor;
-#if 0
                if (FONT_IS_ALPHA(ri->ri_font)) {
                        ri->ri_ops.putchar = cg14_putchar_aa;
                } else
-#endif
                        ri->ri_ops.putchar = cg14_putchar;
        }
 #endif /* NSX > 0 */
@@ -1403,6 +1368,64 @@
        }
 }
 
+/*
+ * for copying glyphs around
+ * - uses all quads for reads
+ * - uses quads for writes as far as possible
+ * - limited by number of registers - won't do more than 120 wide
+ * - doesn't handle overlaps
+ */
+static void
+cg14_bitblt_gc(void *cookie, int xs, int ys, int xd, int yd,
+    int wi, int he, int rop)
+{
+       struct cgfourteen_softc *sc = cookie;
+       uint32_t saddr, daddr;
+       int line, cnt = wi, stride = sc->sc_fb.fb_type.fb_width;
+       int dreg = 8, swi = wi, dd;
+       int in = 0, q = 0, out = 0, r;
+
+       saddr = sc->sc_fb_paddr + xs + stride * ys;
+       daddr = sc->sc_fb_paddr + xd + stride * yd;
+
+       if (saddr & 3) {
+               swi += saddr & 3;
+               dreg += saddr & 3;
+               saddr &= ~3;
+       }
+       swi = (swi + 3) >> 2;   /* round up, number of quads to read */
+       
+       if (daddr & 3) {
+               in = 4 - (daddr & 3); /* pixels to write in byte mode */
+               cnt -= in;
+       }
+
+       q = cnt >> 2;
+       out = cnt & 3;
+       
+       for (line = 0; line < he; line++) {
+               /* read source line, in all quads */
+               sta(saddr & ~7, ASI_SX, SX_LDUQ0(8, swi - 1, saddr & 7));
+               /* now write it out */
+               dd = daddr;
+               r = dreg;
+               if (in > 0) {
+                       sta(dd & ~7, ASI_SX, SX_STB(r, in - 1, dd & 7));
+                       dd += in;
+                       r += in;
+               }
+               if (q > 0) {
+                       sta(dd & ~7, ASI_SX, SX_STUQ0(r, q - 1, dd & 7));
+                       r += q << 2;
+                       dd += q << 2;
+               }
+               if (out > 0) {
+                       sta(dd & ~7, ASI_SX, SX_STB(r, out - 1, dd & 7));
+               }
+               saddr += stride;
+               daddr += stride;
+       }
+}
 
 static void
 cg14_putchar(void *cookie, int row, int col, u_int c, long attr)
@@ -1506,19 +1529,18 @@
 
 }
 
-#if 0
 static void
-r128fb_putchar_aa(void *cookie, int row, int col, u_int c, long attr)
+cg14_putchar_aa(void *cookie, int row, int col, u_int c, long attr)
 {
        struct rasops_info *ri = cookie;
        struct wsdisplay_font *font = PICK_FONT(ri, c);
        struct vcons_screen *scr = ri->ri_hw;
-       struct r128fb_softc *sc = scr->scr_cookie;
-       uint32_t bg, latch = 0, bg8, fg8, pixel;
-       int i, x, y, wi, he, r, g, b, aval;
-       int r1, g1, b1, r0, g0, b0, fgo, bgo;
+       struct cgfourteen_softc *sc = scr->scr_cookie;
+       int stride = sc->sc_fb.fb_type.fb_width;
+       uint32_t bg, addr, bg8, fg8, pixel, in, q, next;
+       int i, j, x, y, wi, he, r, g, b, aval, cnt, reg;
+       int r1, g1, b1, r0, g0, b0, fgo, bgo, rv;
        uint8_t *data8;
-       int rv, cnt = 0;
 
        if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) 
                return;
@@ -1533,7 +1555,7 @@
        x = ri->ri_xorigin + col * wi;



Home | Main Index | Thread Index | Old Index