mi: Draw multiple lines in one FillSpans call in miZeroLine

miZeroLine allocates enough space to draw a line spanning the entire
width/height of the target drawable. When drawing multiple shorter
lines, this leaves most of the space in that buffer unfilled. Let
multiple lines be drawn into the buffer if there is plenty of space.

Speeds up glamor fallback zero-width lines:

Before
    6000000 trep @   0.0020 msec (508000.0/sec): 1-pixel line
    6000000 trep @   0.0020 msec (492000.0/sec): 10-pixel line
    6000000 trep @   0.0023 msec (427000.0/sec): 100-pixel line
    4000000 trep @   0.0035 msec (282000.0/sec): 500-pixel line

After:
  600000000 trep @   0.0000 msec (43400000.0/sec): 1-pixel line
  140000000 trep @   0.0001 msec (13000000.0/sec): 10-pixel line
   16000000 trep @   0.0008 msec (1300000.0/sec): 100-pixel line
    4000000 trep @   0.0038 msec (261000.0/sec): 500-pixel line

(500 pixel lines do not change in performance because the buffer can
only one one of them.)

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Keith Packard 2014-05-07 10:31:16 -07:00 committed by Eric Anholt
parent ea678a73c5
commit 3ac481c9da
1 changed files with 8 additions and 8 deletions

View File

@ -179,14 +179,6 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
MIOUTCODES(oc2, x2, y2, xleft, ytop, xright, ybottom);
while (--npt > 0) {
if (Nspans > 0)
(*pGC->ops->FillSpans) (pDraw, pGC, Nspans, pspanInit,
pwidthInit, FALSE);
Nspans = 0;
new_span = TRUE;
spans = pspanInit - 1;
widths = pwidthInit - 1;
x1 = x2;
y1 = y2;
oc1 = oc2;
@ -208,6 +200,14 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant);
if (ady + 1 > (list_len - Nspans)) {
(*pGC->ops->FillSpans) (pDraw, pGC, Nspans, pspanInit,
pwidthInit, FALSE);
Nspans = 0;
spans = pspanInit - 1;
widths = pwidthInit - 1;
}
new_span = TRUE;
if (adx > ady) {
e1 = ady << 1;
e2 = e1 - (adx << 1);