Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Aug 2014 14:31:53 +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: r270331 - in head/sys/dev/vt: . hw/vga
Message-ID:  <201408221431.s7MEVrHU075483@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dumbbell
Date: Fri Aug 22 14:31:53 2014
New Revision: 270331
URL: http://svnweb.freebsd.org/changeset/base/270331

Log:
  vt(4): Store cursor bitmap & colors in struct vt_device
  
  This removes the need to specify them to each call to vd_bitblt_text_t
  and, therefore, simplifies the API.
  
  MFC after:	1 week

Modified:
  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/vt/hw/vga/vt_vga.c
==============================================================================
--- head/sys/dev/vt/hw/vga/vt_vga.c	Fri Aug 22 14:27:41 2014	(r270330)
+++ head/sys/dev/vt/hw/vga/vt_vga.c	Fri Aug 22 14:31:53 2014	(r270331)
@@ -521,12 +521,8 @@ vga_bitblt_pixels_block_ncolors(struct v
 
 static void
 vga_bitblt_one_text_pixels_block(struct vt_device *vd, const struct vt_buf *vb,
-    const struct vt_font *vf, unsigned int x, unsigned int y
-#ifndef SC_NO_CUTPASTE
-    , const struct vt_mouse_cursor *cursor,
-    term_color_t cursor_fg, term_color_t cursor_bg
-#endif
-    )
+    const struct vt_font *vf, unsigned int x, unsigned int y,
+    int cursor_displayed)
 {
 	unsigned int i, col, row, src_x, x_count;
 	unsigned int used_colors_list[16], used_colors;
@@ -536,6 +532,7 @@ vga_bitblt_one_text_pixels_block(struct 
 	term_color_t fg, bg;
 	const uint8_t *src;
 #ifndef SC_NO_CUTPASTE
+	struct vt_mouse_cursor *cursor;
 	unsigned int mx, my;
 #endif
 
@@ -629,9 +626,10 @@ vga_bitblt_one_text_pixels_block(struct 
 	 * the current position could be different than the one used
 	 * to mark the area dirty.
 	 */
+	cursor = vd->vd_mcursor;
 	mx = vd->vd_moldx + vd->vd_offset.tp_col;
 	my = vd->vd_moldy + vd->vd_offset.tp_row;
-	if (cursor != NULL &&
+	if (cursor_displayed &&
 	    ((mx >= x && x + VT_VGA_PIXELS_BLOCK - 1 >= mx) ||
 	     (mx < x && mx + cursor->width >= x)) &&
 	    ((my >= y && y + vf->vf_height - 1 >= my) ||
@@ -660,11 +658,11 @@ vga_bitblt_one_text_pixels_block(struct 
 		vga_copy_bitmap_portion(pattern_2colors, pattern_ncolors,
 		    cursor->map, cursor->mask, cursor->width,
 		    src_x, dst_x, x_count, src_y, dst_y, y_count,
-		    cursor_fg, cursor_bg, 1);
+		    vd->vd_mcursor_fg, vd->vd_mcursor_bg, 1);
 
-		if ((used_colors_list[cursor_fg] & 0x1) != 0x1)
+		if ((used_colors_list[vd->vd_mcursor_fg] & 0x1) != 0x1)
 			used_colors++;
-		if ((used_colors_list[cursor_bg] & 0x2) != 0x2)
+		if ((used_colors_list[vd->vd_mcursor_bg] & 0x2) != 0x2)
 			used_colors++;
 	}
 #endif
@@ -683,12 +681,7 @@ vga_bitblt_one_text_pixels_block(struct 
 
 static void
 vga_bitblt_text_gfxmode(struct vt_device *vd, const struct vt_buf *vb,
-    const struct vt_font *vf, const term_rect_t *area
-#ifndef SC_NO_CUTPASTE
-    , const struct vt_mouse_cursor *cursor,
-    term_color_t cursor_fg, term_color_t cursor_bg
-#endif
-    )
+    const struct vt_font *vf, const term_rect_t *area, int cursor_displayed)
 {
 	unsigned int col, row;
 	unsigned int x1, y1, x2, y2, x, y;
@@ -770,23 +763,15 @@ vga_bitblt_text_gfxmode(struct vt_device
 
 	for (y = y1; y < y2; y += vf->vf_height) {
 		for (x = x1; x < x2; x += VT_VGA_PIXELS_BLOCK) {
-			vga_bitblt_one_text_pixels_block(vd, vb, vf, x, y
-#ifndef SC_NO_CUTPASTE
-			    , cursor, cursor_fg, cursor_bg
-#endif
-			    );
+			vga_bitblt_one_text_pixels_block(vd, vb, vf, x, y,
+			    cursor_displayed);
 		}
 	}
 }
 
 static void
 vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_buf *vb,
-    const term_rect_t *area
-#ifndef SC_NO_CUTPASTE
-    , const struct vt_mouse_cursor *cursor,
-    term_color_t cursor_fg, term_color_t cursor_bg
-#endif
-    )
+    const term_rect_t *area, int cursor_displayed)
 {
 	struct vga_softc *sc;
 	unsigned int col, row;
@@ -828,26 +813,13 @@ vga_bitblt_text_txtmode(struct vt_device
 
 static void
 vga_bitblt_text(struct vt_device *vd, const struct vt_buf *vb,
-    const struct vt_font *vf, const term_rect_t *area
-#ifndef SC_NO_CUTPASTE
-    , const struct vt_mouse_cursor *cursor,
-    term_color_t cursor_fg, term_color_t cursor_bg
-#endif
-    )
+    const struct vt_font *vf, const term_rect_t *area, int cursor_displayed)
 {
 
 	if (!(vd->vd_flags & VDF_TEXTMODE)) {
-		vga_bitblt_text_gfxmode(vd, vb, vf, area
-#ifndef SC_NO_CUTPASTE
-		    , cursor, cursor_fg, cursor_bg
-#endif
-		    );
+		vga_bitblt_text_gfxmode(vd, vb, vf, area, cursor_displayed);
 	} else {
-		vga_bitblt_text_txtmode(vd, vb, area
-#ifndef SC_NO_CUTPASTE
-		    , cursor, cursor_fg, cursor_bg
-#endif
-		    );
+		vga_bitblt_text_txtmode(vd, vb, area, cursor_displayed);
 	}
 }
 

Modified: head/sys/dev/vt/vt.h
==============================================================================
--- head/sys/dev/vt/vt.h	Fri Aug 22 14:27:41 2014	(r270330)
+++ head/sys/dev/vt/vt.h	Fri Aug 22 14:31:53 2014	(r270331)
@@ -115,6 +115,10 @@ typedef unsigned int 	vt_axis_t;
  * Per-device datastructure.
  */
 
+#ifndef SC_NO_CUTPASTE
+struct vt_mouse_cursor;
+#endif
+
 struct vt_device {
 	struct vt_window	*vd_windows[VT_MAXWINDOWS]; /* (c) Windows. */
 	struct vt_window	*vd_curwindow;	/* (d) Current window. */
@@ -122,6 +126,11 @@ struct vt_device {
 	struct vt_window	*vd_markedwin;	/* (?) Copy/paste buf owner. */
 	const struct vt_driver	*vd_driver;	/* (c) Graphics driver. */
 	void			*vd_softc;	/* (u) Driver data. */
+#ifndef SC_NO_CUTPASTE
+	struct vt_mouse_cursor	*vd_mcursor;	/* (?) Cursor bitmap. */
+	term_color_t		 vd_mcursor_fg;	/* (?) Cursor fg color. */
+	term_color_t		 vd_mcursor_bg;	/* (?) Cursor bg color. */
+#endif
 	uint16_t		 vd_mx;		/* (?) Current mouse X. */
 	uint16_t		 vd_my;		/* (?) current mouse Y. */
 	vt_axis_t		 vd_moldx;	/* (?) Mouse X as of last redraw. */
@@ -280,15 +289,6 @@ struct vt_window {
  * Per-device driver routines.
  */
 
-#ifndef SC_NO_CUTPASTE
-struct vt_mouse_cursor {
-	uint8_t map[64 * 64 / 8];
-	uint8_t mask[64 * 64 / 8];
-	uint8_t width;
-	uint8_t height;
-};
-#endif
-
 typedef int vd_init_t(struct vt_device *vd);
 typedef int vd_probe_t(struct vt_device *vd);
 typedef void vd_postswitch_t(struct vt_device *vd);
@@ -303,12 +303,7 @@ typedef void vd_bitbltchr_t(struct vt_de
 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 void vd_bitblt_text_t(struct vt_device *vd, const struct vt_buf *vb,
-    const struct vt_font *vf, const term_rect_t *area
-#ifndef SC_NO_CUTPASTE
-    , const struct vt_mouse_cursor *cursor,
-    term_color_t cursor_fg, term_color_t cursor_bg
-#endif
-    );
+    const struct vt_font *vf, const term_rect_t *area, int cursor_displayed);
 typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *);
 typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int,
     vm_memattr_t *);
@@ -394,6 +389,15 @@ struct vt_font {
 	unsigned int		 vf_refcount;
 };
 
+#ifndef SC_NO_CUTPASTE
+struct vt_mouse_cursor {
+	uint8_t map[64 * 64 / 8];
+	uint8_t mask[64 * 64 / 8];
+	uint8_t width;
+	uint8_t height;
+};
+#endif
+
 const uint8_t	*vtfont_lookup(const struct vt_font *vf, term_char_t c);
 struct vt_font	*vtfont_ref(struct vt_font *vf);
 void		 vtfont_unref(struct vt_font *vf);

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Fri Aug 22 14:27:41 2014	(r270330)
+++ head/sys/dev/vt/vt_core.c	Fri Aug 22 14:31:53 2014	(r270331)
@@ -162,6 +162,12 @@ static struct vt_device	vt_consdev = {
 	.vd_curwindow = &vt_conswindow,
 	.vd_markedwin = NULL,
 	.vd_kbstate = 0,
+
+#ifndef SC_NO_CUTPASTE
+	.vd_mcursor = &vt_default_mouse_pointer,
+	.vd_mcursor_fg = TC_WHITE,
+	.vd_mcursor_bg = TC_BLACK,
+#endif
 };
 static term_char_t vt_constextbuf[(_VTDEFW) * (VBF_DEFAULT_HISTORY_SIZE)];
 static term_char_t *vt_constextbufrows[VBF_DEFAULT_HISTORY_SIZE];
@@ -852,8 +858,8 @@ vt_flush(struct vt_device *vd)
 	term_rect_t tarea;
 	term_pos_t size;
 	term_char_t *r;
+	int cursor_displayed;
 #ifndef SC_NO_CUTPASTE
-	struct vt_mouse_cursor *cursor;
 	int bpl, h, w;
 #endif
 
@@ -867,8 +873,9 @@ vt_flush(struct vt_device *vd)
 	if (vd->vd_flags & VDF_SPLASH || vw->vw_flags & VWF_BUSY)
 		return;
 
+	cursor_displayed = 0;
+
 #ifndef SC_NO_CUTPASTE
-	cursor = NULL;
 	if ((vd->vd_flags & VDF_MOUSECURSOR) && /* Mouse support enabled. */
 	    !(vw->vw_flags & VWF_MOUSE_HIDE)) { /* Cursor displayed.      */
 		if (vd->vd_moldx != vd->vd_mx ||
@@ -904,7 +911,7 @@ vt_flush(struct vt_device *vd)
 
 		if (!kdb_active && panicstr == NULL) {
 			/* Mouse enabled, and DDB isn't active. */
-			cursor = &vt_default_mouse_pointer;
+			cursor_displayed = 1;
 
 			/* Mark new mouse position as dirty. */
 			vtbuf_mouse_cursor_position(&vw->vw_buf,
@@ -928,11 +935,8 @@ vt_flush(struct vt_device *vd)
 
 	if (vd->vd_driver->vd_bitblt_text != NULL) {
 		if (tarea.tr_begin.tp_col < tarea.tr_end.tp_col) {
-			vd->vd_driver->vd_bitblt_text(vd, &vw->vw_buf, vf, &tarea
-#ifndef SC_NO_CUTPASTE
-			    , cursor, TC_WHITE, TC_BLACK
-#endif
-			    );
+			vd->vd_driver->vd_bitblt_text(vd, &vw->vw_buf, vf,
+			    &tarea, cursor_displayed);
 		}
 	} else {
 		/*
@@ -954,22 +958,24 @@ vt_flush(struct vt_device *vd)
 		}
 
 #ifndef SC_NO_CUTPASTE
-		if (cursor != NULL) {
-			bpl = (cursor->width + 7) >> 3; /* Bytes per source line. */
-			w = cursor->width;
-			h = cursor->height;
+		if (cursor_displayed) {
+			/* Bytes per source line. */
+			bpl = (vd->vd_mcursor->width + 7) >> 3;
+			w = vd->vd_mcursor->width;
+			h = vd->vd_mcursor->height;
 
-			if ((vd->vd_mx + cursor->width) >
+			if ((vd->vd_mx + vd->vd_mcursor->width) >
 			    (size.tp_col * vf->vf_width))
 				w = (size.tp_col * vf->vf_width) - vd->vd_mx - 1;
-			if ((vd->vd_my + cursor->height) >
+			if ((vd->vd_my + vd->vd_mcursor->height) >
 			    (size.tp_row * vf->vf_height))
 				h = (size.tp_row * vf->vf_height) - vd->vd_my - 1;
 
-			vd->vd_driver->vd_bitbltchr(vd, cursor->map, cursor->mask, bpl,
+			vd->vd_driver->vd_bitbltchr(vd,
+			    vd->vd_mcursor->map, vd->vd_mcursor->mask, bpl,
 			    vd->vd_offset.tp_row + vd->vd_my,
 			    vd->vd_offset.tp_col + vd->vd_mx,
-			    w, h, TC_WHITE, TC_BLACK);
+			    w, h, vd->vd_mcursor_fg, vd->vd_mcursor_bg);
 		}
 #endif
 	}



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