From owner-svn-src-head@freebsd.org Wed Apr 12 17:06:25 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 5B5D2D3B147; Wed, 12 Apr 2017 17:06:25 +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 2AE77E69; Wed, 12 Apr 2017 17:06:25 +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 v3CH6Oa5040244; Wed, 12 Apr 2017 17:06:24 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3CH6OTM040243; Wed, 12 Apr 2017 17:06:24 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201704121706.v3CH6OTM040243@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 12 Apr 2017 17:06:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316735 - 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, 12 Apr 2017 17:06:25 -0000 Author: bde Date: Wed Apr 12 17:06:24 2017 New Revision: 316735 URL: https://svnweb.freebsd.org/changeset/base/316735 Log: Fix removing of the mouse image in vga planar mode with 8x8 fonts, and reduce hard-coded assumptions on font sizes so that the cursor size can be more independent of the font size. Moving the mouse in the buggy mode left trails of garbage. The mouse cursor currently has size 9x13 in all modes. This can occupy 2x3 character cells with 8x8 fonts, but the algorithm was hard-coded for only 2x2 character cells. Rearrange to hard-code only a maximum cursor size (now 10x16) and to not hard-code in the logic. The number of cells needed is now over-estimated in some cases. 2x3 character cells should also be used in text mode with 8x8 fonts (except with large pixels, the cursor size should be reduced), but hard-coding for 2x2 in the implementation makes it not very easy to expand, and it practice it shifts out bits to reduce to 2x2. In graphics modes, expansion is easier and there is no shifting out for 9x13 cursors (but 9 is a limit for hard-coding for 2 8-bit VGA cells wide). A previous commit removed the same buggy hard-coding for removal at a lower level in planar mode. Another previous commit fixed the much larger code for lower-level removal in direct mode; this is independent of the font size so worked for 8x8 fonts. Text mode always depended on the higher-level removal here, and always worked since everything was hard-coded consistently for 2x2 character cells. Modified: head/sys/dev/syscons/scmouse.c Modified: head/sys/dev/syscons/scmouse.c ============================================================================== --- head/sys/dev/syscons/scmouse.c Wed Apr 12 16:28:40 2017 (r316734) +++ head/sys/dev/syscons/scmouse.c Wed Apr 12 17:06:24 2017 (r316735) @@ -232,30 +232,33 @@ sc_draw_mouse_image(scr_stat *scp) void sc_remove_mouse_image(scr_stat *scp) { - int size; - int i; + int cols, i, rows; if (ISGRAPHSC(scp)) return; SC_VIDEO_LOCK(scp->sc); - (*scp->rndr->draw_mouse)(scp, - (scp->mouse_oldpos%scp->xsize + scp->xoff) - * scp->font_width, - (scp->mouse_oldpos/scp->xsize + scp->yoff) - * scp->font_size, + (*scp->rndr->draw_mouse)(scp, scp->mouse_oldxpos, scp->mouse_oldypos, FALSE); - size = scp->xsize*scp->ysize; + /* + * To simplify the renderer and ensure undrawing with correct + * attributes, mark for update a region containing the cursor + * (usually 2x2 character cells joined by almost a full line o + * character cells). + * + * The renderer should only undraw any pixels outside of the text + * window (e.g., ones in borders and hardware cursors). + */ i = scp->mouse_oldpos; mark_for_update(scp, i); mark_for_update(scp, i); - if (i + scp->xsize + 1 < size) { - mark_for_update(scp, i + scp->xsize + 1); - } else if (i + scp->xsize < size) { - mark_for_update(scp, i + scp->xsize); - } else if (i + 1 < size) { - mark_for_update(scp, i + 1); - } + cols = 1 + howmany(10 - 1, scp->font_width); /* up to VGA cursor width 9 */ + cols = imax(cols, 2); /* in case it is text mode 2x2 char cells */ + cols = imin(cols, scp->xsize - i % scp->xsize); + rows = 1 + howmany(16 - 1, scp->font_size); /* up to VGA cursor height 16 */ + rows = imax(rows, 2); /* don't bother reducing 3 to 2 if text */ + rows = imin(rows, scp->ysize - i / scp->xsize); + mark_for_update(scp, i + (rows - 1) * scp->xsize + cols - 1); scp->status &= ~MOUSE_VISIBLE; SC_VIDEO_UNLOCK(scp->sc); }