From 5136f041de676d1f4fb1b03551eb934faf8a046d Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 7 Feb 2014 12:39:58 +0000 Subject: [PATCH] Implement vd_drawrect and vd_setpixel for vt(9)'s VGA driver. Sponsored by: The FreeBSD Foundation --- sys/dev/vt/hw/vga/vga.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sys/dev/vt/hw/vga/vga.c b/sys/dev/vt/hw/vga/vga.c index 6d4eb5e86506..e98918f29457 100644 --- a/sys/dev/vt/hw/vga/vga.c +++ b/sys/dev/vt/hw/vga/vga.c @@ -74,6 +74,8 @@ struct vga_softc { static vd_init_t vga_init; static vd_blank_t vga_blank; static vd_bitbltchr_t vga_bitbltchr; +static vd_drawrect_t vga_drawrect; +static vd_setpixel_t vga_setpixel; static vd_putchar_t vga_putchar; static vd_postswitch_t vga_postswitch; @@ -81,6 +83,8 @@ static const struct vt_driver vt_vga_driver = { .vd_init = vga_init, .vd_blank = vga_blank, .vd_bitbltchr = vga_bitbltchr, + .vd_drawrect = vga_drawrect, + .vd_setpixel = vga_setpixel, .vd_putchar = vga_putchar, .vd_postswitch = vga_postswitch, .vd_priority = VD_PRIORITY_GENERIC, @@ -139,6 +143,31 @@ vga_bitblt_put(struct vt_device *vd, u_long dst, term_color_t color, } } +static void +vga_setpixel(struct vt_device *vd, int x, int y, term_color_t color) +{ + + vga_bitblt_put(vd, (y * VT_VGA_WIDTH / 8) + (x / 8), color, + 0x80 >> (x % 8)); +} + +static void +vga_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, + term_color_t color) +{ + int x, y; + + for (y = y1; y <= y2; y++) { + if (fill || (y == y1) || (y == y2)) { + for (x = x1; x <= x2; x++) + vga_setpixel(vd, x, y, color); + } else { + vga_setpixel(vd, x1, y, color); + vga_setpixel(vd, x2, y, color); + } + } +} + static inline void vga_bitblt_draw(struct vt_device *vd, const uint8_t *src, u_long ldst, uint8_t shift, unsigned int width, unsigned int height,