Module Name: src
Committed By: macallan
Date: Tue Feb 14 08:14:02 UTC 2023
Modified Files:
src/sys/dev/wscons: wsdisplay_vcons.c
Log Message:
make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did
To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/wscons/wsdisplay_vcons.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.64 src/sys/dev/wscons/wsdisplay_vcons.c:1.65
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.64 Mon Jul 18 11:09:22 2022
+++ src/sys/dev/wscons/wsdisplay_vcons.c Tue Feb 14 08:14:02 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay_vcons.c,v 1.64 2022/07/18 11:09:22 martin Exp $ */
+/* $NetBSD: wsdisplay_vcons.c,v 1.65 2023/02/14 08:14:02 macallan Exp $ */
/*-
* Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.64 2022/07/18 11:09:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.65 2023/02/14 08:14:02 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -121,7 +121,7 @@ static void vcons_copycols_buffer(void *
static void vcons_erasecols_buffer(void *, int, int, int, long);
static void vcons_copyrows_buffer(void *, int, int, int);
static void vcons_eraserows_buffer(void *, int, int, long);
-static void vcons_putchar_buffer(void *, int, int, u_int, long);
+static int vcons_putchar_buffer(void *, int, int, u_int, long);
/*
* actual wrapper methods which call both the _buffer ones above and the
@@ -1237,22 +1237,25 @@ vcons_eraserows(void *cookie, int row, i
vcons_unlock(scr);
}
-static void
+static int
vcons_putchar_buffer(void *cookie, int row, int col, u_int c, long attr)
{
struct rasops_info *ri = cookie;
struct vcons_screen *scr = ri->ri_hw;
int offset = vcons_offset_to_zero(scr);
- int pos;
+ int pos, ret = 0;
if ((row >= 0) && (row < ri->ri_rows) && (col >= 0) &&
(col < ri->ri_cols)) {
pos = col + row * ri->ri_cols;
+ ret = (scr->scr_attrs[pos + offset] != attr) ||
+ (scr->scr_chars[pos + offset] != c);
scr->scr_attrs[pos + offset] = attr;
scr->scr_chars[pos + offset] = c;
}
- vcons_dirty(scr);
+ if (ret) vcons_dirty(scr);
+ return ret;
}
#ifdef VCONS_DRAW_INTR
@@ -1282,8 +1285,9 @@ vcons_putchar(void *cookie, int row, int
{
struct rasops_info *ri = cookie;
struct vcons_screen *scr = ri->ri_hw;
-
- vcons_putchar_buffer(cookie, row, col, c, attr);
+ int need_draw;
+
+ need_draw = vcons_putchar_buffer(cookie, row, col, c, attr);
if (vcons_use_intr(scr))
return;
@@ -1291,12 +1295,13 @@ vcons_putchar(void *cookie, int row, int
vcons_lock(scr);
if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
#ifdef VCONS_DRAW_INTR
- vcons_putchar_cached(cookie, row, col, c, attr);
+ if (need_draw) vcons_putchar_cached(cookie, row, col, c, attr);
#else
if (row == ri->ri_crow && col == ri->ri_ccol) {
ri->ri_flg &= ~RI_CURSOR;
- }
- scr->putchar(cookie, row, col, c, attr);
+ scr->putchar(cookie, row, col, c, attr);
+ } else if (need_draw)
+ scr->putchar(cookie, row, col, c, attr);
#endif
}
vcons_unlock(scr);