vt_vga: Clip the draw area to never draw offscreen

This fixes a bug when two windows use different fonts, but a longer-term
solution is required. The dirty area should be stored as pixels, not
character cells, because such coordinates don't have the same meaning in
all windows, when using different fonts.

MFC after:	1 week
This commit is contained in:
Jean-Sébastien Pédron 2014-08-22 10:49:51 +00:00
parent bdcaf97c3e
commit 37fcd2911e

View File

@ -740,6 +740,19 @@ vga_bitblt_text_gfxmode(struct vt_device *vd, const struct vt_buf *vb,
* VT_VGA_PIXELS_BLOCK;
y2 = row * vf->vf_height + vd->vd_offset.tp_row;
/*
* Clip the area to the screen size.
*
* FIXME: The problem with handling the dirty area in character
* cells is that when using different fonts, the dirty area was
* possibly calculated with a different font than the one we use
* here, leading to out-of-screen coordinates. The dirty area
* should be stored in pixels.
*/
x2 = min(x2, vd->vd_width - 1);
y2 = min(y2, vd->vd_height - 1);
/*
* Now, we take care of N pixels line at a time (the first for
* loop, N = font height), and for these lines, draw one pixels