Module Name:    src
Committed By:   macallan
Date:           Wed May 25 21:01:04 UTC 2022

Modified Files:
        src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
be lazy about clearing the cursor since most likely we're going to overwrite
it anyway. Same logic as in cgsix.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sparc/dev/cgfourteen.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/arch/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.92 src/sys/arch/sparc/dev/cgfourteen.c:1.93
--- src/sys/arch/sparc/dev/cgfourteen.c:1.92	Fri Dec 17 19:27:57 2021
+++ src/sys/arch/sparc/dev/cgfourteen.c	Wed May 25 21:01:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.92 2021/12/17 19:27:57 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.93 2022/05/25 21:01:04 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1485,6 +1485,10 @@ cg14_putchar(void *cookie, int row, int 
 	if (!CHAR_IN_FONT(c, font))
 		return;
 
+	if (row == ri->ri_crow && col == ri->ri_ccol) {
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+
 	wi = font->fontwidth;
 	he = font->fontheight;
 
@@ -1538,6 +1542,23 @@ cg14_putchar(void *cookie, int row, int 
 }
 
 static void
+cg14_nuke_cursor(struct rasops_info *ri)
+{
+	struct vcons_screen *scr = ri->ri_hw;
+	struct cgfourteen_softc *sc = scr->scr_cookie;
+	int wi, he, x, y;
+		
+	if (ri->ri_flg & RI_CURSOR) {
+		wi = ri->ri_font->fontwidth;
+		he = ri->ri_font->fontheight;
+		x = ri->ri_ccol * wi + ri->ri_xorigin;
+		y = ri->ri_crow * he + ri->ri_yorigin;
+		cg14_invert(sc, x, y, wi, he);
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+}
+
+static void
 cg14_cursor(void *cookie, int on, int row, int col)
 {
 	struct rasops_info *ri = cookie;
@@ -1549,20 +1570,17 @@ cg14_cursor(void *cookie, int on, int ro
 	he = ri->ri_font->fontheight;
 	
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
-		x = ri->ri_ccol * wi + ri->ri_xorigin;
-		y = ri->ri_crow * he + ri->ri_yorigin;
-		if (ri->ri_flg & RI_CURSOR) {
-			cg14_invert(sc, x, y, wi, he);
-			ri->ri_flg &= ~RI_CURSOR;
-		}
-		ri->ri_crow = row;
-		ri->ri_ccol = col;
 		if (on) {
-			x = ri->ri_ccol * wi + ri->ri_xorigin;
-			y = ri->ri_crow * he + ri->ri_yorigin;
+			if (ri->ri_flg & RI_CURSOR) {
+				cg14_nuke_cursor(ri);
+			}
+			x = col * wi + ri->ri_xorigin;
+			y = row * he + ri->ri_yorigin;
 			cg14_invert(sc, x, y, wi, he);
 			ri->ri_flg |= RI_CURSOR;
 		}
+		ri->ri_crow = row;
+		ri->ri_ccol = col;
 	} else {
 		scr->scr_ri.ri_crow = row;
 		scr->scr_ri.ri_ccol = col;
@@ -1590,6 +1608,10 @@ cg14_putchar_aa(void *cookie, int row, i
 	if (!CHAR_IN_FONT(c, font))
 		return;
 
+	if (row == ri->ri_crow && col == ri->ri_ccol) {
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+
 	wi = font->fontwidth;
 	he = font->fontheight;
 
@@ -1692,12 +1714,20 @@ cg14_copycols(void *cookie, int row, int
 	int32_t xs, xd, y, width, height;
 	
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= srccol && ri->ri_ccol < (srccol + ncols)) &&
+		   (ri->ri_flg & RI_CURSOR)) {
+			cg14_nuke_cursor(ri);
+		}
 		xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol;
 		xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol;
 		y = ri->ri_yorigin + ri->ri_font->fontheight * row;
 		width = ri->ri_font->fontwidth * ncols;
 		height = ri->ri_font->fontheight;
 		cg14_bitblt(sc, xs, y, xd, y, width, height, 0x0c);
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= dstcol && ri->ri_ccol < (dstcol + ncols)))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 
@@ -1715,8 +1745,11 @@ cg14_erasecols(void *cookie, int row, in
 		width = ri->ri_font->fontwidth * ncols;
 		height = ri->ri_font->fontheight;
 		rasops_unpack_attr(fillattr, &fg, &bg, &ul);
-
 		cg14_rectfill(sc, x, y, width, height, ri->ri_devcmap[bg]);
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= startcol && ri->ri_ccol < (startcol + ncols)))
+			ri->ri_flg &= ~RI_CURSOR;
+
 	}
 }
 
@@ -1729,12 +1762,18 @@ cg14_copyrows(void *cookie, int srcrow, 
 	int32_t x, ys, yd, width, height;
 
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
+		if ((ri->ri_crow >= srcrow && ri->ri_crow < (srcrow + nrows)) &&
+		   (ri->ri_flg & RI_CURSOR)) {
+			cg14_nuke_cursor(ri);
+		}
 		x = ri->ri_xorigin;
 		ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow;
 		yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow;
 		width = ri->ri_emuwidth;
 		height = ri->ri_font->fontheight * nrows;
 		cg14_bitblt(sc, x, ys, x, yd, width, height, 0x0c);
+		if (ri->ri_crow >= dstrow && ri->ri_crow < (dstrow + nrows))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 
@@ -1752,8 +1791,9 @@ cg14_eraserows(void *cookie, int row, in
 		width = ri->ri_emuwidth;
 		height = ri->ri_font->fontheight * nrows;
 		rasops_unpack_attr(fillattr, &fg, &bg, &ul);
-
 		cg14_rectfill(sc, x, y, width, height, ri->ri_devcmap[bg]);
+		if (ri->ri_crow >= row && ri->ri_crow < (row + nrows))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 

Reply via email to