Date: Wed, 12 Apr 2017 18:52:06 +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: r316737 - head/sys/dev/syscons Message-ID: <201704121852.v3CIq6Gm085860@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bde Date: Wed Apr 12 18:52:06 2017 New Revision: 316737 URL: https://svnweb.freebsd.org/changeset/base/316737 Log: Fix removal of mouse image by the vga planar renderer in the right border in unusual cases. Optimize and significantly clean up removal in this renderer. Optimize removal in the vga direct renderer. Removal only needs to be done in the border (the part with pixels) in both cases. The planar renderer used the condition scp->xoff > 0 to test whether a right border exists. This actually tests for a left border, and when the total horizontal border is 8 pixels, rounding gives only a right border. This was the unusual broken case. An example is easy to configure using something like "vidcontrol -f 8x16 iso-8x16 -g 79x25 MODE_27". Optimize the planar case a little by only removing 9x13 active pixels out of 16x16. Optimize it a lot by not doing anything if there is no overlap with the border. Don't unroll the main loop or hard-code so many assumptions about font sizes in it. On my Haswell system, graphics memory and i/o accesses takes about 520 cycles each so optimizations from unrolling are in the noise. Optimize the direct case to not do anything if there is no overlap with the border. Do a sanity check on the saveunder's coordinates. This requires a previous change to pass non-rounded coordinates. Modified: head/sys/dev/syscons/scvgarndr.c Modified: head/sys/dev/syscons/scvgarndr.c ============================================================================== --- head/sys/dev/syscons/scvgarndr.c Wed Apr 12 17:38:00 2017 (r316736) +++ head/sys/dev/syscons/scvgarndr.c Wed Apr 12 18:52:06 2017 (r316737) @@ -159,6 +159,8 @@ RENDERER_MODULE(vga, vga_set); #ifndef SC_NO_CUTPASTE #if !defined(SC_ALT_MOUSE_IMAGE) || defined(SC_PIXEL_MODE) +#define MOUSE_IMAGE_HEIGHT 13 +#define MOUSE_IMAGE_WIDTH 9 static u_short mouse_and_mask[16] = { 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000 @@ -1100,49 +1102,31 @@ static void remove_pxlmouse_planar(scr_stat *scp, int x, int y) { vm_offset_t p; - int col, row; - int line_width; - int ymax; - int i; + int bx, by, i, line_width, xend, xoff, yend, yoff; /* - * The caller will remove parts of the mouse image over the text - * window better than we can do. Remove only parts over the border. + * It is only necessary to remove the mouse image where it overlaps + * the border. Determine the overlap, and do nothing if it is empty. */ - col = x/8 - scp->xoff; - row = y/scp->font_size - scp->yoff; + bx = (scp->xoff + scp->xsize) * 8; + by = (scp->yoff + scp->ysize) * scp->font_size; + xend = imin(x + MOUSE_IMAGE_WIDTH, scp->xpixel); + yend = imin(y + MOUSE_IMAGE_HEIGHT, scp->ypixel); + if (xend <= bx && yend <= by) + return; + + /* Repaint the non-empty overlap. */ line_width = scp->sc->adp->va_line_width; outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ outw(GDCIDX, 0x0f01); /* set/reset enable */ outw(GDCIDX, 0xff08); /* bit mask */ outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */ - if (row == scp->ysize - 1) { - i = (scp->ysize + scp->yoff)*scp->font_size; - ymax = imin(i + scp->font_size, scp->ypixel); - p = scp->sc->adp->va_window + i*line_width + scp->xoff + col; - if (col < scp->xsize - 1) { - for (; i < ymax; ++i) { - writeb(p, 0); - writeb(p + 1, 0); - p += line_width; - } - } else { - for (; i < ymax; ++i) { - writeb(p, 0); - p += line_width; - } - } - } - if ((col == scp->xsize - 1) && (scp->xoff > 0)) { - i = (row + scp->yoff)*scp->font_size; - ymax = imin(i + scp->font_size*2, scp->ypixel); - p = scp->sc->adp->va_window + i*line_width - + scp->xoff + scp->xsize; - for (; i < ymax; ++i) { + for (i = x / 8, xoff = i * 8; xoff < xend; ++i, xoff += 8) { + yoff = (xoff >= bx) ? y : by; + p = scp->sc->adp->va_window + yoff * line_width + i; + for (; yoff < yend; ++yoff, p += line_width) writeb(p, 0); - p += line_width; - } } outw(GDCIDX, 0x0000); /* set/reset */ outw(GDCIDX, 0x0001); /* set/reset enable */ @@ -1162,6 +1146,16 @@ vga_pxlmouse_direct(scr_stat *scp, int x uint8_t *u8; int bpp; + /* + * Determine overlap with the border and then if removing, do nothing + * if the overlap is empty. + */ + xend = imin(x + 16, scp->xpixel); + yend = imin(y + 16, scp->ypixel); + if (!on && xend <= (scp->xoff + scp->xsize) * 8 && + 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)) @@ -1170,12 +1164,18 @@ vga_pxlmouse_direct(scr_stat *scp, int x line_width = scp->sc->adp->va_line_width; pixel_size = scp->sc->adp->va_info.vi_pixel_size; - xend = imin(x + 16, scp->xpixel); - yend = imin(y + 16, scp->ypixel); - 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++) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704121852.v3CIq6Gm085860>