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>
This commit is contained in:
parent
83f7ec9727
commit
bff8525f84
|
@ -105,6 +105,31 @@ static void miLineArc(DrawablePtr pDraw, GCPtr pGC,
|
||||||
* spans-based polygon filler
|
* spans-based polygon filler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
|
miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
|
||||||
SpanDataPtr spanData, int y, int overall_height,
|
SpanDataPtr spanData, int y, int overall_height,
|
||||||
|
@ -126,27 +151,13 @@ miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
|
||||||
|
|
||||||
DDXPointPtr ppt;
|
DDXPointPtr ppt;
|
||||||
int *pwidth;
|
int *pwidth;
|
||||||
XID oldPixel;
|
|
||||||
int xorg;
|
int xorg;
|
||||||
Spans spanRec;
|
Spans spanRec;
|
||||||
|
|
||||||
left_height = 0;
|
|
||||||
right_height = 0;
|
|
||||||
|
|
||||||
if (!InitSpans(&spanRec, overall_height))
|
if (!InitSpans(&spanRec, overall_height))
|
||||||
return;
|
return;
|
||||||
ppt = spanRec.points;
|
ppt = spanRec.points;
|
||||||
pwidth = spanRec.widths;
|
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;
|
xorg = 0;
|
||||||
if (pGC->miTranslate)
|
if (pGC->miTranslate)
|
||||||
|
@ -219,19 +230,7 @@ miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spanRec.count = ppt - spanRec.points;
|
spanRec.count = ppt - spanRec.points;
|
||||||
if (!spanData)
|
fillSpans (pDrawable, pGC, pixel, &spanRec, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1042,7 +1041,6 @@ miLineArc (
|
||||||
Bool isInt)
|
Bool isInt)
|
||||||
{
|
{
|
||||||
int xorgi = 0, yorgi = 0;
|
int xorgi = 0, yorgi = 0;
|
||||||
XID oldPixel;
|
|
||||||
Spans spanRec;
|
Spans spanRec;
|
||||||
int n;
|
int n;
|
||||||
PolyEdgeRec edge1, edge2;
|
PolyEdgeRec edge1, edge2;
|
||||||
|
@ -1088,16 +1086,6 @@ miLineArc (
|
||||||
}
|
}
|
||||||
if (!InitSpans(&spanRec, pGC->lineWidth))
|
if (!InitSpans(&spanRec, pGC->lineWidth))
|
||||||
return;
|
return;
|
||||||
if (!spanData)
|
|
||||||
{
|
|
||||||
oldPixel = pGC->fgPixel;
|
|
||||||
if (pixel != oldPixel)
|
|
||||||
{
|
|
||||||
XID tmpPixel = (XID)pixel;
|
|
||||||
dixChangeGC(NullClient, pGC, GCForeground, &tmpPixel, NULL);
|
|
||||||
ValidateGC (pDraw, pGC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isInt)
|
if (isInt)
|
||||||
n = miLineArcI(pDraw, pGC, xorgi, yorgi, spanRec.points, spanRec.widths);
|
n = miLineArcI(pDraw, pGC, xorgi, yorgi, spanRec.points, spanRec.widths);
|
||||||
else
|
else
|
||||||
|
@ -1105,20 +1093,7 @@ miLineArc (
|
||||||
&edge1, edgey1, edgeleft1,
|
&edge1, edgey1, edgeleft1,
|
||||||
&edge2, edgey2, edgeleft2);
|
&edge2, edgey2, edgeleft2);
|
||||||
spanRec.count = n;
|
spanRec.count = n;
|
||||||
|
fillSpans (pDraw, pGC, pixel, &spanRec, spanData);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue