Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons in vcons_redraw_screen():



details:   https://anonhg.NetBSD.org/src/rev/1e333b138d75
branches:  trunk
changeset: 786988:1e333b138d75
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue May 28 11:04:04 2013 +0000

description:
in vcons_redraw_screen():
- if RI_FULLCLEAR is set and we use it to clear the screen, don't draw any
  whitespaces with the default background colour
- draw stretches of whitespaces with the same background colour using erasecols

diffstat:

 sys/dev/wscons/wsdisplay_vcons.c |  60 +++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 7 deletions(-)

diffs (112 lines):

diff -r 9c95fbdd19f6 -r 1e333b138d75 sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c  Tue May 28 10:55:34 2013 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c  Tue May 28 11:04:04 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_vcons.c,v 1.27 2012/01/04 08:25:03 macallan Exp $ */
+/*     $NetBSD: wsdisplay_vcons.c,v 1.28 2013/05/28 11:04:04 macallan Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.27 2012/01/04 08:25:03 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.28 2013/05/28 11:04:04 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -402,12 +402,14 @@
 void
 vcons_redraw_screen(struct vcons_screen *scr)
 {
-       uint32_t *charptr = scr->scr_chars;
-       long *attrptr = scr->scr_attrs;
+       uint32_t *charptr = scr->scr_chars, c;
+       long *attrptr = scr->scr_attrs, a, last_a = 0, mask, cmp, acmp;
        struct rasops_info *ri = &scr->scr_ri;
        struct vcons_data *vd = scr->scr_vd;
-       int i, j, offset, boffset = 0;
+       int i, j, offset, boffset = 0, start = -1;
 
+       mask = 0x00ff00ff;      /* background and flags */
+       cmp = -1;               /* never match anything */
        vcons_lock(scr);
        if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
 
@@ -418,6 +420,7 @@
                if (ri->ri_flg & RI_FULLCLEAR) {
                        vd->eraserows(ri, 0, ri->ri_rows,
                            scr->scr_defattr);
+                       cmp = scr->scr_defattr & mask;
                }
 
                /* redraw the screen */
@@ -427,6 +430,7 @@
                offset = 0;
 #endif
                for (i = 0; i < ri->ri_rows; i++) {
+                       start = -1;
                        for (j = 0; j < ri->ri_cols; j++) {
                                /*
                                 * no need to use the wrapper function - we 
@@ -434,8 +438,46 @@
                                 * and we already made sure the screen we're
                                 * working on is visible
                                 */
-                               vd->putchar(ri, i, j, 
-                                   charptr[offset], attrptr[offset]);
+                               c = charptr[offset];
+                               a = attrptr[offset];
+                               acmp = a & mask;
+                               if (c == ' ') {
+                                       /*
+                                        * if we already erased the background
+                                        * and this blank uses the same colour
+                                        * and flags we don't need to do
+                                        * anything here
+                                        */
+                                       if (acmp == cmp)
+                                               goto next;
+                                       /*
+                                        * see if we can optimize things a
+                                        * little bit by drawing stretches of
+                                        * blanks using erasecols
+                                        */
+                                       
+                                       if (start == -1) {
+                                               start = j;
+                                               last_a = acmp;
+                                       } else if (acmp != last_a) {
+                                               /*
+                                                * different attr, need to
+                                                * flush 
+                                                */
+                                               vd->erasecols(ri, i, start,
+                                                   j - start, last_a);
+                                               start = -1;
+                                       }
+                               } else {
+                                       if (start != -1) {
+                                               vd->erasecols(ri, i, start,
+                                                   j - start, last_a);
+                                               start = -1;
+                                       }
+                                                       
+                                       vd->putchar(ri, i, j, c, a);
+                               }
+next:
 #ifdef VCONS_DRAW_INTR
                                vd->chars[boffset] = charptr[offset];
                                vd->attrs[boffset] = attrptr[offset];
@@ -443,6 +485,10 @@
                                offset++;
                                boffset++;
                        }
+                       /* end of the line - draw all defered blanks, if any */
+                       if (start != -1) {
+                               vd->erasecols(ri, i, start, j - start, last_a);
+                       }                       
                }
                ri->ri_flg &= ~RI_CURSOR;
                scr->scr_vd->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);



Home | Main Index | Thread Index | Old Index