aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/syscons
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2017-04-14 14:00:13 +0000
committerBruce Evans <bde@FreeBSD.org>2017-04-14 14:00:13 +0000
commita5126f539e292c87138597a7c499b4ac09389ee7 (patch)
tree989e12d4044a7aef99888af56bd724fa4529fae8 /sys/dev/syscons
parent6d4377c1aedeeab20ed505283eed9b57fcade4c9 (diff)
downloadsrc-a5126f539e292c87138597a7c499b4ac09389ee7.tar.gz
src-a5126f539e292c87138597a7c499b4ac09389ee7.zip
Optimize drawing of the mouse cursor in vga planar mode almost as
much as possible, by avoiding null ANDs and ORs to the frame buffer. Mouse cursors are fairly sparse, especially for their frame. Pixels are written in groups of 8 in planar mode and the per-group sparseness is not as large, but it still averages about 40% with the current 9x13 mouse cursor. The average drawing time is reduced by about this amount (from 22 usec constant to 12.5 usec average on Haswell). This optimization is relatively larger with larger cursors. Width 10 requires 6 frame buffer accesses per line instead of 4 if not done sparsely, but rarely more than 4 if done sparsely.
Notes
Notes: svn path=/head/; revision=316830
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r--sys/dev/syscons/scvgarndr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/dev/syscons/scvgarndr.c b/sys/dev/syscons/scvgarndr.c
index 8450deb74c9c..9e4867b8b7e4 100644
--- a/sys/dev/syscons/scvgarndr.c
+++ b/sys/dev/syscons/scvgarndr.c
@@ -1032,6 +1032,7 @@ draw_pxlmouse_planar(scr_stat *scp, int x, int y)
int ymax;
u_short m;
int i, j, k;
+ uint8_t m1;
line_width = scp->sc->adp->va_line_width;
xoff = (x - scp->xoff*8)%8;
@@ -1046,9 +1047,10 @@ draw_pxlmouse_planar(scr_stat *scp, int x, int y)
for (i = y, j = 0; i < ymax; ++i, ++j) {
m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) >> xoff);
for (k = 0; k < 2; ++k) {
- if (x + 8 * k < scp->xpixel) {
+ m1 = m >> (8 * (1 - k));
+ if (m1 != 0xff && x + 8 * k < scp->xpixel) {
readb(p + k);
- writeb(p + k, m >> (8 * (1 - k)));
+ writeb(p + k, m1);
}
}
p += line_width;
@@ -1058,9 +1060,10 @@ draw_pxlmouse_planar(scr_stat *scp, int x, int y)
for (i = y, j = 0; i < ymax; ++i, ++j) {
m = mouse_or_mask[j] >> xoff;
for (k = 0; k < 2; ++k) {
- if (x + 8 * k < scp->xpixel) {
+ m1 = m >> (8 * (1 - k));
+ if (m1 != 0 && x + 8 * k < scp->xpixel) {
readb(p + k);
- writeb(p + k, m >> (8 * (1 - k)));
+ writeb(p + k, m1);
}
}
p += line_width;