aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/Region.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/X11/Region.c')
-rw-r--r--nx-X11/lib/X11/Region.c234
1 files changed, 44 insertions, 190 deletions
diff --git a/nx-X11/lib/X11/Region.c b/nx-X11/lib/X11/Region.c
index 06f7e2547..5ce276279 100644
--- a/nx-X11/lib/X11/Region.c
+++ b/nx-X11/lib/X11/Region.c
@@ -27,13 +27,13 @@ Copyright 1987, 1988 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
@@ -322,9 +322,9 @@ XOffsetRegion(
return 1;
}
-/*
+/*
Utility procedure Compress:
- Replace r by the region r', where
+ Replace r by the region r', where
p in r' iff (Quantifer m <= dx) (p + m in r), and
Quantifier is Exists if grow is TRUE, For all if grow is FALSE, and
(x,y) + m = (x+m,y) if xdir is TRUE; (x,y+m) if xdir is FALSE.
@@ -395,23 +395,6 @@ XShrinkRegion(
return 0;
}
-#ifdef notdef
-/***********************************************************
- * Bop down the array of rects until we have passed
- * scanline y. numRects is the size of the array.
- ***********************************************************/
-
-static BOX
-*IndexRects(
- register BOX *rects,
- register int numRects,
- register int y)
-{
- while ((numRects--) && (rects->y2 <= y))
- rects++;
- return(rects);
-}
-#endif
/*======================================================================
* Region Intersection
@@ -505,9 +488,9 @@ XIntersectRegion(
(!EXTENTCHECK(&reg1->extents, &reg2->extents)))
newReg->numRects = 0;
else
- miRegionOp (newReg, reg1, reg2,
+ miRegionOp (newReg, reg1, reg2,
miIntersectO, NULL, NULL);
-
+
/*
* Can't alter newReg's extents before we call miRegionOp because
* it might be one of the source regions and miRegionOp depends
@@ -526,13 +509,13 @@ miRegionCopy(
{
if (dstrgn != rgn) /* don't want to copy to itself */
- {
+ {
if (dstrgn->size < rgn->numRects)
{
if (dstrgn->rects)
{
BOX *prevRects = dstrgn->rects;
-
+
if (! (dstrgn->rects = (BOX *)
Xrealloc((char *) dstrgn->rects,
(unsigned) rgn->numRects * (sizeof(BOX))))) {
@@ -553,135 +536,6 @@ miRegionCopy(
}
}
-#ifdef notdef
-
-/*
- * combinRegs(newReg, reg1, reg2)
- * if one region is above or below the other.
-*/
-
-static void
-combineRegs(
- register Region newReg,
- Region reg1,
- Region reg2)
-{
- register Region tempReg;
- register BOX *rects;
- register BOX *rects1;
- register BOX *rects2;
- register int total;
-
- rects1 = reg1->rects;
- rects2 = reg2->rects;
-
- total = reg1->numRects + reg2->numRects;
- if (! (tempReg = XCreateRegion()))
- return;
- tempReg->size = total;
- /* region 1 is below region 2 */
- if (reg1->extents.y1 > reg2->extents.y1)
- {
- miRegionCopy(tempReg, reg2);
- rects = &tempReg->rects[tempReg->numRects];
- total -= tempReg->numRects;
- while (total--)
- *rects++ = *rects1++;
- }
- else
- {
- miRegionCopy(tempReg, reg1);
- rects = &tempReg->rects[tempReg->numRects];
- total -= tempReg->numRects;
- while (total--)
- *rects++ = *rects2++;
- }
- tempReg->extents = reg1->extents;
- tempReg->numRects = reg1->numRects + reg2->numRects;
- EXTENTS(&reg2->extents, tempReg);
- miRegionCopy(newReg, tempReg);
- Xfree((char *)tempReg);
-}
-
-/*
- * QuickCheck checks to see if it does not have to go through all the
- * the ugly code for the region call. It returns 1 if it did all
- * the work for Union, otherwise 0 - still work to be done.
-*/
-
-static int
-QuickCheck(Region newReg, Region reg1, Region reg2)
-{
-
- /* if unioning with itself or no rects to union with */
- if ( (reg1 == reg2) || (!(reg1->numRects)) )
- {
- miRegionCopy(newReg, reg2);
- return TRUE;
- }
-
- /* if nothing to union */
- if (!(reg2->numRects))
- {
- miRegionCopy(newReg, reg1);
- return TRUE;
- }
-
- /* could put an extent check to see if add above or below */
-
- if ((reg1->extents.y1 >= reg2->extents.y2) ||
- (reg2->extents.y1 >= reg1->extents.y2) )
- {
- combineRegs(newReg, reg1, reg2);
- return TRUE;
- }
- return FALSE;
-}
-
-/* TopRects(rects, reg1, reg2)
- * N.B. We now assume that reg1 and reg2 intersect. Therefore we are
- * NOT checking in the two while loops for stepping off the end of the
- * region.
- */
-
-static int
-TopRects(
- register Region newReg,
- register BOX *rects,
- register Region reg1,
- register Region reg2,
- BOX *FirstRect)
-{
- register BOX *tempRects;
-
- /* need to add some rects from region 1 */
- if (reg1->extents.y1 < reg2->extents.y1)
- {
- tempRects = reg1->rects;
- while(tempRects->y1 < reg2->extents.y1)
- {
- MEMCHECK(newReg, rects, FirstRect);
- ADDRECTNOX(newReg,rects, tempRects->x1, tempRects->y1,
- tempRects->x2, MIN(tempRects->y2, reg2->extents.y1));
- tempRects++;
- }
- }
- /* need to add some rects from region 2 */
- if (reg2->extents.y1 < reg1->extents.y1)
- {
- tempRects = reg2->rects;
- while (tempRects->y1 < reg1->extents.y1)
- {
- MEMCHECK(newReg, rects, FirstRect);
- ADDRECTNOX(newReg, rects, tempRects->x1,tempRects->y1,
- tempRects->x2, MIN(tempRects->y2, reg1->extents.y1));
- tempRects++;
- }
- }
- return 1;
-}
-#endif
-
/*======================================================================
* Generic Region Operator
*====================================================================*/
@@ -737,7 +591,7 @@ miCoalesce(
{
pCurBox++;
}
-
+
if (pCurBox != pRegEnd)
{
/*
@@ -754,7 +608,7 @@ miCoalesce(
curStart = pRegEnd - pReg->rects;
pRegEnd = pReg->rects + pReg->numRects;
}
-
+
if ((curNumRects == prevNumRects) && (curNumRects != 0)) {
pCurBox -= curNumRects;
/*
@@ -822,7 +676,7 @@ miCoalesce(
*pPrevBox++ = *pCurBox++;
} while (pCurBox != pRegEnd);
}
-
+
}
}
return (curStart);
@@ -903,7 +757,7 @@ miRegionOp(
* band */
short bot; /* Bottom of non-overlapping
* band */
-
+
/*
* Initialization:
* set r1, r2, r1End and r2End appropriately, preserve the important
@@ -915,9 +769,9 @@ miRegionOp(
r2 = reg2->rects;
r1End = r1 + reg1->numRects;
r2End = r2 + reg2->numRects;
-
+
oldRects = newReg->rects;
-
+
EMPTY_REGION(newReg);
/*
@@ -934,7 +788,7 @@ miRegionOp(
newReg->size = 0;
return;
}
-
+
/*
* Initialize ybot and ytop.
* In the upcoming loop, ybot and ytop serve different functions depending
@@ -952,7 +806,7 @@ miRegionOp(
ybot = reg1->extents.y1;
else
ybot = reg2->extents.y1;
-
+
/*
* prevBand serves to mark the start of the previous band so rectangles
* can be coalesced into larger rectangles. qv. miCoalesce, above.
@@ -963,7 +817,7 @@ miRegionOp(
* array of rectangles.
*/
prevBand = 0;
-
+
do
{
curBand = newReg->numRects;
@@ -980,13 +834,13 @@ miRegionOp(
{
r1BandEnd++;
}
-
+
r2BandEnd = r2;
while ((r2BandEnd != r2End) && (r2BandEnd->y1 == r2->y1))
{
r2BandEnd++;
}
-
+
/*
* First handle the band that doesn't intersect, if any.
*
@@ -1046,7 +900,7 @@ miRegionOp(
(* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
}
-
+
if (newReg->numRects != curBand)
{
prevBand = miCoalesce (newReg, prevBand, curBand);
@@ -1223,7 +1077,7 @@ miUnionO (
register short y2)
{
register BoxPtr pNextRect;
-
+
pNextRect = &pReg->rects[pReg->numRects];
#define MERGERECT(r) \
@@ -1250,7 +1104,7 @@ miUnionO (
} \
assert(pReg->numRects<=pReg->size);\
r++;
-
+
assert (y1<y2);
while ((r1 != r1End) && (r2 != r2End))
{
@@ -1263,7 +1117,7 @@ miUnionO (
MERGERECT(r2);
}
}
-
+
if (r1 != r1End)
{
do
@@ -1309,7 +1163,7 @@ XUnionRegion(
/*
* Region 1 completely subsumes region 2
*/
- if ((reg1->numRects == 1) &&
+ if ((reg1->numRects == 1) &&
(reg1->extents.x1 <= reg2->extents.x1) &&
(reg1->extents.y1 <= reg2->extents.y1) &&
(reg1->extents.x2 >= reg2->extents.x2) &&
@@ -1323,7 +1177,7 @@ XUnionRegion(
/*
* Region 2 completely subsumes region 1
*/
- if ((reg2->numRects == 1) &&
+ if ((reg2->numRects == 1) &&
(reg2->extents.x1 <= reg1->extents.x1) &&
(reg2->extents.y1 <= reg1->extents.y1) &&
(reg2->extents.x2 >= reg1->extents.x2) &&
@@ -1334,7 +1188,7 @@ XUnionRegion(
return 1;
}
- miRegionOp (newReg, reg1, reg2, miUnionO,
+ miRegionOp (newReg, reg1, reg2, miUnionO,
miUnionNonO, miUnionNonO);
newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
@@ -1374,9 +1228,9 @@ miSubtractNonO1 (
register short y2)
{
register BoxPtr pNextRect;
-
+
pNextRect = &pReg->rects[pReg->numRects];
-
+
assert(y1<y2);
while (r != rEnd)
@@ -1424,9 +1278,9 @@ miSubtractO (
{
register BoxPtr pNextRect;
register int x1;
-
+
x1 = r1->x1;
-
+
assert(y1<y2);
pNextRect = &pReg->rects[pReg->numRects];
@@ -1545,7 +1399,7 @@ miSubtractO (
}
return 0; /* lint */
}
-
+
/*-
*-----------------------------------------------------------------------
* miSubtract --
@@ -1564,7 +1418,7 @@ miSubtractO (
int
XSubtractRegion(
Region regM,
- Region regS,
+ Region regS,
register Region regD)
{
/* check for trivial reject */
@@ -1574,8 +1428,8 @@ XSubtractRegion(
miRegionCopy(regD, regM);
return 1;
}
-
- miRegionOp (regD, regM, regS, miSubtractO,
+
+ miRegionOp (regD, regM, regS, miSubtractO,
miSubtractNonO1, NULL);
/*
@@ -1605,10 +1459,10 @@ XXorRegion(Region sra, Region srb, Region dr)
}
/*
- * Check to see if the region is empty. Assumes a region is passed
+ * Check to see if the region is empty. Assumes a region is passed
* as a parameter
*/
-int
+int
XEmptyRegion(
Region r)
{
@@ -1617,9 +1471,9 @@ XEmptyRegion(
}
/*
- * Check to see if two regions are equal
+ * Check to see if two regions are equal
*/
-int
+int
XEqualRegion(Region r1, Region r2)
{
int i;
@@ -1639,7 +1493,7 @@ XEqualRegion(Region r1, Region r2)
return TRUE;
}
-int
+int
XPointInRegion(
Region pRegion,
int x, int y)
@@ -1658,7 +1512,7 @@ XPointInRegion(
return FALSE;
}
-int
+int
XRectInRegion(
register Region region,
int rx, int ry,
@@ -1674,7 +1528,7 @@ XRectInRegion(
prect->y1 = ry;
prect->x2 = rwidth + rx;
prect->y2 = rheight + ry;
-
+
/* this is (just) a useful optimization */
if ((region->numRects == 0) || !EXTENTCHECK(&region->extents, prect))
return(RectangleOut);
@@ -1736,6 +1590,6 @@ XRectInRegion(
}
- return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
+ return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
RectangleOut);
}