aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/PolyReg.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-10-12 08:32:04 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-10-12 08:32:04 +0200
commit051d521f6e20761ba6831cecd91883da960fa931 (patch)
treeb28abba7818115d2fed80eb360a79a0f9183948e /nx-X11/lib/X11/PolyReg.c
parent6dce607bad8711dd06a5a7b69ad1930386b4123b (diff)
parentb8de7bf654929c823080b211aeac56cd213f5a32 (diff)
downloadnx-libs-051d521f6e20761ba6831cecd91883da960fa931.tar.gz
nx-libs-051d521f6e20761ba6831cecd91883da960fa931.tar.bz2
nx-libs-051d521f6e20761ba6831cecd91883da960fa931.zip
Merge branch 'uli42-pr/upgrade_libX11' into 3.6.x
Attributes GH PR #214: https://github.com/ArcticaProject/nx-libs/pull/214 Fixes ArcticaProject/nx-libs#157.
Diffstat (limited to 'nx-X11/lib/X11/PolyReg.c')
-rw-r--r--nx-X11/lib/X11/PolyReg.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/nx-X11/lib/X11/PolyReg.c b/nx-X11/lib/X11/PolyReg.c
index 6cff945b7..6ac2e2897 100644
--- a/nx-X11/lib/X11/PolyReg.c
+++ b/nx-X11/lib/X11/PolyReg.c
@@ -27,13 +27,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
+both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
+software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -82,7 +82,7 @@ InsertEdgeInET(
*/
pPrevSLL = &ET->scanlines;
pSLL = pPrevSLL->next;
- while (pSLL && (pSLL->scanline < scanline))
+ while (pSLL && (pSLL->scanline < scanline))
{
pPrevSLL = pSLL;
pSLL = pSLL->next;
@@ -91,11 +91,11 @@ InsertEdgeInET(
/*
* reassign pSLL (pointer to ScanLineList) if necessary
*/
- if ((!pSLL) || (pSLL->scanline > scanline))
+ if ((!pSLL) || (pSLL->scanline > scanline))
{
- if (*iSLLBlock > SLLSPERBLOCK-1)
+ if (*iSLLBlock > SLLSPERBLOCK-1)
{
- tmpSLLBlock =
+ tmpSLLBlock =
(ScanLineListBlock *)Xmalloc(sizeof(ScanLineListBlock));
(*SLLBlock)->next = tmpSLLBlock;
tmpSLLBlock->next = (ScanLineListBlock *)NULL;
@@ -115,7 +115,7 @@ InsertEdgeInET(
*/
prev = (EdgeTableEntry *)NULL;
start = pSLL->edgelist;
- while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
+ while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
{
prev = start;
start = start->next;
@@ -132,7 +132,7 @@ InsertEdgeInET(
* CreateEdgeTable
*
* This routine creates the edge table for
- * scan converting polygons.
+ * scan converting polygons.
* The Edge Table (ET) looks like:
*
* EdgeTable
@@ -192,19 +192,19 @@ CreateETandAET(
* In this loop we are dealing with two vertices at
* a time -- these make up one edge of the polygon.
*/
- while (count--)
+ while (count--)
{
CurrPt = pts++;
/*
* find out which point is above and which is below.
*/
- if (PrevPt->y > CurrPt->y)
+ if (PrevPt->y > CurrPt->y)
{
bottom = PrevPt, top = CurrPt;
pETEs->ClockWise = 0;
}
- else
+ else
{
bottom = CurrPt, top = PrevPt;
pETEs->ClockWise = 1;
@@ -213,7 +213,7 @@ CreateETandAET(
/*
* don't add horizontal edges to the Edge table.
*/
- if (bottom->y != top->y)
+ if (bottom->y != top->y)
{
pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */
@@ -255,9 +255,9 @@ loadAET(
pPrevAET = AET;
AET = AET->next;
- while (ETEs)
+ while (ETEs)
{
- while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
+ while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
{
pPrevAET = AET;
AET = AET->next;
@@ -279,13 +279,13 @@ loadAET(
*
* This routine links the AET by the
* nextWETE (winding EdgeTableEntry) link for
- * use by the winding number rule. The final
+ * use by the winding number rule. The final
* Active Edge Table (AET) might look something
* like:
*
* AET
* ---------- --------- ---------
- * |ymax | |ymax | |ymax |
+ * |ymax | |ymax | |ymax |
* | ... | |... | |... |
* |next |->|next |->|next |->...
* |nextWETE| |nextWETE| |nextWETE|
@@ -305,7 +305,7 @@ computeWAET(
AET->nextWETE = (EdgeTableEntry *)NULL;
pWETE = AET;
AET = AET->next;
- while (AET)
+ while (AET)
{
if (AET->ClockWise)
isInside++;
@@ -313,7 +313,7 @@ computeWAET(
isInside--;
if ((!inside && !isInside) ||
- ( inside && isInside))
+ ( inside && isInside))
{
pWETE->nextWETE = AET;
pWETE = AET;
@@ -343,7 +343,7 @@ InsertionSort(
register int changed = 0;
AET = AET->next;
- while (AET)
+ while (AET)
{
pETEinsert = AET;
pETEchase = AET;
@@ -351,7 +351,7 @@ InsertionSort(
pETEchase = pETEchase->back;
AET = AET->next;
- if (pETEchase != pETEinsert)
+ if (pETEchase != pETEinsert)
{
pETEchaseBackTMP = pETEchase->back;
pETEinsert->back->next = AET;
@@ -376,7 +376,7 @@ FreeStorage(
{
register ScanLineListBlock *tmpSLLBlock;
- while (pSLLBlock)
+ while (pSLLBlock)
{
tmpSLLBlock = pSLLBlock->next;
Xfree((char *)pSLLBlock);
@@ -407,21 +407,21 @@ static int PtsToRegion(
BOX *prevRects = reg->rects;
extents = &reg->extents;
-
+
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
-
- if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects,
+
+ if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects,
(unsigned) (sizeof(BOX) * numRects)))) {
Xfree(prevRects);
return(0);
}
-
+
reg->size = numRects;
CurPtBlock = FirstPtBlock;
rects = reg->rects - 1;
numRects = 0;
extents->x1 = MAXSHORT, extents->x2 = MINSHORT;
-
+
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
/* the loop uses 2 points per iteration */
i = NUMPTSTOBUFFER >> 1;
@@ -459,7 +459,7 @@ static int PtsToRegion(
extents->y2 = 0;
}
reg->numRects = numRects;
-
+
return(TRUE);
}
@@ -470,11 +470,11 @@ static int PtsToRegion(
* encoding of the resultant bitmap -- the run-length
* encoding is in the form of an array of rectangles.
*/
-Region
-XPolygonRegion(Pts, Count, rule)
- int Count; /* number of pts */
- XPoint *Pts; /* the pts */
- int rule; /* winding rule */
+Region
+XPolygonRegion(
+ XPoint *Pts, /* the pts */
+ int Count, /* number of pts */
+ int rule) /* winding rule */
{
Region region;
register EdgeTableEntry *pAET; /* Active Edge Table */
@@ -492,7 +492,7 @@ XPolygonRegion(Pts, Count, rule)
POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */
POINTBLOCK *tmpPtBlock;
int numFullPtBlocks = 0;
-
+
if (! (region = XCreateRegion())) return (Region) NULL;
/* special case a rectangle */
@@ -518,18 +518,20 @@ XPolygonRegion(Pts, Count, rule)
}
return(region);
}
-
+
if (Count < 2) return region;
if (! (pETEs = (EdgeTableEntry *)
- Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count))))
+ Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) {
+ XDestroyRegion(region);
return (Region) NULL;
+ }
pts = FirstPtBlock.pts;
CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
pSLL = ET.scanlines.next;
curPtBlock = &FirstPtBlock;
-
+
if (rule == EvenOddRule) {
/*
* for each scanline
@@ -545,14 +547,14 @@ XPolygonRegion(Pts, Count, rule)
}
pPrevAET = &AET;
pAET = AET.next;
-
+
/*
* for each active edge
*/
while (pAET) {
pts->x = pAET->bres.minor_axis, pts->y = y;
pts++, iPts++;
-
+
/*
* send out the buffer
*/
@@ -586,7 +588,7 @@ XPolygonRegion(Pts, Count, rule)
pPrevAET = &AET;
pAET = AET.next;
pWETE = pAET;
-
+
/*
* for each active edge
*/
@@ -598,7 +600,7 @@ XPolygonRegion(Pts, Count, rule)
if (pWETE == pAET) {
pts->x = pAET->bres.minor_axis, pts->y = y;
pts++, iPts++;
-
+
/*
* send out the buffer
*/
@@ -613,7 +615,7 @@ XPolygonRegion(Pts, Count, rule)
}
EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
}
-
+
/*
* recompute the winding active edge table if
* we just resorted or have exited an edge.
@@ -624,7 +626,7 @@ XPolygonRegion(Pts, Count, rule)
}
}
}
- FreeStorage(SLLBlock.next);
+ FreeStorage(SLLBlock.next);
(void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
tmpPtBlock = curPtBlock->next;