Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons Add copycols() and copyrows() methods which, ...



details:   https://anonhg.NetBSD.org/src/rev/0c6b3f76b8b1
branches:  trunk
changeset: 757193:0c6b3f76b8b1
user:      macallan <macallan%NetBSD.org@localhost>
date:      Wed Aug 18 16:46:51 2010 +0000

description:
Add copycols() and copyrows() methods which, instead of calling the underlying
driver methods, call the driver's putchar() method to redraw the affected
areas.
For unaccelerated framebuffers where reads are expensive and we can't spare
any memory for a shadow framebuffer. Enabled by setting VCONS_DONT_READ in
scr_flags

diffstat:

 sys/dev/wscons/wsdisplay_vcons.c    |  78 +++++++++++++++++++++++++++++++++++-
 sys/dev/wscons/wsdisplay_vconsvar.h |   3 +-
 2 files changed, 76 insertions(+), 5 deletions(-)

diffs (140 lines):

diff -r fde96727753e -r 0c6b3f76b8b1 sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c  Wed Aug 18 16:39:22 2010 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c  Wed Aug 18 16:46:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_vcons.c,v 1.16 2008/04/28 20:24:01 martin Exp $ */
+/*     $NetBSD: wsdisplay_vcons.c,v 1.17 2010/08/18 16:46:51 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.16 2008/04/28 20:24:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.17 2010/08/18 16:46:51 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,6 +89,13 @@
 static void vcons_putchar(void *, int, int, u_int, long);
 static void vcons_cursor(void *, int, int, int);
 
+/*
+ * methods that avoid framebuffer reads
+ */
+static void vcons_copycols_noread(void *, int, int, int, int);
+static void vcons_copyrows_noread(void *, int, int, int);
+
+
 /* support for reading/writing text buffers. For wsmoused */
 static int  vcons_putwschar(struct vcons_screen *, struct wsdisplay_char *);
 static int  vcons_getwschar(struct vcons_screen *, struct wsdisplay_char *);
@@ -223,11 +230,18 @@
        vd->cursor    = ri->ri_ops.cursor;
 
        ri->ri_ops.eraserows = vcons_eraserows; 
-       ri->ri_ops.copyrows  = vcons_copyrows;  
        ri->ri_ops.erasecols = vcons_erasecols; 
-       ri->ri_ops.copycols  = vcons_copycols;  
        ri->ri_ops.putchar   = vcons_putchar;
        ri->ri_ops.cursor    = vcons_cursor;
+
+       if (scr->scr_flags & VCONS_DONT_READ) {
+               ri->ri_ops.copyrows  = vcons_copyrows_noread;
+               ri->ri_ops.copycols  = vcons_copycols_noread;
+       } else {
+               ri->ri_ops.copyrows  = vcons_copyrows;
+               ri->ri_ops.copycols  = vcons_copycols;
+       }
+
        ri->ri_hw = scr;
 
        /* 
@@ -558,6 +572,33 @@
 }
 
 static void
+vcons_copycols_noread(void *cookie, int row, int srccol, int dstcol, int ncols)
+{
+       struct rasops_info *ri = cookie;
+       struct vcons_screen *scr = ri->ri_hw;
+
+       vcons_copycols_buffer(cookie, row, srccol, dstcol, ncols);
+
+       vcons_lock(scr);
+       if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
+               int pos, c, offset;
+
+#ifdef WSDISPLAY_SCROLLSUPPORT
+               offset = scr->scr_current_offset;
+#else
+               offset = 0;
+#endif
+               pos = ri->ri_cols * row + dstcol + offset;
+               for (c = dstcol; c < (dstcol + ncols); c++) {
+                       scr->scr_vd->putchar(cookie, row, c, 
+                          scr->scr_chars[pos], scr->scr_attrs[pos]);
+                       pos++;
+               }
+       }
+       vcons_unlock(scr);
+}
+
+static void
 vcons_erasecols_buffer(void *cookie, int row, int startcol, int ncols, long fillattr)
 {
        struct rasops_info *ri = cookie;
@@ -649,6 +690,35 @@
 }
 
 static void
+vcons_copyrows_noread(void *cookie, int srcrow, int dstrow, int nrows)
+{
+       struct rasops_info *ri = cookie;
+       struct vcons_screen *scr = ri->ri_hw;
+
+       vcons_copyrows_buffer(cookie, srcrow, dstrow, nrows);
+
+       vcons_lock(scr);
+       if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
+               int pos, l, c, offset;
+
+#ifdef WSDISPLAY_SCROLLSUPPORT
+               offset = scr->scr_current_offset;
+#else
+               offset = 0;
+#endif
+               pos = ri->ri_cols * dstrow + offset;
+               for (l = dstrow; l < (dstrow + nrows); l++) {
+                       for (c = 0; c < ri->ri_cols; c++) {
+                               scr->scr_vd->putchar(cookie, l, c, 
+                                  scr->scr_chars[pos], scr->scr_attrs[pos]);
+                               pos++;
+                       }
+               }
+       }
+       vcons_unlock(scr);
+}
+
+static void
 vcons_eraserows_buffer(void *cookie, int row, int nrows, long fillattr)
 {
        struct rasops_info *ri = cookie;
diff -r fde96727753e -r 0c6b3f76b8b1 sys/dev/wscons/wsdisplay_vconsvar.h
--- a/sys/dev/wscons/wsdisplay_vconsvar.h       Wed Aug 18 16:39:22 2010 +0000
+++ b/sys/dev/wscons/wsdisplay_vconsvar.h       Wed Aug 18 16:46:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_vconsvar.h,v 1.10 2009/08/20 02:01:08 macallan Exp $ */
+/*     $NetBSD: wsdisplay_vconsvar.h,v 1.11 2010/08/18 16:46:51 macallan Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -53,6 +53,7 @@
                                         * - for drivers that use software
                                         * drawing */
 #define VCONS_DONT_DRAW                8       /* don't draw on this screen at all */
+#define VCONS_DONT_READ                0x10    /* avoid framebuffer reads */
        /* status flags used by vcons */
        uint32_t scr_status;
 #define VCONS_IS_VISIBLE       1       /* this screen is currently visible */



Home | Main Index | Thread Index | Old Index