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.
This commit is contained in:
parent
6d4377c1ae
commit
a5126f539e
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user