Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Apr 2017 14:00:14 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316830 - head/sys/dev/syscons
Message-ID:  <201704141400.v3EE0Eo8053721@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Fri Apr 14 14:00:13 2017
New Revision: 316830
URL: https://svnweb.freebsd.org/changeset/base/316830

Log:
  Optimize drawing of the mouse cursor in vga planar mode almost as
  much as possible, by avoiding null ANDs and ORs to the frame buffer.
  
  Mouse cursors are fairly sparse, especially for their frame.  Pixels
  are written in groups of 8 in planar mode and the per-group sparseness
  is not as large, but it still averages about 40% with the current
  9x13 mouse cursor.  The average drawing time is reduced by about this
  amount (from 22 usec constant to 12.5 usec average on Haswell).
  
  This optimization is relatively larger with larger cursors.  Width 10
  requires 6 frame buffer accesses per line instead of 4 if not done
  sparsely, but rarely more than 4 if done sparsely.

Modified:
  head/sys/dev/syscons/scvgarndr.c

Modified: head/sys/dev/syscons/scvgarndr.c
==============================================================================
--- head/sys/dev/syscons/scvgarndr.c	Fri Apr 14 13:25:45 2017	(r316829)
+++ head/sys/dev/syscons/scvgarndr.c	Fri Apr 14 14:00:13 2017	(r316830)
@@ -1032,6 +1032,7 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 	int ymax;
 	u_short m;
 	int i, j, k;
+	uint8_t m1;
 
 	line_width = scp->sc->adp->va_line_width;
 	xoff = (x - scp->xoff*8)%8;
@@ -1046,9 +1047,10 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 	for (i = y, j = 0; i < ymax; ++i, ++j) {
 		m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) >> xoff);
 		for (k = 0; k < 2; ++k) {
-			if (x + 8 * k < scp->xpixel) {
+			m1 = m >> (8 * (1 - k));
+			if (m1 != 0xff && x + 8 * k < scp->xpixel) {
 				readb(p + k);
-				writeb(p + k, m >> (8 * (1 - k)));
+				writeb(p + k, m1);
  			}
 		}
 		p += line_width;
@@ -1058,9 +1060,10 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 	for (i = y, j = 0; i < ymax; ++i, ++j) {
 		m = mouse_or_mask[j] >> xoff;
 		for (k = 0; k < 2; ++k) {
-			if (x + 8 * k < scp->xpixel) {
+			m1 = m >> (8 * (1 - k));
+			if (m1 != 0 && x + 8 * k < scp->xpixel) {
 				readb(p + k);
-				writeb(p + k, m >> (8 * (1 - k)));
+				writeb(p + k, m1);
 			}
 		}
 		p += line_width;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704141400.v3EE0Eo8053721>