From owner-svn-src-head@freebsd.org Wed Apr 19 16:24:52 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 784D5D38232; Wed, 19 Apr 2017 16:24:52 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 55716403; Wed, 19 Apr 2017 16:24:52 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3JGOp1K086845; Wed, 19 Apr 2017 16:24:51 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3JGOpNZ086844; Wed, 19 Apr 2017 16:24:51 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201704191624.v3JGOpNZ086844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 19 Apr 2017 16:24:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317150 - head/sys/dev/syscons X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2017 16:24:52 -0000 Author: bde Date: Wed Apr 19 16:24:51 2017 New Revision: 317150 URL: https://svnweb.freebsd.org/changeset/base/317150 Log: Stop using a saveunder method for mouse cursor drawing in the vga direct mode renderer. I thought that reads were not much slower than writes, so that the method only tripled the time for the whole function, but I recently measured that video memory reads can be up to 53 times slower than writes in tighter loops than here. Loop overheap here reduces the multiplier to only 16-20 on Haswell. Start cleaning up and fixing larger bugs in this function. Only replace the 22-line removal loop by a 3-line one for now, since adjusting the old loop would have required many palette calculations which are better done in the DRAW_PIXEL() macro. This also fixes missing support for depth 24, but only for removal. Removal is currently sloppy at the right bottom corner. It sometimes leaks border color into the text window. This is soon cleaned up by the caller. The planar renderer has complications to clip at the corner. Modified: head/sys/dev/syscons/scvgarndr.c Modified: head/sys/dev/syscons/scvgarndr.c ============================================================================== --- head/sys/dev/syscons/scvgarndr.c Wed Apr 19 16:16:41 2017 (r317149) +++ head/sys/dev/syscons/scvgarndr.c Wed Apr 19 16:24:51 2017 (r317150) @@ -238,12 +238,6 @@ static uint16_t vga_palette15[16] = { 0x0000, 0x0016, 0x02c0, 0x02d6, 0x5800, 0x5816, 0x5940, 0x5ad6, 0x294a, 0x295f, 0x2bea, 0x2bff, 0x7d4a, 0x7d5f, 0x7fea, 0x7fff }; - -#ifndef SC_NO_CUTPASTE -static uint32_t mouse_buf32[256]; -static uint16_t mouse_buf16[256]; -static uint8_t mouse_buf8[256]; -#endif #endif static void @@ -1132,8 +1126,6 @@ vga_pxlmouse_direct(scr_stat *scp, int x vm_offset_t p; int line_width, pixel_size; int xend, yend; - static int x_old = 0, xend_old = 0; - static int y_old = 0, yend_old = 0; int i, j; uint32_t *u32; uint16_t *u16; @@ -1163,39 +1155,12 @@ vga_pxlmouse_direct(scr_stat *scp, int x if (on) goto do_on; - /* - * Repaint overlap with the border and nearby. Unlike in the planar - * case, we kept track of everything under the cursor so can restore - * it all, but we don't completely trust the saved state to be still - * relevant, so do nothing if it is obviously stale. - */ - if (x != x_old || y != y_old || xend != xend_old || yend != yend_old) - return; - - p = scp->sc->adp->va_window + y_old * line_width + x_old * pixel_size; - - for (i = 0; i < (yend_old - y_old); i++) { - for (j = (xend_old - x_old - 1); j >= 0; j--) { - switch (bpp) { - case 32: - u32 = (uint32_t*)(p + j * pixel_size); - writel(u32, mouse_buf32[i * 16 + j]); - break; - case 16: - /* FALLTHROUGH */ - case 15: - u16 = (uint16_t*)(p + j * pixel_size); - writew(u16, mouse_buf16[i * 16 + j]); - break; - case 8: - u8 = (uint8_t*)(p + j * pixel_size); - writeb(u8, mouse_buf8[i * 16 + j]); - break; - } - } + /* Repaint overlap with the border (mess up the corner a little). */ + p = scp->sc->adp->va_window + y * line_width + x * pixel_size; + for (i = 0; i < yend - y; i++, p += line_width) + for (j = xend - x - 1; j >= 0; j--) + DRAW_PIXEL(scp, p + j * pixel_size, scp->border); - p += line_width; - } return; do_on: @@ -1206,7 +1171,6 @@ do_on: switch (bpp) { case 32: u32 = (uint32_t*)(p + j * pixel_size); - mouse_buf32[i * 16 + j] = *u32; if (mdp->md_interior[i] & (1 << (15 - j))) writel(u32, vga_palette32[15]); else if (mdp->md_border[i] & (1 << (15 - j))) @@ -1214,7 +1178,6 @@ do_on: break; case 16: u16 = (uint16_t*)(p + j * pixel_size); - mouse_buf16[i * 16 + j] = *u16; if (mdp->md_interior[i] & (1 << (15 - j))) writew(u16, vga_palette16[15]); else if (mdp->md_border[i] & (1 << (15 - j))) @@ -1222,7 +1185,6 @@ do_on: break; case 15: u16 = (uint16_t*)(p + j * pixel_size); - mouse_buf16[i * 16 + j] = *u16; if (mdp->md_interior[i] & (1 << (15 - j))) writew(u16, vga_palette15[15]); else if (mdp->md_border[i] & (1 << (15 - j))) @@ -1230,7 +1192,6 @@ do_on: break; case 8: u8 = (uint8_t*)(p + j * pixel_size); - mouse_buf8[i * 16 + j] = *u8; if (mdp->md_interior[i] & (1 << (15 - j))) writeb(u8, 15); else if (mdp->md_border[i] & (1 << (15 - j))) @@ -1241,11 +1202,6 @@ do_on: p += line_width; } - - x_old = x; - y_old = y; - xend_old = xend; - yend_old = yend; } static void