]> Pileus Git - ~andy/gtk/blobdiff - gdk/linux-fb/miarc.c
Take thickness into account in the size allocation of the child widgets in
[~andy/gtk] / gdk / linux-fb / miarc.c
index fecf5bb70994f5981f2d48c067b306ef1b8da789..ea237d9d7d12cfc84f0f9c828cc02c41f1c2db11 100644 (file)
@@ -48,6 +48,7 @@ SOFTWARE.
 #define _XOPEN_SOURCE_EXTENDED /* to get prototype for cbrt on some systems */
 #define _XOPEN_SOURCE          /* to get prototype for hypot on some systems */
 
+#include <config.h>
 #include <string.h>            /* memmove */
 #include <limits.h>
 
@@ -401,8 +402,8 @@ miComputeCircleSpans(int lw, miArc *parc, miArcSpanData *spdata)
     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;
@@ -464,7 +465,7 @@ miComputeEllipseSpans(int lw, miArc *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;
@@ -834,8 +835,7 @@ miComputeWideEllipse(int lw, miArc *parc, gboolean *mustFree)
     spdata = lruent->spdata;
     if (!spdata || spdata->k != k)
     {
-       if (spdata)
-           g_free(spdata);
+       g_free(spdata);
        spdata = (miArcSpanData *)g_malloc(sizeof(miArcSpanData) +
                                         sizeof(miArcSpan) * (k + 2));
        lruent->spdata = spdata;
@@ -986,8 +986,8 @@ miPolyArc(GdkDrawable *pDraw, GdkGC *pGC, int narcs, miArc *parcs)
     register int               i;
     miArc                      *parc;
     int                                xMin, xMax, yMin, yMax;
-    int                                pixmapWidth, pixmapHeight;
-    int                                xOrg, yOrg;
+    int                                pixmapWidth = 0, pixmapHeight = 0;
+    int                                xOrg = 0, yOrg = 0;
     int                                width;
     gboolean                   fTricky;
     GdkDrawable*               pDrawTo;
@@ -1197,8 +1197,7 @@ miPolyArc(GdkDrawable *pDraw, GdkGC *pGC, int narcs, miArc *parcs)
 }
 
 static double
-angleBetween (center, point1, point2)
-       SppPointRec     center, point1, point2;
+angleBetween (SppPointRec center, SppPointRec point1, SppPointRec point2)
 {
        double  a1, a2, a;
        
@@ -1217,10 +1216,7 @@ 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;
@@ -1243,7 +1239,7 @@ miArcJoin (GdkDrawable *pDraw, GdkGC *pGC, miArcFacePtr pLeft, miArcFacePtr pRig
        int             cpt;
        SppArcRec       arc;
        miArcFaceRec    Right, Left;
-       int             polyLen;
+       int             polyLen = 0;
        int             xOrg, yOrg;
        double          xFtrans, yFtrans;
        double          a;
@@ -1341,13 +1337,8 @@ miArcJoin (GdkDrawable *pDraw, GdkGC *pGC, miArcFacePtr pLeft, miArcFacePtr pRig
 
 /*ARGSUSED*/
 static void
-miArcCap (pDraw, pGC, pFace, end, xOrg, yOrg, xFtrans, yFtrans)
-       GdkDrawable*    pDraw;
-       GdkGC*          pGC;
-       miArcFacePtr    pFace;
-       int             end;
-       int             xOrg, yOrg;
-       double          xFtrans, yFtrans;
+miArcCap (GdkDrawable *pDraw, GdkGC *pGC, miArcFacePtr pFace, int end,
+          int xOrg, int yOrg, double xFtrans, double yFtrans)
 {
        SppPointRec     corner, otherCorner, center, endPoint, poly[5];
 
@@ -1399,7 +1390,6 @@ static void miRoundCap(GdkDrawable *pDraw, GdkGC *pGC, SppPointRec pCenter, SppP
 {
     int                cpt;
     double     width;
-    double     miDatan2 ();
     SppArcRec  arc;
     SppPointPtr        pArcPts;
 
@@ -1409,7 +1399,7 @@ static void miRoundCap(GdkDrawable *pDraw, GdkGC *pGC, SppPointRec pCenter, SppP
     arc.y = pCenter.y - width/2;
     arc.width = width;
     arc.height = width;
-    arc.angle1 = -miDatan2 (pCorner.y - pCenter.y, pCorner.x - pCenter.x);
+    arc.angle1 = -(miDatan2 (pCorner.y - pCenter.y, pCorner.x - pCenter.x));
     if(PTISEQUAL(pCenter, pEnd))
        arc.angle2 = - 180.0;
     else {
@@ -1445,8 +1435,7 @@ static void miRoundCap(GdkDrawable *pDraw, GdkGC *pGC, SppPointRec pCenter, SppP
 # define mod(a,b)      ((a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 static double
-miDcos (a)
-double a;
+miDcos (double a)
 {
        int     i;
 
@@ -1463,8 +1452,7 @@ double    a;
 }
 
 static double
-miDsin (a)
-double a;
+miDsin (double a)
 {
        int     i;
 
@@ -1481,8 +1469,7 @@ double    a;
 }
 
 static double
-miDasin (v)
-double v;
+miDasin (double v)
 {
     if (v == 0)
        return 0.0;
@@ -1494,8 +1481,7 @@ double    v;
 }
 
 static double
-miDatan2 (dy, dx)
-double dy, dx;
+miDatan2 (double dy, double dx)
 {
     if (dy == 0) {
        if (dx >= 0)
@@ -1612,7 +1598,7 @@ miGetArcPts(SppArcPtr parc, int cpt, SppPointPtr *ppPts)
        x1 = x2; y1 = y2;
     }
     /* adjust the last point */
-    if (abs(parc->angle2) >= 360.0)
+    if (fabs(parc->angle2) >= 360.0)
        poly[cpt +i -1] = poly[0];
     else {
        poly[cpt +i -1].x = (miDcos(st + et) * parc->width/2.0 + xc);
@@ -1630,10 +1616,7 @@ 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;
@@ -1655,10 +1638,8 @@ 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;
@@ -1684,10 +1665,7 @@ addJoin (joinsp, njoinsp, sizep, end0, index0, phase0, end1, index1, phase1)
 }
 
 static miArcDataPtr
-addArc (arcsp, narcsp, sizep, xarc)
-       miArcDataPtr    *arcsp;
-       int             *narcsp, *sizep;
-       miArc           *xarc;
+addArc (miArcDataPtr *arcsp, int *narcsp, int *sizep, miArc *xarc)
 {
        int newsize;
        miArcDataPtr    arc;
@@ -1741,12 +1719,10 @@ miFreeArcs(miPolyArcPtr arcs, GdkGC *pGC)
 # define dashXAngleStep        (((double) (90 * 64)) / ((double) (DASH_MAP_SIZE - 1)))
 
 static void
-computeDashMap (arcp, map)
-       miArc   *arcp;
-       dashMap *map;
+computeDashMap (miArc *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);
@@ -1773,7 +1749,7 @@ miComputeArcs (miArc *parcs, int narcs, GdkGC *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];
@@ -1782,13 +1758,13 @@ miComputeArcs (miArc *parcs, int narcs, GdkGC *pGC)
        struct arcData  *data;
        miArcDataPtr    arc;
        miArc           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;
 
@@ -1822,15 +1798,15 @@ miComputeArcs (miArc *parcs, int narcs, GdkGC *pGC)
 
        for (iphase = 0; iphase < (isDoubleDash ? 2 : 1); iphase++) {
                arcs[iphase].njoins = 0;
-               arcs[iphase].joins = 0;
+               arcs[iphase].joins = NULL;
                joinSize[iphase] = 0;
                
                arcs[iphase].ncaps = 0;
-               arcs[iphase].caps = 0;
+               arcs[iphase].caps = NULL;
                capSize[iphase] = 0;
                
                arcs[iphase].narcs = 0;
-               arcs[iphase].arcs = 0;
+               arcs[iphase].arcs = NULL;
                arcSize[iphase] = 0;
        }
 
@@ -1936,7 +1912,7 @@ miComputeArcs (miArc *parcs, int narcs, GdkGC *pGC)
                        /*
                         * add dashed arcs to each bucket
                         */
-                       arc = 0;
+                       arc = NULL;
                        while (dashAngle != endAngle) {
                                prevDashAngle = dashAngle;
                                if (arcType == OTHER) {
@@ -2160,9 +2136,7 @@ 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;
@@ -2210,9 +2184,7 @@ 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;
@@ -2323,14 +2295,10 @@ static int computeAngleFromPath(int startAngle, int endAngle, dashMap *map, int
  */
 
 static void
-drawZeroArc (pDraw, pGC, tarc, lw, left, right)
-    GdkDrawable*   pDraw;
-    GdkGC*         pGC;
-    miArc          *tarc;
-    int                  lw;
-    miArcFacePtr       right, left;
+drawZeroArc (GdkDrawable *pDraw, GdkGC *pGC, miArc *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;
@@ -2453,9 +2421,7 @@ 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;
 
@@ -2482,46 +2448,35 @@ 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;
 
@@ -2531,9 +2486,7 @@ 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;
@@ -2551,11 +2504,7 @@ computeLine (x1, y1, x2, y2, line)
  */
 
 static void
-computeAcc (tarc, lw, def, acc)
-       miArc                   *tarc;
-       int                     lw;
-       struct arc_def          *def;
-       struct accelerators     *acc;
+computeAcc (miArc *tarc, int lw, struct arc_def *def, struct accelerators *acc)
 {
        def->w = ((double) tarc->width) / 2.0;
        def->h = ((double) tarc->height) / 2.0;
@@ -2581,11 +2530,8 @@ 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;
@@ -2721,11 +2667,8 @@ 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;
 
@@ -2747,12 +2690,8 @@ 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;
@@ -2804,16 +2743,9 @@ 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;
@@ -2874,15 +2806,9 @@ 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;
 
@@ -2902,14 +2828,9 @@ 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;
@@ -2974,7 +2895,7 @@ static struct finalSpan    *freeFinalSpans, *tmpFinalSpan;
 # define allocFinalSpan()   (freeFinalSpans ?\
                                ((tmpFinalSpan = freeFinalSpans), \
                                 (freeFinalSpans = freeFinalSpans->next), \
-                                (tmpFinalSpan->next = 0), \
+                                (tmpFinalSpan->next = NULL), \
                                 tmpFinalSpan) : \
                             realAllocSpan ())
 
@@ -2988,7 +2909,7 @@ struct finalSpanChunk {
 static struct finalSpanChunk   *chunks;
 
 struct finalSpan *
-realAllocSpan ()
+realAllocSpan (void)
 {
        register struct finalSpanChunk  *newChunk;
        register struct finalSpan       *span;
@@ -3004,14 +2925,14 @@ realAllocSpan ()
                span->next = span+1;
                span++;
        }
-       span->next = 0;
+       span->next = NULL;
        span = newChunk->data;
-       span->next = 0;
+       span->next = NULL;
        return span;
 }
 
 static void
-disposeFinalSpans ()
+disposeFinalSpans (void)
 {
        struct finalSpanChunk   *chunk, *next;
 
@@ -3019,16 +2940,14 @@ disposeFinalSpans ()
                next = chunk->next;
                g_free (chunk);
        }
-       chunks = 0;
-       freeFinalSpans = 0;
+       chunks = NULL;
+       freeFinalSpans = NULL;
        g_free(finalSpans);
-       finalSpans = 0;
+       finalSpans = NULL;
 }
 
 static void
-fillSpans (pDrawable, pGC)
-    GdkDrawable*       pDrawable;
-    GdkGC*     pGC;
+fillSpans (GdkDrawable *pDrawable, GdkGC *pGC)
 {
        register struct finalSpan       *span;
        register GdkSpan*               xSpan;
@@ -3074,8 +2993,7 @@ fillSpans (pDrawable, pGC)
                          realFindSpan (y))
 
 static struct finalSpan **
-realFindSpan (y)
-    int y;
+realFindSpan (int y)
 {
        struct finalSpan        **newSpans;
        int                     newSize, newMiny, newMaxy;
@@ -3126,9 +3044,7 @@ 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;
@@ -3138,9 +3054,9 @@ newFinalSpan (y, xmin, xmax)
        f = findSpan (y);
        if (!f)
            return;
-       oldx = 0;
+       oldx = NULL;
        for (;;) {
-               prev = 0;
+               prev = NULL;
                for (x = *f; x; x=x->next) {
                        if (x == oldx) {
                                prev = x;
@@ -3183,9 +3099,7 @@ newFinalSpan (y, xmin, xmax)
 }
 
 static void
-mirrorSppPoint (quadrant, sppPoint)
-       int             quadrant;
-       SppPointPtr     sppPoint;
+mirrorSppPoint (int quadrant, SppPointPtr sppPoint)
 {
        switch (quadrant) {
        case 0:
@@ -3222,9 +3136,9 @@ drawArc (miArc *tarc, int l, int a0, int a1, miArcFacePtr right, miArcFacePtr le
        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;
@@ -3386,7 +3300,7 @@ drawArc (miArc *tarc, int l, int a0, int a1, miArcFacePtr right, miArcFacePtr le
        computeAcc (tarc, l, &def, &acc);
        for (j = 0; j < sweepno; j++) {
                mask = sweep[j].mask;
-               passRight = passLeft = 0;
+               passRight = passLeft = NULL;
                if (mask & (1 << rightq)) {
                        if (sweep[j].a0 == righta)
                                passRight = right;
@@ -3453,13 +3367,9 @@ drawArc (miArc *tarc, int l, int a0, int a1, miArcFacePtr right, miArcFacePtr le
 }
 
 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;