summaryrefslogtreecommitdiff
path: root/xserver/mi/miarc.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2010-12-05 15:36:12 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2010-12-05 15:36:12 +0000
commita90ee792d96752ad1b71b9ada922fa6afe478c99 (patch)
tree6143b00f7646951d23dfe2a4fe2992ca40b77069 /xserver/mi/miarc.c
parentbc97d4ecc0aa9e1b823565b07282f848700bd11a (diff)
Upgrade to xorg-server 1.9.2.
Tested by ajacoutot@, krw@, shadchin@ and jasper@ on various configurations including multihead with both zaphod and xrandr.
Diffstat (limited to 'xserver/mi/miarc.c')
-rw-r--r--xserver/mi/miarc.c224
1 files changed, 62 insertions, 162 deletions
diff --git a/xserver/mi/miarc.c b/xserver/mi/miarc.c
index ddcbff78a..881e0db03 100644
--- a/xserver/mi/miarc.c
+++ b/xserver/mi/miarc.c
@@ -213,16 +213,6 @@ typedef struct _miPolyArc {
miArcJoinPtr joins;
} miPolyArcRec, *miPolyArcPtr;
-#define GCValsFunction 0
-#define GCValsForeground 1
-#define GCValsBackground 2
-#define GCValsLineWidth 3
-#define GCValsCapStyle 4
-#define GCValsJoinStyle 5
-#define GCValsMask (GCFunction | GCForeground | GCBackground | \
- GCLineWidth | GCCapStyle | GCJoinStyle)
-static CARD32 gcvals[6];
-
static void fillSpans(DrawablePtr pDrawable, GCPtr pGC);
static void newFinalSpan(int y, int xmin, int xmax);
static void drawArc(xArc *tarc, int l, int a0, int a1, miArcFacePtr right,
@@ -385,47 +375,10 @@ typedef struct {
char top, bot, hole;
} miArcSpanData;
-typedef struct {
- unsigned long lrustamp;
- unsigned short lw;
- unsigned short width, height;
- miArcSpanData *spdata;
-} arcCacheRec;
-
-#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];
-static RESTYPE cacheType;
-
-static int
-miFreeArcCache (pointer data, XID id)
-{
- int k;
- arcCacheRec *cent;
-
- if (id)
- cacheType = 0;
-
- for (k = CACHESIZE, cent = &arcCache[0]; --k >= 0; cent++)
- {
- if (cent->spdata)
- {
- cent->lrustamp = 0;
- cent->lw = 0;
- xfree(cent->spdata);
- cent->spdata = NULL;
- }
- }
- lrustamp = 0;
- return Success;
-}
-
static void
miComputeCircleSpans(
int lw,
@@ -829,76 +782,21 @@ tailX(
}
static miArcSpanData *
-miComputeWideEllipse(
- int lw,
- xArc *parc,
- Bool *mustFree)
+miComputeWideEllipse(int lw, xArc *parc)
{
- miArcSpanData *spdata;
- arcCacheRec *cent, *lruent;
+ miArcSpanData *spdata = NULL;
int k;
- arcCacheRec fakeent;
if (!lw)
lw = 1;
- if (parc->height <= 1500)
- {
- *mustFree = FALSE;
- cent = lastCacheHit;
- if (cent->lw == lw &&
- cent->width == parc->width && cent->height == parc->height)
- {
- cent->lrustamp = ++lrustamp;
- return cent->spdata;
- }
- lruent = &arcCache[0];
- for (k = CACHESIZE, cent = lruent; --k >= 0; cent++)
- {
- if (cent->lw == lw &&
- cent->width == parc->width && cent->height == parc->height)
- {
- cent->lrustamp = ++lrustamp;
- lastCacheHit = cent;
- return cent->spdata;
- }
- if (cent->lrustamp < lruent->lrustamp)
- lruent = cent;
- }
- if (!cacheType)
- {
- cacheType = CreateNewResourceType(miFreeArcCache, "miArcCache");
- (void) AddResource(FakeClientID(0), cacheType, NULL);
- }
- } else {
- lruent = &fakeent;
- lruent->spdata = NULL;
- *mustFree = TRUE;
- }
k = (parc->height >> 1) + ((lw - 1) >> 1);
- spdata = lruent->spdata;
- if (!spdata || spdata->k != k)
- {
- if (spdata)
- xfree(spdata);
- spdata = xalloc(sizeof(miArcSpanData) + sizeof(miArcSpan) * (k + 2));
- lruent->spdata = spdata;
- if (!spdata)
- {
- lruent->lrustamp = 0;
- lruent->lw = 0;
- return spdata;
- }
- spdata->spans = (miArcSpan *)(spdata + 1);
- spdata->k = k;
- }
+ spdata = malloc(sizeof(miArcSpanData) + sizeof(miArcSpan) * (k + 2));
+ if (!spdata)
+ return NULL;
+ spdata->spans = (miArcSpan *)(spdata + 1);
+ spdata->k = k;
spdata->top = !(lw & 1) && !(parc->width & 1);
spdata->bot = !(parc->height & 1);
- lruent->lrustamp = ++lrustamp;
- lruent->lw = lw;
- lruent->width = parc->width;
- lruent->height = parc->height;
- if (lruent != &fakeent)
- lastCacheHit = lruent;
if (parc->width == parc->height)
miComputeCircleSpans(lw, parc, spdata);
else
@@ -917,21 +815,20 @@ miFillWideEllipse(
int *widths;
int *wids;
miArcSpanData *spdata;
- Bool mustFree;
miArcSpan *span;
int xorg, yorgu, yorgl;
int n;
yorgu = parc->height + pGC->lineWidth;
n = (sizeof(int) * 2) * yorgu;
- widths = xalloc(n + (sizeof(DDXPointRec) * 2) * yorgu);
+ widths = malloc(n + (sizeof(DDXPointRec) * 2) * yorgu);
if (!widths)
return;
points = (DDXPointPtr)((char *)widths + n);
- spdata = miComputeWideEllipse((int)pGC->lineWidth, parc, &mustFree);
+ spdata = miComputeWideEllipse((int)pGC->lineWidth, parc);
if (!spdata)
{
- xfree(widths);
+ free(widths);
return;
}
pts = points;
@@ -1020,11 +917,10 @@ miFillWideEllipse(
wids += 2;
}
}
- if (mustFree)
- xfree(spdata);
+ free(spdata);
(*pGC->ops->FillSpans)(pDraw, pGC, pts - points, points, widths, FALSE);
- xfree(widths);
+ free(widths);
}
/*
@@ -1139,13 +1035,18 @@ miPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
pGCTo = GetScratchGC(1, pDraw->pScreen);
if (!pGCTo)
return;
- gcvals[GCValsFunction] = GXcopy;
- gcvals[GCValsForeground] = 1;
- gcvals[GCValsBackground] = 0;
- gcvals[GCValsLineWidth] = pGC->lineWidth;
- gcvals[GCValsCapStyle] = pGC->capStyle;
- gcvals[GCValsJoinStyle] = pGC->joinStyle;
- dixChangeGC(NullClient, pGCTo, GCValsMask, gcvals, NULL);
+ {
+ 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 */
@@ -1184,11 +1085,14 @@ miPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
iphase >= 0;
iphase--)
{
+ ChangeGCVal gcval;
if (iphase == 1) {
- dixChangeGC (NullClient, pGC, GCForeground, &bg, NULL);
+ gcval.val = bg;
+ ChangeGC (NullClient, pGC, GCForeground, &gcval);
ValidateGC (pDraw, pGC);
} else if (pGC->lineStyle == LineDoubleDash) {
- dixChangeGC (NullClient, pGC, GCForeground, &fg, NULL);
+ gcval.val = fg;
+ ChangeGC (NullClient, pGC, GCForeground, &gcval);
ValidateGC (pDraw, pGC);
}
for (i = 0; i < polyArcs[iphase].narcs; i++) {
@@ -1360,7 +1264,7 @@ miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
arc.height = width;
arc.angle1 = -miDatan2 (corner.y - center.y, corner.x - center.x);
arc.angle2 = a;
- pArcPts = xalloc (3 * sizeof (SppPointRec));
+ pArcPts = malloc(3 * sizeof (SppPointRec));
if (!pArcPts)
return;
pArcPts[0].x = otherCorner.x;
@@ -1376,7 +1280,7 @@ miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
* rest of the line */
miFillSppPoly(pDraw, pGC, cpt, pArcPts, xOrg, yOrg, xFtrans, yFtrans);
}
- xfree(pArcPts);
+ free(pArcPts);
return;
case JoinMiter:
/*
@@ -1507,7 +1411,7 @@ miRoundCap(
* rest of the line */
miFillSppPoly(pDraw, pGC, cpt, pArcPts, -xOrg, -yOrg, xFtrans, yFtrans);
}
- xfree(pArcPts);
+ free(pArcPts);
}
/*
@@ -1605,10 +1509,10 @@ miDatan2 (double dy, double 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 malloc()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 realloc() to handle the null pointer correctly.
*/
static int
miGetArcPts(
@@ -1655,9 +1559,9 @@ miGetArcPts(
count++;
cdt = 2 * miDcos(dt);
- if (!(poly = (SppPointPtr) xrealloc((pointer)*ppPts,
+ if (!(poly = (SppPointPtr) realloc((pointer)*ppPts,
(cpt + count) * sizeof(SppPointRec))))
- return(0);
+ return 0;
*ppPts = poly;
xc = parc->width/2.0; /* store half width and half height */
@@ -1694,7 +1598,7 @@ miGetArcPts(
poly[cpt +i -1].y = (miDsin(st + et) * parc->height/2.0 + yc);
}
- return(count);
+ return count;
}
struct arcData {
@@ -1718,7 +1622,7 @@ addCap (
if (*ncapsp == *sizep)
{
newsize = *sizep + ADD_REALLOC_STEP;
- cap = (miArcCapPtr) xrealloc (*capsp,
+ cap = (miArcCapPtr) realloc(*capsp,
newsize * sizeof (**capsp));
if (!cap)
return;
@@ -1749,7 +1653,7 @@ addJoin (
if (*njoinsp == *sizep)
{
newsize = *sizep + ADD_REALLOC_STEP;
- join = (miArcJoinPtr) xrealloc (*joinsp,
+ join = (miArcJoinPtr) realloc(*joinsp,
newsize * sizeof (**joinsp));
if (!join)
return;
@@ -1779,7 +1683,7 @@ addArc (
if (*narcsp == *sizep)
{
newsize = *sizep + ADD_REALLOC_STEP;
- arc = (miArcDataPtr) xrealloc (*arcsp,
+ arc = (miArcDataPtr) realloc(*arcsp,
newsize * sizeof (**arcsp));
if (!arc)
return NULL;
@@ -1804,13 +1708,13 @@ miFreeArcs(
iphase--)
{
if (arcs[iphase].narcs > 0)
- xfree(arcs[iphase].arcs);
+ free(arcs[iphase].arcs);
if (arcs[iphase].njoins > 0)
- xfree(arcs[iphase].joins);
+ free(arcs[iphase].joins);
if (arcs[iphase].ncaps > 0)
- xfree(arcs[iphase].caps);
+ free(arcs[iphase].caps);
}
- xfree(arcs);
+ free(arcs);
}
/*
@@ -1894,13 +1798,13 @@ miComputeArcs (
isDoubleDash = (pGC->lineStyle == LineDoubleDash);
dashOffset = pGC->dashOffset;
- data = xalloc (narcs * sizeof (struct arcData));
+ data = malloc(narcs * sizeof (struct arcData));
if (!data)
return NULL;
- arcs = xalloc (sizeof (*arcs) * (isDoubleDash ? 2 : 1));
+ arcs = malloc(sizeof (*arcs) * (isDoubleDash ? 2 : 1));
if (!arcs)
{
- xfree(data);
+ free(data);
return NULL;
}
for (i = 0; i < narcs; i++) {
@@ -2249,11 +2153,11 @@ miComputeArcs (
arcs[iphase].arcs[arcs[iphase].narcs-1].cap =
arcs[iphase].ncaps;
}
- xfree(data);
+ free(data);
return arcs;
arcfail:
miFreeArcs(arcs, pGC);
- xfree(data);
+ free(data);
return NULL;
}
@@ -3110,7 +3014,7 @@ realAllocSpan (void)
struct finalSpan *span;
int i;
- newChunk = xalloc (sizeof (struct finalSpanChunk));
+ newChunk = malloc(sizeof (struct finalSpanChunk));
if (!newChunk)
return (struct finalSpan *) NULL;
newChunk->next = chunks;
@@ -3133,11 +3037,11 @@ disposeFinalSpans (void)
for (chunk = chunks; chunk; chunk = next) {
next = chunk->next;
- xfree (chunk);
+ free(chunk);
}
chunks = 0;
freeFinalSpans = 0;
- xfree(finalSpans);
+ free(finalSpans);
finalSpans = 0;
}
@@ -3157,8 +3061,8 @@ fillSpans (
if (nspans == 0)
return;
- xSpan = xSpans = xalloc (nspans * sizeof (DDXPointRec));
- xWidth = xWidths = xalloc (nspans * sizeof (int));
+ xSpan = xSpans = malloc(nspans * sizeof (DDXPointRec));
+ xWidth = xWidths = malloc(nspans * sizeof (int));
if (xSpans && xWidths)
{
i = 0;
@@ -3177,10 +3081,8 @@ fillSpans (
(*pGC->ops->FillSpans) (pDrawable, pGC, i, xSpans, xWidths, TRUE);
}
disposeFinalSpans ();
- if (xSpans)
- xfree (xSpans);
- if (xWidths)
- xfree (xWidths);
+ free(xSpans);
+ free(xWidths);
finalMiny = 0;
finalMaxy = -1;
finalSize = 0;
@@ -3215,7 +3117,7 @@ realFindSpan (int y)
else
change = SPAN_REALLOC;
newSize = finalSize + change;
- newSpans = xalloc(newSize * sizeof (struct finalSpan *));
+ newSpans = malloc(newSize * sizeof (struct finalSpan *));
if (!newSpans)
return NULL;
newMiny = finalMiny;
@@ -3228,12 +3130,12 @@ realFindSpan (int y)
memmove(((char *) newSpans) + (finalMiny-newMiny) * sizeof (struct finalSpan *),
(char *) finalSpans,
finalSize * sizeof (struct finalSpan *));
- xfree (finalSpans);
+ free(finalSpans);
}
if ((i = finalMiny - newMiny) > 0)
- bzero ((char *)newSpans, i * sizeof (struct finalSpan *));
+ memset((char *)newSpans, 0, i * sizeof (struct finalSpan *));
if ((i = newMaxy - finalMaxy) > 0)
- bzero ((char *)(newSpans + newSize - i),
+ memset((char *)(newSpans + newSize - i), 0,
i * sizeof (struct finalSpan *));
finalSpans = newSpans;
finalMaxy = newMaxy;
@@ -3358,9 +3260,8 @@ drawArc (
int flipRight = 0, flipLeft = 0;
int copyEnd = 0;
miArcSpanData *spdata;
- Bool mustFree;
- spdata = miComputeWideEllipse(l, tarc, &mustFree);
+ spdata = miComputeWideEllipse(l, tarc);
if (!spdata)
return;
@@ -3572,8 +3473,7 @@ drawArc (
left->counterClock = temp;
}
}
- if (mustFree)
- xfree(spdata);
+ free(spdata);
}
static void