xserver: Branch 'master' - 5 commits

Keith Packard keithp at kemper.freedesktop.org
Sat Jun 5 19:08:03 PDT 2010


 Xext/panoramiX.c                 |   36 
 Xext/panoramiXprocs.c            |   24 
 Xext/shape.c                     |   48 -
 Xext/xace.c                      |   14 
 composite/compalloc.c            |    6 
 composite/compext.c              |    2 
 composite/compwindow.c           |   42 
 damageext/damageext.c            |   12 
 dix/Makefile.am                  |    1 
 dix/dispatch.c                   |   12 
 dix/events.c                     |   56 -
 dix/region.c                     | 1660 +++++++++++++++++++++++++++++++++++
 dix/window.c                     |  104 +-
 doc/xml/Xserver-spec.xml         |   40 
 exa/exa.c                        |    6 
 exa/exa_accel.c                  |   80 -
 exa/exa_classic.c                |    8 
 exa/exa_migration_classic.c      |   60 -
 exa/exa_mixed.c                  |    4 
 exa/exa_render.c                 |   48 -
 exa/exa_unaccel.c                |   56 -
 fb/fb.h                          |    2 
 fb/fb24_32.c                     |    8 
 fb/fbarc.c                       |    2 
 fb/fbbits.h                      |    4 
 fb/fbfill.c                      |    2 
 fb/fbfillrect.c                  |    6 
 fb/fbfillsp.c                    |    6 
 fb/fbgc.c                        |    2 
 fb/fbglyph.c                     |    4 
 fb/fbimage.c                     |    8 
 fb/fbline.c                      |    4 
 fb/fboverlay.c                   |   42 
 fb/fbpict.c                      |    6 
 fb/fbpixmap.c                    |   14 
 fb/fbpoint.c                     |    2 
 fb/fbpush.c                      |    4 
 fb/fbseg.c                       |    4 
 fb/fbsetsp.c                     |    4 
 fb/fbwindow.c                    |   14 
 fix-miregion                     |   29 
 fix-miregion-private             |   14 
 fix-patch-whitespace             |    4 
 fix-region                       |   38 
 glx/glxdri.c                     |   12 
 glx/glxdri2.c                    |    6 
 hw/dmx/dmxextension.c            |    4 
 hw/dmx/dmxgc.c                   |    4 
 hw/dmx/dmxgcops.c                |   18 
 hw/dmx/dmxpict.c                 |    4 
 hw/dmx/dmxpixmap.c               |   18 
 hw/dmx/dmxshadow.c               |    4 
 hw/dmx/dmxwindow.c               |    8 
 hw/dmx/input/dmxconsole.c        |    2 
 hw/kdrive/ephyr/ephyr.c          |   12 
 hw/kdrive/ephyr/ephyrdriext.c    |   18 
 hw/kdrive/ephyr/ephyrvideo.c     |   16 
 hw/kdrive/src/kdrive.c           |   20 
 hw/kdrive/src/kxv.c              |  158 +--
 hw/xfree86/common/xf86Helper.c   |   16 
 hw/xfree86/common/xf86fbman.c    |  132 +-
 hw/xfree86/common/xf86xv.c       |  172 +--
 hw/xfree86/dri/dri.c             |   36 
 hw/xfree86/dri2/dri2.c           |    8 
 hw/xfree86/modes/xf86Crtc.c      |    6 
 hw/xfree86/modes/xf86Rotate.c    |   18 
 hw/xfree86/shadowfb/shadow.c     |   34 
 hw/xfree86/xaa/xaaBitBlt.c       |   34 
 hw/xfree86/xaa/xaaCpyArea.c      |   12 
 hw/xfree86/xaa/xaaCpyPlane.c     |   12 
 hw/xfree86/xaa/xaaCpyWin.c       |   14 
 hw/xfree86/xaa/xaaDashLine.c     |    4 
 hw/xfree86/xaa/xaaFillArc.c      |    4 
 hw/xfree86/xaa/xaaFillPoly.c     |   12 
 hw/xfree86/xaa/xaaFillRect.c     |   22 
 hw/xfree86/xaa/xaaImage.c        |    4 
 hw/xfree86/xaa/xaaLine.c         |    4 
 hw/xfree86/xaa/xaaNonTEText.c    |   20 
 hw/xfree86/xaa/xaaOverlay.c      |   16 
 hw/xfree86/xaa/xaaOverlayDF.c    |   28 
 hw/xfree86/xaa/xaaPCache.c       |    4 
 hw/xfree86/xaa/xaaPict.c         |   40 
 hw/xfree86/xaa/xaaRect.c         |    4 
 hw/xfree86/xaa/xaaSpans.c        |   10 
 hw/xfree86/xaa/xaaTEText.c       |   12 
 hw/xfree86/xaa/xaaWideLine.c     |    4 
 hw/xfree86/xaa/xaawrap.h         |    2 
 hw/xnest/Events.c                |    2 
 hw/xnest/GC.c                    |   12 
 hw/xnest/GCOps.c                 |   12 
 hw/xnest/Pixmap.c                |   16 
 hw/xnest/Window.c                |   34 
 hw/xquartz/darwin.c              |   22 
 hw/xquartz/xpr/dri.c             |    4 
 hw/xquartz/xpr/xprFrame.c        |    8 
 hw/xwin/winfillsp.c              |    6 
 hw/xwin/wingc.c                  |    2 
 hw/xwin/winmultiwindowshape.c    |   12 
 hw/xwin/winsetsp.c               |    4 
 hw/xwin/winshaddd.c              |    6 
 hw/xwin/winshadddnl.c            |    6 
 hw/xwin/winshadgdi.c             |    6 
 hw/xwin/winvideo.c               |    2 
 hw/xwin/winwin32rootless.c       |    4 
 hw/xwin/winwindow.c              |   26 
 hw/xwin/winwindowswm.c           |    8 
 include/regionstr.h              |  429 +++++----
 include/scrnintstr.h             |    4 
 mi/Makefile.am                   |    1 
 mi/mi.h                          |   17 
 mi/mibitblt.c                    |   32 
 mi/micopy.c                      |   26 
 mi/miexpose.c                    |  110 +-
 mi/migc.c                        |   44 
 mi/mioverlay.c                   |  406 ++++----
 mi/miregion.c                    | 1845 ---------------------------------------
 mi/mispans.h                     |   10 
 mi/misprite.c                    |    4 
 mi/mivaltree.c                   |  138 +-
 mi/miwindow.c                    |  118 +-
 miext/cw/cw.c                    |   14 
 miext/damage/damage.c            |  124 +-
 miext/rootless/rootlessCommon.c  |   46 
 miext/rootless/rootlessScreen.c  |    4 
 miext/rootless/rootlessValTree.c |   96 +-
 miext/rootless/rootlessWindow.c  |   66 -
 miext/shadow/shadow.c            |   10 
 miext/shadow/shpacked.c          |    4 
 miext/shadow/shplanar.c          |    4 
 miext/shadow/shplanar8.c         |    4 
 miext/shadow/shrotate.c          |    4 
 miext/shadow/shrotpack.h         |    4 
 miext/shadow/shrotpackYX.h       |    4 
 render/mipict.c                  |   42 
 render/mirect.c                  |    4 
 render/picture.c                 |   18 
 xfixes/region.c                  |   60 -
 137 files changed, 3684 insertions(+), 3730 deletions(-)

New commits:
commit 7ef612de784daaed09ba13f4615c10714614033f
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 21 12:35:29 2010 -0700

    Add REGION_ macros for source compatibility with existing drivers.
    
    This makes the region code changes source compatible with existing
    code, although none of them are used within the server source itself.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/include/regionstr.h b/include/regionstr.h
index 8bc902a..627941b 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -328,4 +328,43 @@ extern _X_EXPORT int RegionClipSpans(
     int /*fSorted*/
 );
 
+#define INCLUDE_LEGACY_REGION_DEFINES
+#ifdef INCLUDE_LEGACY_REGION_DEFINES
+
+#define REGION_NIL				RegionNil
+#define REGION_NAR				RegionNar
+#define REGION_NUM_RECTS			RegionNumRects
+#define REGION_SIZE				RegionSize
+#define REGION_RECTS				RegionRects
+#define REGION_BOXPTR				RegionBoxptr
+#define REGION_BOX				RegionBox
+#define REGION_TOP				RegionTop
+#define REGION_END				RegionEnd
+#define REGION_SZOF				RegionSizeof
+#define BITMAP_TO_REGION			BitmapToRegion
+#define REGION_CREATE(pScreen, r, s)		RegionCreate(r,s)
+#define REGION_COPY(pScreen, d, r)		RegionCopy(d, r)
+#define REGION_DESTROY(pScreen, r)		RegionDestroy(r)
+#define REGION_INTERSECT(pScreen, res, r1, r2)	RegionIntersect(res, r1, r2)
+#define REGION_UNION(pScreen, res, r1, r2)	RegionUnion(res, r1, r2)
+#define REGION_SUBTRACT(pScreen, res, r1, r2)	RegionSubtract(res, r1, r2)
+#define REGION_INVERSE(pScreen, n, r, b)	RegionInverse(n, r, b)
+#define REGION_TRANSLATE(pScreen, r, x, y)	RegionTranslate(r, x, y)
+#define RECT_IN_REGION(pScreen, r, b) 		RegionContainsRect(r, b)
+#define POINT_IN_REGION(pScreen, r, x, y, b) 	RegionContainsPoint(r, x, y, b)
+#define REGION_EQUAL(pScreen, r1, r2)		RegionEqual(r1, r2)
+#define REGION_APPEND(pScreen, d, r)		RegionAppend(d, r)
+#define REGION_VALIDATE(pScreen, r, o)		RegionValidate(r, o)
+#define RECTS_TO_REGION(pScreen, n, r, c)	RegionFromRects(n, r, c)
+#define REGION_BREAK(pScreen, r)		RegionBreak(r)
+#define REGION_INIT(pScreen, r, b, s)		RegionInit(r, b, s)
+#define REGION_UNINIT(pScreen, r)		RegionUninit(r)
+#define REGION_RESET(pScreen, r, b)		RegionReset(r, b)
+#define REGION_NOTEMPTY(pScreen, r)		RegionNotEmpty(r)
+#define REGION_BROKEN(pScreen, r)		RegionBroken(r)
+#define REGION_EMPTY(pScreen, r)		RegionEmpty(r)
+#define REGION_EXTENTS(pScreen, r)		RegionExtents(r)
+#define REGION_NULL(pScreen, r)			RegionNull(r)
+
+#endif /* INCLUDE_LEGACY_REGION_DEFINES */
 #endif /* REGIONSTRUCT_H */
commit 965cade6ee7c226f850e806cb2e910793d1536f9
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 21 12:18:22 2010 -0700

    Change region implementation from macros to inline functions.
    
    This makes all of the previous macros into inline functions and also
    turns all of the direct calls to pixman region code into inline
    functions as well.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 670cf50..c625438 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -386,7 +386,7 @@ static void XineramaInitData(ScreenPtr pScreen)
 {
     int i, w, h;
 
-    RegionNull(&PanoramiXScreenRegion)
+    RegionNull(&PanoramiXScreenRegion);
     for (i = 0; i < PanoramiXNumScreens; i++) {
 	BoxRec TheBox;
 	RegionRec ScreenRegion;
diff --git a/dix/region.c b/dix/region.c
index 2e8dde5..911fe16 100644
--- a/dix/region.c
+++ b/dix/region.c
@@ -275,12 +275,6 @@ RegionPrint(RegionPtr rgn)
     ErrorF("[mi] \n");
 }
 
-Bool
-RegionEqual(RegionPtr reg1, RegionPtr reg2)
-{
-    return pixman_region_equal (reg1, reg2);
-}
-
 #ifdef DEBUG
 Bool
 RegionIsValid(RegionPtr reg)
@@ -376,12 +370,6 @@ RegionRectAlloc(RegionPtr pRgn, int n)
     return TRUE;
 }
 
-Bool
-RegionCopy(RegionPtr dst, RegionPtr src)
-{
-    return pixman_region_copy (dst, src);
-}
-
 /*======================================================================
  *	    Generic Region Operator
  *====================================================================*/
@@ -800,8 +788,8 @@ RegionOp(
  *-----------------------------------------------------------------------
  * RegionSetExtents --
  *	Reset the extents of a region to what they should be. Called by
- *	RegionSubtract and RegionIntersect as they can't figure it out along the
- *	way or do so easily, as RegionUnion can.
+ *	Subtract and Intersect as they can't figure it out along the
+ *	way or do so easily, as Union can.
  *
  * Results:
  *	None.
@@ -869,15 +857,6 @@ RegionSetExtents (RegionPtr pReg)
  *-----------------------------------------------------------------------
  */
 /*ARGSUSED*/
-Bool
-RegionIntersect(
-    RegionPtr	newReg,     /* destination Region */
-    RegionPtr	reg1,
-    RegionPtr	reg2        /* source regions     */
-    )
-{
-    return pixman_region_intersect (newReg, reg1, reg2);
-}
 
 #define MERGERECT(r)						\
 {								\
@@ -973,16 +952,6 @@ RegionUnionO (
     return TRUE;
 }
 
-Bool
-RegionUnion(
-    RegionPtr	newReg,          /* destination Region */
-    RegionPtr	reg1,
-    RegionPtr	reg2             /* source regions     */
-    )
-{
-    return pixman_region_union (newReg, reg1, reg2);
-}
-
 /*======================================================================
  *	    Batch Rectangle Union
  *====================================================================*/
@@ -1182,7 +1151,7 @@ QuickSortRects(
  *		or a coalescing into 1 box (ala Menus).
  *
  *	Step 3. Merge the separate regions down to a single region by calling
- *		RegionUnion.  Maximize the work each RegionUnion call does by using
+ *		Union.  Maximize the work each Union call does by using
  *		a binary merge.
  *
  *-----------------------------------------------------------------------
@@ -1456,102 +1425,6 @@ RegionFromRects(int nrects, xRectangle *prect, int ctype)
     return pRgn;
 }
 
-/*======================================================================
- * 	    	  Region Subtraction
- *====================================================================*/
-
-
-/*-
- *-----------------------------------------------------------------------
- * RegionSubtractO --
- *	Overlapping band subtraction. x1 is the left-most point not yet
- *	checked.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	pReg may have rectangles added to it.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionSubtract --
- *	Subtract regS from regM and leave the result in regD.
- *	S stands for subtrahend, M for minuend and D for difference.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	regD is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
-{
-    return pixman_region_subtract (regD, regM, regS);
-}
-
-/*======================================================================
- *	    Region Inversion
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionInverse --
- *	Take a region and a box and return a region that is everything
- *	in the box but not in the region. The careful reader will note
- *	that this is the same as subtracting the region from the box...
- *
- * Results:
- *	TRUE.
- *
- * Side Effects:
- *	newReg is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-RegionInverse(
-    RegionPtr	  newReg,       /* Destination region */
-    RegionPtr	  reg1,         /* Region to invert */
-    BoxPtr	  invRect	/* Bounding box for inversion */
-    )
-{
-    return pixman_region_inverse (newReg, reg1, invRect);
-}
-int
-RegionContainsRect(RegionPtr region, BoxPtr prect)
-{
-    return pixman_region_contains_rectangle (region, prect);
-}
-
-/* TranslateRegion(pReg, x, y)
-   translates in place
-*/
-
-void
-RegionTranslate(RegionPtr pReg, int x, int y)
-{
-    pixman_region_translate (pReg, x, y);
-}
-
-Bool
-RegionContainsPoint(
-    RegionPtr pReg,
-    int x,
-    int y,
-    BoxPtr box      /* "return" value */
-    )
-{
-    return pixman_region_contains_point (pReg, x, y, box);
-}
-
 #define ExchangeSpans(a, b)				    \
 {							    \
     DDXPointRec	tpt;				    	    \
diff --git a/include/regionstr.h b/include/regionstr.h
index c6dd162..8bc902a 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -69,131 +69,112 @@ typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
 extern _X_EXPORT BoxRec RegionEmptyBox;
 extern _X_EXPORT RegDataRec RegionEmptyData;
 extern _X_EXPORT RegDataRec RegionBrokenData;
+static inline Bool RegionNil(RegionPtr reg) {
+    return ((reg)->data && !(reg)->data->numRects);
+}
 
-#define RegionNil(reg) ((reg)->data && !(reg)->data->numRects)
 /* not a region */
-#define RegionNar(reg)	((reg)->data == &RegionBrokenData)
-#define RegionNumRects(reg) ((reg)->data ? (reg)->data->numRects : 1)
-#define RegionSize(reg) ((reg)->data ? (reg)->data->size : 0)
-#define RegionRects(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
-			               : &(reg)->extents)
-#define RegionBoxptr(reg) ((BoxPtr)((reg)->data + 1))
-#define RegionBox(reg,i) (&RegionBoxptr(reg)[i])
-#define RegionTop(reg) RegionBox(reg, (reg)->data->numRects)
-#define RegionEnd(reg) RegionBox(reg, (reg)->data->numRects - 1)
-#define RegionSizeof(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
-
-#define RegionCreate(_rect, _size) \
-    RegionCreate(_rect, _size)
-
-#define RegionCopy(dst, src) \
-    RegionCopy(dst, src)
-
-#define RegionDestroy(_pReg) \
-    RegionDestroy(_pReg)
-
-#define RegionIntersect(newReg, reg1, reg2) \
-    RegionIntersect(newReg, reg1, reg2)
-
-#define RegionUnion(newReg, reg1, reg2) \
-    RegionUnion(newReg, reg1, reg2)
-
-#define RegionSubtract(newReg, reg1, reg2) \
-    RegionSubtract(newReg, reg1, reg2)
-
-#define RegionInverse(newReg, reg1, invRect) \
-    RegionInverse(newReg, reg1, invRect)
-
-#define RegionTranslate(_pReg, _x, _y) \
-    RegionTranslate(_pReg, _x, _y)
-
-#define RegionContainsRect(_pReg, prect) \
-    RegionContainsRect(_pReg, prect)
-
-#define RegionContainsPoint(_pReg, _x, _y, prect) \
-    RegionContainsPoint(_pReg, _x, _y, prect)
-
-#define RegionAppend(dstrgn, rgn) \
-    RegionAppend(dstrgn, rgn)
-
-#define RegionValidate(badreg, pOverlap) \
-    RegionValidate(badreg, pOverlap)
-
-#define BitmapToRegion(_pScreen, pPix) \
-    (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
-
-#define RegionFromRects(nrects, prect, ctype) \
-    RegionFromRects(nrects, prect, ctype)
-
-#define RegionEqual(_pReg1, _pReg2) \
-    RegionEqual(_pReg1, _pReg2)
-
-#define RegionBreak(_pReg) \
-    RegionBreak(_pReg)
-
-#define RegionInit(_pReg, _rect, _size) \
-{ \
-    if ((_rect) != NULL)				\
-    { \
-        (_pReg)->extents = *(_rect); \
-        (_pReg)->data = (RegDataPtr)NULL; \
-    } \
-    else \
-    { \
-        (_pReg)->extents = RegionEmptyBox; \
-        if (((_size) > 1) && ((_pReg)->data = \
-                             (RegDataPtr)malloc(RegionSizeof(_size)))) \
-        { \
-            (_pReg)->data->size = (_size); \
-            (_pReg)->data->numRects = 0; \
-        } \
-        else \
-            (_pReg)->data = &RegionEmptyData; \
-    } \
- }
-
-
-#define RegionUninit(_pReg) \
-{ \
-    if ((_pReg)->data && (_pReg)->data->size) { \
-	free((_pReg)->data); \
-	(_pReg)->data = NULL; \
-    } \
+
+static inline Bool RegionNar(RegionPtr reg) {
+    return ((reg)->data == &RegionBrokenData);
+}
+
+static inline int RegionNumRects(RegionPtr reg) {
+    return ((reg)->data ? (reg)->data->numRects : 1);
+}
+
+static inline int RegionSize(RegionPtr reg) {
+    return ((reg)->data ? (reg)->data->size : 0);
 }
 
-#define RegionReset(_pReg, _pBox) \
-{ \
-    (_pReg)->extents = *(_pBox); \
-    RegionUninit(_pReg); \
-    (_pReg)->data = (RegDataPtr)NULL; \
+static inline BoxPtr RegionRects(RegionPtr reg) {
+    return ((reg)->data ? (BoxPtr)((reg)->data + 1) : &(reg)->extents);
 }
 
-#define RegionNotEmpty(_pReg) \
-    !RegionNil(_pReg)
+static inline BoxPtr RegionBoxptr(RegionPtr reg) {
+    return ((BoxPtr)((reg)->data + 1));
+}
 
-#define RegionBroken(_pReg) \
-    RegionNar(_pReg)
+static inline BoxPtr RegionBox(RegionPtr reg, int i) {
+    return (&RegionBoxptr(reg)[i]);
+}
 
-#define RegionEmpty(_pReg) \
-{ \
-    RegionUninit(_pReg); \
-    (_pReg)->extents.x2 = (_pReg)->extents.x1; \
-    (_pReg)->extents.y2 = (_pReg)->extents.y1; \
-    (_pReg)->data = &RegionEmptyData; \
+static inline BoxPtr RegionTop(RegionPtr reg) {
+    return RegionBox(reg, (reg)->data->numRects);
 }
 
-#define RegionExtents(_pReg) \
-    (&(_pReg)->extents)
+static inline BoxPtr RegionEnd(RegionPtr reg) {
+    return RegionBox(reg, (reg)->data->numRects - 1);
+}
 
-#define RegionNull(_pReg) \
-{ \
-    (_pReg)->extents = RegionEmptyBox; \
-    (_pReg)->data = &RegionEmptyData; \
+static inline size_t RegionSizeof(int n) {
+    return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
 }
 
-/* moved from mi.h */
+static inline void RegionInit(RegionPtr _pReg, BoxPtr _rect, int _size)
+{
+    if ((_rect) != NULL)
+    {
+        (_pReg)->extents = *(_rect);
+        (_pReg)->data = (RegDataPtr)NULL;
+    }
+    else
+    {
+        (_pReg)->extents = RegionEmptyBox;
+        if (((_size) > 1) && ((_pReg)->data =
+			      (RegDataPtr)malloc(RegionSizeof(_size))))
+        {
+            (_pReg)->data->size = (_size);
+            (_pReg)->data->numRects = 0;
+        }
+        else
+            (_pReg)->data = &RegionEmptyData;
+    }
+}
 
-extern _X_EXPORT void InitRegions (void);
+static inline void RegionUninit(RegionPtr _pReg)
+{
+    if ((_pReg)->data && (_pReg)->data->size) {
+	free((_pReg)->data);
+	(_pReg)->data = NULL;
+    }
+}
+
+static inline void RegionReset(RegionPtr _pReg, BoxPtr _pBox)
+{
+    (_pReg)->extents = *(_pBox);
+    RegionUninit(_pReg);
+    (_pReg)->data = (RegDataPtr)NULL;
+}
+
+static inline Bool RegionNotEmpty(RegionPtr _pReg) {
+    return !RegionNil(_pReg);
+}
+
+static inline Bool RegionBroken(RegionPtr _pReg) {
+    return RegionNar(_pReg);
+}
+
+static inline void RegionEmpty(RegionPtr _pReg)
+{
+    RegionUninit(_pReg);
+    (_pReg)->extents.x2 = (_pReg)->extents.x1;
+    (_pReg)->extents.y2 = (_pReg)->extents.y1;
+    (_pReg)->data = &RegionEmptyData;
+}
+
+static inline BoxPtr RegionExtents(RegionPtr _pReg)
+{
+    return (&(_pReg)->extents);
+}
+
+static inline void RegionNull(RegionPtr _pReg)
+{
+    (_pReg)->extents = RegionEmptyBox;
+    (_pReg)->data = &RegionEmptyData;
+}
+
+extern _X_EXPORT void InitRegions(void);
 
 extern _X_EXPORT RegionPtr RegionCreate(
     BoxPtr /*rect*/,
@@ -202,19 +183,31 @@ extern _X_EXPORT RegionPtr RegionCreate(
 extern _X_EXPORT void RegionDestroy(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT Bool RegionCopy(
-    RegionPtr /*dst*/,
-    RegionPtr /*src*/);
+static inline Bool
+RegionCopy(RegionPtr dst, RegionPtr src)
+{
+    return pixman_region_copy (dst, src);
+}
 
-extern _X_EXPORT Bool RegionIntersect(
-    RegionPtr /*newReg*/,
-    RegionPtr /*reg1*/,
-    RegionPtr /*reg2*/);
+static inline Bool
+RegionIntersect(
+    RegionPtr	newReg,     /* destination Region */
+    RegionPtr	reg1,
+    RegionPtr	reg2        /* source regions     */
+    )
+{
+    return pixman_region_intersect (newReg, reg1, reg2);
+}
 
-extern _X_EXPORT Bool RegionUnion(
-    RegionPtr /*newReg*/,
-    RegionPtr /*reg1*/,
-    RegionPtr /*reg2*/);
+static inline Bool
+RegionUnion(
+    RegionPtr	newReg,          /* destination Region */
+    RegionPtr	reg1,
+    RegionPtr	reg2             /* source regions     */
+    )
+{
+    return pixman_region_union (newReg, reg1, reg2);
+}
 
 extern _X_EXPORT Bool RegionAppend(
     RegionPtr /*dstrgn*/,
@@ -229,37 +222,87 @@ extern _X_EXPORT RegionPtr RegionFromRects(
     xRectanglePtr /*prect*/,
     int /*ctype*/);
 
-extern _X_EXPORT Bool RegionSubtract(
-    RegionPtr /*regD*/,
-    RegionPtr /*regM*/,
-    RegionPtr /*regS*/);
+/*-
+ *-----------------------------------------------------------------------
+ * Subtract --
+ *	Subtract regS from regM and leave the result in regD.
+ *	S stands for subtrahend, M for minuend and D for difference.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *	regD is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+static inline Bool
+RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
+{
+    return pixman_region_subtract (regD, regM, regS);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * Inverse --
+ *	Take a region and a box and return a region that is everything
+ *	in the box but not in the region. The careful reader will note
+ *	that this is the same as subtracting the region from the box...
+ *
+ * Results:
+ *	TRUE.
+ *
+ * Side Effects:
+ *	newReg is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
 
-extern _X_EXPORT Bool RegionInverse(
-    RegionPtr /*newReg*/,
-    RegionPtr /*reg1*/,
-    BoxPtr /*invRect*/);
+static inline Bool
+RegionInverse(
+    RegionPtr	  newReg,       /* Destination region */
+    RegionPtr	  reg1,         /* Region to invert */
+    BoxPtr	  invRect	/* Bounding box for inversion */
+    )
+{
+    return pixman_region_inverse (newReg, reg1, invRect);
+}
 
-extern _X_EXPORT int RegionContainsRect(
-    RegionPtr /*region*/,
-    BoxPtr /*prect*/);
+static inline int
+RegionContainsRect(RegionPtr region, BoxPtr prect)
+{
+    return pixman_region_contains_rectangle (region, prect);
+}
 
-extern _X_EXPORT void RegionTranslate(
-    RegionPtr /*pReg*/,
-    int /*x*/,
-    int /*y*/);
+/* TranslateRegion(pReg, x, y)
+   translates in place
+*/
+
+static inline void
+RegionTranslate(RegionPtr pReg, int x, int y)
+{
+    pixman_region_translate (pReg, x, y);
+}
 
 extern _X_EXPORT Bool RegionBreak(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT Bool RegionContainsPoint(
-    RegionPtr /*pReg*/,
-    int /*x*/,
-    int /*y*/,
-    BoxPtr /*box*/);
+static inline Bool
+RegionContainsPoint(
+    RegionPtr pReg,
+    int x,
+    int y,
+    BoxPtr box      /* "return" value */
+    )
+{
+    return pixman_region_contains_point (pReg, x, y, box);
+}
 
-extern _X_EXPORT Bool RegionEqual(
-    RegionPtr /*pReg1*/,
-    RegionPtr /*pReg2*/);
+static inline Bool
+RegionEqual(RegionPtr reg1, RegionPtr reg2)
+{
+    return pixman_region_equal (reg1, reg2);
+}
 
 extern _X_EXPORT Bool RegionRectAlloc(
     RegionPtr /*pRgn*/,
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 361c484..e36b15f 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -603,6 +603,10 @@ typedef struct _Screen {
     DeviceCursorCleanupProcPtr    DeviceCursorCleanup;
 } ScreenRec;
 
+static inline RegionPtr BitmapToRegion(ScreenPtr _pScreen, PixmapPtr pPix) {
+    return (*(_pScreen)->BitmapToRegion)(pPix); /* no mi version?! */
+}
+
 typedef struct _ScreenInfo {
     int		imageByteOrder;
     int		bitmapScanlineUnit;
commit 2dc138922b7588515d5f2447e4b9dcdc0bef15e0
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 21 15:05:48 2010 -0700

    Rename region macros to eliminate screen argument
    
    This is a combination of a huge mechanical patch and a few small
    fixups required to finish the job. They were reviewed separately, but
    because the server does not build without both pieces, I've merged
    them together at this time.
    
    The mechanical changes were performed by running the included
    'fix-region' script over the whole tree:
    
    $ git ls-files | grep -v '^fix-' | xargs ./fix-region
    
    And then, the white space errors in the resulting patch were fixed
    using the provided fix-patch-whitespace script.
    
    $ sh ./fix-patch-whitespace
    
    Thanks to Jamey Sharp for the mighty fine sed-generating sed script.
    
    The hand-done changes involve removing functions from dix/region.c
    that duplicate inline functions in include/regionstr.h, along with
    their declarations in regionstr.h, mi.h and mispans.h.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 14e06e1..670cf50 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -152,7 +152,7 @@ XineramaCloseScreen (int i, ScreenPtr pScreen)
     pScreen->CreateGC = pScreenPriv->CreateGC;
 
     if (pScreen->myNum == 0)
-	REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
+	RegionUninit(&PanoramiXScreenRegion);
 
     free((pointer) pScreenPriv);
 
@@ -386,7 +386,7 @@ static void XineramaInitData(ScreenPtr pScreen)
 {
     int i, w, h;
 
-    REGION_NULL(pScreen, &PanoramiXScreenRegion)
+    RegionNull(&PanoramiXScreenRegion)
     for (i = 0; i < PanoramiXNumScreens; i++) {
 	BoxRec TheBox;
 	RegionRec ScreenRegion;
@@ -398,10 +398,10 @@ static void XineramaInitData(ScreenPtr pScreen)
 	TheBox.y1 = pScreen->y;
 	TheBox.y2 = TheBox.y1 + pScreen->height;
 
-	REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1);
-	REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
+	RegionInit(&ScreenRegion, &TheBox, 1);
+	RegionUnion(&PanoramiXScreenRegion, &PanoramiXScreenRegion,
 		     &ScreenRegion);
-	REGION_UNINIT(pScreen, &ScreenRegion);
+	RegionUninit(&ScreenRegion);
     }
 
     PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
@@ -421,7 +421,7 @@ static void XineramaInitData(ScreenPtr pScreen)
 
 void XineramaReinitData(ScreenPtr pScreen)
 {
-    REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
+    RegionUninit(&PanoramiXScreenRegion);
     XineramaInitData(pScreen);
 }
 
@@ -1153,8 +1153,8 @@ XineramaGetImageData(
     SrcBox.x2 = SrcBox.x1 + width;
     SrcBox.y2 = SrcBox.y1 + height;
     
-    REGION_INIT(pScreen, &SrcRegion, &SrcBox, 1);
-    REGION_NULL(pScreen, &GrabRegion);
+    RegionInit(&SrcRegion, &SrcBox, 1);
+    RegionNull(&GrabRegion);
 
     depth = (format == XYPixmap) ? 1 : pDraw->depth;
 
@@ -1169,11 +1169,11 @@ XineramaGetImageData(
 	TheBox.y1 = pScreen->y;
 	TheBox.y2 = TheBox.y1 + pScreen->height;
 
-	REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1);
-	inOut = RECT_IN_REGION(pScreen, &ScreenRegion, &SrcBox);
+	RegionInit(&ScreenRegion, &TheBox, 1);
+	inOut = RegionContainsRect(&ScreenRegion, &SrcBox);
 	if(inOut == rgnPART)
-	    REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, &ScreenRegion);
-	REGION_UNINIT(pScreen, &ScreenRegion);
+	    RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion);
+	RegionUninit(&ScreenRegion);
 
 	if(inOut == rgnIN) {	   
 	    (*pScreen->GetImage)(pDraw,
@@ -1184,10 +1184,10 @@ XineramaGetImageData(
 	} else if (inOut == rgnOUT)
 	    continue;
 
-	nbox = REGION_NUM_RECTS(&GrabRegion);
+	nbox = RegionNumRects(&GrabRegion);
 
 	if(nbox) {
-	    pbox = REGION_RECTS(&GrabRegion);
+	    pbox = RegionRects(&GrabRegion);
 
 	    while(nbox--) {
 		w = pbox->x2 - pbox->x1;
@@ -1264,8 +1264,8 @@ XineramaGetImageData(
 		pbox++;
 	    }
 
-	    REGION_SUBTRACT(pScreen, &SrcRegion, &SrcRegion, &GrabRegion);
-	    if(!REGION_NOTEMPTY(pScreen, &SrcRegion))
+	    RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion);
+	    if(!RegionNotEmpty(&SrcRegion))
 		break;
 	}
 	
@@ -1274,6 +1274,6 @@ XineramaGetImageData(
     if(ScratchMem)
 	free(ScratchMem);
 
-    REGION_UNINIT(pScreen, &SrcRegion);
-    REGION_UNINIT(pScreen, &GrabRegion);
+    RegionUninit(&SrcRegion);
+    RegionUninit(&GrabRegion);
 }
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 5ccbe27..457e071 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -620,7 +620,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
 		 * borderSize
 		 */
 		&& (!wBoundingShape(pWin) ||
-		    POINT_IN_REGION(pWin->drawable.pScreen, 
+		    RegionContainsPoint(
 					wBoundingShape(pWin), 
 					x - pWin->drawable.x, 
 					y - pWin->drawable.y, &box))
@@ -1087,7 +1087,7 @@ int PanoramiXCopyArea(ClientPtr client)
 	RegionRec totalReg;
 	int rc;
 
-	REGION_NULL(unusedScreen, &totalReg);
+	RegionNull(&totalReg);
 	FOR_NSCREENS_BACKWARD(j) {
 	    RegionPtr pRgn;
 	    stuff->dstDrawable = dst->info[j].id;
@@ -1124,11 +1124,11 @@ int PanoramiXCopyArea(ClientPtr client)
 				stuff->dstX, stuff->dstY);
 	    if(pGC->graphicsExposures && pRgn) {
 	       if(srcIsRoot) {
-		   REGION_TRANSLATE(unusedScreen, pRgn,
+		   RegionTranslate(pRgn,
 			    screenInfo.screens[j]->x, screenInfo.screens[j]->y);
 	       }
-	       REGION_APPEND(unusedScreen, &totalReg, pRgn);
-	       REGION_DESTROY(unusedScreen, pRgn);
+	       RegionAppend(&totalReg, pRgn);
+	       RegionDestroy(pRgn);
 	    }
 
 	    if(dstShared)
@@ -1138,10 +1138,10 @@ int PanoramiXCopyArea(ClientPtr client)
 	if(pGC->graphicsExposures) {
 	    ScreenPtr pScreen = pDst->pScreen;
 	    Bool overlap;
-	    REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
+	    RegionValidate(&totalReg, &overlap);
 	    (*pScreen->SendGraphicsExpose)(
 		client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
-	    REGION_UNINIT(unusedScreen, &totalReg);
+	    RegionUninit(&totalReg);
 	}
     }
 
@@ -1193,7 +1193,7 @@ int PanoramiXCopyPlane(ClientPtr client)
     srcx = stuff->srcX; srcy = stuff->srcY;
     dstx = stuff->dstX; dsty = stuff->dstY;
  
-    REGION_NULL(unusedScreen, &totalReg);
+    RegionNull(&totalReg);
     FOR_NSCREENS_BACKWARD(j) {
 	RegionPtr pRgn;
 	stuff->dstDrawable = dst->info[j].id;
@@ -1233,8 +1233,8 @@ int PanoramiXCopyPlane(ClientPtr client)
 				stuff->width, stuff->height, 
 				stuff->dstX, stuff->dstY, stuff->bitPlane);
 	if(pGC->graphicsExposures && pRgn) {
-	    REGION_APPEND(unusedScreen, &totalReg, pRgn);
-	    REGION_DESTROY(unusedScreen, pRgn);
+	    RegionAppend(&totalReg, pRgn);
+	    RegionDestroy(pRgn);
 	}
 
 	if(dstShared)
@@ -1244,10 +1244,10 @@ int PanoramiXCopyPlane(ClientPtr client)
     if(pGC->graphicsExposures) {
 	ScreenPtr pScreen = pdstDraw->pScreen;
 	Bool overlap;
-	REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
+	RegionValidate(&totalReg, &overlap);
 	(*pScreen->SendGraphicsExpose)(
 		client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
-	REGION_UNINIT(unusedScreen, &totalReg);
+	RegionUninit(&totalReg);
     }
 
     return Success;
diff --git a/Xext/shape.c b/Xext/shape.c
index 86b0bc0..fb5b9a7 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -153,11 +153,11 @@ RegionOperate (
     ScreenPtr	pScreen = pWin->drawable.pScreen;
 
     if (srcRgn && (xoff || yoff))
-	REGION_TRANSLATE(pScreen, srcRgn, xoff, yoff);
+	RegionTranslate(srcRgn, xoff, yoff);
     if (!pWin->parent)
     {
 	if (srcRgn)
-	    REGION_DESTROY(pScreen, srcRgn);
+	    RegionDestroy(srcRgn);
 	return Success;
     }
 
@@ -168,7 +168,7 @@ RegionOperate (
      */
     if (srcRgn == NULL) {
       if (*destRgnp != NULL) {
-	REGION_DESTROY (pScreen, *destRgnp);
+	RegionDestroy(*destRgnp);
 	*destRgnp = 0;
 	/* go on to remove shape and generate ShapeNotify */
       }
@@ -187,17 +187,17 @@ RegionOperate (
     else switch (op) {
     case ShapeSet:
 	if (*destRgnp)
-	    REGION_DESTROY(pScreen, *destRgnp);
+	    RegionDestroy(*destRgnp);
 	*destRgnp = srcRgn;
 	srcRgn = 0;
 	break;
     case ShapeUnion:
 	if (*destRgnp)
-	    REGION_UNION(pScreen, *destRgnp, *destRgnp, srcRgn);
+	    RegionUnion(*destRgnp, *destRgnp, srcRgn);
 	break;
     case ShapeIntersect:
 	if (*destRgnp)
-	    REGION_INTERSECT(pScreen, *destRgnp, *destRgnp, srcRgn);
+	    RegionIntersect(*destRgnp, *destRgnp, srcRgn);
 	else {
 	    *destRgnp = srcRgn;
 	    srcRgn = 0;
@@ -206,20 +206,20 @@ RegionOperate (
     case ShapeSubtract:
 	if (!*destRgnp)
 	    *destRgnp = (*create)(pWin);
-	REGION_SUBTRACT(pScreen, *destRgnp, *destRgnp, srcRgn);
+	RegionSubtract(*destRgnp, *destRgnp, srcRgn);
 	break;
     case ShapeInvert:
 	if (!*destRgnp)
-	    *destRgnp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
+	    *destRgnp = RegionCreate((BoxPtr) 0, 0);
 	else
-	    REGION_SUBTRACT(pScreen, *destRgnp, srcRgn, *destRgnp);
+	    RegionSubtract(*destRgnp, srcRgn, *destRgnp);
 	break;
     default:
 	client->errorValue = op;
 	return BadValue;
     }
     if (srcRgn)
-	REGION_DESTROY(pScreen, srcRgn);
+	RegionDestroy(srcRgn);
     (*pScreen->SetShape) (pWin, kind);
     SendShapeNotify (pWin, kind);
     return Success;
@@ -234,7 +234,7 @@ CreateBoundingShape (WindowPtr pWin)
     extents.y1 = -wBorderWidth (pWin);
     extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
     extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
-    return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
+    return RegionCreate(&extents, 1);
 }
 
 RegionPtr
@@ -246,7 +246,7 @@ CreateClipShape (WindowPtr pWin)
     extents.y1 = 0;
     extents.x2 = pWin->drawable.width;
     extents.y2 = pWin->drawable.height;
-    return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
+    return RegionCreate(&extents, 1);
 }
 
 static int
@@ -323,7 +323,7 @@ ProcShapeRectangles (ClientPtr client)
     ctype = VerifyRectOrder(nrects, prects, (int)stuff->ordering);
     if (ctype < 0)
 	return BadMatch;
-    srcRgn = RECTS_TO_REGION(pScreen, nrects, prects, ctype);
+    srcRgn = RegionFromRects(nrects, prects, ctype);
 
     if (!pWin->optional)
 	MakeWindowOptional (pWin);
@@ -419,7 +419,7 @@ ProcShapeMask (ClientPtr client)
 	if (pPixmap->drawable.pScreen != pScreen ||
 	    pPixmap->drawable.depth != 1)
 	    return BadMatch;
-	srcRgn = BITMAP_TO_REGION(pScreen, pPixmap);
+	srcRgn = BitmapToRegion(pScreen, pPixmap);
 	if (!srcRgn)
 	    return BadAlloc;
     }
@@ -547,8 +547,8 @@ ProcShapeCombine (ClientPtr client)
     }
 
     if (srcRgn) {
-        tmp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
-        REGION_COPY(pScreen, tmp, srcRgn);
+        tmp = RegionCreate((BoxPtr) 0, 0);
+        RegionCopy(tmp, srcRgn);
         srcRgn = tmp;
     } else
 	srcRgn = (*createSrc) (pSrcWin);
@@ -641,7 +641,7 @@ ProcShapeOffset (ClientPtr client)
     pScreen = pWin->drawable.pScreen;
     if (srcRgn)
     {
-        REGION_TRANSLATE(pScreen, srcRgn, stuff->xOff, stuff->yOff);
+        RegionTranslate(srcRgn, stuff->xOff, stuff->yOff);
         (*pScreen->SetShape) (pWin, stuff->destKind);
     }
     SendShapeNotify (pWin, (int)stuff->destKind);
@@ -697,7 +697,7 @@ ProcShapeQueryExtents (ClientPtr client)
     rep.clipShaped = (wClipShape(pWin) != 0);
     if ((region = wBoundingShape(pWin))) {
      /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
-	pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
+	pExtents = RegionExtents(region);
 	extents = *pExtents;
     } else {
 	extents.x1 = -wBorderWidth (pWin);
@@ -711,7 +711,7 @@ ProcShapeQueryExtents (ClientPtr client)
     rep.heightBoundingShape = extents.y2 - extents.y1;
     if ((region = wClipShape(pWin))) {
      /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
-	pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
+	pExtents = RegionExtents(region);
 	extents = *pExtents;
     } else {
 	extents.x1 = 0;
@@ -899,7 +899,7 @@ SendShapeNotify (WindowPtr pWin, int which)
     case ShapeBounding:
 	region = wBoundingShape(pWin);
 	if (region) {
-	    extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+	    extents = *RegionExtents(region);
 	    shaped = xTrue;
 	} else {
 	    extents.x1 = -wBorderWidth (pWin);
@@ -912,7 +912,7 @@ SendShapeNotify (WindowPtr pWin, int which)
     case ShapeClip:
 	region = wClipShape(pWin);
 	if (region) {
-	    extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+	    extents = *RegionExtents(region);
 	    shaped = xTrue;
 	} else {
 	    extents.x1 = 0;
@@ -925,7 +925,7 @@ SendShapeNotify (WindowPtr pWin, int which)
     case ShapeInput:
 	region = wInputShape(pWin);
 	if (region) {
-	    extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+	    extents = *RegionExtents(region);
 	    shaped = xTrue;
 	} else {
 	    extents.x1 = -wBorderWidth (pWin);
@@ -1050,8 +1050,8 @@ ProcShapeGetRectangles (ClientPtr client)
 	}
     } else {
 	BoxPtr box;
-	nrects = REGION_NUM_RECTS(region);
-	box = REGION_RECTS(region);
+	nrects = RegionNumRects(region);
+	box = RegionRects(region);
 	rects = malloc(nrects * sizeof (xRectangle));
 	if (!rects && nrects)
 	    return BadAlloc;
diff --git a/Xext/xace.c b/Xext/xace.c
index 53f4b4d..07e3da5 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -255,12 +255,12 @@ XaceCensorImage(
     imageBox.y1 = y;
     imageBox.x2 = x + w;
     imageBox.y2 = y + h;
-    REGION_INIT(pScreen, &imageRegion, &imageBox, 1);
-    REGION_NULL(pScreen, &censorRegion);
+    RegionInit(&imageRegion, &imageBox, 1);
+    RegionNull(&censorRegion);
 
     /* censorRegion = imageRegion - visibleRegion */
-    REGION_SUBTRACT(pScreen, &censorRegion, &imageRegion, pVisibleRegion);
-    nRects = REGION_NUM_RECTS(&censorRegion);
+    RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion);
+    nRects = RegionNumRects(&censorRegion);
     if (nRects > 0)
     { /* we have something to censor */
 	GCPtr pScratchGC = NULL;
@@ -280,7 +280,7 @@ XaceCensorImage(
 	    failed = TRUE;
 	    goto failSafe;
 	}
-	for (pBox = REGION_RECTS(&censorRegion), i = 0;
+	for (pBox = RegionRects(&censorRegion), i = 0;
 	     i < nRects;
 	     i++, pBox++)
 	{
@@ -330,8 +330,8 @@ XaceCensorImage(
 	if (pScratchGC) FreeScratchGC(pScratchGC);
 	if (pPix)       FreeScratchPixmapHeader(pPix);
     }
-    REGION_UNINIT(pScreen, &imageRegion);
-    REGION_UNINIT(pScreen, &censorRegion);
+    RegionUninit(&imageRegion);
+    RegionUninit(&censorRegion);
 } /* XaceCensorImage */
 
 /*
diff --git a/composite/compalloc.c b/composite/compalloc.c
index 7930ebe..d8ccc11 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -134,7 +134,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	    EnableMapUnmapEvents (pWin);
 	}
 
-	REGION_NULL (pScreen, &cw->borderClip);
+	RegionNull(&cw->borderClip);
 	cw->borderClipX = 0;
 	cw->borderClipY = 0;
 	cw->update = CompositeRedirectAutomatic;
@@ -227,7 +227,7 @@ compFreeClientWindow (WindowPtr pWin, XID id)
 	if (cw->damage)
 	    DamageDestroy (cw->damage);
 	
-	REGION_UNINIT (pScreen, &cw->borderClip);
+	RegionUninit(&cw->borderClip);
     
 	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
 	free(cw);
@@ -599,7 +599,7 @@ compFreePixmap (WindowPtr pWin)
      * case correctly.  Unmap adds the window borderClip to the
      * parent exposed area; regions beyond the parent cause crashes
      */
-    REGION_COPY (pScreen, &pWin->borderClip, &cw->borderClip);
+    RegionCopy(&pWin->borderClip, &cw->borderClip);
     pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin);
     pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
     pWin->redirectDraw = RedirectDrawNone;
diff --git a/composite/compext.c b/composite/compext.c
index ed43775..d37d52a 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -218,7 +218,7 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
     pRegion = XFixesRegionCopy (pBorderClip);
     if (!pRegion)
 	return BadAlloc;
-    REGION_TRANSLATE (pScreen, pRegion, -pWin->drawable.x, -pWin->drawable.y);
+    RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y);
     
     if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
 	return BadAlloc;
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 0f3898c..7d877b1 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -98,10 +98,10 @@ compRepaintBorder (ClientPtr pClient, pointer closure)
     if (rc == Success) {
 	RegionRec exposed;
 
-	REGION_NULL(pScreen, &exposed);
-	REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize);
+	RegionNull(&exposed);
+	RegionSubtract(&exposed, &pWindow->borderClip, &pWindow->winSize);
 	miPaintWindow(pWindow, &exposed, PW_BORDER);
-	REGION_UNINIT(pScreen, &exposed);
+	RegionUninit(&exposed);
     }
     return TRUE;
 }
@@ -283,7 +283,7 @@ compClipNotify (WindowPtr pWin, int dx, int dy)
 	if (cw->borderClipX != pWin->drawable.x ||
 	    cw->borderClipY != pWin->drawable.y)
 	{
-	    REGION_TRANSLATE (pScreen, &cw->borderClip,
+	    RegionTranslate(&cw->borderClip,
 			      pWin->drawable.x - cw->borderClipX,
 			      pWin->drawable.y - cw->borderClipY);
 	    cw->borderClipX = pWin->drawable.x;
@@ -404,14 +404,14 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
 	    dx = ptOldOrg.x - pWin->drawable.x;
 	    dy = ptOldOrg.y - pWin->drawable.y;
-	    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+	    RegionTranslate(prgnSrc, -dx, -dy);
 
-	    REGION_NULL (pWin->drawable.pScreen, &rgnDst);
+	    RegionNull(&rgnDst);
 
-	    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst,
+	    RegionIntersect(&rgnDst,
 			     &pWin->borderClip, prgnSrc);
 
-	    REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+	    RegionTranslate(&rgnDst,
 			      -pPixmap->screen_x, -pPixmap->screen_y);
 
 	    dx = dx + pPixmap->screen_x - cw->oldx;
@@ -419,8 +419,8 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 	    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
 	    if (pGC)
 	    {
-		BoxPtr	pBox = REGION_RECTS (&rgnDst);
-		int	nBox = REGION_NUM_RECTS (&rgnDst);
+		BoxPtr	pBox = RegionRects (&rgnDst);
+		int	nBox = RegionNumRects (&rgnDst);
 
 		ValidateGC(&pPixmap->drawable, pGC);
 		while (nBox--)
@@ -448,16 +448,16 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
     {
 	if (dx || dy)
-	    REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
+	    RegionTranslate(prgnSrc, dx, dy);
 	(*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
 	if (dx || dy)
-	    REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+	    RegionTranslate(prgnSrc, -dx, -dy);
     }
     else
     {
 	ptOldOrg.x -= dx;
 	ptOldOrg.y -= dy;
-	REGION_TRANSLATE (prgnSrc, prgnSrc,
+	RegionTranslate(prgnSrc,
 			  pWin->drawable.x - ptOldOrg.x,
 			  pWin->drawable.y - ptOldOrg.y);
 	DamageRegionAppend(&pWin->drawable, prgnSrc);
@@ -525,26 +525,26 @@ compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
     CompWindowPtr   cw = GetCompWindow (pWin);
     RegionRec	    damage;
 
-    REGION_NULL (pScreen, &damage);
+    RegionNull(&damage);
     /*
      * Align old border clip with new border clip
      */
-    REGION_TRANSLATE (pScreen, &cw->borderClip,
+    RegionTranslate(&cw->borderClip,
 		      pWin->drawable.x - cw->borderClipX,
 		      pWin->drawable.y - cw->borderClipY);
     /*
      * Compute newly visible portion of window for repaint
      */
-    REGION_SUBTRACT (pScreen, &damage, pRegion, &cw->borderClip);
+    RegionSubtract(&damage, pRegion, &cw->borderClip);
     /*
      * Report that as damaged so it will be redrawn
      */
     DamageRegionAppend(&pWin->drawable, &damage);
-    REGION_UNINIT (pScreen, &damage);
+    RegionUninit(&damage);
     /*
      * Save the new border clip region
      */
-    REGION_COPY (pScreen, &cw->borderClip, pRegion);
+    RegionCopy(&cw->borderClip, pRegion);
     cw->borderClipX = pWin->drawable.x;
     cw->borderClipY = pWin->drawable.y;
 }
@@ -606,18 +606,18 @@ compWindowUpdateAutomatic (WindowPtr pWin)
     /*
      * First move the region from window to screen coordinates
      */
-    REGION_TRANSLATE (pScreen, pRegion,
+    RegionTranslate(pRegion,
 		      pWin->drawable.x, pWin->drawable.y);
 
     /*
      * Clip against the "real" border clip
      */
-    REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip);
+    RegionIntersect(pRegion, pRegion, &cw->borderClip);
 
     /*
      * Now translate from screen to dest coordinates
      */
-    REGION_TRANSLATE (pScreen, pRegion,
+    RegionTranslate(pRegion,
 		      -pParent->drawable.x, -pParent->drawable.y);
 
     /*
diff --git a/damageext/damageext.c b/damageext/damageext.c
index e4eda5e..7717a40 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -94,10 +94,10 @@ DamageExtReport (DamagePtr pDamage, RegionPtr pRegion, void *closure)
     switch (pDamageExt->level) {
     case DamageReportRawRegion:
     case DamageReportDeltaRegion:
-	DamageExtNotify (pDamageExt, REGION_RECTS(pRegion), REGION_NUM_RECTS(pRegion));
+	DamageExtNotify (pDamageExt, RegionRects(pRegion), RegionNumRects(pRegion));
 	break;
     case DamageReportBoundingBox:
-	DamageExtNotify (pDamageExt, REGION_EXTENTS(prScreen, pRegion), 1);
+	DamageExtNotify (pDamageExt, RegionExtents(pRegion), 1);
 	break;
     case DamageReportNonEmpty:
 	DamageExtNotify (pDamageExt, NullBox, 0);
@@ -261,14 +261,14 @@ ProcDamageSubtract (ClientPtr client)
 	if (pRepair)
 	{
 	    if (pParts)
-		REGION_INTERSECT (prScreen, pParts, DamageRegion (pDamage), pRepair);
+		RegionIntersect(pParts, DamageRegion (pDamage), pRepair);
 	    if (DamageSubtract (pDamage, pRepair))
 		DamageExtReport (pDamage, DamageRegion (pDamage), (void *) pDamageExt);
 	}
 	else
 	{
 	    if (pParts)
-		REGION_COPY (prScreen, pParts, DamageRegion (pDamage));
+		RegionCopy(pParts, DamageRegion (pDamage));
 	    DamageEmpty (pDamage);
 	}
     }
@@ -293,9 +293,9 @@ ProcDamageAdd (ClientPtr client)
     /* The region is relative to the drawable origin, so translate it out to
      * screen coordinates like damage expects.
      */
-    REGION_TRANSLATE(pScreen, pRegion, pDrawable->x, pDrawable->y);
+    RegionTranslate(pRegion, pDrawable->x, pDrawable->y);
     DamageRegionAppend(pDrawable, pRegion);
-    REGION_TRANSLATE(pScreen, pRegion, -pDrawable->x, -pDrawable->y);
+    RegionTranslate(pRegion, -pDrawable->x, -pDrawable->y);
 
     return Success;
 }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index c0efce5..859b93e 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1179,11 +1179,11 @@ ProcTranslateCoords(ClientPtr client)
 		 * borderSize
 		 */
 		&& (!wBoundingShape(pWin) ||
-		    POINT_IN_REGION(pWin->drawable.pScreen, 
+		    RegionContainsPoint(
 					&pWin->borderSize, x, y, &box))
 		
 		&& (!wInputShape(pWin) ||
-		    POINT_IN_REGION(pWin->drawable.pScreen,
+		    RegionContainsPoint(
 				    wInputShape(pWin),
 				    x - pWin->drawable.x,
 				    y - pWin->drawable.y, &box))
@@ -1661,7 +1661,7 @@ ProcCopyArea(ClientPtr client)
 	(*pDst->pScreen->SendGraphicsExpose)
  		(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
 	if (pRgn)
-	    REGION_DESTROY(pDst->pScreen, pRgn);
+	    RegionDestroy(pRgn);
     }
 
     return Success;
@@ -1711,7 +1711,7 @@ ProcCopyPlane(ClientPtr client)
 	(*pdstDraw->pScreen->SendGraphicsExpose)
  		(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
 	if (pRgn)
-	    REGION_DESTROY(pdstDraw->pScreen, pRgn);
+	    RegionDestroy(pRgn);
     }
     return Success;
 }
@@ -2151,7 +2151,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 	pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
 	if (pVisibleRegion)
 	{
-	    REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion,
+	    RegionTranslate(pVisibleRegion,
 			     -pDraw->x, -pDraw->y);
 	}
     }
@@ -2240,7 +2240,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 	}
     }
     if (pVisibleRegion)
-	REGION_DESTROY(pDraw->pScreen, pVisibleRegion);
+	RegionDestroy(pVisibleRegion);
     if (!im_return)
 	free(pBuf);
     return Success;
diff --git a/dix/events.c b/dix/events.c
index 502eebd..4c53b55 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -598,7 +598,7 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 
     i = PanoramiXNumScreens - 1;
 
-    REGION_COPY(pSprite->screen, &pSprite->Reg1,
+    RegionCopy(&pSprite->Reg1,
             &pSprite->windows[i]->borderSize);
     off_x = screenInfo.screens[i]->x;
     off_y = screenInfo.screens[i]->y;
@@ -608,18 +608,18 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
         y = off_y - screenInfo.screens[i]->y;
 
         if(x || y)
-            REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1, x, y);
+            RegionTranslate(&pSprite->Reg1, x, y);
 
-        REGION_UNION(pSprite->screen, &pSprite->Reg1, &pSprite->Reg1,
+        RegionUnion(&pSprite->Reg1, &pSprite->Reg1,
                 &pSprite->windows[i]->borderSize);
 
         off_x = screenInfo.screens[i]->x;
         off_y = screenInfo.screens[i]->y;
     }
 
-    pSprite->hotLimits = *REGION_EXTENTS(pSprite->screen, &pSprite->Reg1);
+    pSprite->hotLimits = *RegionExtents(&pSprite->Reg1);
 
-    if(REGION_NUM_RECTS(&pSprite->Reg1) > 1)
+    if(RegionNumRects(&pSprite->Reg1) > 1)
         pSprite->hotShape = &pSprite->Reg1;
     else
         pSprite->hotShape = NullRegion;
@@ -671,9 +671,9 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py)
     SpritePtr pSprite;
 
     pSprite = pDev->spriteInfo->sprite;
-    if (POINT_IN_REGION(pSprite->hot.pScreen, shape, x, y, &box))
+    if (RegionContainsPoint(shape, x, y, &box))
 	return;
-    box = *REGION_EXTENTS(pSprite->hot.pScreen, shape);
+    box = *RegionExtents(shape);
     /* this is rather crude */
     do {
 	x += incx;
@@ -695,7 +695,7 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py)
 	    else if (y < box.y1)
 		return; /* should never get here! */
 	}
-    } while (!POINT_IN_REGION(pSprite->hot.pScreen, shape, x, y, &box));
+    } while (!RegionContainsPoint(shape, x, y, &box));
     *px = x;
     *py = y;
 }
@@ -817,7 +817,7 @@ CheckVirtualMotion(
 
             i = PanoramiXNumScreens - 1;
 
-            REGION_COPY(pSprite->screen, &pSprite->Reg2,
+            RegionCopy(&pSprite->Reg2,
                     &pSprite->windows[i]->borderSize);
             off_x = screenInfo.screens[i]->x;
             off_y = screenInfo.screens[i]->y;
@@ -827,9 +827,9 @@ CheckVirtualMotion(
                 y = off_y - screenInfo.screens[i]->y;
 
                 if(x || y)
-                    REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, x, y);
+                    RegionTranslate(&pSprite->Reg2, x, y);
 
-                REGION_UNION(pSprite->screen, &pSprite->Reg2, &pSprite->Reg2,
+                RegionUnion(&pSprite->Reg2, &pSprite->Reg2,
                         &pSprite->windows[i]->borderSize);
 
                 off_x = screenInfo.screens[i]->x;
@@ -845,7 +845,7 @@ CheckVirtualMotion(
             }
         }
 
-	lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize);
+	lims = *RegionExtents(&pWin->borderSize);
 	if (pSprite->hot.x < lims.x1)
 	    pSprite->hot.x = lims.x1;
 	else if (pSprite->hot.x >= lims.x2)
@@ -858,7 +858,7 @@ CheckVirtualMotion(
 #ifdef PANORAMIX
         if (!noPanoramiXExtension)
         {
-            if (REGION_NUM_RECTS(&pSprite->Reg2) > 1)
+            if (RegionNumRects(&pSprite->Reg2) > 1)
                 reg = &pSprite->Reg2;
 
         } else
@@ -903,7 +903,7 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, Bo
             return;
         }
 #endif
-	pSprite->hotLimits = *REGION_EXTENTS( pScreen, &pWin->borderSize);
+	pSprite->hotLimits = *RegionExtents(&pWin->borderSize);
 	pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize
 					       : NullRegion;
         CheckPhysLimits(pDev, pSprite->current, generateEvents,
@@ -2552,7 +2552,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
 {
     BoxRec box;
 
-    if(POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))
+    if(RegionContainsPoint(&pWin->borderSize, x, y, &box))
 	return TRUE;
 
 #ifdef PANORAMIX
@@ -2562,7 +2562,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
 	int i;
 
 	for(i = 1; i < PanoramiXNumScreens; i++) {
-	   if(POINT_IN_REGION(pSprite->screen,
+	   if(RegionContainsPoint(
 			&pSprite->windows[i]->borderSize,
 			x + screenInfo.screens[0]->x - screenInfo.screens[i]->x,
 			y + screenInfo.screens[0]->y - screenInfo.screens[i]->y,
@@ -2610,7 +2610,7 @@ XYToWindow(DeviceIntPtr pDev, int x, int y)
 	     */
 	    && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
 	    && (!wInputShape(pWin) ||
-		POINT_IN_REGION(pWin->drawable.pScreen,
+		RegionContainsPoint(
 				wInputShape(pWin),
 				x - pWin->drawable.x,
 				y - pWin->drawable.y, &box))
@@ -2880,10 +2880,10 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
             pSprite->hotLimits.x2 -= xoff;
             pSprite->hotLimits.y2 -= yoff;
 
-            if (REGION_NOTEMPTY(pSprite->screen, &pSprite->Reg1))
-                REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1,    xoff, yoff);
-            if (REGION_NOTEMPTY(pSprite->screen, &pSprite->Reg2))
-                REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2,    xoff, yoff);
+            if (RegionNotEmpty(&pSprite->Reg1))
+                RegionTranslate(&pSprite->Reg1,    xoff, yoff);
+            if (RegionNotEmpty(&pSprite->Reg2))
+                RegionTranslate(&pSprite->Reg2,    xoff, yoff);
 
             /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
             if ((grab = pDev->deviceGrab.grab) && grab->confineTo) {
@@ -3018,8 +3018,8 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
         pSprite->hotShape = NullRegion;
         pSprite->screen = pScreen;
         /* gotta UNINIT these someplace */
-        REGION_NULL(pScreen, &pSprite->Reg1);
-        REGION_NULL(pScreen, &pSprite->Reg2);
+        RegionNull(&pSprite->Reg1);
+        RegionNull(&pSprite->Reg2);
     }
 #endif
 }
@@ -3157,7 +3157,7 @@ XineramaPointInWindowIsVisible(
 
     if (!pWin->realized) return FALSE;
 
-    if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+    if (RegionContainsPoint(&pWin->borderClip, x, y, &box))
         return TRUE;
 
     if(!XineramaSetWindowPntrs(inputInfo.pointer, pWin)) return FALSE;
@@ -3171,9 +3171,9 @@ XineramaPointInWindowIsVisible(
 	x = xoff - screenInfo.screens[i]->x;
 	y = yoff - screenInfo.screens[i]->y;
 
-	if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)
+	if(RegionContainsPoint(&pWin->borderClip, x, y, &box)
 	   && (!wInputShape(pWin) ||
-	       POINT_IN_REGION(pWin->drawable.pScreen,
+	       RegionContainsPoint(
 			       wInputShape(pWin),
 			       x - pWin->drawable.x,
 			       y - pWin->drawable.y, &box)))
@@ -3367,7 +3367,7 @@ ProcWarpPointer(ClientPtr client)
 static Bool
 BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
 {
-     if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->hotPhys.pScreen, &pWin->borderSize))
+     if(RegionNotEmpty(&pWin->borderSize))
 	return TRUE;
 
 #ifdef PANORAMIX
@@ -3375,7 +3375,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
 	int i;
 
 	for(i = 1; i < PanoramiXNumScreens; i++) {
-	    if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->screen,
+	    if(RegionNotEmpty(
                         &pDev->spriteInfo->sprite->windows[i]->borderSize))
 		return TRUE;
 	}
diff --git a/dix/region.c b/dix/region.c
index a561601..2e8dde5 100644
--- a/dix/region.c
+++ b/dix/region.c
@@ -83,8 +83,6 @@ Equipment Corporation.
 #include <X11/Xprotostr.h>
 #include <X11/Xfuncproto.h>
 #include "gc.h"
-#include "mi.h"
-#include "mispans.h"
 #include <pixman.h>
 
 #undef assert
@@ -171,7 +169,7 @@ Equipment Corporation.
         ((r1)->y1 <= (r2)->y1) && \
         ((r1)->y2 >= (r2)->y2) )
 
-#define xallocData(n) malloc(REGION_SZOF(n))
+#define xallocData(n) malloc(RegionSizeof(n))
 #define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data)
 
 #define RECTALLOC_BAIL(pReg,n,bail) \
@@ -197,7 +195,7 @@ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
     {									\
 	if (!RegionRectAlloc(pReg, 1))					\
 	    return FALSE;						\
-	pNextRect = REGION_TOP(pReg);					\
+	pNextRect = RegionTop(pReg);					\
     }									\
     ADDRECT(pNextRect,nx1,ny1,nx2,ny2);					\
     pReg->data->numRects++;						\
@@ -209,7 +207,7 @@ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
 if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
 {									 \
     RegDataPtr NewData;							 \
-    NewData = (RegDataPtr)realloc((reg)->data, REGION_SZOF(numRects));	 \
+    NewData = (RegDataPtr)realloc((reg)->data, RegionSizeof(numRects));	 \
     if (NewData)							 \
     {									 \
 	NewData->size = (numRects);					 \
@@ -265,9 +263,9 @@ RegionPrint(RegionPtr rgn)
     int i;
     BoxPtr rects;
 
-    num = REGION_NUM_RECTS(rgn);
-    size = REGION_SIZE(rgn);
-    rects = REGION_RECTS(rgn);
+    num = RegionNumRects(rgn);
+    size = RegionSize(rgn);
+    rects = RegionRects(rgn);
     ErrorF("[mi] num: %d size: %d\n", num, size);
     ErrorF("[mi] extents: %d %d %d %d\n",
 	   rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2);
@@ -292,7 +290,7 @@ RegionIsValid(RegionPtr reg)
     if ((reg->extents.x1 > reg->extents.x2) ||
 	(reg->extents.y1 > reg->extents.y2))
 	return FALSE;
-    numRects = REGION_NUM_RECTS(reg);
+    numRects = RegionNumRects(reg);
     if (!numRects)
 	return ((reg->extents.x1 == reg->extents.x2) &&
 		(reg->extents.y1 == reg->extents.y2) &&
@@ -304,7 +302,7 @@ RegionIsValid(RegionPtr reg)
 	BoxPtr pboxP, pboxN;
 	BoxRec box;
 	
-	pboxP = REGION_RECTS(reg);
+	pboxP = RegionRects(reg);
 	box = *pboxP;
 	box.y2 = pboxP[numRects-1].y2;
 	pboxN = pboxP + 1;
@@ -330,26 +328,6 @@ RegionIsValid(RegionPtr reg)
 }
 #endif /* DEBUG */
 
-/*****************************************************************
- *   RegionInit(pReg, rect, size)
- *     Outer region rect is statically allocated.
- *****************************************************************/
-
-void
-RegionInit(RegionPtr pReg, BoxPtr rect, int size)
-{
-    if (rect)
-	pixman_region_init_with_extents (pReg, rect);
-    else
-	pixman_region_init (pReg);
-}
-
-void
-RegionUninit(RegionPtr pReg)
-{
-    pixman_region_fini (pReg);
-}
-
 Bool
 RegionBreak (RegionPtr pReg)
 {
@@ -371,7 +349,7 @@ RegionRectAlloc(RegionPtr pRgn, int n)
 	if (!pRgn->data)
 	    return RegionBreak (pRgn);
 	pRgn->data->numRects = 1;
-	*REGION_BOXPTR(pRgn) = pRgn->extents;
+	*RegionBoxptr(pRgn) = pRgn->extents;
     }
     else if (!pRgn->data->size)
     {
@@ -389,7 +367,7 @@ RegionRectAlloc(RegionPtr pRgn, int n)
 		n = 250;
 	}
 	n += pRgn->data->numRects;
-	data = (RegDataPtr)realloc(pRgn->data, REGION_SZOF(n));
+	data = (RegDataPtr)realloc(pRgn->data, RegionSizeof(n));
 	if (!data)
 	    return RegionBreak (pRgn);
 	pRgn->data = data;
@@ -448,8 +426,8 @@ RegionCoalesce (
      * The bands may only be coalesced if the bottom of the previous
      * matches the top scanline of the current.
      */
-    pPrevBox = REGION_BOX(pReg, prevStart);
-    pCurBox = REGION_BOX(pReg, curStart);
+    pPrevBox = RegionBox(pReg, prevStart);
+    pCurBox = RegionBox(pReg, curStart);
     if (pPrevBox->y2 != pCurBox->y1) return curStart;
 
     /*
@@ -528,7 +506,7 @@ RegionAppendNonO (
 
     /* Make sure we have enough space for all rectangles to be added */
     RECTALLOC(pReg, newRects);
-    pNextRect = REGION_TOP(pReg);
+    pNextRect = RegionTop(pReg);
     pReg->data->numRects += newRects;
     do {
 	assert(r->x1 < r->x2);
@@ -553,7 +531,7 @@ RegionAppendNonO (
     int newRects;							\
     if ((newRects = rEnd - r)) {					\
 	RECTALLOC(newReg, newRects);					\
-	memmove((char *)REGION_TOP(newReg),(char *)r, 			\
+	memmove((char *)RegionTop(newReg),(char *)r, 			\
               newRects * sizeof(BoxRec));				\
 	newReg->data->numRects += newRects;				\
     }									\
@@ -634,7 +612,7 @@ RegionOp(
     /*
      * Break any region computed from a broken region
      */
-    if (REGION_NAR (reg1) || REGION_NAR(reg2))
+    if (RegionNar (reg1) || RegionNar(reg2))
 	return RegionBreak (newReg);
     
     /*
@@ -645,11 +623,11 @@ RegionOp(
      * another array of rectangles for it to use.
      */
 
-    r1 = REGION_RECTS(reg1);
-    newSize = REGION_NUM_RECTS(reg1);
+    r1 = RegionRects(reg1);
+    newSize = RegionNumRects(reg1);
     r1End = r1 + newSize;
-    numRects = REGION_NUM_RECTS(reg2);
-    r2 = REGION_RECTS(reg2);
+    numRects = RegionNumRects(reg2);
+    r2 = RegionRects(reg2);
     r2End = r2 + numRects;
     assert(r1 != r1End);
     assert(r2 != r2End);
@@ -806,7 +784,7 @@ RegionOp(
     }
     else if (numRects == 1)
     {
-	newReg->extents = *REGION_BOXPTR(newReg);
+	newReg->extents = *RegionBoxptr(newReg);
 	xfreeData(newReg);
 	newReg->data = NULL;
     }
@@ -847,8 +825,8 @@ RegionSetExtents (RegionPtr pReg)
 	return;
     }
 
-    pBox = REGION_BOXPTR(pReg);
-    pBoxEnd = REGION_END(pReg);
+    pBox = RegionBoxptr(pReg);
+    pBoxEnd = RegionEnd(pReg);
 
     /*
      * Since pBox is the first rectangle in the region, it must have the
@@ -953,7 +931,7 @@ RegionUnionO (
     assert (y1 < y2);
     assert(r1 != r1End && r2 != r2End);
 
-    pNextRect = REGION_TOP(pReg);
+    pNextRect = RegionTop(pReg);
 
     /* Start off current rectangle */
     if (r1->x1 < r2->x1)
@@ -1033,7 +1011,7 @@ RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
     BoxPtr new, old;
     Bool prepend;
 
-    if (REGION_NAR(rgn))
+    if (RegionNar(rgn))
 	return RegionBreak (dstrgn);
     
     if (!rgn->data && (dstrgn->data == &RegionEmptyData))
@@ -1043,16 +1021,16 @@ RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
 	return TRUE;
     }
 
-    numRects = REGION_NUM_RECTS(rgn);
+    numRects = RegionNumRects(rgn);
     if (!numRects)
 	return TRUE;
     prepend = FALSE;
     size = numRects;
-    dnumRects = REGION_NUM_RECTS(dstrgn);
+    dnumRects = RegionNumRects(dstrgn);
     if (!dnumRects && (size < 200))
 	size = 200; /* XXX pick numbers out of a hat */
     RECTALLOC(dstrgn, size);
-    old = REGION_RECTS(rgn);
+    old = RegionRects(rgn);
     if (!dnumRects)
 	dstrgn->extents = rgn->extents;
     else if (dstrgn->extents.x2 > dstrgn->extents.x1)
@@ -1060,7 +1038,7 @@ RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
 	BoxPtr first, last;
 
 	first = old;
-	last = REGION_BOXPTR(dstrgn) + (dnumRects - 1);
+	last = RegionBoxptr(dstrgn) + (dnumRects - 1);
 	if ((first->y1 > last->y2) ||
 	    ((first->y1 == last->y1) && (first->y2 == last->y2) &&
 	     (first->x1 > last->x2)))
@@ -1073,7 +1051,7 @@ RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
 	}
 	else
 	{
-	    first = REGION_BOXPTR(dstrgn);
+	    first = RegionBoxptr(dstrgn);
 	    last = old + (numRects - 1);
 	    if ((first->y1 > last->y2) ||
 		((first->y1 == last->y1) && (first->y2 == last->y2) &&
@@ -1092,16 +1070,16 @@ RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
     }
     if (prepend)
     {
-	new = REGION_BOX(dstrgn, numRects);
+	new = RegionBox(dstrgn, numRects);
 	if (dnumRects == 1)
-	    *new = *REGION_BOXPTR(dstrgn);
+	    *new = *RegionBoxptr(dstrgn);
 	else
-	    memmove((char *)new,(char *)REGION_BOXPTR(dstrgn), 
+	    memmove((char *)new,(char *)RegionBoxptr(dstrgn),
 		  dnumRects * sizeof(BoxRec));
-	new = REGION_BOXPTR(dstrgn);
+	new = RegionBoxptr(dstrgn);
     }
     else
-	new = REGION_BOXPTR(dstrgn) + dnumRects;
+	new = RegionBoxptr(dstrgn) + dnumRects;
     if (numRects == 1)
 	*new = *old;
     else
@@ -1242,7 +1220,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
     numRects = badreg->data->numRects;
     if (!numRects)
     {
-	if (REGION_NAR(badreg))
+	if (RegionNar(badreg))
 	    return FALSE;
 	good(badreg);
 	return TRUE;
@@ -1263,7 +1241,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
     }
 
     /* Step 1: Sort the rects array into ascending (y1, x1) order */
-    QuickSortRects(REGION_BOXPTR(badreg), numRects);
+    QuickSortRects(RegionBoxptr(badreg), numRects);
 
     /* Step 2: Scatter the sorted array into the minimum number of regions */
 
@@ -1277,7 +1255,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
     ri[0].prevBand = 0;
     ri[0].curBand = 0;
     ri[0].reg = *badreg;
-    box = REGION_BOXPTR(&ri[0].reg);
+    box = RegionBoxptr(&ri[0].reg);
     ri[0].reg.extents = *box;
     ri[0].reg.data->numRects = 1;
 
@@ -1294,7 +1272,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
 	for (j = numRI, rit = ri; --j >= 0; rit++)
 	{
 	    reg = &rit->reg;
-	    riBox = REGION_END(reg);
+	    riBox = RegionEnd(reg);
 
 	    if (box->y1 == riBox->y1 && box->y2 == riBox->y2)
 	    {
@@ -1308,7 +1286,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
 		else
 		{
 		    RECTALLOC_BAIL(reg, 1, bail);
-		    *REGION_TOP(reg) = *box;
+		    *RegionTop(reg) = *box;
 		    reg->data->numRects++;
 		}
 		goto NextRect;   /* So sue me */
@@ -1321,7 +1299,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
 		Coalesce(reg, rit->prevBand, rit->curBand);
 		rit->curBand = reg->data->numRects;
 		RECTALLOC_BAIL(reg, 1, bail);
-		*REGION_TOP(reg) = *box;
+		*RegionTop(reg) = *box;
 		reg->data->numRects++;
 		goto NextRect;
 	    }
@@ -1355,7 +1333,7 @@ NextRect: ;
     for (j = numRI, rit = ri; --j >= 0; rit++)
     {
 	reg = &rit->reg;
-	riBox = REGION_END(reg);
+	riBox = RegionEnd(reg);
 	reg->extents.y2 = riBox->y2;
 	if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
 	Coalesce(reg, rit->prevBand, rit->curBand);
@@ -1410,7 +1388,7 @@ RegionFromRects(int nrects, xRectangle *prect, int ctype)
     int			x1, y1, x2, y2;
 
     pRgn = RegionCreate(NullBox, 0);
-    if (REGION_NAR (pRgn))
+    if (RegionNar (pRgn))
 	return pRgn;
     if (!nrects)
 	return pRgn;
@@ -1563,12 +1541,6 @@ RegionTranslate(RegionPtr pReg, int x, int y)
     pixman_region_translate (pReg, x, y);
 }
 
-void
-RegionReset(RegionPtr pReg, BoxPtr pBox)
-{
-    pixman_region_reset (pReg, pBox);
-}
-
 Bool
 RegionContainsPoint(
     RegionPtr pReg,
@@ -1580,36 +1552,6 @@ RegionContainsPoint(
     return pixman_region_contains_point (pReg, x, y, box);
 }
 
-Bool
-RegionNotEmpty(RegionPtr pReg)
-{
-    return pixman_region_not_empty (pReg);
-}
-
-Bool
-RegionBroken(RegionPtr pReg)
-{
-    good(pReg);
-    return (REGION_NAR(pReg));
-}
-
-void
-RegionEmpty(RegionPtr pReg)
-{
-    good(pReg);
-    xfreeData(pReg);
-    pReg->extents.x2 = pReg->extents.x1;
-    pReg->extents.y2 = pReg->extents.y1;
-    pReg->data = &RegionEmptyData;
-}
-
-BoxPtr
-RegionExtents(RegionPtr pReg)
-{
-    good(pReg);
-    return(&pReg->extents);
-}
-
 #define ExchangeSpans(a, b)				    \
 {							    \
     DDXPointRec	tpt;				    	    \
@@ -1795,7 +1737,7 @@ RegionClipSpans(
 	if ((! fSorted) && (nspans > 1))
 	    QuickSortSpans(ppt, pwidth, nspans);
 
-	pboxBandStart = REGION_BOXPTR(prgnDst);
+	pboxBandStart = RegionBoxptr(prgnDst);
 	pboxLast = pboxBandStart + numRects;
     
 	NextBand();
diff --git a/dix/window.c b/dix/window.c
index afb10fd..a98437b 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -416,10 +416,10 @@ CreateRootWindow(ScreenPtr pScreen)
     box.y1 = 0;
     box.x2 = pScreen->width;
     box.y2 = pScreen->height;
-    REGION_INIT(pScreen, &pWin->clipList, &box, 1);
-    REGION_INIT(pScreen, &pWin->winSize, &box, 1);
-    REGION_INIT(pScreen, &pWin->borderSize, &box, 1);
-    REGION_INIT(pScreen, &pWin->borderClip, &box, 1);
+    RegionInit(&pWin->clipList, &box, 1);
+    RegionInit(&pWin->winSize, &box, 1);
+    RegionInit(&pWin->borderSize, &box, 1);
+    RegionInit(&pWin->borderClip, &box, 1);
 
     pWin->drawable.class = InputOutput;
     pWin->optional->visual = pScreen->rootVisual;
@@ -499,7 +499,7 @@ ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn,
 
     pScreen = pWin->drawable.pScreen;
 
-    box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
+    box = *(RegionExtents(&pWin->winSize));
     /* we do these calculations to avoid overflows */
     if (x > box.x1)
 	box.x1 = x;
@@ -515,8 +515,8 @@ ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn,
 	box.x2 = box.x1;
     if (box.y1 > box.y2)
 	box.y2 = box.y1;
-    REGION_RESET(pScreen, Rgn, &box);
-    REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize);
+    RegionReset(Rgn, &box);
+    RegionIntersect(Rgn, Rgn, &pWin->winSize);
 }
 
 static RealChildHeadProc realChildHeadProc = NULL;
@@ -703,10 +703,10 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
     pWin->drawable.y = pParent->drawable.y + y + (int)bw;
 
 	/* set up clip list correctly for unobscured WindowPtr */
-    REGION_NULL(pScreen, &pWin->clipList);
-    REGION_NULL(pScreen, &pWin->borderClip);
-    REGION_NULL(pScreen, &pWin->winSize);
-    REGION_NULL(pScreen, &pWin->borderSize);
+    RegionNull(&pWin->clipList);
+    RegionNull(&pWin->borderClip);
+    RegionNull(&pWin->winSize);
+    RegionNull(&pWin->borderSize);
 
     pHead = RealChildHead(pParent);
     if (pHead)
@@ -824,16 +824,16 @@ FreeWindowResources(WindowPtr pWin)
     DeleteWindowFromAnySaveSet(pWin);
     DeleteWindowFromAnySelections(pWin);
     DeleteWindowFromAnyEvents(pWin, TRUE);
-    REGION_UNINIT(pScreen, &pWin->clipList);
-    REGION_UNINIT(pScreen, &pWin->winSize);
-    REGION_UNINIT(pScreen, &pWin->borderClip);
-    REGION_UNINIT(pScreen, &pWin->borderSize);
+    RegionUninit(&pWin->clipList);
+    RegionUninit(&pWin->winSize);
+    RegionUninit(&pWin->borderClip);
+    RegionUninit(&pWin->borderSize);
     if (wBoundingShape (pWin))
-	REGION_DESTROY(pScreen, wBoundingShape (pWin));
+	RegionDestroy(wBoundingShape (pWin));
     if (wClipShape (pWin))
-	REGION_DESTROY(pScreen, wClipShape (pWin));
+	RegionDestroy(wClipShape (pWin));
     if (wInputShape (pWin))
-	REGION_DESTROY(pScreen, wInputShape (pWin));
+	RegionDestroy(wInputShape (pWin));
     if (pWin->borderIsPixel == FALSE)
 	(*pScreen->DestroyPixmap)(pWin->border.pixmap);
     if (pWin->backgroundState == BackgroundPixmap)
@@ -1431,10 +1431,10 @@ PatchUp:
     {
 	RegionRec exposed;
 
-	REGION_NULL(pScreen, &exposed);
-	REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
+	RegionNull(&exposed);
+	RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize);
 	miPaintWindow(pWin, &exposed, PW_BORDER);
-	REGION_UNINIT(pScreen, &exposed);
+	RegionUninit(&exposed);
     }
     return error;
 }
@@ -1581,7 +1581,7 @@ SetWinSize (WindowPtr pWin)
 	box.y1 = pWin->drawable.y;
 	box.x2 = pWin->drawable.x + pWin->drawable.width;
 	box.y2 = pWin->drawable.y + pWin->drawable.height;
-	REGION_RESET (pScreen, &pWin->winSize, &box);
+	RegionReset(&pWin->winSize, &box);
     }
     else
 #endif
@@ -1593,15 +1593,15 @@ SetWinSize (WindowPtr pWin)
 	ScreenPtr pScreen;
         pScreen = pWin->drawable.pScreen;
 
-	REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x,
+	RegionTranslate(&pWin->winSize, - pWin->drawable.x,
 			 - pWin->drawable.y);
 	if (wBoundingShape (pWin))
-	    REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+	    RegionIntersect(&pWin->winSize, &pWin->winSize,
 			     wBoundingShape (pWin));
 	if (wClipShape (pWin))
-	    REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+	    RegionIntersect(&pWin->winSize, &pWin->winSize,
 			     wClipShape (pWin));
-	REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x,
+	RegionTranslate(&pWin->winSize, pWin->drawable.x,
 			 pWin->drawable.y);
     }
 }
@@ -1626,7 +1626,7 @@ SetBorderSize (WindowPtr pWin)
 	    box.y1 = pWin->drawable.y - bw;
 	    box.x2 = pWin->drawable.x + pWin->drawable.width + bw;
 	    box.y2 = pWin->drawable.y + pWin->drawable.height + bw;
-	    REGION_RESET (pScreen, &pWin->borderSize, &box);
+	    RegionReset(&pWin->borderSize, &box);
 	}
 	else
 #endif
@@ -1638,17 +1638,17 @@ SetBorderSize (WindowPtr pWin)
 	    ScreenPtr pScreen;
             pScreen = pWin->drawable.pScreen;
 
-	    REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x,
+	    RegionTranslate(&pWin->borderSize, - pWin->drawable.x,
 			     - pWin->drawable.y);
-	    REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize,
+	    RegionIntersect(&pWin->borderSize, &pWin->borderSize,
 			     wBoundingShape (pWin));
-	    REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x,
+	    RegionTranslate(&pWin->borderSize, pWin->drawable.x,
 			     pWin->drawable.y);
-	    REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize,
+	    RegionUnion(&pWin->borderSize, &pWin->borderSize,
 			 &pWin->winSize);
 	}
     } else {
-	REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize,
+	RegionCopy(&pWin->borderSize,
 					       &pWin->winSize);
     }
 }
@@ -1848,12 +1848,12 @@ MakeBoundingRegion (
     ScreenPtr   pScreen;
     pScreen = pWin->drawable.pScreen;
 
-    pRgn = REGION_CREATE(pScreen, pBox, 1);
+    pRgn = RegionCreate(pBox, 1);
     if (wBoundingShape (pWin)) {
-	    REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x,
+	    RegionTranslate(pRgn, -pWin->origin.x,
 						  -pWin->origin.y);
-	    REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
-	    REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x,
+	    RegionIntersect(pRgn, pRgn, wBoundingShape (pWin));
+	    RegionTranslate(pRgn, pWin->origin.x,
 						  pWin->origin.y);
     }
     return pRgn;
@@ -1875,10 +1875,10 @@ ShapeOverlap (
     pScreen = pWin->drawable.pScreen;
     pWinRgn = MakeBoundingRegion (pWin, pWinBox);
     pSibRgn = MakeBoundingRegion (pSib, pSibBox);
-    REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn);
-    ret = REGION_NOTEMPTY(pScreen, pWinRgn);
-    REGION_DESTROY(pScreen, pWinRgn);
-    REGION_DESTROY(pScreen, pSibRgn);
+    RegionIntersect(pWinRgn, pWinRgn, pSibRgn);
+    ret = RegionNotEmpty(pWinRgn);
+    RegionDestroy(pWinRgn);
+    RegionDestroy(pSibRgn);
     return ret;
 }
 
@@ -2004,7 +2004,7 @@ WhereDoIGoInTheStack(
 	else if (pSib)
 	{
 	    if ((IsSiblingAboveMe(pWin, pSib) == Above) &&
-		(RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+		(RegionContainsRect(&pSib->borderSize, &box) != rgnOUT))
 		return(pFirst);
 	    else
 		return(pWin->nextSib);
@@ -2019,7 +2019,7 @@ WhereDoIGoInTheStack(
 	else if (pSib)
 	{
 	    if ((IsSiblingAboveMe(pWin, pSib) == Below) &&
-		(RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+		(RegionContainsRect(&pSib->borderSize, &box) != rgnOUT))
 		return NullWindow;
 	    else
 		return(pWin->nextSib);
@@ -2033,7 +2033,7 @@ WhereDoIGoInTheStack(
 	    return(pWin->nextSib);
 	else if (pSib)
 	{
-	    if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)
+	    if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)
 	    {
 		if (IsSiblingAboveMe(pWin, pSib) == Above)
 		    return(pFirst);
@@ -2681,10 +2681,10 @@ MapWindow(WindowPtr pWin, ClientPtr client)
 	    (*pScreen->ClipNotify) (pWin, 0, 0);
 	if (pScreen->PostValidateTree)
 	    (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap);
-	REGION_NULL(pScreen, &temp);
-	REGION_COPY(pScreen, &temp, &pWin->clipList);
+	RegionNull(&temp);
+	RegionCopy(&temp, &pWin->clipList);
 	(*pScreen->WindowExposures) (pWin, &temp, NullRegion);
-	REGION_UNINIT(pScreen, &temp);
+	RegionUninit(&temp);
     }
 
     return(Success);
@@ -3017,10 +3017,10 @@ PointInWindowIsVisible(WindowPtr pWin, int x, int y)
 
     if (!pWin->realized)
 	return (FALSE);
-    if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip,
+    if (RegionContainsPoint(&pWin->borderClip,
 						  x, y, &box)
 	&& (!wInputShape(pWin) ||
-	    POINT_IN_REGION(pWin->drawable.pScreen,
+	    RegionContainsPoint(
 			    wInputShape(pWin),
 			    x - pWin->drawable.x, 
 			    y - pWin->drawable.y, &box)))
@@ -3036,12 +3036,12 @@ NotClippedByChildren(WindowPtr pWin)
     RegionPtr pReg;
 
     pScreen = pWin->drawable.pScreen;
-    pReg = REGION_CREATE(pScreen, NullBox, 1);
+    pReg = RegionCreate(NullBox, 1);
     if (pWin->parent ||
 	screenIsSaved != SCREEN_SAVER_ON ||
 	!HasSaverWindow (pWin->drawable.pScreen))
     {
-	REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
+	RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize);
     }
     return(pReg);
 }
diff --git a/doc/xml/Xserver-spec.xml b/doc/xml/Xserver-spec.xml
index 1bea20f..88885ae 100644
--- a/doc/xml/Xserver-spec.xml
+++ b/doc/xml/Xserver-spec.xml
@@ -2101,7 +2101,7 @@ Making direct calls is faster on many architectures.</para>
 		BoxPtr rect;
 		int size;
 
-	macro: RegionPtr REGION_CREATE(pScreen, rect, size)
+	macro: RegionPtr RegionCreate(rect, size)
 
 </programlisting></blockquote>
 RegionCreate creates a region that describes ONE rectangle.  The
@@ -2122,7 +2122,7 @@ applicable.</para>
 		BoxPtr		rect;
 		int		size;
 
-	macro: REGION_INIT(pScreen, pRegion, rect, size)
+	macro: RegionInit(pRegion, rect, size)
 
 </programlisting></blockquote>
 Given an existing raw region structure (such as an local variable), this
@@ -2136,7 +2136,7 @@ allocation overhead for the region structure itself.
 	Bool pScreen->RegionCopy(dstrgn, srcrgn)
 		RegionPtr dstrgn, srcrgn;
 
-	macro: Bool REGION_COPY(pScreen, dstrgn, srcrgn)
+	macro: Bool RegionCopy(dstrgn, srcrgn)
 
 </programlisting></blockquote>
 RegionCopy copies the description of one region, srcrgn, to another
@@ -2148,7 +2148,7 @@ dstrgn; returning TRUE if the copy succeeded, and FALSE otherwise.</para>
 	void pScreen->RegionDestroy( pRegion)
 		RegionPtr pRegion;
 
-	macro: REGION_DESTROY(pScreen, pRegion)
+	macro: RegionDestroy(pRegion)
 
 </programlisting></blockquote>
 RegionDestroy destroys a region and frees all allocated memory.</para>
@@ -2158,7 +2158,7 @@ RegionDestroy destroys a region and frees all allocated memory.</para>
 	void pScreen->RegionUninit (pRegion)
 		RegionPtr pRegion;
 
-	macro: REGION_UNINIT(pScreen, pRegion)
+	macro: RegionUninit(pRegion)
 
 </programlisting></blockquote>
 Frees everything except the region structure itself, useful when the
@@ -2171,23 +2171,23 @@ it has been RegionInit'ed again.</para>
 	Bool pScreen->Intersect(newReg, reg1, reg2)
 		RegionPtr newReg, reg1, reg2;
 
-	macro: Bool REGION_INTERSECT(pScreen, newReg, reg1, reg2)
+	macro: Bool RegionIntersect(newReg, reg1, reg2)
 
 	Bool  pScreen->Union(newReg, reg1, reg2)
 		RegionPtr newReg, reg1, reg2;
 
-	macro: Bool REGION_UNION(pScreen, newReg, reg1, reg2)
+	macro: Bool RegionUnion(newReg, reg1, reg2)
 
 	Bool  pScreen->Subtract(newReg, regMinuend, regSubtrahend)
 		RegionPtr newReg, regMinuend, regSubtrahend;
 
-	macro: Bool REGION_UNION(pScreen, newReg, regMinuend, regSubtrahend)
+	macro: Bool RegionUnion(newReg, regMinuend, regSubtrahend)
 
 	Bool pScreen->Inverse(newReg, pReg,  pBox)
 		RegionPtr newReg, pReg;
 		BoxPtr pBox;
 
-	macro: Bool REGION_INVERSE(pScreen, newReg, pReg,  pBox)
+	macro: Bool RegionInverse(newReg, pReg,  pBox)
 
 </programlisting></blockquote>
 The above four calls all do basic logical operations on regions.  They
@@ -2213,7 +2213,7 @@ Each routine must return the value TRUE for success.</para>
 		RegionPtr pRegion;
 		BoxPtr pBox;
 
-	macro: REGION_RESET(pScreen, pRegion, pBox)
+	macro: RegionReset(pRegion, pBox)
 
 </programlisting></blockquote>
 RegionReset sets the region to describe
@@ -2225,7 +2225,7 @@ one rectangle and reallocates it to a size of one rectangle, if applicable.</par
 		RegionPtr pRegion;
 		int x, y;
 
-	macro: REGION_TRANSLATE(pScreen, pRegion, x, y)
+	macro: RegionTranslate(pRegion, x, y)
 
 </programlisting></blockquote>
 TranslateRegion simply moves a region +x in the x direction and +y in the y
@@ -2237,7 +2237,7 @@ direction.</para>
 		RegionPtr pRegion;
 		BoxPtr pBox;
 
-	macro: int RECT_IN_REGION(pScreen, pRegion, pBox)
+	macro: int RegionContainsRect(pRegion, pBox)
 
 </programlisting></blockquote>
 RectIn returns one of the defined constants rgnIN, rgnOUT, or rgnPART,
@@ -2252,7 +2252,7 @@ These constants are defined in Xserver/include/region.h.</para>
 		int x, y;
 		BoxPtr pBox;
 
-	macro: Bool POINT_IN_REGION(pScreen, pRegion, x, y, pBox)
+	macro: Bool RegionContainsPoint(pRegion, x, y, pBox)
 
 </programlisting></blockquote>
 PointInRegion returns true if the point x, y is in the region.  In
@@ -2275,7 +2275,7 @@ returned box.</para>
 	Bool pScreen->RegionNotEmpty(pRegion)
 		RegionPtr pRegion;
 
-	macro: Bool REGION_NOTEMPTY(pScreen, pRegion)
+	macro: Bool RegionNotEmpty(pRegion)
 
 </programlisting></blockquote>
 RegionNotEmpty is a boolean function that returns
@@ -2286,7 +2286,7 @@ true or false depending upon whether the region encloses any pixels.</para>
 	void pScreen->RegionEmpty(pRegion)
 		RegionPtr pRegion;
 
-	macro: REGION_EMPTY(pScreen, pRegion)
+	macro: RegionEmpty(pRegion)
 
 </programlisting></blockquote>
 RegionEmpty sets the region to be empty.</para>
@@ -2296,7 +2296,7 @@ RegionEmpty sets the region to be empty.</para>
 	BoxPtr pScreen->RegionExtents(pRegion)
 		RegionPtr pRegion;
 
-	macro: REGION_EXTENTS(pScreen, pRegion)
+	macro: RegionExtents(pRegion)
 
 </programlisting></blockquote>
 RegionExtents returns a rectangle that is the smallest
@@ -2310,13 +2310,13 @@ in your region struct.</para>
 		RegionPtr pDstRgn;
 		RegionPtr pRegion;
 
-	macro: Bool REGION_APPEND(pScreen, pDstRgn, pRegion)
+	macro: Bool RegionAppend(pDstRgn, pRegion)
 
 	Bool pScreen->RegionValidate (pRegion, pOverlap)
 		RegionPtr pRegion;
 		Bool *pOverlap;
 
-	macro: Bool REGION_VALIDATE(pScreen, pRegion, pOverlap)
+	macro: Bool RegionValidate(pRegion, pOverlap)
 
 </programlisting></blockquote>
 These functions provide an optimization for clip list generation and
@@ -2332,7 +2332,7 @@ regions overlap; FALSE otherwise.</para>
 	RegionPtr pScreen->BitmapToRegion (pPixmap)
 		PixmapPtr pPixmap;
 
-	macro: RegionPtr BITMAP_TO_REGION(pScreen, pPixmap)
+	macro: RegionPtr BitmapToRegion(pScreen, pPixmap)
 
 </programlisting></blockquote>
 Given a depth-1 pixmap, this routine must create a valid region which
@@ -2346,7 +2346,7 @@ areas filled with 0's.  This routine returns NULL if out of memory.</para>
 		xRectangle *pRects;
 		int ordering;
 
-	macro: RegionPtr RECTS_TO_REGION(pScreen, nrects, pRects, ordering)
+	macro: RegionPtr RegionFromRects(nrects, pRects, ordering)
 
 </programlisting></blockquote>
 Given a client-supplied list of rectangles, produces a region which includes
diff --git a/exa/exa.c b/exa/exa.c
index 46a850f..4e1ffd6 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -161,10 +161,10 @@ exaPixmapDirty (PixmapPtr pPix, int x1, int y1, int x2, int y2)
     if (box.x1 >= box.x2 || box.y1 >= box.y2)
 	return;
 
-    REGION_INIT(pScreen, &region, &box, 1);
+    RegionInit(&region, &box, 1);
     DamageRegionAppend(&pPix->drawable, &region);
     DamageRegionProcessPending(&pPix->drawable);
-    REGION_UNINIT(pScreen, &region);
+    RegionUninit(&region);
 }
 
 static int
@@ -658,7 +658,7 @@ exaBitmapToRegion(PixmapPtr pPix)
 
     exaPrepareAccess(&pPix->drawable, EXA_PREPARE_SRC);
     swap(pExaScr, pScreen, BitmapToRegion);
-    ret = pScreen->BitmapToRegion(pPix);
+    ret = (*pScreen->BitmapToRegion)(pPix);
     swap(pExaScr, pScreen, BitmapToRegion);
     exaFinishAccess(&pPix->drawable, EXA_PREPARE_SRC);
 
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index cf48ecd..6c677c7 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -81,7 +81,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	return;
     }
 
-    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+    pextent = RegionExtents(pClip);
     extentX1 = pextent->x1;
     extentY1 = pextent->y1;
     extentX2 = pextent->x2;
@@ -106,7 +106,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	if (fullX1 >= fullX2)
 	    continue;
 
-	nbox = REGION_NUM_RECTS (pClip);
+	nbox = RegionNumRects (pClip);
 	if (nbox == 1)
 	{
 	    (*pExaScr->info->Solid) (pPixmap,
@@ -115,7 +115,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	}
 	else
 	{
-	    pbox = REGION_RECTS(pClip);
+	    pbox = RegionRects(pClip);
 	    while(nbox--)
 	    {
 		if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
@@ -192,8 +192,8 @@ exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
     y += pDrawable->y;
 
     pClip = fbGetCompositeClip(pGC);
-    for (nbox = REGION_NUM_RECTS(pClip),
-	 pbox = REGION_RECTS(pClip);
+    for (nbox = RegionNumRects(pClip),
+	 pbox = RegionRects(pClip);
 	 nbox--;
 	 pbox++)
     {
@@ -416,15 +416,15 @@ exaHWCopyNtoN (DrawablePtr    pSrcDrawable,
 	else
 	    ordering = CT_UNSORTED;
 
-	srcregion  = RECTS_TO_REGION(pScreen, nbox, rects, ordering);
+	srcregion  = RegionFromRects(nbox, rects, ordering);
 	free(rects);
 
 	if (!pGC || !exaGCReadsDestination(pDstDrawable, pGC->planemask,
 					   pGC->fillStyle, pGC->alu,
 					   pGC->clientClipType)) {
-	    dstregion = REGION_CREATE(pScreen, NullBox, 0);
-	    REGION_COPY(pScreen, dstregion, srcregion);
-	    REGION_TRANSLATE(pScreen, dstregion, dst_off_x - dx - src_off_x,
+	    dstregion = RegionCreate(NullBox, 0);
+	    RegionCopy(dstregion, srcregion);
+	    RegionTranslate(dstregion, dst_off_x - dx - src_off_x,
 			     dst_off_y - dy - src_off_y);
 	}
     }
@@ -551,12 +551,12 @@ fallback:
 
 out:
     if (dstregion) {
-	REGION_UNINIT(pScreen, dstregion);
-	REGION_DESTROY(pScreen, dstregion);
+	RegionUninit(dstregion);
+	RegionDestroy(dstregion);
     }
     if (srcregion) {
-	REGION_UNINIT(pScreen, srcregion);
-	REGION_DESTROY(pScreen, srcregion);
+	RegionUninit(srcregion);
+	RegionDestroy(srcregion);
     }
 
     return ret;
@@ -788,13 +788,13 @@ exaPolyFillRect(DrawablePtr pDrawable,
     int		    xoff, yoff;
     int		    xorg, yorg;
     int		    n;
-    RegionPtr pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
+    RegionPtr pReg = RegionFromRects(nrect, prect, CT_UNSORTED);
 
     /* Compute intersection of rects and clip region */
-    REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
-    REGION_INTERSECT(pScreen, pReg, pClip, pReg);
+    RegionTranslate(pReg, pDrawable->x, pDrawable->y);
+    RegionIntersect(pReg, pClip, pReg);
 
-    if (!REGION_NUM_RECTS(pReg)) {
+    if (!RegionNumRects(pReg)) {
 	goto out;
     }
 
@@ -856,7 +856,7 @@ fallback:
     xorg = pDrawable->x;
     yorg = pDrawable->y;
 
-    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+    pextent = RegionExtents(pClip);
     extentX1 = pextent->x1;
     extentY1 = pextent->y1;
     extentX2 = pextent->x2;
@@ -883,7 +883,7 @@ fallback:
 
 	if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
 	    continue;
-	n = REGION_NUM_RECTS (pClip);
+	n = RegionNumRects (pClip);
 	if (n == 1)
 	{
 	    (*pExaScr->info->Solid) (pPixmap,
@@ -892,7 +892,7 @@ fallback:
 	}
 	else
 	{
-	    pbox = REGION_RECTS(pClip);
+	    pbox = RegionRects(pClip);
 	    /*
 	     * clip the rectangle to each box in the clip region
 	     * this is logically equivalent to calling Intersect(),
@@ -927,8 +927,8 @@ fallback:
     exaMarkSync(pDrawable->pScreen);
 
 out:
-    REGION_UNINIT(pScreen, pReg);
-    REGION_DESTROY(pScreen, pReg);
+    RegionUninit(pReg);
+    RegionDestroy(pReg);
 }
 
 const GCOps exaOps = {
@@ -964,14 +964,14 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+    RegionTranslate(prgnSrc, -dx, -dy);
 
-    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+    RegionInit(&rgnDst, NullBox, 0);
 
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 #ifdef COMPOSITE
     if (pPixmap->screen_x || pPixmap->screen_y)
-	REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+	RegionTranslate(&rgnDst,
 			  -pPixmap->screen_x, -pPixmap->screen_y);
 #endif
 
@@ -987,11 +987,11 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     pExaScr->fallback_flags &= ~EXA_ACCEL_COPYWINDOW;
 
 fallback:
-    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
 
     if (pExaScr->fallback_flags & EXA_FALLBACK_COPYWINDOW) {
 	pExaScr->fallback_flags &= ~EXA_FALLBACK_COPYWINDOW;
-	REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, dx, dy);
+	RegionTranslate(prgnSrc, dx, dy);
 	ExaCheckCopyWindow(pWin, ptOldOrg, prgnSrc);
     }
 }
@@ -1007,7 +1007,7 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
     Bool ret = FALSE;
 
     exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
-    REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
+    RegionTranslate(pRegion, xoff, yoff);
 
     if (pExaScr->fallback_counter || pExaPixmap->accel_blocked)
 	goto out;
@@ -1030,8 +1030,8 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
 	int nbox;
 	BoxPtr pBox;
 
-	nbox = REGION_NUM_RECTS (pRegion);
-	pBox = REGION_RECTS (pRegion);
+	nbox = RegionNumRects (pRegion);
+	pBox = RegionRects (pRegion);
 
 	while (nbox--)
 	{
@@ -1060,18 +1060,18 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
 		*(CARD8*)pExaPixmap->sys_ptr = pixel;
 	    }
 
-	    REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+	    RegionUnion(&pExaPixmap->validSys, &pExaPixmap->validSys,
 			 pRegion);
-	    REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+	    RegionUnion(&pExaPixmap->validFB, &pExaPixmap->validFB,
 			 pRegion);
-	    REGION_SUBTRACT(pScreen, pending_damage, pending_damage, pRegion);
+	    RegionSubtract(pending_damage, pending_damage, pRegion);
 	}
 
 	ret = TRUE;
     }
 
 out:
-    REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+    RegionTranslate(pRegion, -xoff, -yoff);
 
     return ret;
 }
@@ -1090,8 +1090,8 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
     ExaPixmapPrivPtr pTileExaPixmap = ExaGetPixmapPriv(pTile);
     int xoff, yoff;
     int tileWidth, tileHeight;
-    int nbox = REGION_NUM_RECTS (pRegion);
-    BoxPtr pBox = REGION_RECTS (pRegion);
+    int nbox = RegionNumRects (pRegion);
+    BoxPtr pBox = RegionRects (pRegion);
     Bool ret = FALSE;
     int i;
 
@@ -1137,7 +1137,7 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
     if ((*pExaScr->info->PrepareCopy) (pTile, pPixmap, 1, 1, alu, planemask))
     {
 	if (xoff || yoff)
-	    REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
+	    RegionTranslate(pRegion, xoff, yoff);
 
 	for (i = 0; i < nbox; i++)
 	{
@@ -1245,7 +1245,7 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
 	exaMarkSync(pDrawable->pScreen);
 
 	if (xoff || yoff)
-	    REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+	    RegionTranslate(pRegion, -xoff, -yoff);
     }
 
     return ret;
diff --git a/exa/exa_classic.c b/exa/exa_classic.c
index e1ead6c..0b0ca4e 100644
--- a/exa/exa_classic.c
+++ b/exa/exa_classic.c
@@ -131,8 +131,8 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
     box.y1 = 0;
     box.x2 = w;
     box.y2 = h;
-    REGION_INIT(pScreen, &pExaPixmap->validSys, &box, 0);
-    REGION_INIT(pScreen, &pExaPixmap->validFB, &box, 0);
+    RegionInit(&pExaPixmap->validSys, &box, 0);
+    RegionInit(&pExaPixmap->validFB, &box, 0);
 
     exaSetAccelBlock(pExaScr, pExaPixmap,
                      w, h, bpp);
@@ -237,8 +237,8 @@ exaDestroyPixmap_classic (PixmapPtr pPixmap)
 	    pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
 	    pPixmap->devKind = pExaPixmap->sys_pitch;
 	}
-	REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validSys);
-	REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
+	RegionUninit(&pExaPixmap->validSys);
+	RegionUninit(&pExaPixmap->validFB);
     }
 
     swap(pExaScr, pScreen, DestroyPixmap);
diff --git a/exa/exa_migration_classic.c b/exa/exa_migration_classic.c
index 871679f..6c49fb7 100644
--- a/exa/exa_migration_classic.c
+++ b/exa/exa_migration_classic.c
@@ -78,8 +78,8 @@ exaPixmapIsDirty (PixmapPtr pPix)
     if (!pExaPixmap->pDamage)
 	return FALSE;
 
-    return REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage)) ||
-	!REGION_EQUAL(pScreen, &pExaPixmap->validSys, &pExaPixmap->validFB);
+    return RegionNotEmpty(DamageRegion(pExaPixmap->pDamage)) ||
+	!RegionEqual(&pExaPixmap->validSys, &pExaPixmap->validFB);
 }
 
 /**
@@ -123,22 +123,22 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
 
     /* Damaged bits are valid in current copy but invalid in other one */
     if (pExaPixmap->use_gpu_copy) {
-	REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+	RegionUnion(&pExaPixmap->validFB, &pExaPixmap->validFB,
 		     damage);
-	REGION_SUBTRACT(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+	RegionSubtract(&pExaPixmap->validSys, &pExaPixmap->validSys,
 			damage);
     } else {
-	REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+	RegionUnion(&pExaPixmap->validSys, &pExaPixmap->validSys,
 		     damage);
-	REGION_SUBTRACT(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+	RegionSubtract(&pExaPixmap->validFB, &pExaPixmap->validFB,
 			damage);
     }
 
-    REGION_EMPTY(pScreen, damage);
+    RegionEmpty(damage);
 
     /* Copy bits valid in source but not in destination */
-    REGION_NULL(pScreen, &CopyReg);
-    REGION_SUBTRACT(pScreen, &CopyReg, pValidSrc, pValidDst);
+    RegionNull(&CopyReg);
+    RegionSubtract(&CopyReg, pValidSrc, pValidDst);
 
     if (migrate->as_dst) {
 	ExaScreenPriv (pPixmap->drawable.pScreen);
@@ -153,7 +153,7 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
 	    RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
 
 #if DEBUG_MIGRATE
-	    if (REGION_NIL(pending_damage)) {
+	    if (RegionNil(pending_damage)) {
 		static Bool firsttime = TRUE;
 
 		if (firsttime) {
@@ -167,23 +167,23 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
 	     * rects by filling it up to the extents of the union of the
 	     * destination valid region and the pending damage region.
 	     */
-	    if (REGION_NUM_RECTS(pValidDst) > 10) {
+	    if (RegionNumRects(pValidDst) > 10) {
 		BoxRec box;
 		BoxPtr pValidExt, pDamageExt;
 		RegionRec closure;
 
-		pValidExt = REGION_EXTENTS(pScreen, pValidDst);
-		pDamageExt = REGION_EXTENTS(pScreen, pending_damage);
+		pValidExt = RegionExtents(pValidDst);
+		pDamageExt = RegionExtents(pending_damage);
 
 		box.x1 = min(pValidExt->x1, pDamageExt->x1);
 		box.y1 = min(pValidExt->y1, pDamageExt->y1);
 		box.x2 = max(pValidExt->x2, pDamageExt->x2);
 		box.y2 = max(pValidExt->y2, pDamageExt->y2);
 
-		REGION_INIT(pScreen, &closure, &box, 0);
-		REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, &closure);
+		RegionInit(&closure, &box, 0);
+		RegionIntersect(&CopyReg, &CopyReg, &closure);
 	    } else
-		REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
+		RegionIntersect(&CopyReg, &CopyReg, pending_damage);
 	}
 
 	/* The caller may provide a region to be subtracted from the calculated
@@ -191,17 +191,17 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
 	 * contribute to the result of the operation.
 	 */
 	if (migrate->pReg)
-	    REGION_SUBTRACT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
+	    RegionSubtract(&CopyReg, &CopyReg, migrate->pReg);
     } else {
 	/* The caller may restrict the region to be migrated for source pixmaps
 	 * to what's relevant for the operation.
 	 */
 	if (migrate->pReg)
-	    REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
+	    RegionIntersect(&CopyReg, &CopyReg, migrate->pReg);
     }
 
-    pBox = REGION_RECTS(&CopyReg);
-    nbox = REGION_NUM_RECTS(&CopyReg);
+    pBox = RegionRects(&CopyReg);
+    nbox = RegionNumRects(&CopyReg);
 
     save_use_gpu_copy = pExaPixmap->use_gpu_copy;
     save_pitch = pPixmap->devKind;
@@ -252,13 +252,13 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
      * removing parts of it which are also in the destination valid region.
      * Removing anything beyond that would lead to data loss.
      */
-    if (REGION_NUM_RECTS(pValidSrc) > 20)
-	REGION_SUBTRACT(pScreen, pValidSrc, pValidSrc, pValidDst);
+    if (RegionNumRects(pValidSrc) > 20)
+	RegionSubtract(pValidSrc, pValidSrc, pValidDst);
 
     /* The copied bits are now valid in destination */
-    REGION_UNION(pScreen, pValidDst, pValidDst, &CopyReg);
+    RegionUnion(pValidDst, pValidDst, &CopyReg);
 
-    REGION_UNINIT(pScreen, &CopyReg);
+    RegionUninit(&CopyReg);
 
     if (access_prepared)
 	exaFinishAccess(&pPixmap->drawable, fallback_index);
@@ -440,7 +440,7 @@ exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area)
 
     /* Mark all FB bits as invalid, so all valid system bits get copied to FB
      * next time */
-    REGION_EMPTY(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
+    RegionEmpty(&pExaPixmap->validFB);
 }
 
 /**
@@ -531,15 +531,15 @@ exaAssertNotDirty (PixmapPtr pPixmap)
     if (exaPixmapIsPinned(pPixmap) || pExaPixmap->area == NULL)
 	return ret;
 
-    REGION_NULL(pScreen, &ValidReg);
-    REGION_INTERSECT(pScreen, &ValidReg, &pExaPixmap->validFB,
+    RegionNull(&ValidReg);
+    RegionIntersect(&ValidReg, &pExaPixmap->validFB,
 		     &pExaPixmap->validSys);
-    nbox = REGION_NUM_RECTS(&ValidReg);
+    nbox = RegionNumRects(&ValidReg);
 
     if (!nbox)
 	goto out;
 
-    pBox = REGION_RECTS(&ValidReg);
+    pBox = RegionRects(&ValidReg);
 
     dst_pitch = pExaPixmap->sys_pitch;
     src_pitch = pExaPixmap->fb_pitch;
@@ -586,7 +586,7 @@ skip:
     pPixmap->devKind = save_pitch;
 
 out:
-    REGION_UNINIT(pScreen, &ValidReg);
+    RegionUninit(&ValidReg);
     return ret;
 }
 
diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index 49e04f2..89cb137 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -180,7 +180,7 @@ exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
 
             exaSetAccelBlock(pExaScr, pExaPixmap,
                              width, height, bitsPerPixel);
-            REGION_EMPTY(pScreen, &pExaPixmap->validFB);
+            RegionEmpty(&pExaPixmap->validFB);
         }
 
 	/* Need to re-create system copy if there's also a GPU copy */
@@ -192,7 +192,7 @@ exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
 	    DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
 	    DamageDestroy(pExaPixmap->pDamage);
 	    pExaPixmap->pDamage = NULL;
-	    REGION_EMPTY(pScreen, &pExaPixmap->validSys);
+	    RegionEmpty(&pExaPixmap->validSys);
 
 	    if (pExaScr->deferred_mixed_pixmap == pPixmap)
 		pExaScr->deferred_mixed_pixmap = NULL;
diff --git a/exa/exa_render.c b/exa/exa_render.c
index b7f383f..6f2af8a 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -292,7 +292,7 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
 
     exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
 
-    REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
+    RegionTranslate(&region, dst_off_x, dst_off_y);
 
     if (pSrc->pDrawable) {
 	pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
@@ -305,7 +305,7 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
 	!exaGetPixelFromRGBA(&pixel, red, green, blue, alpha,
 			     pDst->pFormat))
     {
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	RegionUninit(&region);
 	return -1;
     }
 
@@ -320,18 +320,18 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
     }
 
     if (!exaPixmapHasGpuCopy(pDstPix)) {
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	RegionUninit(&region);
 	return 0;
     }
 
     if (!(*pExaScr->info->PrepareSolid) (pDstPix, GXcopy, 0xffffffff, pixel))
     {
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	RegionUninit(&region);
 	return -1;
     }
 
-    nbox = REGION_NUM_RECTS(&region);
-    pbox = REGION_RECTS(&region);
+    nbox = RegionNumRects(&region);
+    pbox = RegionRects(&region);
 
     while (nbox--)
     {
@@ -342,7 +342,7 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
     (*pExaScr->info->DoneSolid) (pDstPix);
     exaMarkSync(pDst->pDrawable->pScreen);
 
-    REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+    RegionUninit(&region);
     return 1;
 }
 
@@ -469,10 +469,10 @@ exaTryDriverCompositeRects(CARD8	       op,
 				       rects->width, rects->height))
 	    goto next_rect;
 
-	REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
+	RegionTranslate(&region, dst_off_x, dst_off_y);
 
-	nbox = REGION_NUM_RECTS(&region);
-	pbox = REGION_RECTS(&region);
+	nbox = RegionNumRects(&region);
+	pbox = RegionRects(&region);
 
 	xMask = xMask + mask_off_x - xDst - dst_off_x;
 	yMask = yMask + mask_off_y - yDst - dst_off_y;
@@ -494,7 +494,7 @@ exaTryDriverCompositeRects(CARD8	       op,
 	}
 
     next_rect:
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	RegionUninit(&region);
 
 	rects++;
     }
@@ -575,11 +575,11 @@ exaCompositeRects(CARD8	              op,
 	 * (see use of DamagePendingRegion in exaCopyDirty)
 	 */
 
-	REGION_INIT(pScreen, &region, &box, 1);
+	RegionInit(&region, &box, 1);
     
 	DamageRegionAppend(pDst->pDrawable, &region);
 
-	REGION_UNINIT(pScreen, &region);
+	RegionUninit(&region);
     }
     
     /************************************************************/
@@ -703,7 +703,7 @@ exaTryDriverComposite(CARD8		op,
 
     exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
 
-    REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
+    RegionTranslate(&region, dst_off_x, dst_off_y);
 
     if (pExaScr->do_migration) {
 	ExaMigrationRec pixmaps[3];
@@ -737,7 +737,7 @@ exaTryDriverComposite(CARD8		op,
     if (pSrcPix) {
 	pSrcPix = exaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
 	if (!pSrcPix) {
-	    REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	    RegionUninit(&region);
 	    return 0;
 	}
     }
@@ -746,25 +746,25 @@ exaTryDriverComposite(CARD8		op,
 	pMaskPix = exaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x,
 					  &mask_off_y);
 	if (!pMaskPix) {
-	    REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	    RegionUninit(&region);
 	    return 0;
 	}
     }
 
     if (!exaPixmapHasGpuCopy(pDstPix)) {
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	RegionUninit(&region);
 	return 0;
     }
 
     if (!(*pExaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix,
 					     pMaskPix, pDstPix))
     {
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+	RegionUninit(&region);
 	return -1;
     }
 
-    nbox = REGION_NUM_RECTS(&region);
-    pbox = REGION_RECTS(&region);
+    nbox = RegionNumRects(&region);
+    pbox = RegionRects(&region);
 
     xMask = xMask + mask_off_x - xDst - dst_off_x;
     yMask = yMask + mask_off_y - yDst - dst_off_y;
@@ -788,7 +788,7 @@ exaTryDriverComposite(CARD8		op,
     (*pExaScr->info->DoneComposite) (pDstPix);
     exaMarkSync(pDst->pDrawable->pScreen);
 
-    REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+    RegionUninit(&region);
     return 1;
 }
 
@@ -953,9 +953,9 @@ exaComposite(CARD8	op,
 		    goto done;
 
 		ret = exaHWCopyNtoN(pSrc->pDrawable, pDst->pDrawable, NULL,
-			     REGION_RECTS(&region), REGION_NUM_RECTS(&region),
+			     RegionRects(&region), RegionNumRects(&region),
 			     xSrc - xDst, ySrc - yDst, FALSE, FALSE);
-		REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+		RegionUninit(&region);
 
 		/* Reset values to their original values. */
 		xDst -= pDst->pDrawable->x;
@@ -1005,7 +1005,7 @@ exaComposite(CARD8	op,
 					 (PixmapPtr)pSrc->pDrawable,
 					 &patOrg, FB_ALLONES, GXcopy, CT_NONE);
 
-		REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+		RegionUninit(&region);
 
 		if (ret)
 		    goto done;
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 402d76d..a078cc1 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -131,10 +131,10 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst,  GCPtr pGC,
 	PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);
 
 	exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
-	REGION_INIT(pScreen, &reg, pbox, nbox);
-	REGION_TRANSLATE(pScreen, &reg, xoff + dx, yoff + dy);
+	RegionInit(&reg, pbox, nbox);
+	RegionTranslate(&reg, xoff + dx, yoff + dy);
 	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, &reg);
-	REGION_UNINIT(pScreen, &reg);
+	RegionUninit(&reg);
     } else
 	exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
 
@@ -144,10 +144,10 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst,  GCPtr pGC,
 	PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
 
 	exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
-	REGION_INIT(pScreen, &reg, pbox, nbox);
-	REGION_TRANSLATE(pScreen, &reg, xoff, yoff);
+	RegionInit(&reg, pbox, nbox);
+	RegionTranslate(&reg, xoff, yoff);
 	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, &reg);
-	REGION_UNINIT(pScreen, &reg);
+	RegionUninit(&reg);
     } else
 	exaPrepareAccess (pDst, EXA_PREPARE_DEST);
 
@@ -188,9 +188,9 @@ ExaFallbackPrepareReg(DrawablePtr pDrawable,
 	box.x2 = box.x1 + width;
 	box.y2 = box.y1 + height;
 
-	REGION_INIT(pScreen, &reg, &box, 1);
+	RegionInit(&reg, &box, 1);
 	pExaScr->prepare_access_reg(pPixmap, index, &reg);
-	REGION_UNINIT(pScreen, &reg);
+	RegionUninit(&reg);
     } else
 	exaPrepareAccess(pDrawable, index);
 }
@@ -382,9 +382,9 @@ ExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 	int xoff, yoff;
 
 	exaGetDrawableDeltas(&pWin->drawable, pPixmap, &xoff, &yoff);
-	REGION_TRANSLATE(pScreen, prgnSrc, xoff, yoff);
+	RegionTranslate(prgnSrc, xoff, yoff);
 	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, prgnSrc);
-	REGION_TRANSLATE(pScreen, prgnSrc, -xoff, -yoff);
+	RegionTranslate(prgnSrc, -xoff, -yoff);
     } else
 	exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
 
@@ -458,9 +458,9 @@ ExaSrcValidate(DrawablePtr pDrawable,
     dst = (pExaScr->srcPix == pPix) ? &pExaScr->srcReg :
 	&pExaScr->maskReg;
 
-    REGION_INIT(pScreen, &reg, &box, 1);
-    REGION_UNION(pScreen, dst, dst, &reg);
-    REGION_UNINIT(pScreen, &reg);
+    RegionInit(&reg, &box, 1);
+    RegionUnion(dst, dst, &reg);
+    RegionUninit(&reg);
 
     if (pExaScr->SavedSourceValidate) {
         swap(pExaScr, pScreen, SourceValidate);
@@ -495,30 +495,30 @@ ExaPrepareCompositeReg(ScreenPtr  pScreen,
     Bool ret;
 
 
-    REGION_NULL(pScreen, &region);
+    RegionNull(&region);
 
     if (pSrc->pDrawable) {
 	pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
-	REGION_NULL(pScreen, &pExaScr->srcReg);
+	RegionNull(&pExaScr->srcReg);
 	srcReg = &pExaScr->srcReg;
 	pExaScr->srcPix = pSrcPix;
 	if (pSrc != pDst)
-	    REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
+	    RegionTranslate(pSrc->pCompositeClip,
 			     -pSrc->pDrawable->x,
 			     -pSrc->pDrawable->y);
     }
 
     if (pMask && pMask->pDrawable) {
 	pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
-	REGION_NULL(pScreen, &pExaScr->maskReg);
+	RegionNull(&pExaScr->maskReg);
 	maskReg = &pExaScr->maskReg;
 	if (pMask != pDst && pMask != pSrc)
-	    REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
+	    RegionTranslate(pMask->pCompositeClip,
 			     -pMask->pDrawable->x,
 			     -pMask->pDrawable->y);
     }
 
-    REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
+    RegionTranslate(pDst->pCompositeClip,
 		     -pDst->pDrawable->x,
 		     -pDst->pDrawable->y);
 
@@ -531,23 +531,23 @@ ExaPrepareCompositeReg(ScreenPtr  pScreen,
 				    width, height);
     swap(pExaScr, pScreen, SourceValidate);
 
-    REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
+    RegionTranslate(pDst->pCompositeClip,
 		     pDst->pDrawable->x,
 		     pDst->pDrawable->y);
     if (pSrc->pDrawable && pSrc != pDst)
-	REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
+	RegionTranslate(pSrc->pCompositeClip,
 			 pSrc->pDrawable->x,
 			 pSrc->pDrawable->y);
     if (pMask && pMask->pDrawable && pMask != pDst && pMask != pSrc)
-	REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
+	RegionTranslate(pMask->pCompositeClip,
 			 pMask->pDrawable->x,
 			 pMask->pDrawable->y);
 
     if (!ret) {
 	if (srcReg)
-	    REGION_UNINIT(pScreen, srcReg);
+	    RegionUninit(srcReg);
 	if (maskReg)
-	    REGION_UNINIT(pScreen, maskReg);
+	    RegionUninit(maskReg);
 
 	return FALSE;
     }
@@ -577,9 +577,9 @@ ExaPrepareCompositeReg(ScreenPtr  pScreen,
 				    maskReg);
 
     if (srcReg)
-	REGION_UNINIT(pScreen, srcReg);
+	RegionUninit(srcReg);
     if (maskReg)
-	REGION_UNINIT(pScreen, maskReg);
+	RegionUninit(maskReg);
 
     pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
     if (!exaOpReadsDestination(op)) {
@@ -587,7 +587,7 @@ ExaPrepareCompositeReg(ScreenPtr  pScreen,
 	int yoff;
 
 	exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &xoff, &yoff);
-	REGION_TRANSLATE(pScreen, &region, pDst->pDrawable->x + xoff,
+	RegionTranslate(&region, pDst->pDrawable->x + xoff,
 			 pDst->pDrawable->y + yoff);
 	dstReg = &region;
     }
@@ -598,7 +598,7 @@ ExaPrepareCompositeReg(ScreenPtr  pScreen,
 				    dstReg);
     pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, dstReg);
 
-    REGION_UNINIT(pScreen, &region);
+    RegionUninit(&region);
     return TRUE;
 }
 
diff --git a/fb/fb.h b/fb/fb.h
index e2222a5..7ab4adf 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -739,7 +739,7 @@ typedef struct {
  */
 
 #define fbWindowEnabled(pWin) \
-    REGION_NOTEMPTY((pWin)->drawable.pScreen, \
+    RegionNotEmpty(\
 		    &(pWin)->drawable.pScreen->root->borderClip)
 
 #define fbDrawableEnabled(pDrawable) \
diff --git a/fb/fb24_32.c b/fb/fb24_32.c
index 1ebd598..2e600ed 100644
--- a/fb/fb24_32.c
+++ b/fb/fb24_32.c
@@ -335,8 +335,8 @@ fb24_32SetSpans (DrawablePtr	    pDrawable,
     {
 	d = dst + (ppt->y + dstYoff) * dstStride;
 	s = (CARD8 *) src;
-	n = REGION_NUM_RECTS(pClip);
-	pbox = REGION_RECTS (pClip);
+	n = RegionNumRects(pClip);
+	pbox = RegionRects (pClip);
 	while (n--)
 	{
 	    if (pbox->y1 > ppt->y)
@@ -399,8 +399,8 @@ fb24_32PutZImage (DrawablePtr	pDrawable,
     dstStride *= sizeof(FbBits);
     dst = (CARD8 *) dstBits;
 
-    for (nbox = REGION_NUM_RECTS (pClip),
-	 pbox = REGION_RECTS(pClip);
+    for (nbox = RegionNumRects (pClip),
+	 pbox = RegionRects(pClip);
 	 nbox--;
 	 pbox++)
     {
diff --git a/fb/fbarc.c b/fb/fbarc.c
index 3a8a2c5..33e44b0 100644
--- a/fb/fbarc.c
+++ b/fb/fbarc.c
@@ -102,7 +102,7 @@ fbPolyArc (DrawablePtr	pDrawable,
 		    y2 = box.y1 + (int)parcs->height + 1;
 		    box.y2 = y2;
 		    if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
-			(RECT_IN_REGION(pDrawable->pScreen, cclip, &box) == rgnIN) ) {
+			(RegionContainsRect(cclip, &box) == rgnIN) ) {
 #ifdef FB_ACCESS_WRAPPER
 			if (!wrapped) {
 			    fbPrepareAccess (pDrawable);
diff --git a/fb/fbbits.h b/fb/fbbits.h
index 44991f1..8bf1a02 100644
--- a/fb/fbbits.h
+++ b/fb/fbbits.h
@@ -670,7 +670,7 @@ POLYLINE (DrawablePtr	pDrawable,
     int		    xoff = pDrawable->x;
     int		    yoff = pDrawable->y;
     unsigned int    bias = miGetZeroLineBias(pDrawable->pScreen);
-    BoxPtr	    pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
+    BoxPtr	    pBox = RegionExtents(fbGetCompositeClip (pGC));
     
     FbBits	    *dst;
     int		    dstStride;
@@ -807,7 +807,7 @@ POLYSEGMENT (DrawablePtr    pDrawable,
     int		    xoff = pDrawable->x;
     int		    yoff = pDrawable->y;
     unsigned int    bias = miGetZeroLineBias(pDrawable->pScreen);
-    BoxPtr	    pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
+    BoxPtr	    pBox = RegionExtents(fbGetCompositeClip (pGC));
     
     FbBits	    *dst;
     int		    dstStride;
diff --git a/fb/fbfill.c b/fb/fbfill.c
index 831b1ce..801a0d0 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -185,7 +185,7 @@ fbSolidBoxClipped (DrawablePtr	pDrawable,
 
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     
-    for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); 
+    for (nbox = RegionNumRects(pClip), pbox = RegionRects(pClip);
 	 nbox--; 
 	 pbox++)
     {
diff --git a/fb/fbfillrect.c b/fb/fbfillrect.c
index 4e4edb3..7fc03f9 100644
--- a/fb/fbfillrect.c
+++ b/fb/fbfillrect.c
@@ -44,7 +44,7 @@ fbPolyFillRect(DrawablePtr  pDrawable,
     xorg = pDrawable->x;
     yorg = pDrawable->y;
     
-    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+    pextent = RegionExtents(pClip);
     extentX1 = pextent->x1;
     extentY1 = pextent->y1;
     extentX2 = pextent->x2;
@@ -71,7 +71,7 @@ fbPolyFillRect(DrawablePtr  pDrawable,
 
 	if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
 	    continue;
-	n = REGION_NUM_RECTS (pClip);
+	n = RegionNumRects (pClip);
 	if (n == 1)
 	{
 	    fbFill (pDrawable,
@@ -80,7 +80,7 @@ fbPolyFillRect(DrawablePtr  pDrawable,
 	}
 	else
 	{
-	    pbox = REGION_RECTS(pClip);
+	    pbox = RegionRects(pClip);
 	    /* 
 	     * clip the rectangle to each box in the clip region
 	     * this is logically equivalent to calling Intersect()
diff --git a/fb/fbfillsp.c b/fb/fbfillsp.c
index 5d21472..194bfc8 100644
--- a/fb/fbfillsp.c
+++ b/fb/fbfillsp.c
@@ -41,7 +41,7 @@ fbFillSpans (DrawablePtr    pDrawable,
     int		    fullX1, fullX2, fullY1;
     int		    partX1, partX2;
     
-    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+    pextent = RegionExtents(pClip);
     extentX1 = pextent->x1;
     extentY1 = pextent->y1;
     extentX2 = pextent->x2;
@@ -66,7 +66,7 @@ fbFillSpans (DrawablePtr    pDrawable,
 	if (fullX1 >= fullX2)
 	    continue;
 	
-	nbox = REGION_NUM_RECTS (pClip);
+	nbox = RegionNumRects (pClip);
 	if (nbox == 1)
 	{
 	    fbFill (pDrawable,
@@ -75,7 +75,7 @@ fbFillSpans (DrawablePtr    pDrawable,
 	}
 	else
 	{
-	    pbox = REGION_RECTS(pClip);
+	    pbox = RegionRects(pClip);
 	    while(nbox--)
 	    {
 		if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
diff --git a/fb/fbgc.c b/fb/fbgc.c
index fda391b..e3e9236 100644
--- a/fb/fbgc.c
+++ b/fb/fbgc.c
@@ -213,7 +213,7 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 	)
     {
 	miComputeCompositeClip (pGC, pDrawable);
-	pPriv->oneRect = REGION_NUM_RECTS(fbGetCompositeClip(pGC)) == 1;
+	pPriv->oneRect = RegionNumRects(fbGetCompositeClip(pGC)) == 1;
     }
     
 #ifdef FB_24_32BIT    
diff --git a/fb/fbglyph.c b/fb/fbglyph.c
index 2c19b74..44fe80f 100644
--- a/fb/fbglyph.c
+++ b/fb/fbglyph.c
@@ -39,7 +39,7 @@ fbGlyphIn (RegionPtr	pRegion,
 	   int		height)
 {
     BoxRec  box;
-    BoxPtr  pExtents = REGION_EXTENTS (dummyScreen, pRegion);
+    BoxPtr  pExtents = RegionExtents(pRegion);
 
     /*
      * Check extents by hand to avoid 16 bit overflows
@@ -56,7 +56,7 @@ fbGlyphIn (RegionPtr	pRegion,
     box.x2 = x + width;
     box.y1 = y;
     box.y2 = y + height;
-    return RECT_IN_REGION (dummyScreen, pRegion, &box) == rgnIN;
+    return RegionContainsRect(pRegion, &box) == rgnIN;
 }
 
 #ifdef FB_24BIT
diff --git a/fb/fbimage.c b/fb/fbimage.c
index 2b9ac27..da1e8bc 100644
--- a/fb/fbimage.c
+++ b/fb/fbimage.c
@@ -134,8 +134,8 @@ fbPutZImage (DrawablePtr	pDrawable,
 
     fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
-    for (nbox = REGION_NUM_RECTS (pClip),
-	 pbox = REGION_RECTS(pClip);
+    for (nbox = RegionNumRects (pClip),
+	 pbox = RegionRects(pClip);
 	 nbox--;
 	 pbox++)
     {
@@ -224,8 +224,8 @@ fbPutXYImage (DrawablePtr	pDrawable,
 	}
     }
 
-    for (nbox = REGION_NUM_RECTS (pClip),
-	 pbox = REGION_RECTS(pClip);
+    for (nbox = RegionNumRects (pClip),
+	 pbox = RegionRects(pClip);
 	 nbox--;
 	 pbox++)
     {
diff --git a/fb/fbline.c b/fb/fbline.c
index 2cee123..fa80573 100644
--- a/fb/fbline.c
+++ b/fb/fbline.c
@@ -117,7 +117,7 @@ fbPolyLine (DrawablePtr	pDrawable,
 #ifndef FBNOPIXADDR
 	if (pGC->fillStyle == FillSolid &&
 	    pGC->lineStyle == LineSolid &&
-	    REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1)
+	    RegionNumRects (fbGetCompositeClip(pGC)) == 1)
 	{
 	    switch (pDrawable->bitsPerPixel) {
 	    case 8:  line = fbPolyline8; break;
@@ -154,7 +154,7 @@ fbPolySegment (DrawablePtr  pDrawable,
 #ifndef FBNOPIXADDR
 	if (pGC->fillStyle == FillSolid &&
 	    pGC->lineStyle == LineSolid &&
-	    REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1)
+	    RegionNumRects (fbGetCompositeClip(pGC)) == 1)
 	{
 	    switch (pDrawable->bitsPerPixel) {
 	    case 8:  seg = fbPolySegment8; break;
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 3eb1b03..392e27f 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -75,7 +75,7 @@ fbOverlayCreateWindow(WindowPtr pWin)
 	     */
 	    if (!pWin->parent)
 	    {
-		REGION_EMPTY (pWin->drawable.pScreen,
+		RegionEmpty(
 			      &pScrPriv->layer[i].u.run.region);
 	    }
 	    return TRUE;
@@ -93,7 +93,7 @@ fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen)
     for (i = 0; i < pScrPriv->nlayers; i++)
     {
 	(*pScreen->DestroyPixmap)(pScrPriv->layer[i].u.run.pixmap);
-	REGION_UNINIT (pScreen, &pScrPriv->layer[i].u.run.region);
+	RegionUninit(&pScrPriv->layer[i].u.run.region);
     }
     return TRUE;
 }
@@ -147,7 +147,7 @@ fbOverlayCreateScreenResources(ScreenPtr pScreen)
 					    pbits))
 	    return FALSE;
 	pScrPriv->layer[i].u.run.pixmap = pPixmap;
-	REGION_INIT(pScreen, &pScrPriv->layer[i].u.run.region, &box, 0);
+	RegionInit(&pScrPriv->layer[i].u.run.region, &box, 0);
     }
     pScreen->devPrivate = pScrPriv->layer[0].u.run.pixmap;
     return TRUE;
@@ -175,24 +175,24 @@ fbOverlayUpdateLayerRegion (ScreenPtr	pScreen,
     int			i;
     RegionRec		rgnNew;
     
-    if (!prgn || !REGION_NOTEMPTY(pScreen, prgn))
+    if (!prgn || !RegionNotEmpty(prgn))
 	return;
     for (i = 0; i < pScrPriv->nlayers; i++)
     {
 	if (i == layer)
 	{
 	    /* add new piece to this fb */
-	    REGION_UNION (pScreen,
+	    RegionUnion(
 			  &pScrPriv->layer[i].u.run.region,
 			  &pScrPriv->layer[i].u.run.region,
 			  prgn);
 	}
-	else if (REGION_NOTEMPTY (pScreen, 
+	else if (RegionNotEmpty(
 				  &pScrPriv->layer[i].u.run.region))
 	{
 	    /* paint new piece with chroma key */
-	    REGION_NULL (pScreen, &rgnNew);
-	    REGION_INTERSECT (pScreen,
+	    RegionNull(&rgnNew);
+	    RegionIntersect(
 			      &rgnNew, 
 			      prgn, 
 			      &pScrPriv->layer[i].u.run.region);
@@ -200,9 +200,9 @@ fbOverlayUpdateLayerRegion (ScreenPtr	pScreen,
 				   &rgnNew,
 				   pScrPriv->layer[i].key,
 				   i);
-	    REGION_UNINIT(pScreen, &rgnNew);
+	    RegionUninit(&rgnNew);
 	    /* remove piece from other fbs */
-	    REGION_SUBTRACT (pScreen,
+	    RegionSubtract(
 			     &pScrPriv->layer[i].u.run.region,
 			     &pScrPriv->layer[i].u.run.region,
 			     prgn);
@@ -232,21 +232,21 @@ fbOverlayCopyWindow(WindowPtr	pWin,
     /*
      * Clip to existing bits
      */
-    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
-    REGION_NULL (pScreen, &rgnDst);
-    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
-    REGION_TRANSLATE(pScreen, &rgnDst, dx, dy);
+    RegionTranslate(prgnSrc, -dx, -dy);
+    RegionNull(&rgnDst);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+    RegionTranslate(&rgnDst, dx, dy);
     /*
      * Compute the portion of each fb affected by this copy
      */
     for (i = 0; i < pScrPriv->nlayers; i++)
     {
-	REGION_NULL (pScreen, &layerRgn[i]);
-	REGION_INTERSECT(pScreen, &layerRgn[i], &rgnDst,
+	RegionNull(&layerRgn[i]);
+	RegionIntersect(&layerRgn[i], &rgnDst,
 			 &pScrPriv->layer[i].u.run.region);
-	if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+	if (RegionNotEmpty(&layerRgn[i]))
 	{
-	    REGION_TRANSLATE(pScreen, &layerRgn[i], -dx, -dy);
+	    RegionTranslate(&layerRgn[i], -dx, -dy);
 	    pPixmap = pScrPriv->layer[i].u.run.pixmap;
 	    miCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
 			  0,
@@ -259,12 +259,12 @@ fbOverlayCopyWindow(WindowPtr	pWin,
      */
     for (i = 0; i < pScrPriv->nlayers; i++)
     {
-	if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+	if (RegionNotEmpty(&layerRgn[i]))
 	    fbOverlayUpdateLayerRegion (pScreen, i, &layerRgn[i]);
 
-	REGION_UNINIT(pScreen, &layerRgn[i]);
+	RegionUninit(&layerRgn[i]);
     }
-    REGION_UNINIT(pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
 }   
 
 void
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 896d33e..26cdc0d 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -77,8 +77,8 @@ fbWalkCompositeRegion (CARD8 op,
 				   xMask, yMask, xDst, yDst, width, height))
         return;
     
-    n = REGION_NUM_RECTS (&region);
-    pbox = REGION_RECTS (&region);
+    n = RegionNumRects (&region);
+    pbox = RegionRects (&region);
     while (n--)
     {
 	h = pbox->y2 - pbox->y1;
@@ -138,7 +138,7 @@ fbWalkCompositeRegion (CARD8 op,
 	}
 	pbox++;
     }
-    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+    RegionUninit(&region);
 }
 
 void
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index cbaab33..625ce71 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -116,7 +116,7 @@ if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&			\
     if ((reg)->data->numRects == (reg)->data->size)		\
     {								\
 	RegionRectAlloc(reg, 1);					\
-	fr = REGION_BOXPTR(reg);				\
+	fr = RegionBoxptr(reg);				\
 	r = fr + (reg)->data->numRects;				\
     }								\
     r->x1 = (rx1);						\
@@ -153,10 +153,10 @@ fbPixmapToRegion(PixmapPtr pPix)
     FbBits		*pwLine;
     int			nWidth;
     
-    pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
+    pReg = RegionCreate(NULL, 1);
     if(!pReg)
 	return NullRegion;
-    FirstRect = REGION_BOXPTR(pReg);
+    FirstRect = RegionBoxptr(pReg);
     rects = FirstRect;
 
     fbPrepareAccess(&pPix->drawable);
@@ -304,8 +304,8 @@ fbPixmapToRegion(PixmapPtr pPix)
 	pReg->extents.x1 = pReg->extents.x2 = 0;
     else
     {
-	pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
-	pReg->extents.y2 = REGION_END(pReg)->y2;
+	pReg->extents.y1 = RegionBoxptr(pReg)->y1;
+	pReg->extents.y2 = RegionEnd(pReg)->y2;
 	if (pReg->data->numRects == 1)
 	{
 	    free(pReg->data);
diff --git a/fb/fbpoint.c b/fb/fbpoint.c
index c0ea8ba..f260a69 100644
--- a/fb/fbpoint.c
+++ b/fb/fbpoint.c
@@ -154,7 +154,7 @@ fbPolyPoint (DrawablePtr    pDrawable,
     case 32:    dots = fbDots32; break;
     }
 #endif
-    for (nBox = REGION_NUM_RECTS (pClip), pBox = REGION_RECTS (pClip);
+    for (nBox = RegionNumRects (pClip), pBox = RegionRects (pClip);
 	 nBox--; pBox++)
 	(*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, 
 		 pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor);
diff --git a/fb/fbpush.c b/fb/fbpush.c
index 891572f..9d82718 100644
--- a/fb/fbpush.c
+++ b/fb/fbpush.c
@@ -190,8 +190,8 @@ fbPushImage (DrawablePtr    pDrawable,
     BoxPtr	pbox;
     int		x1, y1, x2, y2;
     
-    for (nbox = REGION_NUM_RECTS (pClip),
-	 pbox = REGION_RECTS(pClip);
+    for (nbox = RegionNumRects (pClip),
+	 pbox = RegionRects(pClip);
 	 nbox--;
 	 pbox++)
     {
diff --git a/fb/fbseg.c b/fb/fbseg.c
index 999be1c..7cc38a2 100644
--- a/fb/fbseg.c
+++ b/fb/fbseg.c
@@ -624,8 +624,8 @@ fbSegment (DrawablePtr	pDrawable,
     unsigned int oc1;	/* outcode of point 1 */
     unsigned int oc2;	/* outcode of point 2 */
 
-    nBox = REGION_NUM_RECTS (pClip);
-    pBox = REGION_RECTS (pClip);
+    nBox = RegionNumRects (pClip);
+    pBox = RegionRects (pClip);
     
     bres = fbSelectBres (pDrawable, pGC);
     
diff --git a/fb/fbsetsp.c b/fb/fbsetsp.c
index 227ba4c..61dc4dc 100644
--- a/fb/fbsetsp.c
+++ b/fb/fbsetsp.c
@@ -60,8 +60,8 @@ fbSetSpans (DrawablePtr	    pDrawable,
 	xoff = (int) (((long) src) & (FB_MASK >> 3));
 	s = (FbBits *) (src - xoff);
 	xoff <<= 3;
-	n = REGION_NUM_RECTS(pClip);
-	pbox = REGION_RECTS (pClip);
+	n = RegionNumRects(pClip);
+	pbox = RegionRects (pClip);
 	while (n--)
 	{
 	    if (pbox->y1 > ppt->y)
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 46c0334..bb0384d 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -128,15 +128,15 @@ fbCopyWindow(WindowPtr	    pWin,
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+    RegionTranslate(prgnSrc, -dx, -dy);
 
-    REGION_NULL (pWin->drawable.pScreen, &rgnDst);
+    RegionNull(&rgnDst);
     
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
 #ifdef COMPOSITE
     if (pPixmap->screen_x || pPixmap->screen_y)
-	REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, 
+	RegionTranslate(&rgnDst,
 			  -pPixmap->screen_x, -pPixmap->screen_y);
 #endif
 
@@ -144,7 +144,7 @@ fbCopyWindow(WindowPtr	    pWin,
 		  0,
 		  &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
     
-    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
     fbValidateDrawable (&pWin->drawable);
 }
 
@@ -211,8 +211,8 @@ fbFillRegionSolid (DrawablePtr	pDrawable,
     FbStride	dstStride;
     int		dstBpp;
     int		dstXoff, dstYoff;
-    int		n = REGION_NUM_RECTS(pRegion);
-    BoxPtr	pbox = REGION_RECTS(pRegion);
+    int		n = RegionNumRects(pRegion);
+    BoxPtr	pbox = RegionRects(pRegion);
 
 #ifndef FB_ACCESS_WRAPPER
     int try_mmx = 0;
diff --git a/fix-patch-whitespace b/fix-patch-whitespace
new file mode 100755
index 0000000..2d06d8e
--- /dev/null
+++ b/fix-patch-whitespace
@@ -0,0 +1,4 @@
+#!/bin/sh
+git diff --check |
+sed -n 's!^\([^:]*\):\([^:]*\):.*!sed -i "\2 s/[ \t]*$//; \2 s/ *\t/\t/g" \1!p' |
+sh
diff --git a/fix-region b/fix-region
new file mode 100755
index 0000000..ef8eb42
--- /dev/null
+++ b/fix-region
@@ -0,0 +1,38 @@
+#!/bin/sh
+sed -i \
+    -e 's/REGION_NIL\b/RegionNil/g' \
+    -e 's/REGION_NAR\b/RegionNar/g' \
+    -e 's/REGION_NUM_RECTS\b/RegionNumRects/g' \
+    -e 's/REGION_SIZE\b/RegionSize/g' \
+    -e 's/REGION_RECTS\b/RegionRects/g' \
+    -e 's/REGION_BOXPTR\b/RegionBoxptr/g' \
+    -e 's/REGION_BOX\b/RegionBox/g' \
+    -e 's/REGION_TOP\b/RegionTop/g' \
+    -e 's/REGION_END\b/RegionEnd/g' \
+    -e 's/REGION_SZOF\b/RegionSizeof/g' \
+    -e 's/REGION_CREATE *([^,]*, */RegionCreate(/g' \
+    -e 's/REGION_COPY *([^,]*, */RegionCopy(/g' \
+    -e 's/REGION_DESTROY *([^,]*, */RegionDestroy(/g' \
+    -e 's/REGION_INTERSECT *([^,]*, */RegionIntersect(/g' \
+    -e 's/REGION_UNION *([^,]*, */RegionUnion(/g' \
+    -e 's/REGION_SUBTRACT *([^,]*, */RegionSubtract(/g' \
+    -e 's/REGION_INVERSE *([^,]*, */RegionInverse(/g' \
+    -e 's/REGION_TRANSLATE *([^,]*, */RegionTranslate(/g' \
+    -e 's/RECT_IN_REGION *([^,]*, */RegionContainsRect(/g' \
+    -e 's/POINT_IN_REGION *([^,]*, */RegionContainsPoint(/g' \
+    -e 's/REGION_EQUAL *([^,]*, */RegionEqual(/g' \
+    -e 's/REGION_APPEND *([^,]*, */RegionAppend(/g' \
+    -e 's/REGION_VALIDATE *([^,]*, */RegionValidate(/g' \
+    -e 's/BITMAP_TO_REGION\b/BitmapToRegion/g' \
+    -e 's/RECTS_TO_REGION *([^,]*, */RegionFromRects(/g' \
+    -e 's/REGION_BREAK *([^,]*, */RegionBreak(/g' \
+    -e 's/REGION_INIT *([^,]*, */RegionInit(/g' \
+    -e 's/REGION_UNINIT *([^,]*, */RegionUninit(/g' \
+    -e 's/REGION_RESET *([^,]*, */RegionReset(/g' \
+    -e 's/REGION_NOTEMPTY *([^,]*, */RegionNotEmpty(/g' \
+    -e 's/REGION_BROKEN *([^,]*, */RegionBroken(/g' \
+    -e 's/REGION_EMPTY *([^,]*, */RegionEmpty(/g' \
+    -e 's/REGION_EXTENTS *([^,]*, */RegionExtents(/g' \
+    -e 's/REGION_NULL *([^,]*, */RegionNull(/g' \
+    -e 's/REGION_NULL$/RegionNull/g' \
+    "$@"
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 131efcf..32b35db 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -468,7 +468,7 @@ nooverride:
 	pRegion = NULL;
     } else {
 	pRegion = DamageRegion(driDraw->pDamage);
-	if (REGION_NIL(pRegion))
+	if (RegionNil(pRegion))
 	    return Success;
     }
 
@@ -531,8 +531,8 @@ nooverride:
         int i, numRects;
 	BoxPtr p;
 
-	numRects = REGION_NUM_RECTS (pRegion);
-	p = REGION_RECTS (pRegion);
+	numRects = RegionNumRects (pRegion);
+	p = RegionRects (pRegion);
 
 	CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, 0) );
 	CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, 0) );
@@ -832,12 +832,12 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
 
     __glXenterServer(GL_FALSE);
 
-    REGION_INIT(pDraw->pScreen, &region, (BoxPtr) rects, num_rects);
-    REGION_TRANSLATE(pScreen, &region, pDraw->x, pDraw->y);
+    RegionInit(&region, (BoxPtr) rects, num_rects);
+    RegionTranslate(&region, pDraw->x, pDraw->y);
     DamageRegionAppend(pDraw, &region);
     /* This is wrong, this needs a seperate function. */
     DamageRegionProcessPending(pDraw);
-    REGION_UNINIT(pDraw->pScreen, &region);
+    RegionUninit(&region);
 
     __glXleaveServer(GL_FALSE);
 }
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index b971102..177c73c 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -122,7 +122,7 @@ __glXDRIdrawableCopySubBuffer(__GLXdrawable *drawable,
     box.y1 = private->height - y - h;
     box.x2 = x + w;
     box.y2 = private->height - y;
-    REGION_INIT(drawable->pDraw->pScreen, &region, &box, 0);
+    RegionInit(&region, &box, 0);
 
     DRI2CopyRegion(drawable->pDraw, &region,
 		   DRI2BufferFrontLeft, DRI2BufferBackLeft);
@@ -139,7 +139,7 @@ __glXDRIdrawableWaitX(__GLXdrawable *drawable)
     box.y1 = 0;
     box.x2 = private->width;
     box.y2 = private->height;
-    REGION_INIT(drawable->pDraw->pScreen, &region, &box, 0);
+    RegionInit(&region, &box, 0);
 
     DRI2CopyRegion(drawable->pDraw, &region,
 		   DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
@@ -156,7 +156,7 @@ __glXDRIdrawableWaitGL(__GLXdrawable *drawable)
     box.y1 = 0;
     box.x2 = private->width;
     box.y2 = private->height;
-    REGION_INIT(drawable->pDraw->pScreen, &region, &box, 0);
+    RegionInit(&region, &box, 0);
 
     DRI2CopyRegion(drawable->pDraw, &region,
 		   DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 5945a5e..0092835 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -350,7 +350,7 @@ void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
 	 * clipList to be broken since it will be recalculated in
 	 * ValidateTree()
 	 */
-	REGION_BREAK(pScreen, &pRoot->clipList);
+	RegionBreak(&pRoot->clipList);
     } else {
 	/* Otherwise, we just set it directly since there are no
 	 * windows visible on this screen
@@ -994,7 +994,7 @@ static void dmxForceExposures(int idx)
 	 * clipList to be broken since it will be recalculated in
 	 * ValidateTree()
 	 */
-	REGION_BREAK(pScreen, &pRoot->clipList);
+	RegionBreak(&pRoot->clipList);
 	pScreen->ValidateTree(pRoot, NULL, VTBroken);
 	pScreen->HandleExposures(pRoot);
 	if (pScreen->PostValidateTree)
diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c
index a761ea8..3e75de7 100644
--- a/hw/dmx/dmxgc.c
+++ b/hw/dmx/dmxgc.c
@@ -363,9 +363,9 @@ void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
 
     case CT_REGION:
 	if (dmxScreen->beDisplay) {
-	    nRects = REGION_NUM_RECTS((RegionPtr)pGC->clientClip);
+	    nRects = RegionNumRects((RegionPtr)pGC->clientClip);
 	    pRects = malloc(nRects * sizeof(*pRects));
-	    pBox   = REGION_RECTS((RegionPtr)pGC->clientClip);
+	    pBox   = RegionRects((RegionPtr)pGC->clientClip);
 
 	    for (i = 0; i < nRects; i++) {
 		pRects[i].x      = pBox[i].x1;
diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c
index 267a306..589c637 100644
--- a/hw/dmx/dmxgcops.c
+++ b/hw/dmx/dmxgcops.c
@@ -127,16 +127,16 @@ void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
 	    box.y1 = y;
 	    box.x2 = x + w;
 	    box.y2 = y + h;
-	    pSubImages = REGION_CREATE(pGC->pScreen, &box, 1);
+	    pSubImages = RegionCreate(&box, 1);
 
-	    pClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
-	    REGION_COPY(pGC->pScreen, pClip, pGC->pCompositeClip);
-	    REGION_TRANSLATE(pGC->pScreen, pClip,
+	    pClip = RegionCreate(NullBox, 1);
+	    RegionCopy(pClip, pGC->pCompositeClip);
+	    RegionTranslate(pClip,
 			     -pDrawable->x, -pDrawable->y);
-	    REGION_INTERSECT(pGC->pScreen, pSubImages, pSubImages, pClip);
+	    RegionIntersect(pSubImages, pSubImages, pClip);
 
-	    nBox = REGION_NUM_RECTS(pSubImages);
-	    pBox = REGION_RECTS(pSubImages);
+	    nBox = RegionNumRects(pSubImages);
+	    pBox = RegionRects(pSubImages);
 
 	    while (nBox--) {
 		XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img,
@@ -148,8 +148,8 @@ void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
 			  pBox->y2 - pBox->y1);
 		pBox++;
 	    }
-            REGION_DESTROY(pGC->pScreen, pClip);
-            REGION_DESTROY(pGC->pScreen, pSubImages);
+            RegionDestroy(pClip);
+            RegionDestroy(pSubImages);
 	} else {
 	    XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc,
 		      img, 0, 0, x, y, w, h);
diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c
index 0544c88..1642145 100644
--- a/hw/dmx/dmxpict.c
+++ b/hw/dmx/dmxpict.c
@@ -871,8 +871,8 @@ int dmxChangePictureClip(PicturePtr pPicture, int clipType,
 				       pPictPriv->pict, 0, 0, None);
 	} else if (pPicture->clientClip) {
 	    RegionPtr   pClip = pPicture->clientClip;
-	    BoxPtr      pBox  = REGION_RECTS(pClip);
-	    int         nBox  = REGION_NUM_RECTS(pClip);
+	    BoxPtr      pBox  = RegionRects(pClip);
+	    int         nBox  = RegionNumRects(pClip);
 	    XRectangle *pRects;
 	    XRectangle *pRect;
 	    int         nRects;
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index c8b064b..a64cbd0 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -201,7 +201,7 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap)
     Bool           overlap;
   
     if (!dmxScreen->beDisplay) {
-	pReg = REGION_CREATE(pScreen, NullBox, 1);
+	pReg = RegionCreate(NullBox, 1);
 	return pReg;
     }
 
@@ -209,8 +209,8 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap)
 		       pPixmap->drawable.width, pPixmap->drawable.height,
 		       1, XYPixmap);
 
-    pReg = REGION_CREATE(pScreen, NullBox, 1);
-    pTmpReg = REGION_CREATE(pScreen, NullBox, 1);
+    pReg = RegionCreate(NullBox, 1);
+    pTmpReg = RegionCreate(NullBox, 1);
     if(!pReg || !pTmpReg) {
 	XDestroyImage(ximage);
 	return NullRegion;
@@ -229,8 +229,8 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap)
 		} else if (currentPixel == 0L) {
 		    /* right edge */
 		    Box.x2 = x;
-		    REGION_RESET(pScreen, pTmpReg, &Box);
-		    REGION_APPEND(pScreen, pReg, pTmpReg);
+		    RegionReset(pTmpReg, &Box);
+		    RegionAppend(pReg, pTmpReg);
 		}
 		previousPixel = currentPixel;
 	    }
@@ -238,15 +238,15 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap)
 	if (previousPixel != 0L) {
 	    /* right edge because of the end of pixmap */
 	    Box.x2 = pPixmap->drawable.width;
-	    REGION_RESET(pScreen, pTmpReg, &Box);
-	    REGION_APPEND(pScreen, pReg, pTmpReg);
+	    RegionReset(pTmpReg, &Box);
+	    RegionAppend(pReg, pTmpReg);
 	}
     }
   
-    REGION_DESTROY(pScreen, pTmpReg);
+    RegionDestroy(pTmpReg);
     XDestroyImage(ximage);
 
-    REGION_VALIDATE(pScreen, pReg, &overlap);
+    RegionValidate(pReg, &overlap);
 
     dmxSync(dmxScreen, FALSE);
     return(pReg);
diff --git a/hw/dmx/dmxshadow.c b/hw/dmx/dmxshadow.c
index 461fd08..a62eb5c 100644
--- a/hw/dmx/dmxshadow.c
+++ b/hw/dmx/dmxshadow.c
@@ -47,8 +47,8 @@
 void dmxShadowUpdateProc(ScreenPtr pScreen, shadowBufPtr pBuf)
 {
     RegionPtr      damage = &pBuf->damage;
-    int            nbox = REGION_NUM_RECTS(damage);
-    BoxPtr         pbox = REGION_RECTS(damage);
+    int            nbox = RegionNumRects(damage);
+    BoxPtr         pbox = RegionRects(damage);
     DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
 
     if (!dmxScreen->beDisplay)
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index 5b0baff..28212a3 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -940,8 +940,8 @@ static void dmxDoSetShape(WindowPtr pWindow)
 
     /* First, set the bounding shape */
     if (wBoundingShape(pWindow)) {
-	pBox = REGION_RECTS(wBoundingShape(pWindow));
-	nRect = nBox = REGION_NUM_RECTS(wBoundingShape(pWindow));
+	pBox = RegionRects(wBoundingShape(pWindow));
+	nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
 	pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
 	while (nBox--) {
 	    pRect->x      = pBox->x1;
@@ -963,8 +963,8 @@ static void dmxDoSetShape(WindowPtr pWindow)
 
     /* Next, set the clip shape */
     if (wClipShape(pWindow)) {
-	pBox = REGION_RECTS(wClipShape(pWindow));
-	nRect = nBox = REGION_NUM_RECTS(wClipShape(pWindow));
+	pBox = RegionRects(wClipShape(pWindow));
+	nRect = nBox = RegionNumRects(wClipShape(pWindow));
 	pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
 	while (nBox--) {
 	    pRect->x      = pBox->x1;
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index 297166e..80df064 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -226,7 +226,7 @@ static void dmxConsoleDrawWindows(pointer private)
                        pChild->drawable.height,
                        pChild->visibility,
                        pChild->overrideRedirect,
-                       REGION_NUM_RECTS(&pChild->clipList));
+                       RegionNumRects(&pChild->clipList));
 #endif
                 rect.x      = scalex(priv, pChild->drawable.x + pScreen->x);
                 rect.y      = scaley(priv, pChild->drawable.y + pScreen->y);
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index b968516..e0cb956 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -343,13 +343,13 @@ ephyrInternalDamageRedisplay (ScreenPtr pScreen)
 
   pRegion = DamageRegion (scrpriv->pDamage);
 
-  if (REGION_NOTEMPTY (pScreen, pRegion))
+  if (RegionNotEmpty(pRegion))
     {
       int           nbox;
       BoxPtr        pbox;
 
-      nbox = REGION_NUM_RECTS (pRegion);
-      pbox = REGION_RECTS (pRegion);
+      nbox = RegionNumRects (pRegion);
+      pbox = RegionRects (pRegion);
 
       while (nbox--)
         {
@@ -897,10 +897,10 @@ ephyrExposePairedWindow (int a_remote)
 	return;
     }
     screen = pair->local->drawable.pScreen;
-    REGION_NULL (screen, &reg);
-    REGION_COPY (screen, &reg, &pair->local->clipList);
+    RegionNull(&reg);
+    RegionCopy(&reg, &pair->local->clipList);
     screen->WindowExposures (pair->local, &reg, NullRegion);
-    REGION_UNINIT (screen, &reg);
+    RegionUninit(&reg);
 }
 #endif /* XF86DRI */
 
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index 55cc0f1..23c2032 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -418,11 +418,11 @@ ephyrDRIClipNotify (WindowPtr a_win,
         EPHYR_LOG_ERROR ("failed to get window pair\n") ;
         goto out ;
     }
-    rects = calloc(REGION_NUM_RECTS (&a_win->clipList),
+    rects = calloc(RegionNumRects (&a_win->clipList),
                      sizeof (EphyrRect)) ;
-    for (i=0; i < REGION_NUM_RECTS (&a_win->clipList); i++) {
+    for (i=0; i < RegionNumRects (&a_win->clipList); i++) {
         memmove (&rects[i],
-                 &REGION_RECTS (&a_win->clipList)[i],
+                 &RegionRects (&a_win->clipList)[i],
                  sizeof (EphyrRect)) ;
         rects[i].x1 -= a_win->drawable.x;
         rects[i].x2 -= a_win->drawable.x;
@@ -436,7 +436,7 @@ ephyrDRIClipNotify (WindowPtr a_win,
     is_ok = hostx_set_window_bounding_rectangles
                                 (pair->remote,
                                  rects,
-                                 REGION_NUM_RECTS (&a_win->clipList)) ;
+                                 RegionNumRects (&a_win->clipList)) ;
     is_ok = TRUE ;
 
 out:
@@ -1168,12 +1168,12 @@ ProcXF86DRIGetDrawableInfo (register ClientPtr client)
         return BadMatch ;
     }
     EPHYR_LOG ("clip list of xephyr gl drawable:\n") ;
-    for (i=0; i < REGION_NUM_RECTS (&window->clipList); i++) {
+    for (i=0; i < RegionNumRects (&window->clipList); i++) {
         EPHYR_LOG ("x1:%d, y1:%d, x2:%d, y2:%d\n",
-                   REGION_RECTS (&window->clipList)[i].x1,
-                   REGION_RECTS (&window->clipList)[i].y1,
-                   REGION_RECTS (&window->clipList)[i].x2,
-                   REGION_RECTS (&window->clipList)[i].y2) ;
+                   RegionRects (&window->clipList)[i].x1,
+                   RegionRects (&window->clipList)[i].y1,
+                   RegionRects (&window->clipList)[i].x2,
+                   RegionRects (&window->clipList)[i].y2) ;
     }
 
     if (!ephyrDRIGetDrawableInfo (stuff->screen,
diff --git a/hw/kdrive/ephyr/ephyrvideo.c b/hw/kdrive/ephyr/ephyrvideo.c
index 65127ce..69a89ae 100644
--- a/hw/kdrive/ephyr/ephyrvideo.c
+++ b/hw/kdrive/ephyr/ephyrvideo.c
@@ -946,8 +946,8 @@ ephyrPutImage (KdScreenInfo *a_info,
                               a_drw_x, a_drw_y, a_drw_w, a_drw_h,
                               a_src_x, a_src_y, a_src_w, a_src_h,
                               a_width, a_height, a_buf,
-                              (EphyrHostBox*)REGION_RECTS (a_clipping_region),
-                              REGION_NUM_RECTS (a_clipping_region))) {
+                              (EphyrHostBox*)RegionRects (a_clipping_region),
+                              RegionNumRects (a_clipping_region))) {
         EPHYR_LOG_ERROR ("EphyrHostXVPutImage() failed\n") ;
         goto out ;
     }
@@ -1025,8 +1025,8 @@ ephyrReputImage (KdScreenInfo *a_info,
                               port_priv->src_w, port_priv->src_h,
                               port_priv->image_width, port_priv->image_height,
                               port_priv->image_buf,
-                              (EphyrHostBox*)REGION_RECTS (a_clipping_region),
-                              REGION_NUM_RECTS (a_clipping_region))) {
+                              (EphyrHostBox*)RegionRects (a_clipping_region),
+                              RegionNumRects (a_clipping_region))) {
         EPHYR_LOG_ERROR ("ephyrHostXVPutImage() failed\n") ;
         goto out ;
     }
@@ -1064,7 +1064,7 @@ ephyrPutVideo (KdScreenInfo *a_info,
     dst_box.y2 = a_drw_y + a_drw_h;
 
     if (!DoSimpleClip (&dst_box,
-                       REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+                       RegionExtents(a_clipping_region),
                        &clipped_area)) {
         EPHYR_LOG_ERROR ("failed to simple clip\n") ;
         goto out ;
@@ -1115,7 +1115,7 @@ ephyrGetVideo (KdScreenInfo *a_info,
     dst_box.y2 = a_drw_y + a_drw_h;
 
     if (!DoSimpleClip (&dst_box,
-                       REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+                       RegionExtents(a_clipping_region),
                        &clipped_area)) {
         EPHYR_LOG_ERROR ("failed to simple clip\n") ;
         goto out ;
@@ -1166,7 +1166,7 @@ ephyrPutStill (KdScreenInfo *a_info,
     dst_box.y2 = a_drw_y + a_drw_h;
 
     if (!DoSimpleClip (&dst_box,
-                       REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+                       RegionExtents(a_clipping_region),
                        &clipped_area)) {
         EPHYR_LOG_ERROR ("failed to simple clip\n") ;
         goto out ;
@@ -1217,7 +1217,7 @@ ephyrGetStill (KdScreenInfo *a_info,
     dst_box.y2 = a_drw_y + a_drw_h;
 
     if (!DoSimpleClip (&dst_box,
-                       REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+                       RegionExtents(a_clipping_region),
                        &clipped_area)) {
         EPHYR_LOG_ERROR ("failed to simple clip\n") ;
         goto out ;
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 7993f9b..27596e4 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -121,8 +121,8 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable)
 	    {
 		RegionPtr	borderVisible;
 
-		borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
+		borderVisible = RegionCreate(NullBox, 1);
+		RegionSubtract(borderVisible,
 				&pWin->borderClip, &pWin->winSize);
 		pWin->valdata->before.borderVisible = borderVisible;
 	    }
@@ -138,15 +138,15 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable)
 	box.y2 = pScreen->height;
 	pWin->drawable.width = pScreen->width;
 	pWin->drawable.height = pScreen->height;
-	REGION_INIT (pScreen, &pWin->winSize, &box, 1);
-	REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
-	REGION_RESET(pScreen, &pWin->borderClip, &box);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+	RegionInit(&pWin->winSize, &box, 1);
+	RegionInit(&pWin->borderSize, &box, 1);
+	RegionReset(&pWin->borderClip, &box);
+	RegionBreak(&pWin->clipList);
     }
     else
     {
-	REGION_EMPTY(pScreen, &pWin->borderClip);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+	RegionEmpty(&pWin->borderClip);
+	RegionBreak(&pWin->clipList);
     }
 
     ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
@@ -836,8 +836,8 @@ KdCreateWindow (WindowPtr pWin)
 
 	if (!pScreenPriv->enabled)
 	{
-	    REGION_EMPTY (pWin->drawable.pScreen, &pWin->borderClip);
-	    REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+	    RegionEmpty(&pWin->borderClip);
+	    RegionBreak(&pWin->clipList);
 	}
     }
 #endif
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index c81d7da..99ab2d8 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -268,9 +268,9 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
           pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
 	  if(pPriv) {
 	     if(pPriv->clientClip)
-		REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+		RegionDestroy(pPriv->clientClip);
              if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-		REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+		RegionDestroy(pPriv->pCompositeClip);
 	     free(pPriv);
 	  }
       }
@@ -607,18 +607,18 @@ KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
 	return;
    }
 
-   pCompositeClip = REGION_CREATE(pWin->pScreen, NullBox, 1);
-   REGION_COPY(pWin->pScreen, pCompositeClip, portPriv->clientClip);
-   REGION_TRANSLATE(pWin->pScreen, pCompositeClip,
+   pCompositeClip = RegionCreate(NullBox, 1);
+   RegionCopy(pCompositeClip, portPriv->clientClip);
+   RegionTranslate(pCompositeClip,
 			portPriv->pDraw->x + portPriv->clipOrg.x,
 			portPriv->pDraw->y + portPriv->clipOrg.y);
-   REGION_INTERSECT(pWin->pScreen, pCompositeClip, pregWin, pCompositeClip);
+   RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
 
    portPriv->pCompositeClip = pCompositeClip;
    portPriv->FreeCompositeClip = TRUE;
 
    if(freeCompClip) {
-   	REGION_DESTROY(pWin->pScreen, pregWin);
+	RegionDestroy(pregWin);
    }
 }
 
@@ -633,17 +633,17 @@ KdXVCopyClip(
     /* copy the new clip if it exists */
     if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
 	if(!portPriv->clientClip)
-	    portPriv->clientClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
+	    portPriv->clientClip = RegionCreate(NullBox, 1);
 	/* Note: this is in window coordinates */
-	REGION_COPY(pGC->pScreen, portPriv->clientClip, pGC->clientClip);
+	RegionCopy(portPriv->clientClip, pGC->clientClip);
     } else if(portPriv->clientClip) { /* free the old clientClip */
-	REGION_DESTROY(pGC->pScreen, portPriv->clientClip);
+	RegionDestroy(portPriv->clientClip);
 	portPriv->clientClip = NULL;
     }
 
     /* get rid of the old clip list */
     if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
-	REGION_DESTROY(pWin->pScreen, portPriv->pCompositeClip);
+	RegionDestroy(portPriv->pCompositeClip);
     }
 
     portPriv->clipOrg = pGC->clipOrg;
@@ -670,18 +670,18 @@ KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
   WinBox.y2 = WinBox.y1 + portPriv->drw_h;
 
   /* clip to the window composite clip */
-  REGION_INIT(portPriv->pDraw->pScreen, &WinRegion, &WinBox, 1);
-  REGION_INIT(portPriv->pDraw->pScreen, &ClipRegion, NullBox, 1);
-  REGION_INTERSECT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionInit(&ClipRegion, NullBox, 1);
+  RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
 
   /* that's all if it's totally obscured */
-  if(!REGION_NOTEMPTY(portPriv->pDraw->pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
 	clippedAway = TRUE;
 	goto CLIP_VIDEO_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw,
@@ -706,8 +706,8 @@ CLIP_VIDEO_BAILOUT:
   if(!portPriv->FreeCompositeClip)
      portPriv->pCompositeClip = NULL;
 
-  REGION_UNINIT(portPriv->pDraw->pScreen, &WinRegion);
-  REGION_UNINIT(portPriv->pDraw->pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -734,9 +734,9 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
   WinBox.y2 = WinBox.y1 + portPriv->drw_h;
 
   /* clip to the window composite clip */
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
-  REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionInit(&ClipRegion, NullBox, 1);
+  RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
 
   /* clip and translate to the viewport */
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -748,21 +748,21 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
      VPBox.x2 = screen->width;
      VPBox.y2 = screen->height;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   /* that's all if it's totally obscured */
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
 	clippedAway = TRUE;
 	goto CLIP_VIDEO_BAILOUT;
   }
 
   /* bailout if we have to clip but the hardware doesn't support it */
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -772,7 +772,7 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw,
@@ -796,8 +796,8 @@ CLIP_VIDEO_BAILOUT:
   if(!portPriv->FreeCompositeClip)
      portPriv->pCompositeClip = NULL;
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -823,9 +823,9 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
   WinBox.y2 = WinBox.y1 + portPriv->drw_h;
 
   /* clip to the window composite clip */
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
-  REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionInit(&ClipRegion, NullBox, 1);
+  RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
 
   /* clip and translate to the viewport */
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -837,21 +837,21 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
      VPBox.x2 = screen->width;
      VPBox.y2 = screen->height;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   /* that's all if it's totally obscured */
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
 	clippedAway = TRUE;
 	goto CLIP_VIDEO_BAILOUT;
   }
 
   /* bailout if we have to clip but the hardware doesn't support it */
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -861,7 +861,7 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen, portPriv->pDraw,
@@ -882,8 +882,8 @@ CLIP_VIDEO_BAILOUT:
   if(!portPriv->FreeCompositeClip)
      portPriv->pCompositeClip = NULL;
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1021,7 +1021,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
   XvPortRecPrivatePtr pPriv;
   Bool AreasExposed;
 
-  AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+  AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
 
   pScreen->WindowExposures = ScreenPriv->WindowExposures;
   (*pScreen->WindowExposures)(pWin, reg1, reg2);
@@ -1089,7 +1089,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy)
      pPriv = WinPriv->PortRec;
 
      if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-	REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+	RegionDestroy(pPriv->pCompositeClip);
 
      pPriv->pCompositeClip = NULL;
 
@@ -1220,7 +1220,7 @@ KdXVDisable(ScreenPtr pScreen)
 		pPriv->isOn = XV_OFF;
 
 		if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-		    REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+		    RegionDestroy(pPriv->pCompositeClip);
 
 		pPriv->pCompositeClip = NULL;
 
@@ -1330,9 +1330,9 @@ KdXVPutStill(
   WinBox.x2 = WinBox.x1 + drw_w;
   WinBox.y2 = WinBox.y1 + drw_h;
 
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionInit(&ClipRegion, NullBox, 1);
+  RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
 
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
      RegionRec VPReg;
@@ -1343,23 +1343,23 @@ KdXVPutStill(
      VPBox.x2 = screen->width;
      VPBox.y2 = screen->height;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   if(portPriv->pDraw) {
      KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
   }
 
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
      clippedAway = TRUE;
      goto PUT_STILL_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -1369,7 +1369,7 @@ KdXVPutStill(
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen, pDraw,
@@ -1398,8 +1398,8 @@ PUT_STILL_BAILOUT:
         portPriv->isOn = XV_PENDING;
   }
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1483,21 +1483,21 @@ KdXVGetStill(
   WinBox.x2 = WinBox.x1 + drw_w;
   WinBox.y2 = WinBox.y1 + drw_h;
 
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionInit(&ClipRegion, NullBox, 1);
+  RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
 
   if(portPriv->pDraw) {
      KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
   }
 
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
      clippedAway = TRUE;
      goto GET_STILL_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen, pDraw,
@@ -1513,8 +1513,8 @@ GET_STILL_BAILOUT:
         portPriv->isOn = XV_PENDING;
   }
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1630,9 +1630,9 @@ KdXVPutImage(
   WinBox.x2 = WinBox.x1 + drw_w;
   WinBox.y2 = WinBox.y1 + drw_h;
 
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionInit(&ClipRegion, NullBox, 1);
+  RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
 
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
      RegionRec VPReg;
@@ -1643,23 +1643,23 @@ KdXVPutImage(
      VPBox.x2 = pScreen->width;
      VPBox.y2 = pScreen->height;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   if(portPriv->pDraw) {
      KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
   }
 
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
      clippedAway = TRUE;
      goto PUT_IMAGE_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -1669,7 +1669,7 @@ KdXVPutImage(
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen, pDraw,
@@ -1698,8 +1698,8 @@ PUT_IMAGE_BAILOUT:
         portPriv->isOn = XV_PENDING;
   }
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1869,8 +1869,8 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
     GCPtr	pGC;
     ChangeGCVal	val[2];
     xRectangle	*rects, *r;
-    BoxPtr	pBox = REGION_RECTS (pRgn);
-    int		nBox = REGION_NUM_RECTS (pRgn);
+    BoxPtr	pBox = RegionRects (pRgn);
+    int		nBox = RegionNumRects (pRgn);
 
     rects = malloc(nBox * sizeof (xRectangle));
     if (!rects)
@@ -1897,7 +1897,7 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
     ValidateGC (pDraw, pGC);
 
     (*pGC->ops->PolyFillRect) (pDraw, pGC,
-			       REGION_NUM_RECTS (pRgn), rects);
+			       RegionNumRects (pRgn), rects);
 
     FreeScratchGC (pGC);
 bail1:
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 1aad2d1..7867a42 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1085,8 +1085,8 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
 	    {
 		RegionPtr	borderVisible;
 
-		borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
+		borderVisible = RegionCreate(NullBox, 1);
+		RegionSubtract(borderVisible,
 				&pWin->borderClip, &pWin->winSize);
 		pWin->valdata->before.borderVisible = borderVisible;
 	    }
@@ -1105,18 +1105,18 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
 	box.y1 = 0;
 	box.x2 = pScreen->width;
 	box.y2 = pScreen->height;
-	REGION_INIT (pScreen, &pWin->winSize, &box, 1);
-	REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
+	RegionInit(&pWin->winSize, &box, 1);
+	RegionInit(&pWin->borderSize, &box, 1);
 	if (WasViewable)
-	    REGION_RESET(pScreen, &pWin->borderClip, &box);
+	    RegionReset(&pWin->borderClip, &box);
 	pWin->drawable.width = pScreen->width;
 	pWin->drawable.height = pScreen->height;
-        REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+        RegionBreak(&pWin->clipList);
     }
     else
     {
-	REGION_EMPTY(pScreen, &pWin->borderClip);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+	RegionEmpty(&pWin->borderClip);
+	RegionBreak(&pWin->clipList);
     }
 
     ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index a142abe..d883ab3 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -363,8 +363,8 @@ AllocateArea(
 
    if(granularity <= 1) granularity = 0;
 
-   boxp = REGION_RECTS(offman->FreeBoxes);
-   num = REGION_NUM_RECTS(offman->FreeBoxes);
+   boxp = RegionRects(offman->FreeBoxes);
+   num = RegionNumRects(offman->FreeBoxes);
 
    /* look through the free boxes */
    for(i = 0; i < num; i++, boxp++) {
@@ -407,9 +407,9 @@ AllocateArea(
 
 	   /* bye, bye */
 	   (*link->area.RemoveAreaCallback)(&link->area);
-	   REGION_INIT(pScreen, &NewReg, &(link->area.box), 1); 
-	   REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
-	   REGION_UNINIT(pScreen, &NewReg); 
+	   RegionInit(&NewReg, &(link->area.box), 1);
+	   RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+	   RegionUninit(&NewReg);
 
            area = &(link->area);
 	   break;
@@ -427,9 +427,9 @@ AllocateArea(
 	area->RemoveAreaCallback = removeCB;
 	area->devPrivate.ptr = privData;
 
-        REGION_INIT(pScreen, &NewReg, &(area->box), 1);
-	REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
-	REGION_UNINIT(pScreen, &NewReg);
+        RegionInit(&NewReg, &(area->box), 1);
+	RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+	RegionUninit(&NewReg);
    }
 
    return area;
@@ -477,9 +477,9 @@ localFreeOffscreenArea(FBAreaPtr area)
    }
 
    /* put the area back into the pool */
-   REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1); 
-   REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
-   REGION_UNINIT(pScreen, &FreedRegion); 
+   RegionInit(&FreedRegion, &(pLink->area.box), 1);
+   RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
+   RegionUninit(&FreedRegion);
 
    if(pLinkPrev)
 	pLinkPrev->next = pLink->next;
@@ -536,12 +536,12 @@ localResizeOffscreenArea(
 	   (resize->box.x2 == OrigArea.x2))
 		return TRUE;
 
-	REGION_INIT(pScreen, &FreedReg, &OrigArea, 1); 
-	REGION_INIT(pScreen, &NewReg, &(resize->box), 1); 
-	REGION_SUBTRACT(pScreen, &FreedReg, &FreedReg, &NewReg);
-	REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
-	REGION_UNINIT(pScreen, &FreedReg); 
-	REGION_UNINIT(pScreen, &NewReg); 
+	RegionInit(&FreedReg, &OrigArea, 1);
+	RegionInit(&NewReg, &(resize->box), 1);
+	RegionSubtract(&FreedReg, &FreedReg, &NewReg);
+	RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+	RegionUninit(&FreedReg);
+	RegionUninit(&NewReg);
 
 	SendCallFreeBoxCallbacks(offman);
 
@@ -551,8 +551,8 @@ localResizeOffscreenArea(
 
    /* otherwise we remove the old region */
 
-   REGION_INIT(pScreen, &FreedReg, &OrigArea, 1); 
-   REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+   RegionInit(&FreedReg, &OrigArea, 1);
+   RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
   
    /* remove the old link */
    if(pLinkPrev)
@@ -589,8 +589,8 @@ localResizeOffscreenArea(
 	offman->NumUsedAreas--;  
    } else {
       /* reinstate the old region */
-      REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
-      REGION_UNINIT(pScreen, &FreedReg); 
+      RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+      RegionUninit(&FreedReg);
 
       pLink->next = offman->UsedAreas;
       offman->UsedAreas = pLink;
@@ -598,7 +598,7 @@ localResizeOffscreenArea(
    }
 
 
-   REGION_UNINIT(pScreen, &FreedReg); 
+   RegionUninit(&FreedReg);
 
    SendCallFreeBoxCallbacks(offman);
 
@@ -636,47 +636,47 @@ localQueryLargestOffscreenArea(
 	if(offman->NumUsedAreas) {
 	    FBLinkPtr pLink;
 	    RegionRec tmpRegion;
-	    newRegion = REGION_CREATE(pScreen, NULL, 1);
-	    REGION_COPY(pScreen, newRegion, offman->InitialBoxes);
+	    newRegion = RegionCreate(NULL, 1);
+	    RegionCopy(newRegion, offman->InitialBoxes);
 	    pLink = offman->UsedAreas;
 
 	    while(pLink) {
 		if(!pLink->area.RemoveAreaCallback) {
-		    REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
-		    REGION_SUBTRACT(pScreen, newRegion, newRegion, &tmpRegion);
-		    REGION_UNINIT(pScreen, &tmpRegion);
+		    RegionInit(&tmpRegion, &(pLink->area.box), 1);
+		    RegionSubtract(newRegion, newRegion, &tmpRegion);
+		    RegionUninit(&tmpRegion);
 		}
 		pLink = pLink->next;
 	    }
 
-	    nbox = REGION_NUM_RECTS(newRegion);
-	    pbox = REGION_RECTS(newRegion);
+	    nbox = RegionNumRects(newRegion);
+	    pbox = RegionRects(newRegion);
 	    break;
 	}
     case 1:
 	if(offman->NumUsedAreas) {
 	    FBLinkPtr pLink;
 	    RegionRec tmpRegion;
-	    newRegion = REGION_CREATE(pScreen, NULL, 1);
-	    REGION_COPY(pScreen, newRegion, offman->FreeBoxes);
+	    newRegion = RegionCreate(NULL, 1);
+	    RegionCopy(newRegion, offman->FreeBoxes);
 	    pLink = offman->UsedAreas;
 
 	    while(pLink) {
 		if(pLink->area.RemoveAreaCallback) {
-		    REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
-		    REGION_APPEND(pScreen, newRegion, &tmpRegion);
-		    REGION_UNINIT(pScreen, &tmpRegion);
+		    RegionInit(&tmpRegion, &(pLink->area.box), 1);
+		    RegionAppend(newRegion, &tmpRegion);
+		    RegionUninit(&tmpRegion);
 		}
 		pLink = pLink->next;
 	    }
 
-	    nbox = REGION_NUM_RECTS(newRegion);
-	    pbox = REGION_RECTS(newRegion);
+	    nbox = RegionNumRects(newRegion);
+	    pbox = RegionRects(newRegion);
 	    break;
 	}
     default:
-	nbox = REGION_NUM_RECTS(offman->FreeBoxes);
-	pbox = REGION_RECTS(offman->FreeBoxes);
+	nbox = RegionNumRects(offman->FreeBoxes);
+	pbox = RegionRects(offman->FreeBoxes);
 	break;
     }
 
@@ -719,7 +719,7 @@ localQueryLargestOffscreenArea(
     }
 
     if(newRegion)
-	REGION_DESTROY(pScreen, newRegion);
+	RegionDestroy(newRegion);
 
     return TRUE;
 }
@@ -741,9 +741,9 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
 	if(pLink->area.RemoveAreaCallback) {
 	    (*pLink->area.RemoveAreaCallback)(&pLink->area);
 
-	    REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1); 
-	    REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion);
-	    REGION_UNINIT(pScreen, &FreedRegion); 
+	    RegionInit(&FreedRegion, &(pLink->area.box), 1);
+	    RegionAppend(offman->FreeBoxes, &FreedRegion);
+	    RegionUninit(&FreedRegion);
 
 	    if(pPrev)
 	      pPrev->next = pLink->next;
@@ -761,7 +761,7 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
    }
 
    if(anyUsed) {
-	REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed);
+	RegionValidate(offman->FreeBoxes, &anyUsed);
 	SendCallFreeBoxCallbacks(offman);
    }
 
@@ -924,7 +924,7 @@ localAllocateOffscreenLinear(
      return NULL;
 
    /* No linear available, so try and pinch some from the XY areas */
-   extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+   extents = RegionExtents(offman->InitialBoxes);
    pitch = extents->x2 - extents->x1;
 
    if (gran > 1) {
@@ -1055,7 +1055,7 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length)
 	BoxPtr extents;
 	int pitch, w, h;
 
-	extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+	extents = RegionExtents(offman->InitialBoxes);
 	pitch = extents->x2 - extents->x1;
 
 	if(length < pitch) { /* special case */
@@ -1121,7 +1121,7 @@ localQueryLargestOffscreenLinear(
 
 	    offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
 						    xf86FBScreenKey);
-	    extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+	    extents = RegionExtents(offman->InitialBoxes);
 	    if((extents->x2 - extents->x1) == w)
 	    	*size = w * h;
 	    return TRUE;
@@ -1171,8 +1171,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
 	free(tmp2);
    }
 
-   REGION_DESTROY(pScreen, offman->InitialBoxes);
-   REGION_DESTROY(pScreen, offman->FreeBoxes);
+   RegionDestroy(offman->InitialBoxes);
+   RegionDestroy(offman->FreeBoxes);
 
    free(offman->FreeBoxesUpdateCallback);
    free(offman->devPrivates);
@@ -1206,15 +1206,15 @@ xf86InitFBManager(
    if (FullBox->y2 < FullBox->y1) return FALSE;
    if (FullBox->x2 < FullBox->x1) return FALSE;
 
-   REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1); 
-   REGION_INIT(pScreen, &FullRegion, FullBox, 1); 
+   RegionInit(&ScreenRegion, &ScreenBox, 1);
+   RegionInit(&FullRegion, FullBox, 1);
 
-   REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);
+   RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
 
    ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
 
-   REGION_UNINIT(pScreen, &ScreenRegion);
-   REGION_UNINIT(pScreen, &FullRegion);
+   RegionUninit(&ScreenRegion);
+   RegionUninit(&FullRegion);
     
    return ret;
 }
@@ -1249,17 +1249,17 @@ xf86InitFBManagerArea(
     }
 
     /* Factor out virtual resolution */
-    pRegion = RECTS_TO_REGION(pScreen, nRect, Rect, 0);
+    pRegion = RegionFromRects(nRect, Rect, 0);
     if (pRegion) {
-	if (!REGION_NAR(pRegion)) {
+	if (!RegionNar(pRegion)) {
 	    Rect[2].x = Rect[2].y = 0;
 	    Rect[2].width = pScrn->virtualX;
 	    Rect[2].height = pScrn->virtualY;
 
-	    pScreenRegion = RECTS_TO_REGION(pScreen, 1, &Rect[2], 0);
+	    pScreenRegion = RegionFromRects(1, &Rect[2], 0);
 	    if (pScreenRegion) {
-		if (!REGION_NAR(pScreenRegion)) {
-		    REGION_SUBTRACT(pScreen, pRegion, pRegion, pScreenRegion);
+		if (!RegionNar(pScreenRegion)) {
+		    RegionSubtract(pRegion, pRegion, pScreenRegion);
 
 		    ret = xf86InitFBManagerRegion(pScreen, pRegion);
 
@@ -1301,11 +1301,11 @@ xf86InitFBManagerArea(
 		    }
 		}
 
-		REGION_DESTROY(pScreen, pScreenRegion);
+		RegionDestroy(pScreenRegion);
 	    }
 	}
 
-	REGION_DESTROY(pScreen, pRegion);
+	RegionDestroy(pRegion);
     }
 
     return ret;
@@ -1318,7 +1318,7 @@ xf86InitFBManagerRegion(
 ){
    FBManagerPtr offman;
 
-   if(REGION_NIL(FullRegion))
+   if(RegionNil(FullRegion))
 	return FALSE;
 
    if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
@@ -1332,11 +1332,11 @@ xf86InitFBManagerRegion(
    offman->CloseScreen = pScreen->CloseScreen;
    pScreen->CloseScreen = xf86FBCloseScreen;
 
-   offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1);
-   offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1);
+   offman->InitialBoxes = RegionCreate(NULL, 1);
+   offman->FreeBoxes = RegionCreate(NULL, 1);
 
-   REGION_COPY(pScreen, offman->InitialBoxes, FullRegion);
-   REGION_COPY(pScreen, offman->FreeBoxes, FullRegion);
+   RegionCopy(offman->InitialBoxes, FullRegion);
+   RegionCopy(offman->FreeBoxes, FullRegion);
 
    offman->pScreen = pScreen;
    offman->UsedAreas = NULL;
@@ -1415,7 +1415,7 @@ xf86AllocateLinearOffscreenArea (
 
    offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
 					   xf86FBScreenKey);
-   extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+   extents = RegionExtents(offman->InitialBoxes);
    w = extents->x2 - extents->x1;
 
    if (gran > 1) {
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index efed677..36e325f 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -322,9 +322,9 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
 	  pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
 	  if(pPriv) {
 	     if(pPriv->clientClip)
-		REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+		RegionDestroy(pPriv->clientClip);
 	     if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-		REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+		RegionDestroy(pPriv->pCompositeClip);
 	     free(pPriv);
 	  }
       }
@@ -658,18 +658,18 @@ xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
 	return;
    }
 
-   pCompositeClip = REGION_CREATE(pScreen, NullBox, 1);
-   REGION_COPY(pScreen, pCompositeClip, portPriv->clientClip);
-   REGION_TRANSLATE(pScreen, pCompositeClip,
+   pCompositeClip = RegionCreate(NullBox, 1);
+   RegionCopy(pCompositeClip, portPriv->clientClip);
+   RegionTranslate(pCompositeClip,
 			portPriv->pDraw->x + portPriv->clipOrg.x,
 			portPriv->pDraw->y + portPriv->clipOrg.y);
-   REGION_INTERSECT(pScreen, pCompositeClip, pregWin, pCompositeClip);
+   RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
 
    portPriv->pCompositeClip = pCompositeClip;
    portPriv->FreeCompositeClip = TRUE;
 
    if(freeCompClip) {
-	REGION_DESTROY(pScreen, pregWin);
+	RegionDestroy(pregWin);
    }
 }
 
@@ -684,17 +684,17 @@ xf86XVCopyClip(
     /* copy the new clip if it exists */
     if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
 	if(!portPriv->clientClip)
-	    portPriv->clientClip = REGION_CREATE(pScreen, NullBox, 1);
+	    portPriv->clientClip = RegionCreate(NullBox, 1);
 	/* Note: this is in window coordinates */
-	REGION_COPY(pScreen, portPriv->clientClip, pGC->clientClip);
+	RegionCopy(portPriv->clientClip, pGC->clientClip);
     } else if(portPriv->clientClip) { /* free the old clientClip */
-	REGION_DESTROY(pScreen, portPriv->clientClip);
+	RegionDestroy(portPriv->clientClip);
 	portPriv->clientClip = NULL;
     }
 
     /* get rid of the old clip list */
     if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
-	REGION_DESTROY(pScreen, portPriv->pCompositeClip);
+	RegionDestroy(portPriv->pCompositeClip);
     }
 
     portPriv->clipOrg = pGC->clipOrg;
@@ -723,18 +723,18 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
   WinBox.y2 = WinBox.y1 + portPriv->drw_h;
 
   /* clip to the window composite clip */
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_NULL(pScreen, &ClipRegion);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionNull(&ClipRegion);
+  RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
 
   /* that's all if it's totally obscured */
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
 	clippedAway = TRUE;
 	goto CLIP_VIDEO_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
@@ -760,8 +760,8 @@ CLIP_VIDEO_BAILOUT:
   if(!portPriv->FreeCompositeClip)
      portPriv->pCompositeClip = NULL;
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -788,9 +788,9 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
   WinBox.y2 = WinBox.y1 + portPriv->drw_h;
 
   /* clip to the window composite clip */
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_NULL(pScreen, &ClipRegion);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionNull(&ClipRegion);
+  RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
 
   /* clip and translate to the viewport */
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -802,21 +802,21 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
      VPBox.x2 = portPriv->pScrn->frameX1 + 1;
      VPBox.y2 = portPriv->pScrn->frameY1 + 1;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   /* that's all if it's totally obscured */
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
 	clippedAway = TRUE;
 	goto CLIP_VIDEO_BAILOUT;
   }
 
   /* bailout if we have to clip but the hardware doesn't support it */
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -826,7 +826,7 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
@@ -851,8 +851,8 @@ CLIP_VIDEO_BAILOUT:
   if(!portPriv->FreeCompositeClip)
      portPriv->pCompositeClip = NULL;
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -878,9 +878,9 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
   WinBox.y2 = WinBox.y1 + portPriv->drw_h;
 
   /* clip to the window composite clip */
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_NULL(pScreen, &ClipRegion);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionNull(&ClipRegion);
+  RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
 
   /* clip and translate to the viewport */
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -892,21 +892,21 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
      VPBox.x2 = portPriv->pScrn->frameX1 + 1;
      VPBox.y2 = portPriv->pScrn->frameY1 + 1;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   /* that's all if it's totally obscured */
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
 	clippedAway = TRUE;
 	goto CLIP_VIDEO_BAILOUT;
   }
 
   /* bailout if we have to clip but the hardware doesn't support it */
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -916,7 +916,7 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
@@ -938,8 +938,8 @@ CLIP_VIDEO_BAILOUT:
   if(!portPriv->FreeCompositeClip)
      portPriv->pCompositeClip = NULL;
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1060,7 +1060,7 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
   XvPortRecPrivatePtr pPriv;
   Bool AreasExposed;
 
-  AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+  AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
 
   pScreen->WindowExposures = ScreenPriv->WindowExposures;
   (*pScreen->WindowExposures)(pWin, reg1, reg2);
@@ -1131,7 +1131,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
      if(!pPriv) goto next;
  
      if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-	REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+	RegionDestroy(pPriv->pCompositeClip);
 
      pPriv->pCompositeClip = NULL;
 
@@ -1268,7 +1268,7 @@ xf86XVLeaveVT(int index, int flags)
 		pPriv->isOn = XV_OFF;
 
 		if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-		    REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+		    RegionDestroy(pPriv->pCompositeClip);
 
 		pPriv->pCompositeClip = NULL;
 
@@ -1309,7 +1309,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags)
 	if(!pPriv->type && (pPriv->isOn != XV_OFF)) { /* overlaid still/image */
 
 	  if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
-	     REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+	     RegionDestroy(pPriv->pCompositeClip);
 
 	  pPriv->pCompositeClip = NULL;
 
@@ -1432,9 +1432,9 @@ xf86XVPutStill(
   WinBox.x2 = WinBox.x1 + drw_w;
   WinBox.y2 = WinBox.y1 + drw_h;
 
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_NULL(pScreen, &ClipRegion);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionNull(&ClipRegion);
+  RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
 
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
      RegionRec VPReg;
@@ -1445,23 +1445,23 @@ xf86XVPutStill(
      VPBox.x2 = portPriv->pScrn->frameX1 + 1;
      VPBox.y2 = portPriv->pScrn->frameY1 + 1;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   if(portPriv->pDraw) {
      xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
   }
 
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
      clippedAway = TRUE;
      goto PUT_STILL_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -1471,7 +1471,7 @@ xf86XVPutStill(
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
@@ -1500,8 +1500,8 @@ PUT_STILL_BAILOUT:
 	portPriv->isOn = XV_PENDING;
   }
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1584,21 +1584,21 @@ xf86XVGetStill(
   WinBox.x2 = WinBox.x1 + drw_w;
   WinBox.y2 = WinBox.y1 + drw_h;
 
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_NULL(pScreen, &ClipRegion);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionNull(&ClipRegion);
+  RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
 
   if(portPriv->pDraw) {
      xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
   }
 
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
      clippedAway = TRUE;
      goto GET_STILL_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
@@ -1615,8 +1615,8 @@ GET_STILL_BAILOUT:
 	portPriv->isOn = XV_PENDING;
   }
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1732,9 +1732,9 @@ xf86XVPutImage(
   WinBox.x2 = WinBox.x1 + drw_w;
   WinBox.y2 = WinBox.y1 + drw_h;
 
-  REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
-  REGION_NULL(pScreen, &ClipRegion);
-  REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+  RegionInit(&WinRegion, &WinBox, 1);
+  RegionNull(&ClipRegion);
+  RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
 
   if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
      RegionRec VPReg;
@@ -1745,9 +1745,9 @@ xf86XVPutImage(
      VPBox.x2 = portPriv->pScrn->frameX1 + 1;
      VPBox.y2 = portPriv->pScrn->frameY1 + 1;
 
-     REGION_INIT(pScreen, &VPReg, &VPBox, 1);
-     REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
-     REGION_UNINIT(pScreen, &VPReg);
+     RegionInit(&VPReg, &VPBox, 1);
+     RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+     RegionUninit(&VPReg);
   }
 
   /* If we are changing windows, unregister our port in the old window */
@@ -1758,14 +1758,14 @@ xf86XVPutImage(
   ret =  xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
   if(ret != Success) goto PUT_IMAGE_BAILOUT;
 
-  if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+  if(!RegionNotEmpty(&ClipRegion)) {
      clippedAway = TRUE;
      goto PUT_IMAGE_BAILOUT;
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
-     BoxPtr clipBox = REGION_RECTS(&ClipRegion);
-     if(  (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+     BoxPtr clipBox = RegionRects(&ClipRegion);
+     if(  (RegionNumRects(&ClipRegion) != 1) ||
 	  (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
 	  (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
      {
@@ -1775,7 +1775,7 @@ xf86XVPutImage(
   }
 
   if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
-     REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+     RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
   }
 
   ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
@@ -1803,8 +1803,8 @@ PUT_IMAGE_BAILOUT:
 	portPriv->isOn = XV_PENDING;
   }
 
-  REGION_UNINIT(pScreen, &WinRegion);
-  REGION_UNINIT(pScreen, &ClipRegion);
+  RegionUninit(&WinRegion);
+  RegionUninit(&ClipRegion);
 
   return ret;
 }
@@ -1834,8 +1834,8 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
    WindowPtr pWin = (WindowPtr)pDraw;
    XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin);
    GCPtr pGC = NULL;
-   BoxPtr pbox = REGION_RECTS(clipboxes);
-   int i, nbox = REGION_NUM_RECTS(clipboxes);
+   BoxPtr pbox = RegionRects(clipboxes);
+   int i, nbox = RegionNumRects(clipboxes);
    xRectangle *rects;
 
    if(!xf86Screens[pScreen->myNum]->vtSema) return;
@@ -1860,7 +1860,7 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
        ValidateGC(pDraw, pGC);
    }
 
-   REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y);
+   RegionTranslate(clipboxes, -pDraw->x, -pDraw->y);
 
    rects = malloc(nbox * sizeof(xRectangle));
 
@@ -1883,8 +1883,8 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
 {
    DrawablePtr root = &pScreen->root->drawable;
    ChangeGCVal pval[2];
-   BoxPtr pbox = REGION_RECTS(clipboxes);
-   int i, nbox = REGION_NUM_RECTS(clipboxes);
+   BoxPtr pbox = RegionRects(clipboxes);
+   int i, nbox = RegionNumRects(clipboxes);
    xRectangle *rects;
    GCPtr gc;
 
@@ -1936,7 +1936,7 @@ xf86XVClipVideoHelper(
 ){
     double xsw, xdw, ysw, ydw;
     INT32 delta;
-    BoxPtr extents = REGION_EXTENTS(DummyScreen, reg);
+    BoxPtr extents = RegionExtents(reg);
     int diff;
 
     xsw = (*xb - *xa) << 16;
@@ -1998,9 +1998,9 @@ xf86XVClipVideoHelper(
 	(dst->y1 > extents->y1) || (dst->y2 < extents->y2))
     {
 	RegionRec clipReg;
-	REGION_INIT(DummyScreen, &clipReg, dst, 1);
-	REGION_INTERSECT(DummyScreen, reg, reg, &clipReg);
-	REGION_UNINIT(DummyScreen, &clipReg);
+	RegionInit(&clipReg, dst, 1);
+	RegionIntersect(reg, reg, &clipReg);
+	RegionUninit(&clipReg);
     }
     return TRUE;
 }
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index f7cea5e..63c77de 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1157,7 +1157,7 @@ DRIDCNTreeTraversal(WindowPtr pWin, pointer data)
 	ScreenPtr pScreen = pWin->drawable.pScreen;
 	DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
 
-	if (REGION_NUM_RECTS(&pWin->clipList) > 0) {
+	if (RegionNumRects(&pWin->clipList) > 0) {
 	    WindowPtr *pDRIWindows = (WindowPtr*)data;
 	    int i = 0;
 
@@ -1269,7 +1269,7 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
 	    pDRIDrawablePriv->pScreen = pScreen;
 	    pDRIDrawablePriv->refCount = 1;
 	    pDRIDrawablePriv->drawableIndex = -1;
-	    pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList);
+	    pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
 
 	    /* save private off of preallocated index */
 	    dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
@@ -1288,8 +1288,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
 	    drmUpdateDrawableInfo(pDRIPriv->drmFD,
 				  pDRIDrawablePriv->hwDrawable,
 				  DRM_DRAWABLE_CLIPRECTS,
-				  REGION_NUM_RECTS(&pWin->clipList),
-				  REGION_RECTS(&pWin->clipList));
+				  RegionNumRects(&pWin->clipList),
+				  RegionRects(&pWin->clipList));
 	    *hHWDrawable = pDRIDrawablePriv->hwDrawable;
 	}
     }
@@ -1502,8 +1502,8 @@ DRIGetDrawableInfo(ScreenPtr pScreen,
 #endif
 	    *W = (int)(pWin->drawable.width);
 	    *H = (int)(pWin->drawable.height);
-	    *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
-	    *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList);
+	    *numClipRects = RegionNumRects(&pWin->clipList);
+	    *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList);
 
 	    if (!*numClipRects && pDRIPriv->fullscreen) {
 				/* use fake full-screen clip rect */
@@ -1883,10 +1883,10 @@ DRITreeTraversal(WindowPtr pWin, pointer data)
         ScreenPtr pScreen = pWin->drawable.pScreen;
         DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
 
-	if(REGION_NUM_RECTS(&(pWin->clipList)) > 0) {
+	if(RegionNumRects(&(pWin->clipList)) > 0) {
 	   RegionPtr reg = (RegionPtr)data;
 
-	   REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
+	   RegionUnion(reg, reg, &(pWin->clipList));
 	   pDRIPriv->nrWalked++;
 	}
 
@@ -1932,21 +1932,21 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     if(pDRIPriv->nrWindowsVisible > 0) {
        RegionRec reg;
 
-       REGION_NULL(pScreen, &reg);
+       RegionNull(&reg);
        pDRIPriv->nrWalked = 0;
        TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
 
-       if(REGION_NOTEMPTY(pScreen, &reg)) {
-           REGION_TRANSLATE(pScreen, &reg, ptOldOrg.x - pWin->drawable.x,  
+       if(RegionNotEmpty(&reg)) {
+           RegionTranslate(&reg, ptOldOrg.x - pWin->drawable.x,
                                         ptOldOrg.y - pWin->drawable.y);
-           REGION_INTERSECT(pScreen, &reg, &reg, prgnSrc);
+           RegionIntersect(&reg, &reg, prgnSrc);
 
            /* The MoveBuffers interface is not ideal */
            (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
 				pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
        }
 
-       REGION_UNINIT(pScreen, &reg);
+       RegionUninit(&reg);
     }
 
     /* call lower wrapped functions */
@@ -2122,7 +2122,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
     if(!pDRIPriv) return;
 
     if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
-        int nrects = REGION_NUM_RECTS(&pWin->clipList);
+        int nrects = RegionNumRects(&pWin->clipList);
 
         if(!pDRIPriv->windowsTouched) {
             DRILockTree(pScreen);
@@ -2143,7 +2143,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
 
 	drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
 			      DRM_DRAWABLE_CLIPRECTS,
-			      nrects, REGION_RECTS(&pWin->clipList));
+			      nrects, RegionRects(&pWin->clipList));
     }
 
     /* call lower wrapped functions */
@@ -2368,9 +2368,9 @@ DRIMoveBuffersHelper(
    BoxRec tmpBox;
    int y, nbox;
 
-   extents = REGION_EXTENTS(pScreen, reg);
-   nbox = REGION_NUM_RECTS(reg);
-   pbox = REGION_RECTS(reg);
+   extents = RegionExtents(reg);
+   nbox = RegionNumRects(reg);
+   pbox = RegionRects(reg);
 
    if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
      *ydir = -1;
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 45a8271..3c8d3a8 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -461,7 +461,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
 	box.y1 = 0;
 	box.x2 = pPriv->width;
 	box.y2 = pPriv->height;
-	REGION_INIT(pDraw->pScreen, &region, &box, 0);
+	RegionInit(&region, &box, 0);
 
 	DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
 		       DRI2BufferFrontLeft);
@@ -614,7 +614,7 @@ DRI2CanFlip(DrawablePtr pDraw)
     pWinPixmap = pScreen->GetWindowPixmap(pWin);
     if (pRootPixmap != pWinPixmap)
 	return FALSE;
-    if (!REGION_EQUAL(pScreen, &pWin->clipList, &pRoot->winSize))
+    if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
 	return FALSE;
 
     return TRUE;
@@ -710,7 +710,7 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
     box.y1 = 0;
     box.x2 = pDraw->width;
     box.y2 = pDraw->height;
-    REGION_INIT(pScreen, &region, &box, 0);
+    RegionInit(&region, &box, 0);
     DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
 		   DRI2BufferFrontLeft);
 
@@ -782,7 +782,7 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 	box.y1 = 0;
 	box.x2 = pDraw->width;
 	box.y2 = pDraw->height;
-	REGION_INIT(pScreen, &region, &box, 0);
+	RegionInit(&region, &box, 0);
 
 	pPriv->swapsPending++;
 
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 065ba48..60003d5 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3155,9 +3155,9 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
 						  &crtc_box);
 
 	if (crtc) {
-	    REGION_INIT (pScreen, &crtc_region_local, &crtc_box, 1);
+	    RegionInit(&crtc_region_local, &crtc_box, 1);
 	    crtc_region = &crtc_region_local;
-	    REGION_INTERSECT (pScreen, crtc_region, crtc_region, reg);
+	    RegionIntersect(crtc_region, crtc_region, reg);
 	}
 	*crtc_ret = crtc;
     }
@@ -3166,7 +3166,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
 				crtc_region, width, height);
 
     if (crtc_region != reg)
-	REGION_UNINIT (pScreen, &crtc_region_local);
+	RegionUninit(&crtc_region_local);
 
     return ret;
 }
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index e3683a8..4cc99ad 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -81,8 +81,8 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
     PictFormatPtr	format = compWindowFormat (screen->root);
     int			error;
     PicturePtr		src, dst;
-    int			n = REGION_NUM_RECTS(region);
-    BoxPtr		b = REGION_RECTS(region);
+    int			n = RegionNumRects(region);
+    BoxPtr		b = RegionRects(region);
     XID			include_inferiors = IncludeInferiors;
     
     src = CreatePicture (None,
@@ -167,10 +167,10 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc)
     if (damage_box.y1 < 0) damage_box.y1 = 0;
     if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
     if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
-    REGION_INIT (pScreen, &damage_region, &damage_box, 1);
+    RegionInit(&damage_region, &damage_box, 1);
     DamageRegionAppend (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
 			&damage_region);
-    REGION_UNINIT (pScreen, &damage_region);
+    RegionUninit(&damage_region);
     crtc->shadowClear = TRUE;
 }
 
@@ -217,7 +217,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 	return FALSE;
     xf86RotatePrepare (pScreen);
     region = DamageRegion(damage);
-    if (REGION_NOTEMPTY(pScreen, region)) 
+    if (RegionNotEmpty(region))
     {
 	int			c;
 	SourceValidateProcPtr	SourceValidate;
@@ -240,14 +240,14 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 		RegionRec   crtc_damage;
 
 		/* compute portion of damage that overlaps crtc */
-		REGION_INIT(pScreen, &crtc_damage, &crtc->bounds, 1);
-		REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region);
+		RegionInit(&crtc_damage, &crtc->bounds, 1);
+		RegionIntersect(&crtc_damage, &crtc_damage, region);
 		
 		/* update damaged region */
-		if (REGION_NOTEMPTY(pScreen, &crtc_damage))
+		if (RegionNotEmpty(&crtc_damage))
     		    xf86RotateCrtcRedisplay (crtc, &crtc_damage);
 		
-		REGION_UNINIT (pScreen, &crtc_damage);
+		RegionUninit(&crtc_damage);
 	    }
 	}
 	pScreen->SourceValidate = SourceValidate;
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index fd5f26c..a0e4b9e 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -272,18 +272,18 @@ ShadowCopyWindow(
     RegionRec rgnDst;
 
     if (pPriv->vtSema) {
-        REGION_NULL(pWin->drawable.pScreen, &rgnDst);
-	REGION_COPY(pWin->drawable.pScreen, &rgnDst, prgn);
+        RegionNull(&rgnDst);
+	RegionCopy(&rgnDst, prgn);
         
-        REGION_TRANSLATE(pWin->drawable.pScreen, &rgnDst,
+        RegionTranslate(&rgnDst,
                          pWin->drawable.x - ptOldOrg.x,
                          pWin->drawable.y - ptOldOrg.y);
-        REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, &rgnDst);
-        if ((num = REGION_NUM_RECTS(&rgnDst))) {
+        RegionIntersect(&rgnDst, &pWin->borderClip, &rgnDst);
+        if ((num = RegionNumRects(&rgnDst))) {
             if(pPriv->preRefresh)
-                (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
+                (*pPriv->preRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
         } else {
-            REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+            RegionUninit(&rgnDst);
         }
     }
     
@@ -293,8 +293,8 @@ ShadowCopyWindow(
     
     if (num) {
         if (pPriv->postRefresh)
-            (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
-        REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+            (*pPriv->postRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
+        RegionUninit(&rgnDst);
     }
 }
 
@@ -1353,37 +1353,37 @@ ShadowFontToBox(BoxPtr BB, DrawablePtr pDrawable, GCPtr pGC, int x, int y,
 	}
 	right += pFont->info.maxbounds.rightSideBearing;
 	BB->x1 =
-	    max(pDrawable->x + x - left, (REGION_EXTENTS(pGC->pScreen,
+	    max(pDrawable->x + x - left, (RegionExtents(
 		&((WindowPtr) pDrawable)->winSize))->x1);
 	BB->y1 =
 	    max(pDrawable->y + y - ascent,
-	    (REGION_EXTENTS(pGC->pScreen,
+	    (RegionExtents(
              &((WindowPtr) pDrawable)->winSize))->y1);
 	BB->x2 =
 	    min(pDrawable->x + x + right,
-	    (REGION_EXTENTS(pGC->pScreen,
+	    (RegionExtents(
              &((WindowPtr) pDrawable)->winSize))->x2);
 	BB->y2 =
 	    min(pDrawable->y + y + descent,
-	    (REGION_EXTENTS(pGC->pScreen,
+	    (RegionExtents(
              &((WindowPtr) pDrawable)->winSize))->y2);
     } else {
     	ShadowTextExtent(pFont, count, chars, wide ? (FONTLASTROW(pFont) == 0)
                          ? Linear16Bit : TwoD16Bit : Linear8Bit, BB);
 	BB->x1 =
-	    max(pDrawable->x + x + BB->x1, (REGION_EXTENTS(pGC->pScreen,
+	    max(pDrawable->x + x + BB->x1, (RegionExtents(
 		&((WindowPtr) pDrawable)->winSize))->x1);
 	BB->y1 =
 	    max(pDrawable->y + y + BB->y1,
-	    (REGION_EXTENTS(pGC->pScreen,
+	    (RegionExtents(
              &((WindowPtr) pDrawable)->winSize))->y1);
 	BB->x2 =
 	    min(pDrawable->x + x + BB->x2,
-	    (REGION_EXTENTS(pGC->pScreen,
+	    (RegionExtents(
 	     &((WindowPtr) pDrawable)->winSize))->x2);
 	BB->y2 =
 	    min(pDrawable->y + y + BB->y2,
-	    (REGION_EXTENTS(pGC->pScreen, 
+	    (RegionExtents(
 	     &((WindowPtr) pDrawable)->winSize))->y2);
     }
 }
diff --git a/hw/xfree86/xaa/xaaBitBlt.c b/hw/xfree86/xaa/xaaBitBlt.c
index 75033bc..5148ed4 100644
--- a/hw/xfree86/xaa/xaaBitBlt.c
+++ b/hw/xfree86/xaa/xaaBitBlt.c
@@ -118,8 +118,8 @@ XAABitBlt(
 	    fastExpose = 0;
 	}
     } else {
-	REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
-	REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+	RegionInit(&rgnDst, &fastBox, 1);
+	RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
     }
 
     dstx += pDstDrawable->x;
@@ -128,9 +128,9 @@ XAABitBlt(
     if (pDstDrawable->type == DRAWABLE_WINDOW) {
 	if (!((WindowPtr)pDstDrawable)->realized) {
 	    if (!fastClip)
-		REGION_UNINIT(pGC->pScreen, &rgnDst);
+		RegionUninit(&rgnDst);
 	    if (freeSrcClip)
-		REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+		RegionDestroy(prgnSrcClip);
 	    return NULL;
 	}
     }
@@ -153,8 +153,8 @@ XAABitBlt(
 	   blown region and call intersect */
 
 	cclip = pGC->pCompositeClip;
-        if (REGION_NUM_RECTS(cclip) == 1) {
-	    BoxPtr pBox = REGION_RECTS(cclip);
+        if (RegionNumRects(cclip) == 1) {
+	    BoxPtr pBox = RegionRects(cclip);
 
 	    if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
 	    if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
@@ -163,37 +163,37 @@ XAABitBlt(
 
 	    /* Check to see if the region is empty */
 	    if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
-		REGION_NULL(pGC->pScreen, &rgnDst);
+		RegionNull(&rgnDst);
 	    } else {
-		REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+		RegionInit(&rgnDst, &fastBox, 1);
 	    }
 	} else {
 	    /* We must turn off fastClip now, since we must create
 	       a full blown region.  It is intersected with the
 	       composite clip below. */
 	    fastClip = 0;
-	    REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
+	    RegionInit(&rgnDst, &fastBox,1);
 	}
     } else {
-        REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+        RegionTranslate(&rgnDst, -dx, -dy);
     }
 
     if (!fastClip) {
-	REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+	RegionIntersect(&rgnDst, &rgnDst,
 				 pGC->pCompositeClip);
     }
 
     /* Do bit blitting */
-    numRects = REGION_NUM_RECTS(&rgnDst);
+    numRects = RegionNumRects(&rgnDst);
     if (numRects && width && height) {
 	if(!(pptSrc = (DDXPointPtr)malloc(numRects *
 						  sizeof(DDXPointRec)))) {
-	    REGION_UNINIT(pGC->pScreen, &rgnDst);
+	    RegionUninit(&rgnDst);
 	    if (freeSrcClip)
-		REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+		RegionDestroy(prgnSrcClip);
 	    return NULL;
 	}
-	pbox = REGION_RECTS(&rgnDst);
+	pbox = RegionRects(&rgnDst);
 	ppt = pptSrc;
 	for (i = numRects; --i >= 0; pbox++, ppt++) {
 	    ppt->x = pbox->x1 + dx;
@@ -214,8 +214,8 @@ XAABitBlt(
 				  (int)origSource.height,
 				  origDest.x, origDest.y, bitPlane);
     }
-    REGION_UNINIT(pGC->pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
     if (freeSrcClip)
-	REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+	RegionDestroy(prgnSrcClip);
     return prgnExposed;
 }
diff --git a/hw/xfree86/xaa/xaaCpyArea.c b/hw/xfree86/xaa/xaaCpyArea.c
index 1a03bfd..443a0e1 100644
--- a/hw/xfree86/xaa/xaaCpyArea.c
+++ b/hw/xfree86/xaa/xaaCpyArea.c
@@ -95,8 +95,8 @@ XAADoBitBlt(
                ((pSrc->type == DRAWABLE_WINDOW) &&
                 (pDst->type == DRAWABLE_WINDOW)));
 
-    pbox = REGION_RECTS(prgnDst);
-    nbox = REGION_NUM_RECTS(prgnDst);
+    pbox = RegionRects(prgnDst);
+    nbox = RegionNumRects(prgnDst);
 
     pboxNew1 = NULL;
     pptNew1 = NULL;
@@ -204,8 +204,8 @@ XAADoImageWrite(
     int srcwidth;
     unsigned char* psrcBase;			/* start of image */
     unsigned char* srcPntr;			/* index into the image */
-    BoxPtr pbox = REGION_RECTS(prgnDst);
-    int nbox = REGION_NUM_RECTS(prgnDst);
+    BoxPtr pbox = RegionRects(prgnDst);
+    int nbox = RegionNumRects(prgnDst);
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     int Bpp = pSrc->bitsPerPixel >> 3; 
 
@@ -233,8 +233,8 @@ XAADoImageRead(
     int dstwidth;
     unsigned char* pdstBase;			/* start of image */
     unsigned char* dstPntr;			/* index into the image */
-    BoxPtr pbox = REGION_RECTS(prgnDst);
-    int nbox = REGION_NUM_RECTS(prgnDst);
+    BoxPtr pbox = RegionRects(prgnDst);
+    int nbox = RegionNumRects(prgnDst);
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     int Bpp = pSrc->bitsPerPixel >> 3;  /* wouldn't get here unless both
                                            src and dst have same bpp */
diff --git a/hw/xfree86/xaa/xaaCpyPlane.c b/hw/xfree86/xaa/xaaCpyPlane.c
index e3010ea..6d2b3a0 100644
--- a/hw/xfree86/xaa/xaaCpyPlane.c
+++ b/hw/xfree86/xaa/xaaCpyPlane.c
@@ -76,8 +76,8 @@ XAACopyPlane1toNColorExpand(
     DDXPointPtr   pptSrc )
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-    BoxPtr pbox = REGION_RECTS(rgnDst);
-    int numrects = REGION_NUM_RECTS(rgnDst);
+    BoxPtr pbox = RegionRects(rgnDst);
+    int numrects = RegionNumRects(rgnDst);
     unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
     int srcwidth = ((PixmapPtr)pSrc)->devKind; 
     
@@ -101,8 +101,8 @@ XAACopyPlaneNtoNColorExpand(
     DDXPointPtr   pptSrc 
 ){
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-    BoxPtr pbox = REGION_RECTS(rgnDst);
-    int numrects = REGION_NUM_RECTS(rgnDst);
+    BoxPtr pbox = RegionRects(rgnDst);
+    int numrects = RegionNumRects(rgnDst);
     unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
     unsigned char *data, *srcPtr, *dataPtr;
     int srcwidth = ((PixmapPtr)pSrc)->devKind; 
@@ -168,14 +168,14 @@ XAAPushPixelsSolidColorExpansion(
     int xOrg, int yOrg )
 {
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-   int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
+   int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
    BoxPtr	pbox, pClipBoxes;
    int		nboxes, srcx, srcy;
    xRectangle TheRect;
    unsigned char *src = pBitMap->devPrivate.ptr;
    int srcwidth = pBitMap->devKind;
 
-   if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+   if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
    TheRect.x = xOrg;
diff --git a/hw/xfree86/xaa/xaaCpyWin.c b/hw/xfree86/xaa/xaaCpyWin.c
index d58db8e..c3c2690 100644
--- a/hw/xfree86/xaa/xaaCpyWin.c
+++ b/hw/xfree86/xaa/xaaCpyWin.c
@@ -49,18 +49,18 @@ XAACopyWindow(
 
     pwinRoot = pScreen->root;
 
-    REGION_NULL(pScreen, &rgnDst);
+    RegionNull(&rgnDst);
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
-    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    RegionTranslate(prgnSrc, -dx, -dy);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
-    pbox = REGION_RECTS(&rgnDst);
-    nbox = REGION_NUM_RECTS(&rgnDst);
+    pbox = RegionRects(&rgnDst);
+    nbox = RegionNumRects(&rgnDst);
     if(!nbox || 
       !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
-	REGION_UNINIT(pScreen, &rgnDst);
+	RegionUninit(&rgnDst);
 	return;
     }
     ppt = pptSrc;
@@ -78,5 +78,5 @@ XAACopyWindow(
         		&(infoRec->ScratchGC), &rgnDst, pptSrc);
 
     free(pptSrc);
-    REGION_UNINIT(pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
 }
diff --git a/hw/xfree86/xaa/xaaDashLine.c b/hw/xfree86/xaa/xaaDashLine.c
index 63233e0..e847084 100644
--- a/hw/xfree86/xaa/xaaDashLine.c
+++ b/hw/xfree86/xaa/xaaDashLine.c
@@ -37,8 +37,8 @@ XAAPolyLinesDashed(
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     XAAGCPtr   pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
 						    XAAGetGCKey());
-    BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
-    int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
+    BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+    int nboxInit = RegionNumRects(pGC->pCompositeClip);
     unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
     int xorg = pDrawable->x;
     int yorg = pDrawable->y;
diff --git a/hw/xfree86/xaa/xaaFillArc.c b/hw/xfree86/xaa/xaaFillArc.c
index d83922c..47d8041 100644
--- a/hw/xfree86/xaa/xaaFillArc.c
+++ b/hw/xfree86/xaa/xaaFillArc.c
@@ -171,7 +171,7 @@ XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
 
     cclip = pGC->pCompositeClip;
 
-    if(!REGION_NUM_RECTS(cclip))
+    if(!RegionNumRects(cclip))
 	return;
 
     for (arc = parcs, i = narcs; --i >= 0; arc++)
@@ -198,7 +198,7 @@ XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
  	    y2 = box.y1 + (int)arc->height + 1;
  	    box.y2 = y2;
  	    if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
- 		    (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
+		    (RegionContainsRect(cclip, &box) == rgnIN) )
 	    {
 		if ((arc->angle2 >= FULLCIRCLE) ||
 		    (arc->angle2 <= -FULLCIRCLE))
diff --git a/hw/xfree86/xaa/xaaFillPoly.c b/hw/xfree86/xaa/xaaFillPoly.c
index 6f11e35..289a3ca 100644
--- a/hw/xfree86/xaa/xaaFillPoly.c
+++ b/hw/xfree86/xaa/xaaFillPoly.c
@@ -213,7 +213,7 @@ XAAFillPolygonSolid(
     int		    c, y, maxy, h, yoffset;
     DDXPointPtr	    topPoint;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     if (mode == CoordModePrevious) {
@@ -226,7 +226,7 @@ XAAFillPolygonSolid(
         mode = CoordModeOrigin;
     }
     
-    if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
+    if (RegionNumRects(pGC->pCompositeClip) != 1) {
 	miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
 	return;
     }
@@ -676,7 +676,7 @@ XAAFillPolygonStippled(
     RectFuncPtr	    RectFunc = NULL;
     TrapFuncPtr	    TrapFunc = NULL;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     if (mode == CoordModePrevious) {
@@ -689,7 +689,7 @@ XAAFillPolygonStippled(
         mode = CoordModeOrigin;
     }
     
-    if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
+    if (RegionNumRects(pGC->pCompositeClip) != 1) {
 	miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
 	return;
     }
@@ -836,7 +836,7 @@ XAAFillPolygonTiled(
     RectFuncPtr	    RectFunc = NULL;
     TrapFuncPtr	    TrapFunc = NULL;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     if (mode == CoordModePrevious) {
@@ -849,7 +849,7 @@ XAAFillPolygonTiled(
         mode = CoordModeOrigin;
     }
     
-    if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
+    if (RegionNumRects(pGC->pCompositeClip) != 1) {
 	miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
 	return;
     }
diff --git a/hw/xfree86/xaa/xaaFillRect.c b/hw/xfree86/xaa/xaaFillRect.c
index 0b83ef3..dde31c1 100644
--- a/hw/xfree86/xaa/xaaFillRect.c
+++ b/hw/xfree86/xaa/xaaFillRect.c
@@ -40,7 +40,7 @@ XAAPolyFillRect(
     if((nrectFill <= 0) || !pGC->planemask)
         return;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     switch(pGC->fillStyle) {
@@ -944,8 +944,8 @@ XAAClipAndRenderRects(
     pboxClippedBase = (BoxPtr)infoRec->PreAllocMem;
     pboxClipped = pboxClippedBase;
 
-    if (REGION_NUM_RECTS(pGC->pCompositeClip) == 1) {
-	pextent = REGION_RECTS(pGC->pCompositeClip);
+    if (RegionNumRects(pGC->pCompositeClip) == 1) {
+	pextent = RegionRects(pGC->pCompositeClip);
     	while (nrectFill--) {
 	    pboxClipped->x1 = max(pextent->x1, prect->x);
 	    pboxClipped->y1 = max(pextent->y1, prect->y);
@@ -967,7 +967,7 @@ XAAClipAndRenderRects(
 	    }
     	}
     } else {
-	pextent = REGION_EXTENTS(pGC->pScreen, pGC->pCompositeClip);
+	pextent = RegionExtents(pGC->pCompositeClip);
     	while (nrectFill--) {
 	    int n;
 	    BoxRec box, *pbox;
@@ -986,8 +986,8 @@ XAAClipAndRenderRects(
 	    if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
 	    	continue;
     
-	    n = REGION_NUM_RECTS (pGC->pCompositeClip);
-	    pbox = REGION_RECTS(pGC->pCompositeClip);
+	    n = RegionNumRects (pGC->pCompositeClip);
+	    pbox = RegionRects(pGC->pCompositeClip);
     
 	    /* clip the rectangle to each box in the clip region
 	       this is logically equivalent to calling Intersect()
@@ -1030,8 +1030,8 @@ XAAGetRectClipBoxes(
     xRectangle	*prect = prectInit;
     RegionPtr   prgnClip = pGC->pCompositeClip;
 
-    if (REGION_NUM_RECTS(prgnClip) == 1) {
-	pextent = REGION_RECTS(prgnClip);
+    if (RegionNumRects(prgnClip) == 1) {
+	pextent = RegionRects(prgnClip);
     	while (nrectFill--) {
 	    pboxClipped->x1 = max(pextent->x1, prect->x);
 	    pboxClipped->y1 = max(pextent->y1, prect->y);
@@ -1049,7 +1049,7 @@ XAAGetRectClipBoxes(
 	    }
     	}
     } else {
-	pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+	pextent = RegionExtents(prgnClip);
     	while (nrectFill--) {
 	    int n;
 	    BoxRec box, *pbox;
@@ -1068,8 +1068,8 @@ XAAGetRectClipBoxes(
 	    if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
 	    	continue;
     
-	    n = REGION_NUM_RECTS (prgnClip);
-	    pbox = REGION_RECTS(prgnClip);
+	    n = RegionNumRects (prgnClip);
+	    pbox = RegionRects(prgnClip);
     
 	    /* clip the rectangle to each box in the clip region
 	       this is logically equivalent to calling Intersect()
diff --git a/hw/xfree86/xaa/xaaImage.c b/hw/xfree86/xaa/xaaImage.c
index 30caa2a..e88f45c 100644
--- a/hw/xfree86/xaa/xaaImage.c
+++ b/hw/xfree86/xaa/xaaImage.c
@@ -406,7 +406,7 @@ XAAPutImage(
     Bool depthBug = FALSE;
     if(!w || !h) return;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     depthBug = XAA_DEPTH_BUG(pGC);
@@ -431,7 +431,7 @@ XAAPutImage(
 	     !(infoRec->WriteBitmapFlags & NO_PLANEMASK) &&
 	     !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))){
 
-	int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
+	int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
 	BoxPtr pbox, pClipBoxes;
 	int nboxes, srcx, srcy, srcwidth;
 	xRectangle TheRect;
diff --git a/hw/xfree86/xaa/xaaLine.c b/hw/xfree86/xaa/xaaLine.c
index 7469de1..d6c06eb 100644
--- a/hw/xfree86/xaa/xaaLine.c
+++ b/hw/xfree86/xaa/xaaLine.c
@@ -35,8 +35,8 @@ XAAPolyLines(
 #endif
 ){
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-    BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
-    int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
+    BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+    int nboxInit = RegionNumRects(pGC->pCompositeClip);
     unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
     int xorg = pDrawable->x;
     int yorg = pDrawable->y;
diff --git a/hw/xfree86/xaa/xaaNonTEText.c b/hw/xfree86/xaa/xaaNonTEText.c
index 072fe19..a7fcf7a 100644
--- a/hw/xfree86/xaa/xaaNonTEText.c
+++ b/hw/xfree86/xaa/xaaNonTEText.c
@@ -128,7 +128,7 @@ XAAImageText8NonTEColorExpansion(
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     unsigned long n;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, 
@@ -153,7 +153,7 @@ XAAImageText16NonTEColorExpansion(
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     unsigned long n;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     (*pGC->font->get_glyphs)(
@@ -188,7 +188,7 @@ XAAImageGlyphBltNonTEColorExpansion(
 ){
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     ImageGlyphBltNonTEColorExpansion(
@@ -208,7 +208,7 @@ XAAPolyGlyphBltNonTEColorExpansion(
 ){
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     PolyGlyphBltNonTEColorExpansion(
@@ -368,8 +368,8 @@ ImageGlyphBltNonTEColorExpansion(
     int skippix, skipglyph, width, n, i;
     int Left, Right, Top, Bottom;
     int LeftEdge, RightEdge, ytop, ybot;
-    int nbox = REGION_NUM_RECTS(cclip);
-    BoxPtr pbox = REGION_RECTS(cclip);
+    int nbox = RegionNumRects(cclip);
+    BoxPtr pbox = RegionRects(cclip);
     Bool AlreadySetup = FALSE;
 
     width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
@@ -405,8 +405,8 @@ ImageGlyphBltNonTEColorExpansion(
 	nbox--; pbox++;
     }
  
-    nbox = REGION_NUM_RECTS(cclip);
-    pbox = REGION_RECTS(cclip);
+    nbox = RegionNumRects(cclip);
+    pbox = RegionRects(cclip);
 
     if(infoRec->WriteBitmap && (nglyph > 1) && 
 			((FONTMAXBOUNDS(font, rightSideBearing) - 
@@ -477,8 +477,8 @@ PolyGlyphBltNonTEColorExpansion(
     int skippix, skipglyph, width, n, i;
     int Left, Right, Top, Bottom;
     int LeftEdge, RightEdge;
-    int nbox = REGION_NUM_RECTS(cclip);
-    BoxPtr pbox = REGION_RECTS(cclip);
+    int nbox = RegionNumRects(cclip);
+    BoxPtr pbox = RegionRects(cclip);
 
     width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
 
diff --git a/hw/xfree86/xaa/xaaOverlay.c b/hw/xfree86/xaa/xaaOverlay.c
index 14de9bd..4b52bf6 100644
--- a/hw/xfree86/xaa/xaaOverlay.c
+++ b/hw/xfree86/xaa/xaaOverlay.c
@@ -59,18 +59,18 @@ XAACopyWindow8_32(
     if(doUnderlay)
 	freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
 
-    REGION_NULL(pScreen, &rgnDst);
+    RegionNull(&rgnDst);
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
-    REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc);
+    RegionTranslate(prgnSrc, -dx, -dy);
+    RegionIntersect(&rgnDst, borderClip, prgnSrc);
 
-    pbox = REGION_RECTS(&rgnDst);
-    nbox = REGION_NUM_RECTS(&rgnDst);
+    pbox = RegionRects(&rgnDst);
+    nbox = RegionNumRects(&rgnDst);
     if(!nbox || 
       !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
-	REGION_UNINIT(pScreen, &rgnDst);
+	RegionUninit(&rgnDst);
 	return;
     }
     ppt = pptSrc;
@@ -88,9 +88,9 @@ XAACopyWindow8_32(
         		&(infoRec->ScratchGC), &rgnDst, pptSrc);
 
     free(pptSrc);
-    REGION_UNINIT(pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
     if(freeReg) 
-	REGION_DESTROY(pScreen, borderClip);
+	RegionDestroy(borderClip);
 }
 
 static void
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index b186cb5..61adec6 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -341,18 +341,18 @@ XAAOverCopyWindow(
     infoRec->ScratchGC.alu = GXcopy;
     infoRec->ScratchGC.planemask = ~0;
 
-    REGION_NULL(pScreen, &rgnDst);
+    RegionNull(&rgnDst);
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
-    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    RegionTranslate(prgnSrc, -dx, -dy);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
-    nbox = REGION_NUM_RECTS(&rgnDst);
+    nbox = RegionNumRects(&rgnDst);
     if(nbox &&
 	(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
 
-	pbox = REGION_RECTS(&rgnDst);
+	pbox = RegionRects(&rgnDst);
 	for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
 	    ppt->x = pbox->x1 + dx;
 	    ppt->y = pbox->y1 + dy;
@@ -371,18 +371,18 @@ XAAOverCopyWindow(
 	free(pptSrc);
     }
 
-    REGION_UNINIT(pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
 
     if(pWin->drawable.depth == 8) {
-      REGION_NULL(pScreen, &rgnDst);
+      RegionNull(&rgnDst);
       miSegregateChildren(pWin, &rgnDst, pScrn->depth);
-      if(REGION_NOTEMPTY(pScreen, &rgnDst)) {
-	REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrc);
-	nbox = REGION_NUM_RECTS(&rgnDst);
+      if(RegionNotEmpty(&rgnDst)) {
+	RegionIntersect(&rgnDst, &rgnDst, prgnSrc);
+	nbox = RegionNumRects(&rgnDst);
 	if(nbox &&
 	  (pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))){
 
-	    pbox = REGION_RECTS(&rgnDst);
+	    pbox = RegionRects(&rgnDst);
 	    for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
 		ppt->x = pbox->x1 + dx;
 		ppt->y = pbox->y1 + dy;
@@ -394,7 +394,7 @@ XAAOverCopyWindow(
 	    free(pptSrc);
 	}
       }
-      REGION_UNINIT(pScreen, &rgnDst);
+      RegionUninit(&rgnDst);
     }
 }
 
@@ -409,13 +409,13 @@ XAAOverWindowExposures(
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
 
     if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) {
-	if(REGION_NUM_RECTS(pReg) && infoRec->FillSolidRects) {
+	if(RegionNumRects(pReg) && infoRec->FillSolidRects) {
 	    XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
 
 	    SWITCH_DEPTH(8);
 	    (*infoRec->FillSolidRects)(infoRec->pScrn, 
 		infoRec->pScrn->colorKey, GXcopy, ~0,
-			REGION_NUM_RECTS(pReg), REGION_RECTS(pReg));
+			RegionNumRects(pReg), RegionRects(pReg));
 	    miWindowExposures(pWin, pReg, pOtherReg);
 	    return;
 	} else if(infoRec->NeedToSync) {
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index 598a1be..f7f6a29 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -639,8 +639,8 @@ XAAInitPixmapCache(
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    XAAInfoRecPtr infoRec = (XAAInfoRecPtr)data;
    XAAPixmapCachePrivatePtr pCachePriv;
-   BoxPtr pBox = REGION_RECTS(areas);
-   int nBox = REGION_NUM_RECTS(areas);
+   BoxPtr pBox = RegionRects(areas);
+   int nBox = RegionNumRects(areas);
    int Num512, Num256, Num128, NumPartial, NumColor, NumMono;
    int Target512, Target256;
    CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono;
diff --git a/hw/xfree86/xaa/xaaPict.c b/hw/xfree86/xaa/xaaPict.c
index 38ef21e..aaafacb 100644
--- a/hw/xfree86/xaa/xaaPict.c
+++ b/hw/xfree86/xaa/xaaPict.c
@@ -215,7 +215,7 @@ XAADoComposite (
     BoxPtr pbox;
     int nbox, w, h;
 
-    if(!REGION_NUM_RECTS(pDst->pCompositeClip))
+    if(!RegionNumRects(pDst->pCompositeClip))
         return TRUE;
 
     if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable))
@@ -273,8 +273,8 @@ XAADoComposite (
                                    width, height))
 		      return TRUE;
 		      
-	  	nbox = REGION_NUM_RECTS(&region);
-	  	pbox = REGION_RECTS(&region);   
+		nbox = RegionNumRects(&region);
+		pbox = RegionRects(&region);
 		
 	        if(!nbox)
 		    return TRUE;	
@@ -298,7 +298,7 @@ XAADoComposite (
 	   	}
 				  
 		/* WriteBitmap sets the Sync flag */		  
-	        REGION_UNINIT(pScreen, &region);
+	        RegionUninit(&region);
 		return TRUE;
 	  }
 
@@ -340,11 +340,11 @@ XAADoComposite (
                                    width, height))
 		return TRUE;
 
-	  nbox = REGION_NUM_RECTS(&region);
-	  pbox = REGION_RECTS(&region);   
+	  nbox = RegionNumRects(&region);
+	  pbox = RegionRects(&region);
 	     
 	  if(!nbox) {
-                REGION_UNINIT(pScreen, &region);
+                RegionUninit(&region);
 		return TRUE;
 	  }
 
@@ -355,7 +355,7 @@ XAADoComposite (
 			((PixmapPtr)(pMask->pDrawable))->devKind, 
 			w, h, flags))
 	  {
-                REGION_UNINIT(pScreen, &region);
+                RegionUninit(&region);
 		return FALSE;
 	  }
 
@@ -371,7 +371,7 @@ XAADoComposite (
 	   }
 
 	   SET_SYNC_FLAG(infoRec);
-	   REGION_UNINIT(pScreen, &region);
+	   RegionUninit(&region);
 	   return TRUE;
 	}
     } else {
@@ -409,11 +409,11 @@ XAADoComposite (
                                    width, height))
 		return TRUE;
 
-	nbox = REGION_NUM_RECTS(&region);
-	pbox = REGION_RECTS(&region);   
+	nbox = RegionNumRects(&region);
+	pbox = RegionRects(&region);
 	     
         if(!nbox) {
-             REGION_UNINIT(pScreen, &region);
+             RegionUninit(&region);
              return TRUE;
         }
 
@@ -423,7 +423,7 @@ XAADoComposite (
 			((PixmapPtr)(pSrc->pDrawable))->devKind, 
 			w, h, flags))
         {
-              REGION_UNINIT(pScreen, &region);
+              RegionUninit(&region);
               return FALSE;
         }
 
@@ -440,7 +440,7 @@ XAADoComposite (
 	 }
 
 	SET_SYNC_FLAG(infoRec);
-	REGION_UNINIT(pScreen, &region);
+	RegionUninit(&region);
 	return TRUE;
     }
 
@@ -476,16 +476,16 @@ XAACompositeSrcCopy (PicturePtr pSrc,
 				   width, height))
 	return;
 
-    nbox = REGION_NUM_RECTS(&region);
-    pbox = REGION_RECTS(&region);   
+    nbox = RegionNumRects(&region);
+    pbox = RegionRects(&region);
 
     if(!nbox) {
-	REGION_UNINIT(pScreen, &region);
+	RegionUninit(&region);
 	return;
     }
     pptSrc = malloc(sizeof(DDXPointRec) * nbox);
     if (!pptSrc) {
-	REGION_UNINIT(pScreen, &region);
+	RegionUninit(&region);
 	return;
     }
     xoff = xSrc - xDst;
@@ -502,7 +502,7 @@ XAACompositeSrcCopy (PicturePtr pSrc,
 		pptSrc);
 
     free(pptSrc);
-    REGION_UNINIT(pScreen, &region);
+    RegionUninit(&region);
     return;
 }
 
@@ -588,7 +588,7 @@ XAADoGlyphs (CARD8         op,
     ScreenPtr	pScreen = pDst->pDrawable->pScreen;
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
 
-    if(!REGION_NUM_RECTS(pDst->pCompositeClip))
+    if(!RegionNumRects(pDst->pCompositeClip))
 	return TRUE;
 
     if(!infoRec->pScrn->vtSema || 
diff --git a/hw/xfree86/xaa/xaaRect.c b/hw/xfree86/xaa/xaaRect.c
index 0a7e174..4a39129 100644
--- a/hw/xfree86/xaa/xaaRect.c
+++ b/hw/xfree86/xaa/xaaRect.c
@@ -46,8 +46,8 @@ XAAPolyRectangleThinSolid(
     int         clipYMax;       /* lower right corner of clip rect */
     int         width, height;  /* width and height of rect */
 
-    nClipRects = REGION_NUM_RECTS(pGC->pCompositeClip);
-    pClipRects = REGION_RECTS(pGC->pCompositeClip);
+    nClipRects = RegionNumRects(pGC->pCompositeClip);
+    pClipRects = RegionRects(pGC->pCompositeClip);
 
     if(!nClipRects) return;
 
diff --git a/hw/xfree86/xaa/xaaSpans.c b/hw/xfree86/xaa/xaaSpans.c
index 46d6d07..a742cba 100644
--- a/hw/xfree86/xaa/xaaSpans.c
+++ b/hw/xfree86/xaa/xaaSpans.c
@@ -49,7 +49,7 @@ XAAFillSpans(
     if((nInit <= 0) || !pGC->planemask)
         return;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     switch(pGC->fillStyle) {
@@ -117,7 +117,7 @@ XAAFillSpans(
     }
 
 
-    if((nInit < 10) || (REGION_NUM_RECTS(pGC->pCompositeClip) != 1))
+    if((nInit < 10) || (RegionNumRects(pGC->pCompositeClip) != 1))
 	fastClip = FALSE;
 
     if(fastClip) {
@@ -797,10 +797,10 @@ XAAClipAndRenderSpans(
     pptNew = pptBase;
     pwidthNew = pwidthBase;
 
-    numRects = REGION_NUM_RECTS(pGC->pCompositeClip);
+    numRects = RegionNumRects(pGC->pCompositeClip);
 
     if(numRects == 1) {
-        BoxPtr pextent = REGION_RECTS(pGC->pCompositeClip);
+        BoxPtr pextent = RegionRects(pGC->pCompositeClip);
 	    
 	while(nspans--) {
 	    if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) {
@@ -830,7 +830,7 @@ XAAClipAndRenderSpans(
 
 	while(nspans--) {
 	    nbox = numRects;
-	    pbox = REGION_RECTS(pGC->pCompositeClip);
+	    pbox = RegionRects(pGC->pCompositeClip);
 
 	    /* find the first band */
 	    while(nbox && (pbox->y2 <= ppt->y)) {
diff --git a/hw/xfree86/xaa/xaaTEText.c b/hw/xfree86/xaa/xaaTEText.c
index b182283..729e8a8 100644
--- a/hw/xfree86/xaa/xaaTEText.c
+++ b/hw/xfree86/xaa/xaaTEText.c
@@ -110,7 +110,7 @@ XAAImageText8TEColorExpansion(
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     unsigned long n;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, 
@@ -134,7 +134,7 @@ XAAImageText16TEColorExpansion(
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
     unsigned long n;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     (*pGC->font->get_glyphs)(
@@ -169,7 +169,7 @@ XAAImageGlyphBltTEColorExpansion(
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     XAAGlyphBltTEColorExpansion(
@@ -189,7 +189,7 @@ XAAPolyGlyphBltTEColorExpansion(
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
     XAAGlyphBltTEColorExpansion(
@@ -229,8 +229,8 @@ XAAGlyphBltTEColorExpansion(
     int skippix, skipglyphs;
     int Left, Right, Top, Bottom;
     int LeftEdge, RightEdge, ytop, ybot;
-    int nbox = REGION_NUM_RECTS(cclip);
-    BoxPtr pbox = REGION_RECTS(cclip);
+    int nbox = RegionNumRects(cclip);
+    BoxPtr pbox = RegionRects(cclip);
     unsigned int **glyphs = NULL; 
     int glyphWidth = FONTMAXBOUNDS(font, characterWidth);
 
diff --git a/hw/xfree86/xaa/xaaWideLine.c b/hw/xfree86/xaa/xaaWideLine.c
index a684d66..79a6159 100644
--- a/hw/xfree86/xaa/xaaWideLine.c
+++ b/hw/xfree86/xaa/xaaWideLine.c
@@ -804,10 +804,10 @@ XAAPolylinesWideSolid (
     int		    yorg = pDrawable->y;
     Bool	    hardClip = FALSE;
 
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+    if(!RegionNumRects(pGC->pCompositeClip))
 	return;
 
-    if(REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
+    if(RegionNumRects(pGC->pCompositeClip) != 1) {
 	miWideLine(pDrawable, pGC, mode, npt, pPts);
 	return;
     }
diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h
index 86ba003..3f3c261 100644
--- a/hw/xfree86/xaa/xaawrap.h
+++ b/hw/xfree86/xaa/xaawrap.h
@@ -32,7 +32,7 @@
 #define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\
     XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
     GCFuncs *oldFuncs = pGC->funcs;\
-    if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \
+    if(!RegionNumRects(pGC->pCompositeClip)) return; \
     pGC->funcs = pGCPriv->wrapFuncs;\
     pGC->ops = pGCPriv->wrapOps
 
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 277718b..194ec63 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -93,7 +93,7 @@ xnestCollectExposures(void)
       Box.x2 = Box.x1 + X.xexpose.width;
       Box.y2 = Box.y1 + X.xexpose.height;
       
-      REGION_INIT(pWin->drawable.pScreen, &Rgn, &Box, 1);
+      RegionInit(&Rgn, &Box, 1);
       
       miSendExposures(pWin, &Rgn, Box.x2, Box.y2);
     }
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index 4082bfc..2cd555c 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -210,10 +210,10 @@ xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects)
       break;
       
     case CT_REGION:
-      nRects = REGION_NUM_RECTS((RegionPtr)pValue);
+      nRects = RegionNumRects((RegionPtr)pValue);
       size = nRects * sizeof(*pRects);
       pRects = (XRectangle *) malloc(size);
-      pBox = REGION_RECTS((RegionPtr)pValue);
+      pBox = RegionRects((RegionPtr)pValue);
       for (i = nRects; i-- > 0; ) {
 	pRects[i].x = pBox[i].x1;
 	pRects[i].y = pBox[i].y1;
@@ -277,7 +277,7 @@ xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects)
        * other parts of server can only deal with CT_NONE,
        * CT_PIXMAP and CT_REGION client clips.
        */
-      pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nRects,
+      pGC->clientClip = (pointer) RegionFromRects(nRects,
 						  (xRectangle *)pValue, type);
       free(pValue);
       pValue = pGC->clientClip;
@@ -313,7 +313,7 @@ xnestDestroyClipHelper(GCPtr pGC)
       break;
       
     case CT_REGION:
-      REGION_DESTROY(pGC->pScreen, pGC->clientClip); 
+      RegionDestroy(pGC->clientClip);
       break;
     }
 }
@@ -331,8 +331,8 @@ xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
       break;
 
     case CT_REGION:
-      pRgn = REGION_CREATE(pGCDst->pScreen, NULL, 1);
-      REGION_COPY(pGCDst->pScreen, pRgn, pGCSrc->clientClip);
+      pRgn = RegionCreate(NULL, 1);
+      RegionCopy(pRgn, pGCSrc->clientClip);
       xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);
       break;
     }
diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c
index ad9668e..6b76fc2 100644
--- a/hw/xnest/GCOps.c
+++ b/hw/xnest/GCOps.c
@@ -131,8 +131,8 @@ xnestBitBlitHelper(GCPtr pGC)
     BoxRec Box;
     Bool pending, overlap;
 
-    pReg = REGION_CREATE(pGC->pScreen, NULL, 1);
-    pTmpReg = REGION_CREATE(pGC->pScreen, NULL, 1);
+    pReg = RegionCreate(NULL, 1);
+    pTmpReg = RegionCreate(NULL, 1);
     if(!pReg || !pTmpReg) return NullRegion;
     
     pending = True;
@@ -149,15 +149,15 @@ xnestBitBlitHelper(GCPtr pGC)
 	Box.y1 = event.xgraphicsexpose.y;
 	Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width;
 	Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height;
-	REGION_RESET(pGC->pScreen, pTmpReg, &Box);
-	REGION_APPEND(pGC->pScreen, pReg, pTmpReg);
+	RegionReset(pTmpReg, &Box);
+	RegionAppend(pReg, pTmpReg);
 	pending = event.xgraphicsexpose.count;
 	break;
       }
     }
 
-    REGION_DESTROY(pGC->pScreen, pTmpReg);
-    REGION_VALIDATE(pGC->pScreen, pReg, &overlap);
+    RegionDestroy(pTmpReg);
+    RegionValidate(pReg, &overlap);
     return(pReg);
   }
 }
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index 583f877..bf06480 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -97,8 +97,8 @@ xnestPixmapToRegion(PixmapPtr pPixmap)
 		     pPixmap->drawable.width, pPixmap->drawable.height,
 		     1, XYPixmap);
   
-  pReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
-  pTmpReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
+  pReg = RegionCreate(NULL, 1);
+  pTmpReg = RegionCreate(NULL, 1);
   if(!pReg || !pTmpReg) {
       XDestroyImage(ximage);
       return NullRegion;
@@ -118,8 +118,8 @@ xnestPixmapToRegion(PixmapPtr pPixmap)
 	else if (currentPixel == 0L) {
 	  /* right edge */
 	  Box.x2 = x;
-	  REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
-	  REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
+	  RegionReset(pTmpReg, &Box);
+	  RegionAppend(pReg, pTmpReg);
 	}
 	previousPixel = currentPixel;
       }
@@ -127,15 +127,15 @@ xnestPixmapToRegion(PixmapPtr pPixmap)
     if (previousPixel != 0L) {
       /* right edge because of the end of pixmap */
       Box.x2 = pPixmap->drawable.width;
-      REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
-      REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
+      RegionReset(pTmpReg, &Box);
+      RegionAppend(pReg, pTmpReg);
     }
   }
   
-  REGION_DESTROY(pPixmap->drawable.pScreen, pTmpReg);
+  RegionDestroy(pTmpReg);
   XDestroyImage(ximage);
 
-  REGION_VALIDATE(pPixmap->drawable.pScreen, pReg, &overlap);
+  RegionValidate(pReg, &overlap);
 
   return(pReg);
 }
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index 11d5369..fab2f39 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -135,9 +135,9 @@ xnestCreateWindow(WindowPtr pWin)
   if (pWin->nextSib)
     xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin);
   xnestWindowPriv(pWin)->bounding_shape = 
-    REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+    RegionCreate(NULL, 1);
   xnestWindowPriv(pWin)->clip_shape = 
-    REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+    RegionCreate(NULL, 1);
 
   if (!pWin->parent) /* only the root window will have the right colormap */
     xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
@@ -151,9 +151,9 @@ xnestDestroyWindow(WindowPtr pWin)
   if (pWin->nextSib)
     xnestWindowPriv(pWin->nextSib)->sibling_above = 
       xnestWindowPriv(pWin)->sibling_above;
-  REGION_DESTROY(pWin->drawable.pScreen, 
+  RegionDestroy(
 				xnestWindowPriv(pWin)->bounding_shape);
-  REGION_DESTROY(pWin->drawable.pScreen, 
+  RegionDestroy(
 				xnestWindowPriv(pWin)->clip_shape);
   XDestroyWindow(xnestDisplay, xnestWindow(pWin));
   xnestWindowPriv(pWin)->window = None;
@@ -415,7 +415,7 @@ xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed)
 	
     event.xexpose.type = ProcessedExpose;
 	
-    if (RECT_IN_REGION(pWin->drawable.pScreen, pRgn, &Box) != rgnIN)
+    if (RegionContainsRect(pRgn, &Box) != rgnIN)
       XPutBackEvent(xnestDisplay, &event);
   }
   
@@ -439,11 +439,11 @@ xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
 
   if (pReg1 == NullRegion || pReg2 == NullRegion) return False;
 
-  pBox1 = REGION_RECTS(pReg1);
-  n1 = REGION_NUM_RECTS(pReg1);
+  pBox1 = RegionRects(pReg1);
+  n1 = RegionNumRects(pReg1);
 
-  pBox2 = REGION_RECTS(pReg2);
-  n2 = REGION_NUM_RECTS(pReg2);
+  pBox2 = RegionRects(pReg2);
+  n2 = RegionNumRects(pReg2);
 
   if (n1 != n2) return False;
 
@@ -466,13 +466,13 @@ xnestShapeWindow(WindowPtr pWin)
 			wBoundingShape(pWin))) {
     
     if (wBoundingShape(pWin)) {
-      REGION_COPY(pWin->drawable.pScreen, 
+      RegionCopy(
 		xnestWindowPriv(pWin)->bounding_shape, wBoundingShape(pWin));
       
       reg = XCreateRegion();
-      pBox = REGION_RECTS(xnestWindowPriv(pWin)->bounding_shape);
+      pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape);
       for (i = 0; 
-	   i < REGION_NUM_RECTS(xnestWindowPriv(pWin)->bounding_shape);
+	   i < RegionNumRects(xnestWindowPriv(pWin)->bounding_shape);
 	   i++) {
         rect.x = pBox[i].x1;
         rect.y = pBox[i].y1;
@@ -485,7 +485,7 @@ xnestShapeWindow(WindowPtr pWin)
       XDestroyRegion(reg);
     }
     else {
-      REGION_EMPTY(pWin->drawable.pScreen, 
+      RegionEmpty(
 				xnestWindowPriv(pWin)->bounding_shape);
       
       XShapeCombineMask(xnestDisplay, xnestWindow(pWin),
@@ -497,13 +497,13 @@ xnestShapeWindow(WindowPtr pWin)
 			wClipShape(pWin))) {
     
     if (wClipShape(pWin)) {
-      REGION_COPY(pWin->drawable.pScreen, 
+      RegionCopy(
 			xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin));
       
       reg = XCreateRegion();
-      pBox = REGION_RECTS(xnestWindowPriv(pWin)->clip_shape);
+      pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape);
       for (i = 0; 
-	   i < REGION_NUM_RECTS(xnestWindowPriv(pWin)->clip_shape);
+	   i < RegionNumRects(xnestWindowPriv(pWin)->clip_shape);
 	   i++) {
         rect.x = pBox[i].x1;
         rect.y = pBox[i].y1;
@@ -516,7 +516,7 @@ xnestShapeWindow(WindowPtr pWin)
       XDestroyRegion(reg);
     }
     else {
-      REGION_EMPTY(pWin->drawable.pScreen, 
+      RegionEmpty(
 				     xnestWindowPriv(pWin)->clip_shape);
       
       XShapeCombineMask(xnestDisplay, xnestWindow(pWin),
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 7453ecc..1d99d36 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -817,8 +817,8 @@ xf86SetRootClip (ScreenPtr pScreen, int enable)
 	    {
 		RegionPtr	borderVisible;
 
-		borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
+		borderVisible = RegionCreate(NullBox, 1);
+		RegionSubtract(borderVisible,
 				&pWin->borderClip, &pWin->winSize);
 		pWin->valdata->before.borderVisible = borderVisible;
 	    }
@@ -837,13 +837,13 @@ xf86SetRootClip (ScreenPtr pScreen, int enable)
 	box.y1 = 0;
 	box.x2 = pScreen->width;
 	box.y2 = pScreen->height;
-	REGION_RESET(pScreen, &pWin->borderClip, &box);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+	RegionReset(&pWin->borderClip, &box);
+	RegionBreak(&pWin->clipList);
     }
     else
     {
-	REGION_EMPTY(pScreen, &pWin->borderClip);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+	RegionEmpty(&pWin->borderClip);
+	RegionBreak(&pWin->clipList);
     }
 
     ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
@@ -852,8 +852,8 @@ xf86SetRootClip (ScreenPtr pScreen, int enable)
     {
 	if (pWin->backStorage)
 	{
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+	    pOldClip = RegionCreate(NullBox, 1);
+	    RegionCopy(pOldClip, &pWin->clipList);
 	}
 
 	if (pWin->firstChild)
@@ -882,7 +882,7 @@ xf86SetRootClip (ScreenPtr pScreen, int enable)
 			     (pWin, 0, 0, pOldClip,
 			      pWin->drawable.x, pWin->drawable.y);
 	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
+	    RegionDestroy(pOldClip);
 	if (bsExposed)
 	{
 	    RegionPtr	valExposed = NullRegion;
@@ -891,8 +891,8 @@ xf86SetRootClip (ScreenPtr pScreen, int enable)
 		valExposed = &pWin->valdata->after.exposed;
 	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
 	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
+		RegionEmpty(valExposed);
+	    RegionDestroy(bsExposed);
 	}
     }
     if (WasViewable)
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 3b14581..d9b2e03 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -347,8 +347,8 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
         wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
         wc.bit_gravity = XP_GRAVITY_NONE;
 
-        wc.shape_nrects = REGION_NUM_RECTS(&pWin->clipList);
-        wc.shape_rects = REGION_RECTS(&pWin->clipList);
+        wc.shape_nrects = RegionNumRects(&pWin->clipList);
+        wc.shape_rects = RegionRects(&pWin->clipList);
         wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
         wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
 
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 6dc2c87..9f5d8a6 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -163,8 +163,8 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
 
     if (pShape != NULL)
     {
-        wc.shape_nrects = REGION_NUM_RECTS(pShape);
-        wc.shape_rects = REGION_RECTS(pShape);
+        wc.shape_nrects = RegionNumRects(pShape);
+        wc.shape_rects = RegionRects(pShape);
         wc.shape_tx = wc.shape_ty = 0;
         mask |= XP_SHAPE;
     }
@@ -306,8 +306,8 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
     
     if (pShape != NULL)
     {
-        wc.shape_nrects = REGION_NUM_RECTS(pShape);
-        wc.shape_rects = REGION_RECTS(pShape);
+        wc.shape_nrects = RegionNumRects(pShape);
+        wc.shape_rects = RegionRects(pShape);
     }
     else
     {
diff --git a/hw/xwin/winfillsp.c b/hw/xwin/winfillsp.c
index 702f34f..1e8e3e6 100644
--- a/hw/xwin/winfillsp.c
+++ b/hw/xwin/winfillsp.c
@@ -80,8 +80,8 @@ winFillSpansNativeGDI (DrawablePtr	pDrawable,
   int		    	fullX1, fullX2, fullY1;
   HRGN			hrgn = NULL, combined = NULL;
 
-  nbox = REGION_NUM_RECTS (pClip);
-  pbox = REGION_RECTS (pClip);
+  nbox = RegionNumRects (pClip);
+  pbox = RegionRects (pClip);
 
   if (!nbox) return;
 
@@ -97,7 +97,7 @@ winFillSpansNativeGDI (DrawablePtr	pDrawable,
       pbox++;
     }
 
-  pextent = REGION_EXTENTS (pGC->pScreen, pClip);
+  pextent = RegionExtents(pClip);
   extentX1 = pextent->x1;
   extentY1 = pextent->y1;
   extentX2 = pextent->x2;
diff --git a/hw/xwin/wingc.c b/hw/xwin/wingc.c
index 1f37752..196b5b5 100644
--- a/hw/xwin/wingc.c
+++ b/hw/xwin/wingc.c
@@ -210,7 +210,7 @@ winDestroyGCNativeGDI (GCPtr pGC)
   winScreenPriv(pGC->pScreen);
 
   if (pGC->freeCompClip)
-	REGION_DESTROY (pGC->pScreen, pGC->pCompositeClip);
+	RegionDestroy(pGC->pCompositeClip);
 
   /* Free the memory DC */
   if (pGCPriv->hdcMem != NULL)
diff --git a/hw/xwin/winmultiwindowshape.c b/hw/xwin/winmultiwindowshape.c
index 597eab6..9b4910b 100644
--- a/hw/xwin/winmultiwindowshape.c
+++ b/hw/xwin/winmultiwindowshape.c
@@ -117,15 +117,15 @@ winReshapeMultiWindow (WindowPtr pWin)
   if (!wBoundingShape (pWin))
     return;
 
-  REGION_NULL(pWin->drawable.pScreen, &rrNewShape);
-  REGION_COPY(pWin->drawable.pScreen, &rrNewShape, wBoundingShape(pWin));
-  REGION_TRANSLATE(pWin->drawable.pScreen,
+  RegionNull(&rrNewShape);
+  RegionCopy(&rrNewShape, wBoundingShape(pWin));
+  RegionTranslate(
 		   &rrNewShape,
 		   pWin->borderWidth,
                    pWin->borderWidth);
   
-  nRects = REGION_NUM_RECTS(&rrNewShape);
-  pShape = REGION_RECTS(&rrNewShape);
+  nRects = RegionNumRects(&rrNewShape);
+  pShape = RegionRects(&rrNewShape);
   
   /* Don't do anything if there are no rectangles in the region */
   if (nRects > 0)
@@ -205,7 +205,7 @@ winReshapeMultiWindow (WindowPtr pWin)
       pWinPriv->hRgn = hRgn;
     }
 
-  REGION_UNINIT(pWin->drawable.pScreen, &rrNewShape);
+  RegionUninit(&rrNewShape);
   
   return;
 }
diff --git a/hw/xwin/winsetsp.c b/hw/xwin/winsetsp.c
index f894d6c..d1bf90b 100644
--- a/hw/xwin/winsetsp.c
+++ b/hw/xwin/winsetsp.c
@@ -54,8 +54,8 @@ winSetSpansNativeGDI (DrawablePtr	pDrawable,
   int			nbox;
   BoxPtr	 	pbox;
 
-  nbox = REGION_NUM_RECTS (pGC->pCompositeClip);
-  pbox = REGION_RECTS (pGC->pCompositeClip);
+  nbox = RegionNumRects (pGC->pCompositeClip);
+  pbox = RegionRects (pGC->pCompositeClip);
 
   if (!nbox) return;
 
diff --git a/hw/xwin/winshaddd.c b/hw/xwin/winshaddd.c
index 85dc10f..8dd1084 100644
--- a/hw/xwin/winshaddd.c
+++ b/hw/xwin/winshaddd.c
@@ -525,8 +525,8 @@ winShadowUpdateDD (ScreenPtr pScreen,
   HRESULT		ddrval = DD_OK;
   RECT			rcDest, rcSrc;
   POINT			ptOrigin;
-  DWORD			dwBox = REGION_NUM_RECTS (damage);
-  BoxPtr		pBox = REGION_RECTS (damage);
+  DWORD			dwBox = RegionNumRects (damage);
+  BoxPtr		pBox = RegionRects (damage);
   HRGN			hrgnTemp = NULL, hrgnCombined = NULL;
 
   /*
@@ -588,7 +588,7 @@ winShadowUpdateDD (ScreenPtr pScreen,
     }
   else
     {
-      BoxPtr		pBoxExtents = REGION_EXTENTS (pScreen, damage);
+      BoxPtr		pBoxExtents = RegionExtents(damage);
 
       /* Compute a GDI region from the damaged region */
       hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c
index e78fbd9..5ca3e4f 100644
--- a/hw/xwin/winshadddnl.c
+++ b/hw/xwin/winshadddnl.c
@@ -601,8 +601,8 @@ winShadowUpdateDDNL (ScreenPtr pScreen,
   HRESULT		ddrval = DD_OK;
   RECT			rcDest, rcSrc;
   POINT			ptOrigin;
-  DWORD			dwBox = REGION_NUM_RECTS (damage);
-  BoxPtr		pBox = REGION_RECTS (damage);
+  DWORD			dwBox = RegionNumRects (damage);
+  BoxPtr		pBox = RegionRects (damage);
   HRGN			hrgnTemp = NULL, hrgnCombined = NULL;
 
   /*
@@ -677,7 +677,7 @@ winShadowUpdateDDNL (ScreenPtr pScreen,
     }
   else
     {
-      BoxPtr		pBoxExtents = REGION_EXTENTS (pScreen, damage);
+      BoxPtr		pBoxExtents = RegionExtents(damage);
 
       /* Compute a GDI region from the damaged region */
       hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c
index d38e4f7..96d149c 100644
--- a/hw/xwin/winshadgdi.c
+++ b/hw/xwin/winshadgdi.c
@@ -499,8 +499,8 @@ winShadowUpdateGDI (ScreenPtr pScreen,
   winScreenPriv(pScreen);
   winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
   RegionPtr		damage = shadowDamage(pBuf);
-  DWORD			dwBox = REGION_NUM_RECTS (damage);
-  BoxPtr		pBox = REGION_RECTS (damage);
+  DWORD			dwBox = RegionNumRects (damage);
+  BoxPtr		pBox = RegionRects (damage);
   int			x, y, w, h;
   HRGN			hrgnTemp = NULL, hrgnCombined = NULL;
 #ifdef XWIN_UPDATESTATS
@@ -508,7 +508,7 @@ winShadowUpdateGDI (ScreenPtr pScreen,
   static DWORD		s_dwTotalUpdates = 0;
   static DWORD		s_dwTotalBoxes = 0;
 #endif
-  BoxPtr		pBoxExtents = REGION_EXTENTS (pScreen, damage);
+  BoxPtr		pBoxExtents = RegionExtents(damage);
 
   /*
    * Return immediately if the app is not active
diff --git a/hw/xwin/winvideo.c b/hw/xwin/winvideo.c
index 4cdb3c4..0438e5f 100755
--- a/hw/xwin/winvideo.c
+++ b/hw/xwin/winvideo.c
@@ -185,7 +185,7 @@ winSetupImageVideo (ScreenPtr pScreen)
 
 #if 0
     /* gotta uninit this someplace */
-    REGION_NULL(pScreen, &pPriv->clip);
+    RegionNull(&pPriv->clip);
 #endif
 
 #if 0
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index c225a44..9749861 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -150,8 +150,8 @@ winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
 
   if (pShape == NULL) return NULL;
 
-  nRects = REGION_NUM_RECTS(pShape);
-  pRects = REGION_RECTS(pShape);
+  nRects = RegionNumRects(pShape);
+  pRects = RegionRects(pShape);
   
   hRgn = CreateRectRgn (0, 0, 0, 0);
   if (hRgn == NULL)
diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c
index 9348d5c..bc0614d 100644
--- a/hw/xwin/winwindow.c
+++ b/hw/xwin/winwindow.c
@@ -147,22 +147,22 @@ winCopyWindowNativeGDI (WindowPtr pWin,
   pwinRoot = pWin->drawable.pScreen->root;
 
   /* Create a region for the destination */
-  prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+  prgnDst = RegionCreate(NULL, 1);
 
   /* Calculate the shift from the source to the destination */
   dx = ptOldOrg.x - pWin->drawable.x;
   dy = ptOldOrg.y - pWin->drawable.y;
 
   /* Translate the region from the destination to the source? */
-  REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
-  REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
+  RegionTranslate(prgnSrc, -dx, -dy);
+  RegionIntersect(prgnDst, &pWin->borderClip,
 		   prgnSrc);
 
   /* Get a pointer to the first box in the region to be copied */
-  pBox = REGION_RECTS(prgnDst);
+  pBox = RegionRects(prgnDst);
   
   /* Get the number of boxes in the region */
-  nbox = REGION_NUM_RECTS(prgnDst);
+  nbox = RegionNumRects(prgnDst);
 
   /* Allocate source points for each box */
   if(!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec))))
@@ -179,7 +179,7 @@ winCopyWindowNativeGDI (WindowPtr pWin,
     }
 
   /* Setup loop pointers again */
-  pBoxDst = REGION_RECTS(prgnDst);
+  pBoxDst = RegionRects(prgnDst);
   ppt = pptSrc;
 
 #if 0
@@ -205,7 +205,7 @@ winCopyWindowNativeGDI (WindowPtr pWin,
 
   /* Cleanup the regions, etc. */
   free(pptSrc);
-  REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+  RegionDestroy(prgnDst);
 }
 
 
@@ -593,13 +593,13 @@ winReshapeRootless (WindowPtr pWin)
   if (!wBoundingShape (pWin))
     return;
 
-  REGION_NULL(pScreen, &rrNewShape);
-  REGION_COPY(pScreen, &rrNewShape, wBoundingShape(pWin));
-  REGION_TRANSLATE(pScreen, &rrNewShape, pWin->borderWidth,
+  RegionNull(&rrNewShape);
+  RegionCopy(&rrNewShape, wBoundingShape(pWin));
+  RegionTranslate(&rrNewShape, pWin->borderWidth,
                    pWin->borderWidth);
   
-  nRects = REGION_NUM_RECTS(&rrNewShape);
-  pShape = REGION_RECTS(&rrNewShape);
+  nRects = RegionNumRects(&rrNewShape);
+  pShape = RegionRects(&rrNewShape);
   
   if (nRects > 0)
     {
@@ -631,7 +631,7 @@ winReshapeRootless (WindowPtr pWin)
       pWinPriv->hRgn = hRgn;
     }
 
-  REGION_UNINIT(pScreen, &rrNewShape);
+  RegionUninit(&rrNewShape);
   
   return;
 }
diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index 99329c3..5935ac4 100755
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -495,11 +495,11 @@ ProcWindowsWMFrameDraw (register ClientPtr client)
       /* wBoundingShape is relative to *inner* origin of window.
 	 Translate by borderWidth to get the outside-relative position. */
       
-      REGION_NULL(pScreen, &newShape);
-      REGION_COPY(pScreen, &newShape, wBoundingShape(pWin));
-      REGION_TRANSLATE(pScreen, &newShape, pWin->borderWidth, pWin->borderWidth);
+      RegionNull(&newShape);
+      RegionCopy(&newShape, wBoundingShape(pWin));
+      RegionTranslate(&newShape, pWin->borderWidth, pWin->borderWidth);
       winMWExtWMReshapeFrame (pRLWinPriv, &newShape);
-      REGION_UNINIT(pScreen, &newShape);
+      RegionUninit(&newShape);
     }
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("ProcWindowsWMFrameDraw - done\n");
diff --git a/include/regionstr.h b/include/regionstr.h
index 89cf024..c6dd162 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -70,68 +70,68 @@ extern _X_EXPORT BoxRec RegionEmptyBox;
 extern _X_EXPORT RegDataRec RegionEmptyData;
 extern _X_EXPORT RegDataRec RegionBrokenData;
 
-#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
+#define RegionNil(reg) ((reg)->data && !(reg)->data->numRects)
 /* not a region */
-#define REGION_NAR(reg)	((reg)->data == &RegionBrokenData)
-#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
-#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
-#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
+#define RegionNar(reg)	((reg)->data == &RegionBrokenData)
+#define RegionNumRects(reg) ((reg)->data ? (reg)->data->numRects : 1)
+#define RegionSize(reg) ((reg)->data ? (reg)->data->size : 0)
+#define RegionRects(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
 			               : &(reg)->extents)
-#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
-#define REGION_BOX(reg,i) (&REGION_BOXPTR(reg)[i])
-#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
-#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
-#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
+#define RegionBoxptr(reg) ((BoxPtr)((reg)->data + 1))
+#define RegionBox(reg,i) (&RegionBoxptr(reg)[i])
+#define RegionTop(reg) RegionBox(reg, (reg)->data->numRects)
+#define RegionEnd(reg) RegionBox(reg, (reg)->data->numRects - 1)
+#define RegionSizeof(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
 
-#define REGION_CREATE(_pScreen, _rect, _size) \
+#define RegionCreate(_rect, _size) \
     RegionCreate(_rect, _size)
 
-#define REGION_COPY(_pScreen, dst, src) \
+#define RegionCopy(dst, src) \
     RegionCopy(dst, src)
 
-#define REGION_DESTROY(_pScreen, _pReg) \
+#define RegionDestroy(_pReg) \
     RegionDestroy(_pReg)
 
-#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
+#define RegionIntersect(newReg, reg1, reg2) \
     RegionIntersect(newReg, reg1, reg2)
 
-#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
+#define RegionUnion(newReg, reg1, reg2) \
     RegionUnion(newReg, reg1, reg2)
 
-#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
+#define RegionSubtract(newReg, reg1, reg2) \
     RegionSubtract(newReg, reg1, reg2)
 
-#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
+#define RegionInverse(newReg, reg1, invRect) \
     RegionInverse(newReg, reg1, invRect)
 
-#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
+#define RegionTranslate(_pReg, _x, _y) \
     RegionTranslate(_pReg, _x, _y)
 
-#define RECT_IN_REGION(_pScreen, _pReg, prect) \
+#define RegionContainsRect(_pReg, prect) \
     RegionContainsRect(_pReg, prect)
 
-#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
+#define RegionContainsPoint(_pReg, _x, _y, prect) \
     RegionContainsPoint(_pReg, _x, _y, prect)
 
-#define REGION_APPEND(_pScreen, dstrgn, rgn) \
+#define RegionAppend(dstrgn, rgn) \
     RegionAppend(dstrgn, rgn)
 
-#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
+#define RegionValidate(badreg, pOverlap) \
     RegionValidate(badreg, pOverlap)
 
-#define BITMAP_TO_REGION(_pScreen, pPix) \
+#define BitmapToRegion(_pScreen, pPix) \
     (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
 
-#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
+#define RegionFromRects(nrects, prect, ctype) \
     RegionFromRects(nrects, prect, ctype)
 
-#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
+#define RegionEqual(_pReg1, _pReg2) \
     RegionEqual(_pReg1, _pReg2)
 
-#define REGION_BREAK(_pScreen, _pReg) \
+#define RegionBreak(_pReg) \
     RegionBreak(_pReg)
 
-#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
+#define RegionInit(_pReg, _rect, _size) \
 { \
     if ((_rect) != NULL)				\
     { \
@@ -142,7 +142,7 @@ extern _X_EXPORT RegDataRec RegionBrokenData;
     { \
         (_pReg)->extents = RegionEmptyBox; \
         if (((_size) > 1) && ((_pReg)->data = \
-                             (RegDataPtr)malloc(REGION_SZOF(_size)))) \
+                             (RegDataPtr)malloc(RegionSizeof(_size)))) \
         { \
             (_pReg)->data->size = (_size); \
             (_pReg)->data->numRects = 0; \
@@ -153,7 +153,7 @@ extern _X_EXPORT RegDataRec RegionBrokenData;
  }
 
 
-#define REGION_UNINIT(_pScreen, _pReg) \
+#define RegionUninit(_pReg) \
 { \
     if ((_pReg)->data && (_pReg)->data->size) { \
 	free((_pReg)->data); \
@@ -161,41 +161,36 @@ extern _X_EXPORT RegDataRec RegionBrokenData;
     } \
 }
 
-#define REGION_RESET(_pScreen, _pReg, _pBox) \
+#define RegionReset(_pReg, _pBox) \
 { \
     (_pReg)->extents = *(_pBox); \
-    REGION_UNINIT(_pScreen, _pReg); \
+    RegionUninit(_pReg); \
     (_pReg)->data = (RegDataPtr)NULL; \
 }
 
-#define REGION_NOTEMPTY(_pScreen, _pReg) \
-    !REGION_NIL(_pReg)
+#define RegionNotEmpty(_pReg) \
+    !RegionNil(_pReg)
 
-#define REGION_BROKEN(_pScreen, _pReg) \
-    REGION_NAR(_pReg)
+#define RegionBroken(_pReg) \
+    RegionNar(_pReg)
 
-#define REGION_EMPTY(_pScreen, _pReg) \
+#define RegionEmpty(_pReg) \
 { \
-    REGION_UNINIT(_pScreen, _pReg); \
+    RegionUninit(_pReg); \
     (_pReg)->extents.x2 = (_pReg)->extents.x1; \
     (_pReg)->extents.y2 = (_pReg)->extents.y1; \
     (_pReg)->data = &RegionEmptyData; \
 }
 
-#define REGION_EXTENTS(_pScreen, _pReg) \
+#define RegionExtents(_pReg) \
     (&(_pReg)->extents)
 
-#define REGION_NULL(_pScreen, _pReg) \
+#define RegionNull(_pReg) \
 { \
     (_pReg)->extents = RegionEmptyBox; \
     (_pReg)->data = &RegionEmptyData; \
 }
 
-#ifndef REGION_NULL
-#define REGION_NULL(_pScreen, _pReg) \
-    REGION_INIT(_pScreen, _pReg, NullBox, 1)
-#endif
-
 /* moved from mi.h */
 
 extern _X_EXPORT void InitRegions (void);
@@ -204,17 +199,9 @@ extern _X_EXPORT RegionPtr RegionCreate(
     BoxPtr /*rect*/,
     int /*size*/);
 
-extern _X_EXPORT void RegionInit(
-    RegionPtr /*pReg*/,
-    BoxPtr /*rect*/,
-    int /*size*/);
-
 extern _X_EXPORT void RegionDestroy(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT void RegionUninit(
-    RegionPtr /*pReg*/);
-
 extern _X_EXPORT Bool RegionCopy(
     RegionPtr /*dst*/,
     RegionPtr /*src*/);
@@ -261,10 +248,6 @@ extern _X_EXPORT void RegionTranslate(
     int /*x*/,
     int /*y*/);
 
-extern _X_EXPORT void RegionReset(
-    RegionPtr /*pReg*/,
-    BoxPtr /*pBox*/);
-
 extern _X_EXPORT Bool RegionBreak(
     RegionPtr /*pReg*/);
 
@@ -278,16 +261,28 @@ extern _X_EXPORT Bool RegionEqual(
     RegionPtr /*pReg1*/,
     RegionPtr /*pReg2*/);
 
-extern _X_EXPORT Bool RegionNotEmpty(
-    RegionPtr /*pReg*/);
-
-extern _X_EXPORT void RegionEmpty(
-    RegionPtr /*pReg*/);
+extern _X_EXPORT Bool RegionRectAlloc(
+    RegionPtr /*pRgn*/,
+    int /*n*/
+);
 
-extern _X_EXPORT BoxPtr RegionExtents(
-    RegionPtr /*pReg*/);
+#ifdef DEBUG
+extern _X_EXPORT Bool RegionIsValid(
+    RegionPtr /*prgn*/
+);
+#endif
 
 extern _X_EXPORT void RegionPrint(
     RegionPtr /*pReg*/);
 
+extern _X_EXPORT int RegionClipSpans(
+    RegionPtr /*prgnDst*/,
+    DDXPointPtr /*ppt*/,
+    int * /*pwidth*/,
+    int /*nspans*/,
+    DDXPointPtr /*pptNew*/,
+    int * /*pwidthNew*/,
+    int /*fSorted*/
+);
+
 #endif /* REGIONSTRUCT_H */
diff --git a/mi/mi.h b/mi/mi.h
index 9f67d2e..fa32b6b 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -418,23 +418,6 @@ extern _X_EXPORT void miPushPixels(
     int /*yOrg*/
 );
 
-/* miregion.c */
-
-/* see also region.h */
-
-extern _X_EXPORT Bool RegionRectAlloc(
-    RegionPtr /*pRgn*/,
-    int /*n*/
-);
-
-#ifdef DEBUG
-extern _X_EXPORT Bool RegionIsValid(
-    RegionPtr /*prgn*/
-);
-#endif
-
-extern _X_EXPORT Bool RegionBroken(RegionPtr pReg);
-
 /* miscrinit.c */
 
 extern _X_EXPORT Bool miModifyPixmapHeader(
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 9c6e03d..8448483 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -116,7 +116,7 @@ miCopyArea(DrawablePtr  pSrcDrawable,
 	box.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
 	box.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
 
-	prgnSrcClip = REGION_CREATE(pGC->pScreen, &box, 1);
+	prgnSrcClip = RegionCreate(&box, 1);
 	realSrcClip = 1;
     }
     else
@@ -145,8 +145,8 @@ miCopyArea(DrawablePtr  pSrcDrawable,
 
     pptFirst = ppt = malloc(heightSrc * sizeof(DDXPointRec));
     pwidthFirst = pwidth = malloc(heightSrc * sizeof(unsigned int));
-    numRects = REGION_NUM_RECTS(prgnSrcClip);
-    boxes = REGION_RECTS(prgnSrcClip);
+    numRects = RegionNumRects(prgnSrcClip);
+    boxes = RegionRects(prgnSrcClip);
     ordering = malloc(numRects * sizeof(unsigned int));
     if(!pptFirst || !pwidthFirst || !ordering)
     {
@@ -259,7 +259,7 @@ miCopyArea(DrawablePtr  pSrcDrawable,
     prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
 		      widthSrc, heightSrc, xOut, yOut, (unsigned long)0);
     if(realSrcClip)
-	REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+	RegionDestroy(prgnSrcClip);
 		
     free(ordering);
     free(pwidthFirst);
@@ -443,9 +443,9 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
        to destroy what it's sent.  note that this means we don't
        have to free prgnSrcClip ourselves.
     */
-    prgnSrcClip = REGION_CREATE(pGCT->pScreen, NULL, 0);
-    REGION_COPY(pGCT->pScreen, prgnSrcClip, prgnSrc);
-    REGION_TRANSLATE(pGCT->pScreen, prgnSrcClip, srcx, 0);
+    prgnSrcClip = RegionCreate(NULL, 0);
+    RegionCopy(prgnSrcClip, prgnSrc);
+    RegionTranslate(prgnSrcClip, srcx, 0);
     (*pGCT->funcs->ChangeClip)(pGCT, CT_REGION, prgnSrcClip, 0);
     ValidateGC((DrawablePtr)pPixmap, pGCT);
 
@@ -578,7 +578,7 @@ miCopyPlane( DrawablePtr pSrcDrawable,
 	box.x2 = box.x1;
     if (box.y1 > box.y2)
 	box.y2 = box.y1;
-    prgnSrc = REGION_CREATE(pGC->pScreen, &box, 1);
+    prgnSrc = RegionCreate(&box, 1);
 
     if (pSrcDrawable->type != DRAWABLE_PIXMAP) {
 	/* clip to visible drawable */
@@ -586,15 +586,15 @@ miCopyPlane( DrawablePtr pSrcDrawable,
 	if (pGC->subWindowMode == IncludeInferiors)
 	{
 	    RegionPtr	clipList = NotClippedByChildren ((WindowPtr) pSrcDrawable);
-	    REGION_INTERSECT(pGC->pScreen, prgnSrc, prgnSrc, clipList);
-	    REGION_DESTROY(pGC->pScreen, clipList);
+	    RegionIntersect(prgnSrc, prgnSrc, clipList);
+	    RegionDestroy(clipList);
 	} else
-	    REGION_INTERSECT(pGC->pScreen, prgnSrc, prgnSrc,
+	    RegionIntersect(prgnSrc, prgnSrc,
 				       &((WindowPtr)pSrcDrawable)->clipList);
     }
 
-    box = *REGION_EXTENTS(pGC->pScreen, prgnSrc);
-    REGION_TRANSLATE(pGC->pScreen, prgnSrc, -box.x1, -box.y1);
+    box = *RegionExtents(prgnSrc);
+    RegionTranslate(prgnSrc, -box.x1, -box.y1);
 
     if ((box.x2 > box.x1) && (box.y2 > box.y1))
     {
@@ -618,7 +618,7 @@ miCopyPlane( DrawablePtr pSrcDrawable,
     }
     prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
 		      width, height, dstx, dsty, bitPlane);
-    REGION_DESTROY(pGC->pScreen, prgnSrc);
+    RegionDestroy(prgnSrc);
     return prgnExposed;
 }
 
@@ -761,11 +761,11 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth,
 	box.y1 = 0;
 	box.x2 = w;
 	box.y2 = h;
-	prgnSrc = REGION_CREATE(pGC->pScreen, &box, 1);
+	prgnSrc = RegionCreate(&box, 1);
 
         miOpqStipDrawable(pDraw, pGC, prgnSrc, (MiBits *) pImage,
 			  leftPad, w, h, x, y);
-	REGION_DESTROY(pGC->pScreen, prgnSrc);
+	RegionDestroy(prgnSrc);
 	break;
 
       case XYPixmap:
diff --git a/mi/micopy.c b/mi/micopy.c
index 6df9d88..157e324 100644
--- a/mi/micopy.c
+++ b/mi/micopy.c
@@ -49,8 +49,8 @@ miCopyRegion (DrawablePtr   pSrcDrawable,
     int		nbox;
     BoxPtr	pboxNew1, pboxNew2, pboxBase, pboxNext, pboxTmp;
     
-    pbox = REGION_RECTS(pDstRegion);
-    nbox = REGION_NUM_RECTS(pDstRegion);
+    pbox = RegionRects(pDstRegion);
+    nbox = RegionNumRects(pDstRegion);
     
     /* XXX we have to err on the side of safety when both are windows,
      * because we don't know if IncludeInferiors is being used.
@@ -209,7 +209,7 @@ miDoCopy (DrawablePtr	pSrcDrawable,
 	     * VT is inactive, make sure the region isn't empty
 	     */
 	    if (!((WindowPtr) pSrcDrawable)->parent &&
-		REGION_NOTEMPTY (pSrcDrawable->pScreen,
+		RegionNotEmpty(
 				 &((WindowPtr) pSrcDrawable)->borderClip))
 	    {
 		/*
@@ -291,9 +291,9 @@ miDoCopy (DrawablePtr	pSrcDrawable,
 	   blown region and call intersect */
 
 	cclip = miGetCompositeClip(pGC);
-        if (REGION_NUM_RECTS(cclip) == 1)
+        if (RegionNumRects(cclip) == 1)
         {
-	    BoxPtr pBox = REGION_RECTS(cclip);
+	    BoxPtr pBox = RegionRects(cclip);
 
 	    if (box_x1 < pBox->x1) box_x1 = pBox->x1;
 	    if (box_x2 > pBox->x2) box_x2 = pBox->x2;
@@ -306,7 +306,7 @@ miDoCopy (DrawablePtr	pSrcDrawable,
     /* Check to see if the region is empty */
     if (box_x1 >= box_x2 || box_y1 >= box_y2)
     {
-	REGION_NULL(pGC->pScreen, &rgnDst);
+	RegionNull(&rgnDst);
     }
     else
     {
@@ -315,25 +315,25 @@ miDoCopy (DrawablePtr	pSrcDrawable,
 	box.y1 = box_y1;
 	box.x2 = box_x2;
 	box.y2 = box_y2;
-	REGION_INIT(pGC->pScreen, &rgnDst, &box, 1);
+	RegionInit(&rgnDst, &box, 1);
     }
     
     /* Clip against complex source if needed */
     if (!fastSrc)
     {
-	REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
-	REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+	RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
+	RegionTranslate(&rgnDst, -dx, -dy);
     }
 
     /* Clip against complex dest if needed */
     if (!fastDst)
     {
-	REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+	RegionIntersect(&rgnDst, &rgnDst,
 			 miGetCompositeClip(pGC));
     }
 
     /* Do bit blitting */
-    numRects = REGION_NUM_RECTS(&rgnDst);
+    numRects = RegionNumRects(&rgnDst);
     if (numRects && widthSrc && heightSrc)
 	miCopyRegion (pSrcDrawable, pDstDrawable, pGC,
 		      &rgnDst, dx, dy, copyProc, bitPlane, closure);
@@ -347,8 +347,8 @@ miDoCopy (DrawablePtr	pSrcDrawable,
 					xOut - pDstDrawable->x,
 					yOut - pDstDrawable->y,
 					(unsigned long) bitPlane);
-    REGION_UNINIT(pGC->pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
     if (freeSrcClip)
-	REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+	RegionDestroy(prgnSrcClip);
     return prgnExposed;
 }
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 088149b..2fd070d 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -175,21 +175,21 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
 	if (pGC->subWindowMode == IncludeInferiors)
  	{
 	    prgnSrcClip = NotClippedByChildren (pSrcWin);
-	    if ((RECT_IN_REGION(pscr, prgnSrcClip, &TsrcBox)) == rgnIN)
+	    if ((RegionContainsRect(prgnSrcClip, &TsrcBox)) == rgnIN)
 	    {
-		REGION_DESTROY(pscr, prgnSrcClip);
+		RegionDestroy(prgnSrcClip);
 		return NULL;
 	    }
 	}
  	else
  	{
-	    if ((RECT_IN_REGION(pscr, &pSrcWin->clipList, &TsrcBox)) == rgnIN)
+	    if ((RegionContainsRect(&pSrcWin->clipList, &TsrcBox)) == rgnIN)
 		return NULL;
 	    prgnSrcClip = &rgnSrcRec;
-	    REGION_NULL(pscr, prgnSrcClip);
-	    REGION_COPY(pscr, prgnSrcClip, &pSrcWin->clipList);
+	    RegionNull(prgnSrcClip);
+	    RegionCopy(prgnSrcClip, &pSrcWin->clipList);
 	}
-	REGION_TRANSLATE(pscr, prgnSrcClip,
+	RegionTranslate(prgnSrcClip,
 				-pSrcDrawable->x, -pSrcDrawable->y);
     }
     else
@@ -206,7 +206,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
 	box.x2 = pSrcDrawable->width;
 	box.y2 = pSrcDrawable->height;
 	prgnSrcClip = &rgnSrcRec;
-	REGION_INIT(pscr, prgnSrcClip, &box, 1);
+	RegionInit(prgnSrcClip, &box, 1);
 	pSrcWin = NULL;
     }
 
@@ -223,11 +223,11 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
 	else
 	{
 	    prgnDstClip = &rgnDstRec;
-	    REGION_NULL(pscr, prgnDstClip);
-	    REGION_COPY(pscr, prgnDstClip,
+	    RegionNull(prgnDstClip);
+	    RegionCopy(prgnDstClip,
 				&((WindowPtr)pDstDrawable)->clipList);
 	}
-	REGION_TRANSLATE(pscr, prgnDstClip,
+	RegionTranslate(prgnDstClip,
 				 -pDstDrawable->x, -pDstDrawable->y);
     }
     else
@@ -239,24 +239,24 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
 	box.x2 = pDstDrawable->width;
 	box.y2 = pDstDrawable->height;
 	prgnDstClip = &rgnDstRec;
-	REGION_INIT(pscr, prgnDstClip, &box, 1);
+	RegionInit(prgnDstClip, &box, 1);
     }
 
     /* drawable-relative source region */
-    REGION_INIT(pscr, &rgnExposed, &srcBox, 1);
+    RegionInit(&rgnExposed, &srcBox, 1);
 
     /* now get the hidden parts of the source box*/
-    REGION_SUBTRACT(pscr, &rgnExposed, &rgnExposed, prgnSrcClip);
+    RegionSubtract(&rgnExposed, &rgnExposed, prgnSrcClip);
 
     /* move them over the destination */
-    REGION_TRANSLATE(pscr, &rgnExposed, dstx-srcx, dsty-srcy);
+    RegionTranslate(&rgnExposed, dstx-srcx, dsty-srcy);
 
     /* intersect with visible areas of dest */
-    REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, prgnDstClip);
+    RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip);
 
     /* intersect with client clip region. */
     if (pGC->clientClipType == CT_REGION)
-	REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, pGC->clientClip);
+	RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip);
 
     /*
      * If we have LOTS of rectangles, we decide to take the extents
@@ -266,7 +266,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
      * for windows.
      */
     extents = pGC->graphicsExposures &&
-	      (REGION_NUM_RECTS(&rgnExposed) > RECTLIMIT) &&
+	      (RegionNumRects(&rgnExposed) > RECTLIMIT) &&
 	      (pDstDrawable->type != DRAWABLE_PIXMAP);
     if (pSrcWin)
     {
@@ -278,13 +278,13 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
      	 * exposed region will undo all our work!
      	 */
     	if (extents && pSrcWin && region &&
-    	    (RECT_IN_REGION(pscr, region, &srcBox) != rgnIN))
+	    (RegionContainsRect(region, &srcBox) != rgnIN))
 	    	extents = FALSE;
     }
     if (extents)
     {
-	expBox = *REGION_EXTENTS(pscr, &rgnExposed);
-	REGION_RESET(pscr, &rgnExposed, &expBox);
+	expBox = *RegionExtents(&rgnExposed);
+	RegionReset(&rgnExposed, &expBox);
     }
     if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
 	(((WindowPtr)pDstDrawable)->backgroundState != None))
@@ -292,52 +292,52 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
 	WindowPtr pWin = (WindowPtr)pDstDrawable;
 
 	/* make the exposed area screen-relative */
-	REGION_TRANSLATE(pscr, &rgnExposed, 
+	RegionTranslate(&rgnExposed,
 				 pDstDrawable->x, pDstDrawable->y);
 
 	if (extents)
 	{
 	    /* miPaintWindow doesn't clip, so we have to */
-	    REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList);
+	    RegionIntersect(&rgnExposed, &rgnExposed, &pWin->clipList);
 	}
 	miPaintWindow((WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
 
 	if (extents)
 	{
-	    REGION_RESET(pscr, &rgnExposed, &expBox);
+	    RegionReset(&rgnExposed, &expBox);
 	}
 	else
-	    REGION_TRANSLATE(pscr, &rgnExposed,
+	    RegionTranslate(&rgnExposed,
 				     -pDstDrawable->x, -pDstDrawable->y);
     }
     if (prgnDstClip == &rgnDstRec)
     {
-	REGION_UNINIT(pscr, prgnDstClip);
+	RegionUninit(prgnDstClip);
     }
     else if (prgnDstClip != prgnSrcClip)
     {
-	REGION_DESTROY(pscr, prgnDstClip);
+	RegionDestroy(prgnDstClip);
     }
 
     if (prgnSrcClip == &rgnSrcRec)
     {
-	REGION_UNINIT(pscr, prgnSrcClip);
+	RegionUninit(prgnSrcClip);
     }
     else
     {
-	REGION_DESTROY(pscr, prgnSrcClip);
+	RegionDestroy(prgnSrcClip);
     }
 
     if (pGC->graphicsExposures)
     {
 	/* don't look */
-	RegionPtr exposed = REGION_CREATE(pscr, NullBox, 0);
+	RegionPtr exposed = RegionCreate(NullBox, 0);
 	*exposed = rgnExposed;
 	return exposed;
     }
     else
     {
-	REGION_UNINIT(pscr, &rgnExposed);
+	RegionUninit(&rgnExposed);
 	return NULL;
     }
 }
@@ -348,7 +348,7 @@ void
 miSendGraphicsExpose (ClientPtr client, RegionPtr pRgn, XID drawable,
                       int major, int minor)
 {
-    if (pRgn && !REGION_NIL(pRgn))
+    if (pRgn && !RegionNil(pRgn))
     {
         xEvent *pEvent;
 	xEvent *pe;
@@ -356,8 +356,8 @@ miSendGraphicsExpose (ClientPtr client, RegionPtr pRgn, XID drawable,
 	int i;
 	int numRects;
 
-	numRects = REGION_NUM_RECTS(pRgn);
-	pBox = REGION_RECTS(pRgn);
+	numRects = RegionNumRects(pRgn);
+	pBox = RegionRects(pRgn);
 	if(!(pEvent = malloc(numRects * sizeof(xEvent))))
 		return;
 	pe = pEvent;
@@ -401,8 +401,8 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
     xEvent *pEvent, *pe;
     int i;
 
-    pBox = REGION_RECTS(pRgn);
-    numRects = REGION_NUM_RECTS(pRgn);
+    pBox = RegionRects(pRgn);
+    numRects = RegionNumRects(pRgn);
     if(!(pEvent = calloc(1, numRects * sizeof(xEvent))))
 	return;
 
@@ -457,8 +457,8 @@ void
 miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
 {
     RegionPtr   exposures = prgn;
-    if ((prgn && !REGION_NIL(prgn)) || 
-	(exposures && !REGION_NIL(exposures)) || other_exposed)
+    if ((prgn && !RegionNil(prgn)) ||
+	(exposures && !RegionNil(exposures)) || other_exposed)
     {
 	RegionRec   expRec;
 	int	    clientInterested;
@@ -471,15 +471,15 @@ miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
 	{
 	    if (exposures)
 	    {
-		REGION_UNION(pWin->drawable.pScreen, other_exposed,
+		RegionUnion(other_exposed,
 						  exposures,
 					          other_exposed);
 		if (exposures != prgn)
-		    REGION_DESTROY(pWin->drawable.pScreen, exposures);
+		    RegionDestroy(exposures);
 	    }
 	    exposures = other_exposed;
 	}
-	if (clientInterested && exposures && (REGION_NUM_RECTS(exposures) > RECTLIMIT))
+	if (clientInterested && exposures && (RegionNumRects(exposures) > RECTLIMIT))
 	{
 	    /*
 	     * If we have LOTS of rectangles, we decide to take the extents
@@ -489,34 +489,34 @@ miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
 	     */
 	    BoxRec box;
 
-	    box = *REGION_EXTENTS( pWin->drawable.pScreen, exposures);
+	    box = *RegionExtents(exposures);
 	    if (exposures == prgn) {
 		exposures = &expRec;
-		REGION_INIT( pWin->drawable.pScreen, exposures, &box, 1);
-		REGION_RESET( pWin->drawable.pScreen, prgn, &box);
+		RegionInit(exposures, &box, 1);
+		RegionReset(prgn, &box);
 	    } else {
-		REGION_RESET( pWin->drawable.pScreen, exposures, &box);
-		REGION_UNION( pWin->drawable.pScreen, prgn, prgn, exposures);
+		RegionReset(exposures, &box);
+		RegionUnion(prgn, prgn, exposures);
 	    }
 	    /* miPaintWindow doesn't clip, so we have to */
-	    REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
+	    RegionIntersect(prgn, prgn, &pWin->clipList);
 	}
-	if (prgn && !REGION_NIL(prgn))
+	if (prgn && !RegionNil(prgn))
 	    miPaintWindow(pWin, prgn, PW_BACKGROUND);
-	if (clientInterested && exposures && !REGION_NIL(exposures))
+	if (clientInterested && exposures && !RegionNil(exposures))
 	    miSendExposures(pWin, exposures,
 			    pWin->drawable.x, pWin->drawable.y);
 	if (exposures == &expRec)
 	{
-	    REGION_UNINIT( pWin->drawable.pScreen, exposures);
+	    RegionUninit(exposures);
 	}
 	else if (exposures && exposures != prgn && exposures != other_exposed)
-	    REGION_DESTROY( pWin->drawable.pScreen, exposures);
+	    RegionDestroy(exposures);
 	if (prgn)
-	    REGION_EMPTY( pWin->drawable.pScreen, prgn);
+	    RegionEmpty(prgn);
     }
     else if (exposures && exposures != prgn)
-	REGION_DESTROY( pWin->drawable.pScreen, exposures);
+	RegionDestroy(exposures);
 }
 
 #ifdef ROOTLESS
@@ -647,7 +647,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 	gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
     }
 
-    prect = malloc(REGION_NUM_RECTS(prgn) * sizeof(xRectangle));
+    prect = malloc(RegionNumRects(prgn) * sizeof(xRectangle));
     if (!prect)
 	return;
 
@@ -661,8 +661,8 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     ChangeGC (NullClient, pGC, gcmask, gcval);
     ValidateGC (drawable, pGC);
 
-    numRects = REGION_NUM_RECTS(prgn);
-    pbox = REGION_RECTS(prgn);
+    numRects = RegionNumRects(prgn);
+    pbox = RegionRects(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
     {
 	prect->x = pbox->x1 - draw_x_off;
diff --git a/mi/migc.c b/mi/migc.c
index 7b2b1c3..778c4b4 100644
--- a/mi/migc.c
+++ b/mi/migc.c
@@ -50,7 +50,7 @@ miDestroyGC(GCPtr pGC)
     if (pGC->pRotatedPixmap)
 	(*pGC->pScreen->DestroyPixmap) (pGC->pRotatedPixmap);
     if (pGC->freeCompClip)
-	REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+	RegionDestroy(pGC->pCompositeClip);
 }
 
 void
@@ -68,7 +68,7 @@ miDestroyClip(GCPtr pGC)
 	 * we know we'll never have a list of rectangles, since ChangeClip
 	 * immediately turns them into a region
 	 */
-	REGION_DESTROY(pGC->pScreen, pGC->clientClip);
+	RegionDestroy(pGC->clientClip);
     }
     pGC->clientClip = NULL;
     pGC->clientClipType = CT_NONE;
@@ -81,7 +81,7 @@ miChangeClip( GCPtr pGC, int type, pointer pvalue, int nrects)
     if (type == CT_PIXMAP)
     {
 	/* convert the pixmap to a region */
-	pGC->clientClip = (pointer) BITMAP_TO_REGION(pGC->pScreen,
+	pGC->clientClip = (pointer) BitmapToRegion(pGC->pScreen,
 							(PixmapPtr) pvalue);
 	(*pGC->pScreen->DestroyPixmap) (pvalue);
     }
@@ -92,7 +92,7 @@ miChangeClip( GCPtr pGC, int type, pointer pvalue, int nrects)
     }
     else if (type != CT_NONE)
     {
-	pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects,
+	pGC->clientClip = (pointer) RegionFromRects(nrects,
 						      (xRectangle *) pvalue,
 								    type);
 	free(pvalue);
@@ -116,8 +116,8 @@ miCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
 				   pgcSrc->clientClip, 0);
 	break;
       case CT_REGION:
-	prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1);
-	REGION_COPY(pgcDst->pScreen, prgnNew,
+	prgnNew = RegionCreate(NULL, 1);
+	RegionCopy(prgnNew,
 					(RegionPtr) (pgcSrc->clientClip));
 	(*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (pointer) prgnNew, 0);
 	break;
@@ -167,7 +167,7 @@ miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable)
 	if (pGC->clientClipType == CT_NONE)
 	{
 	    if (freeCompClip)
-		REGION_DESTROY(pScreen, pGC->pCompositeClip);
+		RegionDestroy(pGC->pCompositeClip);
 	    pGC->pCompositeClip = pregWin;
 	    pGC->freeCompClip = freeTmpClip;
 	}
@@ -182,30 +182,30 @@ miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable)
 	     * clip. if neither is real, create a new region.
 	     */
 
-	    REGION_TRANSLATE(pScreen, pGC->clientClip,
+	    RegionTranslate(pGC->clientClip,
 					 pDrawable->x + pGC->clipOrg.x,
 					 pDrawable->y + pGC->clipOrg.y);
 
 	    if (freeCompClip)
 	    {
-		REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+		RegionIntersect(pGC->pCompositeClip,
 					    pregWin, pGC->clientClip);
 		if (freeTmpClip)
-		    REGION_DESTROY(pScreen, pregWin);
+		    RegionDestroy(pregWin);
 	    }
 	    else if (freeTmpClip)
 	    {
-		REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+		RegionIntersect(pregWin, pregWin, pGC->clientClip);
 		pGC->pCompositeClip = pregWin;
 	    }
 	    else
 	    {
-		pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
-		REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+		pGC->pCompositeClip = RegionCreate(NullBox, 0);
+		RegionIntersect(pGC->pCompositeClip,
 				       pregWin, pGC->clientClip);
 	    }
 	    pGC->freeCompClip = TRUE;
-	    REGION_TRANSLATE(pScreen, pGC->clientClip,
+	    RegionTranslate(pGC->clientClip,
 					 -(pDrawable->x + pGC->clipOrg.x),
 					 -(pDrawable->y + pGC->clipOrg.y));
 	}
@@ -223,31 +223,31 @@ miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable)
 
 	if (pGC->freeCompClip)
 	{
-	    REGION_RESET(pScreen, pGC->pCompositeClip, &pixbounds);
+	    RegionReset(pGC->pCompositeClip, &pixbounds);
 	}
 	else
 	{
 	    pGC->freeCompClip = TRUE;
-	    pGC->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+	    pGC->pCompositeClip = RegionCreate(&pixbounds, 1);
 	}
 
 	if (pGC->clientClipType == CT_REGION)
 	{
 	    if(pDrawable->x || pDrawable->y) {
-	        REGION_TRANSLATE(pScreen, pGC->clientClip,
+	        RegionTranslate(pGC->clientClip,
 					  pDrawable->x + pGC->clipOrg.x, 
 					  pDrawable->y + pGC->clipOrg.y);
-	        REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+	        RegionIntersect(pGC->pCompositeClip,
 				pGC->pCompositeClip, pGC->clientClip);
-	        REGION_TRANSLATE(pScreen, pGC->clientClip,
+	        RegionTranslate(pGC->clientClip,
 					  -(pDrawable->x + pGC->clipOrg.x), 
 					  -(pDrawable->y + pGC->clipOrg.y));
 	    } else {
-	        REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
+	        RegionTranslate(pGC->pCompositeClip,
 					 -pGC->clipOrg.x, -pGC->clipOrg.y);
-	        REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+	        RegionIntersect(pGC->pCompositeClip,
 				pGC->pCompositeClip, pGC->clientClip);
-	        REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
+	        RegionTranslate(pGC->pCompositeClip,
 					 pGC->clipOrg.x, pGC->clipOrg.y);
 	    }
 	}
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index da3ff4a..d8eb642 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -201,8 +201,8 @@ miOverlayCreateWindow(WindowPtr pWin)
 	    pTree->visibility = VisibilityNotViewable;
 	    pWinPriv->tree = pTree;
 	    if(pWin->parent) {
-		REGION_NULL(pScreen, &(pTree->borderClip));
-		REGION_NULL(pScreen, &(pTree->clipList));
+		RegionNull(&(pTree->borderClip));
+		RegionNull(&(pTree->clipList));
 		RebuildTree(pWin);
 	    } else {
 		BoxRec fullBox;
@@ -210,8 +210,8 @@ miOverlayCreateWindow(WindowPtr pWin)
 		fullBox.y1 = 0;
 		fullBox.x2 = pScreen->width;
 		fullBox.y2 = pScreen->height;
-		REGION_INIT(pScreen, &(pTree->borderClip), &fullBox, 1);
-		REGION_INIT(pScreen, &(pTree->clipList), &fullBox, 1);
+		RegionInit(&(pTree->borderClip), &fullBox, 1);
+		RegionInit(&(pTree->clipList), &fullBox, 1);
 	    }
 	} else free(pTree);
     }
@@ -239,8 +239,8 @@ miOverlayDestroyWindow(WindowPtr pWin)
 	else if(pTree->parent)
 	   pTree->parent->lastChild = pTree->prevSib;
 
-	REGION_UNINIT(pScreen, &(pTree->borderClip));
-	REGION_UNINIT(pScreen, &(pTree->clipList));
+	RegionUninit(&(pTree->borderClip));
+	RegionUninit(&(pTree->clipList));
 	free(pTree);
     }
 
@@ -338,7 +338,7 @@ miOverlayMarkOverlappedWindows(
 
     doUnderlay = (IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin));
 
-    box = REGION_EXTENTS(pScreen, &pWin->borderSize);
+    box = RegionExtents(&pWin->borderSize);
 
     if((pChild = pFirst)) {
 	pLast = pChild->parent->lastChild;
@@ -349,13 +349,13 @@ miOverlayMarkOverlappedWindows(
 		pTree = MIOVERLAY_GET_WINDOW_TREE(pChild);
 
 	    if(pChild->viewable) {
-                if (REGION_BROKEN (pScreen, &pChild->winSize))
+                if (RegionBroken(&pChild->winSize))
                     SetWinSize (pChild);
-                if (REGION_BROKEN (pScreen, &pChild->borderSize))
+                if (RegionBroken(&pChild->borderSize))
 		    SetBorderSize (pChild);
 
 	    	if (markAll || 
-		    RECT_IN_REGION(pScreen, &pChild->borderSize, box))
+		    RegionContainsRect(&pChild->borderSize, box))
 		{
 		    MARK_OVERLAY(pChild);
 		    overMarked = TRUE;
@@ -410,12 +410,12 @@ miOverlayMarkOverlappedWindows(
 
 	while(1) {
 	    if(tChild->pWin->viewable) { 
-                if (REGION_BROKEN (pScreen, &tChild->pWin->winSize))
+                if (RegionBroken(&tChild->pWin->winSize))
                     SetWinSize (tChild->pWin);
-                if (REGION_BROKEN (pScreen, &tChild->pWin->borderSize))
+                if (RegionBroken(&tChild->pWin->borderSize))
 		    SetBorderSize (tChild->pWin);
 
-		if(RECT_IN_REGION(pScreen, &(tChild->pWin->borderSize), box)) 
+		if(RegionContainsRect(&(tChild->pWin->borderSize), box))
 	        {
 		    MARK_UNDERLAY(tChild->pWin);
 		    underMarked = TRUE;
@@ -473,7 +473,7 @@ miOverlayComputeClips(
     borderSize.y2 = dy;
   
     oldVis = tParent->visibility;
-    switch (RECT_IN_REGION( pScreen, universe, &borderSize)) {
+    switch (RegionContainsRect(universe, &borderSize)) {
 	case rgnIN:
 	    newVis = VisibilityUnobscured;
 	    break;
@@ -521,8 +521,8 @@ miOverlayComputeClips(
 	    while (1) {
 		if (tChild->pWin->viewable) {
 		    if (tChild->visibility != VisibilityFullyObscured) {
-			REGION_TRANSLATE( pScreen, &tChild->borderClip, dx, dy);
-			REGION_TRANSLATE( pScreen, &tChild->clipList, dx, dy);
+			RegionTranslate(&tChild->borderClip, dx, dy);
+			RegionTranslate(&tChild->clipList, dx, dy);
 		
 			tChild->pWin->drawable.serialNumber = 
 							 NEXT_SERIAL_NUMBER;
@@ -530,14 +530,14 @@ miOverlayComputeClips(
                             (* pScreen->ClipNotify) (tChild->pWin, dx, dy);
 		    }
 		    if (tChild->valdata) {
-			REGION_NULL(pScreen, &tChild->valdata->borderExposed);
+			RegionNull(&tChild->valdata->borderExposed);
 			if (HasParentRelativeBorder(tChild->pWin)){
-			    REGION_SUBTRACT(pScreen,
+			    RegionSubtract(
 					 &tChild->valdata->borderExposed,
 					 &tChild->borderClip,
 					 &tChild->pWin->winSize);
 			}
-			REGION_NULL(pScreen, &tChild->valdata->exposed);
+			RegionNull(&tChild->valdata->exposed);
 		    }
 		    if (tChild->firstChild) {
 			tChild = tChild->firstChild;
@@ -555,50 +555,50 @@ miOverlayComputeClips(
 	/* fall through */
     default:
     	if (dx || dy)  {
-	    REGION_TRANSLATE( pScreen, &tParent->borderClip, dx, dy);
-	    REGION_TRANSLATE( pScreen, &tParent->clipList, dx, dy);
+	    RegionTranslate(&tParent->borderClip, dx, dy);
+	    RegionTranslate(&tParent->clipList, dx, dy);
     	} 
 	break;
     case VTBroken:
-	REGION_EMPTY (pScreen, &tParent->borderClip);
-	REGION_EMPTY (pScreen, &tParent->clipList);
+	RegionEmpty(&tParent->borderClip);
+	RegionEmpty(&tParent->clipList);
 	break;
     }
 
     borderVisible = tParent->valdata->borderVisible;
-    REGION_NULL(pScreen, &tParent->valdata->borderExposed);
-    REGION_NULL(pScreen, &tParent->valdata->exposed);
+    RegionNull(&tParent->valdata->borderExposed);
+    RegionNull(&tParent->valdata->exposed);
 
     if (HasBorder (pParent)) {
     	if (borderVisible) {
-	    REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
-	    REGION_DESTROY( pScreen, borderVisible);
+	    RegionSubtract(exposed, universe, borderVisible);
+	    RegionDestroy(borderVisible);
     	} else
-	    REGION_SUBTRACT( pScreen, exposed, universe, &tParent->borderClip);
+	    RegionSubtract(exposed, universe, &tParent->borderClip);
 
 	if (HasParentRelativeBorder(pParent) && (dx || dy))
-	    REGION_SUBTRACT( pScreen, &tParent->valdata->borderExposed,
+	    RegionSubtract(&tParent->valdata->borderExposed,
 				  universe, &pParent->winSize);
 	else
-	    REGION_SUBTRACT( pScreen, &tParent->valdata->borderExposed,
+	    RegionSubtract(&tParent->valdata->borderExposed,
 			       exposed, &pParent->winSize);
 
-    	REGION_COPY( pScreen, &tParent->borderClip, universe);    
-    	REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+	RegionCopy(&tParent->borderClip, universe);
+	RegionIntersect(universe, universe, &pParent->winSize);
     }
     else
-    	REGION_COPY( pScreen, &tParent->borderClip, universe);
+	RegionCopy(&tParent->borderClip, universe);
 
     if ((tChild = tParent->firstChild) && pParent->mapped) {
-	REGION_NULL(pScreen, &childUniverse);
-	REGION_NULL(pScreen, &childUnion);
+	RegionNull(&childUniverse);
+	RegionNull(&childUnion);
 
 	for (; tChild; tChild = tChild->nextSib) {
 	    if (tChild->pWin->viewable)
-		REGION_APPEND( pScreen, &childUnion, &tChild->pWin->borderSize);
+		RegionAppend(&childUnion, &tChild->pWin->borderSize);
 	}
 
-	REGION_VALIDATE( pScreen, &childUnion, &overlap);
+	RegionValidate(&childUnion, &overlap);
 
 	for (tChild = tParent->firstChild;
 	     tChild;
@@ -606,31 +606,31 @@ miOverlayComputeClips(
  	{
 	    if (tChild->pWin->viewable) {
 		if (tChild->valdata) {
-		    REGION_INTERSECT( pScreen, &childUniverse, universe,
+		    RegionIntersect(&childUniverse, universe,
 					    &tChild->pWin->borderSize);
 		    miOverlayComputeClips (tChild->pWin, &childUniverse, 
 						kind, exposed);
 		}
 		if (overlap)
-		    REGION_SUBTRACT( pScreen, universe, universe,
+		    RegionSubtract(universe, universe,
 					  &tChild->pWin->borderSize);
 	    }
 	}
 	if (!overlap)
-	    REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
-	REGION_UNINIT( pScreen, &childUnion);
-	REGION_UNINIT( pScreen, &childUniverse);
+	    RegionSubtract(universe, universe, &childUnion);
+	RegionUninit(&childUnion);
+	RegionUninit(&childUniverse);
     } 
 
     if (oldVis == VisibilityFullyObscured ||
 	oldVis == VisibilityNotViewable)
     {
-	REGION_COPY( pScreen, &tParent->valdata->exposed, universe);
+	RegionCopy(&tParent->valdata->exposed, universe);
     }
     else if (newVis != VisibilityFullyObscured &&
 	     newVis != VisibilityNotViewable)
     {
-    	REGION_SUBTRACT( pScreen, &tParent->valdata->exposed,
+	RegionSubtract(&tParent->valdata->exposed,
 			       universe, &tParent->clipList);
     }
     
@@ -708,14 +708,14 @@ miOverlayMarkUnrealizedWindow(
     if ((pChild != pWin) || fromConfigure) {
 	miOverlayTreePtr pTree;
 
-        REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
+        RegionEmpty(&pChild->clipList);
         if (pChild->drawable.pScreen->ClipNotify)
             (* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
-        REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
+        RegionEmpty(&pChild->borderClip);
 	if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
 	    if(pTree->valdata != (miOverlayValDataPtr)UnmapValData) {
-		REGION_EMPTY(pChild->drawable.pScreen, &pTree->clipList);
-		REGION_EMPTY(pChild->drawable.pScreen, &pTree->borderClip);
+		RegionEmpty(&pTree->clipList);
+		RegionEmpty(&pTree->borderClip);
 	    }
 	}
     }
@@ -740,9 +740,9 @@ miOverlayValidateTree(
 
     if (!pChild) pChild = pParent->firstChild;
 
-    REGION_NULL(pScreen, &totalClip);
-    REGION_NULL(pScreen, &childClip);
-    REGION_NULL(pScreen, &exposed);
+    RegionNull(&totalClip);
+    RegionNull(&childClip);
+    RegionNull(&exposed);
 
     newParent = pParent;
 
@@ -756,52 +756,52 @@ miOverlayValidateTree(
     else
 	tChild = tParent->firstChild;
 
-    if (REGION_BROKEN (pScreen, &tParent->clipList) &&
-        !REGION_BROKEN (pScreen, &tParent->borderClip))
+    if (RegionBroken(&tParent->clipList) &&
+        !RegionBroken(&tParent->borderClip))
     {
 	kind = VTBroken;
-	REGION_COPY (pScreen, &totalClip, &tParent->borderClip);
-	REGION_INTERSECT (pScreen, &totalClip, &totalClip,
+	RegionCopy(&totalClip, &tParent->borderClip);
+	RegionIntersect(&totalClip, &totalClip,
 						 &tParent->pWin->winSize);
         
         for (tWin = tParent->firstChild; tWin != tChild; tWin = tWin->nextSib) {
             if (tWin->pWin->viewable)
-                REGION_SUBTRACT (pScreen, &totalClip, &totalClip, 
+                RegionSubtract(&totalClip, &totalClip,
 					&tWin->pWin->borderSize);
         }        
-        REGION_EMPTY (pScreen, &tParent->clipList);
+        RegionEmpty(&tParent->clipList);
     } else {
 	for(tWin = tChild; tWin; tWin = tWin->nextSib) {
 	    if(tWin->valdata)
-		REGION_APPEND(pScreen, &totalClip, &tWin->borderClip);
+		RegionAppend(&totalClip, &tWin->borderClip);
 	}
-	REGION_VALIDATE(pScreen, &totalClip, &overlap);
+	RegionValidate(&totalClip, &overlap);
     }
 
     if(kind != VTStack)
-	REGION_UNION(pScreen, &totalClip, &totalClip, &tParent->clipList);
+	RegionUnion(&totalClip, &totalClip, &tParent->clipList);
 	
     for(tWin = tChild; tWin; tWin = tWin->nextSib) {
 	if(tWin->valdata) {
 	    if(tWin->pWin->viewable) {
-		REGION_INTERSECT(pScreen, &childClip, &totalClip,
+		RegionIntersect(&childClip, &totalClip,
 					&tWin->pWin->borderSize);
 		miOverlayComputeClips(tWin->pWin, &childClip, kind, &exposed);
-		REGION_SUBTRACT(pScreen, &totalClip, &totalClip,
+		RegionSubtract(&totalClip, &totalClip,
 					&tWin->pWin->borderSize);
 	    } else {  /* Means we are unmapping */
-                REGION_EMPTY(pScreen, &tWin->clipList);
-                REGION_EMPTY( pScreen, &tWin->borderClip);
+                RegionEmpty(&tWin->clipList);
+                RegionEmpty(&tWin->borderClip);
 		tWin->valdata = NULL;
 	    }
 	}
     }
 
-    REGION_UNINIT(pScreen, &childClip);
+    RegionUninit(&childClip);
 
     if(!((*pPriv->InOverlay)(newParent))) {
-	REGION_NULL(pScreen, &tParent->valdata->exposed);
-	REGION_NULL(pScreen, &tParent->valdata->borderExposed);
+	RegionNull(&tParent->valdata->exposed);
+	RegionNull(&tParent->valdata->borderExposed);
     }
 
     switch (kind) {
@@ -809,18 +809,18 @@ miOverlayValidateTree(
 	break;
     default:
     	if(!((*pPriv->InOverlay)(newParent))) 
-	    REGION_SUBTRACT(pScreen, &tParent->valdata->exposed, &totalClip, 
+	    RegionSubtract(&tParent->valdata->exposed, &totalClip,
 						&tParent->clipList);
 	/* fall through */
     case VTMap:
-	REGION_COPY( pScreen, &tParent->clipList, &totalClip);
+	RegionCopy(&tParent->clipList, &totalClip);
     	if(!((*pPriv->InOverlay)(newParent))) 
 	    newParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	break;
     }
 
-    REGION_UNINIT( pScreen, &totalClip);
-    REGION_UNINIT( pScreen, &exposed);
+    RegionUninit(&totalClip);
+    RegionUninit(&exposed);
 
 SKIP_UNDERLAY:
 
@@ -853,14 +853,14 @@ miOverlayHandleExposures(WindowPtr pWin)
 	while (1) {
 	    if((mival = pTree->valdata)) {
 		if(!((*pPriv->InOverlay)(pTree->pWin))) {
-		    if (REGION_NOTEMPTY(pScreen, &mival->borderExposed)) {
+		    if (RegionNotEmpty(&mival->borderExposed)) {
 			miPaintWindow(pTree->pWin, &mival->borderExposed,
 				      PW_BORDER);
 		    }
-		    REGION_UNINIT(pScreen, &mival->borderExposed);
+		    RegionUninit(&mival->borderExposed);
 
 		    (*WindowExposures)(pTree->pWin,&mival->exposed,NullRegion);
-		    REGION_UNINIT(pScreen, &mival->exposed);
+		    RegionUninit(&mival->exposed);
 		}
 		free(mival);
 		pTree->valdata = NULL;
@@ -882,24 +882,24 @@ miOverlayHandleExposures(WindowPtr pWin)
     while (1) {
 	if ( (val = pChild->valdata) ) {
 	    if(!((*pPriv->InOverlay)(pChild))) {
-		REGION_UNION(pScreen, &val->after.exposed, &val->after.exposed,
+		RegionUnion(&val->after.exposed, &val->after.exposed,
 			&val->after.borderExposed);
 
-		if (REGION_NOTEMPTY(pScreen, &val->after.exposed)) {
+		if (RegionNotEmpty(&val->after.exposed)) {
 		   (*(MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->MakeTransparent))(
 				pScreen, 
-				REGION_NUM_RECTS(&val->after.exposed),
-				REGION_RECTS(&val->after.exposed));
+				RegionNumRects(&val->after.exposed),
+				RegionRects(&val->after.exposed));
 		}
 	    } else {
-		if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed)) {
+		if (RegionNotEmpty(&val->after.borderExposed)) {
 			miPaintWindow(pChild, &val->after.borderExposed,
 				      PW_BORDER);
 		}
 		(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
 	    }
-	    REGION_UNINIT(pScreen, &val->after.borderExposed);
-	    REGION_UNINIT(pScreen, &val->after.exposed);
+	    RegionUninit(&val->after.borderExposed);
+	    RegionUninit(&val->after.exposed);
 	    free(val);
 	    pChild->valdata = NULL;
 	    if (pChild->firstChild)
@@ -940,13 +940,13 @@ miOverlayMoveWindow(
     oldpt.x = pWin->drawable.x;
     oldpt.y = pWin->drawable.y;
     if (WasViewable) {
-	REGION_NULL(pScreen, &overReg);
-	REGION_NULL(pScreen, &underReg);
+	RegionNull(&overReg);
+	RegionNull(&underReg);
 	if(pTree) {
-	    REGION_COPY(pScreen, &overReg, &pWin->borderClip);
-	    REGION_COPY(pScreen, &underReg, &pTree->borderClip);
+	    RegionCopy(&overReg, &pWin->borderClip);
+	    RegionCopy(&underReg, &pTree->borderClip);
         } else {
-	    REGION_COPY(pScreen, &overReg, &pWin->borderClip);
+	    RegionCopy(&overReg, &pWin->borderClip);
 	    CollectUnderlayChildrenRegions(pWin, &underReg);
 	}
 	(*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
@@ -971,16 +971,16 @@ miOverlayMoveWindow(
 
 
 	(*pScreen->ValidateTree)(pWin->parent, NullWindow, kind);
-	if(REGION_NOTEMPTY(pScreen, &underReg)) {
+	if(RegionNotEmpty(&underReg)) {
 	    pPriv->copyUnderlay = TRUE;
 	    (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, &underReg);
 	}
-	REGION_UNINIT(pScreen, &underReg);
-	if(REGION_NOTEMPTY(pScreen, &overReg)) {
+	RegionUninit(&underReg);
+	if(RegionNotEmpty(&overReg)) {
 	    pPriv->copyUnderlay = FALSE;
 	    (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, &overReg);
 	}
-	REGION_UNINIT(pScreen, &overReg);
+	RegionUninit(&overReg);
 	(*pScreen->HandleExposures)(pWin->parent);
 
 	if (pScreen->PostValidateTree)
@@ -1003,8 +1003,8 @@ miOverlayWindowExposures(
     RegionPtr   exposures = prgn;
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
-    if ((prgn && !REGION_NIL(prgn)) || 
-	(exposures && !REGION_NIL(exposures)) || other_exposed)
+    if ((prgn && !RegionNil(prgn)) ||
+	(exposures && !RegionNil(exposures)) || other_exposed)
     {
 	RegionRec   expRec;
 	int	    clientInterested;
@@ -1013,51 +1013,51 @@ miOverlayWindowExposures(
 		 	    ExposureMask;
 	if (other_exposed) {
 	    if (exposures) {
-		REGION_UNION(pScreen, other_exposed, exposures, other_exposed);
+		RegionUnion(other_exposed, exposures, other_exposed);
 		if (exposures != prgn)
-		    REGION_DESTROY(pScreen, exposures);
+		    RegionDestroy(exposures);
 	    }
 	    exposures = other_exposed;
 	}
 	if (clientInterested && exposures && 
-	   (REGION_NUM_RECTS(exposures) > RECTLIMIT))
+	   (RegionNumRects(exposures) > RECTLIMIT))
 	{
             miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
 	    BoxRec box;
 
-	    box = *REGION_EXTENTS(pScreen, exposures);
+	    box = *RegionExtents(exposures);
 	    if (exposures == prgn) {
 		exposures = &expRec;
-		REGION_INIT(pScreen, exposures, &box, 1);
-		REGION_RESET(pScreen, prgn, &box);
+		RegionInit(exposures, &box, 1);
+		RegionReset(prgn, &box);
 	    } else {
-		REGION_RESET(pScreen, exposures, &box);
-		REGION_UNION(pScreen, prgn, prgn, exposures);
+		RegionReset(exposures, &box);
+		RegionUnion(prgn, prgn, exposures);
 	    }
 	    /* This is the only reason why we are replacing mi's version
                of this file */
 	    
 	    if(!((*pPriv->InOverlay)(pWin))) {
 		miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
-		REGION_INTERSECT(pScreen, prgn, prgn, &pTree->clipList);
+		RegionIntersect(prgn, prgn, &pTree->clipList);
 	    } else
-		REGION_INTERSECT(pScreen, prgn, prgn, &pWin->clipList);
+		RegionIntersect(prgn, prgn, &pWin->clipList);
 	}
-	if (prgn && !REGION_NIL(prgn))
+	if (prgn && !RegionNil(prgn))
 	    miPaintWindow(pWin, prgn, PW_BACKGROUND);
-	if (clientInterested && exposures && !REGION_NIL(exposures))
+	if (clientInterested && exposures && !RegionNil(exposures))
 	    miSendExposures(pWin, exposures,
 			    pWin->drawable.x, pWin->drawable.y);
 	if (exposures == &expRec) {
-	    REGION_UNINIT(pScreen, exposures);
+	    RegionUninit(exposures);
 	} 
 	else if (exposures && exposures != prgn && exposures != other_exposed)
-	    REGION_DESTROY(pScreen, exposures);
+	    RegionDestroy(exposures);
 	if (prgn)
-	    REGION_EMPTY(pScreen, prgn);
+	    RegionEmpty(prgn);
     }
     else if (exposures && exposures != prgn)
-	REGION_DESTROY(pScreen, exposures);
+	RegionDestroy(exposures);
 }
 
 
@@ -1082,23 +1082,23 @@ miOverlayRecomputeExposures (
 	/*
 	 * compute exposed regions of this window
 	 */
-	REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+	RegionSubtract(&pWin->valdata->after.exposed,
 			&pWin->clipList, pValid->over);
 	/*
 	 * compute exposed regions of the border
 	 */
-	REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+	RegionSubtract(&pWin->valdata->after.borderExposed,
 			     &pWin->borderClip, &pWin->winSize);
-	REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+	RegionSubtract(&pWin->valdata->after.borderExposed,
 			     &pWin->valdata->after.borderExposed, pValid->over);
     } 
 
     if(pTree && pTree->valdata) {
-	REGION_SUBTRACT(pScreen, &pTree->valdata->exposed,
+	RegionSubtract(&pTree->valdata->exposed,
 			&pTree->clipList, pValid->under);
-	REGION_SUBTRACT(pScreen, &pTree->valdata->borderExposed,
+	RegionSubtract(&pTree->valdata->borderExposed,
 			     &pTree->borderClip, &pWin->winSize);
-	REGION_SUBTRACT(pScreen, &pTree->valdata->borderExposed,
+	RegionSubtract(&pTree->valdata->borderExposed,
 			     &pTree->valdata->borderExposed, pValid->under);    
     } else if (!pWin->valdata)
 	return WT_NOMATCH;
@@ -1154,11 +1154,11 @@ miOverlayResizeWindow(
 	/*
 	 * save the visible region of the window
 	 */
-	oldRegion = REGION_CREATE(pScreen, NullBox, 1);
-	REGION_COPY(pScreen, oldRegion, &pWin->winSize);
+	oldRegion = RegionCreate(NullBox, 1);
+	RegionCopy(oldRegion, &pWin->winSize);
 	if(doUnderlay) {
-	    oldRegion2 = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, oldRegion2, &pWin->winSize);
+	    oldRegion2 = RegionCreate(NullBox, 1);
+	    RegionCopy(oldRegion2, &pWin->winSize);
 	}
 
 	/*
@@ -1170,16 +1170,16 @@ miOverlayResizeWindow(
 	    g = pChild->winGravity;
 	    if (g != UnmapGravity) {
 		if (!gravitate[g])
-		    gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_UNION(pScreen, gravitate[g],
+		    gravitate[g] = RegionCreate(NullBox, 1);
+		RegionUnion(gravitate[g],
 				   gravitate[g], &pChild->borderClip);
 		
 		if(doUnderlay) {
 		    if (!gravitate2[g])
-			gravitate2[g] = REGION_CREATE(pScreen, NullBox, 0);
+			gravitate2[g] = RegionCreate(NullBox, 0);
 		
 		    if((tChild = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
-		        REGION_UNION(pScreen, gravitate2[g],
+		        RegionUnion(gravitate2[g],
 				   gravitate2[g], &tChild->borderClip);
 		    } else 
 			CollectUnderlayChildrenRegions(pChild, gravitate2[g]);
@@ -1193,11 +1193,11 @@ miOverlayResizeWindow(
 
 	oldWinClip = oldWinClip2 = NULL;
 	if (pWin->bitGravity != ForgetGravity) {
-	    oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
+	    oldWinClip = RegionCreate(NullBox, 1);
+	    RegionCopy(oldWinClip, &pWin->clipList);
 	    if(pTree) {
-		oldWinClip2 = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_COPY(pScreen, oldWinClip2, &pTree->clipList);
+		oldWinClip2 = RegionCreate(NullBox, 1);
+		RegionCopy(oldWinClip2, &pTree->clipList);
 	    }
 	}
 	/*
@@ -1213,26 +1213,26 @@ miOverlayResizeWindow(
 	if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
 	    HasBorder (pWin))
 	{
-	    borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+	    borderVisible = RegionCreate(NullBox, 1);
 	    if(pTree)
-		borderVisible2 = REGION_CREATE(pScreen, NullBox, 1);
+		borderVisible2 = RegionCreate(NullBox, 1);
 	    /* for tiled borders, we punt and draw the whole thing */
 	    if (pWin->borderIsPixel || !moved)
 	    {
 		if (shrunk || moved)
-		    REGION_SUBTRACT(pScreen, borderVisible,
+		    RegionSubtract(borderVisible,
 					  &pWin->borderClip,
 					  &pWin->winSize);
 		else
-		    REGION_COPY(pScreen, borderVisible,
+		    RegionCopy(borderVisible,
 					    &pWin->borderClip);
 		if(pTree) {
 		    if (shrunk || moved)
-			REGION_SUBTRACT(pScreen, borderVisible,
+			RegionSubtract(borderVisible,
 					  &pTree->borderClip,
 					  &pWin->winSize);
 		    else
-			REGION_COPY(pScreen, borderVisible,
+			RegionCopy(borderVisible,
 					    &pTree->borderClip);
 		}
 	    }
@@ -1259,7 +1259,7 @@ miOverlayResizeWindow(
     pFirstChange = MoveWindowInStack(pWin, pSib);
 
     if (WasViewable) {
-	pRegion = REGION_CREATE(pScreen, NullBox, 1);
+	pRegion = RegionCreate(NullBox, 1);
 
 	(*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, NULL);
 
@@ -1274,9 +1274,9 @@ miOverlayResizeWindow(
 	 * the entire window is trashed unless bitGravity
 	 * recovers portions of it
 	 */
-	REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
+	RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList);
 	if(pTree)
-	    REGION_COPY(pScreen, &pTree->valdata->exposed, &pTree->clipList);
+	    RegionCopy(&pTree->valdata->exposed, &pTree->clipList);
     }
 
     GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
@@ -1304,20 +1304,20 @@ miOverlayResizeWindow(
 		dx = (oldx - nx) - offx;
 		dy = (oldy - ny) - offy;
 		if (dx || dy) {
-		    REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
+		    RegionTranslate(&pWin->winSize, dx, dy);
 		    offx += dx;
 		    offy += dy;
 		}
 		if(gravitate[g])
-		    REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
+		    RegionIntersect(gravitate[g], gravitate[g],
 				 &pWin->winSize);
 		if(gravitate2[g])
-		    REGION_INTERSECT(pScreen, gravitate2[g], gravitate2[g],
+		    RegionIntersect(gravitate2[g], gravitate2[g],
 				 &pWin->winSize);
 	    }
 	    /* get winSize back where it belongs */
 	    if (offx || offy)
-		REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
+		RegionTranslate(&pWin->winSize, -offx, -offy);
 	}
 	/*
 	 * add screen bits to the appropriate bucket
@@ -1325,22 +1325,22 @@ miOverlayResizeWindow(
 
 	if (oldWinClip2)
 	{
-	    REGION_COPY(pScreen, pRegion, oldWinClip2);
-	    REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
-	    REGION_INTERSECT(pScreen, oldWinClip2, pRegion, &pTree->clipList);
+	    RegionCopy(pRegion, oldWinClip2);
+	    RegionTranslate(pRegion, nx - oldx, ny - oldy);
+	    RegionIntersect(oldWinClip2, pRegion, &pTree->clipList);
 
 	    for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
 		if (gravitate2[g])
-		    REGION_SUBTRACT(pScreen, oldWinClip2, oldWinClip2,
+		    RegionSubtract(oldWinClip2, oldWinClip2,
 					gravitate2[g]);
 	    }
-	    REGION_TRANSLATE(pScreen, oldWinClip2, oldx - nx, oldy - ny);
+	    RegionTranslate(oldWinClip2, oldx - nx, oldy - ny);
 	    g = pWin->bitGravity;
 	    if (!gravitate2[g])
 		gravitate2[g] = oldWinClip2;
 	    else {
-		REGION_UNION(pScreen,gravitate2[g],gravitate2[g],oldWinClip2);
-		REGION_DESTROY(pScreen, oldWinClip2);
+		RegionUnion(gravitate2[g],gravitate2[g],oldWinClip2);
+		RegionDestroy(oldWinClip2);
 	    }
 	}
 
@@ -1349,9 +1349,9 @@ miOverlayResizeWindow(
 	    /*
 	     * clip to new clipList
 	     */
-	    REGION_COPY(pScreen, pRegion, oldWinClip);
-	    REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
-	    REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
+	    RegionCopy(pRegion, oldWinClip);
+	    RegionTranslate(pRegion, nx - oldx, ny - oldy);
+	    RegionIntersect(oldWinClip, pRegion, &pWin->clipList);
 	    /*
 	     * don't step on any gravity bits which will be copied after this
 	     * region.	Note -- this assumes that the regions will be copied
@@ -1359,16 +1359,16 @@ miOverlayResizeWindow(
 	     */
 	    for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
 		if (gravitate[g])
-		    REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
+		    RegionSubtract(oldWinClip, oldWinClip,
 					gravitate[g]);
 	    }
-	    REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
+	    RegionTranslate(oldWinClip, oldx - nx, oldy - ny);
 	    g = pWin->bitGravity;
 	    if (!gravitate[g])
 		gravitate[g] = oldWinClip;
 	    else {
-		REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
-		REGION_DESTROY(pScreen, oldWinClip);
+		RegionUnion(gravitate[g], gravitate[g], oldWinClip);
+		RegionDestroy(oldWinClip);
 	    }
 	}
 
@@ -1392,23 +1392,23 @@ miOverlayResizeWindow(
 	    /* only copy the remaining useful bits */
 
 	    if(gravitate[g])
-		REGION_INTERSECT(pScreen, gravitate[g], 
+		RegionIntersect(gravitate[g],
 				 gravitate[g], oldRegion);
 	    if(gravitate2[g])
-		REGION_INTERSECT(pScreen, gravitate2[g], 
+		RegionIntersect(gravitate2[g],
 				 gravitate2[g], oldRegion2);
 
 	    /* clip to not overwrite already copied areas */
 
 	    if (destClip && gravitate[g]) {
-		REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
-		REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
-		REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
+		RegionTranslate(destClip, oldpt.x - x, oldpt.y - y);
+		RegionSubtract(gravitate[g], gravitate[g], destClip);
+		RegionTranslate(destClip, x - oldpt.x, y - oldpt.y);
 	    }
 	    if (destClip2 && gravitate2[g]) {
-		REGION_TRANSLATE(pScreen, destClip2, oldpt.x - x, oldpt.y - y);
-		REGION_SUBTRACT(pScreen,gravitate2[g],gravitate2[g],destClip2);
-		REGION_TRANSLATE(pScreen, destClip2, x - oldpt.x, y - oldpt.y);
+		RegionTranslate(destClip2, oldpt.x - x, oldpt.y - y);
+		RegionSubtract(gravitate2[g],gravitate2[g],destClip2);
+		RegionTranslate(destClip2, x - oldpt.x, y - oldpt.y);
 	    }
 
 	    /* and move those bits */
@@ -1429,9 +1429,9 @@ miOverlayResizeWindow(
 	    /* remove any overwritten bits from the remaining useful bits */
 
 	    if(gravitate[g])
-		REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
+		RegionSubtract(oldRegion, oldRegion, gravitate[g]);
 	    if(gravitate2[g])
-		REGION_SUBTRACT(pScreen, oldRegion2, oldRegion2, gravitate2[g]);
+		RegionSubtract(oldRegion2, oldRegion2, gravitate2[g]);
 
 	    /*
 	     * recompute exposed regions of child windows
@@ -1456,38 +1456,38 @@ miOverlayResizeWindow(
 
 	    if (g == pWin->bitGravity) {
 		if(gravitate[g])
-		    REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+		    RegionSubtract(&pWin->valdata->after.exposed,
 				&pWin->valdata->after.exposed, gravitate[g]);
 		if(gravitate2[g] && pTree) 
-		    REGION_SUBTRACT(pScreen, &pTree->valdata->exposed,
+		    RegionSubtract(&pTree->valdata->exposed,
 				&pTree->valdata->exposed, gravitate2[g]);
 	    }
 	    if(gravitate[g]) {
 		if (!destClip)
 		    destClip = gravitate[g];
 		else {
-		    REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
-		    REGION_DESTROY(pScreen, gravitate[g]);
+		    RegionUnion(destClip, destClip, gravitate[g]);
+		    RegionDestroy(gravitate[g]);
 		}
 	    }
 	    if(gravitate2[g]) {
 		if (!destClip2)
 		    destClip2 = gravitate2[g];
 		else {
-		    REGION_UNION(pScreen, destClip2, destClip2, gravitate2[g]);
-		    REGION_DESTROY(pScreen, gravitate2[g]);
+		    RegionUnion(destClip2, destClip2, gravitate2[g]);
+		    RegionDestroy(gravitate2[g]);
 		}
 	    }
 	}
 
-	REGION_DESTROY(pScreen, pRegion);
-	REGION_DESTROY(pScreen, oldRegion);
+	RegionDestroy(pRegion);
+	RegionDestroy(oldRegion);
 	if(doUnderlay)
-	    REGION_DESTROY(pScreen, oldRegion2);
+	    RegionDestroy(oldRegion2);
 	if (destClip)
-	    REGION_DESTROY(pScreen, destClip);
+	    RegionDestroy(destClip);
 	if (destClip2)
-	    REGION_DESTROY(pScreen, destClip2);
+	    RegionDestroy(destClip2);
 	(*pScreen->HandleExposures)(pWin->parent);
 	if (pScreen->PostValidateTree)
 	    (*pScreen->PostValidateTree)(pWin->parent, pFirstChange, VTOther);
@@ -1510,8 +1510,8 @@ miOverlaySetShape(WindowPtr pWin, int kind)
             if (HasBorder (pWin)) {
                 RegionPtr borderVisible;
 
-                borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-                REGION_SUBTRACT(pScreen, borderVisible,
+                borderVisible = RegionCreate(NullBox, 1);
+                RegionSubtract(borderVisible,
                                         &pWin->borderClip, &pWin->winSize);
                 pWin->valdata->before.borderVisible = borderVisible;
                 pWin->valdata->before.resized = TRUE;
@@ -1519,8 +1519,8 @@ miOverlaySetShape(WindowPtr pWin, int kind)
                     miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
                     RegionPtr borderVisible2;
 
-                    borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
-                    REGION_SUBTRACT(pScreen, borderVisible2,
+                    borderVisible2 = RegionCreate(NULL, 1);
+                    RegionSubtract(borderVisible2,
                                         &pTree->borderClip, &pWin->winSize);
                     pTree->valdata->borderVisible = borderVisible2;
                 }
@@ -1579,16 +1579,16 @@ miOverlayChangeBorderWidth(
 
 	    if (HadBorder) {
 		RegionPtr   borderVisible;
-		borderVisible = REGION_CREATE(pScreen, NULL, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
+		borderVisible = RegionCreate(NULL, 1);
+		RegionSubtract(borderVisible,
 				      &pWin->borderClip, &pWin->winSize);
 		pWin->valdata->before.borderVisible = borderVisible;
 		if(IN_UNDERLAY(pWin)) {
 		    miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
 		    RegionPtr borderVisible2;
 
-		    borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
-		    REGION_SUBTRACT(pScreen, borderVisible2,
+		    borderVisible2 = RegionCreate(NULL, 1);
+		    RegionSubtract(borderVisible2,
 				      &pTree->borderClip, &pWin->winSize);
 		    pTree->valdata->borderVisible = borderVisible2;
 		}
@@ -1623,11 +1623,11 @@ miOverlaySetRootClip(ScreenPtr pScreen, Bool enable)
 	box.x2 = pScreen->width;
 	box.y2 = pScreen->height;
 
-	REGION_RESET(pScreen, &pTree->borderClip, &box);
+	RegionReset(&pTree->borderClip, &box);
     } else 
-	REGION_EMPTY(pScreen, &pTree->borderClip);
+	RegionEmpty(&pTree->borderClip);
 
-    REGION_BREAK(pScreen, &pTree->clipList);
+    RegionBreak(&pTree->clipList);
 }
 
 static void 
@@ -1662,7 +1662,7 @@ miOverlayClearToBackground(
     clipList = ((*pScreenPriv->InOverlay)(pWin)) ? &pWin->clipList :
                                                  &pTree->clipList;
 
-    extents = REGION_EXTENTS(pScreen, clipList);
+    extents = RegionExtents(clipList);
     
     if (x1 < extents->x1) x1 = extents->x1;
     if (x2 > extents->x2) x2 = extents->x2;
@@ -1675,16 +1675,16 @@ miOverlayClearToBackground(
     box.x1 = x1; box.x2 = x2;
     box.y1 = y1; box.y2 = y2;
 
-    REGION_INIT(pScreen, &reg, &box, 1);
+    RegionInit(&reg, &box, 1);
 
-    REGION_INTERSECT(pScreen, &reg, &reg, clipList);
+    RegionIntersect(&reg, &reg, clipList);
     if (generateExposures)
         (*pScreen->WindowExposures)(pWin, &reg, pBSReg);
     else if (pWin->backgroundState != None)
 	miPaintWindow(pWin, &reg, PW_BACKGROUND);
-    REGION_UNINIT(pScreen, &reg);
+    RegionUninit(&reg);
     if (pBSReg)
-        REGION_DESTROY(pScreen, pBSReg);
+        RegionDestroy(pBSReg);
 }
 
 
@@ -1738,12 +1738,12 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
     }
 
     if (pGC->subWindowMode == IncludeInferiors) {
-	pregWin = REGION_CREATE(pScreen, NullBox, 1);
+	pregWin = RegionCreate(NullBox, 1);
 	freeTmpClip = TRUE;
 	if (pWin->parent || (screenIsSaved != SCREEN_SAVER_ON) ||
 		!HasSaverWindow (pScreen))
 	{
-            REGION_INTERSECT(pScreen,pregWin,&pTree->borderClip,&pWin->winSize);
+            RegionIntersect(pregWin,&pTree->borderClip,&pWin->winSize);
 	}
     } else {
 	pregWin = &pTree->clipList;
@@ -1752,29 +1752,29 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
     freeCompClip = pGC->freeCompClip;
     if (pGC->clientClipType == CT_NONE) {
 	if (freeCompClip) 
-	    REGION_DESTROY(pScreen, pGC->pCompositeClip);
+	    RegionDestroy(pGC->pCompositeClip);
 	pGC->pCompositeClip = pregWin;
 	pGC->freeCompClip = freeTmpClip;
     } else {
-	REGION_TRANSLATE(pScreen, pGC->clientClip,
+	RegionTranslate(pGC->clientClip,
 				pWin->drawable.x + pGC->clipOrg.x,
 				pWin->drawable.y + pGC->clipOrg.y);
 
 	if (freeCompClip) {
-	    REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+	    RegionIntersect(pGC->pCompositeClip,
 					    pregWin, pGC->clientClip);
 	    if (freeTmpClip)
-		REGION_DESTROY(pScreen, pregWin);
+		RegionDestroy(pregWin);
 	} else if (freeTmpClip) {
-	    REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+	    RegionIntersect(pregWin, pregWin, pGC->clientClip);
 	    pGC->pCompositeClip = pregWin;
 	} else {
-	    pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
-	    REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+	    pGC->pCompositeClip = RegionCreate(NullBox, 0);
+	    RegionIntersect(pGC->pCompositeClip,
 				       pregWin, pGC->clientClip);
 	}
 	pGC->freeCompClip = TRUE;
-	REGION_TRANSLATE(pScreen, pGC->clientClip,
+	RegionTranslate(pGC->clientClip,
 				-(pWin->drawable.x + pGC->clipOrg.x),
 				-(pWin->drawable.y + pGC->clipOrg.y));
     }
@@ -1792,7 +1792,7 @@ miOverlayCollectUnderlayRegions(
 	return FALSE;
     }
 
-    *region = REGION_CREATE(pWin->drawable.pScreen, NullBox, 0);
+    *region = RegionCreate(NullBox, 0);
     
     CollectUnderlayChildrenRegions(pWin, *region);
 
@@ -1913,7 +1913,7 @@ CollectUnderlayChildrenRegions(WindowPtr pWin, RegionPtr pReg)
 
     while(1) {
 	if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
-	    REGION_APPEND(pScreen, pReg, &pTree->borderClip);
+	    RegionAppend(pReg, &pTree->borderClip);
 	    hasUnderlay = TRUE;
 	} else
 	if(pChild->firstChild) {
@@ -1931,7 +1931,7 @@ CollectUnderlayChildrenRegions(WindowPtr pWin, RegionPtr pReg)
 
     if(hasUnderlay) {
 	Bool overlap;
-	REGION_VALIDATE(pScreen, pReg, &overlap);
+	RegionValidate(pReg, &overlap);
     } 
 
     return hasUnderlay;
diff --git a/mi/mispans.h b/mi/mispans.h
index ef090bb..c3a3e67 100644
--- a/mi/mispans.h
+++ b/mi/mispans.h
@@ -85,16 +85,6 @@ extern _X_EXPORT void miFreeSpanGroup(
     SpanGroup * /*spanGroup*/
 );
 
-extern _X_EXPORT int RegionClipSpans(
-    RegionPtr /*prgnDst*/,
-    DDXPointPtr /*ppt*/,
-    int * /*pwidth*/,
-    int /*nspans*/,
-    DDXPointPtr /*pptNew*/,
-    int * /*pwidthNew*/,
-    int /*fSorted*/
-);
-
 /* Rops which must use span groups */
 #define miSpansCarefulRop(rop)	(((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
 #define miSpansEasyRop(rop)	(!miSpansCarefulRop(rop))
diff --git a/mi/mivaltree.c b/mi/mivaltree.c
index cfcdab7..dc88c4d 100644
--- a/mi/mivaltree.c
+++ b/mi/mivaltree.c
@@ -116,8 +116,8 @@ miShapedWindowIn (ScreenPtr pScreen, RegionPtr universe, RegionPtr bounding,
     Bool	someIn, someOut;
     int 	t, x1, y1, x2, y2;
 
-    nbox = REGION_NUM_RECTS (bounding);
-    boundBox = REGION_RECTS (bounding);
+    nbox = RegionNumRects (bounding);
+    boundBox = RegionRects (bounding);
     someIn = someOut = FALSE;
     x1 = rect->x1;
     y1 = rect->y1;
@@ -141,7 +141,7 @@ miShapedWindowIn (ScreenPtr pScreen, RegionPtr universe, RegionPtr bounding,
 	    box.x2 = box.x1;
 	if (box.y1 > box.y2)
 	    box.y2 = box.y1;
-	switch (RECT_IN_REGION(pScreen, universe, &box))
+	switch (RegionContainsRect(universe, &box))
 	{
 	case rgnIN:
 	    if (someOut)
@@ -252,15 +252,15 @@ miComputeClips (
 	if (miSetRedirectBorderClipProc)
 	{
 	    if (TreatAsTransparent (pParent))
-		REGION_EMPTY (pScreen, universe);
+		RegionEmpty(universe);
 	    (*miSetRedirectBorderClipProc) (pParent, universe);
 	}
-	REGION_COPY(pScreen, universe, &pParent->borderSize);
+	RegionCopy(universe, &pParent->borderSize);
     }
 #endif
 
     oldVis = pParent->visibility;
-    switch (RECT_IN_REGION( pScreen, universe, &borderSize)) 
+    switch (RegionContainsRect(universe, &borderSize))
     {
 	case rgnIN:
 	    newVis = VisibilityUnobscured;
@@ -320,9 +320,9 @@ miComputeClips (
 		{
 		    if (pChild->visibility != VisibilityFullyObscured)
 		    {
-			REGION_TRANSLATE( pScreen, &pChild->borderClip,
+			RegionTranslate(&pChild->borderClip,
 						      dx, dy);
-			REGION_TRANSLATE( pScreen, &pChild->clipList,
+			RegionTranslate(&pChild->clipList,
 						      dx, dy);
 			pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 			if (pScreen->ClipNotify)
@@ -331,16 +331,16 @@ miComputeClips (
 		    }
 		    if (pChild->valdata)
 		    {
-			REGION_NULL(pScreen,
+			RegionNull(
 				    &pChild->valdata->after.borderExposed);
 			if (HasParentRelativeBorder(pChild))
 			{
-			    REGION_SUBTRACT(pScreen,
+			    RegionSubtract(
 					 &pChild->valdata->after.borderExposed,
 					 &pChild->borderClip,
 					 &pChild->winSize);
 			}
-			REGION_NULL(pScreen, &pChild->valdata->after.exposed);
+			RegionNull(&pChild->valdata->after.exposed);
 		    }
 		    if (pChild->firstChild)
 		    {
@@ -369,20 +369,20 @@ miComputeClips (
 	     * We translate the old clipList because that will be exposed or copied
 	     * if gravity is right.
 	     */
-	    REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy);
-	    REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy);
+	    RegionTranslate(&pParent->borderClip, dx, dy);
+	    RegionTranslate(&pParent->clipList, dx, dy);
     	} 
 	break;
     case VTBroken:
-	REGION_EMPTY (pScreen, &pParent->borderClip);
-	REGION_EMPTY (pScreen, &pParent->clipList);
+	RegionEmpty(&pParent->borderClip);
+	RegionEmpty(&pParent->clipList);
 	break;
     }
 
     borderVisible = pParent->valdata->before.borderVisible;
     resized = pParent->valdata->before.resized;
-    REGION_NULL(pScreen, &pParent->valdata->after.borderExposed);
-    REGION_NULL(pScreen, &pParent->valdata->after.exposed);
+    RegionNull(&pParent->valdata->after.borderExposed);
+    RegionNull(&pParent->valdata->after.exposed);
 
     /*
      * Since the borderClip must not be clipped by the children, we do
@@ -402,22 +402,22 @@ miComputeClips (
 	     * of the border will be saved by DIX in borderVisible --
 	     * use that region and destroy it
 	     */
-	    REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
-	    REGION_DESTROY( pScreen, borderVisible);
+	    RegionSubtract(exposed, universe, borderVisible);
+	    RegionDestroy(borderVisible);
     	}
     	else
     	{
-	    REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip);
+	    RegionSubtract(exposed, universe, &pParent->borderClip);
     	}
 	if (HasParentRelativeBorder(pParent) && (dx || dy))
-	    REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+	    RegionSubtract(&pParent->valdata->after.borderExposed,
 				  universe,
 				  &pParent->winSize);
 	else
-	    REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+	    RegionSubtract(&pParent->valdata->after.borderExposed,
 			       exposed, &pParent->winSize);
 
-    	REGION_COPY( pScreen, &pParent->borderClip, universe);
+	RegionCopy(&pParent->borderClip, universe);
     
     	/*
      	 * To get the right clipList for the parent, and to make doubly sure
@@ -425,15 +425,15 @@ miComputeClips (
      	 * border from the universe before proceeding.
      	 */
     
-    	REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+	RegionIntersect(universe, universe, &pParent->winSize);
     }
     else
-    	REGION_COPY( pScreen, &pParent->borderClip, universe);
+	RegionCopy(&pParent->borderClip, universe);
     
     if ((pChild = pParent->firstChild) && pParent->mapped)
     {
-	REGION_NULL(pScreen, &childUniverse);
-	REGION_NULL(pScreen, &childUnion);
+	RegionNull(&childUniverse);
+	RegionNull(&childUnion);
 	if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
 	    ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
 	     (pChild->drawable.x < pParent->lastChild->drawable.x)))
@@ -441,7 +441,7 @@ miComputeClips (
 	    for (; pChild; pChild = pChild->nextSib)
 	    {
 		if (pChild->viewable && !TreatAsTransparent(pChild))
-		    REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+		    RegionAppend(&childUnion, &pChild->borderSize);
 	    }
 	}
 	else
@@ -449,10 +449,10 @@ miComputeClips (
 	    for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
 	    {
 		if (pChild->viewable && !TreatAsTransparent(pChild))
-		    REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+		    RegionAppend(&childUnion, &pChild->borderSize);
 	    }
 	}
-	REGION_VALIDATE( pScreen, &childUnion, &overlap);
+	RegionValidate(&childUnion, &overlap);
 
 	for (pChild = pParent->firstChild;
 	     pChild;
@@ -469,7 +469,7 @@ miComputeClips (
 		     * Figure out the new universe from the child's
 		     * perspective and recurse.
 		     */
-		    REGION_INTERSECT( pScreen, &childUniverse,
+		    RegionIntersect(&childUniverse,
 					    universe,
 					    &pChild->borderSize);
 		    miComputeClips (pChild, pScreen, &childUniverse, kind,
@@ -481,14 +481,14 @@ miComputeClips (
 		 * other sibling.
 		 */
 		if (overlap && !TreatAsTransparent (pChild))
-		    REGION_SUBTRACT( pScreen, universe, universe,
+		    RegionSubtract(universe, universe,
 					  &pChild->borderSize);
 	    }
 	}
 	if (!overlap)
-	    REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
-	REGION_UNINIT( pScreen, &childUnion);
-	REGION_UNINIT( pScreen, &childUniverse);
+	    RegionSubtract(universe, universe, &childUnion);
+	RegionUninit(&childUnion);
+	RegionUninit(&childUniverse);
     } /* if any children */
 
     /*
@@ -501,12 +501,12 @@ miComputeClips (
     if (oldVis == VisibilityFullyObscured ||
 	oldVis == VisibilityNotViewable)
     {
-	REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe);
+	RegionCopy(&pParent->valdata->after.exposed, universe);
     }
     else if (newVis != VisibilityFullyObscured &&
 	     newVis != VisibilityNotViewable)
     {
-    	REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
+	RegionSubtract(&pParent->valdata->after.exposed,
 			       universe, &pParent->clipList);
     }
 
@@ -520,7 +520,7 @@ miComputeClips (
     }
 
 #ifdef NOTDEF
-    REGION_COPY( pScreen, &pParent->clipList, universe);
+    RegionCopy(&pParent->clipList, universe);
 #endif
 
     pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
@@ -616,8 +616,8 @@ miValidateTree (
     if (pChild == NullWindow)
 	pChild = pParent->firstChild;
 
-    REGION_NULL(pScreen, &childClip);
-    REGION_NULL(pScreen, &exposed);
+    RegionNull(&childClip);
+    RegionNull(&exposed);
 
     /*
      * compute the area of the parent window occupied
@@ -625,10 +625,10 @@ miValidateTree (
      * is the area which can be divied up among the marked
      * children in their new configuration.
      */
-    REGION_NULL(pScreen, &totalClip);
+    RegionNull(&totalClip);
     viewvals = 0;
-    if (REGION_BROKEN (pScreen, &pParent->clipList) &&
-	!REGION_BROKEN (pScreen, &pParent->borderClip))
+    if (RegionBroken(&pParent->clipList) &&
+	!RegionBroken(&pParent->borderClip))
     {
 	kind = VTBroken;
 	/*
@@ -636,19 +636,19 @@ miValidateTree (
 	 * assume everything is busted.
 	 */
 	forward = TRUE;
-	REGION_COPY (pScreen, &totalClip, &pParent->borderClip);
-	REGION_INTERSECT (pScreen, &totalClip, &totalClip, &pParent->winSize);
+	RegionCopy(&totalClip, &pParent->borderClip);
+	RegionIntersect(&totalClip, &totalClip, &pParent->winSize);
 	
 	for (pWin = pParent->firstChild; pWin != pChild; pWin = pWin->nextSib)
 	{
 	    if (pWin->viewable && !TreatAsTransparent (pWin))
-		REGION_SUBTRACT (pScreen, &totalClip, &totalClip, &pWin->borderSize);
+		RegionSubtract(&totalClip, &totalClip, &pWin->borderSize);
 	}
 	for (pWin = pChild; pWin; pWin = pWin->nextSib)
 	    if (pWin->valdata && pWin->viewable)
 		viewvals++;
 	
-	REGION_EMPTY (pScreen, &pParent->clipList);
+	RegionEmpty(&pParent->clipList);
     }
     else 
     {
@@ -666,7 +666,7 @@ miValidateTree (
 		    if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc)
 			pBorderClip = (*miGetRedirectBorderClipProc)(pWin);
 #endif
-		    REGION_APPEND( pScreen, &totalClip, pBorderClip );
+		    RegionAppend(&totalClip, pBorderClip );
 		    if (pWin->viewable)
 			viewvals++;
 		}
@@ -685,7 +685,7 @@ miValidateTree (
 		    if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc)
 			pBorderClip = (*miGetRedirectBorderClipProc)(pWin);
 #endif
-		    REGION_APPEND( pScreen, &totalClip, pBorderClip );
+		    RegionAppend(&totalClip, pBorderClip );
 		    if (pWin->viewable)
 			viewvals++;
 		}
@@ -694,7 +694,7 @@ miValidateTree (
 		pWin = pWin->prevSib;
 	    }
 	}
-	REGION_VALIDATE( pScreen, &totalClip, &overlap);
+	RegionValidate(&totalClip, &overlap);
     }
 
     /*
@@ -707,7 +707,7 @@ miValidateTree (
     overlap = TRUE;
     if (kind != VTStack)
     {
-	REGION_UNION( pScreen, &totalClip, &totalClip, &pParent->clipList);
+	RegionUnion(&totalClip, &totalClip, &pParent->clipList);
 	if (viewvals > 1)
 	{
 	    /*
@@ -717,12 +717,12 @@ miValidateTree (
 	     * lower than the cost of multiple Subtracts in the
 	     * loop below.
 	     */
-	    REGION_NULL(pScreen, &childUnion);
+	    RegionNull(&childUnion);
 	    if (forward)
 	    {
 		for (pWin = pChild; pWin; pWin = pWin->nextSib)
 		    if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin))
-			REGION_APPEND( pScreen, &childUnion,
+			RegionAppend(&childUnion,
 						   &pWin->borderSize);
 	    }
 	    else
@@ -731,16 +731,16 @@ miValidateTree (
 		while (1)
 		{
 		    if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin))
-			REGION_APPEND( pScreen, &childUnion,
+			RegionAppend(&childUnion,
 						   &pWin->borderSize);
 		    if (pWin == pChild)
 			break;
 		    pWin = pWin->prevSib;
 		}
 	    }
-	    REGION_VALIDATE(pScreen, &childUnion, &overlap);
+	    RegionValidate(&childUnion, &overlap);
 	    if (overlap)
-		REGION_UNINIT(pScreen, &childUnion);
+		RegionUninit(&childUnion);
 	}
     }
 
@@ -750,13 +750,13 @@ miValidateTree (
     {
 	if (pWin->viewable) {
 	    if (pWin->valdata) {
-		REGION_INTERSECT( pScreen, &childClip,
+		RegionIntersect(&childClip,
 					&totalClip,
  					&pWin->borderSize);
 		miComputeClips (pWin, pScreen, &childClip, kind, &exposed);
 		if (overlap && !TreatAsTransparent (pWin))
 		{
-		    REGION_SUBTRACT( pScreen, &totalClip,
+		    RegionSubtract(&totalClip,
 				       	   &totalClip,
 				       	   &pWin->borderSize);
 		}
@@ -765,24 +765,24 @@ miValidateTree (
 	    }
 	} else {
 	    if (pWin->valdata) {
-		REGION_EMPTY( pScreen, &pWin->clipList);
+		RegionEmpty(&pWin->clipList);
 		if (pScreen->ClipNotify)
 		    (* pScreen->ClipNotify) (pWin, 0, 0);
-		REGION_EMPTY( pScreen, &pWin->borderClip);
+		RegionEmpty(&pWin->borderClip);
 		pWin->valdata = NULL;
 	    }
 	}
     }
 
-    REGION_UNINIT( pScreen, &childClip);
+    RegionUninit(&childClip);
     if (!overlap)
     {
-	REGION_SUBTRACT(pScreen, &totalClip, &totalClip, &childUnion);
-	REGION_UNINIT(pScreen, &childUnion);
+	RegionSubtract(&totalClip, &totalClip, &childUnion);
+	RegionUninit(&childUnion);
     }
 
-    REGION_NULL(pScreen, &pParent->valdata->after.exposed);
-    REGION_NULL(pScreen, &pParent->valdata->after.borderExposed);
+    RegionNull(&pParent->valdata->after.exposed);
+    RegionNull(&pParent->valdata->after.borderExposed);
 
     /*
      * each case below is responsible for updating the
@@ -798,17 +798,17 @@ miValidateTree (
 	 * exposures and obscures as per miComputeClips and reset the parent's
 	 * clipList.
 	 */
-	REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
+	RegionSubtract(&pParent->valdata->after.exposed,
 			       &totalClip, &pParent->clipList);
 	/* fall through */
     case VTMap:
-	REGION_COPY( pScreen, &pParent->clipList, &totalClip);
+	RegionCopy(&pParent->clipList, &totalClip);
 	pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	break;
     }
 
-    REGION_UNINIT( pScreen, &totalClip);
-    REGION_UNINIT( pScreen, &exposed);
+    RegionUninit(&totalClip);
+    RegionUninit(&exposed);
     if (pScreen->ClipNotify)
 	(*pScreen->ClipNotify) (pParent, 0, 0);
     return (1);
diff --git a/mi/miwindow.c b/mi/miwindow.c
index ce35974..02b4074 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -112,16 +112,16 @@ miClearToBackground(WindowPtr pWin,
     box.y2 = y2;
 
     pScreen = pWin->drawable.pScreen;
-    REGION_INIT(pScreen, &reg, &box, 1);
+    RegionInit(&reg, &box, 1);
 
-    REGION_INTERSECT(pScreen, &reg, &reg, &pWin->clipList);
+    RegionIntersect(&reg, &reg, &pWin->clipList);
     if (generateExposures)
 	(*pScreen->WindowExposures)(pWin, &reg, pBSReg);
     else if (pWin->backgroundState != None)
 	miPaintWindow(pWin, &reg, PW_BACKGROUND);
-    REGION_UNINIT(pScreen, &reg);
+    RegionUninit(&reg);
     if (pBSReg)
-	REGION_DESTROY(pScreen, pBSReg);
+	RegionDestroy(pBSReg);
 }
 
 void
@@ -164,9 +164,9 @@ miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin)
 	{
 	    if (pChild->viewable)
 	    {
-		if (REGION_BROKEN (pScreen, &pChild->winSize))
+		if (RegionBroken(&pChild->winSize))
 		    SetWinSize (pChild);
-		if (REGION_BROKEN (pScreen, &pChild->borderSize))
+		if (RegionBroken(&pChild->borderSize))
 		    SetBorderSize (pChild);
 		(* MarkWindow)(pChild);
 		if (pChild->firstChild)
@@ -186,17 +186,17 @@ miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin)
     }
     if ( (pChild = pFirst) )
     {
-	box = REGION_EXTENTS(pChild->drawable.pScreen, &pWin->borderSize);
+	box = RegionExtents(&pWin->borderSize);
 	pLast = pChild->parent->lastChild;
 	while (1)
 	{
 	    if (pChild->viewable)
 	    {
-		if (REGION_BROKEN (pScreen, &pChild->winSize))
+		if (RegionBroken(&pChild->winSize))
 		    SetWinSize (pChild);
-		if (REGION_BROKEN (pScreen, &pChild->borderSize))
+		if (RegionBroken(&pChild->borderSize))
 		    SetBorderSize (pChild);
-		if (RECT_IN_REGION(pScreen, &pChild->borderSize, box))
+		if (RegionContainsRect(&pChild->borderSize, box))
 		{
 		    (* MarkWindow)(pChild);
 		    anyMarked = TRUE;
@@ -241,11 +241,11 @@ miHandleValidateExposures(WindowPtr pWin)
     {
 	if ( (val = pChild->valdata) )
 	{
-	    if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
+	    if (RegionNotEmpty(&val->after.borderExposed))
 		miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER);
-	    REGION_UNINIT(pScreen, &val->after.borderExposed);
+	    RegionUninit(&val->after.borderExposed);
 	    (*WindowExposures)(pChild, &val->after.exposed, NullRegion);
-	    REGION_UNINIT(pScreen, &val->after.exposed);
+	    RegionUninit(&val->after.exposed);
 	    free(val);
 	    pChild->valdata = NULL;
 	    if (pChild->firstChild)
@@ -285,8 +285,8 @@ miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind)
     oldpt.y = pWin->drawable.y;
     if (WasViewable)
     {
-	oldRegion = REGION_CREATE(pScreen, NullBox, 1);
-	REGION_COPY(pScreen, oldRegion, &pWin->borderClip);
+	oldRegion = RegionCreate(NullBox, 1);
+	RegionCopy(oldRegion, &pWin->borderClip);
 	anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
     }
     pWin->origin.x = x + (int)bw;
@@ -317,7 +317,7 @@ miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind)
 	{
 	    (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind);
 	    (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion);
-	    REGION_DESTROY(pScreen, oldRegion);
+	    RegionDestroy(oldRegion);
 	    /* XXX need to retile border if ParentRelative origin */
 	    (*pScreen->HandleExposures)(pLayerWin->parent);
 	}
@@ -357,14 +357,14 @@ miRecomputeExposures (
 	/*
 	 * compute exposed regions of this window
 	 */
-	REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+	RegionSubtract(&pWin->valdata->after.exposed,
 			&pWin->clipList, pValid);
 	/*
 	 * compute exposed regions of the border
 	 */
-	REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+	RegionSubtract(&pWin->valdata->after.borderExposed,
 			     &pWin->borderClip, &pWin->winSize);
-	REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+	RegionSubtract(&pWin->valdata->after.borderExposed,
 			     &pWin->valdata->after.borderExposed, pValid);
 	return WT_WALKCHILDREN;
     }
@@ -416,8 +416,8 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	/*
 	 * save the visible region of the window
 	 */
-	oldRegion = REGION_CREATE(pScreen, NullBox, 1);
-	REGION_COPY(pScreen, oldRegion, &pWin->winSize);
+	oldRegion = RegionCreate(NullBox, 1);
+	RegionCopy(oldRegion, &pWin->winSize);
 
 	/*
 	 * categorize child windows into regions to be moved
@@ -430,8 +430,8 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	    if (g != UnmapGravity)
 	    {
 		if (!gravitate[g])
-		    gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_UNION(pScreen, gravitate[g],
+		    gravitate[g] = RegionCreate(NullBox, 1);
+		RegionUnion(gravitate[g],
 				   gravitate[g], &pChild->borderClip);
 	    }
 	    else
@@ -446,8 +446,8 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	oldWinClip = NULL;
 	if (pWin->bitGravity != ForgetGravity)
 	{
-	    oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
+	    oldWinClip = RegionCreate(NullBox, 1);
+	    RegionCopy(oldWinClip, &pWin->clipList);
 	}
 	/*
 	 * if the window is changing size, borderExposed
@@ -462,16 +462,16 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
 	    HasBorder (pWin))
 	{
-	    borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+	    borderVisible = RegionCreate(NullBox, 1);
 	    /* for tiled borders, we punt and draw the whole thing */
 	    if (pWin->borderIsPixel || !moved)
 	    {
 		if (shrunk || moved)
-		    REGION_SUBTRACT(pScreen, borderVisible,
+		    RegionSubtract(borderVisible,
 					  &pWin->borderClip,
 					  &pWin->winSize);
 		else
-		    REGION_COPY(pScreen, borderVisible,
+		    RegionCopy(borderVisible,
 					    &pWin->borderClip);
 	    }
 	}
@@ -498,7 +498,7 @@ miSlideAndSizeWindow(WindowPtr pWin,
 
     if (WasViewable)
     {
-	pRegion = REGION_CREATE(pScreen, NullBox, 1);
+	pRegion = RegionCreate(NullBox, 1);
 
 	if (pLayerWin == pWin)
 	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
@@ -520,7 +520,7 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	 * the entire window is trashed unless bitGravity
 	 * recovers portions of it
 	 */
-	REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
+	RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList);
     }
 
     GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
@@ -549,16 +549,16 @@ miSlideAndSizeWindow(WindowPtr pWin,
 		dy = (oldy - ny) - offy;
 		if (dx || dy)
 		{
-		    REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
+		    RegionTranslate(&pWin->winSize, dx, dy);
 		    offx += dx;
 		    offy += dy;
 		}
-		REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
+		RegionIntersect(gravitate[g], gravitate[g],
 				 &pWin->winSize);
 	    }
 	    /* get winSize back where it belongs */
 	    if (offx || offy)
-		REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
+		RegionTranslate(&pWin->winSize, -offx, -offy);
 	}
 	/*
 	 * add screen bits to the appropriate bucket
@@ -569,9 +569,9 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	    /*
 	     * clip to new clipList
 	     */
-	    REGION_COPY(pScreen, pRegion, oldWinClip);
-	    REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
-	    REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
+	    RegionCopy(pRegion, oldWinClip);
+	    RegionTranslate(pRegion, nx - oldx, ny - oldy);
+	    RegionIntersect(oldWinClip, pRegion, &pWin->clipList);
 	    /*
 	     * don't step on any gravity bits which will be copied after this
 	     * region.	Note -- this assumes that the regions will be copied
@@ -580,17 +580,17 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	    for (g = pWin->bitGravity + 1; g <= StaticGravity; g++)
 	    {
 		if (gravitate[g])
-		    REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
+		    RegionSubtract(oldWinClip, oldWinClip,
 					gravitate[g]);
 	    }
-	    REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
+	    RegionTranslate(oldWinClip, oldx - nx, oldy - ny);
 	    g = pWin->bitGravity;
 	    if (!gravitate[g])
 		gravitate[g] = oldWinClip;
 	    else
 	    {
-		REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
-		REGION_DESTROY(pScreen, oldWinClip);
+		RegionUnion(gravitate[g], gravitate[g], oldWinClip);
+		RegionDestroy(oldWinClip);
 	    }
 	}
 
@@ -614,14 +614,14 @@ miSlideAndSizeWindow(WindowPtr pWin,
 
 	    /* only copy the remaining useful bits */
 
-	    REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion);
+	    RegionIntersect(gravitate[g], gravitate[g], oldRegion);
 
 	    /* clip to not overwrite already copied areas */
 
 	    if (destClip) {
-		REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
-		REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
-		REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
+		RegionTranslate(destClip, oldpt.x - x, oldpt.y - y);
+		RegionSubtract(gravitate[g], gravitate[g], destClip);
+		RegionTranslate(destClip, x - oldpt.x, y - oldpt.y);
 	    }
 
 	    /* and move those bits */
@@ -637,7 +637,7 @@ miSlideAndSizeWindow(WindowPtr pWin,
 
 	    /* remove any overwritten bits from the remaining useful bits */
 
-	    REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
+	    RegionSubtract(oldRegion, oldRegion, gravitate[g]);
 
 	    /*
 	     * recompute exposed regions of child windows
@@ -647,7 +647,7 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	    {
 		if (pChild->winGravity != g)
 		    continue;
-		REGION_INTERSECT(pScreen, pRegion,
+		RegionIntersect(pRegion,
 				       &pChild->borderClip, gravitate[g]);
 		TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion);
 	    }
@@ -658,21 +658,21 @@ miSlideAndSizeWindow(WindowPtr pWin,
 	     */
 
 	    if (g == pWin->bitGravity)
-		REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+		RegionSubtract(&pWin->valdata->after.exposed,
 				     &pWin->valdata->after.exposed, gravitate[g]);
 	    if (!destClip)
 		destClip = gravitate[g];
 	    else
 	    {
-		REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
-		REGION_DESTROY(pScreen, gravitate[g]);
+		RegionUnion(destClip, destClip, gravitate[g]);
+		RegionDestroy(gravitate[g]);
 	    }
 	}
 
-	REGION_DESTROY(pScreen, oldRegion);
-	REGION_DESTROY(pScreen, pRegion);
+	RegionDestroy(oldRegion);
+	RegionDestroy(pRegion);
 	if (destClip)
-	    REGION_DESTROY(pScreen, destClip);
+	    RegionDestroy(destClip);
 	if (anyMarked)
 	    (*pScreen->HandleExposures)(pLayerWin->parent);
 	if (anyMarked && pScreen->PostValidateTree)
@@ -715,8 +715,8 @@ miSetShape(WindowPtr pWin, int kind)
                 {
                     RegionPtr borderVisible;
 
-                    borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-                    REGION_SUBTRACT(pScreen, borderVisible,
+                    borderVisible = RegionCreate(NullBox, 1);
+                    RegionSubtract(borderVisible,
                                     &pWin->borderClip, &pWin->winSize);
                     pWin->valdata->before.borderVisible = borderVisible;
                 }
@@ -789,8 +789,8 @@ miChangeBorderWidth(WindowPtr pWin, unsigned int width)
 	    if (pWin->valdata && HadBorder)
 	    {
 		RegionPtr   borderVisible;
-		borderVisible = REGION_CREATE(pScreen, NULL, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
+		borderVisible = RegionCreate(NULL, 1);
+		RegionSubtract(borderVisible,
 				      &pWin->borderClip, &pWin->winSize);
 		pWin->valdata->before.borderVisible = borderVisible;
 	    }
@@ -814,10 +814,10 @@ miMarkUnrealizedWindow(WindowPtr pChild, WindowPtr pWin, Bool fromConfigure)
 {
     if ((pChild != pWin) || fromConfigure)
     {
-	REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
+	RegionEmpty(&pChild->clipList);
 	if (pChild->drawable.pScreen->ClipNotify)
 	    (* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
-	REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
+	RegionEmpty(&pChild->borderClip);
     }
 }
 
@@ -832,7 +832,7 @@ miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
     for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
     {
 	if (pChild->drawable.depth == depth)
-	    REGION_UNION(pScreen, pReg, pReg, &pChild->borderClip);
+	    RegionUnion(pReg, pReg, &pChild->borderClip);
 
 	if (pChild->firstChild)
 	    miSegregateChildren(pChild, pReg, depth);
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index 2d8fd12..563831a 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -191,8 +191,8 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
 	ChangeGCVal vals[2];
 	RegionPtr   pCompositeClip;
 
-	pCompositeClip = REGION_CREATE (pScreen, NULL, 0);
-	REGION_COPY (pScreen, pCompositeClip, pGC->pCompositeClip);
+	pCompositeClip = RegionCreate(NULL, 0);
+	RegionCopy(pCompositeClip, pGC->pCompositeClip);
 
 	/* Either the drawable has changed, or the clip list in the drawable has
 	 * changed.  Copy the new clip list over and set the new translated
@@ -403,7 +403,7 @@ cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 	dx = ptOldOrg.x - pWin->drawable.x;
 	dy = ptOldOrg.y - pWin->drawable.y;
 
-	pExtents = REGION_EXTENTS(pScreen, prgnSrc);
+	pExtents = RegionExtents(prgnSrc);
 
 	pBackingPixmap = (PixmapPtr) cwGetBackingDrawable((DrawablePtr)pWin,
 							  &x_off, &y_off);
@@ -416,15 +416,15 @@ cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 	dst_y = src_y - dy;
 			       
 	/* Translate region (as required by API) */
-	REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+	RegionTranslate(prgnSrc, -dx, -dy);
 	
 	pGC = GetScratchGC(pBackingPixmap->drawable.depth, pScreen);
 	/*
 	 * Copy region to GC as clip, aligning as dest clip
 	 */
-	pClip = REGION_CREATE (pScreen, NULL, 0);
-	REGION_INTERSECT(pScreen, pClip, &pWin->borderClip, prgnSrc);
-	REGION_TRANSLATE(pScreen, pClip, 
+	pClip = RegionCreate(NULL, 0);
+	RegionIntersect(pClip, &pWin->borderClip, prgnSrc);
+	RegionTranslate(pClip,
 			 -pBackingPixmap->screen_x,
 			 -pBackingPixmap->screen_y);
 	
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 551cb72..935b1c0 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -129,40 +129,40 @@ damageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
 
     switch (pDamage->damageLevel) {
     case DamageReportRawRegion:
-	REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+	RegionUnion(&pDamage->damage, &pDamage->damage,
 			 pDamageRegion);
 	(*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure);
 	break;
     case DamageReportDeltaRegion:
-	REGION_NULL (pScreen, &tmpRegion);
-	REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, &pDamage->damage);
-	if (REGION_NOTEMPTY (pScreen, &tmpRegion)) {
-	    REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+	RegionNull(&tmpRegion);
+	RegionSubtract(&tmpRegion, pDamageRegion, &pDamage->damage);
+	if (RegionNotEmpty(&tmpRegion)) {
+	    RegionUnion(&pDamage->damage, &pDamage->damage,
 			 pDamageRegion);
 	    (*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure);
 	}
-	REGION_UNINIT(pScreen, &tmpRegion);
+	RegionUninit(&tmpRegion);
 	break;
     case DamageReportBoundingBox:
-	tmpBox = *REGION_EXTENTS (pScreen, &pDamage->damage);
-	REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+	tmpBox = *RegionExtents(&pDamage->damage);
+	RegionUnion(&pDamage->damage, &pDamage->damage,
 		     pDamageRegion);
-	if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &pDamage->damage))) {
+	if (!BOX_SAME (&tmpBox, RegionExtents(&pDamage->damage))) {
 	    (*pDamage->damageReport) (pDamage, &pDamage->damage,
 				      pDamage->closure);
 	}
 	break;
     case DamageReportNonEmpty:
-	was_empty = !REGION_NOTEMPTY(pScreen, &pDamage->damage);
-	REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+	was_empty = !RegionNotEmpty(&pDamage->damage);
+	RegionUnion(&pDamage->damage, &pDamage->damage,
 		     pDamageRegion);
-	if (was_empty && REGION_NOTEMPTY(pScreen, &pDamage->damage)) {
+	if (was_empty && RegionNotEmpty(&pDamage->damage)) {
 	    (*pDamage->damageReport) (pDamage, &pDamage->damage,
 				      pDamage->closure);
 	}
 	break;
     case DamageReportNone:
-	REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+	RegionUnion(&pDamage->damage, &pDamage->damage,
 		     pDamageRegion);
 	break;
     }
@@ -175,30 +175,30 @@ damageReportDamagePostRendering (DamagePtr pDamage, RegionPtr pOldDamage, Region
     RegionRec tmpRegion, newDamage;
     Bool was_empty;
 
-    REGION_UNION(pScreem, &newDamage, pOldDamage, pDamageRegion);
+    RegionUnion(&newDamage, pOldDamage, pDamageRegion);
 
     switch (pDamage->damageLevel) {
     case DamageReportRawRegion:
 	(*pDamage->damageReportPostRendering) (pDamage, pDamageRegion, pDamage->closure);
 	break;
     case DamageReportDeltaRegion:
-	REGION_NULL (pScreen, &tmpRegion);
-	REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, pOldDamage);
-	if (REGION_NOTEMPTY (pScreen, &tmpRegion)) {
+	RegionNull(&tmpRegion);
+	RegionSubtract(&tmpRegion, pDamageRegion, pOldDamage);
+	if (RegionNotEmpty(&tmpRegion)) {
 	    (*pDamage->damageReportPostRendering) (pDamage, &tmpRegion, pDamage->closure);
 	}
-	REGION_UNINIT(pScreen, &tmpRegion);
+	RegionUninit(&tmpRegion);
 	break;
     case DamageReportBoundingBox:
-	tmpBox = *REGION_EXTENTS (pScreen, pOldDamage);
-	if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &newDamage))) {
+	tmpBox = *RegionExtents(pOldDamage);
+	if (!BOX_SAME (&tmpBox, RegionExtents(&newDamage))) {
 	    (*pDamage->damageReportPostRendering) (pDamage, &newDamage,
 				      pDamage->closure);
 	}
 	break;
     case DamageReportNonEmpty:
-	was_empty = !REGION_NOTEMPTY(pScreen, pOldDamage);
-	if (was_empty && REGION_NOTEMPTY(pScreen, &newDamage)) {
+	was_empty = !RegionNotEmpty(pOldDamage);
+	if (was_empty && RegionNotEmpty(&newDamage)) {
 	    (*pDamage->damageReportPostRendering) (pDamage, &newDamage,
 				      pDamage->closure);
 	}
@@ -207,7 +207,7 @@ damageReportDamagePostRendering (DamagePtr pDamage, RegionPtr pOldDamage, Region
 	break;
     }
 
-    REGION_UNINIT(pScreen, &newDamage);
+    RegionUninit(&newDamage);
 }
 
 #if DAMAGE_DEBUG_ENABLE
@@ -233,7 +233,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 #endif
 
     /* short circuit for empty regions */
-    if (!REGION_NOTEMPTY(pScreen, pRegion))
+    if (!RegionNotEmpty(pRegion))
 	return;
     
 #ifdef COMPOSITE
@@ -248,7 +248,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 	screen_y = ((PixmapPtr) pDrawable)->screen_y - pDrawable->y;
     }
     if (screen_x || screen_y)
-        REGION_TRANSLATE (pScreen, pRegion, screen_x, screen_y);
+        RegionTranslate(pRegion, screen_x, screen_y);
 #endif
 	
     if (pDrawable->type == DRAWABLE_WINDOW &&
@@ -256,22 +256,22 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
     {
 	if (subWindowMode == ClipByChildren)
 	{
-	    REGION_INTERSECT(pScreen, pRegion, pRegion,
+	    RegionIntersect(pRegion, pRegion,
 			     &((WindowPtr)(pDrawable))->clipList);
 	}
 	else if (subWindowMode == IncludeInferiors)
 	{
 	    RegionPtr pTempRegion =
 		NotClippedByChildren((WindowPtr)(pDrawable));
-	    REGION_INTERSECT(pScreen, pRegion, pRegion, pTempRegion);
-	    REGION_DESTROY(pScreen, pTempRegion);
+	    RegionIntersect(pRegion, pRegion, pTempRegion);
+	    RegionDestroy(pTempRegion);
 	}
 	/* If subWindowMode is set to an invalid value, don't perform
 	 * any drawable-based clipping. */
     }
         
 
-    REGION_NULL (pScreen, &clippedRec);
+    RegionNull(&clippedRec);
     for (; pDamage; pDamage = pNext)
     {
 	pNext = pDamage->pNext;
@@ -316,7 +316,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 	{
 	    pDamageRegion = &clippedRec;
 	    if (pDamage->pDrawable->type == DRAWABLE_WINDOW) {
-		REGION_INTERSECT (pScreen, pDamageRegion, pRegion,
+		RegionIntersect(pDamageRegion, pRegion,
 		    &((WindowPtr)(pDamage->pDrawable))->borderClip);
 	    } else {
 		BoxRec	box;
@@ -324,14 +324,14 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 		box.y1 = draw_y;
 		box.x2 = draw_x + pDamage->pDrawable->width;
 		box.y2 = draw_y + pDamage->pDrawable->height;
-		REGION_INIT(pScreen, &pixClip, &box, 1);
-		REGION_INTERSECT (pScreen, pDamageRegion, pRegion, &pixClip);
-		REGION_UNINIT(pScreen, &pixClip);
+		RegionInit(&pixClip, &box, 1);
+		RegionIntersect(pDamageRegion, pRegion, &pixClip);
+		RegionUninit(&pixClip);
 	    }
 	    /*
 	     * Short circuit empty results
 	     */
-	    if (!REGION_NOTEMPTY(pScreen, pDamageRegion))
+	    if (!RegionNotEmpty(pDamageRegion))
 		continue;
 	}
 	
@@ -346,23 +346,23 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 	 * Move region to target coordinate space
 	 */
 	if (draw_x || draw_y)
-	    REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y);
+	    RegionTranslate(pDamageRegion, -draw_x, -draw_y);
 
 	/* Store damage region if needed after submission. */
 	if (pDamage->reportAfter || pDamage->damageMarker)
-	    REGION_UNION(pScreen, &pDamage->pendingDamage,
+	    RegionUnion(&pDamage->pendingDamage,
 			 &pDamage->pendingDamage, pDamageRegion);
 
 	/* Duplicate current damage if needed. */
 	if (pDamage->damageMarker)
-	    REGION_COPY(pScreen, &pDamage->backupDamage, &pDamage->damage);
+	    RegionCopy(&pDamage->backupDamage, &pDamage->damage);
 
 	/* Report damage now, if desired. */
 	if (!pDamage->reportAfter) {
 	    if (pDamage->damageReport)
 		damageReportDamage (pDamage, pDamageRegion);
 	    else
-		REGION_UNION(pScreen, &pDamage->damage,
+		RegionUnion(&pDamage->damage,
 			 &pDamage->damage, pDamageRegion);
 	}
 
@@ -370,14 +370,14 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 	 * translate original region back
 	 */
 	if (pDamageRegion == pRegion && (draw_x || draw_y))
-	    REGION_TRANSLATE (pScreen, pDamageRegion, draw_x, draw_y);
+	    RegionTranslate(pDamageRegion, draw_x, draw_y);
     }
 #ifdef COMPOSITE
     if (screen_x || screen_y)
-	REGION_TRANSLATE (pScreen, pRegion, -screen_x, -screen_y);
+	RegionTranslate(pRegion, -screen_x, -screen_y);
 #endif
     
-    REGION_UNINIT (pScreen, &clippedRec);
+    RegionUninit(&clippedRec);
 }
 
 static void
@@ -395,14 +395,14 @@ damageRegionProcessPending (DrawablePtr pDrawable)
 	    if (pDamage->damageReport)
 		damageReportDamage (pDamage, &pDamage->pendingDamage);
 	    else
-		REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+		RegionUnion(&pDamage->damage, &pDamage->damage,
 			&pDamage->pendingDamage);
 	}
 
 	if (pDamage->reportAfter || pDamage->damageMarker)
-	    REGION_EMPTY (pScreen, &pDamage->pendingDamage);
+	    RegionEmpty(&pDamage->pendingDamage);
 	if (pDamage->damageMarker)
-	    REGION_EMPTY (pScreen, &pDamage->backupDamage);
+	    RegionEmpty(&pDamage->backupDamage);
     }
     
 }
@@ -418,13 +418,13 @@ damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode)
 {
     RegionRec	region;
 
-    REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
+    RegionInit(&region, pBox, 1);
 #if DAMAGE_DEBUG_ENABLE
     _damageRegionAppend (pDrawable, &region, TRUE, subWindowMode, where);
 #else
     damageRegionAppend (pDrawable, &region, TRUE, subWindowMode);
 #endif
-    REGION_UNINIT (pDrawable->pScreen, &region);
+    RegionUninit(&region);
 }
 
 static void damageValidateGC(GCPtr, unsigned long, DrawablePtr);
@@ -593,7 +593,7 @@ damageDestroyClip(GCPtr pGC)
 
 #define checkGCDamage(d,g)	(getDrawableDamage(d) && \
 				 (!g->pCompositeClip ||\
-				  REGION_NOTEMPTY(d->pScreen, \
+				  RegionNotEmpty(\
 						  g->pCompositeClip)))
 
 #define TRIM_PICTURE_BOX(box, pDst) { \
@@ -605,7 +605,7 @@ damageDestroyClip(GCPtr pGC)
     }
     
 #define checkPictureDamage(p)	(getDrawableDamage(p->pDrawable) && \
-				 REGION_NOTEMPTY(pScreen, p->pCompositeClip))
+				 RegionNotEmpty(p->pCompositeClip))
 
 static void
 damageComposite (CARD8      op,
@@ -1763,9 +1763,9 @@ damageCopyWindow(WindowPtr	pWindow,
 	 * The region comes in source relative, but the damage occurs
 	 * at the destination location.  Translate back and forth.
 	 */
-	REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
+	RegionTranslate(prgnSrc, dx, dy);
 	damageRegionAppend (&pWindow->drawable, prgnSrc, FALSE, -1);
-	REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+	RegionTranslate(prgnSrc, -dx, -dy);
     }
     unwrap (pScrPriv, pScreen, CopyWindow);
     (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
@@ -1931,8 +1931,8 @@ DamageCreate (DamageReportFunc  damageReport,
 	return 0;
     pDamage->pNext = 0;
     pDamage->pNextWin = 0;
-    REGION_NULL(pScreen, &pDamage->damage);
-    REGION_NULL(pScreen, &pDamage->pendingDamage);
+    RegionNull(&pDamage->damage);
+    RegionNull(&pDamage->pendingDamage);
     
     pDamage->damageLevel = damageLevel;
     pDamage->isInternal = isInternal;
@@ -2052,8 +2052,8 @@ DamageDestroy (DamagePtr    pDamage)
     (*pScrPriv->funcs.Destroy) (pDamage);
     dixFreePrivates(pDamage->devPrivates);
     pDamage->devPrivates = NULL;
-    REGION_UNINIT (pScreen, &pDamage->damage);
-    REGION_UNINIT (pScreen, &pDamage->pendingDamage);
+    RegionUninit(&pDamage->damage);
+    RegionUninit(&pDamage->pendingDamage);
     free(pDamage);
 }
 
@@ -2065,7 +2065,7 @@ DamageSubtract (DamagePtr	    pDamage,
     RegionRec	pixmapClip;
     DrawablePtr	pDrawable = pDamage->pDrawable;
     
-    REGION_SUBTRACT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pRegion);
+    RegionSubtract(&pDamage->damage, &pDamage->damage, pRegion);
     if (pDrawable)
     {
 	if (pDrawable->type == DRAWABLE_WINDOW)
@@ -2078,22 +2078,22 @@ DamageSubtract (DamagePtr	    pDamage,
 	    box.y1 = pDrawable->y;
 	    box.x2 = pDrawable->x + pDrawable->width;
 	    box.y2 = pDrawable->y + pDrawable->height;
-	    REGION_INIT (pDrawable->pScreen, &pixmapClip, &box, 1);
+	    RegionInit(&pixmapClip, &box, 1);
 	    pClip = &pixmapClip;
 	}
-	REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, pDrawable->x, pDrawable->y);
-	REGION_INTERSECT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pClip);
-	REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, -pDrawable->x, -pDrawable->y);
+	RegionTranslate(&pDamage->damage, pDrawable->x, pDrawable->y);
+	RegionIntersect(&pDamage->damage, &pDamage->damage, pClip);
+	RegionTranslate(&pDamage->damage, -pDrawable->x, -pDrawable->y);
 	if (pDrawable->type != DRAWABLE_WINDOW)
-	    REGION_UNINIT(pDrawable->pScreen, &pixmapClip);
+	    RegionUninit(&pixmapClip);
     }
-    return REGION_NOTEMPTY (pDrawable->pScreen, &pDamage->damage);
+    return RegionNotEmpty(&pDamage->damage);
 }
 
 void
 DamageEmpty (DamagePtr	    pDamage)
 {
-    REGION_EMPTY (pDamage->pDrawable->pScreen, &pDamage->damage);
+    RegionEmpty(&pDamage->damage);
 }
 
 RegionPtr
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index dd3f953..4fb0e49 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -286,30 +286,30 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion)
        drawing inside the clip, go to some lengths to avoid the general
        case intersection. */
 
-    b1 = REGION_EXTENTS(pScreen, &pWindow->borderClip);
-    b2 = REGION_EXTENTS(pScreen, pRegion);
+    b1 = RegionExtents(&pWindow->borderClip);
+    b2 = RegionExtents(pRegion);
 
     if (EXTENTCHECK(b1, b2)) {
         /* Regions may overlap. */
 
-        if (REGION_NUM_RECTS(pRegion) == 1) {
+        if (RegionNumRects(pRegion) == 1) {
             int in;
 
             /* Damaged region only has a single rect, so we can
                just compare that against the region */
 
-            in = RECT_IN_REGION(pScreen, &pWindow->borderClip,
-                                REGION_RECTS (pRegion));
+            in = RegionContainsRect(&pWindow->borderClip,
+                                RegionRects (pRegion));
             if (in == rgnIN) {
             /* clip totally contains pRegion */
 
 #ifdef ROOTLESS_TRACK_DAMAGE
-                REGION_UNION(pScreen, &winRec->damage,
+                RegionUnion(&winRec->damage,
                                  &winRec->damage, (pRegion));
 #else
                 SCREENREC(pScreen)->imp->DamageRects(winRec->wid,
-                                REGION_NUM_RECTS(pRegion),
-                                REGION_RECTS(pRegion),
+                                RegionNumRects(pRegion),
+                                RegionRects(pRegion),
                                 -winRec->x, -winRec->y);
 #endif
 
@@ -325,20 +325,20 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion)
 
         /* clip overlaps pRegion, need to intersect */
 
-        REGION_NULL(pScreen, &clipped);
-        REGION_INTERSECT(pScreen, &clipped, &pWindow->borderClip, pRegion);
+        RegionNull(&clipped);
+        RegionIntersect(&clipped, &pWindow->borderClip, pRegion);
 
 #ifdef ROOTLESS_TRACK_DAMAGE
-        REGION_UNION(pScreen, &winRec->damage,
+        RegionUnion(&winRec->damage,
                      &winRec->damage, (pRegion));
 #else
         SCREENREC(pScreen)->imp->DamageRects(winRec->wid,
-                        REGION_NUM_RECTS(&clipped),
-                        REGION_RECTS(&clipped),
+                        RegionNumRects(&clipped),
+                        RegionRects(&clipped),
                         -winRec->x, -winRec->y);
 #endif
 
-        REGION_UNINIT(pScreen, &clipped);
+        RegionUninit(&clipped);
 
         RootlessQueueRedisplay(pTop->drawable.pScreen);
     }
@@ -346,8 +346,8 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion)
 out:
 #ifdef ROOTLESSDEBUG
     {
-        BoxRec *box = REGION_RECTS(pRegion), *end;
-        int numBox = REGION_NUM_RECTS(pRegion);
+        BoxRec *box = RegionRects(pRegion), *end;
+        int numBox = RegionNumRects(pRegion);
 
         for (end = box+numBox; box < end; box++) {
             RL_DEBUG_MSG("Damage rect: %i, %i, %i, %i\n",
@@ -369,11 +369,11 @@ RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox)
 {
     RegionRec region;
 
-    REGION_INIT(pWindow->drawable.pScreen, &region, pBox, 1);
+    RegionInit(&region, pBox, 1);
 
     RootlessDamageRegion(pWindow, &region);
 
-    REGION_UNINIT(pWindow->drawable.pScreen, &region);  /* no-op */
+    RegionUninit(&region);  /* no-op */
 }
 
 
@@ -396,11 +396,11 @@ RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h)
     box.y1 = y;
     box.y2 = y + h;
 
-    REGION_INIT(pWindow->drawable.pScreen, &region, &box, 1);
+    RegionInit(&region, &box, 1);
 
     RootlessDamageRegion(pWindow, &region);
 
-    REGION_UNINIT(pWindow->drawable.pScreen, &region);  /* no-op */
+    RegionUninit(&region);  /* no-op */
 }
 
 
@@ -418,18 +418,18 @@ RootlessRedisplay(WindowPtr pWindow)
 
     RootlessStopDrawing(pWindow, FALSE);
 
-    if (REGION_NOTEMPTY(pScreen, &winRec->damage)) {
+    if (RegionNotEmpty(&winRec->damage)) {
         RL_DEBUG_MSG("Redisplay Win 0x%x, %i x %i @ (%i, %i)\n",
                      pWindow, winRec->width, winRec->height,
                      winRec->x, winRec->y);
 
         // move region to window local coords
-        REGION_TRANSLATE(pScreen, &winRec->damage,
+        RegionTranslate(&winRec->damage,
                          -winRec->x, -winRec->y);
 
         SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, &winRec->damage);
 
-        REGION_EMPTY(pScreen, &winRec->damage);
+        RegionEmpty(&winRec->damage);
     }
 
 #else   /* !ROOTLESS_TRACK_DAMAGE */
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index d24ca04..24dcfe8 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -441,9 +441,9 @@ RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
             pChild = pWin;
             while (1) {
                 if (pChild->viewable) {
-                    if (REGION_BROKEN (pScreen, &pChild->winSize))
+                    if (RegionBroken(&pChild->winSize))
                         SetWinSize (pChild);
-                    if (REGION_BROKEN (pScreen, &pChild->borderSize))
+                    if (RegionBroken(&pChild->borderSize))
                         SetBorderSize (pChild);
                     (* MarkWindow)(pChild);
                     if (pChild->firstChild) {
diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c
index 0ee4919..0f62c28 100644
--- a/miext/rootless/rootlessValTree.c
+++ b/miext/rootless/rootlessValTree.c
@@ -122,8 +122,8 @@ RootlessShapedWindowIn (ScreenPtr pScreen, RegionPtr universe,
     Bool    someIn, someOut;
     register int t, x1, y1, x2, y2;
 
-    nbox = REGION_NUM_RECTS (bounding);
-    boundBox = REGION_RECTS (bounding);
+    nbox = RegionNumRects (bounding);
+    boundBox = RegionRects (bounding);
     someIn = someOut = FALSE;
     x1 = rect->x1;
     y1 = rect->y1;
@@ -147,7 +147,7 @@ RootlessShapedWindowIn (ScreenPtr pScreen, RegionPtr universe,
 	    box.x2 = box.x1;
 	if (box.y1 > box.y2)
 	    box.y2 = box.y1;
-	switch (RECT_IN_REGION(pScreen, universe, &box))
+	switch (RegionContainsRect(universe, &box))
 	{
 	case rgnIN:
 	    if (someOut)
@@ -224,7 +224,7 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
     borderSize.y2 = dy;
 
     oldVis = pParent->visibility;
-    switch (RECT_IN_REGION( pScreen, universe, &borderSize)) 
+    switch (RegionContainsRect(universe, &borderSize))
     {
     case rgnIN:
 	    newVis = VisibilityUnobscured;
@@ -285,9 +285,9 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 		{
 		    if (pChild->visibility != VisibilityFullyObscured)
 		    {
-			REGION_TRANSLATE( pScreen, &pChild->borderClip,
+			RegionTranslate(&pChild->borderClip,
 						      dx, dy);
-			REGION_TRANSLATE( pScreen, &pChild->clipList,
+			RegionTranslate(&pChild->clipList,
 						      dx, dy);
 			pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 			if (pScreen->ClipNotify)
@@ -296,16 +296,16 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 		    }
 		    if (pChild->valdata)
 		    {
-			REGION_NULL(pScreen,
+			RegionNull(
 				    &pChild->valdata->after.borderExposed);
 			if (HasParentRelativeBorder(pChild))
 			  {
-			    REGION_SUBTRACT(pScreen,
+			    RegionSubtract(
 					 &pChild->valdata->after.borderExposed,
 					 &pChild->borderClip,
 					 &pChild->winSize);
 			}
-			REGION_NULL(pScreen, &pChild->valdata->after.exposed);
+			RegionNull(&pChild->valdata->after.exposed);
 		    }
 		    if (pChild->firstChild)
 		    {
@@ -334,20 +334,20 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 	     * We translate the old clipList because that will be exposed or copied
 	     * if gravity is right.
 	     */
-	    REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy);
-	    REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy);
+	    RegionTranslate(&pParent->borderClip, dx, dy);
+	    RegionTranslate(&pParent->clipList, dx, dy);
     	} 
 	break;
     case VTBroken:
-	REGION_EMPTY (pScreen, &pParent->borderClip);
-	REGION_EMPTY (pScreen, &pParent->clipList);
+	RegionEmpty(&pParent->borderClip);
+	RegionEmpty(&pParent->clipList);
 	break;
     }
 
     borderVisible = pParent->valdata->before.borderVisible;
     resized = pParent->valdata->before.resized;
-    REGION_NULL(pScreen, &pParent->valdata->after.borderExposed);
-    REGION_NULL(pScreen, &pParent->valdata->after.exposed);
+    RegionNull(&pParent->valdata->after.borderExposed);
+    RegionNull(&pParent->valdata->after.exposed);
 
     /*
      * Since the borderClip must not be clipped by the children, we do
@@ -367,23 +367,23 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 	     * of the border will be saved by DIX in borderVisible --
 	     * use that region and destroy it
 	     */
-	    REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
-	    REGION_DESTROY( pScreen, borderVisible);
+	    RegionSubtract(exposed, universe, borderVisible);
+	    RegionDestroy(borderVisible);
     	}
     	else
     	{
-	    REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip);
+	    RegionSubtract(exposed, universe, &pParent->borderClip);
     	}
 	if (HasParentRelativeBorder(pParent) && (dx || dy)) {
-	    REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+	    RegionSubtract(&pParent->valdata->after.borderExposed,
 				  universe,
 				  &pParent->winSize);
 	} else {
-	    REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+	    RegionSubtract(&pParent->valdata->after.borderExposed,
 			       exposed, &pParent->winSize);
 	}
 
-    	REGION_COPY( pScreen, &pParent->borderClip, universe);
+	RegionCopy(&pParent->borderClip, universe);
     
     	/*
      	 * To get the right clipList for the parent, and to make doubly sure
@@ -391,15 +391,15 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
      	 * border from the universe before proceeding.
      	 */
     
-    	REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+	RegionIntersect(universe, universe, &pParent->winSize);
     }
     else
-    	REGION_COPY( pScreen, &pParent->borderClip, universe);
+	RegionCopy(&pParent->borderClip, universe);
     
     if ((pChild = pParent->firstChild) && pParent->mapped)
     {
-	REGION_NULL(pScreen, &childUniverse);
-	REGION_NULL(pScreen, &childUnion);
+	RegionNull(&childUniverse);
+	RegionNull(&childUnion);
 	if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
 	    ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
 	     (pChild->drawable.x < pParent->lastChild->drawable.x)))
@@ -407,7 +407,7 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 	    for (; pChild; pChild = pChild->nextSib)
 	    {
 		if (pChild->viewable)
-		    REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+		    RegionAppend(&childUnion, &pChild->borderSize);
 	    }
 	}
 	else
@@ -415,10 +415,10 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 	    for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
 	    {
 		if (pChild->viewable)
-		    REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+		    RegionAppend(&childUnion, &pChild->borderSize);
 	    }
 	}
-	REGION_VALIDATE( pScreen, &childUnion, &overlap);
+	RegionValidate(&childUnion, &overlap);
 
 	for (pChild = pParent->firstChild;
 	     pChild;
@@ -435,7 +435,7 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 		     * Figure out the new universe from the child's
 		     * perspective and recurse.
 		     */
-		    REGION_INTERSECT( pScreen, &childUniverse,
+		    RegionIntersect(&childUniverse,
 					    universe,
 					    &pChild->borderSize);
 		    RootlessComputeClips (pChild, pScreen, &childUniverse, 
@@ -447,14 +447,14 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
 		 * other sibling.
 		 */
 		if (overlap)
-		    REGION_SUBTRACT( pScreen, universe, universe,
+		    RegionSubtract(universe, universe,
 					  &pChild->borderSize);
 	    }
 	}
 	if (!overlap)
-	    REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
-	REGION_UNINIT( pScreen, &childUnion);
-	REGION_UNINIT( pScreen, &childUniverse);
+	    RegionSubtract(universe, universe, &childUnion);
+	RegionUninit(&childUnion);
+	RegionUninit(&childUniverse);
     } /* if any children */
 
     /*
@@ -467,12 +467,12 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
     if (oldVis == VisibilityFullyObscured ||
 	oldVis == VisibilityNotViewable)
     {
-	REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe);
+	RegionCopy(&pParent->valdata->after.exposed, universe);
     }
     else if (newVis != VisibilityFullyObscured &&
 	     newVis != VisibilityNotViewable)
     {
-    	REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
+	RegionSubtract(&pParent->valdata->after.exposed,
 			       universe, &pParent->clipList);
     }
 
@@ -484,7 +484,7 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
      */
     if (pParent->backStorage && !resized)
     {
-	REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
+	RegionSubtract(exposed, &pParent->clipList, universe);
 	(* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
     }
     
@@ -498,7 +498,7 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
     }
 
 #ifdef NOTDEF
-    REGION_COPY( pScreen, &pParent->clipList, universe);
+    RegionCopy(&pParent->clipList, universe);
 #endif
 
     pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
@@ -589,15 +589,15 @@ RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */
     if (pChild == NullWindow)
 	pChild = pRoot->firstChild;
 
-    REGION_NULL(pScreen, &childClip);
-    REGION_NULL(pScreen, &exposed);
+    RegionNull(&childClip);
+    RegionNull(&exposed);
 
-    if (REGION_BROKEN (pScreen, &pRoot->clipList) &&
-	!REGION_BROKEN (pScreen, &pRoot->borderClip))
+    if (RegionBroken(&pRoot->clipList) &&
+	!RegionBroken(&pRoot->borderClip))
     {
         // fixme this might not work, but hopefully doesn't happen anyway.
         kind = VTBroken;
-        REGION_EMPTY (pScreen, &pRoot->clipList);
+        RegionEmpty(&pRoot->clipList);
         ErrorF("ValidateTree: BUSTED!\n");
     }
 
@@ -613,28 +613,28 @@ RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */
     {
         if (pWin->viewable) {
             if (pWin->valdata) {
-                REGION_COPY( pScreen, &childClip, &pWin->borderSize);
+                RegionCopy(&childClip, &pWin->borderSize);
                 RootlessComputeClips (pWin, pScreen, &childClip, kind, &exposed);
             } else if (pWin->visibility == VisibilityNotViewable) {
                 RootlessTreeObscured(pWin);
             }
         } else {
             if (pWin->valdata) {
-                REGION_EMPTY( pScreen, &pWin->clipList);
+                RegionEmpty(&pWin->clipList);
                 if (pScreen->ClipNotify)
                     (* pScreen->ClipNotify) (pWin, 0, 0);
-                REGION_EMPTY( pScreen, &pWin->borderClip);
+                RegionEmpty(&pWin->borderClip);
                 pWin->valdata = NULL;
             }
         }
     }
 
-    REGION_UNINIT(pScreen, &childClip);
+    RegionUninit(&childClip);
 
     /* The root is never clipped by its children, so nothing on the root 
        is ever exposed by moving or mapping its children. */
-    REGION_NULL(pScreen, &pRoot->valdata->after.exposed);
-    REGION_NULL(pScreen, &pRoot->valdata->after.borderExposed);
+    RegionNull(&pRoot->valdata->after.exposed);
+    RegionNull(&pRoot->valdata->after.borderExposed);
 
     return 1;
 }
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 4d541f4..7f03214 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -184,7 +184,7 @@ RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec)
     SCREENREC(pScreen)->imp->DestroyFrame(winRec->wid);
 
 #ifdef ROOTLESS_TRACK_DAMAGE
-    REGION_UNINIT(pScreen, &winRec->damage);
+    RegionUninit(&winRec->damage);
 #endif
 
     free(winRec);
@@ -232,9 +232,9 @@ RootlessGetShape(WindowPtr pWin, RegionPtr pShape)
     /* wBoundingShape is relative to *inner* origin of window.
        Translate by borderWidth to get the outside-relative position. */
 
-    REGION_NULL(pScreen, pShape);
-    REGION_COPY(pScreen, pShape, wBoundingShape(pWin));
-    REGION_TRANSLATE(pScreen, pShape, pWin->borderWidth, pWin->borderWidth);
+    RegionNull(pShape);
+    RegionCopy(pShape, wBoundingShape(pWin));
+    RegionTranslate(pShape, pWin->borderWidth, pWin->borderWidth);
 
     return TRUE;
 }
@@ -266,7 +266,7 @@ static void RootlessReshapeFrame(WindowPtr pWin)
     RL_DEBUG_MSG("reshaping...");
     if (pShape != NULL) {
         RL_DEBUG_MSG("numrects %d, extents %d %d %d %d ",
-                     REGION_NUM_RECTS(&newShape),
+                     RegionNumRects(&newShape),
                      newShape.extents.x1, newShape.extents.y1,
                      newShape.extents.x2, newShape.extents.y2);
     } else {
@@ -277,7 +277,7 @@ static void RootlessReshapeFrame(WindowPtr pWin)
     SCREENREC(pScreen)->imp->ReshapeFrame(winRec->wid, pShape);
 
     if (pShape != NULL)
-        REGION_UNINIT(pScreen, &newShape);
+        RegionUninit(&newShape);
 }
 
 
@@ -355,8 +355,8 @@ RootlessPositionWindow(WindowPtr pWin, int x, int y)
 
 #ifdef ROOTLESS_TRACK_DAMAGE
             // Move damaged region to correspond to new window position
-            if (REGION_NOTEMPTY(pScreen, &winRec->damage)) {
-                REGION_TRANSLATE(pScreen, &winRec->damage,
+            if (RegionNotEmpty(&winRec->damage)) {
+                RegionTranslate(&winRec->damage,
                                  x - bw - winRec->x,
                                  y - bw - winRec->y);
             }
@@ -394,7 +394,7 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec)
     winRec->borderWidth = bw;
 
 #ifdef ROOTLESS_TRACK_DAMAGE
-    REGION_NULL(pScreen, &winRec->damage);
+    RegionNull(&winRec->damage);
 #endif
 }
 
@@ -457,7 +457,7 @@ RootlessEnsureFrame(WindowPtr pWin)
       RootlessFlushWindowColormap(pWin);
 
     if (pShape != NULL)
-        REGION_UNINIT(pScreen, &shape);
+        RegionUninit(&shape);
 
     return winRec;
 }
@@ -673,7 +673,7 @@ RootlessNoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
 
     RL_DEBUG_MSG("ROOTLESSNOCOPYWINDOW ");
 
-    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+    RegionTranslate(prgnSrc, -dx, -dy);
 }
 
 
@@ -705,9 +705,9 @@ RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
-    REGION_NULL(pScreen, &rgnDst);
-    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    RegionTranslate(prgnSrc, -dx, -dy);
+    RegionNull(&rgnDst);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
     if (gResizeDeathCount == 1) {
         /* Simple case, we only have a single source pixmap. */
@@ -724,21 +724,21 @@ RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
            intersect the destination with each source and copy those bits. */
 
         for (i = 0; i < gResizeDeathCount; i++) {
-            REGION_INIT(pScreen, &clip, gResizeDeathBounds + 0, 1);
-            REGION_NULL(pScreen, &clipped);
-            REGION_INTERSECT(pScreen, &rgnDst, &clip, &clipped);
+            RegionInit(&clip, gResizeDeathBounds + 0, 1);
+            RegionNull(&clipped);
+            RegionIntersect(&rgnDst, &clip, &clipped);
 
             fbCopyRegion(&gResizeDeathPix[i]->drawable,
                          &pScreen->GetWindowPixmap(pWin)->drawable, 0,
                          &clipped, dx, dy, fbCopyWindowProc, 0, 0);
 
-            REGION_UNINIT(pScreen, &clipped);
-            REGION_UNINIT(pScreen, &clip);
+            RegionUninit(&clipped);
+            RegionUninit(&clip);
         }
     }
 
     /* Don't update - resize will update everything */
-    REGION_UNINIT(pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
 
     fbValidateDrawable(&pWin->drawable);
 
@@ -768,12 +768,12 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+    RegionTranslate(prgnSrc, -dx, -dy);
 
-    REGION_NULL(pScreen, &rgnDst);
-    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    RegionNull(&rgnDst);
+    RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
-    extents = REGION_EXTENTS(pScreen, &rgnDst);
+    extents = RegionExtents(&rgnDst);
     area = (extents->x2 - extents->x1) * (extents->y2 - extents->y1);
 
     /* If the area exceeds threshold, use the implementation's
@@ -797,13 +797,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
         }
 
         /* Move region to window local coords */
-        REGION_TRANSLATE(pScreen, &rgnDst, -winRec->x, -winRec->y);
+        RegionTranslate(&rgnDst, -winRec->x, -winRec->y);
 
         RootlessStopDrawing(pWin, FALSE);
 
         SCREENREC(pScreen)->imp->CopyWindow(winRec->wid,
-                                            REGION_NUM_RECTS(&rgnDst),
-                                            REGION_RECTS(&rgnDst),
+                                            RegionNumRects(&rgnDst),
+                                            RegionRects(&rgnDst),
                                             dx, dy);
     }
     else {
@@ -817,7 +817,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     }
 
 out:
-    REGION_UNINIT(pScreen, &rgnDst);
+    RegionUninit(&rgnDst);
     fbValidateDrawable(&pWin->drawable);
 
     SCREEN_WRAP(pScreen, CopyWindow);
@@ -1320,11 +1320,11 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
 
         box.x1 = x; box.y1 = y;
         box.x2 = x + w; box.y2 = y + h;
-        REGION_UNINIT(pScreen, &pWin->winSize);
-        REGION_INIT(pScreen, &pWin->winSize, &box, 1);
-        REGION_COPY(pScreen, &pWin->borderSize, &pWin->winSize);
-        REGION_COPY(pScreen, &pWin->clipList, &pWin->winSize);
-        REGION_COPY(pScreen, &pWin->borderClip, &pWin->winSize);
+        RegionUninit(&pWin->winSize);
+        RegionInit(&pWin->winSize, &box, 1);
+        RegionCopy(&pWin->borderSize, &pWin->winSize);
+        RegionCopy(&pWin->clipList, &pWin->winSize);
+        RegionCopy(&pWin->borderClip, &pWin->winSize);
 
         miSendExposures(pWin, &pWin->borderClip,
                         pWin->drawable.x, pWin->drawable.y);        
diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
index e027e76..893014b 100644
--- a/miext/shadow/shadow.c
+++ b/miext/shadow/shadow.c
@@ -57,7 +57,7 @@ shadowRedisplay(ScreenPtr pScreen)
     if (!pBuf || !pBuf->pDamage || !pBuf->update)
 	return;
     pRegion = DamageRegion(pBuf->pDamage);
-    if (REGION_NOTEMPTY(pScreen, pRegion)) {
+    if (RegionNotEmpty(pRegion)) {
 	(*pBuf->update)(pScreen, pBuf);
 	DamageEmpty(pBuf->pDamage);
     }
@@ -103,7 +103,7 @@ shadowCloseScreen(int i, ScreenPtr pScreen)
     shadowRemove(pScreen, pBuf->pPixmap);
     DamageDestroy(pBuf->pDamage);
 #ifdef BACKWARDS_COMPATIBILITY
-    REGION_UNINIT(pScreen, &pBuf->damage); /* bc */
+    RegionUninit(&pBuf->damage); /* bc */
 #endif
     if (pBuf->pPixmap)
 	pScreen->DestroyPixmap(pBuf->pPixmap);
@@ -121,13 +121,13 @@ shadowReportFunc(DamagePtr pDamage, RegionPtr pRegion, void *closure)
 
     /* Register the damaged region, use DamageReportNone below when we
      * want to break BC below... */
-    REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage, pRegion);
+    RegionUnion(&pDamage->damage, &pDamage->damage, pRegion);
 
     /*
      * BC hack.  In 7.0 and earlier several drivers would inspect the
      * 'damage' member directly, so we have to keep it existing.
      */
-    REGION_COPY(pScreen, &pBuf->damage, pRegion);
+    RegionCopy(&pBuf->damage, pRegion);
 }
 #endif
 
@@ -166,7 +166,7 @@ shadowSetup(ScreenPtr pScreen)
     pBuf->closure = 0;
     pBuf->randr = 0;
 #ifdef BACKWARDS_COMPATIBILITY
-    REGION_NULL(pScreen, &pBuf->damage); /* bc */
+    RegionNull(&pBuf->damage); /* bc */
 #endif
 
     dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
diff --git a/miext/shadow/shpacked.c b/miext/shadow/shpacked.c
index 6736162..20d2ea1 100644
--- a/miext/shadow/shpacked.c
+++ b/miext/shadow/shpacked.c
@@ -46,8 +46,8 @@ shadowUpdatePacked (ScreenPtr	    pScreen,
 {
     RegionPtr	damage = shadowDamage (pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
-    int		nbox = REGION_NUM_RECTS (damage);
-    BoxPtr	pbox = REGION_RECTS (damage);
+    int		nbox = RegionNumRects (damage);
+    BoxPtr	pbox = RegionRects (damage);
     FbBits	*shaBase, *shaLine, *sha;
     FbStride	shaStride;
     int		scrBase, scrLine, scr;
diff --git a/miext/shadow/shplanar.c b/miext/shadow/shplanar.c
index b5983dc..9ca3f3f 100644
--- a/miext/shadow/shplanar.c
+++ b/miext/shadow/shplanar.c
@@ -92,8 +92,8 @@ shadowUpdatePlanar4 (ScreenPtr	    pScreen,
 {
     RegionPtr	damage = shadowDamage (pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
-    int		nbox = REGION_NUM_RECTS (damage);
-    BoxPtr	pbox = REGION_RECTS (damage);
+    int		nbox = RegionNumRects (damage);
+    BoxPtr	pbox = RegionRects (damage);
     CARD32	*shaBase, *shaLine, *sha;
     FbStride	shaStride;
     int		scrBase, scrLine, scr;
diff --git a/miext/shadow/shplanar8.c b/miext/shadow/shplanar8.c
index 6d8defa..f8b255d 100644
--- a/miext/shadow/shplanar8.c
+++ b/miext/shadow/shplanar8.c
@@ -95,8 +95,8 @@ shadowUpdatePlanar4x8 (ScreenPtr	pScreen,
 {
     RegionPtr	damage = shadowDamage (pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
-    int		nbox = REGION_NUM_RECTS (damage);
-    BoxPtr	pbox = REGION_RECTS (damage);
+    int		nbox = RegionNumRects (damage);
+    BoxPtr	pbox = RegionRects (damage);
     CARD32	*shaBase, *shaLine, *sha;
     CARD8	s1, s2, s3, s4;
     FbStride	shaStride;
diff --git a/miext/shadow/shrotate.c b/miext/shadow/shrotate.c
index 673cd76..c389826 100644
--- a/miext/shadow/shrotate.c
+++ b/miext/shadow/shrotate.c
@@ -54,8 +54,8 @@ shadowUpdateRotatePacked (ScreenPtr	pScreen,
 {
     RegionPtr	damage = shadowDamage (pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
-    int		nbox = REGION_NUM_RECTS (damage);
-    BoxPtr	pbox = REGION_RECTS (damage);
+    int		nbox = RegionNumRects (damage);
+    BoxPtr	pbox = RegionRects (damage);
     FbBits	*shaBits;
     FbStride	shaStride;
     int		shaBpp;
diff --git a/miext/shadow/shrotpack.h b/miext/shadow/shrotpack.h
index 015a985..2d1a87c 100644
--- a/miext/shadow/shrotpack.h
+++ b/miext/shadow/shrotpack.h
@@ -99,8 +99,8 @@ FUNC (ScreenPtr	    pScreen,
 {
     RegionPtr	damage = shadowDamage (pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
-    int		nbox = REGION_NUM_RECTS (damage);
-    BoxPtr	pbox = REGION_RECTS (damage);
+    int		nbox = RegionNumRects (damage);
+    BoxPtr	pbox = RegionRects (damage);
     FbBits	*shaBits;
     Data	*shaBase, *shaLine, *sha;
     FbStride	shaStride;
diff --git a/miext/shadow/shrotpackYX.h b/miext/shadow/shrotpackYX.h
index 8ef70f1..7d36bd1 100644
--- a/miext/shadow/shrotpackYX.h
+++ b/miext/shadow/shrotpackYX.h
@@ -63,8 +63,8 @@ FUNC (ScreenPtr	    pScreen,
 {
     RegionPtr	damage = shadowDamage(pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
-    int		nbox = REGION_NUM_RECTS (damage);
-    BoxPtr	pbox = REGION_RECTS (damage);
+    int		nbox = RegionNumRects (damage);
+    BoxPtr	pbox = RegionRects (damage);
     FbBits	*shaBits;
     Data	*shaBase, *shaLine, *sha;
     FbStride	shaStride, winStride;
diff --git a/render/mipict.c b/render/mipict.c
index 1dad88e..b5b8970 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -47,7 +47,7 @@ void
 miDestroyPicture (PicturePtr pPicture)
 {
     if (pPicture->freeCompClip)
-	REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->pCompositeClip);
+	RegionDestroy(pPicture->pCompositeClip);
 }
 
 void
@@ -64,7 +64,7 @@ miDestroyPictureClip (PicturePtr pPicture)
 	 * we know we'll never have a list of rectangles, since ChangeClip
 	 * immediately turns them into a region
 	 */
-	REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->clientClip);
+	RegionDestroy(pPicture->clientClip);
 	break;
     }
     pPicture->clientClip = NULL;
@@ -85,7 +85,7 @@ miChangePictureClip (PicturePtr    pPicture,
     switch (type) {
     case CT_PIXMAP:
 	/* convert the pixmap to a region */
-	clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
+	clientClip = (pointer) BitmapToRegion(pScreen, (PixmapPtr) value);
 	if (!clientClip)
 	    return BadAlloc;
 	clientClipType = CT_REGION;
@@ -100,7 +100,7 @@ miChangePictureClip (PicturePtr    pPicture,
 	clientClipType = CT_NONE;
 	break;
     default:
-	clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
+	clientClip = (pointer) RegionFromRects(n,
 					       (xRectangle *) value,
 					       type);
 	if (!clientClip)
@@ -160,7 +160,7 @@ miValidatePicture (PicturePtr pPicture,
 	    if (pPicture->clientClipType == CT_NONE)
 	    {
 		if (freeCompClip)
-		    REGION_DESTROY(pScreen, pPicture->pCompositeClip);
+		    RegionDestroy(pPicture->pCompositeClip);
 		pPicture->pCompositeClip = pregWin;
 		pPicture->freeCompClip = freeTmpClip;
 	    }
@@ -175,30 +175,30 @@ miValidatePicture (PicturePtr pPicture,
 		 * clip. if neither is real, create a new region.
 		 */
 
-		REGION_TRANSLATE(pScreen, pPicture->clientClip,
+		RegionTranslate(pPicture->clientClip,
 				 pDrawable->x + pPicture->clipOrigin.x,
 				 pDrawable->y + pPicture->clipOrigin.y);
 
 		if (freeCompClip)
 		{
-		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+		    RegionIntersect(pPicture->pCompositeClip,
 				     pregWin, pPicture->clientClip);
 		    if (freeTmpClip)
-			REGION_DESTROY(pScreen, pregWin);
+			RegionDestroy(pregWin);
 		}
 		else if (freeTmpClip)
 		{
-		    REGION_INTERSECT(pScreen, pregWin, pregWin, pPicture->clientClip);
+		    RegionIntersect(pregWin, pregWin, pPicture->clientClip);
 		    pPicture->pCompositeClip = pregWin;
 		}
 		else
 		{
-		    pPicture->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
-		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+		    pPicture->pCompositeClip = RegionCreate(NullBox, 0);
+		    RegionIntersect(pPicture->pCompositeClip,
 				     pregWin, pPicture->clientClip);
 		}
 		pPicture->freeCompClip = TRUE;
-		REGION_TRANSLATE(pScreen, pPicture->clientClip,
+		RegionTranslate(pPicture->clientClip,
 				 -(pDrawable->x + pPicture->clipOrigin.x),
 				 -(pDrawable->y + pPicture->clipOrigin.y));
 	    }
@@ -216,31 +216,31 @@ miValidatePicture (PicturePtr pPicture,
 
 	    if (pPicture->freeCompClip)
 	    {
-		REGION_RESET(pScreen, pPicture->pCompositeClip, &pixbounds);
+		RegionReset(pPicture->pCompositeClip, &pixbounds);
 	    }
 	    else
 	    {
 		pPicture->freeCompClip = TRUE;
-		pPicture->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+		pPicture->pCompositeClip = RegionCreate(&pixbounds, 1);
 	    }
 
 	    if (pPicture->clientClipType == CT_REGION)
 	    {
 		if(pDrawable->x || pDrawable->y) {
-		    REGION_TRANSLATE(pScreen, pPicture->clientClip,
+		    RegionTranslate(pPicture->clientClip,
 				     pDrawable->x + pPicture->clipOrigin.x, 
 				     pDrawable->y + pPicture->clipOrigin.y);
-		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+		    RegionIntersect(pPicture->pCompositeClip,
 				     pPicture->pCompositeClip, pPicture->clientClip);
-		    REGION_TRANSLATE(pScreen, pPicture->clientClip,
+		    RegionTranslate(pPicture->clientClip,
 				     -(pDrawable->x + pPicture->clipOrigin.x), 
 				     -(pDrawable->y + pPicture->clipOrigin.y));
 		} else {
-		    REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+		    RegionTranslate(pPicture->pCompositeClip,
 				     -pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
-		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+		    RegionIntersect(pPicture->pCompositeClip,
 				     pPicture->pCompositeClip, pPicture->clientClip);
-		    REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+		    RegionTranslate(pPicture->pCompositeClip,
 				     pPicture->clipOrigin.x, pPicture->clipOrigin.y);
 		}
 	    }
@@ -321,7 +321,7 @@ miClipPictureSrc (RegionPtr	pRegion,
 				  pPicture->clipOrigin.x + dx,
 				  pPicture->clipOrigin.y + dy);
 
-	result = REGION_INTERSECT (pScreen, pRegion, pRegion, pPicture->clientClip);
+	result = RegionIntersect(pRegion, pRegion, pPicture->clientClip);
 	
 	pixman_region_translate ( pPicture->clientClip,
 				  - (pPicture->clipOrigin.x + dx),
diff --git a/render/mirect.c b/render/mirect.c
index 13d7fa6..6a3112a 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -64,8 +64,8 @@ miColorRects (PicturePtr    pDst,
 	tmpval[4].val = pDst->clipOrigin.y - yoff;
 	mask |= GCClipXOrigin|GCClipYOrigin;
 	
-	pClip = REGION_CREATE (pScreen, NULL, 1);
-	REGION_COPY (pScreen, pClip,
+	pClip = RegionCreate(NULL, 1);
+	RegionCopy(pClip,
 		     (RegionPtr) pClipPict->clientClip);
 	(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
     }
diff --git a/render/picture.c b/render/picture.c
index 211fa38..ca5e18e 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1298,7 +1298,7 @@ SetPictureClipRects (PicturePtr	pPicture,
     RegionPtr		clientClip;
     int			result;
 
-    clientClip = RECTS_TO_REGION(pScreen,
+    clientClip = RegionFromRects(
 				 nRect, rects, CT_UNSORTED);
     if (!clientClip)
 	return BadAlloc;
@@ -1329,14 +1329,14 @@ SetPictureClipRegion (PicturePtr    pPicture,
     if (pRegion)
     {
         type = CT_REGION;
-        clientClip = REGION_CREATE (pScreen,
-                                    REGION_EXTENTS(pScreen, pRegion),
-                                    REGION_NUM_RECTS(pRegion));
+        clientClip = RegionCreate(
+                                    RegionExtents(pRegion),
+                                    RegionNumRects(pRegion));
         if (!clientClip)
             return BadAlloc;
-        if (!REGION_COPY (pSCreen, clientClip, pRegion))
+        if (!RegionCopy(clientClip, pRegion))
         {
-            REGION_DESTROY (pScreen, clientClip);
+            RegionDestroy(clientClip);
             return BadAlloc;
         }
     }
@@ -1462,9 +1462,9 @@ CopyPicture (PicturePtr	pSrc,
 		    RegionPtr clientClip;
 		    RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip;
 
-		    clientClip = REGION_CREATE(pSrc->pDrawable->pScreen,
-			REGION_EXTENTS(pSrc->pDrawable->pScreen, srcClientClip),
-			REGION_NUM_RECTS(srcClientClip));
+		    clientClip = RegionCreate(
+			RegionExtents(srcClientClip),
+			RegionNumRects(srcClientClip));
 		    (*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0);
 		}
 		break;
diff --git a/xfixes/region.c b/xfixes/region.c
index b034ad0..4fdfa20 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -39,20 +39,20 @@ RegionResFree (pointer data, XID id)
 {
     RegionPtr    pRegion = (RegionPtr) data;
 
-    REGION_DESTROY (0, pRegion);
+    RegionDestroy(pRegion);
     return Success;
 }
 
 RegionPtr
 XFixesRegionCopy (RegionPtr pRegion)
 {
-    RegionPtr   pNew = REGION_CREATE (0, REGION_EXTENTS(0, pRegion),
-				      REGION_NUM_RECTS(pRegion));
+    RegionPtr   pNew = RegionCreate(RegionExtents(pRegion),
+				      RegionNumRects(pRegion));
     if (!pNew)
 	return 0;
-    if (!REGION_COPY (0, pNew, pRegion))
+    if (!RegionCopy(pNew, pRegion))
     {
-	REGION_DESTROY (0, pNew);
+	RegionDestroy(pNew);
 	return 0;
     }
     return pNew;
@@ -81,7 +81,7 @@ ProcXFixesCreateRegion (ClientPtr client)
 	return BadLength;
     things >>= 3;
 
-    pRegion = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
+    pRegion = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
     if (!pRegion)
 	return BadAlloc;
     if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
@@ -124,7 +124,7 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client)
     if (pPixmap->drawable.depth != 1)
 	return BadMatch;
 
-    pRegion = BITMAP_TO_REGION(pPixmap->drawable.pScreen, pPixmap);
+    pRegion = BitmapToRegion(pPixmap->drawable.pScreen, pPixmap);
 
     if (!pRegion)
 	return BadAlloc;
@@ -227,7 +227,7 @@ ProcXFixesCreateRegionFromGC (ClientPtr client)
     
     switch (pGC->clientClipType) {
     case CT_PIXMAP:
-	pRegion = BITMAP_TO_REGION(pGC->pScreen, (PixmapPtr) pGC->clientClip);
+	pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
 	if (!pRegion)
 	    return BadAlloc;
 	break;
@@ -274,7 +274,7 @@ ProcXFixesCreateRegionFromPicture (ClientPtr client)
     
     switch (pPicture->clientClipType) {
     case CT_PIXMAP:
-	pRegion = BITMAP_TO_REGION(pPicture->pDrawable->pScreen,
+	pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
 				   (PixmapPtr) pPicture->clientClip);
 	if (!pRegion)
 	    return BadAlloc;
@@ -346,15 +346,15 @@ ProcXFixesSetRegion (ClientPtr client)
 	return BadLength;
     things >>= 3;
 
-    pNew = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
+    pNew = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
     if (!pNew)
 	return BadAlloc;
-    if (!REGION_COPY (0, pRegion, pNew))
+    if (!RegionCopy(pRegion, pNew))
     {
-	REGION_DESTROY (0, pNew);
+	RegionDestroy(pNew);
 	return BadAlloc;
     }
-    REGION_DESTROY (0, pNew);
+    RegionDestroy(pNew);
     return Success;
 }
 
@@ -380,7 +380,7 @@ ProcXFixesCopyRegion (ClientPtr client)
     VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
     VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
     
-    if (!REGION_COPY(pScreen, pDestination, pSource))
+    if (!RegionCopy(pDestination, pSource))
 	return BadAlloc;
 
     return Success;
@@ -412,15 +412,15 @@ ProcXFixesCombineRegion (ClientPtr client)
     
     switch (stuff->xfixesReqType) {
     case X_XFixesUnionRegion:
-	if (!REGION_UNION (0, pDestination, pSource1, pSource2))
+	if (!RegionUnion(pDestination, pSource1, pSource2))
 	    return BadAlloc;
 	break;
     case X_XFixesIntersectRegion:
-	if (!REGION_INTERSECT (0, pDestination, pSource1, pSource2))
+	if (!RegionIntersect(pDestination, pSource1, pSource2))
 	    return BadAlloc;
 	break;
     case X_XFixesSubtractRegion:
-	if (!REGION_SUBTRACT (0, pDestination, pSource1, pSource2))
+	if (!RegionSubtract(pDestination, pSource1, pSource2))
 	    return BadAlloc;
 	break;
     }
@@ -466,7 +466,7 @@ ProcXFixesInvertRegion (ClientPtr client)
     else
 	bounds.y2 = stuff->y + stuff->height;
 
-    if (!REGION_INVERSE(0, pDestination, pSource, &bounds))
+    if (!RegionInverse(pDestination, pSource, &bounds))
 	return BadAlloc;
 
     return Success;
@@ -498,7 +498,7 @@ ProcXFixesTranslateRegion (ClientPtr client)
     REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
     VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
 
-    REGION_TRANSLATE(pScreen, pRegion, stuff->dx, stuff->dy);
+    RegionTranslate(pRegion, stuff->dx, stuff->dy);
     return Success;
 }
 
@@ -526,7 +526,7 @@ ProcXFixesRegionExtents (ClientPtr client)
     VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
     VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
 
-    REGION_RESET (0, pDestination, REGION_EXTENTS (0, pSource));
+    RegionReset(pDestination, RegionExtents(pSource));
 
     return Success;
 }
@@ -558,9 +558,9 @@ ProcXFixesFetchRegion (ClientPtr client)
     REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
     VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess);
 
-    pExtent = REGION_EXTENTS (0, pRegion);
-    pBox = REGION_RECTS (pRegion);
-    nBox = REGION_NUM_RECTS (pRegion);
+    pExtent = RegionExtents(pRegion);
+    pBox = RegionRects (pRegion);
+    nBox = RegionNumRects (pRegion);
     
     reply = malloc(sizeof (xXFixesFetchRegionReply) +
 		    nBox * sizeof (xRectangle));
@@ -708,7 +708,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client)
 	    break;
 	}
 	if (stuff->xOff || stuff->yOff)
-	    REGION_TRANSLATE (0, pRegion, stuff->xOff, stuff->yOff);
+	    RegionTranslate(pRegion, stuff->xOff, stuff->yOff);
     }
     else
     {
@@ -731,7 +731,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client)
 	    pDestRegion = &pRegion; /* a NULL region pointer */
     }
     if (*pDestRegion)
-	REGION_DESTROY(pScreen, *pDestRegion);
+	RegionDestroy(*pDestRegion);
     *pDestRegion = pRegion;
     (*pScreen->SetShape) (pWin, stuff->destKind);
     SendShapeNotify (pWin, stuff->destKind);
@@ -801,8 +801,8 @@ ProcXFixesExpandRegion (ClientPtr client)
     VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
     VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
     
-    nBoxes = REGION_NUM_RECTS(pSource);
-    pSrc = REGION_RECTS(pSource);
+    nBoxes = RegionNumRects(pSource);
+    pSrc = RegionRects(pSource);
     if (nBoxes)
     {
 	pTmp = malloc(nBoxes * sizeof (BoxRec));
@@ -815,12 +815,12 @@ ProcXFixesExpandRegion (ClientPtr client)
 	    pTmp[i].y1 = pSrc[i].y1 - stuff->top;
 	    pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
 	}
-	REGION_EMPTY (pScreen, pDestination);
+	RegionEmpty(pDestination);
 	for (i = 0; i < nBoxes; i++)
 	{
 	    RegionRec	r;
-	    REGION_INIT (pScreen, &r, &pTmp[i], 0);
-	    REGION_UNION (pScreen, pDestination, pDestination, &r);
+	    RegionInit(&r, &pTmp[i], 0);
+	    RegionUnion(pDestination, pDestination, &r);
 	}
 	free(pTmp);
     }
commit d17e726e89ef644310de77b960b715c2d11088da
Author: Keith Packard <keithp at keithp.com>
Date:   Sat May 22 00:09:47 2010 -0700

    Move mi/miregion.c to dix/region.c
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/Makefile.am b/dix/Makefile.am
index 42b5121..5e2dad7 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -32,6 +32,7 @@ libdix_la_SOURCES = 	\
 	privates.c	\
 	property.c	\
 	ptrveloc.c	\
+	region.c	\
 	registry.c	\
 	resource.c	\
 	selection.c	\
diff --git a/dix/region.c b/dix/region.c
new file mode 100644
index 0000000..a561601
--- /dev/null
+++ b/dix/region.c
@@ -0,0 +1,1845 @@
+/***********************************************************
+
+Copyright 1987, 1988, 1989, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ 
+
+Copyright 1987, 1988, 1989 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, 
+provided that the above copyright notice appear in all copies and that
+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.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "regionstr.h"
+#include <X11/Xprotostr.h>
+#include <X11/Xfuncproto.h>
+#include "gc.h"
+#include "mi.h"
+#include "mispans.h"
+#include <pixman.h>
+
+#undef assert
+#ifdef REGION_DEBUG
+#define assert(expr) { \
+            CARD32 *foo = NULL; \
+            if (!(expr)) { \
+                ErrorF("Assertion failed file %s, line %d: %s\n", \
+                       __FILE__, __LINE__, #expr); \
+                *foo = 0xdeadbeef; /* to get a backtrace */ \
+            } \
+        }
+#else
+#define assert(expr)
+#endif
+
+#define good(reg) assert(RegionIsValid(reg))
+
+/*
+ * The functions in this file implement the Region abstraction used extensively
+ * throughout the X11 sample server. A Region is simply a set of disjoint
+ * (non-overlapping) rectangles, plus an "extent" rectangle which is the
+ * smallest single rectangle that contains all the non-overlapping rectangles.
+ *
+ * A Region is implemented as a "y-x-banded" array of rectangles.  This array
+ * imposes two degrees of order.  First, all rectangles are sorted by top side
+ * y coordinate first (y1), and then by left side x coordinate (x1).
+ *
+ * Furthermore, the rectangles are grouped into "bands".  Each rectangle in a
+ * band has the same top y coordinate (y1), and each has the same bottom y
+ * coordinate (y2).  Thus all rectangles in a band differ only in their left
+ * and right side (x1 and x2).  Bands are implicit in the array of rectangles:
+ * there is no separate list of band start pointers.
+ *
+ * The y-x band representation does not minimize rectangles.  In particular,
+ * if a rectangle vertically crosses a band (the rectangle has scanlines in 
+ * the y1 to y2 area spanned by the band), then the rectangle may be broken
+ * down into two or more smaller rectangles stacked one atop the other. 
+ *
+ *  -----------				    -----------
+ *  |         |				    |         |		    band 0
+ *  |         |  --------		    -----------  --------
+ *  |         |  |      |  in y-x banded    |         |  |      |   band 1
+ *  |         |  |      |  form is	    |         |  |      |
+ *  -----------  |      |		    -----------  --------
+ *               |      |				 |      |   band 2
+ *               --------				 --------
+ *
+ * An added constraint on the rectangles is that they must cover as much
+ * horizontal area as possible: no two rectangles within a band are allowed
+ * to touch.
+ *
+ * Whenever possible, bands will be merged together to cover a greater vertical
+ * distance (and thus reduce the number of rectangles). Two bands can be merged
+ * only if the bottom of one touches the top of the other and they have
+ * rectangles in the same places (of the same width, of course).
+ *
+ * Adam de Boor wrote most of the original region code.  Joel McCormack
+ * substantially modified or rewrote most of the core arithmetic routines,
+ * and added RegionValidate in order to support several speed improvements
+ * to miValidateTree.  Bob Scheifler changed the representation to be more
+ * compact when empty or a single rectangle, and did a bunch of gratuitous
+ * reformatting.
+ */
+
+/*  true iff two Boxes overlap */
+#define EXTENTCHECK(r1,r2) \
+      (!( ((r1)->x2 <= (r2)->x1)  || \
+          ((r1)->x1 >= (r2)->x2)  || \
+          ((r1)->y2 <= (r2)->y1)  || \
+          ((r1)->y1 >= (r2)->y2) ) )
+
+/* true iff (x,y) is in Box */
+#define INBOX(r,x,y) \
+      ( ((r)->x2 >  x) && \
+        ((r)->x1 <= x) && \
+        ((r)->y2 >  y) && \
+        ((r)->y1 <= y) )
+
+/* true iff Box r1 contains Box r2 */
+#define SUBSUMES(r1,r2) \
+      ( ((r1)->x1 <= (r2)->x1) && \
+        ((r1)->x2 >= (r2)->x2) && \
+        ((r1)->y1 <= (r2)->y1) && \
+        ((r1)->y2 >= (r2)->y2) )
+
+#define xallocData(n) malloc(REGION_SZOF(n))
+#define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data)
+
+#define RECTALLOC_BAIL(pReg,n,bail) \
+if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
+    if (!RegionRectAlloc(pReg, n)) { goto bail; }
+
+#define RECTALLOC(pReg,n) \
+if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
+    if (!RegionRectAlloc(pReg, n)) { return FALSE; }
+
+#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2)	\
+{						\
+    pNextRect->x1 = nx1;			\
+    pNextRect->y1 = ny1;			\
+    pNextRect->x2 = nx2;			\
+    pNextRect->y2 = ny2;			\
+    pNextRect++;				\
+}
+
+#define NEWRECT(pReg,pNextRect,nx1,ny1,nx2,ny2)			\
+{									\
+    if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\
+    {									\
+	if (!RegionRectAlloc(pReg, 1))					\
+	    return FALSE;						\
+	pNextRect = REGION_TOP(pReg);					\
+    }									\
+    ADDRECT(pNextRect,nx1,ny1,nx2,ny2);					\
+    pReg->data->numRects++;						\
+    assert(pReg->data->numRects<=pReg->data->size);			\
+}
+
+
+#define DOWNSIZE(reg,numRects)						 \
+if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
+{									 \
+    RegDataPtr NewData;							 \
+    NewData = (RegDataPtr)realloc((reg)->data, REGION_SZOF(numRects));	 \
+    if (NewData)							 \
+    {									 \
+	NewData->size = (numRects);					 \
+	(reg)->data = NewData;						 \
+    }									 \
+}
+
+
+BoxRec RegionEmptyBox = {0, 0, 0, 0};
+RegDataRec RegionEmptyData = {0, 0};
+
+RegDataRec  RegionBrokenData = {0, 0};
+static RegionRec   RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData };
+
+void
+InitRegions (void)
+{
+    pixman_region_set_static_pointers (&RegionEmptyBox, &RegionEmptyData, &RegionBrokenData);
+}
+
+/*****************************************************************
+ *   RegionCreate(rect, size)
+ *     This routine does a simple malloc to make a structure of
+ *     REGION of "size" number of rectangles.
+ *****************************************************************/
+
+RegionPtr
+RegionCreate(BoxPtr rect, int size)
+{
+    RegionPtr pReg;
+   
+    pReg = (RegionPtr)malloc(sizeof(RegionRec));
+    if (!pReg)
+	return &RegionBrokenRegion;
+
+    RegionInit (pReg, rect, size);
+    
+    return(pReg);
+}
+
+void
+RegionDestroy(RegionPtr pReg)
+{
+    pixman_region_fini (pReg);
+    if (pReg != &RegionBrokenRegion)
+	free(pReg);
+}
+
+void
+RegionPrint(RegionPtr rgn)
+{
+    int num, size;
+    int i;
+    BoxPtr rects;
+
+    num = REGION_NUM_RECTS(rgn);
+    size = REGION_SIZE(rgn);
+    rects = REGION_RECTS(rgn);
+    ErrorF("[mi] num: %d size: %d\n", num, size);
+    ErrorF("[mi] extents: %d %d %d %d\n",
+	   rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2);
+    for (i = 0; i < num; i++)
+      ErrorF("[mi] %d %d %d %d \n",
+	     rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
+    ErrorF("[mi] \n");
+}
+
+Bool
+RegionEqual(RegionPtr reg1, RegionPtr reg2)
+{
+    return pixman_region_equal (reg1, reg2);
+}
+
+#ifdef DEBUG
+Bool
+RegionIsValid(RegionPtr reg)
+{
+    int i, numRects;
+    
+    if ((reg->extents.x1 > reg->extents.x2) ||
+	(reg->extents.y1 > reg->extents.y2))
+	return FALSE;
+    numRects = REGION_NUM_RECTS(reg);
+    if (!numRects)
+	return ((reg->extents.x1 == reg->extents.x2) &&
+		(reg->extents.y1 == reg->extents.y2) &&
+		(reg->data->size || (reg->data == &RegionEmptyData)));
+    else if (numRects == 1)
+	return (!reg->data);
+    else
+    {
+	BoxPtr pboxP, pboxN;
+	BoxRec box;
+	
+	pboxP = REGION_RECTS(reg);
+	box = *pboxP;
+	box.y2 = pboxP[numRects-1].y2;
+	pboxN = pboxP + 1;
+	for (i = numRects; --i > 0; pboxP++, pboxN++)
+	{
+	    if ((pboxN->x1 >= pboxN->x2) ||
+		(pboxN->y1 >= pboxN->y2))
+		return FALSE;
+	    if (pboxN->x1 < box.x1)
+		box.x1 = pboxN->x1;
+	    if (pboxN->x2 > box.x2)
+		box.x2 = pboxN->x2;
+	    if ((pboxN->y1 < pboxP->y1) ||
+		((pboxN->y1 == pboxP->y1) &&
+		 ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2))))
+		return FALSE;
+	}
+	return ((box.x1 == reg->extents.x1) &&
+		(box.x2 == reg->extents.x2) &&
+		(box.y1 == reg->extents.y1) &&
+		(box.y2 == reg->extents.y2));
+    }
+}
+#endif /* DEBUG */
+
+/*****************************************************************
+ *   RegionInit(pReg, rect, size)
+ *     Outer region rect is statically allocated.
+ *****************************************************************/
+
+void
+RegionInit(RegionPtr pReg, BoxPtr rect, int size)
+{
+    if (rect)
+	pixman_region_init_with_extents (pReg, rect);
+    else
+	pixman_region_init (pReg);
+}
+
+void
+RegionUninit(RegionPtr pReg)
+{
+    pixman_region_fini (pReg);
+}
+
+Bool
+RegionBreak (RegionPtr pReg)
+{
+    xfreeData (pReg);
+    pReg->extents = RegionEmptyBox;
+    pReg->data = &RegionBrokenData;
+    return FALSE;
+}
+
+Bool
+RegionRectAlloc(RegionPtr pRgn, int n)
+{
+    RegDataPtr	data;
+    
+    if (!pRgn->data)
+    {
+	n++;
+	pRgn->data = xallocData(n);
+	if (!pRgn->data)
+	    return RegionBreak (pRgn);
+	pRgn->data->numRects = 1;
+	*REGION_BOXPTR(pRgn) = pRgn->extents;
+    }
+    else if (!pRgn->data->size)
+    {
+	pRgn->data = xallocData(n);
+	if (!pRgn->data)
+	    return RegionBreak (pRgn);
+	pRgn->data->numRects = 0;
+    }
+    else
+    {
+	if (n == 1)
+	{
+	    n = pRgn->data->numRects;
+	    if (n > 500) /* XXX pick numbers out of a hat */
+		n = 250;
+	}
+	n += pRgn->data->numRects;
+	data = (RegDataPtr)realloc(pRgn->data, REGION_SZOF(n));
+	if (!data)
+	    return RegionBreak (pRgn);
+	pRgn->data = data;
+    }
+    pRgn->data->size = n;
+    return TRUE;
+}
+
+Bool
+RegionCopy(RegionPtr dst, RegionPtr src)
+{
+    return pixman_region_copy (dst, src);
+}
+
+/*======================================================================
+ *	    Generic Region Operator
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionCoalesce --
+ *	Attempt to merge the boxes in the current band with those in the
+ *	previous one.  We are guaranteed that the current band extends to
+ *      the end of the rects array.  Used only by RegionOp.
+ *
+ * Results:
+ *	The new index for the previous band.
+ *
+ * Side Effects:
+ *	If coalescing takes place:
+ *	    - rectangles in the previous band will have their y2 fields
+ *	      altered.
+ *	    - pReg->data->numRects will be decreased.
+ *
+ *-----------------------------------------------------------------------
+ */
+_X_INLINE static int
+RegionCoalesce (
+    RegionPtr	pReg,	    	/* Region to coalesce		     */
+    int	    	  	prevStart,  	/* Index of start of previous band   */
+    int	    	  	curStart)   	/* Index of start of current band    */
+{
+    BoxPtr	pPrevBox;   	/* Current box in previous band	     */
+    BoxPtr	pCurBox;    	/* Current box in current band       */
+    int  	numRects;	/* Number rectangles in both bands   */
+    int		y2;		/* Bottom of current band	     */
+    /*
+     * Figure out how many rectangles are in the band.
+     */
+    numRects = curStart - prevStart;
+    assert(numRects == pReg->data->numRects - curStart);
+
+    if (!numRects) return curStart;
+
+    /*
+     * The bands may only be coalesced if the bottom of the previous
+     * matches the top scanline of the current.
+     */
+    pPrevBox = REGION_BOX(pReg, prevStart);
+    pCurBox = REGION_BOX(pReg, curStart);
+    if (pPrevBox->y2 != pCurBox->y1) return curStart;
+
+    /*
+     * Make sure the bands have boxes in the same places. This
+     * assumes that boxes have been added in such a way that they
+     * cover the most area possible. I.e. two boxes in a band must
+     * have some horizontal space between them.
+     */
+    y2 = pCurBox->y2;
+
+    do {
+	if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) {
+	    return (curStart);
+	}
+	pPrevBox++;
+	pCurBox++;
+	numRects--;
+    } while (numRects);
+
+    /*
+     * The bands may be merged, so set the bottom y of each box
+     * in the previous band to the bottom y of the current band.
+     */
+    numRects = curStart - prevStart;
+    pReg->data->numRects -= numRects;
+    do {
+	pPrevBox--;
+	pPrevBox->y2 = y2;
+	numRects--;
+    } while (numRects);
+    return prevStart;
+}
+
+
+/* Quicky macro to avoid trivial reject procedure calls to RegionCoalesce */
+
+#define Coalesce(newReg, prevBand, curBand)				\
+    if (curBand - prevBand == newReg->data->numRects - curBand) {	\
+	prevBand = RegionCoalesce(newReg, prevBand, curBand);		\
+    } else {								\
+	prevBand = curBand;						\
+    }
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionAppendNonO --
+ *	Handle a non-overlapping band for the union and subtract operations.
+ *      Just adds the (top/bottom-clipped) rectangles into the region.
+ *      Doesn't have to check for subsumption or anything.
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	pReg->data->numRects is incremented and the rectangles overwritten
+ *	with the rectangles we're passed.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+_X_INLINE static Bool
+RegionAppendNonO (
+    RegionPtr	pReg,
+    BoxPtr	r,
+    BoxPtr  	rEnd,
+    int  	y1,
+    int  	y2)
+{
+    BoxPtr	pNextRect;
+    int		newRects;
+
+    newRects = rEnd - r;
+
+    assert(y1 < y2);
+    assert(newRects != 0);
+
+    /* Make sure we have enough space for all rectangles to be added */
+    RECTALLOC(pReg, newRects);
+    pNextRect = REGION_TOP(pReg);
+    pReg->data->numRects += newRects;
+    do {
+	assert(r->x1 < r->x2);
+	ADDRECT(pNextRect, r->x1, y1, r->x2, y2);
+	r++;
+    } while (r != rEnd);
+
+    return TRUE;
+}
+
+#define FindBand(r, rBandEnd, rEnd, ry1)		    \
+{							    \
+    ry1 = r->y1;					    \
+    rBandEnd = r+1;					    \
+    while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1)) {   \
+	rBandEnd++;					    \
+    }							    \
+}
+
+#define	AppendRegions(newReg, r, rEnd)					\
+{									\
+    int newRects;							\
+    if ((newRects = rEnd - r)) {					\
+	RECTALLOC(newReg, newRects);					\
+	memmove((char *)REGION_TOP(newReg),(char *)r, 			\
+              newRects * sizeof(BoxRec));				\
+	newReg->data->numRects += newRects;				\
+    }									\
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionOp --
+ *	Apply an operation to two regions. Called by RegionUnion, RegionInverse,
+ *	RegionSubtract, RegionIntersect....  Both regions MUST have at least one
+ *      rectangle, and cannot be the same object.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *	The new region is overwritten.
+ *	pOverlap set to TRUE if overlapFunc ever returns TRUE.
+ *
+ * Notes:
+ *	The idea behind this function is to view the two regions as sets.
+ *	Together they cover a rectangle of area that this function divides
+ *	into horizontal bands where points are covered only by one region
+ *	or by both. For the first case, the nonOverlapFunc is called with
+ *	each the band and the band's upper and lower extents. For the
+ *	second, the overlapFunc is called to process the entire band. It
+ *	is responsible for clipping the rectangles in the band, though
+ *	this function provides the boundaries.
+ *	At the end of each band, the new region is coalesced, if possible,
+ *	to reduce the number of rectangles in the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+typedef Bool (*OverlapProcPtr)(
+    RegionPtr	pReg,
+    BoxPtr	r1,
+    BoxPtr   	r1End,
+    BoxPtr	r2,
+    BoxPtr   	r2End,
+    short    	y1,
+    short    	y2,
+    Bool	*pOverlap);
+
+static Bool
+RegionOp(
+    RegionPtr       newReg,		    /* Place to store result	     */
+    RegionPtr       reg1,		    /* First region in operation     */
+    RegionPtr       reg2,		    /* 2d region in operation        */
+    OverlapProcPtr  overlapFunc,            /* Function to call for over-
+					     * lapping bands		     */
+    Bool	    appendNon1,		    /* Append non-overlapping bands  */
+					    /* in region 1 ? */
+    Bool	    appendNon2,		    /* Append non-overlapping bands  */
+					    /* in region 2 ? */
+    Bool	    *pOverlap)
+{
+    BoxPtr 	r1;		    /* Pointer into first region     */
+    BoxPtr 	r2;		    /* Pointer into 2d region	     */
+    BoxPtr	r1End;		    /* End of 1st region	     */
+    BoxPtr	r2End;		    /* End of 2d region		     */
+    short	ybot;		    /* Bottom of intersection	     */
+    short	ytop;		    /* Top of intersection	     */
+    RegDataPtr	oldData;	    /* Old data for newReg	     */
+    int		prevBand;	    /* Index of start of
+				     * previous band in newReg       */
+    int		curBand;	    /* Index of start of current
+				     * band in newReg		     */
+    BoxPtr  	r1BandEnd;	    /* End of current band in r1     */
+    BoxPtr  	r2BandEnd;	    /* End of current band in r2     */
+    short   	top;		    /* Top of non-overlapping band   */
+    short   	bot;	    	    /* Bottom of non-overlapping band*/
+    int     	r1y1;	    	    /* Temps for r1->y1 and r2->y1   */
+    int     	r2y1;
+    int	    	newSize;
+    int	    	numRects;
+
+    /*
+     * Break any region computed from a broken region
+     */
+    if (REGION_NAR (reg1) || REGION_NAR(reg2))
+	return RegionBreak (newReg);
+    
+    /*
+     * Initialization:
+     *	set r1, r2, r1End and r2End appropriately, save the rectangles
+     * of the destination region until the end in case it's one of
+     * the two source regions, then mark the "new" region empty, allocating
+     * another array of rectangles for it to use.
+     */
+
+    r1 = REGION_RECTS(reg1);
+    newSize = REGION_NUM_RECTS(reg1);
+    r1End = r1 + newSize;
+    numRects = REGION_NUM_RECTS(reg2);
+    r2 = REGION_RECTS(reg2);
+    r2End = r2 + numRects;
+    assert(r1 != r1End);
+    assert(r2 != r2End);
+
+    oldData = NULL;
+    if (((newReg == reg1) && (newSize > 1)) ||
+	((newReg == reg2) && (numRects > 1)))
+    {
+	oldData = newReg->data;
+	newReg->data = &RegionEmptyData;
+    }
+    /* guess at new size */
+    if (numRects > newSize)
+	newSize = numRects;
+    newSize <<= 1;
+    if (!newReg->data)
+	newReg->data = &RegionEmptyData;
+    else if (newReg->data->size)
+	newReg->data->numRects = 0;
+    if (newSize > newReg->data->size)
+	if (!RegionRectAlloc(newReg, newSize))
+	    return FALSE;
+
+    /*
+     * Initialize ybot.
+     * In the upcoming loop, ybot and ytop serve different functions depending
+     * on whether the band being handled is an overlapping or non-overlapping
+     * band.
+     * 	In the case of a non-overlapping band (only one of the regions
+     * has points in the band), ybot is the bottom of the most recent
+     * intersection and thus clips the top of the rectangles in that band.
+     * ytop is the top of the next intersection between the two regions and
+     * serves to clip the bottom of the rectangles in the current band.
+     *	For an overlapping band (where the two regions intersect), ytop clips
+     * the top of the rectangles of both regions and ybot clips the bottoms.
+     */
+
+    ybot = min(r1->y1, r2->y1);
+    
+    /*
+     * prevBand serves to mark the start of the previous band so rectangles
+     * can be coalesced into larger rectangles. qv. RegionCoalesce, above.
+     * In the beginning, there is no previous band, so prevBand == curBand
+     * (curBand is set later on, of course, but the first band will always
+     * start at index 0). prevBand and curBand must be indices because of
+     * the possible expansion, and resultant moving, of the new region's
+     * array of rectangles.
+     */
+    prevBand = 0;
+    
+    do {
+	/*
+	 * This algorithm proceeds one source-band (as opposed to a
+	 * destination band, which is determined by where the two regions
+	 * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
+	 * rectangle after the last one in the current band for their
+	 * respective regions.
+	 */
+	assert(r1 != r1End);
+	assert(r2 != r2End);
+    
+	FindBand(r1, r1BandEnd, r1End, r1y1);
+	FindBand(r2, r2BandEnd, r2End, r2y1);
+
+	/*
+	 * First handle the band that doesn't intersect, if any.
+	 *
+	 * Note that attention is restricted to one band in the
+	 * non-intersecting region at once, so if a region has n
+	 * bands between the current position and the next place it overlaps
+	 * the other, this entire loop will be passed through n times.
+	 */
+	if (r1y1 < r2y1) {
+	    if (appendNon1) {
+		top = max(r1y1, ybot);
+		bot = min(r1->y2, r2y1);
+		if (top != bot)	{
+		    curBand = newReg->data->numRects;
+		    RegionAppendNonO(newReg, r1, r1BandEnd, top, bot);
+		    Coalesce(newReg, prevBand, curBand);
+		}
+	    }
+	    ytop = r2y1;
+	} else if (r2y1 < r1y1) {
+	    if (appendNon2) {
+		top = max(r2y1, ybot);
+		bot = min(r2->y2, r1y1);
+		if (top != bot) {
+		    curBand = newReg->data->numRects;
+		    RegionAppendNonO(newReg, r2, r2BandEnd, top, bot);
+		    Coalesce(newReg, prevBand, curBand);
+		}
+	    }
+	    ytop = r1y1;
+	} else {
+	    ytop = r1y1;
+	}
+
+	/*
+	 * Now see if we've hit an intersecting band. The two bands only
+	 * intersect if ybot > ytop
+	 */
+	ybot = min(r1->y2, r2->y2);
+	if (ybot > ytop) {
+	    curBand = newReg->data->numRects;
+	    (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot,
+			    pOverlap);
+	    Coalesce(newReg, prevBand, curBand);
+	}
+
+	/*
+	 * If we've finished with a band (y2 == ybot) we skip forward
+	 * in the region to the next band.
+	 */
+	if (r1->y2 == ybot) r1 = r1BandEnd;
+	if (r2->y2 == ybot) r2 = r2BandEnd;
+
+    } while (r1 != r1End && r2 != r2End);
+
+    /*
+     * Deal with whichever region (if any) still has rectangles left.
+     *
+     * We only need to worry about banding and coalescing for the very first
+     * band left.  After that, we can just group all remaining boxes,
+     * regardless of how many bands, into one final append to the list.
+     */
+
+    if ((r1 != r1End) && appendNon1) {
+	/* Do first nonOverlap1Func call, which may be able to coalesce */
+	FindBand(r1, r1BandEnd, r1End, r1y1);
+	curBand = newReg->data->numRects;
+	RegionAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
+	Coalesce(newReg, prevBand, curBand);
+	/* Just append the rest of the boxes  */
+	AppendRegions(newReg, r1BandEnd, r1End);
+
+    } else if ((r2 != r2End) && appendNon2) {
+	/* Do first nonOverlap2Func call, which may be able to coalesce */
+	FindBand(r2, r2BandEnd, r2End, r2y1);
+	curBand = newReg->data->numRects;
+	RegionAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
+	Coalesce(newReg, prevBand, curBand);
+	/* Append rest of boxes */
+	AppendRegions(newReg, r2BandEnd, r2End);
+    }
+
+    if (oldData)
+	free(oldData);
+
+    if (!(numRects = newReg->data->numRects))
+    {
+	xfreeData(newReg);
+	newReg->data = &RegionEmptyData;
+    }
+    else if (numRects == 1)
+    {
+	newReg->extents = *REGION_BOXPTR(newReg);
+	xfreeData(newReg);
+	newReg->data = NULL;
+    }
+    else
+    {
+	DOWNSIZE(newReg, numRects);
+    }
+
+    return TRUE;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionSetExtents --
+ *	Reset the extents of a region to what they should be. Called by
+ *	RegionSubtract and RegionIntersect as they can't figure it out along the
+ *	way or do so easily, as RegionUnion can.
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	The region's 'extents' structure is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+RegionSetExtents (RegionPtr pReg)
+{
+    BoxPtr pBox, pBoxEnd;
+
+    if (!pReg->data)
+	return;
+    if (!pReg->data->size)
+    {
+	pReg->extents.x2 = pReg->extents.x1;
+	pReg->extents.y2 = pReg->extents.y1;
+	return;
+    }
+
+    pBox = REGION_BOXPTR(pReg);
+    pBoxEnd = REGION_END(pReg);
+
+    /*
+     * Since pBox is the first rectangle in the region, it must have the
+     * smallest y1 and since pBoxEnd is the last rectangle in the region,
+     * it must have the largest y2, because of banding. Initialize x1 and
+     * x2 from  pBox and pBoxEnd, resp., as good things to initialize them
+     * to...
+     */
+    pReg->extents.x1 = pBox->x1;
+    pReg->extents.y1 = pBox->y1;
+    pReg->extents.x2 = pBoxEnd->x2;
+    pReg->extents.y2 = pBoxEnd->y2;
+
+    assert(pReg->extents.y1 < pReg->extents.y2);
+    while (pBox <= pBoxEnd) {
+	if (pBox->x1 < pReg->extents.x1)
+	    pReg->extents.x1 = pBox->x1;
+	if (pBox->x2 > pReg->extents.x2)
+	    pReg->extents.x2 = pBox->x2;
+	pBox++;
+    };
+
+    assert(pReg->extents.x1 < pReg->extents.x2);
+}
+
+/*======================================================================
+ *	    Region Intersection
+ *====================================================================*/
+/*-
+ *-----------------------------------------------------------------------
+ * RegionIntersectO --
+ *	Handle an overlapping band for RegionIntersect.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *	Rectangles may be added to the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+Bool
+RegionIntersect(
+    RegionPtr	newReg,     /* destination Region */
+    RegionPtr	reg1,
+    RegionPtr	reg2        /* source regions     */
+    )
+{
+    return pixman_region_intersect (newReg, reg1, reg2);
+}
+
+#define MERGERECT(r)						\
+{								\
+    if (r->x1 <= x2) {						\
+	/* Merge with current rectangle */			\
+	if (r->x1 < x2) *pOverlap = TRUE;				\
+	if (x2 < r->x2) x2 = r->x2;				\
+    } else {							\
+	/* Add current rectangle, start new one */		\
+	NEWRECT(pReg, pNextRect, x1, y1, x2, y2);		\
+	x1 = r->x1;						\
+	x2 = r->x2;						\
+    }								\
+    r++;							\
+}
+
+/*======================================================================
+ *	    Region Union
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionUnionO --
+ *	Handle an overlapping band for the union operation. Picks the
+ *	left-most rectangle each time and merges it into the region.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *	pReg is overwritten.
+ *	pOverlap is set to TRUE if any boxes overlap.
+ *
+ *-----------------------------------------------------------------------
+ */
+static Bool
+RegionUnionO (
+    RegionPtr	pReg,
+    BoxPtr	r1,
+    BoxPtr  	r1End,
+    BoxPtr	r2,
+    BoxPtr  	r2End,
+    short	y1,
+    short	y2,
+    Bool	*pOverlap)
+{
+    BoxPtr     pNextRect;
+    int        x1;     /* left and right side of current union */
+    int        x2;
+
+    assert (y1 < y2);
+    assert(r1 != r1End && r2 != r2End);
+
+    pNextRect = REGION_TOP(pReg);
+
+    /* Start off current rectangle */
+    if (r1->x1 < r2->x1)
+    {
+	x1 = r1->x1;
+	x2 = r1->x2;
+	r1++;
+    }
+    else
+    {
+	x1 = r2->x1;
+	x2 = r2->x2;
+	r2++;
+    }
+    while (r1 != r1End && r2 != r2End)
+    {
+	if (r1->x1 < r2->x1) MERGERECT(r1) else MERGERECT(r2);
+    }
+
+    /* Finish off whoever (if any) is left */
+    if (r1 != r1End)
+    {
+	do
+	{
+	    MERGERECT(r1);
+	} while (r1 != r1End);
+    }
+    else if (r2 != r2End)
+    {
+	do
+	{
+	    MERGERECT(r2);
+	} while (r2 != r2End);
+    }
+    
+    /* Add current rectangle */
+    NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
+
+    return TRUE;
+}
+
+Bool
+RegionUnion(
+    RegionPtr	newReg,          /* destination Region */
+    RegionPtr	reg1,
+    RegionPtr	reg2             /* source regions     */
+    )
+{
+    return pixman_region_union (newReg, reg1, reg2);
+}
+
+/*======================================================================
+ *	    Batch Rectangle Union
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionAppend --
+ * 
+ *      "Append" the rgn rectangles onto the end of dstrgn, maintaining
+ *      knowledge of YX-banding when it's easy.  Otherwise, dstrgn just
+ *      becomes a non-y-x-banded random collection of rectangles, and not
+ *      yet a true region.  After a sequence of appends, the caller must
+ *      call RegionValidate to ensure that a valid region is constructed.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *      dstrgn is modified if rgn has rectangles.
+ *
+ */
+Bool
+RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
+{
+    int numRects, dnumRects, size;
+    BoxPtr new, old;
+    Bool prepend;
+
+    if (REGION_NAR(rgn))
+	return RegionBreak (dstrgn);
+    
+    if (!rgn->data && (dstrgn->data == &RegionEmptyData))
+    {
+	dstrgn->extents = rgn->extents;
+	dstrgn->data = NULL;
+	return TRUE;
+    }
+
+    numRects = REGION_NUM_RECTS(rgn);
+    if (!numRects)
+	return TRUE;
+    prepend = FALSE;
+    size = numRects;
+    dnumRects = REGION_NUM_RECTS(dstrgn);
+    if (!dnumRects && (size < 200))
+	size = 200; /* XXX pick numbers out of a hat */
+    RECTALLOC(dstrgn, size);
+    old = REGION_RECTS(rgn);
+    if (!dnumRects)
+	dstrgn->extents = rgn->extents;
+    else if (dstrgn->extents.x2 > dstrgn->extents.x1)
+    {
+	BoxPtr first, last;
+
+	first = old;
+	last = REGION_BOXPTR(dstrgn) + (dnumRects - 1);
+	if ((first->y1 > last->y2) ||
+	    ((first->y1 == last->y1) && (first->y2 == last->y2) &&
+	     (first->x1 > last->x2)))
+	{
+	    if (rgn->extents.x1 < dstrgn->extents.x1)
+		dstrgn->extents.x1 = rgn->extents.x1;
+	    if (rgn->extents.x2 > dstrgn->extents.x2)
+		dstrgn->extents.x2 = rgn->extents.x2;
+	    dstrgn->extents.y2 = rgn->extents.y2;
+	}
+	else
+	{
+	    first = REGION_BOXPTR(dstrgn);
+	    last = old + (numRects - 1);
+	    if ((first->y1 > last->y2) ||
+		((first->y1 == last->y1) && (first->y2 == last->y2) &&
+		 (first->x1 > last->x2)))
+	    {
+		prepend = TRUE;
+		if (rgn->extents.x1 < dstrgn->extents.x1)
+		    dstrgn->extents.x1 = rgn->extents.x1;
+		if (rgn->extents.x2 > dstrgn->extents.x2)
+		    dstrgn->extents.x2 = rgn->extents.x2;
+		dstrgn->extents.y1 = rgn->extents.y1;
+	    }
+	    else
+		dstrgn->extents.x2 = dstrgn->extents.x1;
+	}
+    }
+    if (prepend)
+    {
+	new = REGION_BOX(dstrgn, numRects);
+	if (dnumRects == 1)
+	    *new = *REGION_BOXPTR(dstrgn);
+	else
+	    memmove((char *)new,(char *)REGION_BOXPTR(dstrgn), 
+		  dnumRects * sizeof(BoxRec));
+	new = REGION_BOXPTR(dstrgn);
+    }
+    else
+	new = REGION_BOXPTR(dstrgn) + dnumRects;
+    if (numRects == 1)
+	*new = *old;
+    else
+	memmove((char *)new, (char *)old, numRects * sizeof(BoxRec));
+    dstrgn->data->numRects += numRects;
+    return TRUE;
+}
+
+   
+#define ExchangeRects(a, b) \
+{			    \
+    BoxRec     t;	    \
+    t = rects[a];	    \
+    rects[a] = rects[b];    \
+    rects[b] = t;	    \
+}
+
+static void
+QuickSortRects(
+    BoxRec     rects[],
+    int        numRects)
+{
+    int	y1;
+    int	x1;
+    int        i, j;
+    BoxPtr     r;
+
+    /* Always called with numRects > 1 */
+
+    do
+    {
+	if (numRects == 2)
+	{
+	    if (rects[0].y1 > rects[1].y1 ||
+		    (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
+		ExchangeRects(0, 1);
+	    return;
+	}
+
+	/* Choose partition element, stick in location 0 */
+        ExchangeRects(0, numRects >> 1);
+	y1 = rects[0].y1;
+	x1 = rects[0].x1;
+
+        /* Partition array */
+        i = 0;
+        j = numRects;
+        do
+	{
+	    r = &(rects[i]);
+	    do
+	    {
+		r++;
+		i++;
+            } while (i != numRects &&
+		     (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1)));
+	    r = &(rects[j]);
+	    do
+	    {
+		r--;
+		j--;
+            } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1));
+            if (i < j)
+		ExchangeRects(i, j);
+        } while (i < j);
+
+        /* Move partition element back to middle */
+        ExchangeRects(0, j);
+
+	/* Recurse */
+        if (numRects-j-1 > 1)
+	    QuickSortRects(&rects[j+1], numRects-j-1);
+        numRects = j;
+    } while (numRects > 1);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionValidate --
+ * 
+ *      Take a ``region'' which is a non-y-x-banded random collection of
+ *      rectangles, and compute a nice region which is the union of all the
+ *      rectangles.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *      The passed-in ``region'' may be modified.
+ *	pOverlap set to TRUE if any retangles overlapped, else FALSE;
+ *
+ * Strategy:
+ *      Step 1. Sort the rectangles into ascending order with primary key y1
+ *		and secondary key x1.
+ *
+ *      Step 2. Split the rectangles into the minimum number of proper y-x
+ *		banded regions.  This may require horizontally merging
+ *		rectangles, and vertically coalescing bands.  With any luck,
+ *		this step in an identity tranformation (ala the Box widget),
+ *		or a coalescing into 1 box (ala Menus).
+ *
+ *	Step 3. Merge the separate regions down to a single region by calling
+ *		RegionUnion.  Maximize the work each RegionUnion call does by using
+ *		a binary merge.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+Bool
+RegionValidate(RegionPtr badreg, Bool *pOverlap)
+{
+    /* Descriptor for regions under construction  in Step 2. */
+    typedef struct {
+	RegionRec   reg;
+	int	    prevBand;
+	int	    curBand;
+    } RegionInfo;
+
+    int	numRects;   /* Original numRects for badreg	    */
+    RegionInfo *ri;	    /* Array of current regions		    */
+    int	numRI;      /* Number of entries used in ri	    */
+    int	sizeRI;	    /* Number of entries available in ri    */
+    int	i;	    /* Index into rects			    */
+    int	j;	    /* Index into ri			    */
+    RegionInfo *rit;       /* &ri[j]				    */
+    RegionPtr  reg;        /* ri[j].reg			    */
+    BoxPtr	box;	    /* Current box in rects		    */
+    BoxPtr	riBox;      /* Last box in ri[j].reg		    */
+    RegionPtr  hreg;       /* ri[j_half].reg			    */
+    Bool		ret = TRUE;
+
+    *pOverlap = FALSE;
+    if (!badreg->data)
+    {
+	good(badreg);
+	return TRUE;
+    }
+    numRects = badreg->data->numRects;
+    if (!numRects)
+    {
+	if (REGION_NAR(badreg))
+	    return FALSE;
+	good(badreg);
+	return TRUE;
+    }
+    if (badreg->extents.x1 < badreg->extents.x2)
+    {
+	if ((numRects) == 1)
+	{
+	    xfreeData(badreg);
+	    badreg->data = (RegDataPtr) NULL;
+	}
+	else
+	{
+	    DOWNSIZE(badreg, numRects);
+	}
+	good(badreg);
+	return TRUE;
+    }
+
+    /* Step 1: Sort the rects array into ascending (y1, x1) order */
+    QuickSortRects(REGION_BOXPTR(badreg), numRects);
+
+    /* Step 2: Scatter the sorted array into the minimum number of regions */
+
+    /* Set up the first region to be the first rectangle in badreg */
+    /* Note that step 2 code will never overflow the ri[0].reg rects array */
+    ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo));
+    if (!ri)
+	return RegionBreak (badreg);
+    sizeRI = 4;
+    numRI = 1;
+    ri[0].prevBand = 0;
+    ri[0].curBand = 0;
+    ri[0].reg = *badreg;
+    box = REGION_BOXPTR(&ri[0].reg);
+    ri[0].reg.extents = *box;
+    ri[0].reg.data->numRects = 1;
+
+    /* Now scatter rectangles into the minimum set of valid regions.  If the
+       next rectangle to be added to a region would force an existing rectangle
+       in the region to be split up in order to maintain y-x banding, just
+       forget it.  Try the next region.  If it doesn't fit cleanly into any
+       region, make a new one. */
+
+    for (i = numRects; --i > 0;)
+    {
+	box++;
+	/* Look for a region to append box to */
+	for (j = numRI, rit = ri; --j >= 0; rit++)
+	{
+	    reg = &rit->reg;
+	    riBox = REGION_END(reg);
+
+	    if (box->y1 == riBox->y1 && box->y2 == riBox->y2)
+	    {
+		/* box is in same band as riBox.  Merge or append it */
+		if (box->x1 <= riBox->x2)
+		{
+		    /* Merge it with riBox */
+		    if (box->x1 < riBox->x2) *pOverlap = TRUE;
+		    if (box->x2 > riBox->x2) riBox->x2 = box->x2;
+		}
+		else
+		{
+		    RECTALLOC_BAIL(reg, 1, bail);
+		    *REGION_TOP(reg) = *box;
+		    reg->data->numRects++;
+		}
+		goto NextRect;   /* So sue me */
+	    }
+	    else if (box->y1 >= riBox->y2)
+	    {
+		/* Put box into new band */
+		if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
+		if (reg->extents.x1 > box->x1)   reg->extents.x1 = box->x1;
+		Coalesce(reg, rit->prevBand, rit->curBand);
+		rit->curBand = reg->data->numRects;
+		RECTALLOC_BAIL(reg, 1, bail);
+		*REGION_TOP(reg) = *box;
+		reg->data->numRects++;
+		goto NextRect;
+	    }
+	    /* Well, this region was inappropriate.  Try the next one. */
+	} /* for j */
+
+	/* Uh-oh.  No regions were appropriate.  Create a new one. */
+	if (sizeRI == numRI)
+	{
+	    /* Oops, allocate space for new region information */
+	    sizeRI <<= 1;
+	    rit = (RegionInfo *) realloc(ri, sizeRI * sizeof(RegionInfo));
+	    if (!rit)
+		goto bail;
+	    ri = rit;
+	    rit = &ri[numRI];
+	}
+	numRI++;
+	rit->prevBand = 0;
+	rit->curBand = 0;
+	rit->reg.extents = *box;
+	rit->reg.data = NULL;
+	if (!RegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
+	    goto bail;
+NextRect: ;
+    } /* for i */
+
+    /* Make a final pass over each region in order to Coalesce and set
+       extents.x2 and extents.y2 */
+
+    for (j = numRI, rit = ri; --j >= 0; rit++)
+    {
+	reg = &rit->reg;
+	riBox = REGION_END(reg);
+	reg->extents.y2 = riBox->y2;
+	if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
+	Coalesce(reg, rit->prevBand, rit->curBand);
+	if (reg->data->numRects == 1) /* keep unions happy below */
+	{
+	    xfreeData(reg);
+	    reg->data = NULL;
+	}
+    }
+
+    /* Step 3: Union all regions into a single region */
+    while (numRI > 1)
+    {
+	int half = numRI/2;
+	for (j = numRI & 1; j < (half + (numRI & 1)); j++)
+	{
+	    reg = &ri[j].reg;
+	    hreg = &ri[j+half].reg;
+	    if (!RegionOp(reg, reg, hreg, RegionUnionO, TRUE, TRUE, pOverlap))
+		ret = FALSE;
+	    if (hreg->extents.x1 < reg->extents.x1)
+		reg->extents.x1 = hreg->extents.x1;
+	    if (hreg->extents.y1 < reg->extents.y1)
+		reg->extents.y1 = hreg->extents.y1;
+	    if (hreg->extents.x2 > reg->extents.x2)
+		reg->extents.x2 = hreg->extents.x2;
+	    if (hreg->extents.y2 > reg->extents.y2)
+		reg->extents.y2 = hreg->extents.y2;
+	    xfreeData(hreg);
+	}
+	numRI -= half;
+    }
+    *badreg = ri[0].reg;
+    free(ri);
+    good(badreg);
+    return ret;
+bail:
+    for (i = 0; i < numRI; i++)
+	xfreeData(&ri[i].reg);
+    free(ri);
+    return RegionBreak (badreg);
+}
+
+RegionPtr
+RegionFromRects(int nrects, xRectangle *prect, int ctype)
+{
+    
+    RegionPtr		pRgn;
+    RegDataPtr		pData;
+    BoxPtr		pBox;
+    int        		i;
+    int			x1, y1, x2, y2;
+
+    pRgn = RegionCreate(NullBox, 0);
+    if (REGION_NAR (pRgn))
+	return pRgn;
+    if (!nrects)
+	return pRgn;
+    if (nrects == 1)
+    {
+	x1 = prect->x;
+	y1 = prect->y;
+	if ((x2 = x1 + (int) prect->width) > MAXSHORT)
+	    x2 = MAXSHORT;
+	if ((y2 = y1 + (int) prect->height) > MAXSHORT)
+	    y2 = MAXSHORT;
+	if (x1 != x2 && y1 != y2)
+	{
+	    pRgn->extents.x1 = x1;
+	    pRgn->extents.y1 = y1;
+	    pRgn->extents.x2 = x2;
+	    pRgn->extents.y2 = y2;
+	    pRgn->data = NULL;
+	}
+	return pRgn;
+    }
+    pData = xallocData(nrects);
+    if (!pData)
+    {
+	RegionBreak (pRgn);
+	return pRgn;
+    }
+    pBox = (BoxPtr) (pData + 1);
+    for (i = nrects; --i >= 0; prect++)
+    {
+	x1 = prect->x;
+	y1 = prect->y;
+	if ((x2 = x1 + (int) prect->width) > MAXSHORT)
+	    x2 = MAXSHORT;
+	if ((y2 = y1 + (int) prect->height) > MAXSHORT)
+	    y2 = MAXSHORT;
+	if (x1 != x2 && y1 != y2)
+	{
+	    pBox->x1 = x1;
+	    pBox->y1 = y1;
+	    pBox->x2 = x2;
+	    pBox->y2 = y2;
+	    pBox++;
+	}
+    }
+    if (pBox != (BoxPtr) (pData + 1))
+    {
+	pData->size = nrects;
+	pData->numRects = pBox - (BoxPtr) (pData + 1);
+    	pRgn->data = pData;
+    	if (ctype != CT_YXBANDED)
+    	{
+	    Bool overlap; /* result ignored */
+	    pRgn->extents.x1 = pRgn->extents.x2 = 0;
+	    RegionValidate(pRgn, &overlap);
+    	}
+    	else
+	    RegionSetExtents(pRgn);
+    	good(pRgn);
+    }
+    else
+    {
+	free(pData);
+    }
+    return pRgn;
+}
+
+/*======================================================================
+ * 	    	  Region Subtraction
+ *====================================================================*/
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionSubtractO --
+ *	Overlapping band subtraction. x1 is the left-most point not yet
+ *	checked.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *	pReg may have rectangles added to it.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionSubtract --
+ *	Subtract regS from regM and leave the result in regD.
+ *	S stands for subtrahend, M for minuend and D for difference.
+ *
+ * Results:
+ *	TRUE if successful.
+ *
+ * Side Effects:
+ *	regD is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+Bool
+RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
+{
+    return pixman_region_subtract (regD, regM, regS);
+}
+
+/*======================================================================
+ *	    Region Inversion
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * RegionInverse --
+ *	Take a region and a box and return a region that is everything
+ *	in the box but not in the region. The careful reader will note
+ *	that this is the same as subtracting the region from the box...
+ *
+ * Results:
+ *	TRUE.
+ *
+ * Side Effects:
+ *	newReg is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+Bool
+RegionInverse(
+    RegionPtr	  newReg,       /* Destination region */
+    RegionPtr	  reg1,         /* Region to invert */
+    BoxPtr	  invRect	/* Bounding box for inversion */
+    )
+{
+    return pixman_region_inverse (newReg, reg1, invRect);
+}
+int
+RegionContainsRect(RegionPtr region, BoxPtr prect)
+{
+    return pixman_region_contains_rectangle (region, prect);
+}
+
+/* TranslateRegion(pReg, x, y)
+   translates in place
+*/
+
+void
+RegionTranslate(RegionPtr pReg, int x, int y)
+{
+    pixman_region_translate (pReg, x, y);
+}
+
+void
+RegionReset(RegionPtr pReg, BoxPtr pBox)
+{
+    pixman_region_reset (pReg, pBox);
+}
+
+Bool
+RegionContainsPoint(
+    RegionPtr pReg,
+    int x,
+    int y,
+    BoxPtr box      /* "return" value */
+    )
+{
+    return pixman_region_contains_point (pReg, x, y, box);
+}
+
+Bool
+RegionNotEmpty(RegionPtr pReg)
+{
+    return pixman_region_not_empty (pReg);
+}
+
+Bool
+RegionBroken(RegionPtr pReg)
+{
+    good(pReg);
+    return (REGION_NAR(pReg));
+}
+
+void
+RegionEmpty(RegionPtr pReg)
+{
+    good(pReg);
+    xfreeData(pReg);
+    pReg->extents.x2 = pReg->extents.x1;
+    pReg->extents.y2 = pReg->extents.y1;
+    pReg->data = &RegionEmptyData;
+}
+
+BoxPtr
+RegionExtents(RegionPtr pReg)
+{
+    good(pReg);
+    return(&pReg->extents);
+}
+
+#define ExchangeSpans(a, b)				    \
+{							    \
+    DDXPointRec	tpt;				    	    \
+    int    	tw;					    \
+							    \
+    tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt;    \
+    tw = widths[a]; widths[a] = widths[b]; widths[b] = tw;  \
+}
+
+/* ||| I should apply the merge sort code to rectangle sorting above, and see
+   if mapping time can be improved.  But right now I've been at work 12 hours,
+   so forget it.
+*/
+
+static void QuickSortSpans(
+    DDXPointRec spans[],
+    int	    	widths[],
+    int	    	numSpans)
+{
+    int	    y;
+    int	    i, j, m;
+    DDXPointPtr    r;
+
+    /* Always called with numSpans > 1 */
+    /* Sorts only by y, doesn't bother to sort by x */
+
+    do
+    {
+	if (numSpans < 9)
+	{
+	    /* Do insertion sort */
+	    int yprev;
+
+	    yprev = spans[0].y;
+	    i = 1;
+	    do
+	    { /* while i != numSpans */
+		y = spans[i].y;
+		if (yprev > y)
+		{
+		    /* spans[i] is out of order.  Move into proper location. */
+		    DDXPointRec tpt;
+		    int	    tw, k;
+
+		    for (j = 0; y >= spans[j].y; j++) {}
+		    tpt = spans[i];
+		    tw  = widths[i];
+		    for (k = i; k != j; k--)
+		    {
+			spans[k] = spans[k-1];
+			widths[k] = widths[k-1];
+		    }
+		    spans[j] = tpt;
+		    widths[j] = tw;
+		    y = spans[i].y;
+		} /* if out of order */
+		yprev = y;
+		i++;
+	    } while (i != numSpans);
+	    return;
+	}
+
+	/* Choose partition element, stick in location 0 */
+	m = numSpans / 2;
+	if (spans[m].y > spans[0].y)		ExchangeSpans(m, 0);
+	if (spans[m].y > spans[numSpans-1].y)   ExchangeSpans(m, numSpans-1);
+	if (spans[m].y > spans[0].y)		ExchangeSpans(m, 0);
+	y = spans[0].y;
+
+        /* Partition array */
+        i = 0;
+        j = numSpans;
+        do
+	{
+	    r = &(spans[i]);
+	    do
+	    {
+		r++;
+		i++;
+            } while (i != numSpans && r->y < y);
+	    r = &(spans[j]);
+	    do
+	    {
+		r--;
+		j--;
+            } while (y < r->y);
+            if (i < j)
+		ExchangeSpans(i, j);
+        } while (i < j);
+
+        /* Move partition element back to middle */
+        ExchangeSpans(0, j);
+
+	/* Recurse */
+        if (numSpans-j-1 > 1)
+	    QuickSortSpans(&spans[j+1], &widths[j+1], numSpans-j-1);
+        numSpans = j;
+    } while (numSpans > 1);
+}
+
+#define NextBand()						    \
+{								    \
+    clipy1 = pboxBandStart->y1;					    \
+    clipy2 = pboxBandStart->y2;					    \
+    pboxBandEnd = pboxBandStart + 1;				    \
+    while (pboxBandEnd != pboxLast && pboxBandEnd->y1 == clipy1) {  \
+	pboxBandEnd++;						    \
+    }								    \
+    for (; ppt != pptLast && ppt->y < clipy1; ppt++, pwidth++) {} \
+}
+
+/*
+    Clip a list of scanlines to a region.  The caller has allocated the
+    space.  FSorted is non-zero if the scanline origins are in ascending
+    order.
+    returns the number of new, clipped scanlines.
+*/
+
+int
+RegionClipSpans(
+    RegionPtr	prgnDst,
+    DDXPointPtr ppt,
+    int	    	*pwidth,
+    int		nspans,
+    DDXPointPtr	pptNew,
+    int		*pwidthNew,
+    int		fSorted)
+{
+    DDXPointPtr pptLast;
+    int	*pwidthNewStart;	/* the vengeance of Xerox! */
+    int	y, x1, x2;
+    int	numRects;
+
+    good(prgnDst);
+    pptLast = ppt + nspans;
+    pwidthNewStart = pwidthNew;
+
+    if (!prgnDst->data)
+    {
+	/* Do special fast code with clip boundaries in registers(?) */
+	/* It doesn't pay much to make use of fSorted in this case, 
+	   so we lump everything together. */
+
+	int clipx1, clipx2, clipy1, clipy2;
+
+	clipx1 = prgnDst->extents.x1;
+	clipy1 = prgnDst->extents.y1;
+	clipx2 = prgnDst->extents.x2;
+	clipy2 = prgnDst->extents.y2;
+	    
+	for (; ppt != pptLast; ppt++, pwidth++)
+	{
+	    y = ppt->y;
+	    x1 = ppt->x;
+	    if (clipy1 <= y && y < clipy2)
+	    {
+		x2 = x1 + *pwidth;
+		if (x1 < clipx1)    x1 = clipx1;
+		if (x2 > clipx2)    x2 = clipx2;
+		if (x1 < x2)
+		{
+		    /* part of span in clip rectangle */
+		    pptNew->x = x1;
+		    pptNew->y = y;
+		    *pwidthNew = x2 - x1;
+		    pptNew++;
+		    pwidthNew++;
+		}
+	    }
+	} /* end for */
+
+    }
+    else if ((numRects = prgnDst->data->numRects))
+    {
+	/* Have to clip against many boxes */
+	BoxPtr pboxBandStart, pboxBandEnd;
+	BoxPtr pbox;
+	BoxPtr pboxLast;
+	int clipy1, clipy2;
+
+	/* In this case, taking advantage of sorted spans gains more than
+	   the sorting costs. */
+	if ((! fSorted) && (nspans > 1))
+	    QuickSortSpans(ppt, pwidth, nspans);
+
+	pboxBandStart = REGION_BOXPTR(prgnDst);
+	pboxLast = pboxBandStart + numRects;
+    
+	NextBand();
+
+	for (; ppt != pptLast; )
+	{
+	    y = ppt->y;
+	    if (y < clipy2)
+	    {
+		/* span is in the current band */
+		pbox = pboxBandStart;
+		x1 = ppt->x;
+		x2 = x1 + *pwidth;
+		do
+		{ /* For each box in band */
+		    int newx1, newx2;
+
+		    newx1 = x1;
+		    newx2 = x2;
+		    if (newx1 < pbox->x1)   newx1 = pbox->x1;
+		    if (newx2 > pbox->x2)   newx2 = pbox->x2;
+		    if (newx1 < newx2)
+		    {
+			/* Part of span in clip rectangle */
+			pptNew->x = newx1;
+			pptNew->y = y;
+			*pwidthNew = newx2 - newx1;
+			pptNew++;
+			pwidthNew++;
+		    }
+		    pbox++;
+		} while (pbox != pboxBandEnd);
+		ppt++;
+		pwidth++;
+	    }
+	    else
+	    {
+		/* Move to next band, adjust ppt as needed */
+		pboxBandStart = pboxBandEnd;
+		if (pboxBandStart == pboxLast)
+		    break; /* We're completely done */
+		NextBand();
+	    }
+	}
+    }
+    return (pwidthNew - pwidthNewStart);
+}
diff --git a/mi/Makefile.am b/mi/Makefile.am
index f22dde9..f6dabda 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -48,7 +48,6 @@ libmi_la_SOURCES = 	\
 	mipolytext.c	\
 	mipolyutil.c	\
 	mipushpxl.c	\
-	miregion.c	\
 	miscanfill.h	\
 	miscrinit.c	\
 	mispans.c	\
diff --git a/mi/miregion.c b/mi/miregion.c
deleted file mode 100644
index a561601..0000000
--- a/mi/miregion.c
+++ /dev/null
@@ -1,1845 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1988, 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
- 
-
-Copyright 1987, 1988, 1989 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, 
-provided that the above copyright notice appear in all copies and that
-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.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-/* The panoramix components contained the following notice */
-/*****************************************************************
-
-Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "regionstr.h"
-#include <X11/Xprotostr.h>
-#include <X11/Xfuncproto.h>
-#include "gc.h"
-#include "mi.h"
-#include "mispans.h"
-#include <pixman.h>
-
-#undef assert
-#ifdef REGION_DEBUG
-#define assert(expr) { \
-            CARD32 *foo = NULL; \
-            if (!(expr)) { \
-                ErrorF("Assertion failed file %s, line %d: %s\n", \
-                       __FILE__, __LINE__, #expr); \
-                *foo = 0xdeadbeef; /* to get a backtrace */ \
-            } \
-        }
-#else
-#define assert(expr)
-#endif
-
-#define good(reg) assert(RegionIsValid(reg))
-
-/*
- * The functions in this file implement the Region abstraction used extensively
- * throughout the X11 sample server. A Region is simply a set of disjoint
- * (non-overlapping) rectangles, plus an "extent" rectangle which is the
- * smallest single rectangle that contains all the non-overlapping rectangles.
- *
- * A Region is implemented as a "y-x-banded" array of rectangles.  This array
- * imposes two degrees of order.  First, all rectangles are sorted by top side
- * y coordinate first (y1), and then by left side x coordinate (x1).
- *
- * Furthermore, the rectangles are grouped into "bands".  Each rectangle in a
- * band has the same top y coordinate (y1), and each has the same bottom y
- * coordinate (y2).  Thus all rectangles in a band differ only in their left
- * and right side (x1 and x2).  Bands are implicit in the array of rectangles:
- * there is no separate list of band start pointers.
- *
- * The y-x band representation does not minimize rectangles.  In particular,
- * if a rectangle vertically crosses a band (the rectangle has scanlines in 
- * the y1 to y2 area spanned by the band), then the rectangle may be broken
- * down into two or more smaller rectangles stacked one atop the other. 
- *
- *  -----------				    -----------
- *  |         |				    |         |		    band 0
- *  |         |  --------		    -----------  --------
- *  |         |  |      |  in y-x banded    |         |  |      |   band 1
- *  |         |  |      |  form is	    |         |  |      |
- *  -----------  |      |		    -----------  --------
- *               |      |				 |      |   band 2
- *               --------				 --------
- *
- * An added constraint on the rectangles is that they must cover as much
- * horizontal area as possible: no two rectangles within a band are allowed
- * to touch.
- *
- * Whenever possible, bands will be merged together to cover a greater vertical
- * distance (and thus reduce the number of rectangles). Two bands can be merged
- * only if the bottom of one touches the top of the other and they have
- * rectangles in the same places (of the same width, of course).
- *
- * Adam de Boor wrote most of the original region code.  Joel McCormack
- * substantially modified or rewrote most of the core arithmetic routines,
- * and added RegionValidate in order to support several speed improvements
- * to miValidateTree.  Bob Scheifler changed the representation to be more
- * compact when empty or a single rectangle, and did a bunch of gratuitous
- * reformatting.
- */
-
-/*  true iff two Boxes overlap */
-#define EXTENTCHECK(r1,r2) \
-      (!( ((r1)->x2 <= (r2)->x1)  || \
-          ((r1)->x1 >= (r2)->x2)  || \
-          ((r1)->y2 <= (r2)->y1)  || \
-          ((r1)->y1 >= (r2)->y2) ) )
-
-/* true iff (x,y) is in Box */
-#define INBOX(r,x,y) \
-      ( ((r)->x2 >  x) && \
-        ((r)->x1 <= x) && \
-        ((r)->y2 >  y) && \
-        ((r)->y1 <= y) )
-
-/* true iff Box r1 contains Box r2 */
-#define SUBSUMES(r1,r2) \
-      ( ((r1)->x1 <= (r2)->x1) && \
-        ((r1)->x2 >= (r2)->x2) && \
-        ((r1)->y1 <= (r2)->y1) && \
-        ((r1)->y2 >= (r2)->y2) )
-
-#define xallocData(n) malloc(REGION_SZOF(n))
-#define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data)
-
-#define RECTALLOC_BAIL(pReg,n,bail) \
-if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
-    if (!RegionRectAlloc(pReg, n)) { goto bail; }
-
-#define RECTALLOC(pReg,n) \
-if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
-    if (!RegionRectAlloc(pReg, n)) { return FALSE; }
-
-#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2)	\
-{						\
-    pNextRect->x1 = nx1;			\
-    pNextRect->y1 = ny1;			\
-    pNextRect->x2 = nx2;			\
-    pNextRect->y2 = ny2;			\
-    pNextRect++;				\
-}
-
-#define NEWRECT(pReg,pNextRect,nx1,ny1,nx2,ny2)			\
-{									\
-    if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\
-    {									\
-	if (!RegionRectAlloc(pReg, 1))					\
-	    return FALSE;						\
-	pNextRect = REGION_TOP(pReg);					\
-    }									\
-    ADDRECT(pNextRect,nx1,ny1,nx2,ny2);					\
-    pReg->data->numRects++;						\
-    assert(pReg->data->numRects<=pReg->data->size);			\
-}
-
-
-#define DOWNSIZE(reg,numRects)						 \
-if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
-{									 \
-    RegDataPtr NewData;							 \
-    NewData = (RegDataPtr)realloc((reg)->data, REGION_SZOF(numRects));	 \
-    if (NewData)							 \
-    {									 \
-	NewData->size = (numRects);					 \
-	(reg)->data = NewData;						 \
-    }									 \
-}
-
-
-BoxRec RegionEmptyBox = {0, 0, 0, 0};
-RegDataRec RegionEmptyData = {0, 0};
-
-RegDataRec  RegionBrokenData = {0, 0};
-static RegionRec   RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData };
-
-void
-InitRegions (void)
-{
-    pixman_region_set_static_pointers (&RegionEmptyBox, &RegionEmptyData, &RegionBrokenData);
-}
-
-/*****************************************************************
- *   RegionCreate(rect, size)
- *     This routine does a simple malloc to make a structure of
- *     REGION of "size" number of rectangles.
- *****************************************************************/
-
-RegionPtr
-RegionCreate(BoxPtr rect, int size)
-{
-    RegionPtr pReg;
-   
-    pReg = (RegionPtr)malloc(sizeof(RegionRec));
-    if (!pReg)
-	return &RegionBrokenRegion;
-
-    RegionInit (pReg, rect, size);
-    
-    return(pReg);
-}
-
-void
-RegionDestroy(RegionPtr pReg)
-{
-    pixman_region_fini (pReg);
-    if (pReg != &RegionBrokenRegion)
-	free(pReg);
-}
-
-void
-RegionPrint(RegionPtr rgn)
-{
-    int num, size;
-    int i;
-    BoxPtr rects;
-
-    num = REGION_NUM_RECTS(rgn);
-    size = REGION_SIZE(rgn);
-    rects = REGION_RECTS(rgn);
-    ErrorF("[mi] num: %d size: %d\n", num, size);
-    ErrorF("[mi] extents: %d %d %d %d\n",
-	   rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2);
-    for (i = 0; i < num; i++)
-      ErrorF("[mi] %d %d %d %d \n",
-	     rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
-    ErrorF("[mi] \n");
-}
-
-Bool
-RegionEqual(RegionPtr reg1, RegionPtr reg2)
-{
-    return pixman_region_equal (reg1, reg2);
-}
-
-#ifdef DEBUG
-Bool
-RegionIsValid(RegionPtr reg)
-{
-    int i, numRects;
-    
-    if ((reg->extents.x1 > reg->extents.x2) ||
-	(reg->extents.y1 > reg->extents.y2))
-	return FALSE;
-    numRects = REGION_NUM_RECTS(reg);
-    if (!numRects)
-	return ((reg->extents.x1 == reg->extents.x2) &&
-		(reg->extents.y1 == reg->extents.y2) &&
-		(reg->data->size || (reg->data == &RegionEmptyData)));
-    else if (numRects == 1)
-	return (!reg->data);
-    else
-    {
-	BoxPtr pboxP, pboxN;
-	BoxRec box;
-	
-	pboxP = REGION_RECTS(reg);
-	box = *pboxP;
-	box.y2 = pboxP[numRects-1].y2;
-	pboxN = pboxP + 1;
-	for (i = numRects; --i > 0; pboxP++, pboxN++)
-	{
-	    if ((pboxN->x1 >= pboxN->x2) ||
-		(pboxN->y1 >= pboxN->y2))
-		return FALSE;
-	    if (pboxN->x1 < box.x1)
-		box.x1 = pboxN->x1;
-	    if (pboxN->x2 > box.x2)
-		box.x2 = pboxN->x2;
-	    if ((pboxN->y1 < pboxP->y1) ||
-		((pboxN->y1 == pboxP->y1) &&
-		 ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2))))
-		return FALSE;
-	}
-	return ((box.x1 == reg->extents.x1) &&
-		(box.x2 == reg->extents.x2) &&
-		(box.y1 == reg->extents.y1) &&
-		(box.y2 == reg->extents.y2));
-    }
-}
-#endif /* DEBUG */
-
-/*****************************************************************
- *   RegionInit(pReg, rect, size)
- *     Outer region rect is statically allocated.
- *****************************************************************/
-
-void
-RegionInit(RegionPtr pReg, BoxPtr rect, int size)
-{
-    if (rect)
-	pixman_region_init_with_extents (pReg, rect);
-    else
-	pixman_region_init (pReg);
-}
-
-void
-RegionUninit(RegionPtr pReg)
-{
-    pixman_region_fini (pReg);
-}
-
-Bool
-RegionBreak (RegionPtr pReg)
-{
-    xfreeData (pReg);
-    pReg->extents = RegionEmptyBox;
-    pReg->data = &RegionBrokenData;
-    return FALSE;
-}
-
-Bool
-RegionRectAlloc(RegionPtr pRgn, int n)
-{
-    RegDataPtr	data;
-    
-    if (!pRgn->data)
-    {
-	n++;
-	pRgn->data = xallocData(n);
-	if (!pRgn->data)
-	    return RegionBreak (pRgn);
-	pRgn->data->numRects = 1;
-	*REGION_BOXPTR(pRgn) = pRgn->extents;
-    }
-    else if (!pRgn->data->size)
-    {
-	pRgn->data = xallocData(n);
-	if (!pRgn->data)
-	    return RegionBreak (pRgn);
-	pRgn->data->numRects = 0;
-    }
-    else
-    {
-	if (n == 1)
-	{
-	    n = pRgn->data->numRects;
-	    if (n > 500) /* XXX pick numbers out of a hat */
-		n = 250;
-	}
-	n += pRgn->data->numRects;
-	data = (RegDataPtr)realloc(pRgn->data, REGION_SZOF(n));
-	if (!data)
-	    return RegionBreak (pRgn);
-	pRgn->data = data;
-    }
-    pRgn->data->size = n;
-    return TRUE;
-}
-
-Bool
-RegionCopy(RegionPtr dst, RegionPtr src)
-{
-    return pixman_region_copy (dst, src);
-}
-
-/*======================================================================
- *	    Generic Region Operator
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionCoalesce --
- *	Attempt to merge the boxes in the current band with those in the
- *	previous one.  We are guaranteed that the current band extends to
- *      the end of the rects array.  Used only by RegionOp.
- *
- * Results:
- *	The new index for the previous band.
- *
- * Side Effects:
- *	If coalescing takes place:
- *	    - rectangles in the previous band will have their y2 fields
- *	      altered.
- *	    - pReg->data->numRects will be decreased.
- *
- *-----------------------------------------------------------------------
- */
-_X_INLINE static int
-RegionCoalesce (
-    RegionPtr	pReg,	    	/* Region to coalesce		     */
-    int	    	  	prevStart,  	/* Index of start of previous band   */
-    int	    	  	curStart)   	/* Index of start of current band    */
-{
-    BoxPtr	pPrevBox;   	/* Current box in previous band	     */
-    BoxPtr	pCurBox;    	/* Current box in current band       */
-    int  	numRects;	/* Number rectangles in both bands   */
-    int		y2;		/* Bottom of current band	     */
-    /*
-     * Figure out how many rectangles are in the band.
-     */
-    numRects = curStart - prevStart;
-    assert(numRects == pReg->data->numRects - curStart);
-
-    if (!numRects) return curStart;
-
-    /*
-     * The bands may only be coalesced if the bottom of the previous
-     * matches the top scanline of the current.
-     */
-    pPrevBox = REGION_BOX(pReg, prevStart);
-    pCurBox = REGION_BOX(pReg, curStart);
-    if (pPrevBox->y2 != pCurBox->y1) return curStart;
-
-    /*
-     * Make sure the bands have boxes in the same places. This
-     * assumes that boxes have been added in such a way that they
-     * cover the most area possible. I.e. two boxes in a band must
-     * have some horizontal space between them.
-     */
-    y2 = pCurBox->y2;
-
-    do {
-	if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) {
-	    return (curStart);
-	}
-	pPrevBox++;
-	pCurBox++;
-	numRects--;
-    } while (numRects);
-
-    /*
-     * The bands may be merged, so set the bottom y of each box
-     * in the previous band to the bottom y of the current band.
-     */
-    numRects = curStart - prevStart;
-    pReg->data->numRects -= numRects;
-    do {
-	pPrevBox--;
-	pPrevBox->y2 = y2;
-	numRects--;
-    } while (numRects);
-    return prevStart;
-}
-
-
-/* Quicky macro to avoid trivial reject procedure calls to RegionCoalesce */
-
-#define Coalesce(newReg, prevBand, curBand)				\
-    if (curBand - prevBand == newReg->data->numRects - curBand) {	\
-	prevBand = RegionCoalesce(newReg, prevBand, curBand);		\
-    } else {								\
-	prevBand = curBand;						\
-    }
-
-/*-
- *-----------------------------------------------------------------------
- * RegionAppendNonO --
- *	Handle a non-overlapping band for the union and subtract operations.
- *      Just adds the (top/bottom-clipped) rectangles into the region.
- *      Doesn't have to check for subsumption or anything.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	pReg->data->numRects is incremented and the rectangles overwritten
- *	with the rectangles we're passed.
- *
- *-----------------------------------------------------------------------
- */
-
-_X_INLINE static Bool
-RegionAppendNonO (
-    RegionPtr	pReg,
-    BoxPtr	r,
-    BoxPtr  	rEnd,
-    int  	y1,
-    int  	y2)
-{
-    BoxPtr	pNextRect;
-    int		newRects;
-
-    newRects = rEnd - r;
-
-    assert(y1 < y2);
-    assert(newRects != 0);
-
-    /* Make sure we have enough space for all rectangles to be added */
-    RECTALLOC(pReg, newRects);
-    pNextRect = REGION_TOP(pReg);
-    pReg->data->numRects += newRects;
-    do {
-	assert(r->x1 < r->x2);
-	ADDRECT(pNextRect, r->x1, y1, r->x2, y2);
-	r++;
-    } while (r != rEnd);
-
-    return TRUE;
-}
-
-#define FindBand(r, rBandEnd, rEnd, ry1)		    \
-{							    \
-    ry1 = r->y1;					    \
-    rBandEnd = r+1;					    \
-    while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1)) {   \
-	rBandEnd++;					    \
-    }							    \
-}
-
-#define	AppendRegions(newReg, r, rEnd)					\
-{									\
-    int newRects;							\
-    if ((newRects = rEnd - r)) {					\
-	RECTALLOC(newReg, newRects);					\
-	memmove((char *)REGION_TOP(newReg),(char *)r, 			\
-              newRects * sizeof(BoxRec));				\
-	newReg->data->numRects += newRects;				\
-    }									\
-}
-
-/*-
- *-----------------------------------------------------------------------
- * RegionOp --
- *	Apply an operation to two regions. Called by RegionUnion, RegionInverse,
- *	RegionSubtract, RegionIntersect....  Both regions MUST have at least one
- *      rectangle, and cannot be the same object.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	The new region is overwritten.
- *	pOverlap set to TRUE if overlapFunc ever returns TRUE.
- *
- * Notes:
- *	The idea behind this function is to view the two regions as sets.
- *	Together they cover a rectangle of area that this function divides
- *	into horizontal bands where points are covered only by one region
- *	or by both. For the first case, the nonOverlapFunc is called with
- *	each the band and the band's upper and lower extents. For the
- *	second, the overlapFunc is called to process the entire band. It
- *	is responsible for clipping the rectangles in the band, though
- *	this function provides the boundaries.
- *	At the end of each band, the new region is coalesced, if possible,
- *	to reduce the number of rectangles in the region.
- *
- *-----------------------------------------------------------------------
- */
-
-typedef Bool (*OverlapProcPtr)(
-    RegionPtr	pReg,
-    BoxPtr	r1,
-    BoxPtr   	r1End,
-    BoxPtr	r2,
-    BoxPtr   	r2End,
-    short    	y1,
-    short    	y2,
-    Bool	*pOverlap);
-
-static Bool
-RegionOp(
-    RegionPtr       newReg,		    /* Place to store result	     */
-    RegionPtr       reg1,		    /* First region in operation     */
-    RegionPtr       reg2,		    /* 2d region in operation        */
-    OverlapProcPtr  overlapFunc,            /* Function to call for over-
-					     * lapping bands		     */
-    Bool	    appendNon1,		    /* Append non-overlapping bands  */
-					    /* in region 1 ? */
-    Bool	    appendNon2,		    /* Append non-overlapping bands  */
-					    /* in region 2 ? */
-    Bool	    *pOverlap)
-{
-    BoxPtr 	r1;		    /* Pointer into first region     */
-    BoxPtr 	r2;		    /* Pointer into 2d region	     */
-    BoxPtr	r1End;		    /* End of 1st region	     */
-    BoxPtr	r2End;		    /* End of 2d region		     */
-    short	ybot;		    /* Bottom of intersection	     */
-    short	ytop;		    /* Top of intersection	     */
-    RegDataPtr	oldData;	    /* Old data for newReg	     */
-    int		prevBand;	    /* Index of start of
-				     * previous band in newReg       */
-    int		curBand;	    /* Index of start of current
-				     * band in newReg		     */
-    BoxPtr  	r1BandEnd;	    /* End of current band in r1     */
-    BoxPtr  	r2BandEnd;	    /* End of current band in r2     */
-    short   	top;		    /* Top of non-overlapping band   */
-    short   	bot;	    	    /* Bottom of non-overlapping band*/
-    int     	r1y1;	    	    /* Temps for r1->y1 and r2->y1   */
-    int     	r2y1;
-    int	    	newSize;
-    int	    	numRects;
-
-    /*
-     * Break any region computed from a broken region
-     */
-    if (REGION_NAR (reg1) || REGION_NAR(reg2))
-	return RegionBreak (newReg);
-    
-    /*
-     * Initialization:
-     *	set r1, r2, r1End and r2End appropriately, save the rectangles
-     * of the destination region until the end in case it's one of
-     * the two source regions, then mark the "new" region empty, allocating
-     * another array of rectangles for it to use.
-     */
-
-    r1 = REGION_RECTS(reg1);
-    newSize = REGION_NUM_RECTS(reg1);
-    r1End = r1 + newSize;
-    numRects = REGION_NUM_RECTS(reg2);
-    r2 = REGION_RECTS(reg2);
-    r2End = r2 + numRects;
-    assert(r1 != r1End);
-    assert(r2 != r2End);
-
-    oldData = NULL;
-    if (((newReg == reg1) && (newSize > 1)) ||
-	((newReg == reg2) && (numRects > 1)))
-    {
-	oldData = newReg->data;
-	newReg->data = &RegionEmptyData;
-    }
-    /* guess at new size */
-    if (numRects > newSize)
-	newSize = numRects;
-    newSize <<= 1;
-    if (!newReg->data)
-	newReg->data = &RegionEmptyData;
-    else if (newReg->data->size)
-	newReg->data->numRects = 0;
-    if (newSize > newReg->data->size)
-	if (!RegionRectAlloc(newReg, newSize))
-	    return FALSE;
-
-    /*
-     * Initialize ybot.
-     * In the upcoming loop, ybot and ytop serve different functions depending
-     * on whether the band being handled is an overlapping or non-overlapping
-     * band.
-     * 	In the case of a non-overlapping band (only one of the regions
-     * has points in the band), ybot is the bottom of the most recent
-     * intersection and thus clips the top of the rectangles in that band.
-     * ytop is the top of the next intersection between the two regions and
-     * serves to clip the bottom of the rectangles in the current band.
-     *	For an overlapping band (where the two regions intersect), ytop clips
-     * the top of the rectangles of both regions and ybot clips the bottoms.
-     */
-
-    ybot = min(r1->y1, r2->y1);
-    
-    /*
-     * prevBand serves to mark the start of the previous band so rectangles
-     * can be coalesced into larger rectangles. qv. RegionCoalesce, above.
-     * In the beginning, there is no previous band, so prevBand == curBand
-     * (curBand is set later on, of course, but the first band will always
-     * start at index 0). prevBand and curBand must be indices because of
-     * the possible expansion, and resultant moving, of the new region's
-     * array of rectangles.
-     */
-    prevBand = 0;
-    
-    do {
-	/*
-	 * This algorithm proceeds one source-band (as opposed to a
-	 * destination band, which is determined by where the two regions
-	 * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
-	 * rectangle after the last one in the current band for their
-	 * respective regions.
-	 */
-	assert(r1 != r1End);
-	assert(r2 != r2End);
-    
-	FindBand(r1, r1BandEnd, r1End, r1y1);
-	FindBand(r2, r2BandEnd, r2End, r2y1);
-
-	/*
-	 * First handle the band that doesn't intersect, if any.
-	 *
-	 * Note that attention is restricted to one band in the
-	 * non-intersecting region at once, so if a region has n
-	 * bands between the current position and the next place it overlaps
-	 * the other, this entire loop will be passed through n times.
-	 */
-	if (r1y1 < r2y1) {
-	    if (appendNon1) {
-		top = max(r1y1, ybot);
-		bot = min(r1->y2, r2y1);
-		if (top != bot)	{
-		    curBand = newReg->data->numRects;
-		    RegionAppendNonO(newReg, r1, r1BandEnd, top, bot);
-		    Coalesce(newReg, prevBand, curBand);
-		}
-	    }
-	    ytop = r2y1;
-	} else if (r2y1 < r1y1) {
-	    if (appendNon2) {
-		top = max(r2y1, ybot);
-		bot = min(r2->y2, r1y1);
-		if (top != bot) {
-		    curBand = newReg->data->numRects;
-		    RegionAppendNonO(newReg, r2, r2BandEnd, top, bot);
-		    Coalesce(newReg, prevBand, curBand);
-		}
-	    }
-	    ytop = r1y1;
-	} else {
-	    ytop = r1y1;
-	}
-
-	/*
-	 * Now see if we've hit an intersecting band. The two bands only
-	 * intersect if ybot > ytop
-	 */
-	ybot = min(r1->y2, r2->y2);
-	if (ybot > ytop) {
-	    curBand = newReg->data->numRects;
-	    (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot,
-			    pOverlap);
-	    Coalesce(newReg, prevBand, curBand);
-	}
-
-	/*
-	 * If we've finished with a band (y2 == ybot) we skip forward
-	 * in the region to the next band.
-	 */
-	if (r1->y2 == ybot) r1 = r1BandEnd;
-	if (r2->y2 == ybot) r2 = r2BandEnd;
-
-    } while (r1 != r1End && r2 != r2End);
-
-    /*
-     * Deal with whichever region (if any) still has rectangles left.
-     *
-     * We only need to worry about banding and coalescing for the very first
-     * band left.  After that, we can just group all remaining boxes,
-     * regardless of how many bands, into one final append to the list.
-     */
-
-    if ((r1 != r1End) && appendNon1) {
-	/* Do first nonOverlap1Func call, which may be able to coalesce */
-	FindBand(r1, r1BandEnd, r1End, r1y1);
-	curBand = newReg->data->numRects;
-	RegionAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
-	Coalesce(newReg, prevBand, curBand);
-	/* Just append the rest of the boxes  */
-	AppendRegions(newReg, r1BandEnd, r1End);
-
-    } else if ((r2 != r2End) && appendNon2) {
-	/* Do first nonOverlap2Func call, which may be able to coalesce */
-	FindBand(r2, r2BandEnd, r2End, r2y1);
-	curBand = newReg->data->numRects;
-	RegionAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
-	Coalesce(newReg, prevBand, curBand);
-	/* Append rest of boxes */
-	AppendRegions(newReg, r2BandEnd, r2End);
-    }
-
-    if (oldData)
-	free(oldData);
-
-    if (!(numRects = newReg->data->numRects))
-    {
-	xfreeData(newReg);
-	newReg->data = &RegionEmptyData;
-    }
-    else if (numRects == 1)
-    {
-	newReg->extents = *REGION_BOXPTR(newReg);
-	xfreeData(newReg);
-	newReg->data = NULL;
-    }
-    else
-    {
-	DOWNSIZE(newReg, numRects);
-    }
-
-    return TRUE;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * RegionSetExtents --
- *	Reset the extents of a region to what they should be. Called by
- *	RegionSubtract and RegionIntersect as they can't figure it out along the
- *	way or do so easily, as RegionUnion can.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	The region's 'extents' structure is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-static void
-RegionSetExtents (RegionPtr pReg)
-{
-    BoxPtr pBox, pBoxEnd;
-
-    if (!pReg->data)
-	return;
-    if (!pReg->data->size)
-    {
-	pReg->extents.x2 = pReg->extents.x1;
-	pReg->extents.y2 = pReg->extents.y1;
-	return;
-    }
-
-    pBox = REGION_BOXPTR(pReg);
-    pBoxEnd = REGION_END(pReg);
-
-    /*
-     * Since pBox is the first rectangle in the region, it must have the
-     * smallest y1 and since pBoxEnd is the last rectangle in the region,
-     * it must have the largest y2, because of banding. Initialize x1 and
-     * x2 from  pBox and pBoxEnd, resp., as good things to initialize them
-     * to...
-     */
-    pReg->extents.x1 = pBox->x1;
-    pReg->extents.y1 = pBox->y1;
-    pReg->extents.x2 = pBoxEnd->x2;
-    pReg->extents.y2 = pBoxEnd->y2;
-
-    assert(pReg->extents.y1 < pReg->extents.y2);
-    while (pBox <= pBoxEnd) {
-	if (pBox->x1 < pReg->extents.x1)
-	    pReg->extents.x1 = pBox->x1;
-	if (pBox->x2 > pReg->extents.x2)
-	    pReg->extents.x2 = pBox->x2;
-	pBox++;
-    };
-
-    assert(pReg->extents.x1 < pReg->extents.x2);
-}
-
-/*======================================================================
- *	    Region Intersection
- *====================================================================*/
-/*-
- *-----------------------------------------------------------------------
- * RegionIntersectO --
- *	Handle an overlapping band for RegionIntersect.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	Rectangles may be added to the region.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-Bool
-RegionIntersect(
-    RegionPtr	newReg,     /* destination Region */
-    RegionPtr	reg1,
-    RegionPtr	reg2        /* source regions     */
-    )
-{
-    return pixman_region_intersect (newReg, reg1, reg2);
-}
-
-#define MERGERECT(r)						\
-{								\
-    if (r->x1 <= x2) {						\
-	/* Merge with current rectangle */			\
-	if (r->x1 < x2) *pOverlap = TRUE;				\
-	if (x2 < r->x2) x2 = r->x2;				\
-    } else {							\
-	/* Add current rectangle, start new one */		\
-	NEWRECT(pReg, pNextRect, x1, y1, x2, y2);		\
-	x1 = r->x1;						\
-	x2 = r->x2;						\
-    }								\
-    r++;							\
-}
-
-/*======================================================================
- *	    Region Union
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionUnionO --
- *	Handle an overlapping band for the union operation. Picks the
- *	left-most rectangle each time and merges it into the region.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	pReg is overwritten.
- *	pOverlap is set to TRUE if any boxes overlap.
- *
- *-----------------------------------------------------------------------
- */
-static Bool
-RegionUnionO (
-    RegionPtr	pReg,
-    BoxPtr	r1,
-    BoxPtr  	r1End,
-    BoxPtr	r2,
-    BoxPtr  	r2End,
-    short	y1,
-    short	y2,
-    Bool	*pOverlap)
-{
-    BoxPtr     pNextRect;
-    int        x1;     /* left and right side of current union */
-    int        x2;
-
-    assert (y1 < y2);
-    assert(r1 != r1End && r2 != r2End);
-
-    pNextRect = REGION_TOP(pReg);
-
-    /* Start off current rectangle */
-    if (r1->x1 < r2->x1)
-    {
-	x1 = r1->x1;
-	x2 = r1->x2;
-	r1++;
-    }
-    else
-    {
-	x1 = r2->x1;
-	x2 = r2->x2;
-	r2++;
-    }
-    while (r1 != r1End && r2 != r2End)
-    {
-	if (r1->x1 < r2->x1) MERGERECT(r1) else MERGERECT(r2);
-    }
-
-    /* Finish off whoever (if any) is left */
-    if (r1 != r1End)
-    {
-	do
-	{
-	    MERGERECT(r1);
-	} while (r1 != r1End);
-    }
-    else if (r2 != r2End)
-    {
-	do
-	{
-	    MERGERECT(r2);
-	} while (r2 != r2End);
-    }
-    
-    /* Add current rectangle */
-    NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
-
-    return TRUE;
-}
-
-Bool
-RegionUnion(
-    RegionPtr	newReg,          /* destination Region */
-    RegionPtr	reg1,
-    RegionPtr	reg2             /* source regions     */
-    )
-{
-    return pixman_region_union (newReg, reg1, reg2);
-}
-
-/*======================================================================
- *	    Batch Rectangle Union
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionAppend --
- * 
- *      "Append" the rgn rectangles onto the end of dstrgn, maintaining
- *      knowledge of YX-banding when it's easy.  Otherwise, dstrgn just
- *      becomes a non-y-x-banded random collection of rectangles, and not
- *      yet a true region.  After a sequence of appends, the caller must
- *      call RegionValidate to ensure that a valid region is constructed.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *      dstrgn is modified if rgn has rectangles.
- *
- */
-Bool
-RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
-{
-    int numRects, dnumRects, size;
-    BoxPtr new, old;
-    Bool prepend;
-
-    if (REGION_NAR(rgn))
-	return RegionBreak (dstrgn);
-    
-    if (!rgn->data && (dstrgn->data == &RegionEmptyData))
-    {
-	dstrgn->extents = rgn->extents;
-	dstrgn->data = NULL;
-	return TRUE;
-    }
-
-    numRects = REGION_NUM_RECTS(rgn);
-    if (!numRects)
-	return TRUE;
-    prepend = FALSE;
-    size = numRects;
-    dnumRects = REGION_NUM_RECTS(dstrgn);
-    if (!dnumRects && (size < 200))
-	size = 200; /* XXX pick numbers out of a hat */
-    RECTALLOC(dstrgn, size);
-    old = REGION_RECTS(rgn);
-    if (!dnumRects)
-	dstrgn->extents = rgn->extents;
-    else if (dstrgn->extents.x2 > dstrgn->extents.x1)
-    {
-	BoxPtr first, last;
-
-	first = old;
-	last = REGION_BOXPTR(dstrgn) + (dnumRects - 1);
-	if ((first->y1 > last->y2) ||
-	    ((first->y1 == last->y1) && (first->y2 == last->y2) &&
-	     (first->x1 > last->x2)))
-	{
-	    if (rgn->extents.x1 < dstrgn->extents.x1)
-		dstrgn->extents.x1 = rgn->extents.x1;
-	    if (rgn->extents.x2 > dstrgn->extents.x2)
-		dstrgn->extents.x2 = rgn->extents.x2;
-	    dstrgn->extents.y2 = rgn->extents.y2;
-	}
-	else
-	{
-	    first = REGION_BOXPTR(dstrgn);
-	    last = old + (numRects - 1);
-	    if ((first->y1 > last->y2) ||
-		((first->y1 == last->y1) && (first->y2 == last->y2) &&
-		 (first->x1 > last->x2)))
-	    {
-		prepend = TRUE;
-		if (rgn->extents.x1 < dstrgn->extents.x1)
-		    dstrgn->extents.x1 = rgn->extents.x1;
-		if (rgn->extents.x2 > dstrgn->extents.x2)
-		    dstrgn->extents.x2 = rgn->extents.x2;
-		dstrgn->extents.y1 = rgn->extents.y1;
-	    }
-	    else
-		dstrgn->extents.x2 = dstrgn->extents.x1;
-	}
-    }
-    if (prepend)
-    {
-	new = REGION_BOX(dstrgn, numRects);
-	if (dnumRects == 1)
-	    *new = *REGION_BOXPTR(dstrgn);
-	else
-	    memmove((char *)new,(char *)REGION_BOXPTR(dstrgn), 
-		  dnumRects * sizeof(BoxRec));
-	new = REGION_BOXPTR(dstrgn);
-    }
-    else
-	new = REGION_BOXPTR(dstrgn) + dnumRects;
-    if (numRects == 1)
-	*new = *old;
-    else
-	memmove((char *)new, (char *)old, numRects * sizeof(BoxRec));
-    dstrgn->data->numRects += numRects;
-    return TRUE;
-}
-
-   
-#define ExchangeRects(a, b) \
-{			    \
-    BoxRec     t;	    \
-    t = rects[a];	    \
-    rects[a] = rects[b];    \
-    rects[b] = t;	    \
-}
-
-static void
-QuickSortRects(
-    BoxRec     rects[],
-    int        numRects)
-{
-    int	y1;
-    int	x1;
-    int        i, j;
-    BoxPtr     r;
-
-    /* Always called with numRects > 1 */
-
-    do
-    {
-	if (numRects == 2)
-	{
-	    if (rects[0].y1 > rects[1].y1 ||
-		    (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
-		ExchangeRects(0, 1);
-	    return;
-	}
-
-	/* Choose partition element, stick in location 0 */
-        ExchangeRects(0, numRects >> 1);
-	y1 = rects[0].y1;
-	x1 = rects[0].x1;
-
-        /* Partition array */
-        i = 0;
-        j = numRects;
-        do
-	{
-	    r = &(rects[i]);
-	    do
-	    {
-		r++;
-		i++;
-            } while (i != numRects &&
-		     (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1)));
-	    r = &(rects[j]);
-	    do
-	    {
-		r--;
-		j--;
-            } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1));
-            if (i < j)
-		ExchangeRects(i, j);
-        } while (i < j);
-
-        /* Move partition element back to middle */
-        ExchangeRects(0, j);
-
-	/* Recurse */
-        if (numRects-j-1 > 1)
-	    QuickSortRects(&rects[j+1], numRects-j-1);
-        numRects = j;
-    } while (numRects > 1);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * RegionValidate --
- * 
- *      Take a ``region'' which is a non-y-x-banded random collection of
- *      rectangles, and compute a nice region which is the union of all the
- *      rectangles.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *      The passed-in ``region'' may be modified.
- *	pOverlap set to TRUE if any retangles overlapped, else FALSE;
- *
- * Strategy:
- *      Step 1. Sort the rectangles into ascending order with primary key y1
- *		and secondary key x1.
- *
- *      Step 2. Split the rectangles into the minimum number of proper y-x
- *		banded regions.  This may require horizontally merging
- *		rectangles, and vertically coalescing bands.  With any luck,
- *		this step in an identity tranformation (ala the Box widget),
- *		or a coalescing into 1 box (ala Menus).
- *
- *	Step 3. Merge the separate regions down to a single region by calling
- *		RegionUnion.  Maximize the work each RegionUnion call does by using
- *		a binary merge.
- *
- *-----------------------------------------------------------------------
- */
-
-Bool
-RegionValidate(RegionPtr badreg, Bool *pOverlap)
-{
-    /* Descriptor for regions under construction  in Step 2. */
-    typedef struct {
-	RegionRec   reg;
-	int	    prevBand;
-	int	    curBand;
-    } RegionInfo;
-
-    int	numRects;   /* Original numRects for badreg	    */
-    RegionInfo *ri;	    /* Array of current regions		    */
-    int	numRI;      /* Number of entries used in ri	    */
-    int	sizeRI;	    /* Number of entries available in ri    */
-    int	i;	    /* Index into rects			    */
-    int	j;	    /* Index into ri			    */
-    RegionInfo *rit;       /* &ri[j]				    */
-    RegionPtr  reg;        /* ri[j].reg			    */
-    BoxPtr	box;	    /* Current box in rects		    */
-    BoxPtr	riBox;      /* Last box in ri[j].reg		    */
-    RegionPtr  hreg;       /* ri[j_half].reg			    */
-    Bool		ret = TRUE;
-
-    *pOverlap = FALSE;
-    if (!badreg->data)
-    {
-	good(badreg);
-	return TRUE;
-    }
-    numRects = badreg->data->numRects;
-    if (!numRects)
-    {
-	if (REGION_NAR(badreg))
-	    return FALSE;
-	good(badreg);
-	return TRUE;
-    }
-    if (badreg->extents.x1 < badreg->extents.x2)
-    {
-	if ((numRects) == 1)
-	{
-	    xfreeData(badreg);
-	    badreg->data = (RegDataPtr) NULL;
-	}
-	else
-	{
-	    DOWNSIZE(badreg, numRects);
-	}
-	good(badreg);
-	return TRUE;
-    }
-
-    /* Step 1: Sort the rects array into ascending (y1, x1) order */
-    QuickSortRects(REGION_BOXPTR(badreg), numRects);
-
-    /* Step 2: Scatter the sorted array into the minimum number of regions */
-
-    /* Set up the first region to be the first rectangle in badreg */
-    /* Note that step 2 code will never overflow the ri[0].reg rects array */
-    ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo));
-    if (!ri)
-	return RegionBreak (badreg);
-    sizeRI = 4;
-    numRI = 1;
-    ri[0].prevBand = 0;
-    ri[0].curBand = 0;
-    ri[0].reg = *badreg;
-    box = REGION_BOXPTR(&ri[0].reg);
-    ri[0].reg.extents = *box;
-    ri[0].reg.data->numRects = 1;
-
-    /* Now scatter rectangles into the minimum set of valid regions.  If the
-       next rectangle to be added to a region would force an existing rectangle
-       in the region to be split up in order to maintain y-x banding, just
-       forget it.  Try the next region.  If it doesn't fit cleanly into any
-       region, make a new one. */
-
-    for (i = numRects; --i > 0;)
-    {
-	box++;
-	/* Look for a region to append box to */
-	for (j = numRI, rit = ri; --j >= 0; rit++)
-	{
-	    reg = &rit->reg;
-	    riBox = REGION_END(reg);
-
-	    if (box->y1 == riBox->y1 && box->y2 == riBox->y2)
-	    {
-		/* box is in same band as riBox.  Merge or append it */
-		if (box->x1 <= riBox->x2)
-		{
-		    /* Merge it with riBox */
-		    if (box->x1 < riBox->x2) *pOverlap = TRUE;
-		    if (box->x2 > riBox->x2) riBox->x2 = box->x2;
-		}
-		else
-		{
-		    RECTALLOC_BAIL(reg, 1, bail);
-		    *REGION_TOP(reg) = *box;
-		    reg->data->numRects++;
-		}
-		goto NextRect;   /* So sue me */
-	    }
-	    else if (box->y1 >= riBox->y2)
-	    {
-		/* Put box into new band */
-		if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
-		if (reg->extents.x1 > box->x1)   reg->extents.x1 = box->x1;
-		Coalesce(reg, rit->prevBand, rit->curBand);
-		rit->curBand = reg->data->numRects;
-		RECTALLOC_BAIL(reg, 1, bail);
-		*REGION_TOP(reg) = *box;
-		reg->data->numRects++;
-		goto NextRect;
-	    }
-	    /* Well, this region was inappropriate.  Try the next one. */
-	} /* for j */
-
-	/* Uh-oh.  No regions were appropriate.  Create a new one. */
-	if (sizeRI == numRI)
-	{
-	    /* Oops, allocate space for new region information */
-	    sizeRI <<= 1;
-	    rit = (RegionInfo *) realloc(ri, sizeRI * sizeof(RegionInfo));
-	    if (!rit)
-		goto bail;
-	    ri = rit;
-	    rit = &ri[numRI];
-	}
-	numRI++;
-	rit->prevBand = 0;
-	rit->curBand = 0;
-	rit->reg.extents = *box;
-	rit->reg.data = NULL;
-	if (!RegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
-	    goto bail;
-NextRect: ;
-    } /* for i */
-
-    /* Make a final pass over each region in order to Coalesce and set
-       extents.x2 and extents.y2 */
-
-    for (j = numRI, rit = ri; --j >= 0; rit++)
-    {
-	reg = &rit->reg;
-	riBox = REGION_END(reg);
-	reg->extents.y2 = riBox->y2;
-	if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
-	Coalesce(reg, rit->prevBand, rit->curBand);
-	if (reg->data->numRects == 1) /* keep unions happy below */
-	{
-	    xfreeData(reg);
-	    reg->data = NULL;
-	}
-    }
-
-    /* Step 3: Union all regions into a single region */
-    while (numRI > 1)
-    {
-	int half = numRI/2;
-	for (j = numRI & 1; j < (half + (numRI & 1)); j++)
-	{
-	    reg = &ri[j].reg;
-	    hreg = &ri[j+half].reg;
-	    if (!RegionOp(reg, reg, hreg, RegionUnionO, TRUE, TRUE, pOverlap))
-		ret = FALSE;
-	    if (hreg->extents.x1 < reg->extents.x1)
-		reg->extents.x1 = hreg->extents.x1;
-	    if (hreg->extents.y1 < reg->extents.y1)
-		reg->extents.y1 = hreg->extents.y1;
-	    if (hreg->extents.x2 > reg->extents.x2)
-		reg->extents.x2 = hreg->extents.x2;
-	    if (hreg->extents.y2 > reg->extents.y2)
-		reg->extents.y2 = hreg->extents.y2;
-	    xfreeData(hreg);
-	}
-	numRI -= half;
-    }
-    *badreg = ri[0].reg;
-    free(ri);
-    good(badreg);
-    return ret;
-bail:
-    for (i = 0; i < numRI; i++)
-	xfreeData(&ri[i].reg);
-    free(ri);
-    return RegionBreak (badreg);
-}
-
-RegionPtr
-RegionFromRects(int nrects, xRectangle *prect, int ctype)
-{
-    
-    RegionPtr		pRgn;
-    RegDataPtr		pData;
-    BoxPtr		pBox;
-    int        		i;
-    int			x1, y1, x2, y2;
-
-    pRgn = RegionCreate(NullBox, 0);
-    if (REGION_NAR (pRgn))
-	return pRgn;
-    if (!nrects)
-	return pRgn;
-    if (nrects == 1)
-    {
-	x1 = prect->x;
-	y1 = prect->y;
-	if ((x2 = x1 + (int) prect->width) > MAXSHORT)
-	    x2 = MAXSHORT;
-	if ((y2 = y1 + (int) prect->height) > MAXSHORT)
-	    y2 = MAXSHORT;
-	if (x1 != x2 && y1 != y2)
-	{
-	    pRgn->extents.x1 = x1;
-	    pRgn->extents.y1 = y1;
-	    pRgn->extents.x2 = x2;
-	    pRgn->extents.y2 = y2;
-	    pRgn->data = NULL;
-	}
-	return pRgn;
-    }
-    pData = xallocData(nrects);
-    if (!pData)
-    {
-	RegionBreak (pRgn);
-	return pRgn;
-    }
-    pBox = (BoxPtr) (pData + 1);
-    for (i = nrects; --i >= 0; prect++)
-    {
-	x1 = prect->x;
-	y1 = prect->y;
-	if ((x2 = x1 + (int) prect->width) > MAXSHORT)
-	    x2 = MAXSHORT;
-	if ((y2 = y1 + (int) prect->height) > MAXSHORT)
-	    y2 = MAXSHORT;
-	if (x1 != x2 && y1 != y2)
-	{
-	    pBox->x1 = x1;
-	    pBox->y1 = y1;
-	    pBox->x2 = x2;
-	    pBox->y2 = y2;
-	    pBox++;
-	}
-    }
-    if (pBox != (BoxPtr) (pData + 1))
-    {
-	pData->size = nrects;
-	pData->numRects = pBox - (BoxPtr) (pData + 1);
-    	pRgn->data = pData;
-    	if (ctype != CT_YXBANDED)
-    	{
-	    Bool overlap; /* result ignored */
-	    pRgn->extents.x1 = pRgn->extents.x2 = 0;
-	    RegionValidate(pRgn, &overlap);
-    	}
-    	else
-	    RegionSetExtents(pRgn);
-    	good(pRgn);
-    }
-    else
-    {
-	free(pData);
-    }
-    return pRgn;
-}
-
-/*======================================================================
- * 	    	  Region Subtraction
- *====================================================================*/
-
-
-/*-
- *-----------------------------------------------------------------------
- * RegionSubtractO --
- *	Overlapping band subtraction. x1 is the left-most point not yet
- *	checked.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	pReg may have rectangles added to it.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionSubtract --
- *	Subtract regS from regM and leave the result in regD.
- *	S stands for subtrahend, M for minuend and D for difference.
- *
- * Results:
- *	TRUE if successful.
- *
- * Side Effects:
- *	regD is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
-{
-    return pixman_region_subtract (regD, regM, regS);
-}
-
-/*======================================================================
- *	    Region Inversion
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * RegionInverse --
- *	Take a region and a box and return a region that is everything
- *	in the box but not in the region. The careful reader will note
- *	that this is the same as subtracting the region from the box...
- *
- * Results:
- *	TRUE.
- *
- * Side Effects:
- *	newReg is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-RegionInverse(
-    RegionPtr	  newReg,       /* Destination region */
-    RegionPtr	  reg1,         /* Region to invert */
-    BoxPtr	  invRect	/* Bounding box for inversion */
-    )
-{
-    return pixman_region_inverse (newReg, reg1, invRect);
-}
-int
-RegionContainsRect(RegionPtr region, BoxPtr prect)
-{
-    return pixman_region_contains_rectangle (region, prect);
-}
-
-/* TranslateRegion(pReg, x, y)
-   translates in place
-*/
-
-void
-RegionTranslate(RegionPtr pReg, int x, int y)
-{
-    pixman_region_translate (pReg, x, y);
-}
-
-void
-RegionReset(RegionPtr pReg, BoxPtr pBox)
-{
-    pixman_region_reset (pReg, pBox);
-}
-
-Bool
-RegionContainsPoint(
-    RegionPtr pReg,
-    int x,
-    int y,
-    BoxPtr box      /* "return" value */
-    )
-{
-    return pixman_region_contains_point (pReg, x, y, box);
-}
-
-Bool
-RegionNotEmpty(RegionPtr pReg)
-{
-    return pixman_region_not_empty (pReg);
-}
-
-Bool
-RegionBroken(RegionPtr pReg)
-{
-    good(pReg);
-    return (REGION_NAR(pReg));
-}
-
-void
-RegionEmpty(RegionPtr pReg)
-{
-    good(pReg);
-    xfreeData(pReg);
-    pReg->extents.x2 = pReg->extents.x1;
-    pReg->extents.y2 = pReg->extents.y1;
-    pReg->data = &RegionEmptyData;
-}
-
-BoxPtr
-RegionExtents(RegionPtr pReg)
-{
-    good(pReg);
-    return(&pReg->extents);
-}
-
-#define ExchangeSpans(a, b)				    \
-{							    \
-    DDXPointRec	tpt;				    	    \
-    int    	tw;					    \
-							    \
-    tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt;    \
-    tw = widths[a]; widths[a] = widths[b]; widths[b] = tw;  \
-}
-
-/* ||| I should apply the merge sort code to rectangle sorting above, and see
-   if mapping time can be improved.  But right now I've been at work 12 hours,
-   so forget it.
-*/
-
-static void QuickSortSpans(
-    DDXPointRec spans[],
-    int	    	widths[],
-    int	    	numSpans)
-{
-    int	    y;
-    int	    i, j, m;
-    DDXPointPtr    r;
-
-    /* Always called with numSpans > 1 */
-    /* Sorts only by y, doesn't bother to sort by x */
-
-    do
-    {
-	if (numSpans < 9)
-	{
-	    /* Do insertion sort */
-	    int yprev;
-
-	    yprev = spans[0].y;
-	    i = 1;
-	    do
-	    { /* while i != numSpans */
-		y = spans[i].y;
-		if (yprev > y)
-		{
-		    /* spans[i] is out of order.  Move into proper location. */
-		    DDXPointRec tpt;
-		    int	    tw, k;
-
-		    for (j = 0; y >= spans[j].y; j++) {}
-		    tpt = spans[i];
-		    tw  = widths[i];
-		    for (k = i; k != j; k--)
-		    {
-			spans[k] = spans[k-1];
-			widths[k] = widths[k-1];
-		    }
-		    spans[j] = tpt;
-		    widths[j] = tw;
-		    y = spans[i].y;
-		} /* if out of order */
-		yprev = y;
-		i++;
-	    } while (i != numSpans);
-	    return;
-	}
-
-	/* Choose partition element, stick in location 0 */
-	m = numSpans / 2;
-	if (spans[m].y > spans[0].y)		ExchangeSpans(m, 0);
-	if (spans[m].y > spans[numSpans-1].y)   ExchangeSpans(m, numSpans-1);
-	if (spans[m].y > spans[0].y)		ExchangeSpans(m, 0);
-	y = spans[0].y;
-
-        /* Partition array */
-        i = 0;
-        j = numSpans;
-        do
-	{
-	    r = &(spans[i]);
-	    do
-	    {
-		r++;
-		i++;
-            } while (i != numSpans && r->y < y);
-	    r = &(spans[j]);
-	    do
-	    {
-		r--;
-		j--;
-            } while (y < r->y);
-            if (i < j)
-		ExchangeSpans(i, j);
-        } while (i < j);
-
-        /* Move partition element back to middle */
-        ExchangeSpans(0, j);
-
-	/* Recurse */
-        if (numSpans-j-1 > 1)
-	    QuickSortSpans(&spans[j+1], &widths[j+1], numSpans-j-1);
-        numSpans = j;
-    } while (numSpans > 1);
-}
-
-#define NextBand()						    \
-{								    \
-    clipy1 = pboxBandStart->y1;					    \
-    clipy2 = pboxBandStart->y2;					    \
-    pboxBandEnd = pboxBandStart + 1;				    \
-    while (pboxBandEnd != pboxLast && pboxBandEnd->y1 == clipy1) {  \
-	pboxBandEnd++;						    \
-    }								    \
-    for (; ppt != pptLast && ppt->y < clipy1; ppt++, pwidth++) {} \
-}
-
-/*
-    Clip a list of scanlines to a region.  The caller has allocated the
-    space.  FSorted is non-zero if the scanline origins are in ascending
-    order.
-    returns the number of new, clipped scanlines.
-*/
-
-int
-RegionClipSpans(
-    RegionPtr	prgnDst,
-    DDXPointPtr ppt,
-    int	    	*pwidth,
-    int		nspans,
-    DDXPointPtr	pptNew,
-    int		*pwidthNew,
-    int		fSorted)
-{
-    DDXPointPtr pptLast;
-    int	*pwidthNewStart;	/* the vengeance of Xerox! */
-    int	y, x1, x2;
-    int	numRects;
-
-    good(prgnDst);
-    pptLast = ppt + nspans;
-    pwidthNewStart = pwidthNew;
-
-    if (!prgnDst->data)
-    {
-	/* Do special fast code with clip boundaries in registers(?) */
-	/* It doesn't pay much to make use of fSorted in this case, 
-	   so we lump everything together. */
-
-	int clipx1, clipx2, clipy1, clipy2;
-
-	clipx1 = prgnDst->extents.x1;
-	clipy1 = prgnDst->extents.y1;
-	clipx2 = prgnDst->extents.x2;
-	clipy2 = prgnDst->extents.y2;
-	    
-	for (; ppt != pptLast; ppt++, pwidth++)
-	{
-	    y = ppt->y;
-	    x1 = ppt->x;
-	    if (clipy1 <= y && y < clipy2)
-	    {
-		x2 = x1 + *pwidth;
-		if (x1 < clipx1)    x1 = clipx1;
-		if (x2 > clipx2)    x2 = clipx2;
-		if (x1 < x2)
-		{
-		    /* part of span in clip rectangle */
-		    pptNew->x = x1;
-		    pptNew->y = y;
-		    *pwidthNew = x2 - x1;
-		    pptNew++;
-		    pwidthNew++;
-		}
-	    }
-	} /* end for */
-
-    }
-    else if ((numRects = prgnDst->data->numRects))
-    {
-	/* Have to clip against many boxes */
-	BoxPtr pboxBandStart, pboxBandEnd;
-	BoxPtr pbox;
-	BoxPtr pboxLast;
-	int clipy1, clipy2;
-
-	/* In this case, taking advantage of sorted spans gains more than
-	   the sorting costs. */
-	if ((! fSorted) && (nspans > 1))
-	    QuickSortSpans(ppt, pwidth, nspans);
-
-	pboxBandStart = REGION_BOXPTR(prgnDst);
-	pboxLast = pboxBandStart + numRects;
-    
-	NextBand();
-
-	for (; ppt != pptLast; )
-	{
-	    y = ppt->y;
-	    if (y < clipy2)
-	    {
-		/* span is in the current band */
-		pbox = pboxBandStart;
-		x1 = ppt->x;
-		x2 = x1 + *pwidth;
-		do
-		{ /* For each box in band */
-		    int newx1, newx2;
-
-		    newx1 = x1;
-		    newx2 = x2;
-		    if (newx1 < pbox->x1)   newx1 = pbox->x1;
-		    if (newx2 > pbox->x2)   newx2 = pbox->x2;
-		    if (newx1 < newx2)
-		    {
-			/* Part of span in clip rectangle */
-			pptNew->x = newx1;
-			pptNew->y = y;
-			*pwidthNew = newx2 - newx1;
-			pptNew++;
-			pwidthNew++;
-		    }
-		    pbox++;
-		} while (pbox != pboxBandEnd);
-		ppt++;
-		pwidth++;
-	    }
-	    else
-	    {
-		/* Move to next band, adjust ppt as needed */
-		pboxBandStart = pboxBandEnd;
-		if (pboxBandStart == pboxLast)
-		    break; /* We're completely done */
-		NextBand();
-	    }
-	}
-    }
-    return (pwidthNew - pwidthNewStart);
-}
commit 9b6f5f549dfe4c20e3cb3c2ef7095ab47abaca3b
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 21 11:14:59 2010 -0700

    Change region implementation names to eliminate the 'mi' prefix
    
    This prepares the file to be moved from mi to dix. This patch
    was done mechanically with the included scripts 'fix-miregion' run over
    the entire X server and 'fix-miregion-private' run over
    include/regionstr.h and mi/miregion.c.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/window.c b/dix/window.c
index ea729db..afb10fd 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -195,7 +195,7 @@ PrintChildren(WindowPtr p1, int indent)
         ErrorF("[dix] ");
 	for (i=0; i<indent; i++) ErrorF(" ");
 	ErrorF("%lx\n", p1->drawable.id);
-	miPrintRegion(&p1->clipList);
+	RegionPrint(&p1->clipList);
 	PrintChildren(p2, indent+4);
 	p1 = p1->nextSib;
     }
@@ -211,7 +211,7 @@ PrintWindowTree(void)
     {
 	ErrorF("[dix] WINDOW %d\n", i);
 	pWin = screenInfo.screens[i]->root;
-	miPrintRegion(&pWin->clipList);
+	RegionPrint(&pWin->clipList);
 	p1 = pWin->firstChild;
 	PrintChildren(p1, 4);
     }
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 4164ff7..cf48ecd 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -407,7 +407,7 @@ exaHWCopyNtoN (DrawablePtr    pSrcDrawable,
 	    rects[i].height = pbox[i].y2 - pbox[i].y1;
 	}
 
-	/* This must match the miRegionCopy() logic for reversing rect order */
+	/* This must match the RegionCopy() logic for reversing rect order */
 	if (nbox == 1 || (dx > 0 && dy > 0) ||
 	    (pDstDrawable != pSrcDrawable &&
 	     (pDstDrawable->type != DRAWABLE_WINDOW ||
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index c73f9f4..cbaab33 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -115,7 +115,7 @@ if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&			\
 {								\
     if ((reg)->data->numRects == (reg)->data->size)		\
     {								\
-	miRectAlloc(reg, 1);					\
+	RegionRectAlloc(reg, 1);					\
 	fr = REGION_BOXPTR(reg);				\
 	r = fr + (reg)->data->numRects;				\
     }								\
@@ -315,7 +315,7 @@ fbPixmapToRegion(PixmapPtr pPix)
 
     fbFinishAccess(&pPix->drawable);
 #ifdef DEBUG
-    if (!miValidRegion(pReg))
+    if (!RegionIsValid(pReg))
 	FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
 #endif
     return(pReg);
diff --git a/fix-miregion b/fix-miregion
new file mode 100755
index 0000000..fc502bb
--- /dev/null
+++ b/fix-miregion
@@ -0,0 +1,29 @@
+#!/bin/sh
+sed -i \
+-e 's/miRegionCreate\b/RegionCreate/g' \
+-e 's/miRegionInit\b/RegionInit/g' \
+-e 's/miRegionDestroy\b/RegionDestroy/g' \
+-e 's/miRegionUninit\b/RegionUninit/g' \
+-e 's/miRegionCopy\b/RegionCopy/g' \
+-e 's/miIntersect\b/RegionIntersect/g' \
+-e 's/miUnion\b/RegionUnion/g' \
+-e 's/miRegionAppend\b/RegionAppend/g' \
+-e 's/miRegionValidate\b/RegionValidate/g' \
+-e 's/miRectsToRegion\b/RegionFromRects/g' \
+-e 's/miSubtract\b/RegionSubtract/g' \
+-e 's/miInverse\b/RegionInverse/g' \
+-e 's/miRectIn\b/RegionContainsRect/g' \
+-e 's/miTranslateRegion\b/RegionTranslate/g' \
+-e 's/miRegionReset\b/RegionReset/g' \
+-e 's/miRegionBreak\b/RegionBreak/g' \
+-e 's/miPointInRegion\b/RegionContainsPoint/g' \
+-e 's/miRegionEqual\b/RegionEqual/g' \
+-e 's/miRegionNotEmpty\b/RegionNotEmpty/g' \
+-e 's/miRegionEmpty\b/RegionEmpty/g' \
+-e 's/miRegionExtents\b/RegionExtents/g' \
+-e 's/miPrintRegion\b/RegionPrint/g' \
+-e 's/miRectAlloc\b/RegionRectAlloc/g' \
+-e 's/miValidRegion\b/RegionIsValid/g' \
+-e 's/miRegionBroken\b/RegionBroken/g' \
+-e 's/miClipSpans\b/RegionClipSpans/g' \
+"$@"
diff --git a/fix-miregion-private b/fix-miregion-private
new file mode 100755
index 0000000..ebc24fa
--- /dev/null
+++ b/fix-miregion-private
@@ -0,0 +1,14 @@
+#!/bin/sh
+sed -i \
+-e 's/miEmptyBox\b/RegionEmptyBox/g' \
+-e 's/miEmptyData\b/RegionEmptyData/g' \
+-e 's/miBrokenData\b/RegionBrokenData/g' \
+-e 's/miBrokenRegion\b/RegionBrokenRegion/g' \
+-e 's/miCoalesce\b/RegionCoalesce/g' \
+-e 's/miAppendNonO\b/RegionAppendNonO/g' \
+-e 's/miRegionOp\b/RegionOp/g' \
+-e 's/miSetExtents\b/RegionSetExtents/g' \
+-e 's/miIntersectO\b/RegionIntersectO/g' \
+-e 's/miUnionO\b/RegionUnionO/g' \
+-e 's/miSubtractO\b/RegionSubtractO/g' \
+"$@"
diff --git a/include/regionstr.h b/include/regionstr.h
index 6a5c98c..89cf024 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -66,13 +66,13 @@ typedef struct pixman_region16 RegionRec, *RegionPtr;
 
 typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
 
-extern _X_EXPORT BoxRec miEmptyBox;
-extern _X_EXPORT RegDataRec miEmptyData;
-extern _X_EXPORT RegDataRec miBrokenData;
+extern _X_EXPORT BoxRec RegionEmptyBox;
+extern _X_EXPORT RegDataRec RegionEmptyData;
+extern _X_EXPORT RegDataRec RegionBrokenData;
 
 #define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
 /* not a region */
-#define REGION_NAR(reg)	((reg)->data == &miBrokenData)
+#define REGION_NAR(reg)	((reg)->data == &RegionBrokenData)
 #define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
 #define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
 #define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
@@ -84,52 +84,52 @@ extern _X_EXPORT RegDataRec miBrokenData;
 #define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
 
 #define REGION_CREATE(_pScreen, _rect, _size) \
-    miRegionCreate(_rect, _size)
+    RegionCreate(_rect, _size)
 
 #define REGION_COPY(_pScreen, dst, src) \
-    miRegionCopy(dst, src)
+    RegionCopy(dst, src)
 
 #define REGION_DESTROY(_pScreen, _pReg) \
-    miRegionDestroy(_pReg)
+    RegionDestroy(_pReg)
 
 #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
-    miIntersect(newReg, reg1, reg2)
+    RegionIntersect(newReg, reg1, reg2)
 
 #define REGION_UNION(_pScreen, newReg, reg1, reg2) \
-    miUnion(newReg, reg1, reg2)
+    RegionUnion(newReg, reg1, reg2)
 
 #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
-    miSubtract(newReg, reg1, reg2)
+    RegionSubtract(newReg, reg1, reg2)
 
 #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
-    miInverse(newReg, reg1, invRect)
+    RegionInverse(newReg, reg1, invRect)
 
 #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
-    miTranslateRegion(_pReg, _x, _y)
+    RegionTranslate(_pReg, _x, _y)
 
 #define RECT_IN_REGION(_pScreen, _pReg, prect) \
-    miRectIn(_pReg, prect)
+    RegionContainsRect(_pReg, prect)
 
 #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
-    miPointInRegion(_pReg, _x, _y, prect)
+    RegionContainsPoint(_pReg, _x, _y, prect)
 
 #define REGION_APPEND(_pScreen, dstrgn, rgn) \
-    miRegionAppend(dstrgn, rgn)
+    RegionAppend(dstrgn, rgn)
 
 #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
-    miRegionValidate(badreg, pOverlap)
+    RegionValidate(badreg, pOverlap)
 
 #define BITMAP_TO_REGION(_pScreen, pPix) \
     (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
 
 #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
-    miRectsToRegion(nrects, prect, ctype)
+    RegionFromRects(nrects, prect, ctype)
 
 #define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
-    miRegionEqual(_pReg1, _pReg2)
+    RegionEqual(_pReg1, _pReg2)
 
 #define REGION_BREAK(_pScreen, _pReg) \
-    miRegionBreak(_pReg)
+    RegionBreak(_pReg)
 
 #define REGION_INIT(_pScreen, _pReg, _rect, _size) \
 { \
@@ -140,7 +140,7 @@ extern _X_EXPORT RegDataRec miBrokenData;
     } \
     else \
     { \
-        (_pReg)->extents = miEmptyBox; \
+        (_pReg)->extents = RegionEmptyBox; \
         if (((_size) > 1) && ((_pReg)->data = \
                              (RegDataPtr)malloc(REGION_SZOF(_size)))) \
         { \
@@ -148,7 +148,7 @@ extern _X_EXPORT RegDataRec miBrokenData;
             (_pReg)->data->numRects = 0; \
         } \
         else \
-            (_pReg)->data = &miEmptyData; \
+            (_pReg)->data = &RegionEmptyData; \
     } \
  }
 
@@ -179,7 +179,7 @@ extern _X_EXPORT RegDataRec miBrokenData;
     REGION_UNINIT(_pScreen, _pReg); \
     (_pReg)->extents.x2 = (_pReg)->extents.x1; \
     (_pReg)->extents.y2 = (_pReg)->extents.y1; \
-    (_pReg)->data = &miEmptyData; \
+    (_pReg)->data = &RegionEmptyData; \
 }
 
 #define REGION_EXTENTS(_pScreen, _pReg) \
@@ -187,8 +187,8 @@ extern _X_EXPORT RegDataRec miBrokenData;
 
 #define REGION_NULL(_pScreen, _pReg) \
 { \
-    (_pReg)->extents = miEmptyBox; \
-    (_pReg)->data = &miEmptyData; \
+    (_pReg)->extents = RegionEmptyBox; \
+    (_pReg)->data = &RegionEmptyData; \
 }
 
 #ifndef REGION_NULL
@@ -200,94 +200,94 @@ extern _X_EXPORT RegDataRec miBrokenData;
 
 extern _X_EXPORT void InitRegions (void);
 
-extern _X_EXPORT RegionPtr miRegionCreate(
+extern _X_EXPORT RegionPtr RegionCreate(
     BoxPtr /*rect*/,
     int /*size*/);
 
-extern _X_EXPORT void miRegionInit(
+extern _X_EXPORT void RegionInit(
     RegionPtr /*pReg*/,
     BoxPtr /*rect*/,
     int /*size*/);
 
-extern _X_EXPORT void miRegionDestroy(
+extern _X_EXPORT void RegionDestroy(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT void miRegionUninit(
+extern _X_EXPORT void RegionUninit(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT Bool miRegionCopy(
+extern _X_EXPORT Bool RegionCopy(
     RegionPtr /*dst*/,
     RegionPtr /*src*/);
 
-extern _X_EXPORT Bool miIntersect(
+extern _X_EXPORT Bool RegionIntersect(
     RegionPtr /*newReg*/,
     RegionPtr /*reg1*/,
     RegionPtr /*reg2*/);
 
-extern _X_EXPORT Bool miUnion(
+extern _X_EXPORT Bool RegionUnion(
     RegionPtr /*newReg*/,
     RegionPtr /*reg1*/,
     RegionPtr /*reg2*/);
 
-extern _X_EXPORT Bool miRegionAppend(
+extern _X_EXPORT Bool RegionAppend(
     RegionPtr /*dstrgn*/,
     RegionPtr /*rgn*/);
 
-extern _X_EXPORT Bool miRegionValidate(
+extern _X_EXPORT Bool RegionValidate(
     RegionPtr /*badreg*/,
     Bool * /*pOverlap*/);
 
-extern _X_EXPORT RegionPtr miRectsToRegion(
+extern _X_EXPORT RegionPtr RegionFromRects(
     int /*nrects*/,
     xRectanglePtr /*prect*/,
     int /*ctype*/);
 
-extern _X_EXPORT Bool miSubtract(
+extern _X_EXPORT Bool RegionSubtract(
     RegionPtr /*regD*/,
     RegionPtr /*regM*/,
     RegionPtr /*regS*/);
 
-extern _X_EXPORT Bool miInverse(
+extern _X_EXPORT Bool RegionInverse(
     RegionPtr /*newReg*/,
     RegionPtr /*reg1*/,
     BoxPtr /*invRect*/);
 
-extern _X_EXPORT int miRectIn(
+extern _X_EXPORT int RegionContainsRect(
     RegionPtr /*region*/,
     BoxPtr /*prect*/);
 
-extern _X_EXPORT void miTranslateRegion(
+extern _X_EXPORT void RegionTranslate(
     RegionPtr /*pReg*/,
     int /*x*/,
     int /*y*/);
 
-extern _X_EXPORT void miRegionReset(
+extern _X_EXPORT void RegionReset(
     RegionPtr /*pReg*/,
     BoxPtr /*pBox*/);
 
-extern _X_EXPORT Bool miRegionBreak(
+extern _X_EXPORT Bool RegionBreak(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT Bool miPointInRegion(
+extern _X_EXPORT Bool RegionContainsPoint(
     RegionPtr /*pReg*/,
     int /*x*/,
     int /*y*/,
     BoxPtr /*box*/);
 
-extern _X_EXPORT Bool miRegionEqual(
+extern _X_EXPORT Bool RegionEqual(
     RegionPtr /*pReg1*/,
     RegionPtr /*pReg2*/);
 
-extern _X_EXPORT Bool miRegionNotEmpty(
+extern _X_EXPORT Bool RegionNotEmpty(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT void miRegionEmpty(
+extern _X_EXPORT void RegionEmpty(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT BoxPtr miRegionExtents(
+extern _X_EXPORT BoxPtr RegionExtents(
     RegionPtr /*pReg*/);
 
-extern _X_EXPORT void miPrintRegion(
+extern _X_EXPORT void RegionPrint(
     RegionPtr /*pReg*/);
 
 #endif /* REGIONSTRUCT_H */
diff --git a/mi/mi.h b/mi/mi.h
index 321523b..9f67d2e 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -422,18 +422,18 @@ extern _X_EXPORT void miPushPixels(
 
 /* see also region.h */
 
-extern _X_EXPORT Bool miRectAlloc(
+extern _X_EXPORT Bool RegionRectAlloc(
     RegionPtr /*pRgn*/,
     int /*n*/
 );
 
 #ifdef DEBUG
-extern _X_EXPORT Bool miValidRegion(
+extern _X_EXPORT Bool RegionIsValid(
     RegionPtr /*prgn*/
 );
 #endif
 
-extern _X_EXPORT Bool miRegionBroken(RegionPtr pReg);
+extern _X_EXPORT Bool RegionBroken(RegionPtr pReg);
 
 /* miscrinit.c */
 
diff --git a/mi/miregion.c b/mi/miregion.c
index 59aaa85..a561601 100644
--- a/mi/miregion.c
+++ b/mi/miregion.c
@@ -101,7 +101,7 @@ Equipment Corporation.
 #define assert(expr)
 #endif
 
-#define good(reg) assert(miValidRegion(reg))
+#define good(reg) assert(RegionIsValid(reg))
 
 /*
  * The functions in this file implement the Region abstraction used extensively
@@ -144,7 +144,7 @@ Equipment Corporation.
  *
  * Adam de Boor wrote most of the original region code.  Joel McCormack
  * substantially modified or rewrote most of the core arithmetic routines,
- * and added miRegionValidate in order to support several speed improvements
+ * and added RegionValidate in order to support several speed improvements
  * to miValidateTree.  Bob Scheifler changed the representation to be more
  * compact when empty or a single rectangle, and did a bunch of gratuitous
  * reformatting.
@@ -176,11 +176,11 @@ Equipment Corporation.
 
 #define RECTALLOC_BAIL(pReg,n,bail) \
 if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
-    if (!miRectAlloc(pReg, n)) { goto bail; }
+    if (!RegionRectAlloc(pReg, n)) { goto bail; }
 
 #define RECTALLOC(pReg,n) \
 if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
-    if (!miRectAlloc(pReg, n)) { return FALSE; }
+    if (!RegionRectAlloc(pReg, n)) { return FALSE; }
 
 #define ADDRECT(pNextRect,nx1,ny1,nx2,ny2)	\
 {						\
@@ -195,7 +195,7 @@ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
 {									\
     if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\
     {									\
-	if (!miRectAlloc(pReg, 1))					\
+	if (!RegionRectAlloc(pReg, 1))					\
 	    return FALSE;						\
 	pNextRect = REGION_TOP(pReg);					\
     }									\
@@ -218,16 +218,16 @@ if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
 }
 
 
-BoxRec miEmptyBox = {0, 0, 0, 0};
-RegDataRec miEmptyData = {0, 0};
+BoxRec RegionEmptyBox = {0, 0, 0, 0};
+RegDataRec RegionEmptyData = {0, 0};
 
-RegDataRec  miBrokenData = {0, 0};
-static RegionRec   miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
+RegDataRec  RegionBrokenData = {0, 0};
+static RegionRec   RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData };
 
 void
 InitRegions (void)
 {
-    pixman_region_set_static_pointers (&miEmptyBox, &miEmptyData, &miBrokenData);
+    pixman_region_set_static_pointers (&RegionEmptyBox, &RegionEmptyData, &RegionBrokenData);
 }
 
 /*****************************************************************
@@ -237,29 +237,29 @@ InitRegions (void)
  *****************************************************************/
 
 RegionPtr
-miRegionCreate(BoxPtr rect, int size)
+RegionCreate(BoxPtr rect, int size)
 {
     RegionPtr pReg;
    
     pReg = (RegionPtr)malloc(sizeof(RegionRec));
     if (!pReg)
-	return &miBrokenRegion;
+	return &RegionBrokenRegion;
 
-    miRegionInit (pReg, rect, size);
+    RegionInit (pReg, rect, size);
     
     return(pReg);
 }
 
 void
-miRegionDestroy(RegionPtr pReg)
+RegionDestroy(RegionPtr pReg)
 {
     pixman_region_fini (pReg);
-    if (pReg != &miBrokenRegion)
+    if (pReg != &RegionBrokenRegion)
 	free(pReg);
 }
 
 void
-miPrintRegion(RegionPtr rgn)
+RegionPrint(RegionPtr rgn)
 {
     int num, size;
     int i;
@@ -278,14 +278,14 @@ miPrintRegion(RegionPtr rgn)
 }
 
 Bool
-miRegionEqual(RegionPtr reg1, RegionPtr reg2)
+RegionEqual(RegionPtr reg1, RegionPtr reg2)
 {
     return pixman_region_equal (reg1, reg2);
 }
 
 #ifdef DEBUG
 Bool
-miValidRegion(RegionPtr reg)
+RegionIsValid(RegionPtr reg)
 {
     int i, numRects;
     
@@ -296,7 +296,7 @@ miValidRegion(RegionPtr reg)
     if (!numRects)
 	return ((reg->extents.x1 == reg->extents.x2) &&
 		(reg->extents.y1 == reg->extents.y2) &&
-		(reg->data->size || (reg->data == &miEmptyData)));
+		(reg->data->size || (reg->data == &RegionEmptyData)));
     else if (numRects == 1)
 	return (!reg->data);
     else
@@ -336,7 +336,7 @@ miValidRegion(RegionPtr reg)
  *****************************************************************/
 
 void
-miRegionInit(RegionPtr pReg, BoxPtr rect, int size)
+RegionInit(RegionPtr pReg, BoxPtr rect, int size)
 {
     if (rect)
 	pixman_region_init_with_extents (pReg, rect);
@@ -345,22 +345,22 @@ miRegionInit(RegionPtr pReg, BoxPtr rect, int size)
 }
 
 void
-miRegionUninit(RegionPtr pReg)
+RegionUninit(RegionPtr pReg)
 {
     pixman_region_fini (pReg);
 }
 
 Bool
-miRegionBreak (RegionPtr pReg)
+RegionBreak (RegionPtr pReg)
 {
     xfreeData (pReg);
-    pReg->extents = miEmptyBox;
-    pReg->data = &miBrokenData;
+    pReg->extents = RegionEmptyBox;
+    pReg->data = &RegionBrokenData;
     return FALSE;
 }
 
 Bool
-miRectAlloc(RegionPtr pRgn, int n)
+RegionRectAlloc(RegionPtr pRgn, int n)
 {
     RegDataPtr	data;
     
@@ -369,7 +369,7 @@ miRectAlloc(RegionPtr pRgn, int n)
 	n++;
 	pRgn->data = xallocData(n);
 	if (!pRgn->data)
-	    return miRegionBreak (pRgn);
+	    return RegionBreak (pRgn);
 	pRgn->data->numRects = 1;
 	*REGION_BOXPTR(pRgn) = pRgn->extents;
     }
@@ -377,7 +377,7 @@ miRectAlloc(RegionPtr pRgn, int n)
     {
 	pRgn->data = xallocData(n);
 	if (!pRgn->data)
-	    return miRegionBreak (pRgn);
+	    return RegionBreak (pRgn);
 	pRgn->data->numRects = 0;
     }
     else
@@ -391,7 +391,7 @@ miRectAlloc(RegionPtr pRgn, int n)
 	n += pRgn->data->numRects;
 	data = (RegDataPtr)realloc(pRgn->data, REGION_SZOF(n));
 	if (!data)
-	    return miRegionBreak (pRgn);
+	    return RegionBreak (pRgn);
 	pRgn->data = data;
     }
     pRgn->data->size = n;
@@ -399,7 +399,7 @@ miRectAlloc(RegionPtr pRgn, int n)
 }
 
 Bool
-miRegionCopy(RegionPtr dst, RegionPtr src)
+RegionCopy(RegionPtr dst, RegionPtr src)
 {
     return pixman_region_copy (dst, src);
 }
@@ -410,10 +410,10 @@ miRegionCopy(RegionPtr dst, RegionPtr src)
 
 /*-
  *-----------------------------------------------------------------------
- * miCoalesce --
+ * RegionCoalesce --
  *	Attempt to merge the boxes in the current band with those in the
  *	previous one.  We are guaranteed that the current band extends to
- *      the end of the rects array.  Used only by miRegionOp.
+ *      the end of the rects array.  Used only by RegionOp.
  *
  * Results:
  *	The new index for the previous band.
@@ -427,7 +427,7 @@ miRegionCopy(RegionPtr dst, RegionPtr src)
  *-----------------------------------------------------------------------
  */
 _X_INLINE static int
-miCoalesce (
+RegionCoalesce (
     RegionPtr	pReg,	    	/* Region to coalesce		     */
     int	    	  	prevStart,  	/* Index of start of previous band   */
     int	    	  	curStart)   	/* Index of start of current band    */
@@ -484,18 +484,18 @@ miCoalesce (
 }
 
 
-/* Quicky macro to avoid trivial reject procedure calls to miCoalesce */
+/* Quicky macro to avoid trivial reject procedure calls to RegionCoalesce */
 
 #define Coalesce(newReg, prevBand, curBand)				\
     if (curBand - prevBand == newReg->data->numRects - curBand) {	\
-	prevBand = miCoalesce(newReg, prevBand, curBand);		\
+	prevBand = RegionCoalesce(newReg, prevBand, curBand);		\
     } else {								\
 	prevBand = curBand;						\
     }
 
 /*-
  *-----------------------------------------------------------------------
- * miAppendNonO --
+ * RegionAppendNonO --
  *	Handle a non-overlapping band for the union and subtract operations.
  *      Just adds the (top/bottom-clipped) rectangles into the region.
  *      Doesn't have to check for subsumption or anything.
@@ -511,7 +511,7 @@ miCoalesce (
  */
 
 _X_INLINE static Bool
-miAppendNonO (
+RegionAppendNonO (
     RegionPtr	pReg,
     BoxPtr	r,
     BoxPtr  	rEnd,
@@ -561,9 +561,9 @@ miAppendNonO (
 
 /*-
  *-----------------------------------------------------------------------
- * miRegionOp --
- *	Apply an operation to two regions. Called by miUnion, miInverse,
- *	miSubtract, miIntersect....  Both regions MUST have at least one
+ * RegionOp --
+ *	Apply an operation to two regions. Called by RegionUnion, RegionInverse,
+ *	RegionSubtract, RegionIntersect....  Both regions MUST have at least one
  *      rectangle, and cannot be the same object.
  *
  * Results:
@@ -599,7 +599,7 @@ typedef Bool (*OverlapProcPtr)(
     Bool	*pOverlap);
 
 static Bool
-miRegionOp(
+RegionOp(
     RegionPtr       newReg,		    /* Place to store result	     */
     RegionPtr       reg1,		    /* First region in operation     */
     RegionPtr       reg2,		    /* 2d region in operation        */
@@ -635,7 +635,7 @@ miRegionOp(
      * Break any region computed from a broken region
      */
     if (REGION_NAR (reg1) || REGION_NAR(reg2))
-	return miRegionBreak (newReg);
+	return RegionBreak (newReg);
     
     /*
      * Initialization:
@@ -659,18 +659,18 @@ miRegionOp(
 	((newReg == reg2) && (numRects > 1)))
     {
 	oldData = newReg->data;
-	newReg->data = &miEmptyData;
+	newReg->data = &RegionEmptyData;
     }
     /* guess at new size */
     if (numRects > newSize)
 	newSize = numRects;
     newSize <<= 1;
     if (!newReg->data)
-	newReg->data = &miEmptyData;
+	newReg->data = &RegionEmptyData;
     else if (newReg->data->size)
 	newReg->data->numRects = 0;
     if (newSize > newReg->data->size)
-	if (!miRectAlloc(newReg, newSize))
+	if (!RegionRectAlloc(newReg, newSize))
 	    return FALSE;
 
     /*
@@ -691,7 +691,7 @@ miRegionOp(
     
     /*
      * prevBand serves to mark the start of the previous band so rectangles
-     * can be coalesced into larger rectangles. qv. miCoalesce, above.
+     * can be coalesced into larger rectangles. qv. RegionCoalesce, above.
      * In the beginning, there is no previous band, so prevBand == curBand
      * (curBand is set later on, of course, but the first band will always
      * start at index 0). prevBand and curBand must be indices because of
@@ -728,7 +728,7 @@ miRegionOp(
 		bot = min(r1->y2, r2y1);
 		if (top != bot)	{
 		    curBand = newReg->data->numRects;
-		    miAppendNonO(newReg, r1, r1BandEnd, top, bot);
+		    RegionAppendNonO(newReg, r1, r1BandEnd, top, bot);
 		    Coalesce(newReg, prevBand, curBand);
 		}
 	    }
@@ -739,7 +739,7 @@ miRegionOp(
 		bot = min(r2->y2, r1y1);
 		if (top != bot) {
 		    curBand = newReg->data->numRects;
-		    miAppendNonO(newReg, r2, r2BandEnd, top, bot);
+		    RegionAppendNonO(newReg, r2, r2BandEnd, top, bot);
 		    Coalesce(newReg, prevBand, curBand);
 		}
 	    }
@@ -781,7 +781,7 @@ miRegionOp(
 	/* Do first nonOverlap1Func call, which may be able to coalesce */
 	FindBand(r1, r1BandEnd, r1End, r1y1);
 	curBand = newReg->data->numRects;
-	miAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
+	RegionAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
 	Coalesce(newReg, prevBand, curBand);
 	/* Just append the rest of the boxes  */
 	AppendRegions(newReg, r1BandEnd, r1End);
@@ -790,7 +790,7 @@ miRegionOp(
 	/* Do first nonOverlap2Func call, which may be able to coalesce */
 	FindBand(r2, r2BandEnd, r2End, r2y1);
 	curBand = newReg->data->numRects;
-	miAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
+	RegionAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
 	Coalesce(newReg, prevBand, curBand);
 	/* Append rest of boxes */
 	AppendRegions(newReg, r2BandEnd, r2End);
@@ -802,7 +802,7 @@ miRegionOp(
     if (!(numRects = newReg->data->numRects))
     {
 	xfreeData(newReg);
-	newReg->data = &miEmptyData;
+	newReg->data = &RegionEmptyData;
     }
     else if (numRects == 1)
     {
@@ -820,10 +820,10 @@ miRegionOp(
 
 /*-
  *-----------------------------------------------------------------------
- * miSetExtents --
+ * RegionSetExtents --
  *	Reset the extents of a region to what they should be. Called by
- *	miSubtract and miIntersect as they can't figure it out along the
- *	way or do so easily, as miUnion can.
+ *	RegionSubtract and RegionIntersect as they can't figure it out along the
+ *	way or do so easily, as RegionUnion can.
  *
  * Results:
  *	None.
@@ -834,7 +834,7 @@ miRegionOp(
  *-----------------------------------------------------------------------
  */
 static void
-miSetExtents (RegionPtr pReg)
+RegionSetExtents (RegionPtr pReg)
 {
     BoxPtr pBox, pBoxEnd;
 
@@ -879,8 +879,8 @@ miSetExtents (RegionPtr pReg)
  *====================================================================*/
 /*-
  *-----------------------------------------------------------------------
- * miIntersectO --
- *	Handle an overlapping band for miIntersect.
+ * RegionIntersectO --
+ *	Handle an overlapping band for RegionIntersect.
  *
  * Results:
  *	TRUE if successful.
@@ -892,7 +892,7 @@ miSetExtents (RegionPtr pReg)
  */
 /*ARGSUSED*/
 Bool
-miIntersect(
+RegionIntersect(
     RegionPtr	newReg,     /* destination Region */
     RegionPtr	reg1,
     RegionPtr	reg2        /* source regions     */
@@ -922,7 +922,7 @@ miIntersect(
 
 /*-
  *-----------------------------------------------------------------------
- * miUnionO --
+ * RegionUnionO --
  *	Handle an overlapping band for the union operation. Picks the
  *	left-most rectangle each time and merges it into the region.
  *
@@ -936,7 +936,7 @@ miIntersect(
  *-----------------------------------------------------------------------
  */
 static Bool
-miUnionO (
+RegionUnionO (
     RegionPtr	pReg,
     BoxPtr	r1,
     BoxPtr  	r1End,
@@ -996,7 +996,7 @@ miUnionO (
 }
 
 Bool
-miUnion(
+RegionUnion(
     RegionPtr	newReg,          /* destination Region */
     RegionPtr	reg1,
     RegionPtr	reg2             /* source regions     */
@@ -1011,13 +1011,13 @@ miUnion(
 
 /*-
  *-----------------------------------------------------------------------
- * miRegionAppend --
+ * RegionAppend --
  * 
  *      "Append" the rgn rectangles onto the end of dstrgn, maintaining
  *      knowledge of YX-banding when it's easy.  Otherwise, dstrgn just
  *      becomes a non-y-x-banded random collection of rectangles, and not
  *      yet a true region.  After a sequence of appends, the caller must
- *      call miRegionValidate to ensure that a valid region is constructed.
+ *      call RegionValidate to ensure that a valid region is constructed.
  *
  * Results:
  *	TRUE if successful.
@@ -1027,16 +1027,16 @@ miUnion(
  *
  */
 Bool
-miRegionAppend(RegionPtr dstrgn, RegionPtr rgn)
+RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
 {
     int numRects, dnumRects, size;
     BoxPtr new, old;
     Bool prepend;
 
     if (REGION_NAR(rgn))
-	return miRegionBreak (dstrgn);
+	return RegionBreak (dstrgn);
     
-    if (!rgn->data && (dstrgn->data == &miEmptyData))
+    if (!rgn->data && (dstrgn->data == &RegionEmptyData))
     {
 	dstrgn->extents = rgn->extents;
 	dstrgn->data = NULL;
@@ -1180,7 +1180,7 @@ QuickSortRects(
 
 /*-
  *-----------------------------------------------------------------------
- * miRegionValidate --
+ * RegionValidate --
  * 
  *      Take a ``region'' which is a non-y-x-banded random collection of
  *      rectangles, and compute a nice region which is the union of all the
@@ -1204,14 +1204,14 @@ QuickSortRects(
  *		or a coalescing into 1 box (ala Menus).
  *
  *	Step 3. Merge the separate regions down to a single region by calling
- *		miUnion.  Maximize the work each miUnion call does by using
+ *		RegionUnion.  Maximize the work each RegionUnion call does by using
  *		a binary merge.
  *
  *-----------------------------------------------------------------------
  */
 
 Bool
-miRegionValidate(RegionPtr badreg, Bool *pOverlap)
+RegionValidate(RegionPtr badreg, Bool *pOverlap)
 {
     /* Descriptor for regions under construction  in Step 2. */
     typedef struct {
@@ -1271,7 +1271,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap)
     /* Note that step 2 code will never overflow the ri[0].reg rects array */
     ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo));
     if (!ri)
-	return miRegionBreak (badreg);
+	return RegionBreak (badreg);
     sizeRI = 4;
     numRI = 1;
     ri[0].prevBand = 0;
@@ -1344,7 +1344,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap)
 	rit->curBand = 0;
 	rit->reg.extents = *box;
 	rit->reg.data = NULL;
-	if (!miRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
+	if (!RegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
 	    goto bail;
 NextRect: ;
     } /* for i */
@@ -1374,7 +1374,7 @@ NextRect: ;
 	{
 	    reg = &ri[j].reg;
 	    hreg = &ri[j+half].reg;
-	    if (!miRegionOp(reg, reg, hreg, miUnionO, TRUE, TRUE, pOverlap))
+	    if (!RegionOp(reg, reg, hreg, RegionUnionO, TRUE, TRUE, pOverlap))
 		ret = FALSE;
 	    if (hreg->extents.x1 < reg->extents.x1)
 		reg->extents.x1 = hreg->extents.x1;
@@ -1396,11 +1396,11 @@ bail:
     for (i = 0; i < numRI; i++)
 	xfreeData(&ri[i].reg);
     free(ri);
-    return miRegionBreak (badreg);
+    return RegionBreak (badreg);
 }
 
 RegionPtr
-miRectsToRegion(int nrects, xRectangle *prect, int ctype)
+RegionFromRects(int nrects, xRectangle *prect, int ctype)
 {
     
     RegionPtr		pRgn;
@@ -1409,7 +1409,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype)
     int        		i;
     int			x1, y1, x2, y2;
 
-    pRgn = miRegionCreate(NullBox, 0);
+    pRgn = RegionCreate(NullBox, 0);
     if (REGION_NAR (pRgn))
 	return pRgn;
     if (!nrects)
@@ -1435,7 +1435,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype)
     pData = xallocData(nrects);
     if (!pData)
     {
-	miRegionBreak (pRgn);
+	RegionBreak (pRgn);
 	return pRgn;
     }
     pBox = (BoxPtr) (pData + 1);
@@ -1465,10 +1465,10 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype)
     	{
 	    Bool overlap; /* result ignored */
 	    pRgn->extents.x1 = pRgn->extents.x2 = 0;
-	    miRegionValidate(pRgn, &overlap);
+	    RegionValidate(pRgn, &overlap);
     	}
     	else
-	    miSetExtents(pRgn);
+	    RegionSetExtents(pRgn);
     	good(pRgn);
     }
     else
@@ -1485,7 +1485,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype)
 
 /*-
  *-----------------------------------------------------------------------
- * miSubtractO --
+ * RegionSubtractO --
  *	Overlapping band subtraction. x1 is the left-most point not yet
  *	checked.
  *
@@ -1501,7 +1501,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype)
 
 /*-
  *-----------------------------------------------------------------------
- * miSubtract --
+ * RegionSubtract --
  *	Subtract regS from regM and leave the result in regD.
  *	S stands for subtrahend, M for minuend and D for difference.
  *
@@ -1514,7 +1514,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype)
  *-----------------------------------------------------------------------
  */
 Bool
-miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
+RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
 {
     return pixman_region_subtract (regD, regM, regS);
 }
@@ -1525,7 +1525,7 @@ miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
 
 /*-
  *-----------------------------------------------------------------------
- * miInverse --
+ * RegionInverse --
  *	Take a region and a box and return a region that is everything
  *	in the box but not in the region. The careful reader will note
  *	that this is the same as subtracting the region from the box...
@@ -1539,7 +1539,7 @@ miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
  *-----------------------------------------------------------------------
  */
 Bool
-miInverse(
+RegionInverse(
     RegionPtr	  newReg,       /* Destination region */
     RegionPtr	  reg1,         /* Region to invert */
     BoxPtr	  invRect	/* Bounding box for inversion */
@@ -1548,7 +1548,7 @@ miInverse(
     return pixman_region_inverse (newReg, reg1, invRect);
 }
 int
-miRectIn(RegionPtr region, BoxPtr prect)
+RegionContainsRect(RegionPtr region, BoxPtr prect)
 {
     return pixman_region_contains_rectangle (region, prect);
 }
@@ -1558,19 +1558,19 @@ miRectIn(RegionPtr region, BoxPtr prect)
 */
 
 void
-miTranslateRegion(RegionPtr pReg, int x, int y)
+RegionTranslate(RegionPtr pReg, int x, int y)
 {
     pixman_region_translate (pReg, x, y);
 }
 
 void
-miRegionReset(RegionPtr pReg, BoxPtr pBox)
+RegionReset(RegionPtr pReg, BoxPtr pBox)
 {
     pixman_region_reset (pReg, pBox);
 }
 
 Bool
-miPointInRegion(
+RegionContainsPoint(
     RegionPtr pReg,
     int x,
     int y,
@@ -1581,30 +1581,30 @@ miPointInRegion(
 }
 
 Bool
-miRegionNotEmpty(RegionPtr pReg)
+RegionNotEmpty(RegionPtr pReg)
 {
     return pixman_region_not_empty (pReg);
 }
 
 Bool
-miRegionBroken(RegionPtr pReg)
+RegionBroken(RegionPtr pReg)
 {
     good(pReg);
     return (REGION_NAR(pReg));
 }
 
 void
-miRegionEmpty(RegionPtr pReg)
+RegionEmpty(RegionPtr pReg)
 {
     good(pReg);
     xfreeData(pReg);
     pReg->extents.x2 = pReg->extents.x1;
     pReg->extents.y2 = pReg->extents.y1;
-    pReg->data = &miEmptyData;
+    pReg->data = &RegionEmptyData;
 }
 
 BoxPtr
-miRegionExtents(RegionPtr pReg)
+RegionExtents(RegionPtr pReg)
 {
     good(pReg);
     return(&pReg->extents);
@@ -1729,7 +1729,7 @@ static void QuickSortSpans(
 */
 
 int
-miClipSpans(
+RegionClipSpans(
     RegionPtr	prgnDst,
     DDXPointPtr ppt,
     int	    	*pwidth,
diff --git a/mi/mispans.h b/mi/mispans.h
index 8151415..ef090bb 100644
--- a/mi/mispans.h
+++ b/mi/mispans.h
@@ -85,7 +85,7 @@ extern _X_EXPORT void miFreeSpanGroup(
     SpanGroup * /*spanGroup*/
 );
 
-extern _X_EXPORT int miClipSpans(
+extern _X_EXPORT int RegionClipSpans(
     RegionPtr /*prgnDst*/,
     DDXPointPtr /*ppt*/,
     int * /*pwidth*/,
diff --git a/mi/misprite.c b/mi/misprite.c
index 2962abf..b2cf5f0 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -268,7 +268,7 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
 
             if (pCursorInfo->isUp &&
                 pCursorInfo->pScreen == pScreen &&
-                miRectIn(pRegion, &pCursorInfo->saved) != rgnOUT)
+                RegionContainsRect(pRegion, &pCursorInfo->saved) != rgnOUT)
             {
                 SPRITE_DEBUG(("Damage remove\n"));
                 miSpriteRemoveCursor (pDev, pScreen);
@@ -523,7 +523,7 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
              * Damage will take care of destination check
              */
             if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen &&
-                    miRectIn(prgnSrc, &pCursorInfo->saved) != rgnOUT)
+                    RegionContainsRect(prgnSrc, &pCursorInfo->saved) != rgnOUT)
             {
                 SPRITE_DEBUG (("CopyWindow remove\n"));
                 miSpriteRemoveCursor (pDev, pScreen);


More information about the xorg-commit mailing list