Blame SOURCES/0003-miarc-Cache-arc-span-data-for-dashed-arcs.patch

4724a4
From 0d7f05ed99b71a4641415c9f26e245c3bb24a9a0 Mon Sep 17 00:00:00 2001
4724a4
From: Adam Jackson <ajax@redhat.com>
4724a4
Date: Wed, 1 Mar 2017 16:13:59 -0500
4724a4
Subject: [PATCH 3/3] miarc: "Cache" arc span data for dashed arcs
4724a4
4724a4
This avoids recomputing the span data for every dash. x11perf thinks
4724a4
this is a pretty modest speedup:
4724a4
4724a4
    832919.4       840471.1 ( 1.009)   100-pixel dashed ellipse
4724a4
    672353.1       680652.2 ( 1.012)   100-pixel double-dashed ellipse
4724a4
     13748.9        24287.9 ( 1.767)   100-pixel wide dashed ellipse
4724a4
      9236.3        21298.2 ( 2.306)   100-pixel wide double-dashed ellipse
4724a4
4724a4
But part of the reason it's so modest there is that the arcs are
4724a4
relatively small (100 pixel diameter at line width 10, so ~6000 pixels)
4724a4
and the dashes relatively large (30 on 20 off so ~6 dashes per
4724a4
quadrant).
4724a4
4724a4
With larger arcs and finer dashes this is much more impressive. A fairly
4724a4
trivial testcase of a single 15000x13000 arc with the default {2, 2}
4724a4
dash pattern drops from ~3500 milliseconds to 10 milliseconds.
4724a4
4724a4
Reviewed-by: Keith Packard <keithp@keithp.com>
4724a4
Signed-off-by: Adam Jackson <ajax@redhat.com>
4724a4
---
4724a4
 mi/miarc.c | 12 +++++++++++-
4724a4
 1 file changed, 11 insertions(+), 1 deletion(-)
4724a4
4724a4
diff --git a/mi/miarc.c b/mi/miarc.c
4724a4
index d6be99000..71df4ab64 100644
4724a4
--- a/mi/miarc.c
4724a4
+++ b/mi/miarc.c
4724a4
@@ -1021,6 +1021,7 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
4724a4
     join[0] = join[1] = 0;
4724a4
     for (iphase = (pGC->lineStyle == LineDoubleDash); iphase >= 0; iphase--) {
4724a4
         miArcSpanData *spdata = NULL;
4724a4
+        xArc lastArc;
4724a4
         ChangeGCVal gcval;
4724a4
 
4724a4
         if (iphase == 1) {
4724a4
@@ -1037,10 +1038,17 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
4724a4
             miArcDataPtr arcData;
4724a4
 
4724a4
             arcData = &polyArcs[iphase].arcs[i];
4724a4
+            if (spdata) {
4724a4
+                if (lastArc.width != arcData->arc.width ||
4724a4
+                    lastArc.height != arcData->arc.height) {
4724a4
+                    free(spdata);
4724a4
+                    spdata = NULL;
4724a4
+                }
4724a4
+            }
4724a4
+            memcpy(&lastArc, &arcData->arc, sizeof(xArc));
4724a4
             spdata = miArcSegment(pDrawTo, pGCTo, arcData->arc,
4724a4
                                   &arcData->bounds[RIGHT_END],
4724a4
                                   &arcData->bounds[LEFT_END], spdata);
4724a4
-            free(spdata);
4724a4
             if (polyArcs[iphase].arcs[i].render) {
4724a4
                 fillSpans(pDrawTo, pGCTo);
4724a4
                 /* don't cap self-joining arcs */
4724a4
@@ -1097,6 +1105,8 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
4724a4
                 }
4724a4
             }
4724a4
         }
4724a4
+        free(spdata);
4724a4
+        spdata = NULL;
4724a4
     }
4724a4
     miFreeArcs(polyArcs, pGC);
4724a4
 
4724a4
-- 
4724a4
2.12.0
4724a4