|
|
4724a4 |
From 849c825855b82caf44d25edb8155bc9f17869256 Mon Sep 17 00:00:00 2001
|
|
|
4724a4 |
From: Adam Jackson <ajax@redhat.com>
|
|
|
4724a4 |
Date: Wed, 1 Mar 2017 16:13:58 -0500
|
|
|
4724a4 |
Subject: [PATCH 2/3] miarc: Make the caller free the arc span data
|
|
|
4724a4 |
|
|
|
4724a4 |
drawArc does some fairly expensive computation, but it's only sensitive
|
|
|
4724a4 |
to arc width/height. Thread the span data up through the call chain so
|
|
|
4724a4 |
it's at least possible for the caller to cache things.
|
|
|
4724a4 |
|
|
|
4724a4 |
Reviewed-by: Keith Packard <keithp@keithp.com>
|
|
|
4724a4 |
Signed-off-by: Adam Jackson <ajax@redhat.com>
|
|
|
4724a4 |
---
|
|
|
4724a4 |
mi/miarc.c | 64 ++++++++++++++++++++++++++++++++++----------------------------
|
|
|
4724a4 |
1 file changed, 35 insertions(+), 29 deletions(-)
|
|
|
4724a4 |
|
|
|
4724a4 |
diff --git a/mi/miarc.c b/mi/miarc.c
|
|
|
4724a4 |
index fed5c9fa3..d6be99000 100644
|
|
|
4724a4 |
--- a/mi/miarc.c
|
|
|
4724a4 |
+++ b/mi/miarc.c
|
|
|
4724a4 |
@@ -215,10 +215,21 @@ typedef struct _miPolyArc {
|
|
|
4724a4 |
miArcJoinPtr joins;
|
|
|
4724a4 |
} miPolyArcRec, *miPolyArcPtr;
|
|
|
4724a4 |
|
|
|
4724a4 |
+typedef struct {
|
|
|
4724a4 |
+ short lx, lw, rx, rw;
|
|
|
4724a4 |
+} miArcSpan;
|
|
|
4724a4 |
+
|
|
|
4724a4 |
+typedef struct {
|
|
|
4724a4 |
+ miArcSpan *spans;
|
|
|
4724a4 |
+ int count1, count2, k;
|
|
|
4724a4 |
+ char top, bot, hole;
|
|
|
4724a4 |
+} miArcSpanData;
|
|
|
4724a4 |
+
|
|
|
4724a4 |
static void fillSpans(DrawablePtr pDrawable, GCPtr pGC);
|
|
|
4724a4 |
static void newFinalSpan(int y, int xmin, int xmax);
|
|
|
4724a4 |
-static void drawArc(xArc * tarc, int l, int a0, int a1, miArcFacePtr right,
|
|
|
4724a4 |
- miArcFacePtr left);
|
|
|
4724a4 |
+static miArcSpanData *drawArc(xArc * tarc, int l, int a0, int a1,
|
|
|
4724a4 |
+ miArcFacePtr right, miArcFacePtr left,
|
|
|
4724a4 |
+ miArcSpanData *spdata);
|
|
|
4724a4 |
static void drawZeroArc(DrawablePtr pDraw, GCPtr pGC, xArc * tarc, int lw,
|
|
|
4724a4 |
miArcFacePtr left, miArcFacePtr right);
|
|
|
4724a4 |
static void miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
|
|
|
4724a4 |
@@ -244,9 +255,9 @@ static int miGetArcPts(SppArcPtr parc, int cpt, SppPointPtr * ppPts);
|
|
|
4724a4 |
* draw one segment of the arc using the arc spans generation routines
|
|
|
4724a4 |
*/
|
|
|
4724a4 |
|
|
|
4724a4 |
-static void
|
|
|
4724a4 |
-miArcSegment(DrawablePtr pDraw,
|
|
|
4724a4 |
- GCPtr pGC, xArc tarc, miArcFacePtr right, miArcFacePtr left)
|
|
|
4724a4 |
+static miArcSpanData *
|
|
|
4724a4 |
+miArcSegment(DrawablePtr pDraw, GCPtr pGC, xArc tarc, miArcFacePtr right,
|
|
|
4724a4 |
+ miArcFacePtr left, miArcSpanData *spdata)
|
|
|
4724a4 |
{
|
|
|
4724a4 |
int l = pGC->lineWidth;
|
|
|
4724a4 |
int a0, a1, startAngle, endAngle;
|
|
|
4724a4 |
@@ -257,7 +268,7 @@ miArcSegment(DrawablePtr pDraw,
|
|
|
4724a4 |
|
|
|
4724a4 |
if (tarc.width == 0 || tarc.height == 0) {
|
|
|
4724a4 |
drawZeroArc(pDraw, pGC, &tarc, l, left, right);
|
|
|
4724a4 |
- return;
|
|
|
4724a4 |
+ return spdata;
|
|
|
4724a4 |
}
|
|
|
4724a4 |
|
|
|
4724a4 |
if (pGC->miTranslate) {
|
|
|
4724a4 |
@@ -298,7 +309,7 @@ miArcSegment(DrawablePtr pDraw,
|
|
|
4724a4 |
endAngle = FULLCIRCLE;
|
|
|
4724a4 |
}
|
|
|
4724a4 |
|
|
|
4724a4 |
- drawArc(&tarc, l, startAngle, endAngle, right, left);
|
|
|
4724a4 |
+ return drawArc(&tarc, l, startAngle, endAngle, right, left, spdata);
|
|
|
4724a4 |
}
|
|
|
4724a4 |
|
|
|
4724a4 |
/*
|
|
|
4724a4 |
@@ -364,16 +375,6 @@ correspond to the inner and outer boundaries.
|
|
|
4724a4 |
|
|
|
4724a4 |
*/
|
|
|
4724a4 |
|
|
|
4724a4 |
-typedef struct {
|
|
|
4724a4 |
- short lx, lw, rx, rw;
|
|
|
4724a4 |
-} miArcSpan;
|
|
|
4724a4 |
-
|
|
|
4724a4 |
-typedef struct {
|
|
|
4724a4 |
- miArcSpan *spans;
|
|
|
4724a4 |
- int count1, count2, k;
|
|
|
4724a4 |
- char top, bot, hole;
|
|
|
4724a4 |
-} miArcSpanData;
|
|
|
4724a4 |
-
|
|
|
4724a4 |
static void drawQuadrant(struct arc_def *def, struct accelerators *acc,
|
|
|
4724a4 |
int a0, int a1, int mask, miArcFacePtr right,
|
|
|
4724a4 |
miArcFacePtr left, miArcSpanData * spdata);
|
|
|
4724a4 |
@@ -905,8 +906,11 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
|
|
4724a4 |
int halfWidth;
|
|
|
4724a4 |
|
|
|
4724a4 |
if (width == 0 && pGC->lineStyle == LineSolid) {
|
|
|
4724a4 |
- for (i = narcs, parc = parcs; --i >= 0; parc++)
|
|
|
4724a4 |
- miArcSegment(pDraw, pGC, *parc, NULL, NULL);
|
|
|
4724a4 |
+ for (i = narcs, parc = parcs; --i >= 0; parc++) {
|
|
|
4724a4 |
+ miArcSpanData *spdata;
|
|
|
4724a4 |
+ spdata = miArcSegment(pDraw, pGC, *parc, NULL, NULL, NULL);
|
|
|
4724a4 |
+ free(spdata);
|
|
|
4724a4 |
+ }
|
|
|
4724a4 |
fillSpans(pDraw, pGC);
|
|
|
4724a4 |
return;
|
|
|
4724a4 |
}
|
|
|
4724a4 |
@@ -1016,6 +1020,7 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
|
|
4724a4 |
cap[0] = cap[1] = 0;
|
|
|
4724a4 |
join[0] = join[1] = 0;
|
|
|
4724a4 |
for (iphase = (pGC->lineStyle == LineDoubleDash); iphase >= 0; iphase--) {
|
|
|
4724a4 |
+ miArcSpanData *spdata = NULL;
|
|
|
4724a4 |
ChangeGCVal gcval;
|
|
|
4724a4 |
|
|
|
4724a4 |
if (iphase == 1) {
|
|
|
4724a4 |
@@ -1032,9 +1037,10 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
|
|
4724a4 |
miArcDataPtr arcData;
|
|
|
4724a4 |
|
|
|
4724a4 |
arcData = &polyArcs[iphase].arcs[i];
|
|
|
4724a4 |
- miArcSegment(pDrawTo, pGCTo, arcData->arc,
|
|
|
4724a4 |
- &arcData->bounds[RIGHT_END],
|
|
|
4724a4 |
- &arcData->bounds[LEFT_END]);
|
|
|
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 |
@@ -3240,9 +3246,9 @@ mirrorSppPoint(int quadrant, SppPointPtr sppPoint)
|
|
|
4724a4 |
* first quadrant.
|
|
|
4724a4 |
*/
|
|
|
4724a4 |
|
|
|
4724a4 |
-static void
|
|
|
4724a4 |
-drawArc(xArc * tarc,
|
|
|
4724a4 |
- int l, int a0, int a1, miArcFacePtr right, miArcFacePtr left)
|
|
|
4724a4 |
+static miArcSpanData *
|
|
|
4724a4 |
+drawArc(xArc * tarc, int l, int a0, int a1, miArcFacePtr right,
|
|
|
4724a4 |
+ miArcFacePtr left, miArcSpanData *spdata)
|
|
|
4724a4 |
{ /* save end line points */
|
|
|
4724a4 |
struct arc_def def;
|
|
|
4724a4 |
struct accelerators acc;
|
|
|
4724a4 |
@@ -3258,11 +3264,11 @@ drawArc(xArc * tarc,
|
|
|
4724a4 |
int i, j;
|
|
|
4724a4 |
int flipRight = 0, flipLeft = 0;
|
|
|
4724a4 |
int copyEnd = 0;
|
|
|
4724a4 |
- miArcSpanData *spdata;
|
|
|
4724a4 |
|
|
|
4724a4 |
- spdata = miComputeWideEllipse(l, tarc);
|
|
|
4724a4 |
if (!spdata)
|
|
|
4724a4 |
- return;
|
|
|
4724a4 |
+ spdata = miComputeWideEllipse(l, tarc);
|
|
|
4724a4 |
+ if (!spdata)
|
|
|
4724a4 |
+ return NULL;
|
|
|
4724a4 |
|
|
|
4724a4 |
if (a1 < a0)
|
|
|
4724a4 |
a1 += 360 * 64;
|
|
|
4724a4 |
@@ -3472,7 +3478,7 @@ drawArc(xArc * tarc,
|
|
|
4724a4 |
left->counterClock = temp;
|
|
|
4724a4 |
}
|
|
|
4724a4 |
}
|
|
|
4724a4 |
- free(spdata);
|
|
|
4724a4 |
+ return spdata;
|
|
|
4724a4 |
}
|
|
|
4724a4 |
|
|
|
4724a4 |
static void
|
|
|
4724a4 |
--
|
|
|
4724a4 |
2.12.0
|
|
|
4724a4 |
|