Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Mar 2014 22:04:28 +0000 (UTC)
From:      Aleksandr Rybalko <ray@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263885 - in head/sys/dev/vt: . hw/vga
Message-ID:  <201403282204.s2SM4SeN001155@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ray
Date: Fri Mar 28 22:04:27 2014
New Revision: 263885
URL: http://svnweb.freebsd.org/changeset/base/263885

Log:
  o Add new vd_driver method to do bitblt with mask, named vd_maskbitbltchr.
  o Move vd_bitbltchr vga's driver method to vd_maskbitbltchr.
  o Implement new vd_bitbltchr method for vga driver. (It do single write for 8
  	pixels, have to be a bit faster).
  
  MFC after:	7 days
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/dev/vt/hw/vga/vga.c
  head/sys/dev/vt/vt.h
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/hw/vga/vga.c
==============================================================================
--- head/sys/dev/vt/hw/vga/vga.c	Fri Mar 28 21:25:19 2014	(r263884)
+++ head/sys/dev/vt/hw/vga/vga.c	Fri Mar 28 22:04:27 2014	(r263885)
@@ -74,6 +74,7 @@ struct vga_softc {
 static vd_init_t	vga_init;
 static vd_blank_t	vga_blank;
 static vd_bitbltchr_t	vga_bitbltchr;
+static vd_maskbitbltchr_t vga_maskbitbltchr;
 static vd_drawrect_t	vga_drawrect;
 static vd_setpixel_t	vga_setpixel;
 static vd_putchar_t	vga_putchar;
@@ -83,6 +84,7 @@ static const struct vt_driver vt_vga_dri
 	.vd_init	= vga_init,
 	.vd_blank	= vga_blank,
 	.vd_bitbltchr	= vga_bitbltchr,
+	.vd_maskbitbltchr = vga_maskbitbltchr,
 	.vd_drawrect	= vga_drawrect,
 	.vd_setpixel	= vga_setpixel,
 	.vd_putchar	= vga_putchar,
@@ -204,6 +206,34 @@ vga_bitbltchr(struct vt_device *vd, cons
     int bpl, vt_axis_t top, vt_axis_t left, unsigned int width,
     unsigned int height, term_color_t fg, term_color_t bg)
 {
+	u_long dst, ldst;
+	int w;
+
+	/* Don't try to put off screen pixels */
+	if (((left + width) > VT_VGA_WIDTH) || ((top + height) >
+	    VT_VGA_HEIGHT))
+		return;
+
+	dst = (VT_VGA_WIDTH * top + left) / 8;
+
+	for (; height > 0; height--) {
+		ldst = dst;
+		for (w = width; w > 0; w -= 8) {
+			vga_bitblt_put(vd, ldst, fg, *src);
+			vga_bitblt_put(vd, ldst, bg, ~*src);
+			ldst++;
+			src++;
+		}
+		dst += VT_VGA_WIDTH / 8;
+	}
+}
+
+/* Bitblt with mask support. Slow. */
+static void
+vga_maskbitbltchr(struct vt_device *vd, const uint8_t *src, const uint8_t *mask,
+    int bpl, vt_axis_t top, vt_axis_t left, unsigned int width,
+    unsigned int height, term_color_t fg, term_color_t bg)
+{
 	struct vga_softc *sc = vd->vd_softc;
 	u_long dst;
 	uint8_t shift;

Modified: head/sys/dev/vt/vt.h
==============================================================================
--- head/sys/dev/vt/vt.h	Fri Mar 28 21:25:19 2014	(r263884)
+++ head/sys/dev/vt/vt.h	Fri Mar 28 22:04:27 2014	(r263885)
@@ -282,6 +282,9 @@ typedef void vd_blank_t(struct vt_device
 typedef void vd_bitbltchr_t(struct vt_device *vd, const uint8_t *src,
     const uint8_t *mask, int bpl, vt_axis_t top, vt_axis_t left,
     unsigned int width, unsigned int height, term_color_t fg, term_color_t bg);
+typedef void vd_maskbitbltchr_t(struct vt_device *vd, const uint8_t *src,
+    const uint8_t *mask, int bpl, vt_axis_t top, vt_axis_t left,
+    unsigned int width, unsigned int height, term_color_t fg, term_color_t bg);
 typedef void vd_putchar_t(struct vt_device *vd, term_char_t,
     vt_axis_t top, vt_axis_t left, term_color_t fg, term_color_t bg);
 typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *);
@@ -298,6 +301,7 @@ struct vt_driver {
 	/* Drawing. */
 	vd_blank_t	*vd_blank;
 	vd_bitbltchr_t	*vd_bitbltchr;
+	vd_maskbitbltchr_t *vd_maskbitbltchr;
 	vd_drawrect_t	*vd_drawrect;
 	vd_setpixel_t	*vd_setpixel;
 

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Fri Mar 28 21:25:19 2014	(r263884)
+++ head/sys/dev/vt/vt_core.c	Fri Mar 28 22:04:27 2014	(r263885)
@@ -775,7 +775,7 @@ vt_flush(struct vt_device *vd)
 		if ((vd->vd_my + m->h) > (size.tp_row * vf->vf_height))
 			h = (size.tp_row * vf->vf_height) - vd->vd_my - 1;
 
-		vd->vd_driver->vd_bitbltchr(vd, m->map, m->mask, bpl,
+		vd->vd_driver->vd_maskbitbltchr(vd, m->map, m->mask, bpl,
 		    vd->vd_offset.tp_row + vd->vd_my,
 		    vd->vd_offset.tp_col + vd->vd_mx,
 		    w, h, TC_WHITE, TC_BLACK);
@@ -1930,6 +1930,8 @@ vt_allocate(struct vt_driver *drv, void 
 		printf("%s: Replace existing VT driver.\n", __func__);
 	}
 	vd = main_vd;
+	if (drv->vd_maskbitbltchr == NULL)
+		drv->vd_maskbitbltchr = drv->vd_bitbltchr;
 
 	/* Stop vt_flush periodic task. */
 	if (vd->vd_curwindow != NULL)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403282204.s2SM4SeN001155>