summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2010-05-08 12:06:50 -0700
committerJamey Sharp <jamey@minilop.net>2010-05-13 16:24:54 -0700
commitbff8525f8483304d5f93e83e36b47209381da721 (patch)
treecf02cbeddd184bdf6da108c5584690a1e0945640 /mi
parent83f7ec97279405958aed86c6a57704a460c3bfba (diff)
Simplify miFillPolyHelper and miLineArc.
Both functions compute a set of spans and either fill them immediately or accumulate them into a caller-provided buffer. Computing the spans used only the miTranslate and lineWidth fields of pGC, and neither could have been changed by the initial ChangeGC/ValidateGC pair, so it's safe to compute the spans first. Then both functions consume the spans the same way, so factor that into a new fillSpans function. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'mi')
-rw-r--r--mi/miwideline.c79
1 files changed, 27 insertions, 52 deletions
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 22e15cf47..cabc0c1ce 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -106,6 +106,31 @@ static void miLineArc(DrawablePtr pDraw, GCPtr pGC,
*/
static void
+fillSpans(DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel, Spans *spans, SpanDataPtr spanData)
+{
+ if (!spanData)
+ {
+ XID oldPixel = pGC->fgPixel;
+ if (pixel != oldPixel)
+ {
+ XID tmpPixel = (XID)pixel;
+ dixChangeGC (NullClient, pGC, GCForeground, &tmpPixel, NULL);
+ ValidateGC (pDrawable, pGC);
+ }
+ (*pGC->ops->FillSpans) (pDrawable, pGC, spans->count, spans->points, spans->widths, TRUE);
+ free(spans->widths);
+ free(spans->points);
+ if (pixel != oldPixel)
+ {
+ dixChangeGC (NullClient, pGC, GCForeground, &oldPixel, NULL);
+ ValidateGC (pDrawable, pGC);
+ }
+ }
+ else
+ AppendSpanGroup (pGC, pixel, spans, spanData);
+}
+
+static void
miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
SpanDataPtr spanData, int y, int overall_height,
PolyEdgePtr left, PolyEdgePtr right,
@@ -126,27 +151,13 @@ miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
DDXPointPtr ppt;
int *pwidth;
- XID oldPixel;
int xorg;
Spans spanRec;
- left_height = 0;
- right_height = 0;
-
if (!InitSpans(&spanRec, overall_height))
return;
ppt = spanRec.points;
pwidth = spanRec.widths;
- if (!spanData)
- {
- oldPixel = pGC->fgPixel;
- if (pixel != oldPixel)
- {
- XID tmpPixel = (XID)pixel;
- dixChangeGC (NullClient, pGC, GCForeground, &tmpPixel, NULL);
- ValidateGC (pDrawable, pGC);
- }
- }
xorg = 0;
if (pGC->miTranslate)
@@ -219,19 +230,7 @@ miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
}
}
spanRec.count = ppt - spanRec.points;
- if (!spanData)
- {
- (*pGC->ops->FillSpans) (pDrawable, pGC, spanRec.count, spanRec.points, spanRec.widths, TRUE);
- free(spanRec.widths);
- free(spanRec.points);
- if (pixel != oldPixel)
- {
- dixChangeGC (NullClient, pGC, GCForeground, &oldPixel, NULL);
- ValidateGC (pDrawable, pGC);
- }
- }
- else
- AppendSpanGroup (pGC, pixel, &spanRec, spanData);
+ fillSpans (pDrawable, pGC, pixel, &spanRec, spanData);
}
static void
@@ -1042,7 +1041,6 @@ miLineArc (
Bool isInt)
{
int xorgi = 0, yorgi = 0;
- XID oldPixel;
Spans spanRec;
int n;
PolyEdgeRec edge1, edge2;
@@ -1088,16 +1086,6 @@ miLineArc (
}
if (!InitSpans(&spanRec, pGC->lineWidth))
return;
- if (!spanData)
- {
- oldPixel = pGC->fgPixel;
- if (pixel != oldPixel)
- {
- XID tmpPixel = (XID)pixel;
- dixChangeGC(NullClient, pGC, GCForeground, &tmpPixel, NULL);
- ValidateGC (pDraw, pGC);
- }
- }
if (isInt)
n = miLineArcI(pDraw, pGC, xorgi, yorgi, spanRec.points, spanRec.widths);
else
@@ -1105,20 +1093,7 @@ miLineArc (
&edge1, edgey1, edgeleft1,
&edge2, edgey2, edgeleft2);
spanRec.count = n;
-
- if (!spanData)
- {
- (*pGC->ops->FillSpans)(pDraw, pGC, spanRec.count, spanRec.points, spanRec.widths, TRUE);
- free(spanRec.widths);
- free(spanRec.points);
- if (pixel != oldPixel)
- {
- dixChangeGC(NullClient, pGC, GCForeground, &oldPixel, NULL);
- ValidateGC (pDraw, pGC);
- }
- }
- else
- AppendSpanGroup (pGC, pixel, &spanRec, spanData);
+ fillSpans (pDraw, pGC, pixel, &spanRec, spanData);
}
static void