summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2018-08-25 12:23:45 +0000
committerkettenis <kettenis@openbsd.org>2018-08-25 12:23:45 +0000
commit55e28768a49ac85d8784c354b500776502a32922 (patch)
treec2031b8a92b15e54d1d4ec4def1018e03667167d
parentInsert new child nodes at the end. (diff)
downloadwireguard-openbsd-55e28768a49ac85d8784c354b500776502a32922.tar.xz
wireguard-openbsd-55e28768a49ac85d8784c354b500776502a32922.zip
The current rasops cursor implementation simply inverts the appropriate
framebuffer pixels by doing an XOR with an all-ones bit pattern. This means the code has to read from the framebuffer which can be very slow. Add an implementation that simply redraws the character covered by the cursor with the foreground and background color swapped. While this doesn't necessarily have the same visual result, most people probably won't notice the difference (let's see). Use this implementation when the RI_WRONLY or the RI_VCONS flags are set. ok fcambus@
-rw-r--r--sys/dev/rasops/rasops.c61
1 files changed, 44 insertions, 17 deletions
diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c
index 1dc08ad9f2a..e483ff074ad 100644
--- a/sys/dev/rasops/rasops.c
+++ b/sys/dev/rasops/rasops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rasops.c,v 1.54 2018/05/03 10:05:47 jsg Exp $ */
+/* $OpenBSD: rasops.c,v 1.55 2018/08/25 12:23:45 kettenis Exp $ */
/* $NetBSD: rasops.c,v 1.35 2001/02/02 06:01:01 marcus Exp $ */
/*-
@@ -130,6 +130,22 @@ const u_char rasops_isgray[16] = {
0, 0, 0, 1
};
+struct rasops_screen {
+ LIST_ENTRY(rasops_screen) rs_next;
+ struct rasops_info *rs_ri;
+
+ struct wsdisplay_charcell *rs_bs;
+ int rs_visible;
+ int rs_crow;
+ int rs_ccol;
+ long rs_defattr;
+
+ int rs_sbscreens;
+#define RS_SCROLLBACK_SCREENS 5
+ int rs_dispoffset; /* rs_bs index, start of our actual screen */
+ int rs_visibleoffset; /* rs_bs index, current scrollback screen */
+};
+
/* Generic functions */
int rasops_copycols(void *, int, int, int, int);
int rasops_copyrows(void *, int, int, int);
@@ -179,6 +195,7 @@ int rasops_wronly_copycols(void *, int, int, int, int);
int rasops_wronly_erasecols(void *, int, int, int, long);
int rasops_wronly_copyrows(void *, int, int, int);
int rasops_wronly_eraserows(void *, int, int, long);
+int rasops_wronly_do_cursor(struct rasops_info *);
int rasops_add_font(struct rasops_info *, struct wsdisplay_font *);
int rasops_use_font(struct rasops_info *, struct wsdisplay_font *);
@@ -268,6 +285,8 @@ rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
return (-1);
ri->ri_active = cookie;
+ ri->ri_bs =
+ &ri->ri_active->rs_bs[ri->ri_active->rs_dispoffset];
ri->ri_ops.cursor = rasops_vcons_cursor;
ri->ri_ops.mapchar = rasops_vcons_mapchar;
@@ -278,6 +297,7 @@ rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
ri->ri_ops.eraserows = rasops_vcons_eraserows;
ri->ri_ops.alloc_attr = rasops_vcons_alloc_attr;
ri->ri_ops.unpack_attr = rasops_vcons_unpack_attr;
+ ri->ri_do_cursor = rasops_wronly_do_cursor;
} else if ((ri->ri_flg & RI_WRONLY) && ri->ri_bs != NULL) {
long attr;
int i;
@@ -287,6 +307,7 @@ rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
ri->ri_ops.erasecols = rasops_wronly_erasecols;
ri->ri_ops.copyrows = rasops_wronly_copyrows;
ri->ri_ops.eraserows = rasops_wronly_eraserows;
+ ri->ri_do_cursor = rasops_wronly_do_cursor;
ri->ri_alloc_attr(ri, 0, 0, 0, &attr);
for (i = 0; i < ri->ri_rows * ri->ri_cols; i++) {
@@ -1365,22 +1386,6 @@ slow_bcopy(void *s, void *d, size_t len)
}
#endif /* NRASOPS_BSWAP */
-struct rasops_screen {
- LIST_ENTRY(rasops_screen) rs_next;
- struct rasops_info *rs_ri;
-
- struct wsdisplay_charcell *rs_bs;
- int rs_visible;
- int rs_crow;
- int rs_ccol;
- long rs_defattr;
-
- int rs_sbscreens;
-#define RS_SCROLLBACK_SCREENS 5
- int rs_dispoffset; /* rs_bs index, start of our actual screen */
- int rs_visibleoffset; /* rs_bs index, current scrollback screen */
-};
-
int
rasops_alloc_screen(void *v, void **cookiep,
int *curxp, int *curyp, long *attrp)
@@ -1482,6 +1487,7 @@ rasops_doswitch(void *v)
ri->ri_active->rs_visible = 0;
ri->ri_eraserows(ri, 0, ri->ri_rows, scr->rs_defattr);
ri->ri_active = scr;
+ ri->ri_bs = &ri->ri_active->rs_bs[ri->ri_active->rs_dispoffset];
ri->ri_active->rs_visible = 1;
ri->ri_active->rs_visibleoffset = ri->ri_active->rs_dispoffset;
for (row = 0; row < ri->ri_rows; row++) {
@@ -1769,6 +1775,27 @@ rasops_wronly_eraserows(void *cookie, int row, int num, long attr)
return ri->ri_eraserows(ri, row, num, attr);
}
+int
+rasops_wronly_do_cursor(struct rasops_info *ri)
+{
+ int off = ri->ri_crow * ri->ri_cols + ri->ri_ccol;
+ u_int uc;
+ long attr;
+ int fg, bg;
+
+ uc = ri->ri_bs[off].uc;
+ attr = ri->ri_bs[off].attr;
+
+ if ((ri->ri_flg & RI_CURSOR) == 0) {
+ fg = ((u_int)attr >> 24) & 0xf;
+ bg = ((u_int)attr >> 16) & 0xf;
+ attr &= ~0x0ffff0000;
+ attr |= (fg << 16) | (bg << 24);
+ }
+
+ return ri->ri_putchar(ri, ri->ri_crow, ri->ri_ccol, uc, attr);
+}
+
/*
* Font management.
*