summaryrefslogtreecommitdiff
path: root/mi/miarc.c
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
commitd568221710959cf7d783e6ff0fb80fb43a231124 (patch)
tree8d6f039393294c6ffac8533639afdebe5d68bfc1 /mi/miarc.c
parent9508a382f8a9f241dab097d921b6d290c1c3a776 (diff)
Diffstat (limited to 'mi/miarc.c')
-rw-r--r--mi/miarc.c562
1 files changed, 313 insertions, 249 deletions
diff --git a/mi/miarc.c b/mi/miarc.c
index db569fa41..8c86200ee 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/mi/miarc.c,v 3.13 2002/01/12 22:20:33 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -48,7 +49,7 @@ SOFTWARE.
/* Author: Keith Packard and Bob Scheifler */
/* Warning: this code is toxic, do not dally very long here. */
-#ifdef _XOPEN_SOURCE
+#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__)
#include <math.h>
#else
#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
@@ -67,12 +68,11 @@ SOFTWARE.
#include "mifillarc.h"
#include "Xfuncproto.h"
-static double miDsin(), miDcos(), miDasin(), miDatan2();
-double cbrt(
-#if NeedFunctionPrototypes
- double
-#endif
-);
+static double miDsin(double a);
+static double miDcos(double a);
+static double miDasin(double v);
+static double miDatan2(double dy, double dx);
+double cbrt(double);
#ifdef ICEILTEMPDECL
ICEILTEMPDECL
@@ -101,7 +101,7 @@ ICEILTEMPDECL
#undef max
#undef min
-#if defined (__GNUC__) && defined (__STDC__) && !defined (__STRICT_ANSI__)
+#if defined (__GNUC__) && !defined (__STRICT_ANSI__)
#define USE_INLINE
#endif
@@ -119,13 +119,13 @@ inline static const int min (const int x, const int y)
#else
static int
-max (x, y)
+max (int x, int y)
{
return x>y? x:y;
}
static int
-min (x, y)
+min (int x, int y)
{
return x<y? x:y;
}
@@ -242,12 +242,27 @@ typedef struct _miPolyArc {
GCLineWidth | GCCapStyle | GCJoinStyle)
static CARD32 gcvals[6];
-static void fillSpans(), newFinalSpan();
-static void drawArc(), drawQuadrant(), drawZeroArc();
-static void miArcJoin(), miArcCap(), miRoundCap(), miFreeArcs();
-static int computeAngleFromPath();
-static miPolyArcPtr miComputeArcs ();
-static int miGetArcPts();
+static void fillSpans(DrawablePtr pDrawable, GCPtr pGC);
+static void newFinalSpan(int y, register int xmin, register int xmax);
+static void drawArc(xArc *tarc, int l, int a0, int a1, miArcFacePtr right,
+ miArcFacePtr left);
+static void drawZeroArc(DrawablePtr pDraw, GCPtr pGC, xArc *tarc, int lw,
+ miArcFacePtr left, miArcFacePtr right);
+static void miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
+ miArcFacePtr pRight, int xOrgLeft, int yOrgLeft,
+ double xFtransLeft, double yFtransLeft,
+ int xOrgRight, int yOrgRight,
+ double xFtransRight, double yFtransRight);
+static void miArcCap(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pFace,
+ int end, int xOrg, int yOrg, double xFtrans,
+ double yFtrans);
+static void miRoundCap(DrawablePtr pDraw, GCPtr pGC, SppPointRec pCenter,
+ SppPointRec pEnd, SppPointRec pCorner,
+ SppPointRec pOtherCorner, int fLineEnd,
+ int xOrg, int yOrg, double xFtrans, double yFtrans);
+static void miFreeArcs(miPolyArcPtr arcs, GCPtr pGC);
+static miPolyArcPtr miComputeArcs(xArc *parcs, int narcs, GCPtr pGC);
+static int miGetArcPts(SppArcPtr parc, int cpt, SppPointPtr *ppPts);
# define CUBED_ROOT_2 1.2599210498948732038115849718451499938964
# define CUBED_ROOT_4 1.5874010519681993173435330390930175781250
@@ -257,11 +272,12 @@ static int miGetArcPts();
*/
static void
-miArcSegment(pDraw, pGC, tarc, right, left)
- DrawablePtr pDraw;
- GCPtr pGC;
- xArc tarc;
- miArcFacePtr right, left;
+miArcSegment(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc tarc,
+ miArcFacePtr right,
+ miArcFacePtr left)
{
int l = pGC->lineWidth;
int a0, a1, startAngle, endAngle;
@@ -397,6 +413,10 @@ typedef struct {
#define CACHESIZE 25
+static void drawQuadrant(struct arc_def *def, struct accelerators *acc,
+ int a0, int a1, int mask, miArcFacePtr right,
+ miArcFacePtr left, miArcSpanData *spdata);
+
static arcCacheRec arcCache[CACHESIZE];
static unsigned long lrustamp;
static arcCacheRec *lastCacheHit = &arcCache[0];
@@ -433,18 +453,18 @@ miFreeArcCache (data, id)
}
static void
-miComputeCircleSpans(lw, parc, spdata)
- int lw;
- xArc *parc;
- miArcSpanData *spdata;
+miComputeCircleSpans(
+ int lw,
+ xArc *parc,
+ miArcSpanData *spdata)
{
register miArcSpan *span;
int doinner;
register int x, y, e;
int xk, yk, xm, ym, dx, dy;
register int slw, inslw;
- int inx, iny, ine;
- int inxk, inyk, inxm, inym;
+ int inx = 0, iny, ine = 0;
+ int inxk = 0, inyk = 0, inxm = 0, inym = 0;
doinner = -lw;
slw = parc->width - doinner;
@@ -501,15 +521,15 @@ miComputeCircleSpans(lw, parc, spdata)
}
static void
-miComputeEllipseSpans(lw, parc, spdata)
- int lw;
- xArc *parc;
- miArcSpanData *spdata;
+miComputeEllipseSpans(
+ int lw,
+ xArc *parc,
+ miArcSpanData *spdata)
{
register miArcSpan *span;
double w, h, r, xorg;
double Hs, Hf, WH, K, Vk, Nk, Fk, Vr, N, Nc, Z, rs;
- double A, T, b, d, x, y, t, inx, outx, hepp, hepm;
+ double A, T, b, d, x, y, t, inx, outx = 0.0, hepp, hepm;
int flip, solution;
w = (double)parc->width / 2.0;
@@ -587,7 +607,10 @@ miComputeEllipseSpans(lw, parc, spdata)
t = y / h;
x = w * sqrt(1 - (t * t));
t = K - y;
- t = sqrt(rs - (t * t));
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
if (flip == 2)
inx = x - t;
else
@@ -612,7 +635,10 @@ miComputeEllipseSpans(lw, parc, spdata)
t = y / h;
x = w * sqrt(1 - (t * t));
t = K - y;
- inx = x - sqrt(rs - (t * t));
+ if (rs - (t * t) >= 0)
+ inx = x - sqrt(rs - (t * t));
+ else
+ inx = x;
}
y = (b - d) / 2;
if (y >= 0.0)
@@ -622,7 +648,10 @@ miComputeEllipseSpans(lw, parc, spdata)
t = y / h;
x = w * sqrt(1 - (t * t));
t = K - y;
- t = sqrt(rs - (t * t));
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
if (flip == 1)
inx = x - t;
else
@@ -685,11 +714,11 @@ miComputeEllipseSpans(lw, parc, spdata)
}
static double
-tailX(K, def, bounds, acc)
- double K;
- struct arc_def *def;
- struct arc_bound *bounds;
- struct accelerators *acc;
+tailX(
+ double K,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc)
{
double w, h, r;
double Hs, Hf, WH, Vk, Nk, Fk, Vr, N, Nc, Z, rs;
@@ -769,7 +798,10 @@ tailX(K, def, bounds, acc)
t = y / h;
x = w * sqrt(1 - (t * t));
t = K - y;
- t = sqrt(rs - (t * t));
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
*xp++ = x - t;
}
}
@@ -791,7 +823,10 @@ tailX(K, def, bounds, acc)
t = y / h;
x = w * sqrt(1 - (t * t));
t = K - y;
- *xp++ = x - sqrt(rs - (t * t));
+ if (rs - (t * t) >= 0)
+ *xp++ = x - sqrt(rs - (t * t));
+ else
+ *xp++ = x;
}
y = (b - d) / 2;
if (y >= 0.0 && flip == 1)
@@ -801,7 +836,10 @@ tailX(K, def, bounds, acc)
t = y / h;
x = w * sqrt(1 - (t * t));
t = K - y;
- t = sqrt(rs - (t * t));
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
*xp++ = x - t;
}
}
@@ -817,10 +855,10 @@ tailX(K, def, bounds, acc)
}
static miArcSpanData *
-miComputeWideEllipse(lw, parc, mustFree)
- int lw;
- register xArc *parc;
- Bool *mustFree;
+miComputeWideEllipse(
+ int lw,
+ register xArc *parc,
+ Bool *mustFree)
{
register miArcSpanData *spdata;
register arcCacheRec *cent, *lruent;
@@ -896,10 +934,10 @@ miComputeWideEllipse(lw, parc, mustFree)
}
static void
-miFillWideEllipse(pDraw, pGC, parc)
- DrawablePtr pDraw;
- GCPtr pGC;
- xArc *parc;
+miFillWideEllipse(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *parc)
{
DDXPointPtr points;
register DDXPointPtr pts;
@@ -1039,8 +1077,8 @@ miPolyArc(pDraw, pGC, narcs, parcs)
register int i;
xArc *parc;
int xMin, xMax, yMin, yMax;
- int pixmapWidth, pixmapHeight;
- int xOrg, yOrg;
+ int pixmapWidth = 0, pixmapHeight = 0;
+ int xOrg = 0, yOrg = 0;
int width;
Bool fTricky;
DrawablePtr pDrawTo;
@@ -1259,8 +1297,7 @@ miPolyArc(pDraw, pGC, narcs, parcs)
}
static double
-angleBetween (center, point1, point2)
- SppPointRec center, point1, point2;
+angleBetween (SppPointRec center, SppPointRec point1, SppPointRec point2)
{
double a1, a2, a;
@@ -1279,10 +1316,12 @@ angleBetween (center, point1, point2)
}
static void
-translateBounds (b, x, y, fx, fy)
-miArcFacePtr b;
-int x, y;
-double fx, fy;
+translateBounds (
+ miArcFacePtr b,
+ int x,
+ int y,
+ double fx,
+ double fy)
{
fx += x;
fy += y;
@@ -1295,16 +1334,11 @@ double fx, fy;
}
static void
-miArcJoin (pDraw, pGC, pLeft, pRight,
- xOrgLeft, yOrgLeft, xFtransLeft, yFtransLeft,
- xOrgRight, yOrgRight, xFtransRight, yFtransRight)
- DrawablePtr pDraw;
- GCPtr pGC;
- miArcFacePtr pRight, pLeft;
- int xOrgRight, yOrgRight;
- double xFtransRight, yFtransRight;
- int xOrgLeft, yOrgLeft;
- double xFtransLeft, yFtransLeft;
+miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
+ miArcFacePtr pRight, int xOrgLeft, int yOrgLeft,
+ double xFtransLeft, double yFtransLeft,
+ int xOrgRight, int yOrgRight,
+ double xFtransRight, double yFtransRight)
{
SppPointRec center, corner, otherCorner;
SppPointRec poly[5], e;
@@ -1312,7 +1346,7 @@ miArcJoin (pDraw, pGC, pLeft, pRight,
int cpt;
SppArcRec arc;
miArcFaceRec Right, Left;
- int polyLen;
+ int polyLen = 0;
int xOrg, yOrg;
double xFtrans, yFtrans;
double a;
@@ -1410,13 +1444,15 @@ miArcJoin (pDraw, pGC, pLeft, pRight,
/*ARGSUSED*/
static void
-miArcCap (pDraw, pGC, pFace, end, xOrg, yOrg, xFtrans, yFtrans)
- DrawablePtr pDraw;
- GCPtr pGC;
- miArcFacePtr pFace;
- int end;
- int xOrg, yOrg;
- double xFtrans, yFtrans;
+miArcCap (
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ miArcFacePtr pFace,
+ int end,
+ int xOrg,
+ int yOrg,
+ double xFtrans,
+ double yFtrans)
{
SppPointRec corner, otherCorner, center, endPoint, poly[5];
@@ -1461,18 +1497,21 @@ miArcCap (pDraw, pGC, pFace, end, xOrg, yOrg, xFtrans, yFtrans)
*/
/*ARGSUSED*/
static void
-miRoundCap(pDraw, pGC, pCenter, pEnd, pCorner, pOtherCorner, fLineEnd,
- xOrg, yOrg, xFtrans, yFtrans)
- DrawablePtr pDraw;
- GCPtr pGC;
- SppPointRec pCenter, pEnd;
- SppPointRec pCorner, pOtherCorner;
- int fLineEnd, xOrg, yOrg;
- double xFtrans, yFtrans;
+miRoundCap(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ SppPointRec pCenter,
+ SppPointRec pEnd,
+ SppPointRec pCorner,
+ SppPointRec pOtherCorner,
+ int fLineEnd,
+ int xOrg,
+ int yOrg,
+ double xFtrans,
+ double yFtrans)
{
int cpt;
double width;
- double miDatan2 ();
SppArcRec arc;
SppPointPtr pArcPts;
@@ -1518,8 +1557,7 @@ miRoundCap(pDraw, pGC, pCenter, pEnd, pCorner, pOtherCorner, fLineEnd,
# define mod(a,b) ((a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
static double
-miDcos (a)
-double a;
+miDcos (double a)
{
int i;
@@ -1536,8 +1574,7 @@ double a;
}
static double
-miDsin (a)
-double a;
+miDsin (double a)
{
int i;
@@ -1554,8 +1591,7 @@ double a;
}
static double
-miDasin (v)
-double v;
+miDasin (double v)
{
if (v == 0)
return 0.0;
@@ -1567,8 +1603,7 @@ double v;
}
static double
-miDatan2 (dy, dx)
-double dy, dx;
+miDatan2 (double dy, double dx)
{
if (dy == 0) {
if (dx >= 0)
@@ -1600,16 +1635,16 @@ double dy, dx;
* This procedure allocates the space necessary to fit the arc points.
* Sometimes it's convenient for those points to be at the end of an existing
* array. (For example, if we want to leave a spare point to make sectors
- * instead of segments.) So we pass in the Xalloc()ed chunk that contains the
+ * instead of segments.) So we pass in the xalloc()ed chunk that contains the
* array and an index saying where we should start stashing the points.
* If there isn't an array already, we just pass in a null pointer and
- * count on Xrealloc() to handle the null pointer correctly.
+ * count on xrealloc() to handle the null pointer correctly.
*/
static int
-miGetArcPts(parc, cpt, ppPts)
- SppArcPtr parc; /* points to an arc */
- int cpt; /* number of points already in arc list */
- SppPointPtr *ppPts; /* pointer to pointer to arc-list -- modified */
+miGetArcPts(
+ SppArcPtr parc, /* points to an arc */
+ int cpt, /* number of points already in arc list */
+ SppPointPtr *ppPts) /* pointer to pointer to arc-list -- modified */
{
double st, /* Start Theta, start angle */
et, /* End Theta, offset from start theta */
@@ -1701,10 +1736,12 @@ struct arcData {
# define ADD_REALLOC_STEP 20
static void
-addCap (capsp, ncapsp, sizep, end, arcIndex)
- miArcCapPtr *capsp;
- int *ncapsp, *sizep;
- int end, arcIndex;
+addCap (
+ miArcCapPtr *capsp,
+ int *ncapsp,
+ int *sizep,
+ int end,
+ int arcIndex)
{
int newsize;
miArcCapPtr cap;
@@ -1726,10 +1763,16 @@ addCap (capsp, ncapsp, sizep, end, arcIndex)
}
static void
-addJoin (joinsp, njoinsp, sizep, end0, index0, phase0, end1, index1, phase1)
- miArcJoinPtr *joinsp;
- int *njoinsp, *sizep;
- int end0, index0, phase0, end1, index1, phase1;
+addJoin (
+ miArcJoinPtr *joinsp,
+ int *njoinsp,
+ int *sizep,
+ int end0,
+ int index0,
+ int phase0,
+ int end1,
+ int index1,
+ int phase1)
{
int newsize;
miArcJoinPtr join;
@@ -1755,10 +1798,11 @@ addJoin (joinsp, njoinsp, sizep, end0, index0, phase0, end1, index1, phase1)
}
static miArcDataPtr
-addArc (arcsp, narcsp, sizep, xarc)
- miArcDataPtr *arcsp;
- int *narcsp, *sizep;
- xArc *xarc;
+addArc (
+ miArcDataPtr *arcsp,
+ int *narcsp,
+ int *sizep,
+ xArc *xarc)
{
int newsize;
miArcDataPtr arc;
@@ -1780,9 +1824,9 @@ addArc (arcsp, narcsp, sizep, xarc)
}
static void
-miFreeArcs(arcs, pGC)
- miPolyArcPtr arcs;
- GCPtr pGC;
+miFreeArcs(
+ miPolyArcPtr arcs,
+ GCPtr pGC)
{
int iphase;
@@ -1819,13 +1863,16 @@ typedef struct {
double map[DASH_MAP_SIZE];
} dashMap;
+static int computeAngleFromPath(int startAngle, int endAngle, dashMap *map,
+ int *lenp, int backwards);
+
static void
-computeDashMap (arcp, map)
- xArc *arcp;
- dashMap *map;
+computeDashMap (
+ xArc *arcp,
+ dashMap *map)
{
int di;
- double a, x, y, prevx, prevy, dist;
+ double a, x, y, prevx = 0.0, prevy = 0.0, dist;
for (di = 0; di < DASH_MAP_SIZE; di++) {
a = dashIndexToAngle (di);
@@ -1847,15 +1894,15 @@ typedef enum {HORIZONTAL, VERTICAL, OTHER} arcTypes;
/* this routine is a bit gory */
static miPolyArcPtr
-miComputeArcs (parcs, narcs, pGC)
- xArc *parcs;
- int narcs;
- GCPtr pGC;
+miComputeArcs (
+ xArc *parcs,
+ int narcs,
+ GCPtr pGC)
{
int isDashed, isDoubleDash;
int dashOffset;
miPolyArcPtr arcs;
- int start, i, j, k, nexti, nextk;
+ int start, i, j, k = 0, nexti, nextk = 0;
int joinSize[2];
int capSize[2];
int arcSize[2];
@@ -1864,13 +1911,13 @@ miComputeArcs (parcs, narcs, pGC)
struct arcData *data;
miArcDataPtr arc;
xArc xarc;
- int iphase, prevphase, joinphase;
+ int iphase, prevphase = 0, joinphase;
int arcsJoin;
int selfJoin;
- int iDash, dashRemaining;
- int iDashStart, dashRemainingStart, iphaseStart;
- int startAngle, spanAngle, endAngle, backwards;
+ int iDash = 0, dashRemaining;
+ int iDashStart = 0, dashRemainingStart = 0, iphaseStart;
+ int startAngle, spanAngle, endAngle, backwards = 0;
int prevDashAngle, dashAngle;
dashMap map;
@@ -2242,9 +2289,9 @@ arcfail:
}
static double
-angleToLength (angle, map)
- int angle;
- dashMap *map;
+angleToLength (
+ int angle,
+ dashMap *map)
{
double len, excesslen, sidelen = map->map[DASH_MAP_SIZE - 1], totallen;
int di;
@@ -2292,9 +2339,9 @@ angleToLength (angle, map)
*/
static int
-lengthToAngle (len, map)
- double len;
- dashMap *map;
+lengthToAngle (
+ double len,
+ dashMap *map)
{
double sidelen = map->map[DASH_MAP_SIZE - 1];
int angle, angleexcess;
@@ -2364,11 +2411,12 @@ lengthToAngle (len, map)
*/
static int
-computeAngleFromPath (startAngle, endAngle, map, lenp, backwards)
- int startAngle, endAngle; /* normalized absolute angles in *64 degrees */
- dashMap *map;
- int *lenp;
- int backwards;
+computeAngleFromPath (
+ int startAngle,
+ int endAngle, /* normalized absolute angles in *64 degrees */
+ dashMap *map,
+ int *lenp,
+ int backwards)
{
int a0, a1, a;
double len0;
@@ -2409,14 +2457,15 @@ computeAngleFromPath (startAngle, endAngle, map, lenp, backwards)
*/
static void
-drawZeroArc (pDraw, pGC, tarc, lw, left, right)
- DrawablePtr pDraw;
- GCPtr pGC;
- xArc *tarc;
- int lw;
- miArcFacePtr right, left;
+drawZeroArc (
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *tarc,
+ int lw,
+ miArcFacePtr left,
+ miArcFacePtr right)
{
- double x0, y0, x1, y1, w, h, x, y;
+ double x0 = 0.0, y0 = 0.0, x1 = 0.0, y1 = 0.0, w, h, x, y;
double xmax, ymax, xmin, ymin;
int a0, a1;
double a, startAngle, endAngle;
@@ -2543,9 +2592,9 @@ drawZeroArc (pDraw, pGC, tarc, lw, left, right)
*/
static void
-tailEllipseY (def, acc)
- struct arc_def *def;
- struct accelerators *acc;
+tailEllipseY (
+ struct arc_def *def,
+ struct accelerators *acc)
{
double t;
@@ -2572,46 +2621,50 @@ tailEllipseY (def, acc)
*/
static double
-outerXfromXY (x, y, def, acc)
- double x, y;
- struct arc_def *def;
- struct accelerators *acc;
+outerXfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
{
return x + (x * acc->h2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
}
static double
-outerYfromXY (x, y, def, acc)
- double x, y;
- struct arc_def *def;
- struct accelerators *acc;
+outerYfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
{
return y + (y * acc->w2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
}
static double
-innerXfromXY (x, y, def, acc)
- double x, y;
- struct arc_def *def;
- struct accelerators *acc;
+innerXfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
{
return x - (x * acc->h2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
}
static double
-innerYfromXY (x, y, def, acc)
- double x, y;
- struct arc_def *def;
- struct accelerators *acc;
+innerYfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
{
return y - (y * acc->w2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
}
static double
-innerYfromY (y, def, acc)
- double y;
- struct arc_def *def;
- struct accelerators *acc;
+innerYfromY (
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
{
double x;
@@ -2621,9 +2674,12 @@ innerYfromY (y, def, acc)
}
static void
-computeLine (x1, y1, x2, y2, line)
- double x1, y1, x2, y2;
- struct line *line;
+computeLine (
+ double x1,
+ double y1,
+ double x2,
+ double y2,
+ struct line *line)
{
if (y1 == y2)
line->valid = 0;
@@ -2641,11 +2697,11 @@ computeLine (x1, y1, x2, y2, line)
*/
static void
-computeAcc (tarc, lw, def, acc)
- xArc *tarc;
- int lw;
- struct arc_def *def;
- struct accelerators *acc;
+computeAcc (
+ xArc *tarc,
+ int lw,
+ struct arc_def *def,
+ struct accelerators *acc)
{
def->w = ((double) tarc->width) / 2.0;
def->h = ((double) tarc->height) / 2.0;
@@ -2671,11 +2727,12 @@ computeAcc (tarc, lw, def, acc)
*/
static void
-computeBound (def, bound, acc, right, left)
- struct arc_def *def;
- struct arc_bound *bound;
- struct accelerators *acc;
- miArcFacePtr right, left;
+computeBound (
+ struct arc_def *def,
+ struct arc_bound *bound,
+ struct accelerators *acc,
+ miArcFacePtr right,
+ miArcFacePtr left)
{
double t;
double innerTaily;
@@ -2811,11 +2868,11 @@ computeBound (def, bound, acc, right, left)
*/
static double
-hookEllipseY (scan_y, bound, acc, left)
- double scan_y;
- struct arc_bound *bound;
- struct accelerators *acc;
- int left;
+hookEllipseY (
+ double scan_y,
+ struct arc_bound *bound,
+ struct accelerators *acc,
+ int left)
{
double ret;
@@ -2837,12 +2894,12 @@ hookEllipseY (scan_y, bound, acc, left)
*/
static double
-hookX (scan_y, def, bound, acc, left)
- double scan_y;
- struct arc_def *def;
- struct arc_bound *bound;
- struct accelerators *acc;
- int left;
+hookX (
+ double scan_y,
+ struct arc_def *def,
+ struct arc_bound *bound,
+ struct accelerators *acc,
+ int left)
{
double ellipse_y, x;
double maxMin;
@@ -2894,16 +2951,16 @@ hookX (scan_y, def, bound, acc, left)
*/
static void
-arcSpan (y, lx, lw, rx, rw, def, bounds, acc, mask)
- int y;
- int lx;
- int lw;
- int rx;
- int rw;
- struct arc_def *def;
- struct arc_bound *bounds;
- struct accelerators *acc;
- int mask;
+arcSpan (
+ int y,
+ int lx,
+ int lw,
+ int rx,
+ int rw,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc,
+ int mask)
{
int linx, loutx, rinx, routx;
double x, altx;
@@ -2964,15 +3021,15 @@ arcSpan (y, lx, lw, rx, rw, def, bounds, acc, mask)
}
static void
-arcSpan0 (lx, lw, rx, rw, def, bounds, acc, mask)
- int lx;
- int lw;
- int rx;
- int rw;
- struct arc_def *def;
- struct arc_bound *bounds;
- struct accelerators *acc;
- int mask;
+arcSpan0 (
+ int lx,
+ int lw,
+ int rx,
+ int rw,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc,
+ int mask)
{
double x;
@@ -2992,14 +3049,14 @@ arcSpan0 (lx, lw, rx, rw, def, bounds, acc, mask)
}
static void
-tailSpan (y, lw, rw, def, bounds, acc, mask)
- int y;
- int lw;
- int rw;
- struct arc_def *def;
- struct arc_bound *bounds;
- struct accelerators *acc;
- int mask;
+tailSpan (
+ int y,
+ int lw,
+ int rw,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc,
+ int mask)
{
double yy, xalt, x, lx, rx;
int n;
@@ -3101,7 +3158,7 @@ realAllocSpan ()
}
static void
-disposeFinalSpans ()
+disposeFinalSpans (void)
{
struct finalSpanChunk *chunk, *next;
@@ -3116,9 +3173,9 @@ disposeFinalSpans ()
}
static void
-fillSpans (pDrawable, pGC)
- DrawablePtr pDrawable;
- GCPtr pGC;
+fillSpans (
+ DrawablePtr pDrawable,
+ GCPtr pGC)
{
register struct finalSpan *span;
register DDXPointPtr xSpan;
@@ -3131,8 +3188,8 @@ fillSpans (pDrawable, pGC)
if (nspans == 0)
return;
- xSpan = xSpans = (DDXPointPtr) xalloc (nspans * sizeof (DDXPointRec));
- xWidth = xWidths = (int *) xalloc (nspans * sizeof (int));
+ xSpan = xSpans = (DDXPointPtr) ALLOCATE_LOCAL (nspans * sizeof (DDXPointRec));
+ xWidth = xWidths = (int *) ALLOCATE_LOCAL (nspans * sizeof (int));
if (xSpans && xWidths)
{
i = 0;
@@ -3151,8 +3208,10 @@ fillSpans (pDrawable, pGC)
(*pGC->ops->FillSpans) (pDrawable, pGC, i, xSpans, xWidths, TRUE);
}
disposeFinalSpans ();
- xfree (xSpans);
- xfree (xWidths);
+ if (xSpans)
+ DEALLOCATE_LOCAL (xSpans);
+ if (xWidths)
+ DEALLOCATE_LOCAL (xWidths);
finalMiny = 0;
finalMaxy = -1;
finalSize = 0;
@@ -3166,8 +3225,7 @@ fillSpans (pDrawable, pGC)
realFindSpan (y))
static struct finalSpan **
-realFindSpan (y)
- int y;
+realFindSpan (int y)
{
struct finalSpan **newSpans;
int newSize, newMiny, newMaxy;
@@ -3218,9 +3276,10 @@ realFindSpan (y)
}
static void
-newFinalSpan (y, xmin, xmax)
- int y;
- register int xmin, xmax;
+newFinalSpan (
+ int y,
+ register int xmin,
+ register int xmax)
{
register struct finalSpan *x;
register struct finalSpan **f;
@@ -3275,9 +3334,9 @@ newFinalSpan (y, xmin, xmax)
}
static void
-mirrorSppPoint (quadrant, sppPoint)
- int quadrant;
- SppPointPtr sppPoint;
+mirrorSppPoint (
+ int quadrant,
+ SppPointPtr sppPoint)
{
switch (quadrant) {
case 0:
@@ -3308,17 +3367,20 @@ mirrorSppPoint (quadrant, sppPoint)
*/
static void
-drawArc (tarc, l, a0, a1, right, left)
- xArc *tarc;
- int l, a0, a1;
- miArcFacePtr right, left; /* save end line points */
+drawArc (
+ xArc *tarc,
+ int l,
+ int a0,
+ int a1,
+ miArcFacePtr right,
+ miArcFacePtr left) /* save end line points */
{
struct arc_def def;
struct accelerators acc;
int startq, endq, curq;
- int rightq, leftq, righta, lefta;
+ int rightq, leftq = 0, righta = 0, lefta = 0;
miArcFacePtr passRight, passLeft;
- int q0, q1, mask;
+ int q0 = 0, q1 = 0, mask;
struct band {
int a0, a1;
int mask;
@@ -3547,13 +3609,15 @@ drawArc (tarc, l, a0, a1, right, left)
}
static void
-drawQuadrant (def, acc, a0, a1, mask, right, left, spdata)
- struct arc_def *def;
- struct accelerators *acc;
- int a0, a1;
- int mask;
- miArcFacePtr right, left;
- miArcSpanData *spdata;
+drawQuadrant (
+ struct arc_def *def,
+ struct accelerators *acc,
+ int a0,
+ int a1,
+ int mask,
+ miArcFacePtr right,
+ miArcFacePtr left,
+ miArcSpanData *spdata)
{
struct arc_bound bound;
double yy, x, xalt;