From ed04063907b4fe05bac7fb6a1975425725d72bc0 Mon Sep 17 00:00:00 2001 From: dumbbell Date: Fri, 22 Aug 2014 10:49:51 +0000 Subject: [PATCH] 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 --- sys/dev/vt/hw/vga/vt_vga.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c index ccfa4ea71007..7b0141cfd7ea 100644 --- a/sys/dev/vt/hw/vga/vt_vga.c +++ b/sys/dev/vt/hw/vga/vt_vga.c @@ -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