miarc: Style cleanup for miWideArc
Outdent, normalize comment formatting, and use 'goto out' idiom for error paths. No functional change. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
fe5c340046
commit
9426c5500b
352
mi/miarc.c
352
mi/miarc.c
|
@ -894,7 +894,7 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
||||||
int xMin, xMax, yMin, yMax;
|
int xMin, xMax, yMin, yMax;
|
||||||
int pixmapWidth = 0, pixmapHeight = 0;
|
int pixmapWidth = 0, pixmapHeight = 0;
|
||||||
int xOrg = 0, yOrg = 0;
|
int xOrg = 0, yOrg = 0;
|
||||||
int width;
|
int width = pGC->lineWidth;
|
||||||
Bool fTricky;
|
Bool fTricky;
|
||||||
DrawablePtr pDrawTo;
|
DrawablePtr pDrawTo;
|
||||||
CARD32 fg, bg;
|
CARD32 fg, bg;
|
||||||
|
@ -904,210 +904,200 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
||||||
int iphase;
|
int iphase;
|
||||||
int halfWidth;
|
int halfWidth;
|
||||||
|
|
||||||
width = pGC->lineWidth;
|
|
||||||
if (width == 0 && pGC->lineStyle == LineSolid) {
|
if (width == 0 && pGC->lineStyle == LineSolid) {
|
||||||
for (i = narcs, parc = parcs; --i >= 0; parc++)
|
for (i = narcs, parc = parcs; --i >= 0; parc++)
|
||||||
miArcSegment(pDraw, pGC, *parc, (miArcFacePtr) 0, (miArcFacePtr) 0);
|
miArcSegment(pDraw, pGC, *parc, NULL, NULL);
|
||||||
fillSpans(pDraw, pGC);
|
fillSpans(pDraw, pGC);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if ((pGC->lineStyle == LineSolid) && narcs) {
|
if ((pGC->lineStyle == LineSolid) && narcs) {
|
||||||
while (parcs->width && parcs->height &&
|
while (parcs->width && parcs->height &&
|
||||||
(parcs->angle2 >= FULLCIRCLE ||
|
(parcs->angle2 >= FULLCIRCLE || parcs->angle2 <= -FULLCIRCLE)) {
|
||||||
parcs->angle2 <= -FULLCIRCLE)) {
|
miFillWideEllipse(pDraw, pGC, parcs);
|
||||||
miFillWideEllipse(pDraw, pGC, parcs);
|
if (!--narcs)
|
||||||
if (!--narcs)
|
return;
|
||||||
return;
|
parcs++;
|
||||||
parcs++;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set up pDrawTo and pGCTo based on the rasterop */
|
||||||
|
switch (pGC->alu) {
|
||||||
|
case GXclear: /* 0 */
|
||||||
|
case GXcopy: /* src */
|
||||||
|
case GXcopyInverted: /* NOT src */
|
||||||
|
case GXset: /* 1 */
|
||||||
|
fTricky = FALSE;
|
||||||
|
pDrawTo = pDraw;
|
||||||
|
pGCTo = pGC;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fTricky = TRUE;
|
||||||
|
|
||||||
|
/* find bounding box around arcs */
|
||||||
|
xMin = yMin = MAXSHORT;
|
||||||
|
xMax = yMax = MINSHORT;
|
||||||
|
|
||||||
|
for (i = narcs, parc = parcs; --i >= 0; parc++) {
|
||||||
|
xMin = min(xMin, parc->x);
|
||||||
|
yMin = min(yMin, parc->y);
|
||||||
|
xMax = max(xMax, (parc->x + (int) parc->width));
|
||||||
|
yMax = max(yMax, (parc->y + (int) parc->height));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up pDrawTo and pGCTo based on the rasterop */
|
/* expand box to deal with line widths */
|
||||||
switch (pGC->alu) {
|
halfWidth = (width + 1) / 2;
|
||||||
case GXclear: /* 0 */
|
xMin -= halfWidth;
|
||||||
case GXcopy: /* src */
|
yMin -= halfWidth;
|
||||||
case GXcopyInverted: /* NOT src */
|
xMax += halfWidth;
|
||||||
case GXset: /* 1 */
|
yMax += halfWidth;
|
||||||
fTricky = FALSE;
|
|
||||||
pDrawTo = pDraw;
|
|
||||||
pGCTo = pGC;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fTricky = TRUE;
|
|
||||||
|
|
||||||
/* find bounding box around arcs */
|
/* compute pixmap size; limit it to size of drawable */
|
||||||
xMin = yMin = MAXSHORT;
|
xOrg = max(xMin, 0);
|
||||||
xMax = yMax = MINSHORT;
|
yOrg = max(yMin, 0);
|
||||||
|
pixmapWidth = min(xMax, pDraw->width) - xOrg;
|
||||||
|
pixmapHeight = min(yMax, pDraw->height) - yOrg;
|
||||||
|
|
||||||
for (i = narcs, parc = parcs; --i >= 0; parc++) {
|
/* if nothing left, return */
|
||||||
xMin = min(xMin, parc->x);
|
if ((pixmapWidth <= 0) || (pixmapHeight <= 0))
|
||||||
yMin = min(yMin, parc->y);
|
return;
|
||||||
xMax = max(xMax, (parc->x + (int) parc->width));
|
|
||||||
yMax = max(yMax, (parc->y + (int) parc->height));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* expand box to deal with line widths */
|
for (i = narcs, parc = parcs; --i >= 0; parc++) {
|
||||||
halfWidth = (width + 1) / 2;
|
parc->x -= xOrg;
|
||||||
xMin -= halfWidth;
|
parc->y -= yOrg;
|
||||||
yMin -= halfWidth;
|
}
|
||||||
xMax += halfWidth;
|
if (pGC->miTranslate) {
|
||||||
yMax += halfWidth;
|
xOrg += pDraw->x;
|
||||||
|
yOrg += pDraw->y;
|
||||||
/* compute pixmap size; limit it to size of drawable */
|
|
||||||
xOrg = max(xMin, 0);
|
|
||||||
yOrg = max(yMin, 0);
|
|
||||||
pixmapWidth = min(xMax, pDraw->width) - xOrg;
|
|
||||||
pixmapHeight = min(yMax, pDraw->height) - yOrg;
|
|
||||||
|
|
||||||
/* if nothing left, return */
|
|
||||||
if ((pixmapWidth <= 0) || (pixmapHeight <= 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = narcs, parc = parcs; --i >= 0; parc++) {
|
|
||||||
parc->x -= xOrg;
|
|
||||||
parc->y -= yOrg;
|
|
||||||
}
|
|
||||||
if (pGC->miTranslate) {
|
|
||||||
xOrg += pDraw->x;
|
|
||||||
yOrg += pDraw->y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set up scratch GC */
|
|
||||||
|
|
||||||
pGCTo = GetScratchGC(1, pDraw->pScreen);
|
|
||||||
if (!pGCTo)
|
|
||||||
return;
|
|
||||||
{
|
|
||||||
ChangeGCVal gcvals[6];
|
|
||||||
|
|
||||||
gcvals[0].val = GXcopy;
|
|
||||||
gcvals[1].val = 1;
|
|
||||||
gcvals[2].val = 0;
|
|
||||||
gcvals[3].val = pGC->lineWidth;
|
|
||||||
gcvals[4].val = pGC->capStyle;
|
|
||||||
gcvals[5].val = pGC->joinStyle;
|
|
||||||
ChangeGC(NullClient, pGCTo, GCFunction |
|
|
||||||
GCForeground | GCBackground | GCLineWidth |
|
|
||||||
GCCapStyle | GCJoinStyle, gcvals);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate a 1 bit deep pixmap of the appropriate size, and
|
|
||||||
* validate it */
|
|
||||||
pDrawTo = (DrawablePtr) (*pDraw->pScreen->CreatePixmap)
|
|
||||||
(pDraw->pScreen, pixmapWidth, pixmapHeight, 1,
|
|
||||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
|
||||||
if (!pDrawTo) {
|
|
||||||
FreeScratchGC(pGCTo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ValidateGC(pDrawTo, pGCTo);
|
|
||||||
miClearDrawable(pDrawTo, pGCTo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fg = pGC->fgPixel;
|
/* set up scratch GC */
|
||||||
bg = pGC->bgPixel;
|
pGCTo = GetScratchGC(1, pDraw->pScreen);
|
||||||
if ((pGC->fillStyle == FillTiled) ||
|
if (!pGCTo)
|
||||||
(pGC->fillStyle == FillOpaqueStippled))
|
return;
|
||||||
bg = fg; /* the protocol sez these don't cause color changes */
|
{
|
||||||
|
ChangeGCVal gcvals[6];
|
||||||
|
|
||||||
polyArcs = miComputeArcs(parcs, narcs, pGC);
|
gcvals[0].val = GXcopy;
|
||||||
|
gcvals[1].val = 1;
|
||||||
|
gcvals[2].val = 0;
|
||||||
|
gcvals[3].val = pGC->lineWidth;
|
||||||
|
gcvals[4].val = pGC->capStyle;
|
||||||
|
gcvals[5].val = pGC->joinStyle;
|
||||||
|
ChangeGC(NullClient, pGCTo, GCFunction |
|
||||||
|
GCForeground | GCBackground | GCLineWidth |
|
||||||
|
GCCapStyle | GCJoinStyle, gcvals);
|
||||||
|
}
|
||||||
|
|
||||||
if (!polyArcs) {
|
/* allocate a bitmap of the appropriate size, and validate it */
|
||||||
if (fTricky) {
|
pDrawTo = (DrawablePtr) (*pDraw->pScreen->CreatePixmap)
|
||||||
(*pDraw->pScreen->DestroyPixmap) ((PixmapPtr) pDrawTo);
|
(pDraw->pScreen, pixmapWidth, pixmapHeight, 1,
|
||||||
FreeScratchGC(pGCTo);
|
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||||
}
|
if (!pDrawTo) {
|
||||||
|
FreeScratchGC(pGCTo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ValidateGC(pDrawTo, pGCTo);
|
||||||
|
miClearDrawable(pDrawTo, pGCTo);
|
||||||
|
}
|
||||||
|
|
||||||
cap[0] = cap[1] = 0;
|
fg = pGC->fgPixel;
|
||||||
join[0] = join[1] = 0;
|
bg = pGC->bgPixel;
|
||||||
for (iphase = ((pGC->lineStyle == LineDoubleDash) ? 1 : 0);
|
|
||||||
iphase >= 0; iphase--) {
|
|
||||||
ChangeGCVal gcval;
|
|
||||||
|
|
||||||
if (iphase == 1) {
|
/* the protocol sez these don't cause color changes */
|
||||||
gcval.val = bg;
|
if ((pGC->fillStyle == FillTiled) ||
|
||||||
ChangeGC(NullClient, pGC, GCForeground, &gcval);
|
(pGC->fillStyle == FillOpaqueStippled))
|
||||||
ValidateGC(pDraw, pGC);
|
bg = fg;
|
||||||
}
|
|
||||||
else if (pGC->lineStyle == LineDoubleDash) {
|
|
||||||
gcval.val = fg;
|
|
||||||
ChangeGC(NullClient, pGC, GCForeground, &gcval);
|
|
||||||
ValidateGC(pDraw, pGC);
|
|
||||||
}
|
|
||||||
for (i = 0; i < polyArcs[iphase].narcs; i++) {
|
|
||||||
miArcDataPtr arcData;
|
|
||||||
|
|
||||||
arcData = &polyArcs[iphase].arcs[i];
|
polyArcs = miComputeArcs(parcs, narcs, pGC);
|
||||||
miArcSegment(pDrawTo, pGCTo, arcData->arc,
|
if (!polyArcs)
|
||||||
&arcData->bounds[RIGHT_END],
|
goto out;
|
||||||
&arcData->bounds[LEFT_END]);
|
|
||||||
if (polyArcs[iphase].arcs[i].render) {
|
|
||||||
fillSpans(pDrawTo, pGCTo);
|
|
||||||
/*
|
|
||||||
* don't cap self-joining arcs
|
|
||||||
*/
|
|
||||||
if (polyArcs[iphase].arcs[i].selfJoin &&
|
|
||||||
cap[iphase] < polyArcs[iphase].arcs[i].cap)
|
|
||||||
cap[iphase]++;
|
|
||||||
while (cap[iphase] < polyArcs[iphase].arcs[i].cap) {
|
|
||||||
int arcIndex, end;
|
|
||||||
miArcDataPtr arcData0;
|
|
||||||
|
|
||||||
arcIndex = polyArcs[iphase].caps[cap[iphase]].arcIndex;
|
cap[0] = cap[1] = 0;
|
||||||
end = polyArcs[iphase].caps[cap[iphase]].end;
|
join[0] = join[1] = 0;
|
||||||
arcData0 = &polyArcs[iphase].arcs[arcIndex];
|
for (iphase = (pGC->lineStyle == LineDoubleDash); iphase >= 0; iphase--) {
|
||||||
miArcCap(pDrawTo, pGCTo,
|
ChangeGCVal gcval;
|
||||||
&arcData0->bounds[end], end,
|
|
||||||
arcData0->arc.x, arcData0->arc.y,
|
|
||||||
(double) arcData0->arc.width / 2.0,
|
|
||||||
(double) arcData0->arc.height / 2.0);
|
|
||||||
++cap[iphase];
|
|
||||||
}
|
|
||||||
while (join[iphase] < polyArcs[iphase].arcs[i].join) {
|
|
||||||
int arcIndex0, arcIndex1, end0, end1;
|
|
||||||
int phase0, phase1;
|
|
||||||
miArcDataPtr arcData0, arcData1;
|
|
||||||
miArcJoinPtr joinp;
|
|
||||||
|
|
||||||
joinp = &polyArcs[iphase].joins[join[iphase]];
|
if (iphase == 1) {
|
||||||
arcIndex0 = joinp->arcIndex0;
|
gcval.val = bg;
|
||||||
end0 = joinp->end0;
|
ChangeGC(NullClient, pGC, GCForeground, &gcval);
|
||||||
arcIndex1 = joinp->arcIndex1;
|
ValidateGC(pDraw, pGC);
|
||||||
end1 = joinp->end1;
|
}
|
||||||
phase0 = joinp->phase0;
|
else if (pGC->lineStyle == LineDoubleDash) {
|
||||||
phase1 = joinp->phase1;
|
gcval.val = fg;
|
||||||
arcData0 = &polyArcs[phase0].arcs[arcIndex0];
|
ChangeGC(NullClient, pGC, GCForeground, &gcval);
|
||||||
arcData1 = &polyArcs[phase1].arcs[arcIndex1];
|
ValidateGC(pDraw, pGC);
|
||||||
miArcJoin(pDrawTo, pGCTo,
|
}
|
||||||
&arcData0->bounds[end0],
|
for (i = 0; i < polyArcs[iphase].narcs; i++) {
|
||||||
&arcData1->bounds[end1],
|
miArcDataPtr arcData;
|
||||||
arcData0->arc.x, arcData0->arc.y,
|
|
||||||
(double) arcData0->arc.width / 2.0,
|
arcData = &polyArcs[iphase].arcs[i];
|
||||||
(double) arcData0->arc.height / 2.0,
|
miArcSegment(pDrawTo, pGCTo, arcData->arc,
|
||||||
arcData1->arc.x, arcData1->arc.y,
|
&arcData->bounds[RIGHT_END],
|
||||||
(double) arcData1->arc.width / 2.0,
|
&arcData->bounds[LEFT_END]);
|
||||||
(double) arcData1->arc.height / 2.0);
|
if (polyArcs[iphase].arcs[i].render) {
|
||||||
++join[iphase];
|
fillSpans(pDrawTo, pGCTo);
|
||||||
}
|
/* don't cap self-joining arcs */
|
||||||
if (fTricky) {
|
if (polyArcs[iphase].arcs[i].selfJoin &&
|
||||||
if (pGC->serialNumber != pDraw->serialNumber)
|
cap[iphase] < polyArcs[iphase].arcs[i].cap)
|
||||||
ValidateGC(pDraw, pGC);
|
cap[iphase]++;
|
||||||
(*pGC->ops->PushPixels) (pGC, (PixmapPtr) pDrawTo,
|
while (cap[iphase] < polyArcs[iphase].arcs[i].cap) {
|
||||||
pDraw, pixmapWidth,
|
int arcIndex, end;
|
||||||
pixmapHeight, xOrg, yOrg);
|
miArcDataPtr arcData0;
|
||||||
miClearDrawable((DrawablePtr) pDrawTo, pGCTo);
|
|
||||||
}
|
arcIndex = polyArcs[iphase].caps[cap[iphase]].arcIndex;
|
||||||
|
end = polyArcs[iphase].caps[cap[iphase]].end;
|
||||||
|
arcData0 = &polyArcs[iphase].arcs[arcIndex];
|
||||||
|
miArcCap(pDrawTo, pGCTo,
|
||||||
|
&arcData0->bounds[end], end,
|
||||||
|
arcData0->arc.x, arcData0->arc.y,
|
||||||
|
(double) arcData0->arc.width / 2.0,
|
||||||
|
(double) arcData0->arc.height / 2.0);
|
||||||
|
++cap[iphase];
|
||||||
|
}
|
||||||
|
while (join[iphase] < polyArcs[iphase].arcs[i].join) {
|
||||||
|
int arcIndex0, arcIndex1, end0, end1;
|
||||||
|
int phase0, phase1;
|
||||||
|
miArcDataPtr arcData0, arcData1;
|
||||||
|
miArcJoinPtr joinp;
|
||||||
|
|
||||||
|
joinp = &polyArcs[iphase].joins[join[iphase]];
|
||||||
|
arcIndex0 = joinp->arcIndex0;
|
||||||
|
end0 = joinp->end0;
|
||||||
|
arcIndex1 = joinp->arcIndex1;
|
||||||
|
end1 = joinp->end1;
|
||||||
|
phase0 = joinp->phase0;
|
||||||
|
phase1 = joinp->phase1;
|
||||||
|
arcData0 = &polyArcs[phase0].arcs[arcIndex0];
|
||||||
|
arcData1 = &polyArcs[phase1].arcs[arcIndex1];
|
||||||
|
miArcJoin(pDrawTo, pGCTo,
|
||||||
|
&arcData0->bounds[end0],
|
||||||
|
&arcData1->bounds[end1],
|
||||||
|
arcData0->arc.x, arcData0->arc.y,
|
||||||
|
(double) arcData0->arc.width / 2.0,
|
||||||
|
(double) arcData0->arc.height / 2.0,
|
||||||
|
arcData1->arc.x, arcData1->arc.y,
|
||||||
|
(double) arcData1->arc.width / 2.0,
|
||||||
|
(double) arcData1->arc.height / 2.0);
|
||||||
|
++join[iphase];
|
||||||
|
}
|
||||||
|
if (fTricky) {
|
||||||
|
if (pGC->serialNumber != pDraw->serialNumber)
|
||||||
|
ValidateGC(pDraw, pGC);
|
||||||
|
(*pGC->ops->PushPixels) (pGC, (PixmapPtr) pDrawTo,
|
||||||
|
pDraw, pixmapWidth,
|
||||||
|
pixmapHeight, xOrg, yOrg);
|
||||||
|
miClearDrawable((DrawablePtr) pDrawTo, pGCTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
miFreeArcs(polyArcs, pGC);
|
}
|
||||||
|
miFreeArcs(polyArcs, pGC);
|
||||||
|
|
||||||
if (fTricky) {
|
out:
|
||||||
(*pGCTo->pScreen->DestroyPixmap) ((PixmapPtr) pDrawTo);
|
if (fTricky) {
|
||||||
FreeScratchGC(pGCTo);
|
(*pGCTo->pScreen->DestroyPixmap) ((PixmapPtr) pDrawTo);
|
||||||
}
|
FreeScratchGC(pGCTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user