Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Apr 2017 17:57:24 +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: r317264 - head/sys/dev/syscons
Message-ID:  <201704211757.v3LHvOj3019417@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Fri Apr 21 17:57:23 2017
New Revision: 317264
URL: https://svnweb.freebsd.org/changeset/base/317264

Log:
  Optimize setting of the foreground color in the main planar method much
  like for the background color.
  
  This is a about 5% faster for output that actually reaches the screen.

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

Modified: head/sys/dev/syscons/scvgarndr.c
==============================================================================
--- head/sys/dev/syscons/scvgarndr.c	Fri Apr 21 17:42:48 2017	(r317263)
+++ head/sys/dev/syscons/scvgarndr.c	Fri Apr 21 17:57:23 2017	(r317264)
@@ -736,7 +736,7 @@ vga_vgadraw_planar(scr_stat *scp, int fr
 	vm_offset_t d;
 	vm_offset_t e;
 	u_char *f;
-	u_short bg;
+	u_short bg, fg;
 	u_short col1, col2;
 	int line_width;
 	int i, j;
@@ -754,7 +754,7 @@ vga_vgadraw_planar(scr_stat *scp, int fr
 		outw(GDCIDX, 0x0005);	/* read mode 0, write mode 0 */
 	outw(GDCIDX, 0x0003);		/* data rotate/function select */
 	outw(GDCIDX, 0x0f01);		/* set/reset enable */
-	bg = -1;
+	fg = bg = -1;
 	if (from + count > scp->xsize*scp->ysize)
 		count = scp->xsize*scp->ysize - from;
 	for (i = from; count-- > 0; ++i) {
@@ -769,6 +769,7 @@ vga_vgadraw_planar(scr_stat *scp, int fr
 		/* set background color in EGA/VGA latch */
 		if (bg != col2) {
 			bg = col2;
+			fg = -1;
 			outw(GDCIDX, bg | 0x00); /* set/reset */
 			if (scp->sc->adp->va_type != KD_VGA)
 				outw(GDCIDX, 0xff08); /* bit mask */
@@ -776,7 +777,10 @@ vga_vgadraw_planar(scr_stat *scp, int fr
 			c = readb(d);		/* set bg color in the latch */
 		}
 		/* foreground color */
-		outw(GDCIDX, col1 | 0x00);	/* set/reset */
+		if (fg != col1) {
+			fg = col1;
+			outw(GDCIDX, col1 | 0x00); /* set/reset */
+		}
 		e = d;
 		f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
 		for (j = 0; j < scp->font_size; ++j, ++f) {



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