Module Name:    src
Committed By:   macallan
Date:           Tue Jan 26 16:24:18 UTC 2021

Modified Files:
        src/sys/dev/wscons: wsdisplay_vcons.c

Log Message:
- 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


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/wscons/wsdisplay_vcons.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.49 src/sys/dev/wscons/wsdisplay_vcons.c:1.50
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.49	Mon Jan 25 02:11:41 2021
+++ src/sys/dev/wscons/wsdisplay_vcons.c	Tue Jan 26 16:24:17 2021
@@ -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 @@ vcons_init_screen(struct vcons_data *vd,
 	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 @@ vcons_init_screen(struct vcons_data *vd,
 	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 @@ vcons_init_screen(struct vcons_data *vd,
 		vd->copyrows = ri->ri_ops.copyrows;
 	}
 
-	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;
+		vd->cursor  = vcons_cursor_noread;
 	} else {
-		ri->ri_ops.cursor    = vcons_cursor;
+		vd->cursor = ri->ri_ops.cursor;
 	}
 
+	ri->ri_ops.eraserows = vcons_eraserows;	
+	ri->ri_ops.erasecols = vcons_erasecols;	
+	ri->ri_ops.putchar   = vcons_putchar;
+	ri->ri_ops.cursor    = vcons_cursor;
 	ri->ri_ops.copycols  = vcons_copycols;
 	ri->ri_ops.copyrows  = vcons_copyrows;
 
@@ -471,14 +472,17 @@ vcons_load_font(void *v, void *cookie, s
 		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 @@ vcons_copycols_noread(void *cookie, int 
 			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 @@ vcons_copyrows_noread(void *cookie, int 
 				ppos++;
 			}
 		}
+		if (ri->ri_crow >= dstrow && ri->ri_crow < (dstrow + nrows))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 	vcons_unlock(scr);
 }
@@ -1318,53 +1327,33 @@ vcons_cursor_noread(void *cookie, int on
 {
 	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() */

Reply via email to