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 pixmapWidth = 0, pixmapHeight = 0;
|
||||
int xOrg = 0, yOrg = 0;
|
||||
int width;
|
||||
int width = pGC->lineWidth;
|
||||
Bool fTricky;
|
||||
DrawablePtr pDrawTo;
|
||||
CARD32 fg, bg;
|
||||
|
@ -904,210 +904,200 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
|
|||
int iphase;
|
||||
int halfWidth;
|
||||
|
||||
width = pGC->lineWidth;
|
||||
if (width == 0 && pGC->lineStyle == LineSolid) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if ((pGC->lineStyle == LineSolid) && narcs) {
|
||||
while (parcs->width && parcs->height &&
|
||||
(parcs->angle2 >= FULLCIRCLE ||
|
||||
parcs->angle2 <= -FULLCIRCLE)) {
|
||||
miFillWideEllipse(pDraw, pGC, parcs);
|
||||
if (!--narcs)
|
||||
return;
|
||||
parcs++;
|
||||
}
|
||||
|
||||
if ((pGC->lineStyle == LineSolid) && narcs) {
|
||||
while (parcs->width && parcs->height &&
|
||||
(parcs->angle2 >= FULLCIRCLE || parcs->angle2 <= -FULLCIRCLE)) {
|
||||
miFillWideEllipse(pDraw, pGC, parcs);
|
||||
if (!--narcs)
|
||||
return;
|
||||
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 */
|
||||
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;
|
||||
/* expand box to deal with line widths */
|
||||
halfWidth = (width + 1) / 2;
|
||||
xMin -= halfWidth;
|
||||
yMin -= halfWidth;
|
||||
xMax += halfWidth;
|
||||
yMax += halfWidth;
|
||||
|
||||
/* find bounding box around arcs */
|
||||
xMin = yMin = MAXSHORT;
|
||||
xMax = yMax = MINSHORT;
|
||||
/* 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;
|
||||
|
||||
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));
|
||||
}
|
||||
/* if nothing left, return */
|
||||
if ((pixmapWidth <= 0) || (pixmapHeight <= 0))
|
||||
return;
|
||||
|
||||
/* expand box to deal with line widths */
|
||||
halfWidth = (width + 1) / 2;
|
||||
xMin -= halfWidth;
|
||||
yMin -= halfWidth;
|
||||
xMax += halfWidth;
|
||||
yMax += halfWidth;
|
||||
|
||||
/* 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);
|
||||
for (i = narcs, parc = parcs; --i >= 0; parc++) {
|
||||
parc->x -= xOrg;
|
||||
parc->y -= yOrg;
|
||||
}
|
||||
if (pGC->miTranslate) {
|
||||
xOrg += pDraw->x;
|
||||
yOrg += pDraw->y;
|
||||
}
|
||||
|
||||
fg = pGC->fgPixel;
|
||||
bg = pGC->bgPixel;
|
||||
if ((pGC->fillStyle == FillTiled) ||
|
||||
(pGC->fillStyle == FillOpaqueStippled))
|
||||
bg = fg; /* the protocol sez these don't cause color changes */
|
||||
/* set up scratch GC */
|
||||
pGCTo = GetScratchGC(1, pDraw->pScreen);
|
||||
if (!pGCTo)
|
||||
return;
|
||||
{
|
||||
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) {
|
||||
if (fTricky) {
|
||||
(*pDraw->pScreen->DestroyPixmap) ((PixmapPtr) pDrawTo);
|
||||
FreeScratchGC(pGCTo);
|
||||
}
|
||||
/* allocate a bitmap 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);
|
||||
}
|
||||
|
||||
cap[0] = cap[1] = 0;
|
||||
join[0] = join[1] = 0;
|
||||
for (iphase = ((pGC->lineStyle == LineDoubleDash) ? 1 : 0);
|
||||
iphase >= 0; iphase--) {
|
||||
ChangeGCVal gcval;
|
||||
fg = pGC->fgPixel;
|
||||
bg = pGC->bgPixel;
|
||||
|
||||
if (iphase == 1) {
|
||||
gcval.val = bg;
|
||||
ChangeGC(NullClient, pGC, GCForeground, &gcval);
|
||||
ValidateGC(pDraw, pGC);
|
||||
}
|
||||
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;
|
||||
/* the protocol sez these don't cause color changes */
|
||||
if ((pGC->fillStyle == FillTiled) ||
|
||||
(pGC->fillStyle == FillOpaqueStippled))
|
||||
bg = fg;
|
||||
|
||||
arcData = &polyArcs[iphase].arcs[i];
|
||||
miArcSegment(pDrawTo, pGCTo, arcData->arc,
|
||||
&arcData->bounds[RIGHT_END],
|
||||
&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;
|
||||
polyArcs = miComputeArcs(parcs, narcs, pGC);
|
||||
if (!polyArcs)
|
||||
goto out;
|
||||
|
||||
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;
|
||||
cap[0] = cap[1] = 0;
|
||||
join[0] = join[1] = 0;
|
||||
for (iphase = (pGC->lineStyle == LineDoubleDash); iphase >= 0; iphase--) {
|
||||
ChangeGCVal gcval;
|
||||
|
||||
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);
|
||||
}
|
||||
if (iphase == 1) {
|
||||
gcval.val = bg;
|
||||
ChangeGC(NullClient, pGC, GCForeground, &gcval);
|
||||
ValidateGC(pDraw, pGC);
|
||||
}
|
||||
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];
|
||||
miArcSegment(pDrawTo, pGCTo, arcData->arc,
|
||||
&arcData->bounds[RIGHT_END],
|
||||
&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;
|
||||
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) {
|
||||
(*pGCTo->pScreen->DestroyPixmap) ((PixmapPtr) pDrawTo);
|
||||
FreeScratchGC(pGCTo);
|
||||
}
|
||||
out:
|
||||
if (fTricky) {
|
||||
(*pGCTo->pScreen->DestroyPixmap) ((PixmapPtr) pDrawTo);
|
||||
FreeScratchGC(pGCTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue