From owner-svn-src-all@FreeBSD.ORG Wed Aug 27 15:10:29 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CF767573; Wed, 27 Aug 2014 15:10:29 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 B0ABA3EA3; Wed, 27 Aug 2014 15:10:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7RFATrv018620; Wed, 27 Aug 2014 15:10:29 GMT (envelope-from dumbbell@FreeBSD.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7RFATwQ018617; Wed, 27 Aug 2014 15:10:29 GMT (envelope-from dumbbell@FreeBSD.org) Message-Id: <201408271510.s7RFATwQ018617@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dumbbell set sender to dumbbell@FreeBSD.org using -f From: Jean-Sebastien Pedron Date: Wed, 27 Aug 2014 15:10:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270720 - in head/sys/dev: fb vt/hw/fb vt/hw/ofwfb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Aug 2014 15:10:29 -0000 Author: dumbbell Date: Wed Aug 27 15:10:28 2014 New Revision: 270720 URL: http://svnweb.freebsd.org/changeset/base/270720 Log: vt(4): Fix mouse cursor handling in vt_fb/creator_vt/ofwfb There were two issues: 1. The area given to vt_is_cursor_in_area() was adding the drawable area offset, something already handled by this function. 2. The cursor was shifted on the screen by the offset of this area and thus was misplaced or not erased. Furthermore, when reaching the bottom or right borders, the cursor was either totally removed or not erased correctly. MFC after: 1 week Modified: head/sys/dev/fb/creator_vt.c head/sys/dev/vt/hw/fb/vt_fb.c head/sys/dev/vt/hw/ofwfb/ofwfb.c Modified: head/sys/dev/fb/creator_vt.c ============================================================================== --- head/sys/dev/fb/creator_vt.c Wed Aug 27 14:25:18 2014 (r270719) +++ head/sys/dev/fb/creator_vt.c Wed Aug 27 15:10:28 2014 (r270720) @@ -186,21 +186,20 @@ creatorfb_bitblt_bitmap(struct vt_device struct creatorfb_softc *sc = vd->vd_softc; u_long line; uint32_t fgc, bgc; - int c; + int c, l; uint8_t b, m; fgc = sc->fb.fb_cmap[fg]; bgc = sc->fb.fb_cmap[bg]; b = m = 0; - /* Don't try to put off screen pixels */ - if (((x + width) > vd->vd_width) || ((y + height) > - vd->vd_height)) - return; - line = (sc->fb.fb_stride * y) + 4*x; - for (; height > 0; height--) { - for (c = 0; c < width; c++) { + for (l = 0; + l < height && y + l < vw->vw_draw_area.tr_end.tp_row; + l++) { + for (c = 0; + c < width && x + c < vw->vw_draw_area.tr_end.tp_col; + c++) { if (c % 8 == 0) b = *pattern++; else @@ -258,20 +257,17 @@ creatorfb_bitblt_text(struct vt_device * term_rect_t drawn_area; - drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; - drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; + drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width; + drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height; + drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width; + drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height; if (vt_is_cursor_in_area(vd, &drawn_area)) { creatorfb_bitblt_bitmap(vd, vw, vd->vd_mcursor->map, vd->vd_mcursor->mask, vd->vd_mcursor->width, vd->vd_mcursor->height, - vd->vd_mx_drawn, vd->vd_my_drawn, + vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col, + vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row, vd->vd_mcursor_fg, vd->vd_mcursor_bg); } #endif Modified: head/sys/dev/vt/hw/fb/vt_fb.c ============================================================================== --- head/sys/dev/vt/hw/fb/vt_fb.c Wed Aug 27 14:25:18 2014 (r270719) +++ head/sys/dev/vt/hw/fb/vt_fb.c Wed Aug 27 15:10:28 2014 (r270720) @@ -263,17 +263,16 @@ vt_fb_bitblt_bitmap(struct vt_device *vd b = m = 0; bpl = (width + 7) >> 3; /* Bytes per source line. */ - /* Don't try to put off screen pixels */ - if (((x + width) > info->fb_width) || ((y + height) > - info->fb_height)) - return; - KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer")); line = (info->fb_stride * y) + (x * bpp); - for (l = 0; l < height; l++) { + for (l = 0; + l < height && y + l < vw->vw_draw_area.tr_end.tp_row; + l++) { ch = pattern; - for (c = 0; c < width; c++) { + for (c = 0; + c < width && x + c < vw->vw_draw_area.tr_end.tp_col; + c++) { if (c % 8 == 0) b = *ch++; else @@ -353,20 +352,17 @@ vt_fb_bitblt_text(struct vt_device *vd, term_rect_t drawn_area; - drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; - drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; + drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width; + drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height; + drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width; + drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height; if (vt_is_cursor_in_area(vd, &drawn_area)) { vt_fb_bitblt_bitmap(vd, vw, vd->vd_mcursor->map, vd->vd_mcursor->mask, vd->vd_mcursor->width, vd->vd_mcursor->height, - vd->vd_mx_drawn, vd->vd_my_drawn, + vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col, + vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row, vd->vd_mcursor_fg, vd->vd_mcursor_bg); } #endif Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c ============================================================================== --- head/sys/dev/vt/hw/ofwfb/ofwfb.c Wed Aug 27 14:25:18 2014 (r270719) +++ head/sys/dev/vt/hw/ofwfb/ofwfb.c Wed Aug 27 15:10:28 2014 (r270720) @@ -110,7 +110,7 @@ ofwfb_bitblt_bitmap(struct vt_device *vd struct fb_info *sc = vd->vd_softc; u_long line; uint32_t fgc, bgc; - int c; + int c, l; uint8_t b, m; union { uint32_t l; @@ -121,13 +121,13 @@ ofwfb_bitblt_bitmap(struct vt_device *vd bgc = sc->fb_cmap[bg]; b = m = 0; - /* Don't try to put off screen pixels */ - if (((x + width) > vd->vd_width) || ((y + height) > - vd->vd_height)) - return; - line = (sc->fb_stride * y) + x * sc->fb_bpp/8; if (mask == NULL && sc->fb_bpp == 8 && (width % 8 == 0)) { + /* Don't try to put off screen pixels */ + if (((x + width) > vd->vd_width) || ((y + height) > + vd->vd_height)) + return; + for (; height > 0; height--) { for (c = 0; c < width; c += 8) { b = *pattern++; @@ -160,8 +160,12 @@ ofwfb_bitblt_bitmap(struct vt_device *vd line += sc->fb_stride; } } else { - for (; height > 0; height--) { - for (c = 0; c < width; c++) { + for (l = 0; + l < height && y + l < vw->vw_draw_area.tr_end.tp_row; + l++) { + for (c = 0; + c < width && x + c < vw->vw_draw_area.tr_end.tp_col; + c++) { if (c % 8 == 0) b = *pattern++; else @@ -231,20 +235,17 @@ ofwfb_bitblt_text(struct vt_device *vd, term_rect_t drawn_area; - drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; - drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; + drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width; + drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height; + drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width; + drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height; if (vt_is_cursor_in_area(vd, &drawn_area)) { ofwfb_bitblt_bitmap(vd, vw, vd->vd_mcursor->map, vd->vd_mcursor->mask, vd->vd_mcursor->width, vd->vd_mcursor->height, - vd->vd_mx_drawn, vd->vd_my_drawn, + vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col, + vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row, vd->vd_mcursor_fg, vd->vd_mcursor_bg); } #endif