Date: Mon, 25 Aug 2014 19:06:31 +0000 (UTC) From: Jean-Sebastien Pedron <dumbbell@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270613 - in head/sys/dev: fb vt vt/hw/fb vt/hw/ofwfb vt/hw/vga Message-ID: <201408251906.s7PJ6Vnq076021@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dumbbell Date: Mon Aug 25 19:06:31 2014 New Revision: 270613 URL: http://svnweb.freebsd.org/changeset/base/270613 Log: vt(4): Store a rectangle for the drawable area, not just the top-left corner This allows backends to verify they do not draw outside of this area. This fixes a bug in vt_vga where the text was happily drawn over the right and bottom margins, when using the Gallant font. 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 head/sys/dev/vt/hw/vga/vt_vga.c head/sys/dev/vt/vt.h head/sys/dev/vt/vt_core.c Modified: head/sys/dev/fb/creator_vt.c ============================================================================== --- head/sys/dev/fb/creator_vt.c Mon Aug 25 18:52:51 2014 (r270612) +++ head/sys/dev/fb/creator_vt.c Mon Aug 25 19:06:31 2014 (r270613) @@ -236,8 +236,10 @@ creatorfb_bitblt_text(struct vt_device * for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col; ++col) { - x = col * vf->vf_width + vw->vw_offset.tp_col; - y = row * vf->vf_height + vw->vw_offset.tp_row; + x = col * vf->vf_width + + vw->vw_draw_area.tr_begin.tp_col; + y = row * vf->vf_height + + vw->vw_draw_area.tr_begin.tp_row; c = VTBUF_GET_FIELD(&vw->vw_buf, row, col); pattern = vtfont_lookup(vf, c); @@ -257,13 +259,13 @@ 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_offset.tp_col; + vw->vw_draw_area.tr_begin.tp_col; drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height + - vw->vw_offset.tp_row; + vw->vw_draw_area.tr_begin.tp_row; drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width + - vw->vw_offset.tp_col; + vw->vw_draw_area.tr_begin.tp_col; drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height + - vw->vw_offset.tp_row; + vw->vw_draw_area.tr_begin.tp_row; if (vt_is_cursor_in_area(vd, &drawn_area)) { creatorfb_bitblt_bitmap(vd, vw, Modified: head/sys/dev/vt/hw/fb/vt_fb.c ============================================================================== --- head/sys/dev/vt/hw/fb/vt_fb.c Mon Aug 25 18:52:51 2014 (r270612) +++ head/sys/dev/vt/hw/fb/vt_fb.c Mon Aug 25 19:06:31 2014 (r270613) @@ -331,8 +331,10 @@ vt_fb_bitblt_text(struct vt_device *vd, for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col; ++col) { - x = col * vf->vf_width + vw->vw_offset.tp_col; - y = row * vf->vf_height + vw->vw_offset.tp_row; + x = col * vf->vf_width + + vw->vw_draw_area.tr_begin.tp_col; + y = row * vf->vf_height + + vw->vw_draw_area.tr_begin.tp_row; c = VTBUF_GET_FIELD(&vw->vw_buf, row, col); pattern = vtfont_lookup(vf, c); @@ -352,13 +354,13 @@ 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_offset.tp_col; + vw->vw_draw_area.tr_begin.tp_col; drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height + - vw->vw_offset.tp_row; + vw->vw_draw_area.tr_begin.tp_row; drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width + - vw->vw_offset.tp_col; + vw->vw_draw_area.tr_begin.tp_col; drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height + - vw->vw_offset.tp_row; + vw->vw_draw_area.tr_begin.tp_row; if (vt_is_cursor_in_area(vd, &drawn_area)) { vt_fb_bitblt_bitmap(vd, vw, Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c ============================================================================== --- head/sys/dev/vt/hw/ofwfb/ofwfb.c Mon Aug 25 18:52:51 2014 (r270612) +++ head/sys/dev/vt/hw/ofwfb/ofwfb.c Mon Aug 25 19:06:31 2014 (r270613) @@ -209,8 +209,10 @@ ofwfb_bitblt_text(struct vt_device *vd, for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col; ++col) { - x = col * vf->vf_width + vw->vw_offset.tp_col; - y = row * vf->vf_height + vw->vw_offset.tp_row; + x = col * vf->vf_width + + vw->vw_draw_area.tr_begin.tp_col; + y = row * vf->vf_height + + vw->vw_draw_area.tr_begin.tp_row; c = VTBUF_GET_FIELD(&vw->vw_buf, row, col); pattern = vtfont_lookup(vf, c); @@ -230,13 +232,13 @@ 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_offset.tp_col; + vw->vw_draw_area.tr_begin.tp_col; drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height + - vw->vw_offset.tp_row; + vw->vw_draw_area.tr_begin.tp_row; drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width + - vw->vw_offset.tp_col; + vw->vw_draw_area.tr_begin.tp_col; drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height + - vw->vw_offset.tp_row; + vw->vw_draw_area.tr_begin.tp_row; if (vt_is_cursor_in_area(vd, &drawn_area)) { ofwfb_bitblt_bitmap(vd, vw, Modified: head/sys/dev/vt/hw/vga/vt_vga.c ============================================================================== --- head/sys/dev/vt/hw/vga/vt_vga.c Mon Aug 25 18:52:51 2014 (r270612) +++ head/sys/dev/vt/hw/vga/vt_vga.c Mon Aug 25 19:06:31 2014 (r270613) @@ -556,16 +556,17 @@ vga_bitblt_one_text_pixels_block(struct memset(pattern_2colors, 0, sizeof(pattern_2colors)); memset(pattern_ncolors, 0, sizeof(pattern_ncolors)); - if (i < vw->vw_offset.tp_col) { + if (i < vw->vw_draw_area.tr_begin.tp_col) { /* * i is in the margin used to center the text area on * the screen. */ - i = vw->vw_offset.tp_col; + i = vw->vw_draw_area.tr_begin.tp_col; } - while (i < x + VT_VGA_PIXELS_BLOCK) { + while (i < x + VT_VGA_PIXELS_BLOCK && + i < vw->vw_draw_area.tr_end.tp_col) { /* * Find which character is drawn on this pixel in the * pixels block. @@ -573,8 +574,8 @@ vga_bitblt_one_text_pixels_block(struct * While here, record what colors it uses. */ - col = (i - vw->vw_offset.tp_col) / vf->vf_width; - row = (y - vw->vw_offset.tp_row) / vf->vf_height; + col = (i - vw->vw_draw_area.tr_begin.tp_col) / vf->vf_width; + row = (y - vw->vw_draw_area.tr_begin.tp_row) / vf->vf_height; c = VTBUF_GET_FIELD(vb, row, col); src = vtfont_lookup(vf, c); @@ -605,11 +606,15 @@ vga_bitblt_one_text_pixels_block(struct * character. */ - src_x = i - (col * vf->vf_width + vw->vw_offset.tp_col); - x_count = min( - (col + 1) * vf->vf_width + vw->vw_offset.tp_col, - x + VT_VGA_PIXELS_BLOCK); - x_count -= col * vf->vf_width + vw->vw_offset.tp_col; + src_x = i - + (col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col); + x_count = min(min( + (col + 1) * vf->vf_width + + vw->vw_draw_area.tr_begin.tp_col, + x + VT_VGA_PIXELS_BLOCK), + vw->vw_draw_area.tr_end.tp_col); + x_count -= col * vf->vf_width + + vw->vw_draw_area.tr_begin.tp_col; x_count -= src_x; /* Copy a portion of the character. */ @@ -643,14 +648,16 @@ vga_bitblt_one_text_pixels_block(struct unsigned int dst_x, src_y, dst_y, y_count; cursor = vd->vd_mcursor; - mx = vd->vd_mx_drawn + vw->vw_offset.tp_col; - my = vd->vd_my_drawn + vw->vw_offset.tp_row; + mx = vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col; + my = vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row; /* Compute the portion of the cursor we want to copy. */ src_x = x > mx ? x - mx : 0; dst_x = mx > x ? mx - x : 0; - x_count = min( - min(cursor->width - src_x, x + VT_VGA_PIXELS_BLOCK - mx), + x_count = min(min(min( + cursor->width - src_x, + x + VT_VGA_PIXELS_BLOCK - mx), + vw->vw_draw_area.tr_end.tp_col - mx), VT_VGA_PIXELS_BLOCK); /* @@ -725,10 +732,10 @@ vga_bitblt_text_gfxmode(struct vt_device col = area->tr_begin.tp_col; row = area->tr_begin.tp_row; - x1 = (int)((col * vf->vf_width + vw->vw_offset.tp_col) + x1 = (int)((col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col) / VT_VGA_PIXELS_BLOCK) * VT_VGA_PIXELS_BLOCK; - y1 = row * vf->vf_height + vw->vw_offset.tp_row; + y1 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; /* * Compute the bottom right pixel position, again, aligned with @@ -740,19 +747,15 @@ vga_bitblt_text_gfxmode(struct vt_device col = area->tr_end.tp_col; row = area->tr_end.tp_row; - x2 = (int)((col * vf->vf_width + vw->vw_offset.tp_col + x2 = (int)((col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col + VT_VGA_PIXELS_BLOCK - 1) / VT_VGA_PIXELS_BLOCK) * VT_VGA_PIXELS_BLOCK; - y2 = row * vf->vf_height + vw->vw_offset.tp_row; + y2 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; - /* - * Clip the area to the screen size. - * - * FIXME: Take vw_offset into account. - */ - x2 = min(x2, vd->vd_width - 1); - y2 = min(y2, vd->vd_height - 1); + /* Clip the area to the screen size. */ + x2 = min(x2, vw->vw_draw_area.tr_end.tp_col); + y2 = min(y2, vw->vw_draw_area.tr_end.tp_row); /* * Now, we take care of N pixels line at a time (the first for Modified: head/sys/dev/vt/vt.h ============================================================================== --- head/sys/dev/vt/vt.h Mon Aug 25 18:52:51 2014 (r270612) +++ head/sys/dev/vt/vt.h Mon Aug 25 19:06:31 2014 (r270613) @@ -258,7 +258,7 @@ struct vt_window { struct terminal *vw_terminal; /* (c) Terminal. */ struct vt_buf vw_buf; /* (u) Screen buffer. */ struct vt_font *vw_font; /* (d) Graphical font. */ - term_pos_t vw_offset; /* (?) Pixel offset. */ + term_rect_t vw_draw_area; /* (?) Drawable area. */ unsigned int vw_number; /* (c) Window number. */ int vw_kbdmode; /* (?) Keyboard mode. */ char *vw_kbdsq; /* Escape sequence queue*/ Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Mon Aug 25 18:52:51 2014 (r270612) +++ head/sys/dev/vt/vt_core.c Mon Aug 25 19:06:31 2014 (r270613) @@ -828,8 +828,8 @@ vt_is_cursor_in_area(const struct vt_dev * We use the cursor position saved during the current refresh, * in case the cursor moved since. */ - mx = vd->vd_mx_drawn + vd->vd_curwindow->vw_offset.tp_col; - my = vd->vd_my_drawn + vd->vd_curwindow->vw_offset.tp_row; + mx = vd->vd_mx_drawn + vd->vd_curwindow->vw_draw_area.tr_begin.tp_col; + my = vd->vd_my_drawn + vd->vd_curwindow->vw_draw_area.tr_begin.tp_row; x1 = area->tr_begin.tp_col; y1 = area->tr_begin.tp_row; @@ -1202,8 +1202,8 @@ vt_set_border(struct vt_window *vw, stru x = vd->vd_width - 1; y = vd->vd_height - 1; - off_x = vw->vw_offset.tp_col; - off_y = vw->vw_offset.tp_row; + off_x = vw->vw_draw_area.tr_begin.tp_col; + off_y = vw->vw_draw_area.tr_begin.tp_row; /* Top bar. */ if (off_y > 0) @@ -1257,9 +1257,17 @@ vt_change_font(struct vt_window *vw, str vt_termsize(vd, vf, &size); vt_winsize(vd, vf, &wsz); - /* Save offset to font aligned area. */ - vw->vw_offset.tp_col = (vd->vd_width % vf->vf_width) / 2; - vw->vw_offset.tp_row = (vd->vd_height % vf->vf_height) / 2; + + /* + * Compute the drawable area, so that the text is centered on + * the screen. + */ + vw->vw_draw_area.tr_begin.tp_col = (vd->vd_width % vf->vf_width) / 2; + vw->vw_draw_area.tr_begin.tp_row = (vd->vd_height % vf->vf_height) / 2; + vw->vw_draw_area.tr_end.tp_col = vw->vw_draw_area.tr_begin.tp_col + + vd->vd_width / vf->vf_width * vf->vf_width; + vw->vw_draw_area.tr_end.tp_row = vw->vw_draw_area.tr_begin.tp_row + + vd->vd_height / vf->vf_height * vf->vf_height; /* Grow the screen buffer and terminal. */ terminal_mute(tm, 1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408251906.s7PJ6Vnq076021>