xserver: Branch 'master'

Adam Jackson ajax at kemper.freedesktop.org
Sat Aug 25 12:16:09 PDT 2007


 Xext/mbufbf.c                     |   16 
 afb/Makefile.am                   |    2 
 afb/afb.h                         |   16 
 afb/afbbstore.c                   |  154 -
 afb/afbscrinit.c                  |    9 
 cfb/Makefile.am.inc               |    2 
 cfb/cfb.h                         |   16 
 cfb/cfbbstore.c                   |  143 -
 cfb/cfbscrinit.c                  |    9 
 composite/compinit.c              |   31 
 composite/compint.h               |    5 
 dix/window.c                      |    7 
 exa/exa.c                         |    2 
 exa/exa_priv.h                    |   14 
 exa/exa_unaccel.c                 |   28 
 fb/Makefile.am                    |    1 
 fb/fb.h                           |   17 
 fb/fbbstore.c                     |   63 
 fb/fbscreen.c                     |    6 
 hw/darwin/darwin.c                |   30 
 hw/kdrive/src/kasync.c            |   27 
 hw/kdrive/src/kdrive.c            |   30 
 hw/kdrive/src/kdrive.h            |   14 
 hw/xfree86/common/xf86Helper.c    |   30 
 hw/xfree86/rac/xf86RAC.c          |   48 
 hw/xfree86/shadowfb/shadow.c      |   38 
 hw/xfree86/xaa/xaaInit.c          |  149 -
 hw/xfree86/xaa/xaaOverlayDF.c     |   45 
 hw/xfree86/xaa/xaaStateChange.c   |   24 
 hw/xfree86/xaa/xaalocal.h         |    1 
 hw/xfree86/xf1bpp/Makefile.am     |    1 
 hw/xfree86/xf4bpp/Makefile.am     |    1 
 hw/xfree86/xf4bpp/ppcBStore.c     |  155 -
 hw/xfree86/xf4bpp/ppcIO.c         |   15 
 hw/xfree86/xf4bpp/xf4bpp.h        |   16 
 hw/xfree86/xf8_32bpp/Makefile.am  |    1 
 hw/xfree86/xf8_32bpp/cfb8_32.h    |   18 
 hw/xfree86/xf8_32bpp/cfbbstore.c  |  105 -
 hw/xfree86/xf8_32bpp/cfbscrinit.c |   10 
 hw/xgl/Makefile.am                |    1 
 hw/xgl/xgl.h                      |   19 
 hw/xgl/xglbstore.c                |  125 -
 hw/xgl/xgloutput.c                |   36 
 hw/xgl/xglscreen.c                |    3 
 hw/xnest/Screen.c                 |    9 
 hw/xprint/pcl/PclWindow.c         |   16 
 hw/xprint/ps/PsWindow.c           |   14 
 hw/xwin/winscrinit.c              |    7 
 include/bstorestr.h               |    2 
 mfb/Makefile.am                   |    2 
 mfb/mfb.h                         |   16 
 mfb/mfbbstore.c                   |  154 -
 mfb/mfbscrinit.c                  |   11 
 mi/mibank.c                       |  118 -
 mi/mibstore.c                     | 3901 --------------------------------------
 mi/mibstore.h                     |    3 
 mi/midispcur.c                    |    2 
 mi/miexpose.c                     |   51 
 mi/mioverlay.c                    |   71 
 mi/misprite.c                     |   47 
 mi/mispritest.h                   |    3 
 mi/mivaltree.c                    |   17 
 mi/miwindow.c                     |   76 
 miext/damage/damage.c             |   22 
 miext/damage/damagestr.h          |    1 
 miext/rootless/rootlessScreen.c   |    1 
 miext/rootless/rootlessValTree.c  |   12 
 67 files changed, 80 insertions(+), 5959 deletions(-)

New commits:
diff-tree ae7f71a8b3d6756161e55d998d6eec37d2695c98 (from bf0883ae5081bd75569115a3eb27c6d3d336c9f2)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sat Aug 25 15:08:20 2007 -0400

    Implement core protocol backing store exclusively in terms of Composite.
    
    Composite's automatic redirection is a more general mechanism than the
    ad-hoc BS machinery, so it's much prettier to implement the one in terms
    of the other.  Composite now wraps ChangeWindowAttributes and activates
    automatic redirection for windows with backing store requested.  The old
    backing store infrastructure is completely gutted: ABI-visible structures
    retain the function pointers, but they never get called, and all the
    open-coded conditionals throughout the DIX layer to implement BS are gone.
    
    Note that this is still not a strictly complete implementation of backing
    store, since Composite will throw the bits away on unmap and therefore
    WhenMapped and Always hints are equivalent.

diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c
index 04fc487..e29c974 100644
--- a/Xext/mbufbf.c
+++ b/Xext/mbufbf.c
@@ -329,10 +329,6 @@ bufCreateBuffer(pScreen, pWin, bufferNum
     pBuffer->firstChild = NULL;
     pBuffer->lastChild  = NULL;
 
-    /* XXX - Worry about backingstore later */
-    pBuffer->backStorage   = NULL;
-    pBuffer->backingStore  = NotUseful;
-
     /* XXX - Need to call pScreen->CreateWindow for tile/stipples
      *       or should I just copy the devPrivates?
      */
@@ -505,18 +501,6 @@ bufClearImageBufferArea(pMBBuffer, x,y, 
 
     pScreen = pBuffer->drawable.pScreen;
     REGION_INIT(pScreen, &reg, &box, 1);
-    if (pBuffer->backStorage)
-    {
-	/*
-	 * If the window has backing-store on, call through the
-	 * ClearToBackground vector to handle the special semantics
-	 * (i.e. things backing store is to be cleared out and
-	 * an Expose event is to be generated for those areas in backing
-	 * store if generateExposures is TRUE).
-	 */
-	pBSReg = (* pScreen->ClearBackingStore)(pBuffer, x, y, w, h,
-						 generateExposures);
-    }
 
     REGION_INTERSECT(pScreen, &reg, &reg, &pBuffer->clipList);
     if (pBuffer->backgroundState != None)
diff --git a/afb/Makefile.am b/afb/Makefile.am
index d83b674..d6b8901 100644
--- a/afb/Makefile.am
+++ b/afb/Makefile.am
@@ -10,7 +10,7 @@ libafb_la_SOURCES = afbgc.c afbwindow.c 
 	 afbimage.c afbline.c afbbres.c afbhrzvert.c afbbresd.c afbpushpxl.c afbply1rct.c \
 	 afbzerarc.c afbfillarc.c afbfillsp.c afbsetsp.c afbscrinit.c afbplygblt.c \
 	 afbclip.c afbgetsp.c afbpolypnt.c afbbitblt.c afbcmap.c afbimggblt.c afbpntarea.c \
-	 afbmisc.c afbbstore.c afbtegblt.c $(libafb_gen_sources)
+	 afbmisc.c afbtegblt.c $(libafb_gen_sources)
 
 INCLUDES = -I$(top_srcdir)/mfb -I$(top_srcdir)/hw/xfree86/os-support
 
diff --git a/afb/afb.h b/afb/afb.h
index 5aa2b0c..9125951 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -182,23 +182,7 @@ extern void afbBresD(
 	unsigned char * /*rrops*/,
 	unsigned char * /*bgrrops*/
 );
-/* afbbstore.c */
 
-extern void afbSaveAreas(
-	PixmapPtr /*pPixmap*/,
-	RegionPtr /*prgnSave*/,
-	int /*xorg*/,
-	int /*yorg*/,
-	WindowPtr /*pWin*/
-);
-
-extern void afbRestoreAreas(
-	PixmapPtr /*pPixmap*/,
-	RegionPtr /*prgnRestore*/,
-	int /*xorg*/,
-	int /*yorg*/,
-	WindowPtr /*pWin*/
-);
 /* afbclip.c */
 
 extern RegionPtr afbPixmapToRegion(
diff --git a/afb/afbbstore.c b/afb/afbbstore.c
deleted file mode 100644
index 32d64ec..0000000
--- a/afb/afbbstore.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
-/*
-
-Copyright (c) 1987  X Consortium
-
-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, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-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 X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include	"afb.h"
-#include	<X11/X.h>
-#include	"mibstore.h"
-#include	"regionstr.h"
-#include	"scrnintstr.h"
-#include	"pixmapstr.h"
-#include	"windowstr.h"
-
-/*-
- *-----------------------------------------------------------------------
- * afbSaveAreas --
- *		Function called by miSaveAreas to actually fetch the areas to be
- *		saved into the backing pixmap. This is very simple to do, since
- *		afbDoBitblt is designed for this very thing. The region to save is
- *		already destination-relative and we're given the offset to the
- *		window origin, so we have only to create an array of points of the
- *		u.l. corners of the boxes in the region translated to the screen
- *		coordinate system and fetch the screen pixmap out of its devPrivate
- *		field....
- *
- * Results:
- *		None.
- *
- * Side Effects:
- *		Data are copied from the screen into the pixmap.
- *
- *-----------------------------------------------------------------------
- */
-void
-afbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
-	PixmapPtr		  		pPixmap;  		/* Backing pixmap */
-	RegionPtr		  		prgnSave; 		/* Region to save (pixmap-relative) */
-	int					  		xorg;					/* X origin of region */
-	int					  		yorg;					/* Y origin of region */
-	WindowPtr				pWin;
-{
-	register DDXPointPtr pPt;
-	DDXPointPtr				pPtsInit;
-	register BoxPtr		pBox;
-	register int		numRects;
-
-	numRects = REGION_NUM_RECTS(prgnSave);
-	pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
-	if (!pPtsInit)
-		return;
-
-	pBox = REGION_RECTS(prgnSave);
-	pPt = pPtsInit;
-	while (numRects--) {
-		pPt->x = pBox->x1 + xorg;
- 		pPt->y = pBox->y1 + yorg;
- 		pPt++;
- 		pBox++;
-	}
-
-	afbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr,
-				(DrawablePtr)pPixmap,
-				GXcopy,
-				prgnSave,
-				pPtsInit, wBackingBitPlanes (pWin));
-
-	DEALLOCATE_LOCAL(pPtsInit);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * afbRestoreAreas --
- *		Function called by miRestoreAreas to actually fetch the areas to be
- *		restored from the backing pixmap. This is very simple to do, since
- *		afbDoBitblt is designed for this very thing. The region to restore is
- *		already destination-relative and we're given the offset to the
- *		window origin, so we have only to create an array of points of the
- *		u.l. corners of the boxes in the region translated to the pixmap
- *		coordinate system and fetch the screen pixmap out of its devPrivate
- *		field....
- *
- * Results:
- *		None.
- *
- * Side Effects:
- *		Data are copied from the pixmap into the screen.
- *
- *-----------------------------------------------------------------------
- */
-void
-afbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
-	PixmapPtr		  		pPixmap;  		/* Backing pixmap */
-	RegionPtr		  		prgnRestore; 		/* Region to restore (screen-relative)*/
-	int					  		xorg;					/* X origin of window */
-	int					  		yorg;					/* Y origin of window */
-	WindowPtr				pWin;
-{
-	register DDXPointPtr pPt;
-	DDXPointPtr				pPtsInit;
-	register BoxPtr		pBox;
-	register int		numRects;
-
-	numRects = REGION_NUM_RECTS(prgnRestore);
-	pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
-	if (!pPtsInit)
-		return;
-
-	pBox = REGION_RECTS(prgnRestore);
-	pPt = pPtsInit;
-	while (numRects--) {
-		pPt->x = pBox->x1 - xorg;
- 		pPt->y = pBox->y1 - yorg;
- 		pPt++;
- 		pBox++;
-	}
-
-	afbDoBitblt((DrawablePtr)pPixmap,
-				(DrawablePtr)pPixmap->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr,
-				GXcopy,
-				prgnRestore,
-				pPtsInit, wBackingBitPlanes (pWin));
-
-	DEALLOCATE_LOCAL(pPtsInit);
-}
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
index 7cb7423..71e8d4c 100644
--- a/afb/afbscrinit.c
+++ b/afb/afbscrinit.c
@@ -77,14 +77,6 @@ int afbScreenPrivateIndex;
 
 static unsigned long afbGeneration = 0;
 
-static BSFuncRec afbBSFuncRec = {
-	afbSaveAreas,
-	afbRestoreAreas,
-	(BackingStoreSetClipmaskRgnProcPtr) 0,
-	(BackingStoreGetImagePixmapProcPtr) 0,
-	(BackingStoreGetSpansPixmapProcPtr) 0,
-};
-
 static Bool
 afbCloseScreen(int index, ScreenPtr pScreen)
 {
@@ -231,7 +223,6 @@ afbScreenInit(register ScreenPtr pScreen
 
 	pScreen->CloseScreen = afbCloseScreen;
 	pScreen->CreateScreenResources = afbCreateScreenResources;
-	pScreen->BackingStoreFuncs = afbBSFuncRec;
 
 	pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
 	pScreen->devPrivate = oldDevPrivate;
diff --git a/cfb/Makefile.am.inc b/cfb/Makefile.am.inc
index 65e011a..5aa913a 100644
--- a/cfb/Makefile.am.inc
+++ b/cfb/Makefile.am.inc
@@ -15,7 +15,7 @@ libcfb_common_sources =  $(top_srcdir)/c
 	$(top_srcdir)/cfb/cfballpriv.c $(top_srcdir)/cfb/cfbgetsp.c \
 	$(top_srcdir)/cfb/cfbfillrct.c $(top_srcdir)/cfb/cfbigblt8.c \
 	$(top_srcdir)/cfb/cfbglblt8.c $(top_srcdir)/cfb/cfbtegblt.c \
-	$(top_srcdir)/cfb/cfbbstore.c $(top_srcdir)/cfb/cfbpolypnt.c \
+	$(top_srcdir)/cfb/cfbpolypnt.c \
 	$(top_srcdir)/cfb/cfbbres.c $(top_srcdir)/cfb/cfbline.c \
 	$(top_srcdir)/cfb/cfbhrzvert.c $(top_srcdir)/cfb/cfbbresd.c \
 	$(top_srcdir)/cfb/cfbimage.c $(top_srcdir)/cfb/cfbcppl.c \
diff --git a/cfb/cfb.h b/cfb/cfb.h
index 8c682ae..5614f4f 100644
--- a/cfb/cfb.h
+++ b/cfb/cfb.h
@@ -486,23 +486,7 @@ extern void cfbBresD(
     int /*e2*/,
     int /*len*/
 );
-/* cfbbstore.c */
 
-extern void cfbSaveAreas(
-    PixmapPtr /*pPixmap*/,
-    RegionPtr /*prgnSave*/,
-    int /*xorg*/,
-    int /*yorg*/,
-    WindowPtr /*pWin*/
-);
-
-extern void cfbRestoreAreas(
-    PixmapPtr /*pPixmap*/,
-    RegionPtr /*prgnRestore*/,
-    int /*xorg*/,
-    int /*yorg*/,
-    WindowPtr /*pWin*/
-);
 /* cfbcmap.c */
 
 #ifndef CFB_PROTOTYPES_ONLY
diff --git a/cfb/cfbbstore.c b/cfb/cfbbstore.c
deleted file mode 100644
index f09360c..0000000
--- a/cfb/cfbbstore.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*-
- * cfbbstore.c --
- *	Functions required by the backing-store implementation in MI.
- *
- * Copyright (c) 1987 by the Regents of the University of California
- *
- * 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.  The University of California
- * makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without
- * express or implied warranty.
- *
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include    "cfb.h"
-#include    <X11/X.h>
-#include    "mibstore.h"
-#include    "regionstr.h"
-#include    "scrnintstr.h"
-#include    "pixmapstr.h"
-#include    "windowstr.h"
-
-/*-
- *-----------------------------------------------------------------------
- * cfbSaveAreas --
- *	Function called by miSaveAreas to actually fetch the areas to be
- *	saved into the backing pixmap. This is very simple to do, since
- *	cfbDoBitblt is designed for this very thing. The region to save is
- *	already destination-relative and we're given the offset to the
- *	window origin, so we have only to create an array of points of the
- *	u.l. corners of the boxes in the region translated to the screen
- *	coordinate system and fetch the screen pixmap out of its devPrivate
- *	field....
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Data are copied from the screen into the pixmap.
- *
- *-----------------------------------------------------------------------
- */
-void
-cfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
-    PixmapPtr	  	pPixmap;  	/* Backing pixmap */
-    RegionPtr	  	prgnSave; 	/* Region to save (pixmap-relative) */
-    int	    	  	xorg;	    	/* X origin of region */
-    int	    	  	yorg;	    	/* Y origin of region */
-    WindowPtr		pWin;
-{
-    register DDXPointPtr pPt;
-    DDXPointPtr		pPtsInit;
-    register BoxPtr	pBox;
-    register int	i;
-    ScreenPtr		pScreen = pPixmap->drawable.pScreen;
-    PixmapPtr		pScrPix;
-    
-    i = REGION_NUM_RECTS(prgnSave);
-    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
-    if (!pPtsInit)
-	return;
-    
-    pBox = REGION_RECTS(prgnSave);
-    pPt = pPtsInit;
-    while (--i >= 0) {
-	pPt->x = pBox->x1 + xorg;
-	pPt->y = pBox->y1 + yorg;
-	pPt++;
-	pBox++;
-    }
-
-    pScrPix = (*pScreen->GetWindowPixmap)(pWin);
-
-
-    cfbDoBitbltCopy((DrawablePtr) pScrPix, (DrawablePtr)pPixmap,
-		    GXcopy, prgnSave, pPtsInit, ~0L);
-
-    DEALLOCATE_LOCAL (pPtsInit);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * cfbRestoreAreas --
- *	Function called by miRestoreAreas to actually fetch the areas to be
- *	restored from the backing pixmap. This is very simple to do, since
- *	cfbDoBitblt is designed for this very thing. The region to restore is
- *	already destination-relative and we're given the offset to the
- *	window origin, so we have only to create an array of points of the
- *	u.l. corners of the boxes in the region translated to the pixmap
- *	coordinate system and fetch the screen pixmap out of its devPrivate
- *	field....
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Data are copied from the pixmap into the screen.
- *
- *-----------------------------------------------------------------------
- */
-void
-cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
-    PixmapPtr	  	pPixmap;  	/* Backing pixmap */
-    RegionPtr	  	prgnRestore; 	/* Region to restore (screen-relative)*/
-    int	    	  	xorg;	    	/* X origin of window */
-    int	    	  	yorg;	    	/* Y origin of window */
-    WindowPtr		pWin;
-{
-    register DDXPointPtr pPt;
-    DDXPointPtr		pPtsInit;
-    register BoxPtr	pBox;
-    register int	i;
-    ScreenPtr		pScreen = pPixmap->drawable.pScreen;
-    PixmapPtr		pScrPix;
-    
-    i = REGION_NUM_RECTS(prgnRestore);
-    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
-    if (!pPtsInit)
-	return;
-    
-    pBox = REGION_RECTS(prgnRestore);
-    pPt = pPtsInit;
-    while (--i >= 0) {
-	pPt->x = pBox->x1 - xorg;
-	pPt->y = pBox->y1 - yorg;
-	pPt++;
-	pBox++;
-    }
-
-    pScrPix = (*pScreen->GetWindowPixmap)(pWin);
-
-    cfbDoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
-		    GXcopy, prgnRestore, pPtsInit, ~0L);
-
-    DEALLOCATE_LOCAL (pPtsInit);
-}
diff --git a/cfb/cfbscrinit.c b/cfb/cfbscrinit.c
index 9f411ab..83f5cf0 100644
--- a/cfb/cfbscrinit.c
+++ b/cfb/cfbscrinit.c
@@ -46,14 +46,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "cfbmskbits.h"
 #include "mibstore.h"
 
-BSFuncRec cfbBSFuncRec = {
-    cfbSaveAreas,
-    cfbRestoreAreas,
-    (BackingStoreSetClipmaskRgnProcPtr) 0,
-    (BackingStoreGetImagePixmapProcPtr) 0,
-    (BackingStoreGetSpansPixmapProcPtr) 0,
-};
-
 Bool
 cfbCloseScreen (index, pScreen)
     int		index;
@@ -184,7 +176,6 @@ cfbFinishScreenInit(pScreen, pbits, xsiz
     pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
     pScreen->devPrivate = oldDevPrivate;
 #endif
-    pScreen->BackingStoreFuncs = cfbBSFuncRec;
     pScreen->GetScreenPixmap = cfbGetScreenPixmap;
     pScreen->SetScreenPixmap = cfbSetScreenPixmap;
     return TRUE;
diff --git a/composite/compinit.c b/composite/compinit.c
index 630f104..c557eeb 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -63,6 +63,7 @@ compCloseScreen (int index, ScreenPtr pS
     pScreen->CloseScreen = cs->CloseScreen;
     pScreen->BlockHandler = cs->BlockHandler;
     pScreen->InstallColormap = cs->InstallColormap;
+    pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
     pScreen->ReparentWindow = cs->ReparentWindow;
     pScreen->MoveWindow = cs->MoveWindow;
     pScreen->ResizeWindow = cs->ResizeWindow;
@@ -109,6 +110,33 @@ compInstallColormap (ColormapPtr pColorm
     pScreen->InstallColormap = compInstallColormap;
 }
 
+/* Fake backing store via automatic redirection */
+static Bool
+compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    CompScreenPtr cs = GetCompScreen (pScreen);
+    Bool ret;
+
+    pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
+    ret = pScreen->ChangeWindowAttributes(pWin, mask);
+
+    if (ret && (mask & CWBackingStore)) {
+	if (pWin->backingStore != NotUseful) {
+	    compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);
+	    pWin->backStorage = TRUE;
+	} else {
+	    compUnredirectWindow(serverClient, pWin,
+				 CompositeRedirectAutomatic);
+	    pWin->backStorage = FALSE;
+	}
+    }
+
+    pScreen->ChangeWindowAttributes = compChangeWindowAttributes;
+
+    return ret;
+}
+
 static void
 compScreenUpdate (ScreenPtr pScreen)
 {
@@ -424,6 +452,9 @@ compScreenInit (ScreenPtr pScreen)
     cs->InstallColormap = pScreen->InstallColormap;
     pScreen->InstallColormap = compInstallColormap;
 
+    cs->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+    pScreen->ChangeWindowAttributes = compChangeWindowAttributes;
+
     cs->BlockHandler = pScreen->BlockHandler;
     pScreen->BlockHandler = compBlockHandler;
 
diff --git a/composite/compint.h b/composite/compint.h
index 2c4d5c0..38b1777 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -143,6 +143,11 @@ typedef struct _CompScreen {
      */
     InstallColormapProcPtr	InstallColormap;
 
+    /*
+     * Fake backing store via automatic redirection
+     */
+    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
     ScreenBlockHandlerProcPtr	BlockHandler;
     CloseScreenProcPtr		CloseScreen;
     Bool			damaged;
diff --git a/dix/window.c b/dix/window.c
index be4ea2c..ca4335c 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -175,7 +175,6 @@ static Bool TileScreenSaver(int i, int k
 
 #define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
 
-
 _X_EXPORT int numSaveUndersViewable = 0;
 _X_EXPORT int deltaSaveUndersViewable = 0;
 
@@ -3031,9 +3030,6 @@ UnrealizeTree(
 		    deltaSaveUndersViewable--;
 #endif
 		pChild->viewable = FALSE;
-		if (pChild->backStorage)
-		    (*pChild->drawable.pScreen->SaveDoomedAreas)(
-					    pChild, &pChild->clipList, 0, 0);
 		(* MarkUnrealizedWindow)(pChild, pWin, fromConfigure);
 		pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	    }
@@ -3161,9 +3157,6 @@ UnmapSubwindows(WindowPtr pWin)
 #ifdef DO_SAVE_UNDERS
 		pChild->DIXsaveUnder = FALSE;
 #endif /* DO_SAVE_UNDERS */
-		if (pChild->backStorage)
-		    (*pScreen->SaveDoomedAreas)(
-					    pChild, &pChild->clipList, 0, 0);
 	    }
 	}
     }
diff --git a/exa/exa.c b/exa/exa.c
index d827fc6..99707fa 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -666,8 +666,6 @@ exaDriverInit (ScreenPtr		pScreen,
     pExaScr->SavedPaintWindowBorder = pScreen->PaintWindowBorder;
     pScreen->PaintWindowBorder = exaPaintWindow;
 
-    pScreen->BackingStoreFuncs.SaveAreas = ExaCheckSaveAreas;
-    pScreen->BackingStoreFuncs.RestoreAreas = ExaCheckRestoreAreas;
 #ifdef RENDER
     if (ps) {
         pExaScr->SavedComposite = ps->Composite;
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 9bed5c8..a456da0 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -269,20 +269,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
 		 char *pdstStart);
 
 void
-ExaCheckSaveAreas (PixmapPtr	pPixmap,
-		  RegionPtr	prgnSave,
-		  int		xorg,
-		  int		yorg,
-		  WindowPtr	pWin);
-
-void
-ExaCheckRestoreAreas (PixmapPtr	pPixmap,
-		     RegionPtr	prgnSave,
-		     int	xorg,
-		     int    	yorg,
-		     WindowPtr	pWin);
-
-void
 ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
 
 CARD32
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index a94648b..d793ec2 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -283,34 +283,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
     exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
 }
 
-void
-ExaCheckSaveAreas (PixmapPtr	pPixmap,
-		  RegionPtr	prgnSave,
-		  int		xorg,
-		  int		yorg,
-		  WindowPtr	pWin)
-{
-    EXA_FALLBACK(("from %p (%c)\n", &pPixmap->drawable,
-		  exaDrawableLocation(&pPixmap->drawable)));
-    exaPrepareAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
-    fbSaveAreas (pPixmap, prgnSave, xorg, yorg, pWin);
-    exaFinishAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
-}
-
-void
-ExaCheckRestoreAreas (PixmapPtr	pPixmap,
-		     RegionPtr	prgnSave,
-		     int	xorg,
-		     int    	yorg,
-		     WindowPtr	pWin)
-{
-    EXA_FALLBACK(("to %p (%c)\n", &pPixmap->drawable,
-		  exaDrawableLocation(&pPixmap->drawable)));
-    exaPrepareAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
-    fbRestoreAreas (pPixmap, prgnSave, xorg, yorg, pWin);
-    exaFinishAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
-}
-
 /* XXX: Note the lack of a prepare on the tile, if the window has a tiled
  * background.  This function happens to only be called if pExaScr->swappedOut,
  * so we actually end up not having to do it since the tile won't be in fb.
diff --git a/fb/Makefile.am b/fb/Makefile.am
index 75861a3..e34aaba 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -24,7 +24,6 @@ libfb_la_SOURCES = 	\
 	fbbits.h	\
 	fbblt.c		\
 	fbbltone.c	\
-	fbbstore.c	\
 	fbcopy.c	\
 	fbfill.c	\
 	fbfillrect.c	\
diff --git a/fb/fb.h b/fb/fb.h
index df430b8..a924f49 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1262,23 +1262,6 @@ fbBltPlane (FbBits	    *src,
 	    Pixel	    planeMask);
 
 /*
- * fbbstore.c
- */
-void
-fbSaveAreas(PixmapPtr	pPixmap,
-	    RegionPtr	prgnSave,
-	    int		xorg,
-	    int		yorg,
-	    WindowPtr	pWin);
-
-void
-fbRestoreAreas(PixmapPtr    pPixmap,
-	       RegionPtr    prgnRestore,
-	       int	    xorg,
-	       int	    yorg,
-	       WindowPtr    pWin);
-
-/*
  * fbcmap.c
  */
 int
diff --git a/fb/fbbstore.c b/fb/fbbstore.c
deleted file mode 100644
index 3ee5f5e..0000000
--- a/fb/fbbstore.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * 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, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-void
-fbSaveAreas(PixmapPtr	pPixmap,
-	    RegionPtr	prgnSave,
-	    int		xorg,
-	    int		yorg,
-	    WindowPtr	pWin)
-{
-    fbCopyWindowProc (&pWin->drawable,
-		      &pPixmap->drawable,
-		      0,
-		      REGION_RECTS(prgnSave),
-		      REGION_NUM_RECTS(prgnSave),
-		      xorg, yorg,
-		      FALSE,
-		      FALSE,
-		      0,0);
-}
-
-void
-fbRestoreAreas(PixmapPtr    pPixmap,
-	       RegionPtr    prgnRestore,
-	       int	    xorg,
-	       int	    yorg,
-	       WindowPtr    pWin)
-{
-    fbCopyWindowProc (&pPixmap->drawable,
-		      &pWin->drawable,
-		      0,
-		      REGION_RECTS(prgnRestore),
-		      REGION_NUM_RECTS(prgnRestore),
-		      -xorg, -yorg,
-		      FALSE,
-		      FALSE,
-		      0,0);
-}
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 94033f1..661268c 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -142,12 +142,6 @@ fbSetupScreen(ScreenPtr	pScreen, 
     pScreen->GetWindowPixmap = _fbGetWindowPixmap;
     pScreen->SetWindowPixmap = _fbSetWindowPixmap;
 
-    pScreen->BackingStoreFuncs.SaveAreas = fbSaveAreas;
-    pScreen->BackingStoreFuncs.RestoreAreas = fbRestoreAreas;
-    pScreen->BackingStoreFuncs.SetClipmaskRgn = 0;
-    pScreen->BackingStoreFuncs.GetImagePixmap = 0;
-    pScreen->BackingStoreFuncs.GetSpansPixmap = 0;
-    
     return TRUE;
 }
 
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 7da8626..7b48368 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -992,7 +992,7 @@ xf86SetRootClip (ScreenPtr pScreen, BOOL
     WindowPtr	pChild;
     Bool	WasViewable = (Bool)(pWin->viewable);
     Bool	anyMarked = TRUE;
-    RegionPtr	pOldClip = NULL, bsExposed;
+    RegionPtr	pOldClip = NULL;
 #ifdef DO_SAVE_UNDERS
     Bool	dosave = FALSE;
 #endif
@@ -1048,12 +1048,6 @@ xf86SetRootClip (ScreenPtr pScreen, BOOL
 
     if (WasViewable)
     {
-	if (pWin->backStorage)
-	{
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
-	}
-
 	if (pWin->firstChild)
 	{
 	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
@@ -1077,28 +1071,6 @@ xf86SetRootClip (ScreenPtr pScreen, BOOL
 	    (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
     }
 
-    if (pWin->backStorage &&
-	((pWin->backingStore == Always) || WasViewable))
-    {
-	if (!WasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-	bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, 0, 0, pOldClip,
-			      pWin->drawable.x, pWin->drawable.y);
-	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
-    }
     if (WasViewable)
     {
 	if (anyMarked)
diff --git a/hw/kdrive/src/kasync.c b/hw/kdrive/src/kasync.c
index cc75111..5190963 100644
--- a/hw/kdrive/src/kasync.c
+++ b/hw/kdrive/src/kasync.c
@@ -224,30 +224,6 @@ KdCheckGetSpans (DrawablePtr pDrawable,
 }
 
 void
-KdCheckSaveAreas (PixmapPtr	pPixmap,
-		  RegionPtr	prgnSave,
-		  int		xorg,
-		  int		yorg,
-		  WindowPtr	pWin)
-{
-    kaaWaitSync(pWin->drawable.pScreen);
-    kaaDrawableDirty (&pPixmap->drawable);
-    fbSaveAreas (pPixmap, prgnSave, xorg, yorg, pWin);
-}
-
-void
-KdCheckRestoreAreas (PixmapPtr	pPixmap,
-		     RegionPtr	prgnSave,
-		     int	xorg,
-		     int    	yorg,
-		     WindowPtr	pWin)
-{
-    kaaWaitSync(pWin->drawable.pScreen);
-    kaaDrawableDirty ((DrawablePtr)pWin);
-    fbRestoreAreas (pPixmap, prgnSave, xorg, yorg, pWin);
-}
-
-void
 KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
 {
     kaaWaitSync (pWin->drawable.pScreen);
@@ -292,9 +268,6 @@ KdScreenInitAsync (ScreenPtr pScreen)
     pScreen->PaintWindowBackground = KdCheckPaintWindow;
     pScreen->PaintWindowBorder = KdCheckPaintWindow;
     pScreen->CopyWindow = KdCheckCopyWindow;
-    
-    pScreen->BackingStoreFuncs.SaveAreas = KdCheckSaveAreas;
-    pScreen->BackingStoreFuncs.RestoreAreas = KdCheckRestoreAreas;
 #ifdef RENDER
     KdPictureInitAsync (pScreen);
 #endif
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 2bb7b53..8c4342e 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -101,7 +101,7 @@ KdSetRootClip (ScreenPtr pScreen, BOOL e
     WindowPtr	pChild;
     Bool	WasViewable;
     Bool	anyMarked = FALSE;
-    RegionPtr	pOldClip = 0, bsExposed;
+    RegionPtr	pOldClip = 0;
 #ifdef DO_SAVE_UNDERS
     Bool	dosave = FALSE;
 #endif
@@ -159,12 +159,6 @@ KdSetRootClip (ScreenPtr pScreen, BOOL e
     
     if (WasViewable)
     {
-	if (pWin->backStorage)
-	{
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
-	}
-
 	if (pWin->firstChild)
 	{
 	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
@@ -188,28 +182,6 @@ KdSetRootClip (ScreenPtr pScreen, BOOL e
 	    (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
     }
 
-    if (pWin->backStorage &&
-	((pWin->backingStore == Always) || WasViewable))
-    {
-	if (!WasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-	bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, 0, 0, pOldClip,
-			      pWin->drawable.x, pWin->drawable.y);
-	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-    
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
-    }
     if (WasViewable)
     {
 	if (anyMarked)
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 81f3e01..2da008d 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -612,20 +612,6 @@ KdCheckGetSpans (DrawablePtr pDrawable,
 		 char *pdstStart);
 
 void
-KdCheckSaveAreas (PixmapPtr	pPixmap,
-		  RegionPtr	prgnSave,
-		  int		xorg,
-		  int		yorg,
-		  WindowPtr	pWin);
-
-void
-KdCheckRestoreAreas (PixmapPtr	pPixmap,
-		     RegionPtr	prgnSave,
-		     int	xorg,
-		     int    	yorg,
-		     WindowPtr	pWin);
-
-void
 KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
 
 void
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 63970dc..b6fc6b6 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1114,7 +1114,7 @@ xf86SetRootClip (ScreenPtr pScreen, Bool
     WindowPtr	pChild;
     Bool	WasViewable = (Bool)(pWin->viewable);
     Bool	anyMarked = FALSE;
-    RegionPtr	pOldClip = NULL, bsExposed;
+    RegionPtr	pOldClip = NULL;
 #ifdef DO_SAVE_UNDERS
     Bool	dosave = FALSE;
 #endif
@@ -1175,12 +1175,6 @@ xf86SetRootClip (ScreenPtr pScreen, Bool
 
     if (WasViewable)
     {
-	if (pWin->backStorage)
-	{
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
-	}
-
 	if (pWin->firstChild)
 	{
 	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
@@ -1204,28 +1198,6 @@ xf86SetRootClip (ScreenPtr pScreen, Bool
 	    (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
     }
 
-    if (pWin->backStorage &&
-	((pWin->backingStore == Always) || WasViewable))
-    {
-	if (!WasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-	bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, 0, 0, pOldClip,
-			      pWin->drawable.x, pWin->drawable.y);
-	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
-    }
     if (WasViewable)
     {
 	if (anyMarked)
diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c
index aba8622..8492cdb 100644
--- a/hw/xfree86/rac/xf86RAC.c
+++ b/hw/xfree86/rac/xf86RAC.c
@@ -102,7 +102,6 @@ typedef struct _RACScreen {
     PaintWindowBorderProcPtr 	PaintWindowBorder;
     CopyWindowProcPtr 		CopyWindow;
     ClearToBackgroundProcPtr 	ClearToBackground;
-    BSFuncRec 			BackingStoreFuncs;
     CreatePixmapProcPtr         CreatePixmap;
     SaveScreenProcPtr           SaveScreen;
     /* Colormap */
@@ -146,10 +145,6 @@ static void RACCopyWindow(WindowPtr pWin
 			  RegionPtr prgnSrc );
 static void RACClearToBackground (WindowPtr pWin, int x, int y,
 				  int w, int h, Bool generateExposures );
-static void RACSaveAreas (PixmapPtr pPixmap, RegionPtr prgnSave,
-			  int xorg, int yorg, WindowPtr pWin);
-static void RACRestoreAreas (PixmapPtr pPixmap, RegionPtr prgnRestore,
-			     int xorg, int yorg, WindowPtr pWin);
 static PixmapPtr RACCreatePixmap(ScreenPtr pScreen, int w, int h, int depth);
 static Bool  RACCreateGC(GCPtr pGC);
 static Bool RACSaveScreen(ScreenPtr pScreen, Bool unblank);
@@ -306,8 +301,6 @@ xf86RACInit(ScreenPtr pScreen, unsigned 
     WRAP_SCREEN_COND(CopyWindow, RACCopyWindow, RAC_FB);
     WRAP_SCREEN_COND(ClearToBackground, RACClearToBackground, RAC_FB);
     WRAP_SCREEN_COND(CreatePixmap, RACCreatePixmap, RAC_FB);
-    WRAP_SCREEN_COND(BackingStoreFuncs.RestoreAreas, RACRestoreAreas, RAC_FB);
-    WRAP_SCREEN_COND(BackingStoreFuncs.SaveAreas, RACSaveAreas, RAC_FB);
     WRAP_SCREEN_COND(StoreColors, RACStoreColors, RAC_COLORMAP);
     WRAP_SCREEN_COND(DisplayCursor, RACDisplayCursor, RAC_CURSOR);
     WRAP_SCREEN_COND(RealizeCursor, RACRealizeCursor, RAC_CURSOR);
@@ -352,8 +345,6 @@ RACCloseScreen (int i, ScreenPtr pScreen
     UNWRAP_SCREEN(PaintWindowBorder);
     UNWRAP_SCREEN(CopyWindow);
     UNWRAP_SCREEN(ClearToBackground);
-    UNWRAP_SCREEN(BackingStoreFuncs.RestoreAreas);
-    UNWRAP_SCREEN(BackingStoreFuncs.SaveAreas);
     UNWRAP_SCREEN(SaveScreen);
     UNWRAP_SCREEN(StoreColors);
     UNWRAP_SCREEN(DisplayCursor);
@@ -498,45 +489,6 @@ RACClearToBackground (
     SCREEN_EPILOG (ClearToBackground, RACClearToBackground);
 }
 
-static void
-RACSaveAreas (
-    PixmapPtr pPixmap,
-    RegionPtr prgnSave,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin
-    )
-{
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-    DPRINT_S("RACSaveAreas",pScreen->myNum);
-    SCREEN_PROLOG (BackingStoreFuncs.SaveAreas);
-    ENABLE;
-    (*pScreen->BackingStoreFuncs.SaveAreas) (
-	pPixmap, prgnSave, xorg, yorg, pWin);
-
-    SCREEN_EPILOG (BackingStoreFuncs.SaveAreas, RACSaveAreas);
-}
-
-static void
-RACRestoreAreas (    
-    PixmapPtr pPixmap,
-    RegionPtr prgnRestore,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin 
-    )
-{
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-
-    DPRINT_S("RACRestoreAreas",pScreen->myNum);
-    SCREEN_PROLOG (BackingStoreFuncs.RestoreAreas);
-    ENABLE;
-    (*pScreen->BackingStoreFuncs.RestoreAreas) (
-	pPixmap, prgnRestore, xorg, yorg, pWin);
-
-    SCREEN_EPILOG ( BackingStoreFuncs.RestoreAreas, RACRestoreAreas);
-}
-
 static PixmapPtr 
 RACCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
 {
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index 2fc02a7..c1b6ed1 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -35,13 +35,6 @@
 #define MAX(a,b) (((a)>(b))?(a):(b))
 
 static Bool ShadowCloseScreen (int i, ScreenPtr pScreen);
-static void ShadowRestoreAreas (    
-    PixmapPtr pPixmap,
-    RegionPtr prgn,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin 
-);
 static void ShadowPaintWindow (
     WindowPtr pWin,
     RegionPtr prgn,
@@ -93,7 +86,6 @@ typedef struct {
   PaintWindowBorderProcPtr		PaintWindowBorder;
   CopyWindowProcPtr			CopyWindow;
   CreateGCProcPtr			CreateGC;
-  BackingStoreRestoreAreasProcPtr	RestoreAreas;  
   ModifyPixmapHeaderProcPtr		ModifyPixmapHeader;
 #ifdef RENDER
   CompositeProcPtr Composite;
@@ -212,7 +204,6 @@ ShadowFBInit2 (
     pPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
     pPriv->CopyWindow = pScreen->CopyWindow;
     pPriv->CreateGC = pScreen->CreateGC;
-    pPriv->RestoreAreas = pScreen->BackingStoreFuncs.RestoreAreas;
     pPriv->ModifyPixmapHeader = pScreen->ModifyPixmapHeader;
 
     pPriv->EnterVT = pScrn->EnterVT;
@@ -223,7 +214,6 @@ ShadowFBInit2 (
     pScreen->PaintWindowBorder = ShadowPaintWindow;
     pScreen->CopyWindow = ShadowCopyWindow;
     pScreen->CreateGC = ShadowCreateGC;
-    pScreen->BackingStoreFuncs.RestoreAreas = ShadowRestoreAreas;
     pScreen->ModifyPixmapHeader = ShadowModifyPixmapHeader;
 
     pScrn->EnterVT = ShadowEnterVT;
@@ -290,7 +280,6 @@ ShadowCloseScreen (int i, ScreenPtr pScr
     pScreen->PaintWindowBorder = pPriv->PaintWindowBorder;
     pScreen->CopyWindow = pPriv->CopyWindow;
     pScreen->CreateGC = pPriv->CreateGC;
-    pScreen->BackingStoreFuncs.RestoreAreas = pPriv->RestoreAreas;
     pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader;
 
     pScrn->EnterVT = pPriv->EnterVT;
@@ -307,33 +296,6 @@ ShadowCloseScreen (int i, ScreenPtr pScr
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
-
-static void
-ShadowRestoreAreas (    
-    PixmapPtr pPixmap,
-    RegionPtr prgn,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin 
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
-    int num = 0;
-
-    if(pPriv->vtSema && (num = REGION_NUM_RECTS(prgn)))
-        if(pPriv->preRefresh)
-            (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(prgn));
-
-    pScreen->BackingStoreFuncs.RestoreAreas = pPriv->RestoreAreas;
-    (*pScreen->BackingStoreFuncs.RestoreAreas) (
-                pPixmap, prgn, xorg, yorg, pWin);
-    pScreen->BackingStoreFuncs.RestoreAreas = ShadowRestoreAreas;
-
-    if(num && pPriv->postRefresh)
-	(*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(prgn));
-}
-
-
 static void
 ShadowPaintWindow(
   WindowPtr pWin,
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 529dbd1..93f6995 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -32,10 +32,6 @@ static void XAAGetSpans(DrawablePtr pDra
 			int *pwidth, int nspans, char *pdstStart);
 static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth);
 static Bool XAADestroyPixmap(PixmapPtr pPixmap);
-static void XAARestoreAreas (PixmapPtr pPixmap, RegionPtr prgnRestore, 
-			int xorg, int yorg, WindowPtr pWin);
-static void XAASaveAreas (PixmapPtr pPixmap, RegionPtr prgnSave, 
-			int xorg, int yorg, WindowPtr pWin);
 static Bool XAAEnterVT (int index, int flags);
 static void XAALeaveVT (int index, int flags);
 static int  XAASetDGAMode(int index, int num, DGADevicePtr devRet);
@@ -157,10 +153,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr
 	infoRec->PaintWindowBorder = XAAPaintWindow;
     if(!infoRec->CopyWindow)
 	infoRec->CopyWindow = XAACopyWindow;
-    if(!infoRec->SaveAreas)
-	infoRec->SaveAreas = XAASaveAreas;
-    if(!infoRec->RestoreAreas)
-	infoRec->RestoreAreas = XAARestoreAreas;
 
     pScreenPriv->CreateGC = pScreen->CreateGC;
     pScreen->CreateGC = XAACreateGC;
@@ -180,12 +172,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr
     pScreen->CreatePixmap = XAACreatePixmap;
     pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
     pScreen->DestroyPixmap = XAADestroyPixmap;
-    pScreenPriv->BackingStoreFuncs.RestoreAreas = 
-			pScreen->BackingStoreFuncs.RestoreAreas;
-    pScreen->BackingStoreFuncs.RestoreAreas = infoRec->RestoreAreas;
-    pScreenPriv->BackingStoreFuncs.SaveAreas = 
-			pScreen->BackingStoreFuncs.SaveAreas;
-    pScreen->BackingStoreFuncs.SaveAreas = infoRec->SaveAreas;
     pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
     pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes;
 
@@ -256,10 +242,6 @@ XAACloseScreen (int i, ScreenPtr pScreen
     pScreen->WindowExposures = pScreenPriv->WindowExposures;
     pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
     pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
-    pScreen->BackingStoreFuncs.RestoreAreas = 
-			pScreenPriv->BackingStoreFuncs.RestoreAreas;
-    pScreen->BackingStoreFuncs.SaveAreas = 
-			pScreenPriv->BackingStoreFuncs.SaveAreas;
     pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
 
     /* We leave it up to the client to free the XAAInfoRec */
@@ -326,137 +308,6 @@ XAAGetSpans (
 }
 
 
-static void
-XAASaveAreas (
-    PixmapPtr pPixmap,
-    RegionPtr prgnSave,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin
-){
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-
-    if(IS_OFFSCREEN_PIXMAP(pPixmap)) {
-	BoxPtr pbox = REGION_RECTS(prgnSave);
-	int nboxes = REGION_NUM_RECTS(prgnSave);
-
-	(*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, ~0, -1);
-	while(nboxes--) {
-	    (*infoRec->SubsequentScreenToScreenCopy)(pScrn, 
-		pbox->x1 + xorg, pbox->y1 + yorg, 
-		pPixmap->drawable.x + pbox->x1, 
-		pPixmap->drawable.y + pbox->y1,
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
-	    pbox++;
-	}
-	SET_SYNC_FLAG(infoRec);
-	return;
-    }
-
-    if(xf86Screens[pScreen->myNum]->vtSema && infoRec->ReadPixmap &&
-	(pWin->drawable.bitsPerPixel == pPixmap->drawable.bitsPerPixel)) {
-	BoxPtr pbox = REGION_RECTS(prgnSave);
-	int nboxes = REGION_NUM_RECTS(prgnSave);
-	int Bpp =  pPixmap->drawable.bitsPerPixel >> 3;
-	unsigned char *dstp = (unsigned char*)pPixmap->devPrivate.ptr;
-
-	while(nboxes--) {
-	    (*infoRec->ReadPixmap)(infoRec->pScrn,
-		pbox->x1 + xorg, pbox->y1 + yorg, 
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, 
-		dstp + (pPixmap->devKind * pbox->y1) + (pbox->x1 * Bpp),
-		pPixmap->devKind,
-		pPixmap->drawable.bitsPerPixel, pPixmap->drawable.depth);
-	    pbox++;
-	}
-	return;
-    }
-
-    XAA_SCREEN_PROLOGUE (pScreen, BackingStoreFuncs.SaveAreas);
-    if(pScrn->vtSema) {
-	SYNC_CHECK(&pWin->drawable);
-    }
-    (*pScreen->BackingStoreFuncs.SaveAreas) (
-		pPixmap, prgnSave, xorg, yorg, pWin);
-
-    XAA_SCREEN_EPILOGUE (pScreen, BackingStoreFuncs.SaveAreas,
-			 XAASaveAreas);
-}
-
-static void
-XAARestoreAreas (    
-    PixmapPtr pPixmap,
-    RegionPtr prgnRestore,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin 
-){
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-
-    if(IS_OFFSCREEN_PIXMAP(pPixmap)) {
-	BoxPtr pbox = REGION_RECTS(prgnRestore);
-	int nboxes = REGION_NUM_RECTS(prgnRestore);
-	int pm = ~0;
-
-	if((pScrn->overlayFlags & OVERLAY_8_32_PLANAR) && 
-					(pWin->drawable.depth == 24))
-	   pm = 0x00ffffff;
-
-	(*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, pm, -1);
-	while(nboxes--) {
-	    (*infoRec->SubsequentScreenToScreenCopy)(pScrn, 
-		pPixmap->drawable.x + pbox->x1 - xorg, 
-		pPixmap->drawable.y + pbox->y1 - yorg,
-		pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
-	    pbox++;
-	}
-	SET_SYNC_FLAG(infoRec);
-	return;
-    }
-
-    if(pScrn->vtSema && infoRec->WritePixmap &&
-	!(infoRec->WritePixmapFlags & NO_GXCOPY) &&
-	((pWin->drawable.bitsPerPixel == pPixmap->drawable.bitsPerPixel) ||
-		((pWin->drawable.bitsPerPixel == 24) &&  
-		 (pPixmap->drawable.bitsPerPixel == 32) &&
-		 (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP)))) {
-	BoxPtr pbox = REGION_RECTS(prgnRestore);
-	int nboxes = REGION_NUM_RECTS(prgnRestore);
-	int Bpp =  pPixmap->drawable.bitsPerPixel >> 3;
-	unsigned char *srcp = (unsigned char*)pPixmap->devPrivate.ptr;
-	int pm = ~0;
-
-	if((pScrn->overlayFlags & OVERLAY_8_32_PLANAR) && 
-					(pWin->drawable.depth == 24))
-	   pm = 0x00ffffff;
- 
-	while(nboxes--) {
-	    (*infoRec->WritePixmap)(pScrn, pbox->x1, pbox->y1, 
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, 
-		srcp + (pPixmap->devKind * (pbox->y1 - yorg)) + 
-				((pbox->x1 - xorg) * Bpp), 
-		pPixmap->devKind, GXcopy, pm, -1, 
-		pPixmap->drawable.bitsPerPixel, pPixmap->drawable.depth);
-	    pbox++;
-	}
-	return;
-    }
-
-    XAA_SCREEN_PROLOGUE (pScreen, BackingStoreFuncs.RestoreAreas);
-    if(pScrn->vtSema) {
-	SYNC_CHECK(&pWin->drawable);
-    }
-    (*pScreen->BackingStoreFuncs.RestoreAreas) (
-		pPixmap, prgnRestore, xorg, yorg, pWin);
-
-    XAA_SCREEN_EPILOGUE (pScreen, BackingStoreFuncs.RestoreAreas,
-				 XAARestoreAreas);
-}
-
 static int
 XAAPixmapBPP (ScreenPtr pScreen, int depth)
 {
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index cfdac38..5897e32 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -30,9 +30,6 @@
 static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
 static void XAAOverPaintWindow(WindowPtr, RegionPtr, int);
 static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr);
-static void XAAOverSaveAreas(PixmapPtr, RegionPtr, int, int, WindowPtr);
-static void XAAOverRestoreAreas(PixmapPtr, RegionPtr, int, int, WindowPtr);
-
 
 static int XAAOverStippledFillChooser(GCPtr);
 static int XAAOverOpaqueStippledFillChooser(GCPtr);
@@ -200,8 +197,6 @@ XAAInitDualFramebufferOverlay(
     pScreen->PaintWindowBackground = XAAOverPaintWindow;
     pScreen->PaintWindowBorder = XAAOverPaintWindow;
     pScreen->WindowExposures = XAAOverWindowExposures;
-    pScreen->BackingStoreFuncs.SaveAreas = XAAOverSaveAreas;
-    pScreen->BackingStoreFuncs.RestoreAreas = XAAOverRestoreAreas;
 
     pOverPriv->StippledFillChooser = infoRec->StippledFillChooser;
     pOverPriv->OpaqueStippledFillChooser = infoRec->OpaqueStippledFillChooser;
@@ -495,46 +490,6 @@ XAAOverWindowExposures(
     XAA_SCREEN_EPILOGUE(pScreen, WindowExposures, XAAOverWindowExposures);
 }
 
-
-static void
-XAAOverSaveAreas (
-    PixmapPtr pPixmap,
-    RegionPtr prgnSave,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin
-){
-    XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pWin->drawable.pScreen);
-    XAAInfoRecPtr infoRec = 
-		GET_XAAINFORECPTR_FROM_DRAWABLE((DrawablePtr)pWin);
-
-    if(pOverPriv->pScrn->vtSema) {
-	SWITCH_DEPTH(pWin->drawable.depth);
-    }
-    
-    (*infoRec->SaveAreas)(pPixmap, prgnSave, xorg, yorg, pWin);
-}
-
-
-static void
-XAAOverRestoreAreas (    
-    PixmapPtr pPixmap,
-    RegionPtr prgnRestore,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin 
-){
-    XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pWin->drawable.pScreen);
-    XAAInfoRecPtr infoRec = 
-		GET_XAAINFORECPTR_FROM_DRAWABLE((DrawablePtr)pWin);
-
-    if(pOverPriv->pScrn->vtSema) {
-	SWITCH_DEPTH(pWin->drawable.depth);
-    }
-    
-    (*infoRec->RestoreAreas)(pPixmap, prgnRestore, xorg, yorg, pWin);
-}
-
 /*********************  Choosers *************************/
 
 static int 
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index a614fe2..711f779 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -262,8 +262,6 @@ typedef struct _XAAStateWrapRec {
    PaintWindowBackgroundProcPtr PaintWindowBackground;
    PaintWindowBorderProcPtr PaintWindowBorder;
    CopyWindowProcPtr CopyWindow;
-   BackingStoreSaveAreasProcPtr SaveAreas;
-   BackingStoreRestoreAreasProcPtr RestoreAreas;
 #ifdef RENDER
    Bool (*SetupForCPUToScreenAlphaTexture2)(ScrnInfoPtr pScrn, int op,
                                            CARD16 red, CARD16 green,
@@ -1481,26 +1479,6 @@ static void XAAStateWrapCopyWindow(Windo
 			     prgnSrc);
 }
 
-static void XAAStateWrapSaveAreas(PixmapPtr pBackingPixmap, RegionPtr pObscured, int x, 
-				  int y, WindowPtr pWin)
-{
-   GET_STATEPRIV_SCREEN(pBackingPixmap->drawable.pScreen);
-   STATE_CHECK_SP(pStatePriv);
-
-   (*pStatePriv->SaveAreas)(pBackingPixmap, pObscured, x, 
-			    y, pWin);
-}
-
-static void XAAStateWrapRestoreAreas(PixmapPtr pBackingPixmap, RegionPtr pExposed,
-				     int x, int y, WindowPtr pWin)
-{
-   GET_STATEPRIV_SCREEN(pBackingPixmap->drawable.pScreen);
-   STATE_CHECK_SP(pStatePriv);
-
-   (*pStatePriv->RestoreAreas)(pBackingPixmap, pExposed,
-			       x, y, pWin);
-}
-
 #ifdef RENDER
 static Bool XAAStateWrapSetupForCPUToScreenAlphaTexture2(ScrnInfoPtr pScrn,
                                                          int op, CARD16 red,
@@ -1674,8 +1652,6 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAI
    XAA_STATE_WRAP(PaintWindowBackground);
    XAA_STATE_WRAP(PaintWindowBorder);
    XAA_STATE_WRAP(CopyWindow);
-   XAA_STATE_WRAP(SaveAreas);
-   XAA_STATE_WRAP(RestoreAreas);
 #ifdef RENDER
    XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2);
    XAA_STATE_WRAP(SetupForCPUToScreenTexture2);
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index c365a7d..3ddea24 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -49,7 +49,6 @@ typedef struct _XAAScreen {
    PaintWindowBorderProcPtr 	PaintWindowBorder;
    CopyWindowProcPtr 		CopyWindow;
    WindowExposuresProcPtr	WindowExposures;
-   BSFuncRec 			BackingStoreFuncs;
    CreatePixmapProcPtr 		CreatePixmap;
    DestroyPixmapProcPtr 	DestroyPixmap;
    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
diff --git a/hw/xfree86/xf1bpp/Makefile.am b/hw/xfree86/xf1bpp/Makefile.am
index ef3d08f..4ea7ef0 100644
--- a/hw/xfree86/xf1bpp/Makefile.am
+++ b/hw/xfree86/xf1bpp/Makefile.am
@@ -32,7 +32,6 @@ libxf1bppmfb_a_SOURCES = \
         mfbbitblt.c \
         mfbbres.c \
         mfbbresd.c \
-        mfbbstore.c \
         mfbclip.c \
         mfbcmap.c \
         mfbfillarc.c \
diff --git a/hw/xfree86/xf4bpp/Makefile.am b/hw/xfree86/xf4bpp/Makefile.am
index 5eab92f..8665b2a 100644
--- a/hw/xfree86/xf4bpp/Makefile.am
+++ b/hw/xfree86/xf4bpp/Makefile.am
@@ -6,7 +6,6 @@ libxf4bpp_la_LDFLAGS = -avoid-version
 
 libxf4bpp_la_SOURCES = \
         ppcArea.c \
-        ppcBStore.c \
         ppcClip.c \
         ppcCpArea.c \
         ppcCReduce.c \
diff --git a/hw/xfree86/xf4bpp/ppcBStore.c b/hw/xfree86/xf4bpp/ppcBStore.c
deleted file mode 100644
index 00c9446..0000000
--- a/hw/xfree86/xf4bpp/ppcBStore.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-
-Copyright (c) 1987  X Consortium
-
-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, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-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 X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-Copyright IBM Corporation 1987,1988,1989
-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 IBM not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-IBM 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.
-
-
-Copyright 1987 by the Regents of the University of California
-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.
-
-*/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf4bpp.h"
-#include "vgaVideo.h"
-#include "ibmTrace.h"
-
-/*-----------------------------------------------------------------------
- * xf4bppSaveAreas --
- *	Function called by miSaveAreas to actually fetch the areas to be
- *	saved into the backing pixmap.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Data are copied from the screen into the pixmap.
- *
- *-----------------------------------------------------------------------
- */
-void
-xf4bppSaveAreas( pPixmap, prgnSave, xorg, yorg, pWin )
-    register PixmapPtr pPixmap ; /* Backing pixmap */
-    RegionPtr prgnSave ;	/* Region to save (pixmap-relative) */
-    int xorg ;			/* X origin of region */
-    int yorg ;			/* Y origin of region */
-    WindowPtr pWin;
-{
-    register BoxPtr pBox ;
-    register int nBox ;
-
-    TRACE( ( "xf4bppSaveAreas(0x%x,0x%x,%d,%d)\n",
-	   pPixmap, prgnSave, xorg, yorg ) ) ;
-/* WHOOP WHOOP WHOOP XXX -- depth 8 *only* */ /* GJA -- ? */
-
-    if ( !( nBox = REGION_NUM_RECTS(prgnSave) ) )
-	return ;
-
-    for ( pBox = REGION_RECTS(prgnSave) ; nBox-- ; pBox++ )
-	xf4bppReadColorImage( pWin, pBox->x1 + xorg,
-		 pBox->y1 + yorg,
-		 pBox->x2 - pBox->x1,
-		 pBox->y2 - pBox->y1,
-		 ( (unsigned char *) pPixmap->devPrivate.ptr )
-		 + ( pBox->y1 * pPixmap->devKind ) + pBox->x1,
-		 pPixmap->devKind ) ;
-
-    return ;
-}
-
-/*-----------------------------------------------------------------------
- * xf4bppRestoreAreas --
- *	Function called by miRestoreAreas to actually fetch the areas to be
- *	restored from the backing pixmap.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Data are copied from the pixmap into the screen.
- *
- *-----------------------------------------------------------------------
- */
-void
-xf4bppRestoreAreas( pPixmap, prgnRestore, xorg, yorg, pWin )
-    register PixmapPtr pPixmap ; /* Backing pixmap */
-    RegionPtr prgnRestore ;	/* Region to restore (screen-relative)*/
-    int xorg ;			/* X origin of window */
-    int yorg ;			/* Y origin of window */
-    WindowPtr pWin;
-{
-    register BoxPtr pBox ;
-    register int nBox ;
-
-    TRACE( ( "xf4bppRestoreAreas(0x%x,0x%x,%d,%d)\n",
-	   pPixmap, prgnRestore, xorg, yorg ) ) ;
-/* WHOOP WHOOP WHOOP XXX -- depth 8 *only* */
-
-    if ( !( nBox = REGION_NUM_RECTS(prgnRestore) ) )
-	return ;
-    for ( pBox = REGION_RECTS(prgnRestore) ; nBox-- ; pBox++ )
-	xf4bppDrawColorImage( pWin, pBox->x1,
-		 pBox->y1,
-		 pBox->x2 - pBox->x1,
-		 pBox->y2 - pBox->y1,
-		 ( (unsigned char *)pPixmap->devPrivate.ptr )
-		 + ( ( pBox->y1 - yorg ) * pPixmap->devKind )
-		 + ( pBox->x1 - xorg ),
-		 pPixmap->devKind,
-		 GXcopy, VGA_ALLPLANES ) ;
-    return ;
-}
diff --git a/hw/xfree86/xf4bpp/ppcIO.c b/hw/xfree86/xf4bpp/ppcIO.c
index 72793cc..8d726e7 100644
--- a/hw/xfree86/xf4bpp/ppcIO.c
+++ b/hw/xfree86/xf4bpp/ppcIO.c
@@ -87,14 +87,6 @@ xf4bppNeverCalled()
 	FatalError("xf4bppNeverCalled was nevertheless called\n");
 }
 
-static BSFuncRec ppcBSFuncRec = {
-    xf4bppSaveAreas,
-    xf4bppRestoreAreas,
-    (BackingStoreSetClipmaskRgnProcPtr) 0,
-    (BackingStoreGetImagePixmapProcPtr) 0,
-    (BackingStoreGetSpansPixmapProcPtr) 0,
-};
-
 /*ARGSUSED*/
 static Bool
 vgaScreenClose
@@ -217,12 +209,6 @@ xf4bppScreenInit( pScreen, pbits, virtx,
   pScreen-> PaintWindowBorder = xf4bppPaintWindow;
   pScreen-> CopyWindow = xf4bppCopyWindow;
   pScreen-> CreatePixmap = xf4bppCreatePixmap;
-  pScreen-> SaveDoomedAreas = (SaveDoomedAreasProcPtr)NoopDDA;
-  pScreen-> RestoreAreas = (RestoreAreasProcPtr)NoopDDA;
-  pScreen-> ExposeCopy = (ExposeCopyProcPtr)NoopDDA;
-  pScreen-> TranslateBackingStore = (TranslateBackingStoreProcPtr)NoopDDA;
-  pScreen-> ClearBackingStore = (ClearBackingStoreProcPtr)NoopDDA;
-  pScreen-> DrawGuarantee = (DrawGuaranteeProcPtr)NoopDDA;
   pScreen-> CreateGC = xf4bppCreateGC;
   pScreen-> CreateColormap = xf4bppInitializeColormap;
   pScreen-> DestroyColormap = (DestroyColormapProcPtr)NoopDDA;
@@ -240,7 +226,6 @@ xf4bppScreenInit( pScreen, pbits, virtx,
 	rootdepth, ndepths, depths, defaultVisual /* See above */,
 	nvisuals, visuals))
      return FALSE;
-  pScreen->BackingStoreFuncs = ppcBSFuncRec;
 
   /* GJA -- Now we override the supplied default: */
   pScreen -> CreateScreenResources = v16CreateScreenResources;
diff --git a/hw/xfree86/xf4bpp/xf4bpp.h b/hw/xfree86/xf4bpp/xf4bpp.h
index 01512a8..5d5dcdd 100644
--- a/hw/xfree86/xf4bpp/xf4bpp.h
+++ b/hw/xfree86/xf4bpp/xf4bpp.h
@@ -19,22 +19,6 @@ void xf4bppFillArea(
     GCPtr
 );
 
-/* ppcBStore.c */
-void xf4bppSaveAreas(
-    PixmapPtr,
-    RegionPtr,
-    int,
-    int,
-    WindowPtr
-);
-void xf4bppRestoreAreas(
-    PixmapPtr,
-    RegionPtr,
-    int,
-    int,
-    WindowPtr
-);
-
 /* ppcClip.c */
 void xf4bppDestroyClip(
     GCPtr
diff --git a/hw/xfree86/xf8_32bpp/Makefile.am b/hw/xfree86/xf8_32bpp/Makefile.am
index bbcd10f..6f51a62 100644
--- a/hw/xfree86/xf8_32bpp/Makefile.am
+++ b/hw/xfree86/xf8_32bpp/Makefile.am
@@ -9,7 +9,6 @@ AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
 libxf8_32bpp_la_LDFLAGS = -avoid-version
 
 libxf8_32bpp_la_SOURCES = \
-	cfbbstore.c \
 	cfbcpyarea.c \
 	cfbcpyplane.c \
 	cfbgcmisc.c \
diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h
index 969fa29..31028a3 100644
--- a/hw/xfree86/xf8_32bpp/cfb8_32.h
+++ b/hw/xfree86/xf8_32bpp/cfb8_32.h
@@ -27,24 +27,6 @@ extern int cfb8_32GetGCPrivateIndex(void
 extern int cfb8_32ScreenPrivateIndex;	/* XXX */
 extern int cfb8_32GetScreenPrivateIndex(void);
 
-void
-cfb8_32SaveAreas(
-    PixmapPtr	  	pPixmap,
-    RegionPtr	  	prgnSave, 
-    int	    	  	xorg,
-    int	    	  	yorg,
-    WindowPtr		pWin
-);
-
-void
-cfb8_32RestoreAreas(
-    PixmapPtr	  	pPixmap, 
-    RegionPtr	  	prgnRestore,
-    int	    	  	xorg,
-    int	    	  	yorg,
-    WindowPtr		pWin
-);
-
 RegionPtr
 cfb8_32CopyArea(
     DrawablePtr pSrcDraw,
diff --git a/hw/xfree86/xf8_32bpp/cfbbstore.c b/hw/xfree86/xf8_32bpp/cfbbstore.c
deleted file mode 100644
index f4d570f..0000000
--- a/hw/xfree86/xf8_32bpp/cfbbstore.c
+++ /dev/null
@@ -1,105 +0,0 @@
-
-#define PSZ 8
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "cfb.h"
-#undef PSZ
-#include "cfb32.h"
-#include "cfb8_32.h"
-#include <X11/X.h>
-#include "mibstore.h"
-#include "regionstr.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-
-void
-cfb8_32SaveAreas(
-    PixmapPtr	  	pPixmap,
-    RegionPtr	  	prgnSave, 
-    int	    	  	xorg,
-    int	    	  	yorg,
-    WindowPtr		pWin
-){
-    DDXPointPtr pPt;
-    DDXPointPtr	pPtsInit;
-    BoxPtr	pBox;
-    int		i;
-    ScreenPtr	pScreen = pPixmap->drawable.pScreen;
-    PixmapPtr	pScrPix;
-
-    if(pPixmap->drawable.bitsPerPixel == 32) {
-	cfb32SaveAreas(pPixmap, prgnSave, xorg, yorg, pWin);
-	return;
-    }
-    
-    i = REGION_NUM_RECTS(prgnSave);
-    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
-    if (!pPtsInit)
-	return;
-    
-    pBox = REGION_RECTS(prgnSave);
-    pPt = pPtsInit;
-    while (--i >= 0) {
-	pPt->x = pBox->x1 + xorg;
-	pPt->y = pBox->y1 + yorg;
-	pPt++;
-	pBox++;
-    }
-
-    pScrPix = (PixmapPtr) pScreen->devPrivate;
-
-    cfbDoBitblt32To8((DrawablePtr) pScrPix, (DrawablePtr)pPixmap,
-		    GXcopy, prgnSave, pPtsInit, ~0L);
-
-    DEALLOCATE_LOCAL (pPtsInit);
-}
-
-
-void
-cfb8_32RestoreAreas(
-    PixmapPtr	  	pPixmap, 
-    RegionPtr	  	prgnRestore,
-    int	    	  	xorg,
-    int	    	  	yorg,
-    WindowPtr		pWin
-){
-    DDXPointPtr pPt;
-    DDXPointPtr pPtsInit;
-    BoxPtr	pBox;
-    int		i;
-    ScreenPtr	pScreen = pPixmap->drawable.pScreen;
-    PixmapPtr	pScrPix;
-
-    i = REGION_NUM_RECTS(prgnRestore);
-    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
-    if (!pPtsInit)
-	return;
-    
-    pBox = REGION_RECTS(prgnRestore);
-    pPt = pPtsInit;
-    while (--i >= 0) {
-	pPt->x = pBox->x1 - xorg;
-	pPt->y = pBox->y1 - yorg;
-	pPt++;
-	pBox++;
-    }
-
-    pScrPix = (PixmapPtr) pScreen->devPrivate;
-
-    if(pPixmap->drawable.bitsPerPixel == 32) {
-	if(pWin->drawable.depth == 24)
-	    cfb32DoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
-		    GXcopy, prgnRestore, pPtsInit, 0x00ffffff);
-	else
-	    cfb32DoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
-		    GXcopy, prgnRestore, pPtsInit, ~0);
-    } else {
-	cfbDoBitblt8To32((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
-		    GXcopy, prgnRestore, pPtsInit, ~0L);
-    }
-
-    DEALLOCATE_LOCAL (pPtsInit);
-}
diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c
index 7cbdb5a..29dc669 100644
--- a/hw/xfree86/xf8_32bpp/cfbscrinit.c
+++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c
@@ -31,15 +31,6 @@
 /* CAUTION:  We require that cfb8 and cfb32 were NOT 
 	compiled with CFB_NEED_SCREEN_PRIVATE */
 
-static BSFuncRec cfb8_32BSFuncRec = {
-    cfb8_32SaveAreas,
-    cfb8_32RestoreAreas,
-    (BackingStoreSetClipmaskRgnProcPtr) 0,
-    (BackingStoreGetImagePixmapProcPtr) 0,
-    (BackingStoreGetSpansPixmapProcPtr) 0,
-};
-
-
 int cfb8_32GCPrivateIndex;
 int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex; }
 int cfb8_32ScreenPrivateIndex;
@@ -220,7 +211,6 @@ cfb8_32FinishScreenInit(
 			defaultVisual, nvisuals, visuals))
 	return FALSE;
 
-    pScreen->BackingStoreFuncs = cfb8_32BSFuncRec;
     pScreen->CreateScreenResources = cfb8_32CreateScreenResources;
     pScreen->CloseScreen = cfb8_32CloseScreen;
     pScreen->GetScreenPixmap = cfb32GetScreenPixmap; 	/* OK */
diff --git a/hw/xgl/Makefile.am b/hw/xgl/Makefile.am
index 965060c..81484b9 100644
--- a/hw/xgl/Makefile.am
+++ b/hw/xgl/Makefile.am
@@ -48,7 +48,6 @@ libxgl_a_SOURCES =     \
 	xglcopy.c      \
 	xglfill.c      \
 	xglwindow.c    \
-	xglbstore.c    \
 	xglget.c       \
 	xglgc.c	       \
 	xglshm.c       \
diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h
index cd4cec1..5710bbf 100644
--- a/hw/xgl/xgl.h
+++ b/hw/xgl/xgl.h
@@ -293,8 +293,6 @@ typedef struct _xglScreen {
     RealizeGlyphProcPtr		  RealizeGlyph;
     UnrealizeGlyphProcPtr	  UnrealizeGlyph;
 #endif
-
-    BSFuncRec			  BackingStoreFuncs;
 } xglScreenRec, *xglScreenPtr;
 
 extern int xglScreenPrivateIndex;
@@ -1110,23 +1108,6 @@ xglSetWindowPixmap (WindowPtr pWin,
 		    PixmapPtr pPixmap);
 
 
-/* xglbstore.c */
-
-void
-xglSaveAreas (PixmapPtr	pPixmap,
-	      RegionPtr	prgnSave,
-	      int	xorg,
-	      int	yorg,
-	      WindowPtr	pWin);
-
-void
-xglRestoreAreas (PixmapPtr pPixmap,
-		 RegionPtr prgnRestore,
-		 int	   xorg,
-		 int	   yorg,
-		 WindowPtr pWin);
-
-
 /* xglget.c */
 
 void
diff --git a/hw/xgl/xglbstore.c b/hw/xgl/xglbstore.c
deleted file mode 100644
index 91019e0..0000000
--- a/hw/xgl/xglbstore.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright © 2004 David Reveman
- *
- * 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, and that the name of
- * David Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL DAVID REVEMAN 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.
- *
- * Author: David Reveman <davidr at novell.com>
- */
-
-#include "xgl.h"
-
-#define XGL_BSTORE_FALLBACK_PROLOGUE(pDrawable, func) \
-    xglSyncDamageBoxBits (pDrawable);		      \
-    XGL_SCREEN_UNWRAP (func)
-
-#define XGL_BSTORE_FALLBACK_EPILOGUE(pDrawable, func, xglfunc) \
-    XGL_SCREEN_WRAP (func, xglfunc);			       \
-    xglAddCurrentSurfaceDamage (pDrawable)
-
-/*
- * The follwong functions are not yet tested so we can assume that they
- * are both broken.
- */
-
-void
-xglSaveAreas (PixmapPtr	pPixmap,
-	      RegionPtr	prgnSave,
-	      int	xorg,
-	      int	yorg,
-	      WindowPtr	pWin)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    BoxRec    box;
-
-    XGL_SCREEN_PRIV (pScreen);
-    XGL_PIXMAP_PRIV (pPixmap);
-
-    box = *(REGION_EXTENTS (pScreen, prgnSave));
-
-    pPixmapPriv->damageBox = box;
-
-    if (xglCopy (&pWin->drawable,
-		 &pPixmap->drawable,
-		 xorg, yorg,
-		 REGION_RECTS (prgnSave),
-		 REGION_NUM_RECTS (prgnSave)))
-    {
-	xglAddCurrentBitDamage (&pPixmap->drawable);
-	return;
-    }
-
-    box.x1 += xorg;
-    box.y1 += yorg;
-    box.x2 += xorg;
-    box.y2 += yorg;
-
-    if (!xglSyncBits (&pWin->drawable, &box))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_BSTORE_FALLBACK_PROLOGUE (&pPixmap->drawable,
-				  BackingStoreFuncs.SaveAreas);
-    (*pScreen->BackingStoreFuncs.SaveAreas) (pPixmap, prgnSave,
-					     xorg, yorg, pWin);
-    XGL_BSTORE_FALLBACK_EPILOGUE (&pPixmap->drawable,
-				  BackingStoreFuncs.SaveAreas,
-				  xglSaveAreas);
-}
-
-void
-xglRestoreAreas (PixmapPtr pPixmap,
-		 RegionPtr prgnRestore,
-		 int	   xorg,
-		 int	   yorg,
-		 WindowPtr pWin)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    BoxPtr    pExt;
-    BoxRec    box;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (xglCopy (&pPixmap->drawable,
-		 &pWin->drawable,
-		 -xorg, -yorg,
-		 REGION_RECTS (prgnRestore),
-		 REGION_NUM_RECTS (prgnRestore)))
-    {
-	xglAddCurrentBitDamage (&pPixmap->drawable);
-	return;
-    }
-
-    pExt = REGION_EXTENTS (pScreen, prgnRestore);
-
-    box.x1 = pExt->x1 - xorg;
-    box.y1 = pExt->y1 - yorg;
-    box.x2 = pExt->x2 - xorg;
-    box.y2 = pExt->y2 - yorg;
-
-    if (!xglSyncBits (&pPixmap->drawable, &box))
-	FatalError (XGL_SW_FAILURE_STRING);
-
-    XGL_BSTORE_FALLBACK_PROLOGUE (&pWin->drawable,
-				  BackingStoreFuncs.RestoreAreas);
-    (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgnRestore,
-						xorg, yorg, pWin);
-    XGL_BSTORE_FALLBACK_EPILOGUE (&pWin->drawable,
-				  BackingStoreFuncs.RestoreAreas,
-				  xglRestoreAreas);
-}
diff --git a/hw/xgl/xgloutput.c b/hw/xgl/xgloutput.c
index 7b7ffad..76903a8 100644
--- a/hw/xgl/xgloutput.c
+++ b/hw/xgl/xgloutput.c
@@ -76,7 +76,7 @@ xglSetRootClip (ScreenPtr pScreen,
     WindowPtr	pChild;
     Bool	wasViewable;
     Bool	anyMarked = FALSE;
-    RegionPtr	pOldClip = 0, bsExposed;
+    RegionPtr	pOldClip = 0;
 
 #ifdef DO_SAVE_UNDERS
     Bool	dosave = FALSE;
@@ -141,12 +141,6 @@ xglSetRootClip (ScreenPtr pScreen,
 
     if (wasViewable)
     {
-	if (pWin->backStorage)
-	{
-	    pOldClip = REGION_CREATE (pScreen, NullBox, 1);
-	    REGION_COPY (pScreen, pOldClip, &pWin->clipList);
-	}
-
 	if (pWin->firstChild)
 	{
 	    anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild,
@@ -168,34 +162,6 @@ xglSetRootClip (ScreenPtr pScreen,
 	    (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
     }
 
-    if (pWin->backStorage && ((pWin->backingStore == Always) || wasViewable))
-    {
-	if (!wasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-
-	bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip,
-						       pWin->drawable.x,
-						       pWin->drawable.y);
-
-	if (wasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-
-	if (bsExposed)
-	{
-	    RegionPtr valExposed = NullRegion;
-
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-
-	    if (valExposed)
-		REGION_EMPTY (pScreen, valExposed);
-
-	    REGION_DESTROY (pScreen, bsExposed);
-	}
-    }
-
     if (wasViewable)
     {
 	if (anyMarked)
diff --git a/hw/xgl/xglscreen.c b/hw/xgl/xglscreen.c
index 5ad9091..e468697 100644
--- a/hw/xgl/xglscreen.c
+++ b/hw/xgl/xglscreen.c
@@ -253,9 +253,6 @@ xglScreenInit (ScreenPtr pScreen)
     }
 #endif
 
-    XGL_SCREEN_WRAP (BackingStoreFuncs.SaveAreas, xglSaveAreas);
-    XGL_SCREEN_WRAP (BackingStoreFuncs.RestoreAreas, xglRestoreAreas);
-
     if (!fbCreateDefColormap (pScreen))
 	return FALSE;
 
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index e66b4f7..d08e482 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -304,15 +304,6 @@ xnestOpenScreen(int index, ScreenPtr pSc
   pScreen->CreatePixmap = xnestCreatePixmap;
   pScreen->DestroyPixmap = xnestDestroyPixmap;
 
-  /* Backing store procedures */
-  
-  pScreen->SaveDoomedAreas = NULL;
-  pScreen->RestoreAreas = NULL;
-  pScreen->ExposeCopy = NULL;
-  pScreen->TranslateBackingStore = NULL;
-  pScreen->ClearBackingStore = NULL;
-  pScreen->DrawGuarantee = NULL;
-
   /* Font procedures */
 
   pScreen->RealizeFont = xnestRealizeFont;
diff --git a/hw/xprint/pcl/PclWindow.c b/hw/xprint/pcl/PclWindow.c
index adf03da..80f4e91 100644
--- a/hw/xprint/pcl/PclWindow.c
+++ b/hw/xprint/pcl/PclWindow.c
@@ -333,14 +333,6 @@ PclPaintWindow(
 	  newValues[ABSY] = (pointer)0;
       }
 
-/*
- * XXX Backing store is turned off for the PCL driver    
-
-    if (pWin->backStorage)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
-	GuaranteeVisBack);
- */
-
     mask = gcmask;
     gcmask = 0;
     i = 0;
@@ -420,14 +412,6 @@ PclPaintWindow(
     (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
     DEALLOCATE_LOCAL(prect);
 
-/*
- * XXX Backing store is turned off for the PCL driver
-
-    if (pWin->backStorage)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
-	GuaranteeNothing);
- */
-
     if (what == PW_BORDER)
       {
 	  REGION_UNINIT(pScreen, &pWin->clipList);
diff --git a/hw/xprint/ps/PsWindow.c b/hw/xprint/ps/PsWindow.c
index 1317fd7..26075a8 100644
--- a/hw/xprint/ps/PsWindow.c
+++ b/hw/xprint/ps/PsWindow.c
@@ -340,13 +340,6 @@ PsPaintWindow(
     newValues[ABSY] = (pointer)0;
   }
 
-/*
- * XXX Backing store is turned off for the PS driver
-
-  if( pWin->backStorage )
-    (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
- */
-
   mask = gcmask;
   gcmask = 0;
   i = 0;
@@ -433,13 +426,6 @@ PsPaintWindow(
   (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
   DEALLOCATE_LOCAL(prect);
 
-/*
- * XXX Backing store is turned off for the PS driver
-
-  if( pWin->backStorage )
-    (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
- */
-
   if( what==PW_BORDER )
   {
     REGION_UNINIT(pScreen, &pWin->clipList);
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index a9b061a..52adba8 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -336,13 +336,6 @@ winFinishScreenInitFB (int index,
   /* Place our save screen function */
   pScreen->SaveScreen = winSaveScreen;
 
-  /* Backing store functions */
-  /*
-   * FIXME: Backing store support still doesn't seem to be working.
-   */
-  pScreen->BackingStoreFuncs.SaveAreas = fbSaveAreas;
-  pScreen->BackingStoreFuncs.RestoreAreas = fbRestoreAreas;
-
   /* Finish fb initialization */
   if (!fbFinishScreenInit (pScreen,
 			   pScreenInfo->pfb,
diff --git a/include/bstorestr.h b/include/bstorestr.h
index 14e2fe1..cf7820b 100644
--- a/include/bstorestr.h
+++ b/include/bstorestr.h
@@ -45,13 +45,11 @@ typedef    PixmapPtr (* BackingStoreGetI
 typedef    PixmapPtr (* BackingStoreGetSpansPixmapProcPtr)(void);
 
 typedef struct _BSFuncs {
-
 	BackingStoreSaveAreasProcPtr SaveAreas;
 	BackingStoreRestoreAreasProcPtr RestoreAreas;
 	BackingStoreSetClipmaskRgnProcPtr SetClipmaskRgn;
 	BackingStoreGetImagePixmapProcPtr GetImagePixmap;
 	BackingStoreGetSpansPixmapProcPtr GetSpansPixmap;
-
 } BSFuncRec, *BSFuncPtr;
 
 #endif /* _BSTORESTR_H_ */
diff --git a/mfb/Makefile.am b/mfb/Makefile.am
index fe0bb1c..8ff0260 100644
--- a/mfb/Makefile.am
+++ b/mfb/Makefile.am
@@ -17,7 +17,7 @@ libmfb_la_SOURCES = mfbgc.c mfbwindow.c 
 	 mfbpushpxl.c mfbzerarc.c mfbfillarc.c \
          mfbfillsp.c mfbsetsp.c mfbscrinit.c mfbscrclse.c mfbclip.c \
          mfbbitblt.c mfbgetsp.c mfbpolypnt.c \
-	 mfbcmap.c mfbmisc.c mfbbstore.c $(libmfb_gen_sources)
+	 mfbcmap.c mfbmisc.c $(libmfb_gen_sources)
 
 EXTRA_DIST = maskbits.h mergerop.h fastblt.h mfbline.c mfbblt.c mfbtile.c \
              mfbplygblt.c mfbimggblt.c mfbpntarea.c mfbtegblt.c mfbply1rct.c
diff --git a/mfb/mfb.h b/mfb/mfb.h
index f597b16..bc07f02 100644
--- a/mfb/mfb.h
+++ b/mfb/mfb.h
@@ -205,23 +205,7 @@ extern void mfbBresD(
     int /*e2*/,
     int /*len*/
 );
-/* mfbbstore.c */
 
-extern void mfbSaveAreas(
-    PixmapPtr /*pPixmap*/,
-    RegionPtr /*prgnSave*/,
-    int /*xorg*/,
-    int /*yorg*/,
-    WindowPtr /*pWin*/
-);
-
-extern void mfbRestoreAreas(
-    PixmapPtr /*pPixmap*/,
-    RegionPtr /*prgnRestore*/,
-    int /*xorg*/,
-    int /*yorg*/,
-    WindowPtr /*pWin*/
-);
 /* mfbclip.c */
 
 extern RegionPtr mfbPixmapToRegion(
diff --git a/mfb/mfbbstore.c b/mfb/mfbbstore.c
deleted file mode 100644
index 784df4e..0000000
--- a/mfb/mfbbstore.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
-/*
-
-Copyright 1987, 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.
-
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include    "mfb.h"
-#include    <X11/X.h>
-#include    "mibstore.h"
-#include    "regionstr.h"
-#include    "scrnintstr.h"
-#include    "pixmapstr.h"
-#include    "windowstr.h"
-
-/*-
- *-----------------------------------------------------------------------
- * mfbSaveAreas --
- *	Function called by miSaveAreas to actually fetch the areas to be
- *	saved into the backing pixmap. This is very simple to do, since
- *	mfbDoBitblt is designed for this very thing. The region to save is
- *	already destination-relative and we're given the offset to the
- *	window origin, so we have only to create an array of points of the
- *	u.l. corners of the boxes in the region translated to the screen
- *	coordinate system and fetch the screen pixmap out of its devPrivate
- *	field....
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Data are copied from the screen into the pixmap.
- *
- *-----------------------------------------------------------------------
- */
-void
-mfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
-    PixmapPtr	  	pPixmap;  	/* Backing pixmap */
-    RegionPtr	  	prgnSave; 	/* Region to save (pixmap-relative) */
-    int	    	  	xorg;	    	/* X origin of region */
-    int	    	  	yorg;	    	/* Y origin of region */
-    WindowPtr		pWin;
-{
-    register DDXPointPtr pPt;
-    DDXPointPtr		pPtsInit;
-    register BoxPtr	pBox;
-    register int	numRects;
-    
-    numRects = REGION_NUM_RECTS(prgnSave);
-    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
-    if (!pPtsInit)
-	return;
-    
-    pBox = REGION_RECTS(prgnSave);
-    pPt = pPtsInit;
-    while (numRects--)
-    {
-	pPt->x = pBox->x1 + xorg;
- 	pPt->y = pBox->y1 + yorg;
- 	pPt++;
- 	pBox++;
-    }
-
-    mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
-		(DrawablePtr)pPixmap,
-		GXcopy,
-		prgnSave,
-		pPtsInit);
-
-    DEALLOCATE_LOCAL(pPtsInit);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * mfbRestoreAreas --
- *	Function called by miRestoreAreas to actually fetch the areas to be
- *	restored from the backing pixmap. This is very simple to do, since
- *	mfbDoBitblt is designed for this very thing. The region to restore is
- *	already destination-relative and we're given the offset to the
- *	window origin, so we have only to create an array of points of the
- *	u.l. corners of the boxes in the region translated to the pixmap
- *	coordinate system and fetch the screen pixmap out of its devPrivate
- *	field....
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Data are copied from the pixmap into the screen.
- *
- *-----------------------------------------------------------------------
- */
-void
-mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
-    PixmapPtr	  	pPixmap;  	/* Backing pixmap */
-    RegionPtr	  	prgnRestore; 	/* Region to restore (screen-relative)*/
-    int	    	  	xorg;	    	/* X origin of window */
-    int	    	  	yorg;	    	/* Y origin of window */
-    WindowPtr		pWin;
-{
-    register DDXPointPtr pPt;
-    DDXPointPtr		pPtsInit;
-    register BoxPtr	pBox;
-    register int	numRects;
-    
-    numRects = REGION_NUM_RECTS(prgnRestore);
-    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
-    if (!pPtsInit)
-	return;
-    
-    pBox = REGION_RECTS(prgnRestore);
-    pPt = pPtsInit;
-    while (numRects--)
-    {
-	pPt->x = pBox->x1 - xorg;
- 	pPt->y = pBox->y1 - yorg;
- 	pPt++;
- 	pBox++;
-    }
-
-    mfbDoBitblt((DrawablePtr)pPixmap,
-		(DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
-		GXcopy,
-		prgnRestore,
-		pPtsInit);
-
-    DEALLOCATE_LOCAL(pPtsInit);
-}
diff --git a/mfb/mfbscrinit.c b/mfb/mfbscrinit.c
index 0707c1a..13ea5d3 100644
--- a/mfb/mfbscrinit.c
+++ b/mfb/mfbscrinit.c
@@ -89,16 +89,6 @@ static DepthRec depth = {
     1,		1,		&VID
 };
 
-
-BSFuncRec mfbBSFuncRec = {
-    mfbSaveAreas,
-    mfbRestoreAreas,
-    (BackingStoreSetClipmaskRgnProcPtr) 0,
-    (BackingStoreGetImagePixmapProcPtr) 0,
-    (BackingStoreGetSpansPixmapProcPtr) 0,
-};
-
-
 Bool
 mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
     ScreenPtr pScreen;
@@ -169,7 +159,6 @@ mfbScreenInit(pScreen, pbits, xsize, ysi
     if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 			1, 1, &depth, VID, 1, &visual))
 	return FALSE;
-    pScreen->BackingStoreFuncs = mfbBSFuncRec;
     return TRUE;
 }
 
diff --git a/mi/mibank.c b/mi/mibank.c
index 32e963f..00638a4 100644
--- a/mi/mibank.c
+++ b/mi/mibank.c
@@ -124,7 +124,6 @@ typedef struct _miBankScreen
     PaintWindowBackgroundProcPtr  PaintWindowBackground;
     PaintWindowBorderProcPtr      PaintWindowBorder;
     CopyWindowProcPtr             CopyWindow;
-    BSFuncRec                     BackingStoreFuncs;
 } miBankScreenRec, *miBankScreenPtr;
 
 typedef struct _miBankGC
@@ -1716,7 +1715,6 @@ miBankCloseScreen(
     SCREEN_UNWRAP(PaintWindowBackground);
     SCREEN_UNWRAP(PaintWindowBorder);
     SCREEN_UNWRAP(CopyWindow);
-    SCREEN_UNWRAP(BackingStoreFuncs);
 
     Xfree(pScreenPriv);
     return (*pScreen->CloseScreen)(nIndex, pScreen);
@@ -2054,114 +2052,6 @@ miBankCopyWindow(
     DEALLOCATE_LOCAL(pBoxNew1);
 }
 
-/**************************
- * Backing store wrappers *
- **************************/
-
-static void
-miBankSaveAreas(
-    PixmapPtr pPixmap,
-    RegionPtr prgnSave,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin
-)
-{
-    ScreenPtr   pScreen   = pPixmap->drawable.pScreen;
-    RegionRec   rgnClipped;
-    int         i;
-
-    SCREEN_INIT;
-    SCREEN_SAVE;
-    SCREEN_UNWRAP(BackingStoreFuncs.SaveAreas);
-
-    if (!IS_BANKED(pWin))
-    {
-        (*pScreen->BackingStoreFuncs.SaveAreas)(pPixmap, prgnSave, xorg, yorg,
-            pWin);
-    }
-    else
-    {
-        REGION_NULL(pScreen, &rgnClipped);
-        REGION_TRANSLATE(pScreen, prgnSave, xorg, yorg);
-
-        for (i = 0;  i < pScreenPriv->nBanks;  i++)
-        {
-            if (!pScreenPriv->pBanks[i])
-                continue;
-
-            REGION_INTERSECT(pScreen, &rgnClipped,
-                prgnSave, pScreenPriv->pBanks[i]);
-
-            if (REGION_NIL(&rgnClipped))
-                continue;
-
-            SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
-
-            REGION_TRANSLATE(pScreen, &rgnClipped, -xorg, -yorg);
-
-            (*pScreen->BackingStoreFuncs.SaveAreas)(pPixmap, &rgnClipped,
-                xorg, yorg, pWin);
-        }
-
-        REGION_TRANSLATE(pScreen, prgnSave, -xorg, -yorg);
-        REGION_UNINIT(pScreen, &rgnClipped);
-    }
-
-    SCREEN_WRAP(BackingStoreFuncs.SaveAreas, miBankSaveAreas);
-    SCREEN_RESTORE;
-}
-
-static void
-miBankRestoreAreas(
-    PixmapPtr pPixmap,
-    RegionPtr prgnRestore,
-    int       xorg,
-    int       yorg,
-    WindowPtr pWin
-)
-{
-    ScreenPtr   pScreen   = pPixmap->drawable.pScreen;
-    RegionRec   rgnClipped;
-    int         i;
-
-    SCREEN_INIT;
-    SCREEN_SAVE;
-    SCREEN_UNWRAP(BackingStoreFuncs.RestoreAreas);
-
-    if (!IS_BANKED(pWin))
-    {
-        (*pScreen->BackingStoreFuncs.RestoreAreas)(pPixmap, prgnRestore,
-            xorg, yorg, pWin);
-    }
-    else
-    {
-        REGION_NULL(pScreen, &rgnClipped);
-
-        for (i = 0;  i < pScreenPriv->nBanks;  i++)
-        {
-            if (!pScreenPriv->pBanks[i])
-                continue;
-
-            REGION_INTERSECT(pScreen, &rgnClipped,
-                prgnRestore, pScreenPriv->pBanks[i]);
-
-            if (REGION_NIL(&rgnClipped))
-                continue;
-
-            SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
-
-            (*pScreen->BackingStoreFuncs.RestoreAreas)(pPixmap, &rgnClipped,
-                xorg, yorg, pWin);
-        }
-
-        REGION_UNINIT(pScreen, &rgnClipped);
-    }
-
-    SCREEN_WRAP(BackingStoreFuncs.RestoreAreas, miBankRestoreAreas);
-    SCREEN_RESTORE;
-}
-
 _X_EXPORT Bool
 miInitializeBanking(
     ScreenPtr     pScreen,
@@ -2383,14 +2273,6 @@ miInitializeBanking(
     SCREEN_WRAP(PaintWindowBorder,     miBankPaintWindow);
     SCREEN_WRAP(CopyWindow,            miBankCopyWindow);
 
-    pScreenPriv->BackingStoreFuncs     = pScreen->BackingStoreFuncs;
-
-    pScreen->BackingStoreFuncs.SaveAreas      = miBankSaveAreas;
-    pScreen->BackingStoreFuncs.RestoreAreas   = miBankRestoreAreas;
-    /* ??????????????????????????????????????????????????????????????
-    pScreen->BackingStoreFuncs.SetClipmaskRgn = miBankSetClipmaskRgn;
-    ?????????????????????????????????????????????????????????????? */
-
     BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
 
     return TRUE;
diff --git a/mi/mibstore.c b/mi/mibstore.c
index 70839ce..294b2ca 100644
--- a/mi/mibstore.c
+++ b/mi/mibstore.c
@@ -1,3879 +1,48 @@
-/***********************************************************
-
-Copyright 1987, 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 by the Regents of the University of California
-
-                        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 The Open Group not be used in advertising or publicity
-pertaining to distribution of the software without specific, written prior
-permission.  
-
-The University of California makes no representations about the suitability
-of this software for any purpose.  It is provided "as is" without express or
-implied warranty.
-
-******************************************************************/
-
+/*
+ * Copyright 2007 Red Hat, Inc.
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * them Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) 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 MERCHANTIBILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS 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.
+ */
 
-#define NEED_EVENTS
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
 #endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "regionstr.h"
 #include "scrnintstr.h"
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include <X11/fonts/fontstruct.h>
-#include "dixfontstr.h"
-#include "dixstruct.h"		/* For requestingClient */
-#include "mi.h"
-#include "mibstorest.h"
+#include "mibstore.h"
 
 /*
- * When the server fails to allocate a backing store pixmap, if you want
- * it to dynamically retry to allocate backing store on every subsequent
- * graphics op, you can enable BSEAGER; otherwise, backing store will be
- * disabled on the window until it is unmapped and then remapped.
- */
-/* #define BSEAGER */
-
-/*-
- * NOTES ON USAGE:
+ * There is no longer an mi implementation of backing store.  This function
+ * is only for source compatibility with old drivers.
  *
- * The functions in this file implement a machine-independent backing-store
- * scheme. To use it, the output library must do the following:
- *	- Provide a SaveAreas function that takes a destination pixmap, a
- *	    region of the areas to save (in the pixmap's coordinate system)
- *	    and the screen origin of the region. It should copy the areas from
- *	    the screen into the pixmap.
- *	- Provide a RestoreAreas function that takes a source pixmap, a region
- *	    of the areas to restore (in the screen's coordinate system) and the
- *	    origin of the pixmap on the screen. It should copy the areas from
- *	    the pixmap into the screen.
- *	- Provide a SetClipmaskRgn function that takes a gc and a region
- *	    and merges the region into any CT_PIXMAP client clip that
- *	    is specified in the GC.  This routine is only needed if
- *	    miValidateBackingStore will see CT_PIXMAP clip lists; not
- *	    true for any of the sample servers (which convert the PIXMAP
- *	    clip lists into CT_REGION clip lists; an expensive but simple
- *	    to code option).
- *	- The function placed in a window's ClearToBackground vector must call
- *	    pScreen->ClearBackingStore with the window, followed by
- *	    the window-relative x and y coordinates, followed by the width and
- *	    height of the area to be cleared, followed by the generateExposures
- *	    flag. This has been taken care of in miClearToBackground.
- *	- Whatever determines GraphicsExpose events for the CopyArea and
- *	    CopyPlane requests should call pWin->backStorage->ExposeCopy
- *	    with the source and destination drawables, the GC used, a source-
- *	    window-relative region of exposed areas, the source and destination
- *	    coordinates and the bitplane copied, if CopyPlane, or 0, if
- *	    CopyArea.
- *
- * JUSTIFICATION
- *    This is a cross between saving everything and just saving the
- * obscued areas (as in Pike's layers.)  This method has the advantage
- * of only doing each output operation once per pixel, visible or
- * invisible, and avoids having to do all the crufty storage
- * management of keeping several separate rectangles.  Since the
- * ddx layer ouput primitives are required to draw through clipping
- * rectangles anyway, sending multiple drawing requests for each of
- * several rectangles isn't necessary.  (Of course, it could be argued
- * that the ddx routines should just take one rectangle each and
- * get called multiple times, but that would make taking advantage of
- * smart hardware harder, and probably be slower as well.)
- */
-
-#define SETUP_BACKING_TERSE(pGC) \
-    miBSGCPtr	pGCPrivate = (miBSGCPtr)(pGC)->devPrivates[miBSGCIndex].ptr; \
-    GCFuncs	*oldFuncs = pGC->funcs;
-
-#define SETUP_BACKING(pDrawable,pGC) \
-    miBSWindowPtr pBackingStore = \
-    	(miBSWindowPtr)((WindowPtr)(pDrawable))->backStorage; \
-    DrawablePtr	  pBackingDrawable = (DrawablePtr) \
-        pBackingStore->pBackingPixmap; \
-    SETUP_BACKING_TERSE(pGC) \
-    GCPtr	pBackingGC = pGCPrivate->pBackingGC;
-
-#define PROLOGUE(pGC) { \
-    pGC->ops = pGCPrivate->wrapOps;\
-    pGC->funcs = pGCPrivate->wrapFuncs; \
-    }
-
-#define EPILOGUE(pGC) { \
-    pGCPrivate->wrapOps = (pGC)->ops; \
-    (pGC)->ops = &miBSGCOps; \
-    (pGC)->funcs = oldFuncs; \
-    }
-   
-static void	    miCreateBSPixmap(WindowPtr pWin, BoxPtr pExtents);
-static void	    miDestroyBSPixmap(WindowPtr pWin);
-static void	    miTileVirtualBS(WindowPtr pWin);
-static void	    miBSAllocate(WindowPtr pWin), miBSFree(WindowPtr pWin);
-static Bool	    miBSCreateGCPrivate(GCPtr pGC);
-static void	    miBSClearBackingRegion(WindowPtr pWin, RegionPtr pRgn);
-
-#define MoreCopy0 ;
-#define MoreCopy2 *dstCopy++ = *srcCopy++; *dstCopy++ = *srcCopy++;
-#define MoreCopy4 MoreCopy2 MoreCopy2
-
-#define copyData(src,dst,n,morecopy) \
-{ \
-    short *srcCopy = (short *)(src); \
-    short *dstCopy = (short *)(dst); \
-    int i; \
-    int bsx = pBackingStore->x; \
-    int bsy = pBackingStore->y; \
-    for (i = n; --i >= 0; ) \
-    { \
-	*dstCopy++ = *srcCopy++ - bsx; \
-	*dstCopy++ = *srcCopy++ - bsy; \
-	morecopy \
-    } \
-}
-
-#define copyPoints(src,dst,n,mode) \
-if (mode == CoordModeOrigin) \
-{ \
-    copyData(src,dst,n,MoreCopy0); \
-} \
-else \
-{ \
-    memmove((char *)(dst), (char *)(src), (n) << 2); \
-    *((short *)(dst)) -= pBackingStore->x; \
-    *((short *)(dst) + 1) -= pBackingStore->y; \
-}
-
-/*
- * wrappers for screen funcs
- */
-
-static int  miBSScreenIndex;
-static unsigned long miBSGeneration = 0;
-
-static Bool	    miBSCloseScreen(int i, ScreenPtr pScreen);
-static void	    miBSGetImage(DrawablePtr pDrawable, int sx, int sy,
-				 int w, int h, unsigned int format,
-				 unsigned long planemask, char *pdstLine);
-static void	    miBSGetSpans(DrawablePtr pDrawable, int wMax,
-				 DDXPointPtr ppt, int *pwidth, int nspans,
-				 char *pdstStart);
-static Bool	    miBSChangeWindowAttributes(WindowPtr pWin,
-					       unsigned long mask);
-static Bool	    miBSCreateGC(GCPtr pGC);
-static Bool	    miBSDestroyWindow(WindowPtr pWin);
-
-/*
- * backing store screen functions
- */
-
-static void	    miBSSaveDoomedAreas(WindowPtr pWin, RegionPtr pObscured,
-					int dx, int dy);
-static RegionPtr    miBSRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed);
-static void	    miBSExposeCopy(WindowPtr pSrc, DrawablePtr pDst,
-				   GCPtr pGC, RegionPtr prgnExposed,
-				   int srcx, int srcy, int dstx, int dsty,
-				   unsigned long plane);
-static RegionPtr    miBSTranslateBackingStore(WindowPtr pWin, int windx,
-					      int windy, RegionPtr oldClip,
-					      int oldx, int oldy);
-static RegionPtr    miBSClearBackingStore(WindowPtr pWin, int x, int y,
-					  int w, int h, Bool generateExposures);
-static void	    miBSDrawGuarantee(WindowPtr pWin, GCPtr pGC,
-				      int guarantee);
-
-/*
- * wrapper vectors for GC funcs and ops
- */
-
-static int  miBSGCIndex;
-
-static void miBSValidateGC(GCPtr pGC, unsigned long stateChanges,
-			   DrawablePtr pDrawable);
-static void miBSCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
-static void miBSDestroyGC(GCPtr pGC);
-static void miBSChangeGC(GCPtr pGC, unsigned long mask);
-static void miBSChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
-static void miBSDestroyClip(GCPtr pGC);
-static void miBSCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
-
-static GCFuncs	miBSGCFuncs = {
-    miBSValidateGC,
-    miBSChangeGC,
-    miBSCopyGC,
-    miBSDestroyGC,
-    miBSChangeClip,
-    miBSDestroyClip,
-    miBSCopyClip,
-};
-
-static void	    miBSFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit,
-				  DDXPointPtr pptInit, int *pwidthInit,
-				  int fSorted);
-static void	    miBSSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
-				 DDXPointPtr ppt, int *pwidth, int nspans,
-				 int fSorted);
-static void	    miBSPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
-				 int x, int y, int w, int h, int leftPad,
-				 int format, char *pBits);
-static RegionPtr    miBSCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
-				 GCPtr pGC, int srcx, int srcy, int w, int h,
-				 int dstx, int dsty);
-static RegionPtr    miBSCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
-				  GCPtr pGC, int srcx, int srcy, int w, int h,
-				  int dstx, int dsty, unsigned long plane);
-static void	    miBSPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
-				  int npt, xPoint *pptInit);
-static void	    miBSPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode,
-				  int npt, DDXPointPtr pptInit);
-static void	    miBSPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
-				    xSegment *pSegs);
-static void	    miBSPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
-				      int nrects, xRectangle *pRects);
-static void	    miBSPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs,
-				xArc *parcs);
-static void	    miBSFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
-				    int shape, int mode, int count,
-				    DDXPointPtr pPts);
-static void	    miBSPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
-				     int nrectFill, xRectangle *prectInit);
-static void	    miBSPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
-				    int narcs, xArc *parcs);
-static int	    miBSPolyText8(DrawablePtr pDrawable, GCPtr pGC,
-				  int x, int y, int count, char *chars);
-static int	    miBSPolyText16(DrawablePtr pDrawable, GCPtr pGC,
-				   int x, int y, int count,
-				   unsigned short *chars);
-static void	    miBSImageText8(DrawablePtr pDrawable, GCPtr pGC,
-				   int x, int y, int count, char *chars);
-static void	    miBSImageText16(DrawablePtr pDrawable, GCPtr pGC,
-				    int x, int y, int count,
-				    unsigned short *chars);
-static void	    miBSImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
-				      int x, int y, unsigned int nglyph,
-				      CharInfoPtr *ppci, pointer pglyphBase);
-static void	    miBSPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
-				     int x, int y, unsigned int nglyph,
-				     CharInfoPtr *ppci, pointer pglyphBase);
-static void	    miBSPushPixels(GCPtr pGC, PixmapPtr pBitMap,
-				   DrawablePtr pDst, int w, int h,
-				   int x, int y);
-
-static GCOps miBSGCOps = {
-    miBSFillSpans,	miBSSetSpans,	    miBSPutImage,	
-    miBSCopyArea,	miBSCopyPlane,	    miBSPolyPoint,
-    miBSPolylines,	miBSPolySegment,    miBSPolyRectangle,
-    miBSPolyArc,	miBSFillPolygon,    miBSPolyFillRect,
-    miBSPolyFillArc,	miBSPolyText8,	    miBSPolyText16,
-    miBSImageText8,	miBSImageText16,    miBSImageGlyphBlt,
-    miBSPolyGlyphBlt,	miBSPushPixels
-};
-
-#define FUNC_PROLOGUE(pGC, pPriv) \
-    ((pGC)->funcs = pPriv->wrapFuncs),\
-    ((pGC)->ops = pPriv->wrapOps)
-
-#define FUNC_EPILOGUE(pGC, pPriv) \
-    ((pGC)->funcs = &miBSGCFuncs),\
-    ((pGC)->ops = &miBSGCOps)
-
-/*
- * every GC in the server is initially wrapped with these
- * "cheap" functions.  This allocates no memory and is used
- * to discover GCs used with windows which have backing
- * store enabled
- */
-
-static void miBSCheapValidateGC(GCPtr pGC, unsigned long stateChanges,
-				DrawablePtr pDrawable);
-static void miBSCheapCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
-static void miBSCheapDestroyGC(GCPtr pGC);
-static void miBSCheapChangeGC(GCPtr pGC, unsigned long mask);
-static void miBSCheapChangeClip(GCPtr pGC, int type, pointer pvalue,
-				int nrects);
-static void miBSCheapDestroyClip(GCPtr pGC);
-static void miBSCheapCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
-
-static GCFuncs miBSCheapGCFuncs = {
-    miBSCheapValidateGC,
-    miBSCheapChangeGC,
-    miBSCheapCopyGC,
-    miBSCheapDestroyGC,
-    miBSCheapChangeClip,
-    miBSCheapDestroyClip,
-    miBSCheapCopyClip,
-};
-
-#define CHEAP_FUNC_PROLOGUE(pGC) \
-    ((pGC)->funcs = (GCFuncs *) (pGC)->devPrivates[miBSGCIndex].ptr)
-
-#define CHEAP_FUNC_EPILOGUE(pGC) \
-    ((pGC)->funcs = &miBSCheapGCFuncs)
-
-/*
- * called from device screen initialization proc.  Gets a GCPrivateIndex
- * and wraps appropriate per-screen functions.  pScreen->BackingStoreFuncs
- * must be previously initialized.
+ * Note though that you do get backing store for free if your server has
+ * Composite enabled, since the automatic redirection mechanism provides
+ * essentially the same functionality.  See compChangeWindowAttributes()
+ * for the implementation.
  */
 
 _X_EXPORT void
-miInitializeBackingStore (pScreen)
-    ScreenPtr	pScreen;
-{
-    miBSScreenPtr    pScreenPriv;
-
-    if (miBSGeneration != serverGeneration)
-    {
-	miBSScreenIndex = AllocateScreenPrivateIndex ();
-	if (miBSScreenIndex < 0)
-	    return;
-	miBSGCIndex = AllocateGCPrivateIndex ();
-	miBSGeneration = serverGeneration;
-    }
-    if (!AllocateGCPrivate(pScreen, miBSGCIndex, 0))
-	return;
-    pScreenPriv = (miBSScreenPtr) xalloc (sizeof (miBSScreenRec));
-    if (!pScreenPriv)
-	return;
-
-    pScreenPriv->CloseScreen = pScreen->CloseScreen;
-    pScreenPriv->GetImage = pScreen->GetImage;
-    pScreenPriv->GetSpans = pScreen->GetSpans;
-    pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
-    pScreenPriv->CreateGC = pScreen->CreateGC;
-    pScreenPriv->DestroyWindow = pScreen->DestroyWindow;
-
-    pScreen->CloseScreen = miBSCloseScreen;
-    pScreen->GetImage = miBSGetImage;
-    pScreen->GetSpans = miBSGetSpans;
-    pScreen->ChangeWindowAttributes = miBSChangeWindowAttributes;
-    pScreen->CreateGC = miBSCreateGC;
-    pScreen->DestroyWindow = miBSDestroyWindow;
-
-    pScreen->SaveDoomedAreas = miBSSaveDoomedAreas;
-    pScreen->RestoreAreas = miBSRestoreAreas;
-    pScreen->ExposeCopy = miBSExposeCopy;
-    pScreen->TranslateBackingStore = miBSTranslateBackingStore;
-    pScreen->ClearBackingStore = miBSClearBackingStore;
-    pScreen->DrawGuarantee = miBSDrawGuarantee;
-
-    pScreen->devPrivates[miBSScreenIndex].ptr = (pointer) pScreenPriv;
-}
-
-/*
- * Screen function wrappers
- */
-
-#define SCREEN_PROLOGUE(pScreen, field)\
-  ((pScreen)->field = \
-   ((miBSScreenPtr) \
-    (pScreen)->devPrivates[miBSScreenIndex].ptr)->field)
-
-#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
-    ((pScreen)->field = wrapper)
-
-/*
- * CloseScreen wrapper -- unwrap everything, free the private data
- * and call the wrapped function
- */
-
-static Bool
-miBSCloseScreen (i, pScreen)
-    int		i;
-    ScreenPtr	pScreen;
-{
-    miBSScreenPtr   pScreenPriv;
-
-    pScreenPriv = (miBSScreenPtr) pScreen->devPrivates[miBSScreenIndex].ptr;
-
-    pScreen->CloseScreen = pScreenPriv->CloseScreen;
-    pScreen->GetImage = pScreenPriv->GetImage;
-    pScreen->GetSpans = pScreenPriv->GetSpans;
-    pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
-    pScreen->CreateGC = pScreenPriv->CreateGC;
-
-    xfree ((pointer) pScreenPriv);
-
-    return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-static void miBSFillVirtualBits(DrawablePtr pDrawable, GCPtr pGC,
-				RegionPtr pRgn, int x, int y, int state,
-				PixUnion pixunion, unsigned long planemask);
-
-static void
-miBSGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine)
-    DrawablePtr	    pDrawable;
-    int		    sx, sy, w, h;
-    unsigned int    format;
-    unsigned long   planemask;
-    char	    *pdstLine;
-{
-    ScreenPtr		    pScreen = pDrawable->pScreen;
-    BoxRec		    bounds;
-    unsigned char	    depth;
-    
-    SCREEN_PROLOGUE (pScreen, GetImage);
-
-    if (pDrawable->type != DRAWABLE_PIXMAP &&
-	((WindowPtr) pDrawable)->visibility != VisibilityUnobscured)
-    {
-	PixmapPtr	pPixmap;
-	miBSWindowPtr	pWindowPriv;
-	GCPtr		pGC = NULL;
-	WindowPtr	pWin, pSrcWin;
-	int		xoff, yoff;
-	RegionRec	Remaining;
-	RegionRec	Border;
-	RegionRec	Inside;
-	BoxPtr		pBox;
-	int		n;
-
-	pWin = (WindowPtr) pDrawable;
-	pPixmap = 0;
-	depth = pDrawable->depth;
-	bounds.x1 = sx + pDrawable->x;
-	bounds.y1 = sy + pDrawable->y;
-	bounds.x2 = bounds.x1 + w;
-	bounds.y2 = bounds.y1 + h;
-	REGION_INIT(pScreen, &Remaining, &bounds, 0);
-	for (;;)
- 	{
-	    bounds.x1 = sx + pDrawable->x - pWin->drawable.x;
-	    bounds.y1 = sy + pDrawable->y - pWin->drawable.y;
-	    bounds.x2 = bounds.x1 + w;
-	    bounds.y2 = bounds.y1 + h;
-	    if (pWin->viewable && pWin->backStorage &&
-		pWin->drawable.depth == depth &&
-	        (RECT_IN_REGION(pScreen, &(pWindowPriv =
-		    (miBSWindowPtr) pWin->backStorage)->SavedRegion,
-		    &bounds) != rgnOUT ||
-		 RECT_IN_REGION(pScreen, &Remaining,
-		  REGION_EXTENTS(pScreen, &pWin->borderSize)) != rgnOUT))
-	    {
-		if (!pPixmap)
-		{
-		    XID	subWindowMode = IncludeInferiors;
-		    int	x, y;
-
-		    pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, depth);
-		    if (!pPixmap)
-			goto punt;
-		    pGC = GetScratchGC (depth, pScreen);
-		    if (!pGC)
-		    {
-			(*pScreen->DestroyPixmap) (pPixmap);
-			goto punt;
-		    }
-		    ChangeGC (pGC, GCSubwindowMode, &subWindowMode);
-		    ValidateGC ((DrawablePtr)pPixmap, pGC);
-		    REGION_NULL(pScreen, &Border);
-		    REGION_NULL(pScreen, &Inside);
-		    pSrcWin = (WindowPtr) pDrawable;
-		    x = sx;
-		    y = sy;
-		    if (pSrcWin->parent)
-		    {
-			x += pSrcWin->origin.x;
-			y += pSrcWin->origin.y;
-			pSrcWin = pSrcWin->parent;
-		    }
-		    (*pGC->ops->CopyArea) ((DrawablePtr)pSrcWin,
- 					    (DrawablePtr)pPixmap, pGC,
-					    x, y, w, h,
-					    0, 0);
-		    REGION_SUBTRACT(pScreen, &Remaining, &Remaining,
-				    &((WindowPtr) pDrawable)->borderClip);
-		}
-
-		REGION_INTERSECT(pScreen, &Inside, &Remaining, &pWin->winSize);
-		REGION_TRANSLATE(pScreen, &Inside,
-					     -pWin->drawable.x,
- 					     -pWin->drawable.y);
-		REGION_INTERSECT(pScreen, &Inside, &Inside,
-				 &pWindowPriv->SavedRegion);
-
-		/* offset of sub-window in GetImage pixmap */
-		xoff = pWin->drawable.x - pDrawable->x - sx;
-		yoff = pWin->drawable.y - pDrawable->y - sy;
-
-		if (REGION_NUM_RECTS(&Inside) > 0)
-		{
-		    switch (pWindowPriv->status)
-		    {
-		    case StatusContents:
-			pBox = REGION_RECTS(&Inside);
-			for (n = REGION_NUM_RECTS(&Inside); --n >= 0;)
-			{
-			    (*pGC->ops->CopyArea) (
-				(DrawablePtr)pWindowPriv->pBackingPixmap,
-						   (DrawablePtr)pPixmap, pGC,
-						   pBox->x1 - pWindowPriv->x,
-						   pBox->y1 - pWindowPriv->y,
-						   pBox->x2 - pBox->x1,
-						   pBox->y2 - pBox->y1,
-						   pBox->x1 + xoff,
-						   pBox->y1 + yoff);
-			    ++pBox;
-			}
-			break;
-		    case StatusVirtual:
-		    case StatusVDirty:
-			if (pWindowPriv->backgroundState == BackgroundPixmap ||
-			    pWindowPriv->backgroundState == BackgroundPixel)
-			miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Inside,
-					    xoff, yoff,
-					    (int) pWindowPriv->backgroundState,
-					    pWindowPriv->background, ~0L);
-			break;
-		    }
-		}
-		REGION_SUBTRACT(pScreen, &Border, &pWin->borderSize,
-				&pWin->winSize);
-		REGION_INTERSECT(pScreen, &Border, &Border, &Remaining);
-		if (REGION_NUM_RECTS(&Border) > 0)
-		{
-		    REGION_TRANSLATE(pScreen, &Border, -pWin->drawable.x,
-						  -pWin->drawable.y);
-		    miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Border,
-				    	xoff, yoff,
-				    	pWin->borderIsPixel ? (int)BackgroundPixel : (int)BackgroundPixmap,
-				    	pWin->border, ~0L);
-		}
-	    }
-
-	    if (pWin->viewable && pWin->firstChild)
-		pWin = pWin->firstChild;
-	    else
-	    {
-		while (!pWin->nextSib && pWin != (WindowPtr) pDrawable)
-		    pWin = pWin->parent;
-		if (pWin == (WindowPtr) pDrawable)
-		    break;
-		pWin = pWin->nextSib;
-	    }
-	}
-
-	REGION_UNINIT(pScreen, &Remaining);
-
-	if (pPixmap)
-	{
-	    REGION_UNINIT(pScreen, &Border);
-	    REGION_UNINIT(pScreen, &Inside);
-	    (*pScreen->GetImage) ((DrawablePtr) pPixmap,
-		0, 0, w, h, format, planemask, pdstLine);
-	    (*pScreen->DestroyPixmap) (pPixmap);
-	    FreeScratchGC (pGC);
-	}
-	else
-	{
-	    goto punt;
-	}
-    }
-    else
-    {
-punt:	;
-	(*pScreen->GetImage) (pDrawable, sx, sy, w, h,
-			      format, planemask, pdstLine);
-    }
-
-    SCREEN_EPILOGUE (pScreen, GetImage, miBSGetImage);
-}
-
-static void
-miBSGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
-    DrawablePtr	pDrawable;
-    int		wMax;
-    DDXPointPtr	ppt;
-    int		*pwidth;
-    int		nspans;
-    char	*pdstStart;
-{
-    ScreenPtr		    pScreen = pDrawable->pScreen;
-    BoxRec		    bounds;
-    int			    i;
-    WindowPtr		    pWin;
-    int			    dx, dy;
-    
-    SCREEN_PROLOGUE (pScreen, GetSpans);
-
-    if (pDrawable->type != DRAWABLE_PIXMAP && ((WindowPtr) pDrawable)->backStorage)
-    {
-	PixmapPtr	pPixmap;
-	miBSWindowPtr	pWindowPriv;
-	GCPtr		pGC;
-
-	pWin = (WindowPtr) pDrawable;
-	pWindowPriv = (miBSWindowPtr) pWin->backStorage;
-	pPixmap = pWindowPriv->pBackingPixmap;
-
-    	bounds.x1 = ppt->x;
-    	bounds.y1 = ppt->y;
-    	bounds.x2 = bounds.x1 + *pwidth;
-    	bounds.y2 = ppt->y;
-    	for (i = 0; i < nspans; i++)
-    	{
-	    if (ppt[i].x < bounds.x1)
-	    	bounds.x1 = ppt[i].x;
-	    if (ppt[i].x + pwidth[i] > bounds.x2)
-	    	bounds.x2 = ppt[i].x + pwidth[i];
-	    if (ppt[i].y < bounds.y1)
-	    	bounds.y1 = ppt[i].y;
-	    else if (ppt[i].y > bounds.y2)
-	    	bounds.y2 = ppt[i].y;
-    	}
-    
-    	switch (RECT_IN_REGION(pScreen, &pWindowPriv->SavedRegion, &bounds))
- 	{
-	case rgnPART:
-	    if (!pPixmap)
-	    {
-		miCreateBSPixmap (pWin, NullBox);
-		if (!(pPixmap = pWindowPriv->pBackingPixmap))
-		    break;
-	    }
-	    pWindowPriv->status = StatusNoPixmap;
-	    pGC = GetScratchGC(pPixmap->drawable.depth,
-			       pPixmap->drawable.pScreen);
-	    if (pGC)
-	    {
-		ValidateGC ((DrawablePtr) pPixmap, pGC);
-		(*pGC->ops->CopyArea)
-		    (pDrawable, (DrawablePtr) pPixmap, pGC,
-		    bounds.x1, bounds.y1,
-		    bounds.x2 - bounds.x1, bounds.y2 - bounds.y1,
-		    bounds.x1 + pPixmap->drawable.x - pWin->drawable.x -
-		     pWindowPriv->x,
-		    bounds.y1 + pPixmap->drawable.y - pWin->drawable.y -
-		     pWindowPriv->y);
-		FreeScratchGC(pGC);
-	    }
-	    pWindowPriv->status = StatusContents;
-	    /* fall through */
-	case rgnIN:
-	    if (!pPixmap)
-	    {
-		miCreateBSPixmap (pWin, NullBox);
-		if (!(pPixmap = pWindowPriv->pBackingPixmap))
-		    break;
-	    }
-	    dx = pPixmap->drawable.x - pWin->drawable.x - pWindowPriv->x;
-	    dy = pPixmap->drawable.y - pWin->drawable.y - pWindowPriv->y;
-	    for (i = 0; i < nspans; i++)
-	    {
-		ppt[i].x += dx;
-		ppt[i].y += dy;
-	    }
-	    (*pScreen->GetSpans) ((DrawablePtr) pPixmap, wMax, ppt, pwidth,
-				  nspans, pdstStart);
-	    break;
-	case rgnOUT:
-	    (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans,
-				  pdstStart);
-	    break;
-	}
-    }
-    else
-    {
-	(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-    }
-
-    SCREEN_EPILOGUE (pScreen, GetSpans, miBSGetSpans);
-}
-
-static Bool
-miBSChangeWindowAttributes (pWin, mask)
-    WindowPtr	    pWin;
-    unsigned long   mask;
-{
-    ScreenPtr	pScreen;
-    Bool	ret;
-
-    pScreen = pWin->drawable.pScreen;
-
-    SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes);
-
-    ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
-
-    if (ret && (mask & CWBackingStore))
-    {
-	if (pWin->backingStore != NotUseful || pWin->DIXsaveUnder)
-	    miBSAllocate (pWin);
-	else
-	    miBSFree (pWin);
-    }
-
-    SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, miBSChangeWindowAttributes);
-
-    return ret;
-}
-
-/*
- * GC Create wrapper.  Set up the cheap GC func wrappers to track
- * GC validation on BackingStore windows
- */
-
-static Bool
-miBSCreateGC (pGC)
-    GCPtr   pGC;
-{
-    ScreenPtr	pScreen = pGC->pScreen;
-    Bool	ret;
-
-    SCREEN_PROLOGUE (pScreen, CreateGC);
-    
-    if ( (ret = (*pScreen->CreateGC) (pGC)) )
-    {
-    	pGC->devPrivates[miBSGCIndex].ptr = (pointer) pGC->funcs;
-    	pGC->funcs = &miBSCheapGCFuncs;
-    }
-
-    SCREEN_EPILOGUE (pScreen, CreateGC, miBSCreateGC);
-
-    return ret;
-}
-
-static Bool
-miBSDestroyWindow (pWin)
-    WindowPtr	pWin;
-{
-    ScreenPtr	pScreen = pWin->drawable.pScreen;
-    Bool	ret;
-
-    SCREEN_PROLOGUE (pScreen, DestroyWindow);
-    
-    ret = (*pScreen->DestroyWindow) (pWin);
-
-    miBSFree (pWin);
-
-    SCREEN_EPILOGUE (pScreen, DestroyWindow, miBSDestroyWindow);
-
-    return ret;
-}
-
-/*
- * cheap GC func wrappers.  Simply track validation on windows
- * with backing store to enable the real func/op wrappers
- */
-
-static void
-miBSCheapValidateGC (pGC, stateChanges, pDrawable)
-    GCPtr	    pGC;
-    unsigned long   stateChanges;
-    DrawablePtr	    pDrawable;
-{
-    CHEAP_FUNC_PROLOGUE (pGC);
-    
-    if (pDrawable->type != DRAWABLE_PIXMAP &&
-        ((WindowPtr) pDrawable)->backStorage != NULL &&
-	miBSCreateGCPrivate (pGC))
-    {
-	(*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
-    }
-    else
-    {
-	(*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
-
-	/* rewrap funcs as Validate may have changed them */
-	pGC->devPrivates[miBSGCIndex].ptr = (pointer) pGC->funcs;
-
-	CHEAP_FUNC_EPILOGUE (pGC);
-    }
-}
-
-static void
-miBSCheapChangeGC (pGC, mask)
-    GCPtr   pGC;
-    unsigned long   mask;
-{
-    CHEAP_FUNC_PROLOGUE (pGC);
-
-    (*pGC->funcs->ChangeGC) (pGC, mask);
-
-    CHEAP_FUNC_EPILOGUE (pGC);
-}
-
-static void
-miBSCheapCopyGC (pGCSrc, mask, pGCDst)
-    GCPtr   pGCSrc, pGCDst;
-    unsigned long   mask;
-{
-    CHEAP_FUNC_PROLOGUE (pGCDst);
-
-    (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
-
-    CHEAP_FUNC_EPILOGUE (pGCDst);
-}
-
-static void
-miBSCheapDestroyGC (pGC)
-    GCPtr   pGC;
-{
-    CHEAP_FUNC_PROLOGUE (pGC);
-
-    (*pGC->funcs->DestroyGC) (pGC);
-
-    /* leave it unwrapped */
-}
-
-static void
-miBSCheapChangeClip (pGC, type, pvalue, nrects)
-    GCPtr   pGC;
-    int		type;
-    pointer	pvalue;
-    int		nrects;
-{
-    CHEAP_FUNC_PROLOGUE (pGC);
-
-    (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
-
-    CHEAP_FUNC_EPILOGUE (pGC);
-}
-
-static void
-miBSCheapCopyClip(pgcDst, pgcSrc)
-    GCPtr pgcDst, pgcSrc;
-{
-    CHEAP_FUNC_PROLOGUE (pgcDst);
-
-    (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
-
-    CHEAP_FUNC_EPILOGUE (pgcDst);
-}
-
-static void
-miBSCheapDestroyClip(pGC)
-    GCPtr	pGC;
-{
-    CHEAP_FUNC_PROLOGUE (pGC);
-
-    (* pGC->funcs->DestroyClip)(pGC);
-
-    CHEAP_FUNC_EPILOGUE (pGC);
-}
-
-/*
- * create the full func/op wrappers for a GC
- */
-
-static Bool
-miBSCreateGCPrivate (pGC)
-    GCPtr   pGC;
-{
-    miBSGCRec	*pPriv;
-
-    pPriv = (miBSGCRec *) xalloc (sizeof (miBSGCRec));
-    if (!pPriv)
-	return FALSE;
-    pPriv->pBackingGC = NULL;
-    pPriv->guarantee = GuaranteeNothing;
-    pPriv->serialNumber = 0;
-    pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1;
-    pPriv->wrapOps = pGC->ops;
-    pPriv->wrapFuncs = pGC->funcs;
-    pGC->funcs = &miBSGCFuncs;
-    pGC->ops = &miBSGCOps;
-    pGC->devPrivates[miBSGCIndex].ptr = (pointer) pPriv;
-    return TRUE;
-}
-
-static void
-miBSDestroyGCPrivate (GCPtr pGC)
-{
-    miBSGCRec	*pPriv;
-
-    pPriv = (miBSGCRec *) pGC->devPrivates[miBSGCIndex].ptr;
-    if (pPriv)
-    {
-	pGC->devPrivates[miBSGCIndex].ptr = (pointer) pPriv->wrapFuncs;
-	pGC->funcs = &miBSCheapGCFuncs;
-	pGC->ops = pPriv->wrapOps;
-	if (pPriv->pBackingGC)
-	    FreeGC (pPriv->pBackingGC, (GContext) 0);
-	xfree ((pointer) pPriv);
-    }
-}
-
-/*
- * GC ops -- wrap each GC operation with our own function
- */
-
-/*-
- *-----------------------------------------------------------------------
- * miBSFillSpans --
- *	Perform a FillSpans, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		nInit;			/* number of spans to fill */
-    DDXPointPtr pptInit;		/* pointer to list of start points */
-    int		*pwidthInit;		/* pointer to list of n widths */
-    int 	fSorted;
-{
-    DDXPointPtr	pptCopy, pptReset;
-    int 	*pwidthCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(nInit*sizeof(DDXPointRec));
-    pwidthCopy=(int *)ALLOCATE_LOCAL(nInit*sizeof(int));
-    if (pptCopy && pwidthCopy)
-    {
-	copyData(pptInit, pptCopy, nInit, MoreCopy0);
-	memmove((char *)pwidthCopy,(char *)pwidthInit,nInit*sizeof(int));
-
-	(* pGC->ops->FillSpans)(pDrawable, pGC, nInit, pptInit,
-			     pwidthInit, fSorted);
-	if (pGC->miTranslate)
-	{
-	    int	dx, dy;
-	    int	nReset;
-
-	    pptReset = pptCopy;
-	    dx = pDrawable->x - pBackingDrawable->x;
-	    dy = pDrawable->y - pBackingDrawable->y;
-	    nReset = nInit;
-	    while (nReset--)
-	    {
-		pptReset->x -= dx;
-		pptReset->y -= dy;
-		++pptReset;
-	    }
-	}
-	(* pBackingGC->ops->FillSpans)(pBackingDrawable,
-				  pBackingGC, nInit, pptCopy, pwidthCopy,
-				  fSorted);
-    }
-    if (pwidthCopy) DEALLOCATE_LOCAL(pwidthCopy);
-    if (pptCopy) DEALLOCATE_LOCAL(pptCopy);
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSSetSpans --
- *	Perform a SetSpans, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted)
-    DrawablePtr		pDrawable;
-    GCPtr		pGC;
-    char		*psrc;
-    DDXPointPtr 	ppt;
-    int			*pwidth;
-    int			nspans;
-    int			fSorted;
-{
-    DDXPointPtr	pptCopy, pptReset;
-    int 	*pwidthCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(nspans*sizeof(DDXPointRec));
-    pwidthCopy=(int *)ALLOCATE_LOCAL(nspans*sizeof(int));
-    if (pptCopy && pwidthCopy)
-    {
-	copyData(ppt, pptCopy, nspans, MoreCopy0);
-	memmove((char *)pwidthCopy,(char *)pwidth,nspans*sizeof(int));
-
-	(* pGC->ops->SetSpans)(pDrawable, pGC, psrc, ppt, pwidth,
-			       nspans, fSorted);
-	if (pGC->miTranslate)
-	{
-	    int	dx, dy;
-	    int	nReset;
-
-	    pptReset = pptCopy;
-	    dx = pDrawable->x - pBackingDrawable->x;
-	    dy = pDrawable->y - pBackingDrawable->y;
-	    nReset = nspans;
-	    while (nReset--)
-	    {
-		pptReset->x -= dx;
-		pptReset->y -= dy;
-		++pptReset;
-	    }
-	}
-	(* pBackingGC->ops->SetSpans)(pBackingDrawable, pBackingGC,
-				psrc, pptCopy, pwidthCopy, nspans, fSorted);
-    }
-    if (pwidthCopy) DEALLOCATE_LOCAL(pwidthCopy);
-    if (pptCopy) DEALLOCATE_LOCAL(pptCopy);
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPutImage --
- *	Perform a PutImage, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits)
-    DrawablePtr	  pDrawable;
-    GCPtr   	  pGC;
-    int		  depth;
-    int	    	  x;
-    int	    	  y;
-    int	    	  w;
-    int	    	  h;
-    int		  leftPad;
-    int	    	  format;
-    char    	  *pBits;
-{
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    (*pGC->ops->PutImage)(pDrawable, pGC,
-		     depth, x, y, w, h, leftPad, format, pBits);
-    (*pBackingGC->ops->PutImage)(pBackingDrawable, pBackingGC,
-		     depth, x - pBackingStore->x, y - pBackingStore->y,
-		     w, h, leftPad, format, pBits);
-
-    EPILOGUE (pGC);
-}
-
-typedef RegionPtr (* CopyAreaProcPtr)(DrawablePtr, DrawablePtr, GCPtr,
-				      int, int, int, int, int, int);
-typedef RegionPtr (* CopyPlaneProcPtr)(DrawablePtr, DrawablePtr, GCPtr,
-				      int, int, int, int, int, int,
-				      unsigned long bitPlane);
-/*-
- *-----------------------------------------------------------------------
- * miBSDoCopy --
- *	Perform a CopyArea or CopyPlane within a window that has backing
- *	store enabled.
- *
- * Results:
- *	TRUE if the copy was performed or FALSE if a regular one should
- *	be done.
- *
- * Side Effects:
- *	Things are copied (no s***!)
- *
- * Notes:
- *	The idea here is to form two regions that cover the source box.
- *	One contains the exposed rectangles while the other contains
- *	the obscured ones. An array of <box, drawable> pairs is then
- *	formed where the <box> indicates the area to be copied and the
- *	<drawable> indicates from where it is to be copied (exposed regions
- *	come from the screen while obscured ones come from the backing
- *	pixmap). The array 'sequence' is then filled with the indices of
- *	the pairs in the order in which they should be copied to prevent
- *	things from getting screwed up. A call is also made through the
- *	backingGC to take care of any copying into the backing pixmap.
- *
- *-----------------------------------------------------------------------
- */
-static Bool
-miBSDoCopy(
-    WindowPtr	  pWin,	    	    /* Window being scrolled */
-    GCPtr   	  pGC,	    	    /* GC we're called through */
-    int	    	  srcx,	    	    /* X of source rectangle */
-    int	    	  srcy,	    	    /* Y of source rectangle */
-    int	    	  w,	    	    /* Width of source rectangle */
-    int	    	  h,	    	    /* Height of source rectangle */
-    int	    	  dstx,	    	    /* X of destination rectangle */
-    int	    	  dsty,	    	    /* Y of destination rectangle */
-    unsigned long plane,    	    /* Plane to copy (0 for CopyArea) */
-    CopyPlaneProcPtr copyProc,      /* Procedure to call to perform the copy */
-    RegionPtr	  *ppRgn)	    /* resultant Graphics Expose region */
-{
-    RegionPtr 	    	pRgnExp;    /* Exposed region */
-    RegionPtr	  	pRgnObs;    /* Obscured region */
-    BoxRec	  	box;	    /* Source box (screen coord) */
-    struct BoxDraw {
-	BoxPtr	  	pBox;	    	/* Source box */
-	enum {
-	    win, pix
-	}   	  	source;	    	/* Place from which to copy */
-    }	    	  	*boxes;	    /* Array of box/drawable pairs covering
-				     * source box. */
-    int  	  	*sequence;  /* Sequence of boxes to move */
-    int  		i, j, k, l, y;
-    BoxPtr		pBox;
-    int	    	  	dx, dy, nrects;
-    Bool    	  	graphicsExposures;
-    CopyPlaneProcPtr  	pixCopyProc;
-    int			numRectsExp, numRectsObs;
-    BoxPtr		pBoxExp, pBoxObs;
-
-    SETUP_BACKING (pWin, pGC);
-    (void)oldFuncs;
-
-    /*
-     * Create a region of exposed boxes in pRgnExp.
-     */
-    box.x1 = srcx + pWin->drawable.x;
-    box.x2 = box.x1 + w;
-    box.y1 = srcy + pWin->drawable.y;
-    box.y2 = box.y1 + h;
-    
-    pRgnExp = REGION_CREATE(pGC->pScreen, &box, 1);
-    REGION_INTERSECT(pGC->pScreen, pRgnExp, pRgnExp, &pWin->clipList);
-    pRgnObs = REGION_CREATE(pGC->pScreen, NULL, 1);
-    REGION_INVERSE( pGC->pScreen, pRgnObs, pRgnExp, &box);
-
-    /*
-     * Translate regions into window coordinates for proper calls
-     * to the copyProc, then make sure none of the obscured region sticks
-     * into invalid areas of the backing pixmap.
-     */
-    REGION_TRANSLATE(pGC->pScreen, pRgnExp,
-				      -pWin->drawable.x,
-				      -pWin->drawable.y);
-    REGION_TRANSLATE(pGC->pScreen, pRgnObs,
-				      -pWin->drawable.x,
-				      -pWin->drawable.y);
-    REGION_INTERSECT(pGC->pScreen, pRgnObs, pRgnObs, &pBackingStore->SavedRegion);
-
-    /*
-     * If the obscured region is empty, there's no point being fancy.
-     */
-    if (!REGION_NOTEMPTY(pGC->pScreen, pRgnObs))
-    {
-	REGION_DESTROY(pGC->pScreen, pRgnExp);
-	REGION_DESTROY(pGC->pScreen, pRgnObs);
-
-	return (FALSE);
-    }
-
-    numRectsExp = REGION_NUM_RECTS(pRgnExp);
-    pBoxExp = REGION_RECTS(pRgnExp);
-    pBoxObs = REGION_RECTS(pRgnObs);
-    numRectsObs = REGION_NUM_RECTS(pRgnObs);
-    nrects = numRectsExp + numRectsObs;
-    
-    boxes = (struct BoxDraw *)ALLOCATE_LOCAL(nrects * sizeof(struct BoxDraw));
-    sequence = (int *) ALLOCATE_LOCAL(nrects * sizeof(int));
-    *ppRgn = NULL;
-
-    if (!boxes || !sequence)
-    {
-	if (sequence) DEALLOCATE_LOCAL(sequence);
-	if (boxes) DEALLOCATE_LOCAL(boxes);
-	REGION_DESTROY(pGC->pScreen, pRgnExp);
-	REGION_DESTROY(pGC->pScreen, pRgnObs);
-
-	return(TRUE);
-    }
-
-    /*
-     * Order the boxes in the two regions so we know from which drawable
-     * to copy which box, storing the result in the boxes array
-     */
-    for (i = 0, j = 0, k = 0;
-	 (i < numRectsExp) && (j < numRectsObs);
-	 k++)
-    {
-	if (pBoxExp[i].y1 < pBoxObs[j].y1)
-	{
-	    boxes[k].pBox = &pBoxExp[i];
-	    boxes[k].source = win;
-	    i++;
-	}
-	else if ((pBoxObs[j].y1 < pBoxExp[i].y1) ||
-		 (pBoxObs[j].x1 < pBoxExp[i].x1))
-	{
-	    boxes[k].pBox = &pBoxObs[j];
-	    boxes[k].source = pix;
-	    j++;
-	}
-	else
-	{
-	    boxes[k].pBox = &pBoxExp[i];
-	    boxes[k].source = win;
-	    i++;
-	}
-    }
-
-    /*
-     * Catch any leftover boxes from either region (note that only
-     * one can have leftover boxes...)
-     */
-    if (i != numRectsExp)
-    {
-	do
-	{
-	    boxes[k].pBox = &pBoxExp[i];
-	    boxes[k].source = win;
-	    i++;
-	    k++;
-	} while (i < numRectsExp);
-
-    }
-    else
-    {
-	do
-	{
-	    boxes[k].pBox = &pBoxObs[j];
-	    boxes[k].source = pix;
-	    j++;
-	    k++;
-	} while (j < numRectsObs);
-    }
-    
-    if (dsty <= srcy)
-    {
-	/*
-	 * Scroll up or vertically stationary, so vertical order is ok.
-	 */
-	if (dstx <= srcx)
-	{
-	    /*
-	     * Scroll left or horizontally stationary, so horizontal order
-	     * is ok as well.
-	     */
-	    for (i = 0; i < nrects; i++)
-	    {
-		sequence[i] = i;
-	    }
-	}
-	else
-	{
-	    /*
-	     * Scroll right. Need to reverse the rectangles within each
-	     * band.
-	     */
-	    for (i = 0, j = 1, k = 0;
-		 i < nrects;
-		 j = i + 1, k = i)
-	    {
-		y = boxes[i].pBox->y1;
-		while ((j < nrects) && (boxes[j].pBox->y1 == y))
-		{
-		    j++;
-		}
-		for (j--; j >= k; j--, i++)
-		{
-		    sequence[i] = j;
-		}
-	    }
-	}
-    }
-    else
-    {
-	/*
-	 * Scroll down. Must reverse vertical banding, at least.
-	 */
-	if (dstx < srcx)
-	{
-	    /*
-	     * Scroll left. Horizontal order is ok.
-	     */
-	    for (i = nrects - 1, j = i - 1, k = i, l = 0;
-		 i >= 0;
-		 j = i - 1, k = i)
-	    {
-		/*
-		 * Find extent of current horizontal band, then reverse
-		 * the order of the whole band.
-		 */
-		y = boxes[i].pBox->y1;
-		while ((j >= 0) && (boxes[j].pBox->y1 == y))
-		{
-		    j--;
-		}
-		for (j++; j <= k; j++, i--, l++)
-		{
-		    sequence[l] = j;
-		}
-	    }
-	}
-	else
-	{
-	    /*
-	     * Scroll right or horizontal stationary.
-	     * Reverse horizontal order as well (if stationary, horizontal
-	     * order can be swapped without penalty and this is faster
-             * to compute).
-	     */
-	    for (i = 0, j = nrects - 1; i < nrects; i++, j--)
-	    {
-		sequence[i] = j;
-	    }
-	}
-    }
-	    
-    /*
-     * XXX: To avoid getting multiple NoExpose events from this operation,
-     * we turn OFF graphicsExposures in the gc and deal with any uncopied
-     * areas later, if there's something not in backing-store.
-     */
-
-    graphicsExposures = pGC->graphicsExposures;
-    pGC->graphicsExposures = FALSE;
-    
-    dx = dstx - srcx;
-    dy = dsty - srcy;
-
-    /*
-     * Figure out which copy procedure to use from the backing GC. Note we
-     * must do this because some implementations (sun's, e.g.) have
-     * pBackingGC a fake GC with the real one below it, thus the devPriv for
-     * pBackingGC won't be what the output library expects.
-     */
-    if (plane != 0)
-    {
-	pixCopyProc = pBackingGC->ops->CopyPlane;
-    }
-    else
-    {
-	pixCopyProc = (CopyPlaneProcPtr)pBackingGC->ops->CopyArea;
-    }
-    
-    for (i = 0; i < nrects; i++)
-    {
-	pBox = boxes[sequence[i]].pBox;
-	
-	/*
-	 * If we're copying from the pixmap, we need to place its contents
-	 * onto the screen before scrolling the pixmap itself. If we're copying
-	 * from the window, we need to copy its contents into the pixmap before
-	 * we scroll the window itself.
-	 */
-	if (boxes[sequence[i]].source == pix)
-	{
-	    (void) (* copyProc) (pBackingDrawable, &(pWin->drawable), pGC,
-			  pBox->x1 - pBackingStore->x,
-			  pBox->y1 - pBackingStore->y,
-			  pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
-			  pBox->x1 + dx, pBox->y1 + dy, plane);
-	    (void) (* pixCopyProc) (pBackingDrawable, pBackingDrawable, pBackingGC,
-			     pBox->x1 - pBackingStore->x,
-			     pBox->y1 - pBackingStore->y,
-			     pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
-			     pBox->x1 + dx - pBackingStore->x,
-			     pBox->y1 + dy - pBackingStore->y, plane);
-	}
-	else
-	{
-	    (void) (* pixCopyProc) (&(pWin->drawable), pBackingDrawable, pBackingGC,
-			     pBox->x1, pBox->y1,
-			     pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
-			     pBox->x1 + dx - pBackingStore->x,
-			     pBox->y1 + dy - pBackingStore->y, plane);
-	    (void) (* copyProc) (&(pWin->drawable), &(pWin->drawable), pGC,
-			  pBox->x1, pBox->y1,
-			  pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
-			  pBox->x1 + dx, pBox->y1 + dy, plane);
-	}
-    }
-    DEALLOCATE_LOCAL(sequence);
-    DEALLOCATE_LOCAL(boxes);
-
-    pGC->graphicsExposures = graphicsExposures;
-    /*
-     * Form union of rgnExp and rgnObs and see if covers entire area
-     * to be copied.  Store the resultant region for miBSCopyArea
-     * to return to dispatch which will send the appropriate expose
-     * events.
-     */
-    REGION_UNION(pGC->pScreen, pRgnExp, pRgnExp, pRgnObs);
-    box.x1 = srcx;
-    box.x2 = srcx + w;
-    box.y1 = srcy;
-    box.y2 = srcy + h;
-    if (RECT_IN_REGION(pGC->pScreen, pRgnExp, &box) == rgnIN)
-    {
-	REGION_EMPTY(pGC->pScreen, pRgnExp);
-    }
-    else
-    {
-	REGION_INVERSE( pGC->pScreen, pRgnExp, pRgnExp, &box);
-	REGION_TRANSLATE( pGC->pScreen, pRgnExp,
-					   dx + pWin->drawable.x,
- 					   dy + pWin->drawable.y);
-	REGION_INTERSECT( pGC->pScreen, pRgnObs, pRgnExp, &pWin->clipList);
-	(*pWin->drawable.pScreen->PaintWindowBackground) (pWin,
-						pRgnObs, PW_BACKGROUND);
-	REGION_TRANSLATE( pGC->pScreen, pRgnExp,
-					   -pWin->drawable.x,
- 					   -pWin->drawable.y);
-	miBSClearBackingRegion (pWin, pRgnExp);
-    }
-    if (graphicsExposures)
-	*ppRgn = pRgnExp;
-    else
-	REGION_DESTROY(pGC->pScreen, pRgnExp);
-    REGION_DESTROY(pGC->pScreen, pRgnObs);
-
-    return (TRUE);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSCopyArea --
- *	Perform a CopyArea from the source to the destination, extracting
- *	from the source's backing-store and storing into the destination's
- *	backing-store without messing anything up. If the source and
- *	destination are different, there's not too much to worry about:
- *	we can just issue several calls to the regular CopyArea function.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static RegionPtr
-miBSCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty)
-    DrawablePtr	  pSrc;
-    DrawablePtr	  pDst;
-    GCPtr   	  pGC;
-    int	    	  srcx;
-    int	    	  srcy;
-    int	    	  w;
-    int	    	  h;
-    int	    	  dstx;
-    int	    	  dsty;
-{
-    BoxPtr	pExtents;
-    long	dx, dy;
-    int		bsrcx, bsrcy, bw, bh, bdstx, bdsty;
-    RegionPtr	pixExposed = 0, winExposed = 0;
-
-    SETUP_BACKING(pDst, pGC);
-
-    PROLOGUE(pGC);
-
-    if ((pSrc != pDst) ||
-	(!miBSDoCopy((WindowPtr)pSrc, pGC, srcx, srcy, w, h, dstx, dsty,
-		     (unsigned long) 0, (CopyPlaneProcPtr)pGC->ops->CopyArea,
-		     &winExposed)))
-    {
-	/*
-	 * always copy to the backing store first, miBSDoCopy
-	 * returns FALSE if the *source* region is disjoint
-	 * from the backing store saved region.  So, copying
-	 * *to* the backing store is always safe
-	 */
-	if (pGC->clientClipType != CT_PIXMAP)
-	{
-	    /*
-	     * adjust srcx, srcy, w, h, dstx, dsty to be clipped to
-	     * the backing store.  An unnecessary optimisation,
-	     * but a useful one when GetSpans is slow.
-	     */
-	    pExtents = REGION_EXTENTS(pDst->pScreen,
-				      (RegionPtr)pBackingGC->clientClip);
-	    bsrcx = srcx;
-	    bsrcy = srcy;
-	    bw = w;
-	    bh = h;
-	    bdstx = dstx;
-	    bdsty = dsty;
-	    dx = pExtents->x1 - bdstx;
-	    if (dx > 0)
-	    {
-		bsrcx += dx;
-		bdstx += dx;
-		bw -= dx;
-	    }
-	    dy = pExtents->y1 - bdsty;
-	    if (dy > 0)
-	    {
-		bsrcy += dy;
-		bdsty += dy;
-		bh -= dy;
-	    }
-	    dx = (bdstx + bw) - pExtents->x2;
-	    if (dx > 0)
-		bw -= dx;
-	    dy = (bdsty + bh) - pExtents->y2;
-	    if (dy > 0)
-		bh -= dy;
-	    if (bw > 0 && bh > 0)
-		pixExposed = (* pBackingGC->ops->CopyArea) (pSrc, 
-			    pBackingDrawable, pBackingGC, 
-			    bsrcx, bsrcy, bw, bh, bdstx - pBackingStore->x,
-			    bdsty - pBackingStore->y);
-	}
-	else
-	    pixExposed = (* pBackingGC->ops->CopyArea) (pSrc, 
-			    pBackingDrawable, pBackingGC,
-			    srcx, srcy, w, h,
-			    dstx - pBackingStore->x, dsty - pBackingStore->y);
-
-	winExposed = (* pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
-    }
-
-    /*
-     * compute the composite graphics exposure region
-     */
-    if (winExposed)
-    {
-	if (pixExposed){
-	    REGION_UNION(pDst->pScreen, winExposed, winExposed, pixExposed);
-	    REGION_DESTROY(pDst->pScreen, pixExposed);
-	}
-    } else
-	winExposed = pixExposed;
-
-    EPILOGUE (pGC);
-
-    return winExposed;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSCopyPlane --
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static RegionPtr
-miBSCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane)
-    DrawablePtr	  pSrc;
-    DrawablePtr	  pDst;
-    GC  	 *pGC;
-    int     	  srcx,
-		  srcy;
-    int     	  w,
-		  h;
-    int     	  dstx,
-		  dsty;
-    unsigned long  plane;
+miInitializeBackingStore (ScreenPtr pScreen)
 {
-    BoxPtr	pExtents;
-    long	dx, dy;
-    int		bsrcx, bsrcy, bw, bh, bdstx, bdsty;
-    RegionPtr	winExposed = 0, pixExposed = 0;
-    SETUP_BACKING(pDst, pGC);
-
-    PROLOGUE(pGC);
-
-    if ((pSrc != pDst) ||
-	(!miBSDoCopy((WindowPtr)pSrc, pGC, srcx, srcy, w, h, dstx, dsty,
-		     plane,  pGC->ops->CopyPlane, &winExposed)))
-    {
-	/*
-	 * always copy to the backing store first, miBSDoCopy
-	 * returns FALSE if the *source* region is disjoint
-	 * from the backing store saved region.  So, copying
-	 * *to* the backing store is always safe
-	 */
-	if (pGC->clientClipType != CT_PIXMAP)
-	{
-	    /*
-	     * adjust srcx, srcy, w, h, dstx, dsty to be clipped to
-	     * the backing store.  An unnecessary optimisation,
-	     * but a useful one when GetSpans is slow.
-	     */
-	    pExtents = REGION_EXTENTS(pDst->pScreen,
-				      (RegionPtr)pBackingGC->clientClip);
-	    bsrcx = srcx;
-	    bsrcy = srcy;
-	    bw = w;
-	    bh = h;
-	    bdstx = dstx;
-	    bdsty = dsty;
-	    dx = pExtents->x1 - bdstx;
-	    if (dx > 0)
-	    {
-		bsrcx += dx;
-		bdstx += dx;
-		bw -= dx;
-	    }
-	    dy = pExtents->y1 - bdsty;
-	    if (dy > 0)
-	    {
-		bsrcy += dy;
-		bdsty += dy;
-		bh -= dy;
-	    }
-	    dx = (bdstx + bw) - pExtents->x2;
-	    if (dx > 0)
-		bw -= dx;
-	    dy = (bdsty + bh) - pExtents->y2;
-	    if (dy > 0)
-		bh -= dy;
-	    if (bw > 0 && bh > 0)
-		pixExposed = (* pBackingGC->ops->CopyPlane) (pSrc, 
-				    pBackingDrawable,
-				    pBackingGC, bsrcx, bsrcy, bw, bh,
-				    bdstx - pBackingStore->x,
-				    bdsty - pBackingStore->y, plane);
-	}
-	else
-	    pixExposed = (* pBackingGC->ops->CopyPlane) (pSrc, 
-				    pBackingDrawable,
-				    pBackingGC, srcx, srcy, w, h,
-				    dstx - pBackingStore->x,
-				    dsty - pBackingStore->y, plane);
-
-	winExposed = (* pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h,
-			      dstx, dsty, plane);
-	
-    }
-
-    /*
-     * compute the composite graphics exposure region
-     */
-    if (winExposed)
-    {
-	if (pixExposed)
-	{
-	    REGION_UNION(pDst->pScreen, winExposed, winExposed, pixExposed);
-	    REGION_DESTROY(pDst->pScreen, pixExposed);
-	}
-    } else
-	winExposed = pixExposed;
-
-    EPILOGUE (pGC);
-
-    return winExposed;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyPoint --
- *	Perform a PolyPoint, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolyPoint (pDrawable, pGC, mode, npt, pptInit)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		mode;		/* Origin or Previous */
-    int		npt;
-    xPoint 	*pptInit;
-{
-    xPoint	  *pptCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pptCopy = (xPoint *)ALLOCATE_LOCAL(npt*sizeof(xPoint));
-    if (pptCopy)
-    {
-	copyPoints(pptInit, pptCopy, npt, mode);
-
-	(* pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit);
-
-	(* pBackingGC->ops->PolyPoint) (pBackingDrawable,
-				   pBackingGC, mode, npt, pptCopy);
-
-	DEALLOCATE_LOCAL(pptCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyLines --
- *	Perform a Polylines, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolylines (pDrawable, pGC, mode, npt, pptInit)
-    DrawablePtr	  pDrawable;
-    GCPtr   	  pGC;
-    int	    	  mode;
-    int	    	  npt;
-    DDXPointPtr	  pptInit;
-{
-    DDXPointPtr	pptCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(npt*sizeof(DDXPointRec));
-    if (pptCopy)
-    {
-	copyPoints(pptInit, pptCopy, npt, mode);
-
-	(* pGC->ops->Polylines)(pDrawable, pGC, mode, npt, pptInit);
-	(* pBackingGC->ops->Polylines)(pBackingDrawable,
-				  pBackingGC, mode, npt, pptCopy);
-	DEALLOCATE_LOCAL(pptCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolySegment --
- *	Perform a PolySegment, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolySegment(pDrawable, pGC, nseg, pSegs)
-    DrawablePtr pDrawable;
-    GCPtr 	pGC;
-    int		nseg;
-    xSegment	*pSegs;
-{
-    xSegment	*pSegsCopy;
-
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pSegsCopy = (xSegment *)ALLOCATE_LOCAL(nseg*sizeof(xSegment));
-    if (pSegsCopy)
-    {
-	copyData(pSegs, pSegsCopy, nseg << 1, MoreCopy0);
-
-	(* pGC->ops->PolySegment)(pDrawable, pGC, nseg, pSegs);
-	(* pBackingGC->ops->PolySegment)(pBackingDrawable,
-				    pBackingGC, nseg, pSegsCopy);
-
-	DEALLOCATE_LOCAL(pSegsCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyRectangle --
- *	Perform a PolyRectangle, routing output to backing-store as needed.
- *
- * Results:
- *	None
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolyRectangle(pDrawable, pGC, nrects, pRects)
-    DrawablePtr	pDrawable;
-    GCPtr	pGC;
-    int		nrects;
-    xRectangle	*pRects;
-{
-    xRectangle	*pRectsCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pRectsCopy =(xRectangle *)ALLOCATE_LOCAL(nrects*sizeof(xRectangle));
-    if (pRectsCopy)
-    {
-	copyData(pRects, pRectsCopy, nrects, MoreCopy2);
-
-	(* pGC->ops->PolyRectangle)(pDrawable, pGC, nrects, pRects);
-	(* pBackingGC->ops->PolyRectangle)(pBackingDrawable,
-				      pBackingGC, nrects, pRectsCopy);
-
-	DEALLOCATE_LOCAL(pRectsCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyArc --
- *	Perform a PolyArc, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolyArc(pDrawable, pGC, narcs, parcs)
-    DrawablePtr	pDrawable;
-    GCPtr	pGC;
-    int		narcs;
-    xArc	*parcs;
-{
-    xArc  *pArcsCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pArcsCopy = (xArc *)ALLOCATE_LOCAL(narcs*sizeof(xArc));
-    if (pArcsCopy)
-    {
-	copyData(parcs, pArcsCopy, narcs, MoreCopy4);
-
-	(* pGC->ops->PolyArc)(pDrawable, pGC, narcs, parcs);
-	(* pBackingGC->ops->PolyArc)(pBackingDrawable, pBackingGC,
-				narcs, pArcsCopy);
-
-	DEALLOCATE_LOCAL(pArcsCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSFillPolygon --
- *	Perform a FillPolygon, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSFillPolygon(pDrawable, pGC, shape, mode, count, pPts)
-    DrawablePtr		pDrawable;
-    GCPtr		pGC;
-    int			shape, mode;
-    int			count;
-    DDXPointPtr		pPts;
-{
-    DDXPointPtr	pPtsCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pPtsCopy = (DDXPointPtr)ALLOCATE_LOCAL(count*sizeof(DDXPointRec));
-    if (pPtsCopy)
-    {
-	copyPoints(pPts, pPtsCopy, count, mode);
-	(* pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, count, pPts);
-	(* pBackingGC->ops->FillPolygon)(pBackingDrawable,
-				    pBackingGC, shape, mode,
-				    count, pPtsCopy);
-
-	DEALLOCATE_LOCAL(pPtsCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyFillRect --
- *	Perform a PolyFillRect, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		nrectFill; 	/* number of rectangles to fill */
-    xRectangle	*prectInit;  	/* Pointer to first rectangle to fill */
-{
-    xRectangle	*pRectCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pRectCopy =
-	(xRectangle *)ALLOCATE_LOCAL(nrectFill*sizeof(xRectangle));
-    if (pRectCopy)
-    {
-	copyData(prectInit, pRectCopy, nrectFill, MoreCopy2);
-
-	(* pGC->ops->PolyFillRect)(pDrawable, pGC, nrectFill, prectInit);
-	(* pBackingGC->ops->PolyFillRect)(pBackingDrawable,
-				     pBackingGC, nrectFill, pRectCopy);
-
-	DEALLOCATE_LOCAL(pRectCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyFillArc --
- *	Perform a PolyFillArc, routing output to backing-store as needed.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolyFillArc(pDrawable, pGC, narcs, parcs)
-    DrawablePtr	pDrawable;
-    GCPtr	pGC;
-    int		narcs;
-    xArc	*parcs;
-{
-    xArc  *pArcsCopy;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    pArcsCopy = (xArc *)ALLOCATE_LOCAL(narcs*sizeof(xArc));
-    if (pArcsCopy)
-    {
-	copyData(parcs, pArcsCopy, narcs, MoreCopy4);
-	(* pGC->ops->PolyFillArc)(pDrawable, pGC, narcs, parcs);
-	(* pBackingGC->ops->PolyFillArc)(pBackingDrawable,
-				    pBackingGC, narcs, pArcsCopy);
-	DEALLOCATE_LOCAL(pArcsCopy);
-    }
-
-    EPILOGUE (pGC);
-}
-
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyText8 --
- *	Perform a PolyText8, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static int
-miBSPolyText8(pDrawable, pGC, x, y, count, chars)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		x, y;
-    int 	count;
-    char	*chars;
-{
-    int	    result;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    result = (* pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars);
-    (* pBackingGC->ops->PolyText8)(pBackingDrawable, pBackingGC,
-				   x - pBackingStore->x, y - pBackingStore->y,
-				   count, chars);
-
-    EPILOGUE (pGC);
-    return result;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyText16 --
- *	Perform a PolyText16, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static int
-miBSPolyText16(pDrawable, pGC, x, y, count, chars)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		x, y;
-    int		count;
-    unsigned short *chars;
-{
-    int	result;
-    SETUP_BACKING (pDrawable, pGC);
-
-    PROLOGUE(pGC);
-
-    result = (* pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars);
-    (* pBackingGC->ops->PolyText16)(pBackingDrawable, pBackingGC,
-				    x - pBackingStore->x, y - pBackingStore->y,
-				    count, chars);
-
-    EPILOGUE (pGC);
-
-    return result;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSImageText8 --
- *	Perform a ImageText8, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSImageText8(pDrawable, pGC, x, y, count, chars)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		x, y;
-    int		count;
-    char	*chars;
-{
-    SETUP_BACKING (pDrawable, pGC);
-    PROLOGUE(pGC);
-
-    (* pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars);
-    (* pBackingGC->ops->ImageText8)(pBackingDrawable, pBackingGC,
-				    x - pBackingStore->x, y - pBackingStore->y,
-				    count, chars);
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSImageText16 --
- *	Perform a ImageText16, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSImageText16(pDrawable, pGC, x, y, count, chars)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int		x, y;
-    int		count;
-    unsigned short *chars;
-{
-    SETUP_BACKING (pDrawable, pGC);
-    PROLOGUE(pGC);
-
-    (* pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars);
-    (* pBackingGC->ops->ImageText16)(pBackingDrawable, pBackingGC,
-				    x - pBackingStore->x, y - pBackingStore->y,
-				     count, chars);
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSImageGlyphBlt --
- *	Perform a ImageGlyphBlt, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
-    DrawablePtr pDrawable;
-    GCPtr 	pGC;
-    int 	x, y;
-    unsigned int nglyph;
-    CharInfoPtr *ppci;		/* array of character info */
-    pointer 	pglyphBase;	/* start of array of glyphs */
-{
-    SETUP_BACKING (pDrawable, pGC);
-    PROLOGUE(pGC);
-
-    (* pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci,
-			     pglyphBase);
-    (* pBackingGC->ops->ImageGlyphBlt)(pBackingDrawable, pBackingGC,
-				    x - pBackingStore->x, y - pBackingStore->y,
-				       nglyph, ppci, pglyphBase);
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPolyGlyphBlt --
- *	Perform a PolyGlyphBlt, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
-    DrawablePtr pDrawable;
-    GCPtr	pGC;
-    int 	x, y;
-    unsigned int nglyph;
-    CharInfoPtr *ppci;		/* array of character info */
-    pointer	pglyphBase;	/* start of array of glyphs */
-{
-    SETUP_BACKING (pDrawable, pGC);
-    PROLOGUE(pGC);
-
-    (* pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph,
-			    ppci, pglyphBase);
-    (* pBackingGC->ops->PolyGlyphBlt)(pBackingDrawable, pBackingGC,
-				    x - pBackingStore->x, y - pBackingStore->y,
-				      nglyph, ppci, pglyphBase);
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSPushPixels --
- *	Perform a PushPixels, routing output to backing-store as needed.
- *
- * Results:
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSPushPixels(pGC, pBitMap, pDst, w, h, x, y)
-    GCPtr	pGC;
-    PixmapPtr	pBitMap;
-    DrawablePtr pDst;
-    int		w, h, x, y;
-{
-    SETUP_BACKING (pDst, pGC);
-    PROLOGUE(pGC);
-
-    (* pGC->ops->PushPixels)(pGC, pBitMap, pDst, w, h, x, y);
-    if (pGC->miTranslate) {
- 	x -= pDst->x;
- 	y -= pDst->y;
-    }
-    (* pBackingGC->ops->PushPixels)(pBackingGC, pBitMap,
-			       pBackingDrawable, w, h,
-			       x - pBackingStore->x, y - pBackingStore->y);
-
-    EPILOGUE (pGC);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSClearBackingStore --
- *	Clear the given area of the backing pixmap with the background of
- *	the window, whatever it is. If generateExposures is TRUE, generate
- *	exposure events for the area. Note that if the area has any
- *	part outside the saved portions of the window, we do not allow the
- *	count in the expose events to be 0, since there will be more
- *	expose events to come.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	Areas of pixmap are cleared and Expose events are generated.
- *
- *-----------------------------------------------------------------------
- */
-static RegionPtr
-miBSClearBackingStore(pWin, x, y, w, h, generateExposures)
-    WindowPtr	  	pWin;
-    int	    	  	x;
-    int	    	  	y;
-    int	    	  	w;
-    int	    	  	h;
-    Bool    	  	generateExposures;
-{
-    RegionPtr	  	pRgn;
-    int	    	  	i;
-    miBSWindowPtr	pBackingStore;
-    ScreenPtr	  	pScreen;
-    GCPtr   	  	pGC;
-    int	    	  	ts_x_origin,
-			ts_y_origin;
-    pointer    	  	gcvalues[4];
-    unsigned long 	gcmask;
-    xRectangle	  	*rects;
-    BoxPtr  	  	pBox;
-    BoxRec  	  	box;
-    PixUnion		background;
-    char		backgroundState;
-    int			numRects;
-
-    pBackingStore = (miBSWindowPtr)pWin->backStorage;
-    pScreen = pWin->drawable.pScreen;
-
-    if ((pBackingStore->status == StatusNoPixmap) ||
-	(pBackingStore->status == StatusBadAlloc))
-	return NullRegion;
-    
-    if (w == 0)
-	w = (int) pWin->drawable.width - x;
-    if (h == 0)
-	h = (int) pWin->drawable.height - y;
-
-    box.x1 = x;
-    box.y1 = y;
-    box.x2 = x + w;
-    box.y2 = y + h;
-    pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
-    if (!pRgn)
-	return NullRegion;
-    REGION_INTERSECT( pScreen, pRgn, pRgn, &pBackingStore->SavedRegion);
-
-    if (REGION_NOTEMPTY( pScreen, pRgn))
-    {
-	/*
-	 * if clearing entire window, simply make new virtual
-	 * tile.  For the root window, we also destroy the pixmap
-	 * to save a pile of memory
-	 */
-	if (x == 0 && y == 0 &&
- 	    w == pWin->drawable.width &&
- 	    h == pWin->drawable.height)
-	{
-	    if (!pWin->parent)
-		miDestroyBSPixmap (pWin);
-	    if (pBackingStore->status != StatusContents)
-		 miTileVirtualBS (pWin);
-	}
-
-	ts_x_origin = ts_y_origin = 0;
-
-	backgroundState = pWin->backgroundState;
-	background = pWin->background;
-	if (backgroundState == ParentRelative) {
-	    WindowPtr	pParent;
-
-	    pParent = pWin;
-	    while (pParent->backgroundState == ParentRelative) {
-		ts_x_origin -= pParent->origin.x;
-		ts_y_origin -= pParent->origin.y;
-		pParent = pParent->parent;
-	    }
-	    backgroundState = pParent->backgroundState;
-	    background = pParent->background;
-	}
-
-	if ((backgroundState != None) &&
-	    ((pBackingStore->status == StatusContents) ||
-	     !SameBackground (pBackingStore->backgroundState,
-			      pBackingStore->background,
-			      backgroundState,
-			      background)))
-	{
-	    if (!pBackingStore->pBackingPixmap)
-		miCreateBSPixmap(pWin, NullBox);
-
-	    pGC = GetScratchGC(pWin->drawable.depth, pScreen);
-	    if (pGC && pBackingStore->pBackingPixmap)
-	    {
-		/*
-		 * First take care of any ParentRelative stuff by altering the
-		 * tile/stipple origin to match the coordinates of the upper-left
-		 * corner of the first ancestor without a ParentRelative background.
-		 * This coordinate is, of course, negative.
-		 */
-	    
-		if (backgroundState == BackgroundPixel)
-		{
-		    gcvalues[0] = (pointer) background.pixel;
-		    gcvalues[1] = (pointer)FillSolid;
-		    gcmask = GCForeground|GCFillStyle;
-		}
-		else
-		{
-		    gcvalues[0] = (pointer)FillTiled;
-		    gcvalues[1] = (pointer) background.pixmap;
-		    gcmask = GCFillStyle|GCTile;
-		}
-		gcvalues[2] = (pointer)(long)(ts_x_origin - pBackingStore->x);
-		gcvalues[3] = (pointer)(long)(ts_y_origin - pBackingStore->y);
-		gcmask |= GCTileStipXOrigin|GCTileStipYOrigin;
-		DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE);
-		ValidateGC((DrawablePtr)pBackingStore->pBackingPixmap, pGC);
-    
-		/*
-		 * Figure out the array of rectangles to fill and fill them with
-		 * PolyFillRect in the proper mode, as set in the GC above.
-		 */
-		numRects = REGION_NUM_RECTS(pRgn);
-		rects = (xRectangle *)ALLOCATE_LOCAL(numRects*sizeof(xRectangle));
-	    
-		if (rects)
-		{
-		    for (i = 0, pBox = REGION_RECTS(pRgn);
-			 i < numRects;
-			 i++, pBox++)
-		    {
-			rects[i].x = pBox->x1 - pBackingStore->x;
-			rects[i].y = pBox->y1 - pBackingStore->y;
-			rects[i].width = pBox->x2 - pBox->x1;
-			rects[i].height = pBox->y2 - pBox->y1;
-		    }
-		    (* pGC->ops->PolyFillRect) (
-				(DrawablePtr)pBackingStore->pBackingPixmap,
-				       pGC, numRects, rects);
-		    DEALLOCATE_LOCAL(rects);
-		}	
-		FreeScratchGC(pGC);
-	    }
-	}	
-
-	if (!generateExposures)
- 	{
-	    REGION_DESTROY(pScreen, pRgn);
-	    pRgn = NULL;
-	}
-	else
-	{
-	    /*
-	     * result must be screen relative, but is currently
-	     * drawable relative.
-	     */
-	    REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x,
-			     pWin->drawable.y);
-	}
-    }
-    else
-    {
-	REGION_DESTROY( pScreen, pRgn);
-	pRgn = NULL;
-    }
-    return pRgn;
-}
-
-static void
-miBSClearBackingRegion (pWin, pRgn)
-    WindowPtr	pWin;
-    RegionPtr	pRgn;
-{
-    BoxPtr	pBox;
-    int		i;
-
-    i = REGION_NUM_RECTS(pRgn);
-    pBox = REGION_RECTS(pRgn);
-    while (i--)
-    {
-	(void) miBSClearBackingStore(pWin, pBox->x1, pBox->y1,
-					pBox->x2 - pBox->x1,
-					pBox->y2 - pBox->y1,
-					FALSE);
-	pBox++;
-    }
-}
-
-/*
- * fill a region of the destination with virtual bits
- *
- * pRgn is to be translated by (x,y)
- */
-
-static void
-miBSFillVirtualBits (pDrawable, pGC, pRgn, x, y, state, pixunion, planeMask)
-    DrawablePtr		pDrawable;
-    GCPtr		pGC;
-    RegionPtr		pRgn;
-    int			x, y;
-    int			state;
-    PixUnion		pixunion;
-    unsigned long	planeMask;
-{
-    int		i;
-    BITS32	gcmask;
-    pointer	gcval[5];
-    xRectangle	*pRect;
-    BoxPtr	pBox;
-    WindowPtr	pWin;
-    int		numRects;
-
-    if (state == None)
-	return;
-    numRects = REGION_NUM_RECTS(pRgn);
-    pRect = (xRectangle *)ALLOCATE_LOCAL(numRects * sizeof(xRectangle));
-    if (!pRect)
-	return;
-    pWin = 0;
-    if (pDrawable->type != DRAWABLE_PIXMAP)
-    {
-	pWin = (WindowPtr) pDrawable;
-	if (!pWin->backStorage)
-	    pWin = 0;
-    }
-    i = 0;
-    gcmask = 0;
-    gcval[i++] = (pointer)planeMask;
-    gcmask |= GCPlaneMask;
-    if (state == BackgroundPixel)
-    {
-	if (pGC->fgPixel != pixunion.pixel)
-	{
-	    gcval[i++] = (pointer)pixunion.pixel;
-	    gcmask |= GCForeground;
-	}
-	if (pGC->fillStyle != FillSolid)
-	{
-	    gcval[i++] = (pointer)FillSolid;
-	    gcmask |= GCFillStyle;
-	}
-    }
-    else
-    {
-	if (pGC->fillStyle != FillTiled)
-	{
-	    gcval[i++] = (pointer)FillTiled;
-	    gcmask |= GCFillStyle;
-	}
-	if (pGC->tileIsPixel || pGC->tile.pixmap != pixunion.pixmap)
-	{
-	    gcval[i++] = (pointer)pixunion.pixmap;
-	    gcmask |= GCTile;
-	}
-	if (pGC->patOrg.x != x)
-	{
-	    gcval[i++] = (pointer)(long)x;
-	    gcmask |= GCTileStipXOrigin;
-	}
-	if (pGC->patOrg.y != y)
-	{
-	    gcval[i++] = (pointer)(long)y;
-	    gcmask |= GCTileStipYOrigin;
-	}
-    }
-    if (gcmask)
-	DoChangeGC (pGC, gcmask, (XID *)gcval, 1);
-
-    if (pWin)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
-
-    if (pDrawable->serialNumber != pGC->serialNumber)
-	ValidateGC (pDrawable, pGC);
-
-    pBox = REGION_RECTS(pRgn);
-    for (i = numRects; --i >= 0; pBox++, pRect++)
-    {
-    	pRect->x = pBox->x1 + x;
-	pRect->y = pBox->y1 + y;
-	pRect->width = pBox->x2 - pBox->x1;
-	pRect->height = pBox->y2 - pBox->y1;
-    }
-    pRect -= numRects;
-    (*pGC->ops->PolyFillRect) (pDrawable, pGC, numRects, pRect);
-    if (pWin)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
-    DEALLOCATE_LOCAL (pRect);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSAllocate --
- *	Create and install backing store info for a window
- *
- *-----------------------------------------------------------------------
- */
-
-static void
-miBSAllocate(pWin)
-    WindowPtr 	  pWin;
-{
-    miBSWindowPtr  	pBackingStore;
-    ScreenPtr 	   	pScreen;
-	
-    if (pWin->drawable.pScreen->backingStoreSupport == NotUseful)
-	return;
-    pScreen = pWin->drawable.pScreen;
-    if (!(pBackingStore = (miBSWindowPtr)pWin->backStorage))
-    {
-
-	pBackingStore = (miBSWindowPtr)xalloc(sizeof(miBSWindowRec));
-	if (!pBackingStore)
-	    return;
-
-	pBackingStore->pBackingPixmap = NullPixmap;
-	pBackingStore->x = 0;
-	pBackingStore->y = 0;
-	REGION_NULL( pScreen, &pBackingStore->SavedRegion);
-	pBackingStore->viewable = (char)pWin->viewable;
-	pBackingStore->status = StatusNoPixmap;
-	pBackingStore->backgroundState = None;
-	pWin->backStorage = (pointer) pBackingStore;
-    }
-	
-    /*
-     * Now want to initialize the backing pixmap and SavedRegion if
-     * necessary. The initialization consists of finding all the
-     * currently-obscured regions, by taking the inverse of the window's
-     * clip list, storing the result in SavedRegion, and exposing those
-     * areas of the window.
-     */
-
-    if (pBackingStore->status == StatusNoPixmap &&
-	((pWin->backingStore == WhenMapped && pWin->viewable) ||
-	 (pWin->backingStore == Always)))
-    {
-	BoxRec  	box;
-	RegionPtr	pSavedRegion;
-
-	pSavedRegion = &pBackingStore->SavedRegion;
-
-	box.x1 = pWin->drawable.x;
-	box.x2 = box.x1 + (int) pWin->drawable.width;
-	box.y1 = pWin->drawable.y;
-	box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
-
-	REGION_INVERSE( pScreen, pSavedRegion, &pWin->clipList,  &box);
-	REGION_TRANSLATE( pScreen, pSavedRegion,
-				      -pWin->drawable.x,
-				      -pWin->drawable.y);
-#ifdef SHAPE
-	if (wBoundingShape (pWin))
-	    REGION_INTERSECT(pScreen, pSavedRegion, pSavedRegion,
-			     wBoundingShape (pWin));
-	if (wClipShape (pWin))
-	    REGION_INTERSECT(pScreen, pSavedRegion, pSavedRegion,
-			     wClipShape (pWin));
-#endif
-	/* if window is already on-screen, assume it has been drawn to */
-	if (pWin->viewable)
-	    pBackingStore->status = StatusVDirty;
-	miTileVirtualBS (pWin);
-	
-	/*
-	 * deliver all the newly available regions
-	 * as exposure events to the window
-	 */
-
-	miSendExposures(pWin, pSavedRegion, 0, 0);
-    }
-    else if (!pWin->viewable)
-    {
-        /*
-         * Turn off backing store when we're not supposed to
-         * be saving anything
-         */
-        if (pBackingStore->status != StatusNoPixmap)
-        {
-            REGION_EMPTY( pScreen, &pBackingStore->SavedRegion);
-            miDestroyBSPixmap (pWin);
-        }
-    }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSFree --
- *	Destroy and free all the stuff associated with the backing-store
- *	for the given window.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	The backing pixmap and all the regions and GC's are destroyed.
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSFree(pWin)
-    WindowPtr pWin;
-{
-    miBSWindowPtr 	pBackingStore;
-    ScreenPtr		pScreen;
-
-    pScreen = pWin->drawable.pScreen;
-
-    pBackingStore = (miBSWindowPtr)pWin->backStorage;
-    if (pBackingStore)
-    {
-	miDestroyBSPixmap (pWin);
-
-	REGION_UNINIT( pScreen, &pBackingStore->SavedRegion);
-
-	xfree(pBackingStore);
-	pWin->backStorage = NULL;
-    }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miResizeBackingStore --
- *	Alter the size of the backing pixmap as necessary when the
- *	SavedRegion changes size. The contents of the old pixmap are
- *	copied/shifted into the new/same pixmap.
- *
- * Results:
- *	The new Pixmap is created as necessary.
- *
- * Side Effects:
- *	The old pixmap is destroyed.
- *
- *-----------------------------------------------------------------------
- */
-static void
-miResizeBackingStore(
-    WindowPtr	pWin,
-    int		dx,	    /* bits are moving this far */
-    int		dy,	    /* bits are moving this far */
-    Bool	saveBits)   /* bits are useful */
-{
-    miBSWindowPtr pBackingStore;
-    PixmapPtr pBackingPixmap;
-    ScreenPtr pScreen;
-    GC	   *pGC;
-    BoxPtr  extents;
-    PixmapPtr pNewPixmap;
-    int nx, ny;
-    int	nw, nh;
-
-    pBackingStore = (miBSWindowPtr)(pWin->backStorage);
-    pBackingPixmap = pBackingStore->pBackingPixmap;
-    if (!pBackingPixmap)
-	return;
-    pScreen = pWin->drawable.pScreen;
-    extents = REGION_EXTENTS(pScreen, &pBackingStore->SavedRegion);
-    pNewPixmap = pBackingPixmap;
-
-    nw = extents->x2 - extents->x1;
-    nh = extents->y2 - extents->y1;
-
-    /* the policy here could be more sophisticated */
-    if (nw != pBackingPixmap->drawable.width ||
-	nh != pBackingPixmap->drawable.height)
-    {
-	if (!saveBits || !nw || !nh)
-	{
-	    pNewPixmap = NullPixmap;
-	    pBackingStore->status = StatusNoPixmap;
-	}
-	else
-	{
-	    pNewPixmap = (PixmapPtr)(*pScreen->CreatePixmap)
-					    (pScreen,
-					     nw, nh,
-					     pWin->drawable.depth);
-	    if (!pNewPixmap)
-	    {
-#ifdef BSEAGER
-		pBackingStore->status = StatusNoPixmap;
-#else
-		pBackingStore->status = StatusBadAlloc;
-#endif
-	    }
-	}
-    }
-    if (!pNewPixmap)
-    {
-	pBackingStore->x = 0;
-	pBackingStore->y = 0;
-    }
-    else
-    {
-    	nx = pBackingStore->x - extents->x1 + dx;
-    	ny = pBackingStore->y - extents->y1 + dy;
-    	pBackingStore->x = extents->x1;
-    	pBackingStore->y = extents->y1;
-    	
-    	if (saveBits && (pNewPixmap != pBackingPixmap || nx != 0 || ny != 0))
-    	{
-    	    pGC = GetScratchGC(pNewPixmap->drawable.depth, pScreen);
-    	    if (pGC)
-    	    {
-	    	ValidateGC((DrawablePtr)pNewPixmap, pGC);
-	    	/* if we implement a policy where the pixmap can be larger than
-		 * the region extents, we might want to optimize this copyarea
-		 * by only copying the old extents, rather than the entire
-		 * pixmap
-		 */
-	    	(*pGC->ops->CopyArea)((DrawablePtr)pBackingPixmap,
-				      (DrawablePtr)pNewPixmap, pGC,
-				      0, 0,
-				      pBackingPixmap->drawable.width,
-				      pBackingPixmap->drawable.height,
-				      nx, ny);
-	    	FreeScratchGC(pGC);
-    	    }
-    	}
-    }
-    /* SavedRegion is used in the backingGC clip; force an update */
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    if (pNewPixmap != pBackingPixmap)
-    {
-	(* pScreen->DestroyPixmap)(pBackingPixmap);
-	pBackingStore->pBackingPixmap = pNewPixmap;
-    }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSSaveDoomedAreas --
- *	Saved the areas of the given window that are about to be
- *	obscured.  If the window has moved, pObscured is expected to
- *	be at the new screen location and (dx,dy) is expected to be the offset
- *	to the window's previous location.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	The region is copied from the screen into pBackingPixmap and
- *	SavedRegion is updated.
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSSaveDoomedAreas(pWin, pObscured, dx, dy)
-    WindowPtr		pWin;
-    RegionPtr		pObscured;
-    int			dx, dy;
-{
-    miBSWindowPtr 	pBackingStore;
-    ScreenPtr	  	pScreen;
-    int			x, y;
-
-    pBackingStore = (miBSWindowPtr)pWin->backStorage;
-    pScreen = pWin->drawable.pScreen;
-
-    /*
-     * If the window isn't realized, it's being unmapped, thus we don't
-     * want to save anything if backingStore isn't Always.
-     */
-    if (!pWin->realized)
-    {
-	pBackingStore->viewable = (char)pWin->viewable;
-	if (pWin->backingStore != Always)
-	{
-	    REGION_EMPTY( pScreen, &pBackingStore->SavedRegion);
-	    miDestroyBSPixmap (pWin);
-	    return;
-	}
-	if (pBackingStore->status == StatusBadAlloc)
-	    pBackingStore->status = StatusNoPixmap;
-    }
-
-    /* Don't even pretend to save anything for a virtual background None */
-    if ((pBackingStore->status == StatusVirtual) &&
-	(pBackingStore->backgroundState == None))
-	return;
-
-    if (REGION_NOTEMPTY(pScreen, pObscured))
-    {
-	BoxRec	oldExtents;
-	x = pWin->drawable.x;
-	y = pWin->drawable.y;
-	REGION_TRANSLATE(pScreen, pObscured, -x, -y);
-	oldExtents = *REGION_EXTENTS(pScreen, &pBackingStore->SavedRegion);
-	REGION_UNION( pScreen, &pBackingStore->SavedRegion,
-			   &pBackingStore->SavedRegion,
-			   pObscured);
-	/*
-	 * only save the bits if we've actually
-	 * started using backing store
-	 */
-	if (pBackingStore->status != StatusVirtual)
-	{
-	    if (!pBackingStore->pBackingPixmap)
-		miCreateBSPixmap (pWin, &oldExtents);
-	    else
-		miResizeBackingStore(pWin, 0, 0, TRUE);
-
-	    if (pBackingStore->pBackingPixmap) {
-		if (pBackingStore->x | pBackingStore->y)
-		{
-		    REGION_TRANSLATE( pScreen, pObscured,
-						  -pBackingStore->x,
-						  -pBackingStore->y);
-		    x += pBackingStore->x;
-		    y += pBackingStore->y;
-		}
-		(* pScreen->BackingStoreFuncs.SaveAreas)
-		    (pBackingStore->pBackingPixmap, pObscured,
-		     x - dx, y - dy, pWin);
-	    }
-	}
-	REGION_TRANSLATE(pScreen, pObscured, x, y);
-    }
-    else
-    {
-	if (REGION_BROKEN (pScreen, pObscured))
-	{
-	    REGION_EMPTY( pScreen, &pBackingStore->SavedRegion);
-	    miDestroyBSPixmap (pWin);
-	    return;
-	}
-    }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSRestoreAreas --
- *	Restore areas from backing-store that are no longer obscured.
- *	expects prgnExposed to contain a screen-relative area.
- *
- * Results:
- *	The region to generate exposure events on (which may be
- *	different from the region to paint).
- *
- * Side Effects:
- *	Areas are copied from pBackingPixmap to the screen. prgnExposed
- *	is altered to contain the region that could not be restored from
- *	backing-store.
- *
- * Notes:
- *	This is called before sending any exposure events to the client,
- *	and so might be called if the window has grown.  Changing the backing
- *	pixmap doesn't require revalidating the backingGC because the
- *	client's next output request will result in a call to ValidateGC,
- *	since the window clip region has changed, which will in turn call
- *	miValidateBackingStore.
- *-----------------------------------------------------------------------
- */
-static RegionPtr
-miBSRestoreAreas(pWin, prgnExposed)
-    WindowPtr pWin;
-    RegionPtr prgnExposed;
-{
-    PixmapPtr pBackingPixmap;
-    miBSWindowPtr pBackingStore;
-    RegionPtr prgnSaved;
-    RegionPtr prgnRestored;
-    ScreenPtr pScreen;
-    RegionPtr exposures = prgnExposed;
-
-    pScreen = pWin->drawable.pScreen;
-    pBackingStore = (miBSWindowPtr)pWin->backStorage;
-    pBackingPixmap = pBackingStore->pBackingPixmap;
-
-    prgnSaved = &pBackingStore->SavedRegion;
-
-    if (pBackingStore->status == StatusContents)
-    {
-	REGION_TRANSLATE(pScreen, prgnSaved, pWin->drawable.x,
-			 pWin->drawable.y);
-
-	prgnRestored = REGION_CREATE( pScreen, (BoxPtr)NULL, 1);
-	REGION_INTERSECT( pScreen, prgnRestored, prgnExposed, prgnSaved);
-	
-	/*
-	 * Since prgnExposed is no longer obscured, we no longer
-	 * will have a valid copy of it in backing-store, but there is a valid
-	 * copy of it on screen, so subtract the area we just restored from
-	 * from the area to be exposed.
-	 */
-
-	if (REGION_NOTEMPTY( pScreen, prgnRestored))
-	{
-	    REGION_SUBTRACT( pScreen, prgnSaved, prgnSaved, prgnExposed);
-	    REGION_SUBTRACT( pScreen, prgnExposed, prgnExposed, prgnRestored);
-
-	    /*
-	     * Do the actual restoration
-	     */
-	    (* pScreen->BackingStoreFuncs.RestoreAreas) (pBackingPixmap,
-					  prgnRestored,
-					  pWin->drawable.x + pBackingStore->x,
-					  pWin->drawable.y + pBackingStore->y,
-					  pWin);
-	    /*
-	     * if the saved region is completely empty, dispose of the
-	     * backing pixmap, otherwise, retranslate the saved
-	     * region to window relative
-	     */
-
-	    if (REGION_NOTEMPTY(pScreen, prgnSaved))
-	    {
-		REGION_TRANSLATE(pScreen, prgnSaved,
-					     -pWin->drawable.x,
-					     -pWin->drawable.y);
-		miResizeBackingStore(pWin, 0, 0, TRUE);
-	    }
-	    else
-		miDestroyBSPixmap (pWin);
-	}
-	else
-	    REGION_TRANSLATE(pScreen, prgnSaved,
-				-pWin->drawable.x, -pWin->drawable.y);
-	REGION_DESTROY( pScreen, prgnRestored);
-
-    }
-    else if ((pBackingStore->status == StatusVirtual) ||
-	     (pBackingStore->status == StatusVDirty))
-    {
-	REGION_TRANSLATE(pScreen, prgnSaved,
-				     pWin->drawable.x, pWin->drawable.y);
-	exposures = REGION_CREATE( pScreen, NullBox, 1);
-	if (SameBackground (pBackingStore->backgroundState,
-			    pBackingStore->background,
-			    pWin->backgroundState,
- 			    pWin->background))
-	{
-	    REGION_SUBTRACT( pScreen, exposures, prgnExposed, prgnSaved);
-	}
-	else
-	{
-	    miTileVirtualBS(pWin);
-
-	    /* we need to expose all we have (virtually) retiled */
-	    REGION_UNION( pScreen, exposures, prgnExposed, prgnSaved);
-	}
-	REGION_SUBTRACT( pScreen, prgnSaved, prgnSaved, prgnExposed);
-	REGION_TRANSLATE(pScreen, prgnSaved,
-				     -pWin->drawable.x, -pWin->drawable.y);
-    }
-    else if (pWin->viewable && !pBackingStore->viewable &&
-	     pWin->backingStore != Always)
-    {
-	/*
-	 * The window was just mapped and nothing has been saved in
-	 * backing-store from the last time it was mapped. We want to capture
-	 * any output to regions that are already obscured but there are no
-	 * bits to snag off the screen, so we initialize things just as we did
-	 * in miBSAllocate, above.
-	 */
-	BoxRec  box;
-	
-	prgnSaved = &pBackingStore->SavedRegion;
-
-	box.x1 = pWin->drawable.x;
-	box.x2 = box.x1 + (int) pWin->drawable.width;
-	box.y1 = pWin->drawable.y;
-	box.y2 = box.y1 + (int) pWin->drawable.height;
-	
-	REGION_INVERSE( pScreen, prgnSaved, &pWin->clipList,  &box);
-	REGION_TRANSLATE( pScreen, prgnSaved,
-				      -pWin->drawable.x,
-				      -pWin->drawable.y);
-#ifdef SHAPE
-	if (wBoundingShape (pWin))
-	    REGION_INTERSECT(pScreen, prgnSaved, prgnSaved,
-			     wBoundingShape (pWin));
-	if (wClipShape (pWin))
-	    REGION_INTERSECT(pScreen, prgnSaved, prgnSaved,
-			     wClipShape (pWin));
-#endif
-	miTileVirtualBS(pWin);
-
-	exposures = REGION_CREATE( pScreen, &box, 1);
-    }
-    pBackingStore->viewable = (char)pWin->viewable;
-    return exposures;
-}
-
-
-/*-
- *-----------------------------------------------------------------------
- * miBSTranslateBackingStore --
- *	Shift the backing-store in the given direction. Called when bit
- *	gravity is shifting things around. 
- *
- * Results:
- *	An occluded region of the window which should be sent exposure events.
- *	This region should be in absolute coordinates (i.e. include
- *	new window position).
- *
- * Side Effects:
- *	If the window changed size as well as position, the backing pixmap
- *	is resized. The contents of the backing pixmap are shifted
- *
- * Warning:
- *	Bob and I have rewritten this routine quite a few times, each
- *	time it gets a few more cases correct, and introducing some
- *	interesting bugs.  Naturally, I think the code is correct this
- *	time.
- *
- *	Let me try to explain what this routine is for:
- *
- *	It's called from SlideAndSizeWindow whenever a window
- *	with backing store is resized.  There are two separate
- *	possibilities:
- *
- *	a)  The window has ForgetGravity
- *
- *	    In this case, windx, windy will be 0 and oldClip will
- *	    be NULL.  This indicates that all of the window contents
- *	    currently saved offscreen should be discarded, and the
- *	    entire window exposed.  TranslateBackingStore, then, should
- *	    prepare a completely new backing store region based on the
- *	    new window clipList and return that region for exposure.
- *
- *	b)  The window has some other gravity
- *
- *	    In this case, windx, windy will be set to the distance
- *	    that the bits should move within the window.  oldClip
- *	    will be set to the old visible portion of the window.
- *	    TranslateBackingStore, then, should adjust the backing
- *	    store to accommodate the portion of the existing backing
- *	    store bits which coorespond to backing store bits which
- *	    will still be occluded in the new configuration.  oldx,oldy
- *	    are set to the old position of the window on the screen.
- *
- *	    Furthermore, in this case any contents of the screen which
- *	    are about to become occluded should be fetched from the screen
- *	    and placed in backing store.  This is to avoid the eventual
- *	    occlusion by the win gravity shifting the child window bits around
- *	    on top of this window, and potentially losing information
- *
- *	It's also called from SetShape, but I think (he says not
- *	really knowing for sure) that this code will even work
- *	in that case.
- *-----------------------------------------------------------------------
- */
-
-static RegionPtr
-miBSTranslateBackingStore(pWin, windx, windy, oldClip, oldx, oldy)
-    WindowPtr 	  pWin;
-    int     	  windx;	/* bit translation distance in window */
-    int     	  windy;
-    RegionPtr	  oldClip;  	/* Region being copied */
-    int     	  oldx;		/* old window position */
-    int     	  oldy;
-{
-    miBSWindowPtr 	pBackingStore;
-    RegionPtr 	    	pSavedRegion;
-    RegionPtr 	    	newSaved, doomed;
-    ScreenPtr		pScreen;
-    BoxRec		extents;
-    int 		scrdx;	/* bit translation distance on screen */
-    int     	  	scrdy;
-    int			dx;		/* distance window moved  on screen */
-    int			dy;
-
-    pScreen = pWin->drawable.pScreen;
-    pBackingStore = (miBSWindowPtr)(pWin->backStorage);
-    if ((pBackingStore->status == StatusNoPixmap) ||
-	(pBackingStore->status == StatusBadAlloc))
-	return NullRegion;
-
-    /*
-     * Compute the new saved region
-     */
-
-    newSaved = REGION_CREATE( pScreen, NullBox, 1);
-    extents.x1 = pWin->drawable.x;
-    extents.x2 = pWin->drawable.x + (int) pWin->drawable.width;
-    extents.y1 = pWin->drawable.y;
-    extents.y2 = pWin->drawable.y + (int) pWin->drawable.height;
-    REGION_INVERSE( pScreen, newSaved, &pWin->clipList, &extents);
-
-    REGION_TRANSLATE( pScreen, newSaved,
-			-pWin->drawable.x, -pWin->drawable.y);
-#ifdef SHAPE
-    if (wBoundingShape (pWin) || wClipShape (pWin)) {
-	if (wBoundingShape (pWin))
-	    REGION_INTERSECT( pScreen, newSaved, newSaved,
-				wBoundingShape (pWin));
-	if (wClipShape (pWin))
-	    REGION_INTERSECT( pScreen, newSaved, newSaved, wClipShape (pWin));
-    }
-#endif
-    
-    pSavedRegion = &pBackingStore->SavedRegion;
-
-    /* now find any visible areas we can save from the screen */
-    /* and then translate newSaved to old local coordinates */
-    if (oldClip)
-    {
-    	/* bit gravity makes things virtually too hard, punt */
-    	if (((windx != 0) || (windy != 0)) &&
-	    (pBackingStore->status != StatusContents))
-	    miCreateBSPixmap(pWin, NullBox);
-    
-	/*
-	 * The window is moving this far on the screen
-	 */
-    	dx = pWin->drawable.x - oldx;
-    	dy = pWin->drawable.y - oldy;
-	/*
-	 * The bits will be moving on the screen by the
-	 * amount the window is moving + the amount the
-	 * bits are moving within the window
-	 */
-    	scrdx = windx + dx;
-    	scrdy = windy + dy;
-    
-	/*
- 	 * intersect at old bit position to discover the
-	 * bits on the screen which can be put into the
-	 * new backing store
- 	 */
-	REGION_TRANSLATE( pScreen, oldClip, windx - oldx, windy - oldy);
-	doomed = REGION_CREATE( pScreen, NullBox, 1);
-	REGION_INTERSECT( pScreen, doomed, oldClip, newSaved);
-	REGION_TRANSLATE( pScreen, oldClip, oldx - windx, oldy - windy);
-
-	/*
-	 * Translate the old saved region to the position in the
-	 * window where it will appear to be
-	 */
-	REGION_TRANSLATE( pScreen, pSavedRegion, windx, windy);
-
-	/*
-	 * Add the old saved region to the new saved region, so
-	 * that calls to RestoreAreas will be able to fetch those
-	 * bits back
-	 */
-	REGION_UNION( pScreen, newSaved, newSaved, pSavedRegion);
-
-	/*
-	 * Swap the new saved region into the window
-	 */
-	{
-	    RegionRec	tmp;
-
-	    tmp = *pSavedRegion;
-	    *pSavedRegion = *newSaved;
-	    *newSaved = tmp;
-	}
-	miResizeBackingStore (pWin, windx, windy, TRUE);
-
-	/*
-	 * Compute the newly enabled region
-	 * of backing store.  This region will be
-	 * set to background in the backing pixmap and
-	 * sent as exposure events to the client.
-	 */
-	REGION_SUBTRACT( pScreen, newSaved, pSavedRegion, newSaved);
-
-	/*
-	 * Fetch bits which will be obscured from
-	 * the screen
-	 */
-	if (REGION_NOTEMPTY( pScreen, doomed))
-	{
-	    /*
-	     * Don't clear regions which have bits on the
-	     * screen
-	     */
-	    REGION_SUBTRACT( pScreen, newSaved, newSaved, doomed);
-
-	    /*
-	     * Make the region to SaveDoomedAreas absolute, instead
-	     * of window relative.
-	     */
-	    REGION_TRANSLATE( pScreen, doomed,
-					  pWin->drawable.x, pWin->drawable.y);
-	    (* pScreen->SaveDoomedAreas) (pWin, doomed, scrdx, scrdy);
-	}
-	
-	REGION_DESTROY(pScreen, doomed);
-
-    	/*
- 	 * and clear whatever there is that's new
- 	 */
-    	if (REGION_NOTEMPTY( pScreen, newSaved))
-    	{
-	    miBSClearBackingRegion (pWin, newSaved);
-	    /*
-	     * Make the exposed region absolute
-	     */
-	    REGION_TRANSLATE(pScreen, newSaved,
-				     	 pWin->drawable.x,
-				     	 pWin->drawable.y);
-    	}
-    	else
-    	{
-	    REGION_DESTROY(pScreen, newSaved);
-	    newSaved = NullRegion;
-    	}
-    }
-    else
-    {
-	/*
-	 * ForgetGravity: just reset backing store and
-	 * expose the whole mess
-	 */
-	REGION_COPY( pScreen, pSavedRegion, newSaved);
-	REGION_TRANSLATE( pScreen, newSaved,
-				      pWin->drawable.x, pWin->drawable.y);
-
-	miResizeBackingStore (pWin, 0, 0, FALSE);
-	(void) miBSClearBackingStore (pWin, 0, 0, 0, 0, FALSE);
-    }
-
-    return newSaved;
-}
-
-/*
- * Inform the backing store layer that you are about to validate
- * a gc with a window, and that subsequent output to the window
- * is (or is not) guaranteed to be already clipped to the visible
- * regions of the window.
- */
-
-static void
-miBSDrawGuarantee (pWin, pGC, guarantee)
-    WindowPtr	pWin;
-    GCPtr	pGC;
-    int		guarantee;
-{
-    miBSGCPtr 	pPriv;
-
-    if (pWin->backStorage)
-    {
-	pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr;
-	if (!pPriv)
-	    (void) miBSCreateGCPrivate (pGC);
-	pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr;
-	if (pPriv)
-	{
-	    /*
-	     * XXX KLUDGE ALERT
-	     *
-	     * when the GC is Cheap pPriv will point
-	     * at some device's gc func structure.  guarantee
-	     * will point at the ChangeGC entry of that struct
-	     * and will never match a valid guarantee value.
-	     */
-	    switch (pPriv->guarantee)
-	    {
-	    case GuaranteeNothing:
-	    case GuaranteeVisBack:
-		pPriv->guarantee = guarantee;
-		break;
-	    }
-	}
-    }
-}
-
-#define noBackingCopy (GCGraphicsExposures|GCClipXOrigin|GCClipYOrigin| \
-		       GCClipMask|GCSubwindowMode| \
-		       GCTileStipXOrigin|GCTileStipYOrigin)
-
-/*-
- *-----------------------------------------------------------------------
- * miBSValidateGC --
- *	Wrapper around output-library's ValidateGC routine
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *
- * Notes:
- *	The idea here is to perform several functions:
- *	    - All the output calls must be intercepted and routed to
- *	      backing-store as necessary.
- *	    - pGC in the window's devBackingStore must be set up with the
- *	      clip list appropriate for writing to pBackingPixmap (i.e.
- *	      the inverse of the window's clipList intersected with the
- *	      clientClip of the GC). Since the destination for this GC is
- *	      a pixmap, it is sufficient to set the clip list as its
- *	      clientClip.
- *-----------------------------------------------------------------------
- */
-
-static void
-miBSValidateGC (pGC, stateChanges, pDrawable)
-    GCPtr   	  pGC;
-    unsigned long stateChanges;
-    DrawablePtr   pDrawable;
-{
-    GCPtr   	  	pBackingGC;
-    miBSWindowPtr	pWindowPriv = NULL;
-    miBSGCPtr		pPriv;
-    WindowPtr		pWin;
-    int			lift_functions;
-    RegionPtr		backingCompositeClip = NULL;
-
-    if (pDrawable->type != DRAWABLE_PIXMAP)
-    {
-        pWin = (WindowPtr) pDrawable;
-	pWindowPriv = (miBSWindowPtr) pWin->backStorage;
-	lift_functions = (pWindowPriv == (miBSWindowPtr) NULL);
-    }
-    else
-    {
-        pWin = (WindowPtr) NULL;
-	lift_functions = TRUE;
-    }
-
-    pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pGC, pPriv);
-
-    (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
-
-    /*
-     * rewrap funcs and ops as Validate may have changed them
-     */
-
-    pPriv->wrapFuncs = pGC->funcs;
-    pPriv->wrapOps = pGC->ops;
-
-    if (!lift_functions && ((pPriv->guarantee == GuaranteeVisBack) ||
-                            (pWindowPriv->status == StatusNoPixmap) ||
-                            (pWindowPriv->status == StatusBadAlloc)))
-        lift_functions = TRUE;
-
-    /*
-     * check to see if a new backingCompositeClip region must
-     * be generated
-     */
-
-    if (!lift_functions && 
-        ((pDrawable->serialNumber != pPriv->serialNumber) ||
-	 (stateChanges&(GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode))))
-    {
-	if (REGION_NOTEMPTY(pGC->pScreen, &pWindowPriv->SavedRegion))
- 	{
-	    backingCompositeClip = REGION_CREATE(pGC->pScreen, NULL, 1);
-	    if ((pGC->clientClipType == CT_NONE) || 
-		(pGC->clientClipType == CT_PIXMAP))
-	    {
-		REGION_COPY(pGC->pScreen, backingCompositeClip,
-					     &pWindowPriv->SavedRegion); 
-	    }
-	    else
-	    {
-		/*
-		 * Make a new copy of the client clip, translated to
-		 * its proper origin.
-		 */
-
-		REGION_COPY(pGC->pScreen, backingCompositeClip,
-				pGC->clientClip);
-		REGION_TRANSLATE(pGC->pScreen, backingCompositeClip,
-						  pGC->clipOrg.x,
-						  pGC->clipOrg.y);
-		REGION_INTERSECT(pGC->pScreen, backingCompositeClip,
-					backingCompositeClip,
-					&pWindowPriv->SavedRegion);
-	    }
-	    if (pGC->subWindowMode == IncludeInferiors)
- 	    {
-		RegionPtr translatedClip;
-
-		/* XXX
-		 * any output in IncludeInferiors mode will not
-		 * be redirected to Inferiors backing store.  This
-		 * can be fixed only at great cost to the shadow routines.
-		 */
-		translatedClip = NotClippedByChildren (pWin);
-		REGION_TRANSLATE(pGC->pScreen, translatedClip,
-						  -pDrawable->x,
-						  -pDrawable->y);
-		REGION_SUBTRACT(pGC->pScreen, backingCompositeClip,
-				backingCompositeClip, translatedClip);
-		REGION_DESTROY(pGC->pScreen, translatedClip);
-	    }
-	    if (!REGION_NOTEMPTY(pGC->pScreen, backingCompositeClip))
-		lift_functions = TRUE;
-	}
- 	else
- 	{
-	    lift_functions = TRUE;
-	}
-
-	/* Reset the status when drawing to an unoccluded window so that
-	 * future SaveAreas will actually copy bits from the screen.  Note that
-	 * output to root window in IncludeInferiors mode will not cause this
-	 * to change.  This causes all transient graphics by the window
-	 * manager to the root window to not enable backing store.
-	 */
-	if (lift_functions && (pWindowPriv->status == StatusVirtual) &&
-	    (pWin->parent || pGC->subWindowMode != IncludeInferiors))
-	    pWindowPriv->status = StatusVDirty;
-    }
-
-    /*
-     * if no backing store has been allocated, and it's needed,
-     * create it now.
-     */
-
-    if (!lift_functions && !pWindowPriv->pBackingPixmap)
-    {
-	miCreateBSPixmap (pWin, NullBox);
-	if (!pWindowPriv->pBackingPixmap)
-	    lift_functions = TRUE;
-    }
-    
-    /*
-     * create the backing GC if needed, lift functions
-     * if the creation fails
-     */
-
-    if (!lift_functions && !pPriv->pBackingGC)
-    {
-	int status;
-	XID noexpose = xFalse;
-
-	/* We never want ops with the backingGC to generate GraphicsExpose */
-	pBackingGC = CreateGC ((DrawablePtr)pWindowPriv->pBackingPixmap,
-			       GCGraphicsExposures, &noexpose, &status);
-	if (status != Success)
-	    lift_functions = TRUE;
-	else
-	    pPriv->pBackingGC = pBackingGC;
-    }
-
-    pBackingGC = pPriv->pBackingGC;
-
-    pPriv->stateChanges |= stateChanges;
-
-    if (lift_functions)
-    {
-	if (backingCompositeClip)
-	    REGION_DESTROY( pGC->pScreen, backingCompositeClip);
-
-	/* unwrap the GC again */
-	miBSDestroyGCPrivate (pGC);
-
-	return;
-    }
-
-    /*
-     * the rest of this function gets the pBackingGC
-     * into shape for possible draws
-     */
-
-    pPriv->stateChanges &= ~noBackingCopy;
-    if (pPriv->stateChanges)
-	CopyGC(pGC, pBackingGC, pPriv->stateChanges);
-    if ((pGC->patOrg.x - pWindowPriv->x) != pBackingGC->patOrg.x ||
-	(pGC->patOrg.y - pWindowPriv->y) != pBackingGC->patOrg.y)
-    {
-	XID vals[2];
-	vals[0] = pGC->patOrg.x - pWindowPriv->x;
-	vals[1] = pGC->patOrg.y - pWindowPriv->y;
-	DoChangeGC(pBackingGC, GCTileStipXOrigin|GCTileStipYOrigin, vals, 0);
-    }
-    pPriv->stateChanges = 0;
-
-    if (backingCompositeClip)
-    {
-	XID vals[2];
-
-	if (pGC->clientClipType == CT_PIXMAP)
-	{
-	    (*pBackingGC->funcs->CopyClip)(pBackingGC, pGC);
-	    REGION_TRANSLATE(pGC->pScreen, backingCompositeClip,
-					-pGC->clipOrg.x, -pGC->clipOrg.y);
-	    vals[0] = pGC->clipOrg.x - pWindowPriv->x;
-	    vals[1] = pGC->clipOrg.y - pWindowPriv->y;
-	    DoChangeGC(pBackingGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
-	    (* pGC->pScreen->BackingStoreFuncs.SetClipmaskRgn)
-		(pBackingGC, backingCompositeClip);
-	    REGION_DESTROY( pGC->pScreen, backingCompositeClip);
-	}
-	else
-	{
-	    vals[0] = -pWindowPriv->x;
-	    vals[1] = -pWindowPriv->y;
-	    DoChangeGC(pBackingGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
-	    (*pBackingGC->funcs->ChangeClip) (pBackingGC, CT_REGION, backingCompositeClip, 0);
-	}
-	pPriv->serialNumber = pDrawable->serialNumber;
-    }
-    
-    if (pWindowPriv->pBackingPixmap->drawable.serialNumber
-    	!= pBackingGC->serialNumber)
-    {
-	ValidateGC((DrawablePtr)pWindowPriv->pBackingPixmap, pBackingGC);
-    }
-
-    if (pBackingGC->clientClip == 0)
-    	ErrorF ("backing store clip list nil");
-
-    FUNC_EPILOGUE (pGC, pPriv);
-}
-
-static void
-miBSChangeGC (pGC, mask)
-    GCPtr   pGC;
-    unsigned long   mask;
-{
-    miBSGCPtr	pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pGC, pPriv);
-
-    (*pGC->funcs->ChangeGC) (pGC, mask);
-
-    FUNC_EPILOGUE (pGC, pPriv);
-}
-
-static void
-miBSCopyGC (pGCSrc, mask, pGCDst)
-    GCPtr   pGCSrc, pGCDst;
-    unsigned long   mask;
-{
-    miBSGCPtr	pPriv = (miBSGCPtr) (pGCDst)->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pGCDst, pPriv);
-
-    (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
-
-    FUNC_EPILOGUE (pGCDst, pPriv);
-}
-
-static void
-miBSDestroyGC (pGC)
-    GCPtr   pGC;
-{
-    miBSGCPtr	pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pGC, pPriv);
-
-    if (pPriv->pBackingGC)
-	FreeGC(pPriv->pBackingGC, (GContext)0);
-
-    (*pGC->funcs->DestroyGC) (pGC);
-
-    FUNC_EPILOGUE (pGC, pPriv);
-
-    xfree(pPriv);
-}
-
-static void
-miBSChangeClip(pGC, type, pvalue, nrects)
-    GCPtr	pGC;
-    int		type;
-    pointer	pvalue;
-    int		nrects;
-{
-    miBSGCPtr	pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pGC, pPriv);
-
-    (* pGC->funcs->ChangeClip)(pGC, type, pvalue, nrects);
-
-    FUNC_EPILOGUE (pGC, pPriv);
-}
-
-static void
-miBSCopyClip(pgcDst, pgcSrc)
-    GCPtr pgcDst, pgcSrc;
-{
-    miBSGCPtr	pPriv = (miBSGCPtr) (pgcDst)->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pgcDst, pPriv);
-
-    (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
-
-    FUNC_EPILOGUE (pgcDst, pPriv);
-}
-
-static void
-miBSDestroyClip(pGC)
-    GCPtr	pGC;
-{
-    miBSGCPtr	pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
-
-    FUNC_PROLOGUE (pGC, pPriv);
-
-    (* pGC->funcs->DestroyClip)(pGC);
-
-    FUNC_EPILOGUE (pGC, pPriv);
-}
-
-static void
-miDestroyBSPixmap (pWin)
-    WindowPtr	pWin;
-{
-    miBSWindowPtr	pBackingStore;
-    ScreenPtr		pScreen;
-    
-    pScreen = pWin->drawable.pScreen;
-    pBackingStore = (miBSWindowPtr) pWin->backStorage;
-    if (pBackingStore->pBackingPixmap)
-	(* pScreen->DestroyPixmap)(pBackingStore->pBackingPixmap);
-    pBackingStore->pBackingPixmap = NullPixmap;
-    pBackingStore->x = 0;
-    pBackingStore->y = 0;
-    if (pBackingStore->backgroundState == BackgroundPixmap)
-	(* pScreen->DestroyPixmap)(pBackingStore->background.pixmap);
-    pBackingStore->backgroundState = None;
-    pBackingStore->status = StatusNoPixmap;
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-}
-
-static void
-miTileVirtualBS (pWin)
-    WindowPtr	pWin;
-{
-    miBSWindowPtr	pBackingStore;
-
-    pBackingStore = (miBSWindowPtr) pWin->backStorage;
-    if (pBackingStore->backgroundState == BackgroundPixmap)
- 	(* pWin->drawable.pScreen->DestroyPixmap)
-	    (pBackingStore->background.pixmap);
-    pBackingStore->backgroundState = pWin->backgroundState;
-    pBackingStore->background = pWin->background;
-    if (pBackingStore->backgroundState == BackgroundPixmap)
-	pBackingStore->background.pixmap->refcnt++;
-
-    if (pBackingStore->status != StatusVDirty)
-	pBackingStore->status = StatusVirtual;
-
-    /*
-     * punt parent relative tiles and do it now
-     */
-    if (pBackingStore->backgroundState == ParentRelative)
-	miCreateBSPixmap (pWin, NullBox);
-}
-
-#ifdef DEBUG
-static int BSAllocationsFailed = 0;
-#define FAILEDSIZE	32
-static struct { int w, h; } failedRecord[FAILEDSIZE];
-static int failedIndex;
-#endif
-
-static void
-miCreateBSPixmap (pWin, pExtents)
-    WindowPtr	pWin;
-    BoxPtr	pExtents;
-{
-    miBSWindowPtr	pBackingStore;
-    ScreenPtr		pScreen;
-    PixUnion		background;
-    char		backgroundState = 0;
-    BoxPtr		extents;
-    Bool		backSet;
-
-    pScreen = pWin->drawable.pScreen;
-    pBackingStore = (miBSWindowPtr) pWin->backStorage;
-    if (pBackingStore->status == StatusBadAlloc)
-	return;
-    backSet = ((pBackingStore->status == StatusVirtual) ||
-	       (pBackingStore->status == StatusVDirty));
-
-    extents = REGION_EXTENTS( pScreen, &pBackingStore->SavedRegion);
-
-    if (!pBackingStore->pBackingPixmap &&
-	extents->x2 != extents->x1 &&
-	extents->y2 != extents->y1)
-    {
-	/* the policy here could be more sophisticated */
-	pBackingStore->x = extents->x1;
-	pBackingStore->y = extents->y1;
-	pBackingStore->pBackingPixmap =
-    	    (PixmapPtr)(* pScreen->CreatePixmap)
-			   (pScreen,
-			    extents->x2 - extents->x1,
-			    extents->y2 - extents->y1,
-			    pWin->drawable.depth);
-    }
-    if (!pBackingStore->pBackingPixmap)
-    {
-#ifdef DEBUG
-	BSAllocationsFailed++;
-	/*
-	 * record failed allocations
-	 */
-	failedRecord[failedIndex].w = pWin->drawable.width;
-	failedRecord[failedIndex].h = pWin->drawable.height;
-	failedIndex++;
-	if (failedIndex == FAILEDSIZE)
-		failedIndex = 0;
-#endif
-#ifdef BSEAGER
-	pBackingStore->status = StatusNoPixmap;
-#else
-	pBackingStore->status = StatusBadAlloc;
-#endif
-	return;
-    }
-
-    pBackingStore->status = StatusContents;
-
-    if (backSet)
-    {
-	backgroundState = pWin->backgroundState;
-	background = pWin->background;
-    
-	pWin->backgroundState = pBackingStore->backgroundState;
-	pWin->background = pBackingStore->background;
-	if (pWin->backgroundState == BackgroundPixmap)
-	    pWin->background.pixmap->refcnt++;
-    }
-
-    if (!pExtents)
-	pExtents = extents;
-
-    if (pExtents->y1 != pExtents->y2)
-    {
-	RegionPtr exposed;
-
-	exposed = miBSClearBackingStore(pWin,
-			      pExtents->x1, pExtents->y1,
-			      pExtents->x2 - pExtents->x1,
-			      pExtents->y2 - pExtents->y1,
-			      !backSet);
-	if (exposed)
-	{
-	    miSendExposures(pWin, exposed, pWin->drawable.x, pWin->drawable.y);
-	    REGION_DESTROY( pScreen, exposed);
-	}
-    }
-
-    if (backSet)
-    {
-	if (pWin->backgroundState == BackgroundPixmap)
-	    (* pScreen->DestroyPixmap) (pWin->background.pixmap);
-	pWin->backgroundState = backgroundState;
-	pWin->background = background;
-	if (pBackingStore->backgroundState == BackgroundPixmap)
-	    (* pScreen->DestroyPixmap) (pBackingStore->background.pixmap);
-	pBackingStore->backgroundState = None;
-    }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miBSExposeCopy --
- *	Handle the restoration of areas exposed by graphics operations.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	prgnExposed has the areas exposed from backing-store removed
- *	from it.
- *
- *-----------------------------------------------------------------------
- */
-static void
-miBSExposeCopy (pSrc, pDst, pGC, prgnExposed, srcx, srcy, dstx, dsty, plane)
-    WindowPtr	  	pSrc;
-    DrawablePtr	  	pDst;
-    GCPtr   	  	pGC;
-    RegionPtr	  	prgnExposed;
-    int	    	  	srcx, srcy;
-    int	    	  	dstx, dsty;
-    unsigned long 	plane;
-{
-    RegionRec	  	tempRgn;
-    miBSWindowPtr	pBackingStore;
-    CopyPlaneProcPtr 	copyProc;
-    GCPtr		pScratchGC;
-    BoxPtr		pBox;
-    int  		i;
-    int  		dx, dy;
-    BITS32		gcMask;
-
-    if (!REGION_NOTEMPTY(pGC->pScreen, prgnExposed))
-	return;
-    pBackingStore = (miBSWindowPtr)pSrc->backStorage;
-    
-    if ((pBackingStore->status == StatusNoPixmap) ||
-	(pBackingStore->status == StatusBadAlloc))
-    	return;
-
-    REGION_NULL( pGC->pScreen, &tempRgn);
-    REGION_INTERSECT( pGC->pScreen, &tempRgn, prgnExposed,
-				 &pBackingStore->SavedRegion);
-    REGION_SUBTRACT( pGC->pScreen, prgnExposed, prgnExposed, &tempRgn);
-
-    if (plane != 0) {
-	copyProc = pGC->ops->CopyPlane;
-    } else {
-	copyProc = (CopyPlaneProcPtr)pGC->ops->CopyArea;
-    }
-    
-    dx = dstx - srcx;
-    dy = dsty - srcy;
-    
-    switch (pBackingStore->status) {
-    case StatusVirtual:
-    case StatusVDirty:
-	pScratchGC = GetScratchGC (pDst->depth, pDst->pScreen);
-	if (pScratchGC)
-	{
-	    gcMask = 0;
-	    if (pGC->alu != pScratchGC->alu)
-	    	gcMask = GCFunction;
-	    if (pGC->planemask != pScratchGC->planemask)
-	    	gcMask |= GCPlaneMask;
-	    if (gcMask)
-	    	CopyGC (pGC, pScratchGC, gcMask);
-	    miBSFillVirtualBits (pDst, pScratchGC, &tempRgn, dx, dy,
-				 (int) pBackingStore->backgroundState,
-				 pBackingStore->background,
-				 ~0L);
-	    FreeScratchGC (pScratchGC);
-	}
-	break;
-    case StatusContents:
-	for (i = REGION_NUM_RECTS(&tempRgn), pBox = REGION_RECTS(&tempRgn);
-	     --i >= 0;
-	     pBox++)
-	{
-	    (* copyProc) (&(pBackingStore->pBackingPixmap->drawable), pDst, pGC,
-			  pBox->x1 - pBackingStore->x,
-			  pBox->y1 - pBackingStore->y,
-			  pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
-			  pBox->x1 + dx, pBox->y1 + dy, plane);
-	}
-	break;
-    }
-    REGION_UNINIT( pGC->pScreen, &tempRgn);
+    pScreen->SaveDoomedAreas = NULL;
+    pScreen->RestoreAreas = NULL;
+    pScreen->ExposeCopy = NULL;
+    pScreen->TranslateBackingStore = NULL;
+    pScreen->ClearBackingStore = NULL;
+    pScreen->DrawGuarantee = NULL;
 }
diff --git a/mi/mibstore.h b/mi/mibstore.h
index 23abde2..baa5920 100644
--- a/mi/mibstore.h
+++ b/mi/mibstore.h
@@ -11,11 +11,8 @@
  * makes no representations about the suitability of this
  * software for any purpose.  It is provided "as is" without
  * express or implied warranty.
- *
  */
 
-
-
 #ifndef _MIBSTORE_H
 #define _MIBSTORE_H
 
diff --git a/mi/midispcur.c b/mi/midispcur.c
index de009cb..802fc6c 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -451,8 +451,6 @@ miDCMakeGC(
     gcvals[1] = FALSE;
     pGC = CreateGC((DrawablePtr)pWin,
 		   GCSubwindowMode|GCGraphicsExposures, gcvals, &status);
-    if (pGC && pWin->drawable.pScreen->DrawGuarantee)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
     *ppGC = pGC;
     return pGC;
 }
diff --git a/mi/miexpose.c b/mi/miexpose.c
index df04bd2..8ae4118 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -255,21 +255,6 @@ miHandleExposures(pSrcDrawable, pDstDraw
     /* now get the hidden parts of the source box*/
     REGION_SUBTRACT(pscr, &rgnExposed, &rgnExposed, prgnSrcClip);
 
-    if (pSrcWin && pSrcWin->backStorage)
-    {
-	/*
-	 * Copy any areas from the source backing store. Modifies
-	 * rgnExposed.
-	 */
-	(* pSrcWin->drawable.pScreen->ExposeCopy) ((WindowPtr)pSrcDrawable,
-					      pDstDrawable,
-					      pGC,
-					      &rgnExposed,
-					      srcx, srcy,
-					      dstx, dsty,
-					      plane);
-    }
-    
     /* move them over the destination */
     REGION_TRANSLATE(pscr, &rgnExposed, dstx-srcx, dsty-srcy);
 
@@ -307,15 +292,6 @@ miHandleExposures(pSrcDrawable, pDstDraw
 
 	expBox = *REGION_EXTENTS(pscr, &rgnExposed);
 	REGION_RESET(pscr, &rgnExposed, &expBox);
-	/* need to clear out new areas of backing store */
-	if (pWin->backStorage)
-	    (void) (* pWin->drawable.pScreen->ClearBackingStore)(
-					 pWin,
-					 expBox.x1,
-					 expBox.y1,
-					 expBox.x2 - expBox.x1,
-					 expBox.y2 - expBox.y1,
-					 FALSE);
     }
     if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
 	(((WindowPtr)pDstDrawable)->backgroundState != None))
@@ -496,18 +472,6 @@ miWindowExposures(pWin, prgn, other_expo
     RegionPtr prgn, other_exposed;
 {
     RegionPtr   exposures = prgn;
-    if (pWin->backStorage && prgn)
-	/*
-	 * in some cases, backing store will cause a different
-	 * region to be exposed than needs to be repainted
-	 * (like when a window is mapped).  RestoreAreas is
-	 * allowed to return a region other than prgn,
-	 * in which case this routine will free the resultant
-	 * region.  If exposures is null, then no events will
-	 * be sent to the client; if prgn is empty
-	 * no areas will be repainted.
-	 */
-	exposures = (*pWin->drawable.pScreen->RestoreAreas)(pWin, prgn);
     if ((prgn && !REGION_NIL(prgn)) || 
 	(exposures && !REGION_NIL(exposures)) || other_exposed)
     {
@@ -551,15 +515,6 @@ miWindowExposures(pWin, prgn, other_expo
 	    }
 	    /* PaintWindowBackground doesn't clip, so we have to */
 	    REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
-	    /* need to clear out new areas of backing store, too */
-	    if (pWin->backStorage)
-		(void) (* pWin->drawable.pScreen->ClearBackingStore)(
-					     pWin,
-					     box.x1 - pWin->drawable.x,
-					     box.y1 - pWin->drawable.y,
-					     box.x2 - box.x1,
-					     box.y2 - box.y1,
-					     FALSE);
 	}
 	if (prgn && !REGION_NIL(prgn))
 	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND);
@@ -779,9 +734,6 @@ int what;
 	pWin = pRoot;
     }
     
-    if (pWin->backStorage)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
-
     mask = gcmask;
     gcmask = 0;
     i = 0;
@@ -860,9 +812,6 @@ int what;
     (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
     DEALLOCATE_LOCAL(prect);
 
-    if (pWin->backStorage)
-	(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
-
     if (usingScratchGC)
     {
 	if (what == PW_BORDER)
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 9701001..1dbb85d 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -1025,8 +1025,6 @@ miOverlayWindowExposures(
     RegionPtr   exposures = prgn;
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
-    if (pWin->backStorage && prgn)
-	exposures = (*pScreen->RestoreAreas)(pWin, prgn);
     if ((prgn && !REGION_NIL(prgn)) || 
 	(exposures && !REGION_NIL(exposures)) || other_exposed)
     {
@@ -1066,16 +1064,6 @@ miOverlayWindowExposures(
 		REGION_INTERSECT(pScreen, prgn, prgn, &pTree->clipList);
 	    } else
 		REGION_INTERSECT(pScreen, prgn, prgn, &pWin->clipList);
-
-	    /* need to clear out new areas of backing store, too */
-	    if (pWin->backStorage)
-		(void) (*pScreen->ClearBackingStore)(
-					     pWin,
-					     box.x1 - pWin->drawable.x,
-					     box.y1 - pWin->drawable.y,
-					     box.x2 - box.x1,
-					     box.y2 - box.y1,
-					     FALSE);
 	}
 	if (prgn && !REGION_NIL(prgn))
 	    (*pScreen->PaintWindowBackground)(
@@ -1172,7 +1160,6 @@ miOverlayResizeWindow(
     RegionPtr	oldWinClip = NULL, oldWinClip2 = NULL;	
     RegionPtr	borderVisible = NullRegion; 
     RegionPtr	borderVisible2 = NullRegion; 
-    RegionPtr	bsExposed = NullRegion;	    /* backing store exposures */
     Bool	shrunk = FALSE; /* shrunk in an inner dimension */
     Bool	moved = FALSE;	/* window position changed */
 #ifdef DO_SAVE_UNDERS
@@ -1299,8 +1286,6 @@ miOverlayResizeWindow(
 
     if (WasViewable) {
 	pRegion = REGION_CREATE(pScreen, NullBox, 1);
-	if (pWin->backStorage)
-	    REGION_COPY(pScreen, pRegion, &pWin->clipList);
 
 	(*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, NULL);
 
@@ -1326,17 +1311,6 @@ miOverlayResizeWindow(
 
     GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
 
-    if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) {
-	if (!WasViewable)
-	    pRegion = &pWin->clipList; /* a convenient empty region */
-	if (pWin->bitGravity == ForgetGravity)
-	    bsExposed = (*pScreen->TranslateBackingStore)
-				(pWin, 0, 0, NullRegion, oldx, oldy);
-	else
-	    bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, nx - x, ny - y, pRegion, oldx, oldy);
-    }
-
     if (WasViewable) {
 	miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
 	miOverlayTwoRegions TwoRegions;
@@ -1544,16 +1518,6 @@ miOverlayResizeWindow(
 	    REGION_DESTROY(pScreen, destClip);
 	if (destClip2)
 	    REGION_DESTROY(pScreen, destClip2);
-	if (bsExposed) {
-	    RegionPtr	valExposed = NullRegion;
-
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
 	(*pScreen->HandleExposures)(pWin->parent);
 #ifdef DO_SAVE_UNDERS
 	if (dosave)
@@ -1562,10 +1526,6 @@ miOverlayResizeWindow(
 	if (pScreen->PostValidateTree)
 	    (*pScreen->PostValidateTree)(pWin->parent, pFirstChange, VTOther);
     }
-    else if (bsExposed) {
-	(*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
-	REGION_DESTROY(pScreen, bsExposed);
-    }
     if (pWin->realized)
 	WindowsRestructured ();
 }
@@ -1577,7 +1537,7 @@ miOverlaySetShape(WindowPtr pWin)
 {
     Bool	WasViewable = (Bool)(pWin->viewable);
     ScreenPtr 	pScreen = pWin->drawable.pScreen;
-    RegionPtr	pOldClip = NULL, bsExposed;
+    RegionPtr	pOldClip = NULL;
 #ifdef DO_SAVE_UNDERS
     Bool	dosave = FALSE;
 #endif
@@ -1611,11 +1571,6 @@ miOverlaySetShape(WindowPtr pWin)
     ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
 
     if (WasViewable) {
-	if (pWin->backStorage) {
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
-	}
-
 	(*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
 
 #ifdef DO_SAVE_UNDERS
@@ -1626,26 +1581,6 @@ miOverlaySetShape(WindowPtr pWin)
 	(*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther);
     }
 
-    if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) {
-	if (!WasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-	bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, 0, 0, pOldClip,
-			      pWin->drawable.x, pWin->drawable.y);
-	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-    
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
-    }
     if (WasViewable) {
 	(*pScreen->HandleExposures)(pWin->parent);
 #ifdef DO_SAVE_UNDERS
@@ -1798,10 +1733,6 @@ miOverlayClearToBackground(
     box.y1 = y1; box.y2 = y2;
 
     REGION_INIT(pScreen, &reg, &box, 1);
-    if (pWin->backStorage) {
-        pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
-                                                 generateExposures);
-    }
 
     REGION_INTERSECT(pScreen, &reg, &reg, clipList);
     if (generateExposures)
diff --git a/mi/misprite.c b/mi/misprite.c
index c0560a4..0b402fa 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -89,9 +89,6 @@ static void	    miSpriteInstallColormap(
 static void	    miSpriteStoreColors(ColormapPtr pMap, int ndef,
 					xColorItem *pdef);
 
-static void	    miSpriteSaveDoomedAreas(WindowPtr pWin,
-					    RegionPtr pObscured, int dx,
-					    int dy);
 static void	    miSpriteComputeSaved(ScreenPtr pScreen);
 
 #define SCREEN_PROLOGUE(pScreen, field)\
@@ -195,8 +192,6 @@ miSpriteInitialize (pScreen, cursorFuncs
 
     pScreenPriv->CopyWindow = pScreen->CopyWindow;
     
-    pScreenPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas;
-    
     pScreenPriv->InstallColormap = pScreen->InstallColormap;
     pScreenPriv->StoreColors = pScreen->StoreColors;
     
@@ -228,8 +223,6 @@ miSpriteInitialize (pScreen, cursorFuncs
     
     pScreen->CopyWindow = miSpriteCopyWindow;
     
-    pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas;
-    
     pScreen->InstallColormap = miSpriteInstallColormap;
     pScreen->StoreColors = miSpriteStoreColors;
 
@@ -264,7 +257,6 @@ miSpriteCloseScreen (i, pScreen)
     pScreen->InstallColormap = pScreenPriv->InstallColormap;
     pScreen->StoreColors = pScreenPriv->StoreColors;
 
-    pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas;
     miSpriteIsUpFALSE (pScreen, pScreenPriv);
     DamageDestroy (pScreenPriv->pDamage);
     
@@ -558,45 +550,6 @@ miSpriteFindColors (ScreenPtr pScreen)
 }
 
 /*
- * BackingStore wrappers
- */
-
-static void
-miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy)
-    WindowPtr	pWin;
-    RegionPtr	pObscured;
-    int		dx, dy;
-{
-    ScreenPtr		pScreen;
-    miSpriteScreenPtr   pScreenPriv;
-    BoxRec		cursorBox;
-
-    pScreen = pWin->drawable.pScreen;
-    
-    SCREEN_PROLOGUE (pScreen, SaveDoomedAreas);
-
-    pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-    if (pScreenPriv->isUp)
-    {
-	cursorBox = pScreenPriv->saved;
-
-	if (dx || dy)
- 	{
-	    cursorBox.x1 += dx;
-	    cursorBox.y1 += dy;
-	    cursorBox.x2 += dx;
-	    cursorBox.y2 += dy;
-	}
-	if (RECT_IN_REGION( pScreen, pObscured, &cursorBox) != rgnOUT)
-	    miSpriteRemoveCursor (pScreen);
-    }
-
-    (*pScreen->SaveDoomedAreas) (pWin, pObscured, dx, dy);
-
-    SCREEN_EPILOGUE (pScreen, SaveDoomedAreas);
-}
-
-/*
  * miPointer interface routines
  */
 
diff --git a/mi/mispritest.h b/mi/mispritest.h
index 5075f05..e8251ea 100644
--- a/mi/mispritest.h
+++ b/mi/mispritest.h
@@ -57,9 +57,6 @@ typedef struct {
     /* window procedures */
     CopyWindowProcPtr			CopyWindow;
     
-    /* backing store procedures */
-    SaveDoomedAreasProcPtr		SaveDoomedAreas;
-    
     /* colormap procedures */
     InstallColormapProcPtr		InstallColormap;
     StoreColorsProcPtr			StoreColors;
diff --git a/mi/mivaltree.c b/mi/mivaltree.c
index c999267..74483e3 100644
--- a/mi/mivaltree.c
+++ b/mi/mivaltree.c
@@ -513,18 +513,6 @@ miComputeClips (
 			       universe, &pParent->clipList);
     }
 
-    /*
-     * One last thing: backing storage. We have to try to save what parts of
-     * the window are about to be obscured. We can just subtract the universe
-     * from the old clipList and get the areas that were in the old but aren't
-     * in the new and, hence, are about to be obscured.
-     */
-    if (pParent->backStorage && !resized)
-    {
-	REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
-	(* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
-    }
-    
     /* HACK ALERT - copying contents of regions, instead of regions */
     {
 	RegionRec   tmp;
@@ -816,11 +804,6 @@ miValidateTree (pParent, pChild, kind)
 			       &totalClip, &pParent->clipList);
 	/* fall through */
     case VTMap:
-	if (pParent->backStorage) {
-	    REGION_SUBTRACT( pScreen, &exposed, &pParent->clipList, &totalClip);
-	    (* pScreen->SaveDoomedAreas)(pParent, &exposed, 0, 0);
-	}
-	
 	REGION_COPY( pScreen, &pParent->clipList, &totalClip);
 	pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	break;
diff --git a/mi/miwindow.c b/mi/miwindow.c
index 6ca2e1e..cab67ea 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -113,18 +113,6 @@ miClearToBackground(pWin, x, y, w, h, ge
 
     pScreen = pWin->drawable.pScreen;
     REGION_INIT(pScreen, &reg, &box, 1);
-    if (pWin->backStorage)
-    {
-	/*
-	 * If the window has backing-store on, call through the
-	 * ClearToBackground vector to handle the special semantics
-	 * (i.e. things backing store is to be cleared out and
-	 * an Expose event is to be generated for those areas in backing
-	 * store if generateExposures is TRUE).
-	 */
-	pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
-						 generateExposures);
-    }
 
     REGION_INTERSECT(pScreen, &reg, &reg, &pWin->clipList);
     if (generateExposures)
@@ -631,7 +619,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, p
     RegionPtr	destClip;	/* portions of destination already written */
     RegionPtr	oldWinClip = NULL;	/* old clip list for window */
     RegionPtr	borderVisible = NullRegion; /* visible area of the border */
-    RegionPtr	bsExposed = NullRegion;	    /* backing store exposures */
     Bool	shrunk = FALSE; /* shrunk in an inner dimension */
     Bool	moved = FALSE;	/* window position changed */
 #ifdef DO_SAVE_UNDERS
@@ -735,8 +722,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, p
     if (WasViewable)
     {
 	pRegion = REGION_CREATE(pScreen, NullBox, 1);
-	if (pWin->backStorage)
-	    REGION_COPY(pScreen, pRegion, &pWin->clipList);
 
 	if (pLayerWin == pWin)
 	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
@@ -769,21 +754,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, p
 
     GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
 
-    if (pWin->backStorage &&
-	((pWin->backingStore == Always) || WasViewable))
-    {
-	if (!WasViewable)
-	    pRegion = &pWin->clipList; /* a convenient empty region */
-	if (pWin->bitGravity == ForgetGravity)
-	    bsExposed = (*pScreen->TranslateBackingStore)
-				(pWin, 0, 0, NullRegion, oldx, oldy);
-	else
-	{
-	    bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, nx - x, ny - y, pRegion, oldx, oldy);
-	}
-    }
-
     if (WasViewable)
     {
 	/* avoid the border */
@@ -932,17 +902,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, p
 	REGION_DESTROY(pScreen, pRegion);
 	if (destClip)
 	    REGION_DESTROY(pScreen, destClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
 	if (anyMarked)
 	    (*pScreen->HandleExposures)(pLayerWin->parent);
 #ifdef DO_SAVE_UNDERS
@@ -955,11 +914,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, p
 	    (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange,
 					  VTOther);
     }
-    else if (bsExposed)
-    {
-	(*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
-	REGION_DESTROY(pScreen, bsExposed);
-    }
     if (pWin->realized)
 	WindowsRestructured ();
 }
@@ -986,7 +940,7 @@ miSetShape(pWin)
     Bool	WasViewable = (Bool)(pWin->viewable);
     ScreenPtr 	pScreen = pWin->drawable.pScreen;
     Bool	anyMarked = FALSE;
-    RegionPtr	pOldClip = NULL, bsExposed;
+    RegionPtr	pOldClip = NULL;
 #ifdef DO_SAVE_UNDERS
     Bool	dosave = FALSE;
 #endif
@@ -1018,12 +972,6 @@ miSetShape(pWin)
 
     if (WasViewable)
     {
-	if (pWin->backStorage)
-	{
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
-	}
-
 	anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
 						(WindowPtr *)NULL);
 
@@ -1038,28 +986,6 @@ miSetShape(pWin)
 	    (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
     }
 
-    if (pWin->backStorage &&
-	((pWin->backingStore == Always) || WasViewable))
-    {
-	if (!WasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-	bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, 0, 0, pOldClip,
-			      pWin->drawable.x, pWin->drawable.y);
-	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-    
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
-    }
     if (WasViewable)
     {
 	if (anyMarked)
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 2acff11..65314d8 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1705,25 +1705,6 @@ static GCOps damageGCOps = {
 };
 
 static void
-damageRestoreAreas (PixmapPtr	pPixmap,
-		    RegionPtr	prgn,
-		    int		xorg,
-		    int		yorg,
-		    WindowPtr	pWindow)
-{
-    ScreenPtr pScreen = pWindow->drawable.pScreen;
-    damageScrPriv(pScreen);
-
-    damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
-    unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
-    (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn,
-						xorg, yorg, pWindow);
-    damageReportPostOp (&pWindow->drawable);
-    wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
-			     damageRestoreAreas);
-}
-
-static void
 damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
 {
     DamagePtr	pDamage;
@@ -1786,7 +1767,6 @@ damageCloseScreen (int i, ScreenPtr pScr
     unwrap (pScrPriv, pScreen, PaintWindowBorder);
     unwrap (pScrPriv, pScreen, CopyWindow);
     unwrap (pScrPriv, pScreen, CloseScreen);
-    unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
     xfree (pScrPriv);
     return (*pScreen->CloseScreen) (i, pScreen);
 }
@@ -1840,8 +1820,6 @@ DamageSetup (ScreenPtr pScreen)
     wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
     wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
     wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen);
-    wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
-			     damageRestoreAreas);
 #ifdef RENDER
     if (ps) {
 	wrap (pScrPriv, ps, Glyphs, damageGlyphs);
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index 58ee2bb..1e0efad 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -72,7 +72,6 @@ typedef struct _damageScrPriv {
     CompositeProcPtr		Composite;
     GlyphsProcPtr		Glyphs;
 #endif
-    BSFuncRec			BackingStoreFuncs;
 } DamageScrPrivRec, *DamageScrPrivPtr;
 
 typedef struct _damageGCPriv {
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 356fec7..700de6e 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -633,7 +633,6 @@ RootlessWrap(ScreenPtr pScreen)
 #endif
 
     // WRAP(ClearToBackground); fixme put this back? useful for shaped wins?
-    // WRAP(RestoreAreas); fixme put this back?
 
 #undef WRAP
 }
diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c
index 4f16530..9fab786 100644
--- a/miext/rootless/rootlessValTree.c
+++ b/miext/rootless/rootlessValTree.c
@@ -482,18 +482,6 @@ RootlessComputeClips (pParent, pScreen, 
 			       universe, &pParent->clipList);
     }
 
-    /*
-     * One last thing: backing storage. We have to try to save what parts of
-     * the window are about to be obscured. We can just subtract the universe
-     * from the old clipList and get the areas that were in the old but aren't
-     * in the new and, hence, are about to be obscured.
-     */
-    if (pParent->backStorage && !resized)
-    {
-	REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
-	(* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
-    }
-    
     /* HACK ALERT - copying contents of regions, instead of regions */
     {
 	RegionRec   tmp;


More information about the xorg-commit mailing list