Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons - refactor vcons_cursor_noread() a bit so it ...



details:   https://anonhg.NetBSD.org/src/rev/e3281c23a257
branches:  trunk
changeset: 1018225:e3281c23a257
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Jan 26 16:24:17 2021 +0000

description:
- refactor vcons_cursor_noread() a bit so it works the same way as the other
  _noread() methods instead of duplicating half of vcons_cursor()
- skip clearing the cursor only if we use all _noread() methods
- clear RI_CURSOR in all copy*_noread() methods as well if we overwrite the
  cursor

diffstat:

 sys/dev/wscons/wsdisplay_vcons.c |  93 +++++++++++++++++----------------------
 1 files changed, 41 insertions(+), 52 deletions(-)

diffs (171 lines):

diff -r 34c5690a3de5 -r e3281c23a257 sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c  Tue Jan 26 15:30:05 2021 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c  Tue Jan 26 16:24:17 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_vcons.c,v 1.49 2021/01/25 02:11:41 macallan Exp $ */
+/*     $NetBSD: wsdisplay_vcons.c,v 1.50 2021/01/26 16:24:17 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.49 2021/01/25 02:11:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.50 2021/01/26 16:24:17 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -320,6 +320,7 @@
        scr->scr_cookie = vd->cookie;
        scr->scr_vd = scr->scr_origvd = vd;
        scr->scr_busy = 0;
+
        if (scr->scr_type == NULL)
                scr->scr_type = vd->defaulttype;
        
@@ -336,7 +337,6 @@
        vd->eraserows = ri->ri_ops.eraserows;
        vd->erasecols = ri->ri_ops.erasecols;
        scr->putchar   = ri->ri_ops.putchar;
-       vd->cursor    = ri->ri_ops.cursor;
 
        if (scr->scr_flags & VCONS_NO_COPYCOLS) {
                vd->copycols  = vcons_copycols_noread;
@@ -350,15 +350,16 @@
                vd->copyrows = ri->ri_ops.copyrows;
        }
 
+       if (scr->scr_flags & VCONS_NO_CURSOR) {
+               vd->cursor  = vcons_cursor_noread;
+       } else {
+               vd->cursor = ri->ri_ops.cursor;
+       }
+
        ri->ri_ops.eraserows = vcons_eraserows; 
        ri->ri_ops.erasecols = vcons_erasecols; 
        ri->ri_ops.putchar   = vcons_putchar;
-       if (scr->scr_flags & VCONS_NO_CURSOR) {
-               ri->ri_ops.cursor    = vcons_cursor_noread;
-       } else {
-               ri->ri_ops.cursor    = vcons_cursor;
-       }
-
+       ri->ri_ops.cursor    = vcons_cursor;
        ri->ri_ops.copycols  = vcons_copycols;
        ri->ri_ops.copyrows  = vcons_copyrows;
 
@@ -471,14 +472,17 @@
                vd->copyrows = ri->ri_ops.copyrows;
        }
 
+       if (scr->scr_flags & VCONS_NO_CURSOR) {
+               vd->cursor  = vcons_cursor_noread;
+       } else {
+               vd->cursor = ri->ri_ops.cursor;
+       }
+
        /* and put our wrappers back */
        ri->ri_ops.eraserows = vcons_eraserows; 
        ri->ri_ops.erasecols = vcons_erasecols; 
        ri->ri_ops.putchar   = vcons_putchar;
-       if (scr->scr_flags & VCONS_NO_CURSOR) {
-               ri->ri_ops.cursor    = vcons_cursor_noread;
-       } else
-               ri->ri_ops.cursor    = vcons_cursor;
+       ri->ri_ops.cursor    = vcons_cursor;
        ri->ri_ops.copycols  = vcons_copycols;
        ri->ri_ops.copyrows  = vcons_copyrows;
        vcons_unlock(vd->active);
@@ -955,6 +959,9 @@
                        pos++;
                        ppos++;
                }
+               if (ri->ri_crow == row && 
+                  (ri->ri_ccol >= dstcol && ri->ri_ccol < (dstcol + ncols )))
+                       ri->ri_flg &= ~RI_CURSOR;
        }
        vcons_unlock(scr);
 }
@@ -1130,6 +1137,8 @@
                                ppos++;
                        }
                }
+               if (ri->ri_crow >= dstrow && ri->ri_crow < (dstrow + nrows))
+                       ri->ri_flg &= ~RI_CURSOR;
        }
        vcons_unlock(scr);
 }
@@ -1318,53 +1327,33 @@
 {
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr = ri->ri_hw;
-       int offset = 0; 
-
-#if defined(VCONS_DRAW_INTR)
-       if (scr->scr_vd->use_intr) {
-               vcons_lock(scr);
-               if (scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) {
-                       scr->scr_ri.ri_crow = row;
-                       scr->scr_ri.ri_ccol = col;
-                       atomic_inc_uint(&scr->scr_dirty);
-               }
-               vcons_unlock(scr);
-               return;
-       }
-#endif
-
-       vcons_lock(scr);
+       int offset = 0, ofs;
 
 #ifdef WSDISPLAY_SCROLLSUPPORT
        offset = scr->scr_current_offset;
 #endif
-       if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
-               int ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol;
-               if (on && (ri->ri_flg & RI_CURSOR)) {
-                       scr->putchar(cookie, ri->ri_crow, ri->ri_ccol,
-                           scr->scr_chars[ofs], scr->scr_attrs[ofs]);
-                       ri->ri_flg &= ~RI_CURSOR;
-               }
-               ri->ri_crow = row;
-               ri->ri_ccol = col;
-               ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol;
-               if (on) {
-                       scr->putchar(cookie, row, col, scr->scr_chars[ofs],
+       ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol;
+       if ((ri->ri_flg & RI_CURSOR) && 
+          ((scr->scr_flags & VCONS_DONT_READ) != VCONS_DONT_READ)) {
+               scr->putchar(cookie, ri->ri_crow, ri->ri_ccol,
+                   scr->scr_chars[ofs], scr->scr_attrs[ofs]);
+               ri->ri_flg &= ~RI_CURSOR;
+       }
+       ri->ri_crow = row;
+       ri->ri_ccol = col;
+       ofs = offset + ri->ri_crow * ri->ri_cols + ri->ri_ccol;
+       if (on) {
+               scr->putchar(cookie, row, col, scr->scr_chars[ofs],
 #ifdef VCONS_DEBUG_CURSOR_NOREAD
-                       /* draw a red cursor so we can tell which cursor() 
-                        * implementation is being used */
-                           ((scr->scr_attrs[ofs] & 0xff00ffff) ^ 0x0f000000) |
-                             0x00010000);
+               /* draw a red cursor so we can tell which cursor() 
+                * implementation is being used */
+                   ((scr->scr_attrs[ofs] & 0xff00ffff) ^ 0x0f000000) |
+                     0x00010000);
 #else
-                           scr->scr_attrs[ofs] ^ 0x0f0f0000);
+                   scr->scr_attrs[ofs] ^ 0x0f0f0000);
 #endif
-                       ri->ri_flg |= RI_CURSOR;
-               }
-       } else {
-               scr->scr_ri.ri_crow = row;
-               scr->scr_ri.ri_ccol = col;
+               ri->ri_flg |= RI_CURSOR;
        }
-       vcons_unlock(scr);
 }
 
 /* methods to read/write characters via ioctl() */



Home | Main Index | Thread Index | Old Index