aboutsummaryrefslogtreecommitdiff
path: root/libX11/src/Region.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-07-25 12:47:39 +0000
committermarha <marha@users.sourceforge.net>2009-07-25 12:47:39 +0000
commitcb897b8ffca0a68c017c2edfa523cb5ff0491962 (patch)
tree8b4e9e320258d5280ce454163c49363030626c1a /libX11/src/Region.c
parent213d71f78d6f9e35b23c00e35f9919efc9670b1e (diff)
parentc87efef42f76c2ff0dcfad2842ab369beffd21de (diff)
downloadvcxsrv-cb897b8ffca0a68c017c2edfa523cb5ff0491962.tar.gz
vcxsrv-cb897b8ffca0a68c017c2edfa523cb5ff0491962.tar.bz2
vcxsrv-cb897b8ffca0a68c017c2edfa523cb5ff0491962.zip
svn merge file:///D:/svnrepos/vcxsrv/branches/released .
Diffstat (limited to 'libX11/src/Region.c')
-rw-r--r--libX11/src/Region.c234
1 files changed, 44 insertions, 190 deletions
diff --git a/libX11/src/Region.c b/libX11/src/Region.c
index cdd223b25..7d7e596a2 100644
--- a/libX11/src/Region.c
+++ b/libX11/src/Region.c
@@ -28,13 +28,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
@@ -324,9 +324,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.
@@ -397,23 +397,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
@@ -507,9 +490,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
@@ -528,13 +511,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))))) {
@@ -555,135 +538,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
*====================================================================*/
@@ -739,7 +593,7 @@ miCoalesce(
{
pCurBox++;
}
-
+
if (pCurBox != pRegEnd)
{
/*
@@ -756,7 +610,7 @@ miCoalesce(
curStart = pRegEnd - pReg->rects;
pRegEnd = pReg->rects + pReg->numRects;
}
-
+
if ((curNumRects == prevNumRects) && (curNumRects != 0)) {
pCurBox -= curNumRects;
/*
@@ -824,7 +678,7 @@ miCoalesce(
*pPrevBox++ = *pCurBox++;
} while (pCurBox != pRegEnd);
}
-
+
}
}
return (curStart);
@@ -905,7 +759,7 @@ miRegionOp(
* band */
short bot; /* Bottom of non-overlapping
* band */
-
+
/*
* Initialization:
* set r1, r2, r1End and r2End appropriately, preserve the important
@@ -917,9 +771,9 @@ miRegionOp(
r2 = reg2->rects;
r1End = r1 + reg1->numRects;
r2End = r2 + reg2->numRects;
-
+
oldRects = newReg->rects;
-
+
EMPTY_REGION(newReg);
/*
@@ -936,7 +790,7 @@ miRegionOp(
newReg->size = 0;
return;
}
-
+
/*
* Initialize ybot and ytop.
* In the upcoming loop, ybot and ytop serve different functions depending
@@ -954,7 +808,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.
@@ -965,7 +819,7 @@ miRegionOp(
* array of rectangles.
*/
prevBand = 0;
-
+
do
{
curBand = newReg->numRects;
@@ -982,13 +836,13 @@ miRegionOp(
{
r1BandEnd++;
}
-
+
r2BandEnd = r2;
while ((r2BandEnd != r2End) && (r2BandEnd->y1 == r2->y1))
{
r2BandEnd++;
}
-
+
/*
* First handle the band that doesn't intersect, if any.
*
@@ -1048,7 +902,7 @@ miRegionOp(
(* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
}
-
+
if (newReg->numRects != curBand)
{
prevBand = miCoalesce (newReg, prevBand, curBand);
@@ -1225,7 +1079,7 @@ miUnionO (
register short y2)
{
register BoxPtr pNextRect;
-
+
pNextRect = &pReg->rects[pReg->numRects];
#define MERGERECT(r) \
@@ -1252,7 +1106,7 @@ miUnionO (
} \
assert(pReg->numRects<=pReg->size);\
r++;
-
+
assert (y1<y2);
while ((r1 != r1End) && (r2 != r2End))
{
@@ -1265,7 +1119,7 @@ miUnionO (
MERGERECT(r2);
}
}
-
+
if (r1 != r1End)
{
do
@@ -1311,7 +1165,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) &&
@@ -1325,7 +1179,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) &&
@@ -1336,7 +1190,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);
@@ -1376,9 +1230,9 @@ miSubtractNonO1 (
register short y2)
{
register BoxPtr pNextRect;
-
+
pNextRect = &pReg->rects[pReg->numRects];
-
+
assert(y1<y2);
while (r != rEnd)
@@ -1426,9 +1280,9 @@ miSubtractO (
{
register BoxPtr pNextRect;
register int x1;
-
+
x1 = r1->x1;
-
+
assert(y1<y2);
pNextRect = &pReg->rects[pReg->numRects];
@@ -1547,7 +1401,7 @@ miSubtractO (
}
return 0; /* lint */
}
-
+
/*-
*-----------------------------------------------------------------------
* miSubtract --
@@ -1566,7 +1420,7 @@ miSubtractO (
int
XSubtractRegion(
Region regM,
- Region regS,
+ Region regS,
register Region regD)
{
/* check for trivial reject */
@@ -1576,8 +1430,8 @@ XSubtractRegion(
miRegionCopy(regD, regM);
return 1;
}
-
- miRegionOp (regD, regM, regS, miSubtractO,
+
+ miRegionOp (regD, regM, regS, miSubtractO,
miSubtractNonO1, NULL);
/*
@@ -1607,10 +1461,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)
{
@@ -1619,9 +1473,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;
@@ -1641,7 +1495,7 @@ XEqualRegion(Region r1, Region r2)
return TRUE;
}
-int
+int
XPointInRegion(
Region pRegion,
int x, int y)
@@ -1660,7 +1514,7 @@ XPointInRegion(
return FALSE;
}
-int
+int
XRectInRegion(
register Region region,
int rx, int ry,
@@ -1676,7 +1530,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);
@@ -1738,6 +1592,6 @@ XRectInRegion(
}
- return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
+ return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
RectangleOut);
}