diff options
Diffstat (limited to 'src/Region.c')
-rw-r--r-- | src/Region.c | 318 |
1 files changed, 187 insertions, 131 deletions
diff --git a/src/Region.c b/src/Region.c index bf6a58c7..af1f0f22 100644 --- a/src/Region.c +++ b/src/Region.c @@ -45,7 +45,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ************************************************************************/ -/* $XFree86: xc/lib/X11/Region.c,v 1.9 2002/06/04 22:19:57 dawes Exp $ */ +/* $XFree86: xc/lib/X11/Region.c,v 1.10 2003/04/13 19:22:17 dawes Exp $ */ /* * The functions in this file implement the Region abstraction, similar to one * used in the X11 sample server. A Region is simply an area, as the name @@ -85,12 +85,56 @@ SOFTWARE. #define assert(expr) #endif -typedef void (*voidProcp)(); +typedef int (*overlapProcp)( + register Region pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + short y1, + short y2); + +typedef int (*nonOverlapProcp)( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2); + +static void miRegionOp( + register Region newReg, /* Place to store result */ + Region reg1, /* First region in operation */ + Region reg2, /* 2d region in operation */ + int (*overlapFunc)( + register Region pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + short y1, + short y2), /* Function to call for over- + * lapping bands */ + int (*nonOverlap1Func)( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2), /* Function to call for non- + * overlapping bands in region + * 1 */ + int (*nonOverlap2Func)( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2)); /* Function to call for non- + * overlapping bands in region + * 2 */ + -static void miRegionOp(); /* Create a new empty region */ Region -XCreateRegion() +XCreateRegion(void) { Region temp; @@ -110,9 +154,9 @@ XCreateRegion() } int -XClipBox( r, rect ) - Region r; - XRectangle *rect; +XClipBox( + Region r, + XRectangle *rect) { rect->x = r->extents.x1; rect->y = r->extents.y1; @@ -122,9 +166,9 @@ XClipBox( r, rect ) } int -XUnionRectWithRegion(rect, source, dest) - register XRectangle *rect; - Region source, dest; +XUnionRectWithRegion( + register XRectangle *rect, + Region source, Region dest) { REGION region; @@ -157,8 +201,8 @@ XUnionRectWithRegion(rect, source, dest) *----------------------------------------------------------------------- */ static void -miSetExtents (pReg) - Region pReg; +miSetExtents ( + Region pReg) { register BoxPtr pBox, pBoxEnd, @@ -205,13 +249,11 @@ miSetExtents (pReg) assert(pExtents->x1 < pExtents->x2); } -extern void _XSetClipRectangles(); - int -XSetRegion( dpy, gc, r ) - Display *dpy; - GC gc; - register Region r; +XSetRegion( + Display *dpy, + GC gc, + register Region r) { register int i; register XRectangle *xr, *pr; @@ -238,8 +280,8 @@ XSetRegion( dpy, gc, r ) } int -XDestroyRegion( r ) - Region r; +XDestroyRegion( + Region r) { Xfree( (char *) r->rects ); Xfree( (char *) r ); @@ -253,10 +295,10 @@ XDestroyRegion( r ) */ int -XOffsetRegion(pRegion, x, y) - register Region pRegion; - register int x; - register int y; +XOffsetRegion( + register Region pRegion, + register int x, + register int y) { register int nbox; register BOX *pbox; @@ -306,10 +348,10 @@ XOffsetRegion(pRegion, x, y) #define ZCopyRegion(a,b) XUnionRegion(a,a,b) static void -Compress(r, s, t, dx, xdir, grow) - Region r, s, t; - register unsigned dx; - register int xdir, grow; +Compress( + Region r, Region s, Region t, + register unsigned dx, + register int xdir, register int grow) { register unsigned shift = 1; @@ -333,9 +375,9 @@ Compress(r, s, t, dx, xdir, grow) #undef ZCopyRegion int -XShrinkRegion(r, dx, dy) - Region r; - int dx, dy; +XShrinkRegion( + Region r, + int dx, int dy) { Region s, t; int grow; @@ -359,10 +401,10 @@ XShrinkRegion(r, dx, dy) ***********************************************************/ static BOX -*IndexRects(rects, numRects, y) - register BOX *rects; - register int numRects; - register int y; +*IndexRects( + register BOX *rects, + register int numRects, + register int y) { while ((numRects--) && (rects->y2 <= y)) rects++; @@ -388,14 +430,14 @@ static BOX */ /* static void*/ static int -miIntersectO (pReg, r1, r1End, r2, r2End, y1, y2) - register Region pReg; - register BoxPtr r1; - BoxPtr r1End; - register BoxPtr r2; - BoxPtr r2End; - short y1; - short y2; +miIntersectO ( + register Region pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + short y1, + short y2) { register short x1; register short x2; @@ -452,10 +494,10 @@ miIntersectO (pReg, r1, r1End, r2, r2End, y1, y2) } int -XIntersectRegion(reg1, reg2, newReg) - Region reg1; - Region reg2; /* source regions */ - register Region newReg; /* destination Region */ +XIntersectRegion( + Region reg1, + Region reg2, /* source regions */ + register Region newReg) /* destination Region */ { /* check for trivial reject */ if ( (!(reg1->numRects)) || (!(reg2->numRects)) || @@ -463,7 +505,7 @@ XIntersectRegion(reg1, reg2, newReg) newReg->numRects = 0; else miRegionOp (newReg, reg1, reg2, - (voidProcp) miIntersectO, (voidProcp) NULL, (voidProcp) NULL); + miIntersectO, NULL, NULL); /* * Can't alter newReg's extents before we call miRegionOp because @@ -477,9 +519,9 @@ XIntersectRegion(reg1, reg2, newReg) } static void -miRegionCopy(dstrgn, rgn) - register Region dstrgn; - register Region rgn; +miRegionCopy( + register Region dstrgn, + register Region rgn) { if (dstrgn != rgn) /* don't want to copy to itself */ @@ -518,10 +560,10 @@ miRegionCopy(dstrgn, rgn) */ static void -combineRegs(newReg, reg1, reg2) - register Region newReg; - Region reg1; - Region reg2; +combineRegs( + register Region newReg, + Region reg1, + Region reg2) { register Region tempReg; register BOX *rects; @@ -567,8 +609,7 @@ combineRegs(newReg, reg1, reg2) */ static int -QuickCheck(newReg, reg1, reg2) - Region newReg, reg1, reg2; +QuickCheck(Region newReg, Region reg1, Region reg2) { /* if unioning with itself or no rects to union with */ @@ -603,12 +644,12 @@ QuickCheck(newReg, reg1, reg2) */ static int -TopRects(newReg, rects, reg1, reg2, FirstRect) - register Region newReg; - register BOX *rects; - register Region reg1; - register Region reg2; - BOX *FirstRect; +TopRects( + register Region newReg, + register BOX *rects, + register Region reg1, + register Region reg2, + BOX *FirstRect) { register BOX *tempRects; @@ -663,10 +704,10 @@ TopRects(newReg, rects, reg1, reg2, FirstRect) */ /* static int*/ static int -miCoalesce (pReg, prevStart, curStart) - register Region pReg; /* Region to coalesce */ - int prevStart; /* Index of start of previous band */ - int curStart; /* Index of start of current band */ +miCoalesce( + register Region pReg, /* Region to coalesce */ + int prevStart, /* Index of start of previous band */ + int curStart) /* Index of start of current band */ { register BoxPtr pPrevBox; /* Current box in previous band */ register BoxPtr pCurBox; /* Current box in current band */ @@ -814,16 +855,33 @@ miCoalesce (pReg, prevStart, curStart) */ /* static void*/ static void -miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func) - register Region newReg; /* Place to store result */ - Region reg1; /* First region in operation */ - Region reg2; /* 2d region in operation */ - void (*overlapFunc)(); /* Function to call for over- +miRegionOp( + register Region newReg, /* Place to store result */ + Region reg1, /* First region in operation */ + Region reg2, /* 2d region in operation */ + int (*overlapFunc)( + register Region pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + short y1, + short y2), /* Function to call for over- * lapping bands */ - void (*nonOverlap1Func)(); /* Function to call for non- + int (*nonOverlap1Func)( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2), /* Function to call for non- * overlapping bands in region * 1 */ - void (*nonOverlap2Func)(); /* Function to call for non- + int (*nonOverlap2Func)( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2)) /* Function to call for non- * overlapping bands in region * 2 */ { @@ -941,7 +999,7 @@ miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func) top = max(r1->y1,ybot); bot = min(r1->y2,r2->y1); - if ((top != bot) && (nonOverlap1Func != (void (*)())NULL)) + if ((top != bot) && (nonOverlap1Func != NULL)) { (* nonOverlap1Func) (newReg, r1, r1BandEnd, top, bot); } @@ -953,7 +1011,7 @@ miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func) top = max(r2->y1,ybot); bot = min(r2->y2,r1->y1); - if ((top != bot) && (nonOverlap2Func != (void (*)())NULL)) + if ((top != bot) && (nonOverlap2Func != NULL)) { (* nonOverlap2Func) (newReg, r2, r2BandEnd, top, bot); } @@ -1013,7 +1071,7 @@ miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func) curBand = newReg->numRects; if (r1 != r1End) { - if (nonOverlap1Func != (void (*)())NULL) + if (nonOverlap1Func != NULL) { do { @@ -1028,7 +1086,7 @@ miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func) } while (r1 != r1End); } } - else if ((r2 != r2End) && (nonOverlap2Func != (void (*)())NULL)) + else if ((r2 != r2End) && (nonOverlap2Func != NULL)) { do { @@ -1105,12 +1163,12 @@ miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func) */ /* static void*/ static int -miUnionNonO (pReg, r, rEnd, y1, y2) - register Region pReg; - register BoxPtr r; - BoxPtr rEnd; - register short y1; - register short y2; +miUnionNonO ( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2) { register BoxPtr pNextRect; @@ -1154,14 +1212,14 @@ miUnionNonO (pReg, r, rEnd, y1, y2) /* static void*/ static int -miUnionO (pReg, r1, r1End, r2, r2End, y1, y2) - register Region pReg; - register BoxPtr r1; - BoxPtr r1End; - register BoxPtr r2; - BoxPtr r2End; - register short y1; - register short y2; +miUnionO ( + register Region pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + register short y1, + register short y2) { register BoxPtr pNextRect; @@ -1220,10 +1278,10 @@ miUnionO (pReg, r1, r1End, r2, r2End, y1, y2) } int -XUnionRegion(reg1, reg2, newReg) - Region reg1; - Region reg2; /* source regions */ - Region newReg; /* destination Region */ +XUnionRegion( + Region reg1, + Region reg2, /* source regions */ + Region newReg) /* destination Region */ { /* checks all the simple cases */ @@ -1275,8 +1333,8 @@ XUnionRegion(reg1, reg2, newReg) return 1; } - miRegionOp (newReg, reg1, reg2, (voidProcp) miUnionO, - (voidProcp) miUnionNonO, (voidProcp) miUnionNonO); + miRegionOp (newReg, reg1, reg2, miUnionO, + miUnionNonO, miUnionNonO); newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1); newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1); @@ -1307,12 +1365,12 @@ XUnionRegion(reg1, reg2, newReg) */ /* static void*/ static int -miSubtractNonO1 (pReg, r, rEnd, y1, y2) - register Region pReg; - register BoxPtr r; - BoxPtr rEnd; - register short y1; - register short y2; +miSubtractNonO1 ( + register Region pReg, + register BoxPtr r, + BoxPtr rEnd, + register short y1, + register short y2) { register BoxPtr pNextRect; @@ -1354,14 +1412,14 @@ miSubtractNonO1 (pReg, r, rEnd, y1, y2) */ /* static void*/ static int -miSubtractO (pReg, r1, r1End, r2, r2End, y1, y2) - register Region pReg; - register BoxPtr r1; - BoxPtr r1End; - register BoxPtr r2; - BoxPtr r2End; - register short y1; - register short y2; +miSubtractO ( + register Region pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + register short y1, + register short y2) { register BoxPtr pNextRect; register int x1; @@ -1503,10 +1561,10 @@ miSubtractO (pReg, r1, r1End, r2, r2End, y1, y2) */ int -XSubtractRegion(regM, regS, regD) - Region regM; - Region regS; - register Region regD; +XSubtractRegion( + Region regM, + Region regS, + register Region regD) { /* check for trivial reject */ if ( (!(regM->numRects)) || (!(regS->numRects)) || @@ -1516,8 +1574,8 @@ XSubtractRegion(regM, regS, regD) return 1; } - miRegionOp (regD, regM, regS, (voidProcp) miSubtractO, - (voidProcp) miSubtractNonO1, (voidProcp) NULL); + miRegionOp (regD, regM, regS, miSubtractO, + miSubtractNonO1, NULL); /* * Can't alter newReg's extents before we call miRegionOp because @@ -1531,8 +1589,7 @@ XSubtractRegion(regM, regS, regD) } int -XXorRegion( sra, srb, dr ) - Region sra, srb, dr; +XXorRegion(Region sra, Region srb, Region dr) { Region tra, trb; @@ -1551,8 +1608,8 @@ XXorRegion( sra, srb, dr ) * as a parameter */ int -XEmptyRegion( r ) - Region r; +XEmptyRegion( + Region r) { if( r->numRects == 0 ) return TRUE; else return FALSE; @@ -1562,8 +1619,7 @@ XEmptyRegion( r ) * Check to see if two regions are equal */ int -XEqualRegion( r1, r2 ) - Region r1, r2; +XEqualRegion(Region r1, Region r2) { int i; @@ -1583,9 +1639,9 @@ XEqualRegion( r1, r2 ) } int -XPointInRegion( pRegion, x, y ) - Region pRegion; - int x, y; +XPointInRegion( + Region pRegion, + int x, int y) { int i; @@ -1602,10 +1658,10 @@ XPointInRegion( pRegion, x, y ) } int -XRectInRegion(region, rx, ry, rwidth, rheight) - register Region region; - int rx, ry; - unsigned int rwidth, rheight; +XRectInRegion( + register Region region, + int rx, int ry, + unsigned int rwidth, unsigned int rheight) { register BoxPtr pbox; register BoxPtr pboxEnd; |