Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Apr 2017 18:35:34 +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: r317157 - head/sys/dev/syscons
Message-ID:  <201704191835.v3JIZYk2040822@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Wed Apr 19 18:35:34 2017
New Revision: 317157
URL: https://svnweb.freebsd.org/changeset/base/317157

Log:
  Fix missing support for drawing the mouse cursor in depth 24 of direct
  mode.
  
  Use the general DRAWPIXEL() macro with its bigger case statement
  (twice) instead of our big case statement (once).  DRAWPIXEL() is more
  complicated since it is not missing support for depth 24 or
  complications for colors in depth 16 (we currently hard-code black and
  white so the complications for colors are not needed).  DRAWPIXEL()
  also does the bpp calculation in the inner loop.  Compilers optimize
  DRAWPIXEL() well enough, and the main text drawing method always
  depended on this.  In direct mode, mouse cursor drawing is now similar
  to normal text drawing except it draws in 2 hard-coded colors instead
  of 1 variable color.
  
  This also fixes a nested hard-coding of colors.  DRAWPIXEL() uses the
  palette in all cases, but the direct code didn't use the palette for
  its hard-coded black.  This only had an effect in depth 8, since
  changing the palette is not supported in other depths.

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

Modified: head/sys/dev/syscons/scvgarndr.c
==============================================================================
--- head/sys/dev/syscons/scvgarndr.c	Wed Apr 19 18:11:08 2017	(r317156)
+++ head/sys/dev/syscons/scvgarndr.c	Wed Apr 19 18:35:34 2017	(r317157)
@@ -1127,10 +1127,6 @@ vga_pxlmouse_direct(scr_stat *scp, int x
 	int line_width, pixel_size;
 	int xend, yend;
 	int i, j;
-	uint32_t *u32;
-	uint16_t *u16;
-	uint8_t  *u8;
-	int bpp;
 
 	mdp = (scp->font_size < 14) ? &mouse9x13 : &mouse10x16;
 
@@ -1144,11 +1140,6 @@ vga_pxlmouse_direct(scr_stat *scp, int x
 	    yend <= (scp->yoff + scp->ysize) * scp->font_size)
 		return;
 
-	bpp = scp->sc->adp->va_info.vi_depth;
-
-	if ((bpp == 16) && (scp->sc->adp->va_info.vi_pixel_fsizes[1] == 5))
-		bpp = 15;
-
 	line_width = scp->sc->adp->va_line_width;
 	pixel_size = scp->sc->adp->va_info.vi_pixel_size;
 
@@ -1165,43 +1156,12 @@ vga_pxlmouse_direct(scr_stat *scp, int x
 
 do_on:
 	p = scp->sc->adp->va_window + y * line_width + x * pixel_size;
-
-	for (i = 0; i < (yend - y); i++) {
-		for (j = (xend - x - 1); j >= 0; j--) {
-			switch (bpp) {
-			case 32:
-				u32 = (uint32_t*)(p + j * pixel_size);
-				if (mdp->md_interior[i] & (1 << (15 - j)))
-					writel(u32, vga_palette32[15]);
-				else if (mdp->md_border[i] & (1 << (15 - j)))
-					writel(u32, 0);
-				break;
-			case 16:
-				u16 = (uint16_t*)(p + j * pixel_size);
-				if (mdp->md_interior[i] & (1 << (15 - j)))
-					writew(u16, vga_palette16[15]);
-				else if (mdp->md_border[i] & (1 << (15 - j)))
-					writew(u16, 0);
-				break;
-			case 15:
-				u16 = (uint16_t*)(p  + j * pixel_size);
-				if (mdp->md_interior[i] & (1 << (15 - j)))
-					writew(u16, vga_palette15[15]);
-				else if (mdp->md_border[i] & (1 << (15 - j)))
-					writew(u16, 0);
-				break;
-			case 8:
-				u8 = (uint8_t*)(p + j * pixel_size);
-				if (mdp->md_interior[i] & (1 << (15 - j)))
-					writeb(u8, 15);
-				else if (mdp->md_border[i] & (1 << (15 - j)))
-					writeb(u8, 0);
-				break;
-			}
-		}
-
-		p += line_width;
-	}
+	for (i = 0; i < yend - y; i++, p += line_width)
+		for (j = xend - x - 1; j >= 0; j--)
+			if (mdp->md_interior[i] & (1 << (15 - j)))
+				DRAW_PIXEL(scp, p + j * pixel_size, 15);
+			else if (mdp->md_border[i] & (1 << (15 - j)))
+				DRAW_PIXEL(scp, p + j * pixel_size, 0);
 }
 
 static void 



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