Commit ae7f71a8 authored by Adam Jackson's avatar Adam Jackson

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.
parent bf0883ae
......@@ -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, w,h, generateExposures)
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)
......
......@@ -10,7 +10,7 @@ libafb_la_SOURCES = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpntwin.c afbpi
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
......
......@@ -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(
......
/* 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);
}
......@@ -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, pointer pbits, int xsize, int ysize, i
pScreen->CloseScreen = afbCloseScreen;
pScreen->CreateScreenResources = afbCreateScreenResources;
pScreen->BackingStoreFuncs = afbBSFuncRec;
pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
pScreen->devPrivate = oldDevPrivate;
......
......@@ -15,7 +15,7 @@ libcfb_common_sources = $(top_srcdir)/cfb/cfbgc.c $(top_srcdir)/cfb/cfbrrop.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 \
......
......@@ -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
......
/*-
* 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);
}
......@@ -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, xsize, ysize, dpix, dpiy, width)
pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
pScreen->devPrivate = oldDevPrivate;
#endif
pScreen->BackingStoreFuncs = cfbBSFuncRec;
pScreen->GetScreenPixmap = cfbGetScreenPixmap;
pScreen->SetScreenPixmap = cfbSetScreenPixmap;
return TRUE;
......
......@@ -63,6 +63,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
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 pColormap)
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;
......
......@@ -143,6 +143,11 @@ typedef struct _CompScreen {
*/
InstallColormapProcPtr InstallColormap;
/*
* Fake backing store via automatic redirection
*/
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
ScreenBlockHandlerProcPtr BlockHandler;
CloseScreenProcPtr CloseScreen;
Bool damaged;
......
......@@ -175,7 +175,6 @@ static Bool TileScreenSaver(int i, int kind);
#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);
}
}
}
......
......@@ -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;
......
......@@ -268,20 +268,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
int nspans,
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);
......
......@@ -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.
......
......@@ -24,7 +24,6 @@ libfb_la_SOURCES = \
fbbits.h \
fbblt.c \
fbbltone.c \
fbbstore.c \
fbcopy.c \
fbfill.c \
fbfillrect.c \
......
......@@ -1261,23 +1261,6 @@ fbBltPlane (FbBits *src,
FbStip bgxor,
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
*/
......
/*
* 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