diff options
author | Tiago Vignatti <tiago.vignatti@nokia.com> | 2010-03-30 19:10:36 +0300 |
---|---|---|
committer | Tiago Vignatti <tiago.vignatti@nokia.com> | 2010-04-12 17:19:38 +0300 |
commit | 57f814d78961a4f421c609973aedd9b67593e1b1 (patch) | |
tree | 4ca03299d31a950a2b74dfd388dfbf1b572a88c2 | |
parent | a7698a677682a32960b885c22fdba2add70f4658 (diff) |
Death to Multibuffer extension
The rationale behind is because no sane application will use this when we have
modern APIs such DRI2. Besides, as a fact, xfree86 server has already
deprecated this extension in 1998:
http://www.xfree86.org/3.3.6/isc7.html
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
-rw-r--r-- | Xext/Makefile.am | 9 | ||||
-rw-r--r-- | Xext/mbuf.c | 2014 | ||||
-rw-r--r-- | Xext/mbufbf.c | 1007 | ||||
-rw-r--r-- | Xext/mbufpx.c | 648 | ||||
-rw-r--r-- | Xext/sync.c | 1 | ||||
-rw-r--r-- | Xext/xtest.c | 2 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/modinit.c | 9 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/modinit.h | 5 | ||||
-rw-r--r-- | include/dix-config.h.in | 3 | ||||
-rw-r--r-- | include/globals.h | 4 | ||||
-rw-r--r-- | mi/miinitext.c | 13 | ||||
-rw-r--r-- | os/utils.c | 3 |
13 files changed, 0 insertions, 3725 deletions
diff --git a/Xext/Makefile.am b/Xext/Makefile.am index 53cbc1fbd..fa007aa91 100644 --- a/Xext/Makefile.am +++ b/Xext/Makefile.am @@ -99,13 +99,6 @@ BUILTIN_SRCS += $(XCALIBRATE_SRCS) # XCalibrate needs tslib endif -# Multi-buffering extension -MULTIBUFFER_SRCS = mbuf.c -EXTRA_MULTIBUFFER_SRCS = mbufbf.c mbufpx.c -if MULTIBUFFER -MODULE_SRCS += $(MULTIBUFFER_SRCS) -endif - # XF86 Big Font extension BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h if XF86BIGFONT @@ -140,8 +133,6 @@ EXTRA_DIST = \ $(XSELINUX_SRCS) \ $(XCALIBRATE_SRCS) \ $(XINERAMA_SRCS) \ - $(MULTIBUFFER_SRCS) \ - $(EXTRA_MULTIBUFFER_SRCS) \ $(FONTCACHE_SRCS) \ $(BIGFONT_SRCS) \ $(DPMS_SRCS) \ diff --git a/Xext/mbuf.c b/Xext/mbuf.c deleted file mode 100644 index aacb9cfde..000000000 --- a/Xext/mbuf.c +++ /dev/null @@ -1,2014 +0,0 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "window.h" -#include "os.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "gcstruct.h" -#include "extnsionst.h" -#include "dixstruct.h" -#include "resource.h" -#include "opaque.h" -#include "sleepuntil.h" -#include "inputstr.h" -#include <X11/extensions/multibufconst.h> -#include <X11/extensions/multibufproto.h> - -#include <stdio.h> -#if !defined(WIN32) -#include <sys/time.h> -#endif - -/* given an OtherClientPtr obj, get the ClientPtr */ -#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) - -/* given a MultibufferPtr b, get the ClientPtr */ -#define bClient(b) (clients[CLIENT_ID(b->pPixmap->drawable.id)]) - -#define ValidEventMasks (ExposureMask|MultibufferClobberNotifyMask|MultibufferUpdateNotifyMask) - -/* The _Multibuffer and _Multibuffers structures below refer to each other, - * so we need this forward declaration - */ -typedef struct _Multibuffers *MultibuffersPtr; - -/* - * per-Multibuffer data - */ -typedef struct _Multibuffer { - MultibuffersPtr pMultibuffers; /* associated window data */ - Mask eventMask; /* MultibufferClobberNotifyMask|ExposureMask|MultibufferUpdateNotifyMask */ - Mask otherEventMask; /* mask of all other clients event masks */ - OtherClients *otherClients; /* other clients that want events */ - int number; /* index of this buffer into array */ - int side; /* always Mono */ - int clobber; /* Unclobbered, PartiallyClobbered, FullClobbered */ - PixmapPtr pPixmap; /* associated pixmap */ -} MultibufferRec, *MultibufferPtr; - -/* - * per-window data - */ - -typedef struct _Multibuffers { - WindowPtr pWindow; /* associated window */ - int numMultibuffer; /* count of buffers */ - int refcnt; /* ref count for delete */ - int displayedMultibuffer; /* currently active buffer */ - int updateAction; /* Undefined, Background, Untouched, Copied */ - int updateHint; /* Frequent, Intermittent, Static */ - int windowMode; /* always Mono */ - - TimeStamp lastUpdate; /* time of last update */ - - unsigned short width, height; /* last known window size */ - short x, y; /* for static gravity */ - - MultibufferPtr buffers; /* array of numMultibuffer buffers */ -} MultibuffersRec; - -/* - * per-screen data - */ -typedef struct _MultibufferScreen { - PositionWindowProcPtr PositionWindow; /* pWin, x,y */ -} MultibufferScreenRec, *MultibufferScreenPtr; - -/* - * per display-image-buffers request data. - */ - -typedef struct _DisplayRequest { - struct _DisplayRequest *next; - TimeStamp activateTime; - ClientPtr pClient; - XID id; -} DisplayRequestRec, *DisplayRequestPtr; - -#define DestroyWindowMask (1L<<0) -#define PositionWindowMask (1L<<1) -#define PostValidateTreeMask (1L<<2) -#define ClipNotifyMask (1L<<3) -#define WindowExposuresMask (1L<<4) -#define CopyWindowMask (1L<<5) -#define ClearToBackgroundMask (1L<<6) -#define ChangeWindowAttributesMask (1L<<7) - -extern int MultibufferScreenIndex; -extern int MultibufferWindowIndex; - -extern RESTYPE MultibufferDrawableResType; - -extern void MultibufferUpdate( /* pMbuffer, time */ - MultibufferPtr /* pMultibuffer */, - CARD32 /* time */ - ); -extern void MultibufferExpose( /* pMbuffer, pRegion */ - MultibufferPtr /* pMultibuffer */, - RegionPtr /* pRegion */ - ); -extern void MultibufferClobber( /* pMbuffer */ - MultibufferPtr /* pMultibuffer */ - ); - -typedef struct _mbufWindow *mbufWindowPtr; - -void DestroyImageBuffers (WindowPtr pWin); - -/* - * per-buffer data - */ - -#define MB_DISPLAYED_BUFFER(pMBWindow) \ - ((pMBWindow)->buffers + (pMBWindow)->displayedMultibuffer) - -typedef struct _mbufBuffer { - mbufWindowPtr pMBWindow; /* associated window data */ - Mask eventMask; /* client event mask */ - Mask otherEventMask; /* union of other clients' event masks */ - OtherClientsPtr otherClients; /* other clients that want events */ - int number; /* index of this buffer into array */ - int side; /* stero side: always Mono */ - int clobber; /* clober state */ - DrawablePtr pDrawable; /* associated drawable */ -} mbufBufferRec, *mbufBufferPtr; - - -/* - * per-window data - */ - -#define MB_WINDOW_PRIV(pWin) \ - ((mbufWindowPtr)((pWin)->devPrivates[MultibufferWindowIndex].ptr)) - -typedef struct _mbufWindow { - WindowPtr pWindow; /* associated window */ - int numMultibuffer; /* count of buffers */ - mbufBufferPtr buffers; /* array of (numMultibuffer) buffers */ - int displayedMultibuffer; /* currently active buffer */ - int updateAction; /* Undefined, Background, - Untouched, Copied */ - int updateHint; /* Frequent, Intermittent, Static */ - int windowMode; /* always Mono */ - TimeStamp lastUpdate; /* time of last update */ - short x, y; /* for static gravity */ - unsigned short width, height; /* last known window size */ - DevUnion devPrivate; -} mbufWindowRec; - - -/* - * per-screen data - */ - -#define MB_SCREEN_PRIV(pScreen) \ - ((mbufScreenPtr)((pScreen)->devPrivates[MultibufferScreenIndex].ptr)) - -typedef struct _mbufScreen { - long mbufWindowCount; /* count of multibuffered windows */ - - /* Wrap pScreen->DestroyWindow */ - DestroyWindowProcPtr DestroyWindow; - long funcsWrapped; /* flags which functions are wrapped */ - - /* Initialized by device-dependent section */ - int nInfo; /* number of buffer info rec's */ - xMbufBufferInfo *pInfo; /* buffer info (for Normal buffers) */ - - int (* CreateImageBuffers)( - WindowPtr /* pWin */, - int /* nbuf */, - XID * /* ids */, - int /* action */, - int /* hint */ - ); - void (* DestroyImageBuffers)( - WindowPtr /* pWin */ - ); - void (* DisplayImageBuffers)( - ScreenPtr /* pScreen */, - mbufBufferPtr * /* ppMBBuffer */, - mbufWindowPtr * /* ppMBWindow */, - int /* nbuf */ - ); - void (* ClearImageBufferArea)( - mbufBufferPtr /* pMBBuffer */, - short /* x */, - short /* y */, - unsigned short /* width */, - unsigned short /* height */, - Bool /* exposures */ - ); - Bool (* ChangeMBufferAttributes)( /* pMBWindow, vmask */ - /* FIXME */ - ); - Bool (* ChangeBufferAttributes)( /* pMBBuffer, vmask */ - /* FIXME */ - ); - void (* DeleteBufferDrawable)( - DrawablePtr /* pDrawable */ - ); - void (* WrapScreenFuncs)( - ScreenPtr /* pScreen */ - ); - void (* ResetProc)( - ScreenPtr /* pScreen */ - ); - DevUnion devPrivate; -} mbufScreenRec, *mbufScreenPtr; - - -/* Privates to mbufScreenRec */ - -#ifdef _MULTIBUF_PIXMAP_ -#define MB_SCREEN_PRIV_PIXMAP(pScreen) \ - ((mbufPixmapPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr) - -typedef struct _mbufPixmapPriv -{ - /* Pointers to wrapped functions */ - PositionWindowProcPtr PositionWindow; /* pWin, x,y */ - long funcsWrapped; /* flags which functions are wrapped */ -} mbufPixmapPrivRec, *mbufPixmapPrivPtr; -#endif /* _MULTIBUF_PIXMAP_ */ - - -#ifdef _MULTIBUF_BUFFER_ - -extern int frameWindowPrivateIndex; - -#define MB_SCREEN_PRIV_BUFFER(pScreen) \ - ((mbufBufferPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr) - -typedef struct _mbufBufferPriv -{ - DevUnion *frameBuffer; /* Array of screen framebuffers */ - DevUnion selectPlane; /* Plane(s) that select displayed buffer */ - - /* - * Note: subtractRgn and unionRgn may overlap. subtractRgn is a union - * of all the old clipLists of the windows that are displaying - * the backbuffer. unionRgn is the union of all the new clipLists - * of the same windows. - */ - - RegionRec backBuffer; /* Area of screen displaying back buffer */ - RegionRec subtractRgn; /* Regions lost to backBuffer */ - RegionRec unionRgn; /* Regions gained by backBuffer */ - Bool rgnChanged; /* TRUE if "backBuffer" needs to be updated */ - - void (* CopyBufferBits)(); /* pMBWindow, srcBufferNum, dstBufferNum */ - void (* DrawSelectPlane)(); /* pScreen, selectPlane, pRegion, bufferNum */ - - /* Pointers to wrapped functions */ - PostValidateTreeProcPtr PostValidateTree; /* pParent, pChild, kind */ - ClipNotifyProcPtr ClipNotify; /* pWin, dx, dy */ - WindowExposuresProcPtr WindowExposures; /* pWin, pRegion */ - CopyWindowProcPtr CopyWindow; /* pWin, oldPt, pOldRegion */ - ClearToBackgroundProcPtr ClearToBackground; /* pWin, x,y,w,h, sendExpose */ - ChangeWindowAttributesProcPtr ChangeWindowAttributes; /* pWin, vmask */ - long funcsWrapped; /* flags which functions are wrapped */ - unsigned inClearToBackground:1; /* used by WindowExposure */ -} mbufBufferPrivRec, *mbufBufferPrivPtr; -#endif /* _MULTIBUF_BUFFER_ */ - -static int MultibufferEventBase; -static int MultibufferErrorBase; -static int MultibufferScreenPrivKeyIndex; -static DevPrivateKey MultibufferScreenPrivKey = &MultibufferScreenPrivKeyIndex; -static int MultibufferWindowPrivKeyIndex; -static DevPrivateKey MultibufferWindowPrivKey = &MultibufferWindowPrivKeyIndex; - -static void PerformDisplayRequest ( - MultibuffersPtr * /* ppMultibuffers */, - MultibufferPtr * /* pMultibuffer */, - int /* nbuf */ - ); -static Bool QueueDisplayRequest ( - ClientPtr /* client */, - TimeStamp /* activateTime */ - ); - -static void BumpTimeStamp ( - TimeStamp * /* ts */, - CARD32 /* inc */ - ); - -static void AliasMultibuffer ( - MultibuffersPtr /* pMultibuffers */, - int /* i */ - ); -static void RecalculateMultibufferOtherEvents ( - MultibufferPtr /* pMultibuffer */ - ); -static int EventSelectForMultibuffer( - MultibufferPtr /* pMultibuffer */, - ClientPtr /* client */, - Mask /* mask */ - ); - -/* - * The Pixmap associated with a buffer can be found as a resource - * with this type - */ -RESTYPE MultibufferDrawableResType; -static int MultibufferDrawableDelete ( - pointer /* value */, - XID /* id */ - ); -/* - * The per-buffer data can be found as a resource with this type. - * the resource id of the per-buffer data is the same as the resource - * id of the pixmap - */ -static RESTYPE MultibufferResType; -static int MultibufferDelete ( - pointer /* value */, - XID /* id */ - ); - -/* - * The per-window data can be found as a resource with this type, - * using the window resource id - */ -static RESTYPE MultibuffersResType; -static int MultibuffersDelete ( - pointer /* value */, - XID /* id */ - ); - -/* - * Clients other than the buffer creator attach event masks in - * OtherClient structures; each has a resource of this type. - */ -static RESTYPE OtherClientResType; -static int OtherClientDelete ( - pointer /* value */, - XID /* id */ - ); - -/**************** - * MultibufferExtensionInit - * - * Called from InitExtensions in main() - * - ****************/ - -extern DISPATCH_PROC(ProcGetBufferAttributes); - -static DISPATCH_PROC(ProcClearImageBufferArea); -static DISPATCH_PROC(ProcCreateImageBuffers); -static DISPATCH_PROC(ProcDestroyImageBuffers); -static DISPATCH_PROC(ProcDisplayImageBuffers); -static DISPATCH_PROC(ProcGetBufferInfo); -static DISPATCH_PROC(ProcGetBufferVersion); -static DISPATCH_PROC(ProcGetMBufferAttributes); -static DISPATCH_PROC(ProcMultibufferDispatch); -static DISPATCH_PROC(ProcSetBufferAttributes); -static DISPATCH_PROC(ProcSetMBufferAttributes); -static DISPATCH_PROC(SProcClearImageBufferArea); -static DISPATCH_PROC(SProcCreateImageBuffers); -static DISPATCH_PROC(SProcDestroyImageBuffers); -static DISPATCH_PROC(SProcDisplayImageBuffers); -static DISPATCH_PROC(SProcGetBufferAttributes); -static DISPATCH_PROC(SProcGetBufferInfo); -static DISPATCH_PROC(SProcGetBufferVersion); -static DISPATCH_PROC(SProcGetMBufferAttributes); -static DISPATCH_PROC(SProcMultibufferDispatch); -static DISPATCH_PROC(SProcSetBufferAttributes); -static DISPATCH_PROC(SProcSetMBufferAttributes); - -static void MultibufferResetProc( - ExtensionEntry * /* extEntry */ - ); -static void SClobberNotifyEvent( - xMbufClobberNotifyEvent * /* from */, - xMbufClobberNotifyEvent * /* to */ - ); -static void SUpdateNotifyEvent( - xMbufUpdateNotifyEvent * /* from */, - xMbufUpdateNotifyEvent * /* to */ - ); -static Bool MultibufferPositionWindow( - WindowPtr /* pWin */, - int /* x */, - int /* y */ - ); - -static void SetupBackgroundPainter ( - WindowPtr /* pWin */, - GCPtr /* pGC */ - ); - -static int DeliverEventsToMultibuffer ( - MultibufferPtr /* pMultibuffer */, - xEvent * /* pEvents */, - int /* count */, - Mask /* filter */ - ); - -void -MultibufferExtensionInit() -{ - ExtensionEntry *extEntry; - int i, j; - ScreenPtr pScreen; - MultibufferScreenPtr pMultibufferScreen; - - for (i = 0; i < screenInfo.numScreens; i++) - { - pScreen = screenInfo.screens[i]; - if (!(pMultibufferScreen = xalloc (sizeof (MultibufferScreenRec)))) - { - for (j = 0; j < i; j++) - xfree (dixLookupPrivate(&screenInfo.screens[j]->devPrivates, MultibufferScreenPrivKey)); - return; - } - dixSetPrivate(&pScreen->devPrivates, MultibufferScreenPrivKey, pMultibufferScreen); - /* - * wrap PositionWindow to resize the pixmap when the window - * changes size - */ - pMultibufferScreen->PositionWindow = pScreen->PositionWindow; - pScreen->PositionWindow = MultibufferPositionWindow; - } - /* - * create the resource types - */ - MultibufferDrawableResType = - CreateNewResourceType(MultibufferDrawableDelete, "MultibufferDrawable"); - if (MultiBufferDrawableResType) - MultibufferDrawableResType |= RC_DRAWABLE; - MultibufferResType = CreateNewResourceType(MultibufferDelete, - "MultibufferBuffer"); - MultibuffersResType = CreateNewResourceType(MultibuffersDelete, - "MultibufferWindow"); - OtherClientResType = CreateNewResourceType(OtherClientDelete, - "MultibufferOtherClient"); - if (MultibufferDrawableResType && MultibufferResType && - MultibuffersResType && OtherClientResType && - (extEntry = AddExtension(MULTIBUFFER_PROTOCOL_NAME, - MultibufferNumberEvents, - MultibufferNumberErrors, - ProcMultibufferDispatch, SProcMultibufferDispatch, - MultibufferResetProc, StandardMinorOpcode))) - { - MultibufferEventBase = extEntry->eventBase; - MultibufferErrorBase = extEntry->errorBase; - EventSwapVector[MultibufferEventBase + MultibufferClobberNotify] = (EventSwapPtr) SClobberNotifyEvent; - EventSwapVector[MultibufferEventBase + MultibufferUpdateNotify] = (EventSwapPtr) SUpdateNotifyEvent; - } -} - -/*ARGSUSED*/ -static void -MultibufferResetProc (extEntry) -ExtensionEntry *extEntry; -{ - int i; - ScreenPtr pScreen; - MultibufferScreenPtr pMultibufferScreen; - - for (i = 0; i < screenInfo.numScreens; i++) - { - pScreen = screenInfo.screens[i]; - if ((pMultibufferScreen = (MultibufferScreenPtr)dixLookupPrivate(&pScreen->devPrivates, MultibufferScreenPrivKey))) - { - pScreen->PositionWindow = pMultibufferScreen->PositionWindow; - xfree (pMultibufferScreen); - } - } -} - -static int -ProcGetBufferVersion (client) - ClientPtr client; -{ - xMbufGetBufferVersionReply rep; - int n; - - REQUEST_SIZE_MATCH (xMbufGetBufferVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = MULTIBUFFER_MAJOR_VERSION; - rep.minorVersion = MULTIBUFFER_MINOR_VERSION; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - } - WriteToClient(client, sizeof (xMbufGetBufferVersionReply), (char *)&rep); - return (client->noClientException); -} - -static void -SetupBackgroundPainter (pWin, pGC) - WindowPtr pWin; - GCPtr pGC; -{ - pointer gcvalues[4]; - int ts_x_origin, ts_y_origin; - PixUnion background; - int backgroundState; - Mask gcmask; - - /* - * 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. - */ - - ts_x_origin = ts_y_origin = 0; - while (pWin->backgroundState == ParentRelative) { - ts_x_origin -= pWin->origin.x; - ts_y_origin -= pWin->origin.y; - pWin = pWin->parent; - } - backgroundState = pWin->backgroundState; - background = pWin->background; - - switch (backgroundState) - { - case BackgroundPixel: - gcvalues[0] = (pointer) background.pixel; - gcvalues[1] = (pointer) FillSolid; - gcmask = GCForeground|GCFillStyle; - break; - - case BackgroundPixmap: - gcvalues[0] = (pointer) FillTiled; - gcvalues[1] = (pointer) background.pixmap; - gcvalues[2] = (pointer)(long) ts_x_origin; - gcvalues[3] = (pointer)(long) ts_y_origin; - gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin; - break; - - default: - gcvalues[0] = (pointer) GXnoop; - gcmask = GCFunction; - } - DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE); -} - -int -CreateImageBuffers (pWin, nbuf, ids, action, hint) - WindowPtr pWin; - int nbuf; - XID *ids; - int action; - int hint; -{ - MultibuffersPtr pMultibuffers; - MultibufferPtr pMultibuffer; - ScreenPtr pScreen; - int width, height, depth; - int i; - GCPtr pClearGC = NULL; - xRectangle clearRect; - - DestroyImageBuffers(pWin); - pMultibuffers = xalloc (sizeof (MultibuffersRec) + nbuf * sizeof (MultibufferRec)); - if (!pMultibuffers) - return BadAlloc; - pMultibuffers->pWindow = pWin; - pMultibuffers->buffers = (MultibufferPtr) (pMultibuffers + 1); - pMultibuffers->refcnt = pMultibuffers->numMultibuffer = 0; - if (!AddResource (pWin->drawable.id, MultibuffersResType, (pointer) pMultibuffers)) - return BadAlloc; - width = pWin->drawable.width; - height = pWin->drawable.height; - depth = pWin->drawable.depth; - pScreen = pWin->drawable.pScreen; - - if (pWin->backgroundState != None) - { - pClearGC = GetScratchGC (pWin->drawable.depth, pScreen); - SetupBackgroundPainter (pWin, pClearGC); - clearRect.x = clearRect.y = 0; - clearRect.width = width; - clearRect.height = height; - } - - for (i = 0; i < nbuf; i++) - { - pMultibuffer = &pMultibuffers->buffers[i]; - pMultibuffer->eventMask = 0L; - pMultibuffer->otherEventMask = 0L; - pMultibuffer->otherClients = (OtherClientsPtr) NULL; - pMultibuffer->number = i; - pMultibuffer->side = MultibufferSideMono; - pMultibuffer->clobber = MultibufferUnclobbered; - pMultibuffer->pMultibuffers = pMultibuffers; - if (!AddResource (ids[i], MultibufferResType, (pointer) pMultibuffer)) - break; - pMultibuffer->pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, depth, 0); - if (!pMultibuffer->pPixmap) - break; - if (!AddResource (ids[i], MultibufferDrawableResType, (pointer) pMultibuffer->pPixmap)) - { - FreeResource (ids[i], MultibufferResType); - (*pScreen->DestroyPixmap) (pMultibuffer->pPixmap); - break; - } - pMultibuffer->pPixmap->drawable.id = ids[i]; - - if (i > 0 && pClearGC) - { - ValidateGC((DrawablePtr)pMultibuffer->pPixmap, pClearGC); - (*pClearGC->ops->PolyFillRect)((DrawablePtr)pMultibuffer->pPixmap, - pClearGC, 1, &clearRect); - } - } - pMultibuffers->numMultibuffer = i; - pMultibuffers->refcnt = i; - pMultibuffers->displayedMultibuffer = -1; - if (i > 0) - AliasMultibuffer (pMultibuffers, 0); - pMultibuffers->updateAction = action; - pMultibuffers->updateHint = hint; - pMultibuffers->windowMode = MultibufferModeMono; - pMultibuffers->lastUpdate.months = 0; - pMultibuffers->lastUpdate.milliseconds = 0; - pMultibuffers->width = width; - pMultibuffers->height = height; - dixSetPrivate(&pWin->devPrivates, MultibufferWindowPrivKey, pMultibuffers); - if (pClearGC) FreeScratchGC(pClearGC); - return Success; -} - - -static int -ProcCreateImageBuffers (client) - ClientPtr client; -{ - REQUEST(xMbufCreateImageBuffersReq); - xMbufCreateImageBuffersReply rep; - int n; - WindowPtr pWin; - XID *ids; - int len, nbuf, i, err, rc; - - REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); - len = stuff->length - bytes_to_int32(sizeof(xMbufCreateImageBuffersReq)); - if (len == 0) - return BadLength; - rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); - if (rc != Success) - return rc; - if (pWin->drawable.class == InputOnly) - return BadMatch; - switch (stuff->updateAction) - { - case MultibufferUpdateActionUndefined: - case MultibufferUpdateActionBackground: - case MultibufferUpdateActionUntouched: - case MultibufferUpdateActionCopied: - break; - default: - client->errorValue = stuff->updateAction; - return BadValue; - } - switch (stuff->updateHint) - { - case MultibufferUpdateHintFrequent: - case MultibufferUpdateHintIntermittent: - case MultibufferUpdateHintStatic: - break; - default: - client->errorValue = stuff->updateHint; - return BadValue; - } - nbuf = len; - ids = (XID *) &stuff[1]; - for (i = 0; i < nbuf; i++) - { - LEGAL_NEW_RESOURCE(ids[i], client); - } - err = CreateImageBuffers (pWin, nbuf, ids, - stuff->updateAction, stuff->updateHint); - if (err != Success) - return err; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.numberBuffer = ((MultibuffersPtr) (dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey)))->numMultibuffer; - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.numberBuffer, n); - } - WriteToClient(client, sizeof (xMbufCreateImageBuffersReply), (char*)&rep); - return (client->noClientException); -} - -static int -ProcDisplayImageBuffers (client) - ClientPtr client; -{ - REQUEST(xMbufDisplayImageBuffersReq); - MultibufferPtr *pMultibuffer; - MultibuffersPtr *ppMultibuffers; - int nbuf; - XID *ids; - int i, j; - CARD32 minDelay; - TimeStamp activateTime, bufferTime; - int rc; - - - REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq); - nbuf = stuff->length - bytes_to_int32(sizeof (xMbufDisplayImageBuffersReq)); - if (!nbuf) - return Success; - minDelay = stuff->minDelay; - ids = (XID *) &stuff[1]; - ppMultibuffers = xalloc(nbuf * sizeof (MultibuffersPtr)); - pMultibuffer = xalloc(nbuf * sizeof (MultibufferPtr)); - if (!ppMultibuffers || !pMultibuffer) - { - if (ppMultibuffers) xfree(ppMultibuffers); - if (pMultibuffer) xfree(pMultibuffer); - client->errorValue = 0; - return BadAlloc; - } - activateTime.months = 0; - activateTime.milliseconds = 0; - for (i = 0; i < nbuf; i++) - { - rc = dixLookupResourceByType(&pMultibuffer[i], ids[i], - MultibufferResType, client, DixUseAccess); - if (rc != Success) - { - xfree(ppMultibuffers); - xfree(pMultibuffer); - client->errorValue = ids[i]; - return MultibufferErrorBase + MultibufferBadBuffer; - } - ppMultibuffers[i] = pMultibuffer[i]->pMultibuffers; - for (j = 0; j < i; j++) - { - if (ppMultibuffers[i] == ppMultibuffers[j]) - { - xfree(ppMultibuffers); - xfree(pMultibuffer); - client->errorValue = ids[i]; - return BadMatch; - } - } - bufferTime = ppMultibuffers[i]->lastUpdate; - BumpTimeStamp (&bufferTime, minDelay); - if (CompareTimeStamps (bufferTime, activateTime) == LATER) - activateTime = bufferTime; - } - UpdateCurrentTime (); - if (CompareTimeStamps (activateTime, currentTime) == LATER && - QueueDisplayRequest (client, activateTime)) - { - ; - } - else - PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf); - - xfree(ppMultibuffers); - xfree(pMultibuffer); - return Success; -} - - -static int -ProcDestroyImageBuffers (client) - ClientPtr client; -{ - REQUEST (xMbufDestroyImageBuffersReq); - WindowPtr pWin; - int rc; - - REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); - if (rc != Success) - return rc; - DestroyImageBuffers (pWin); - return Success; -} - -static int -ProcSetMBufferAttributes (client) - ClientPtr client; -{ - REQUEST (xMbufSetMBufferAttributesReq); - WindowPtr pWin; - MultibuffersPtr pMultibuffers; - int len, rc; - Mask vmask; - Mask index2; - CARD32 updateHint; - XID *vlist; - - REQUEST_AT_LEAST_SIZE (xMbufSetMBufferAttributesReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); - if (rc != Success) - return rc; - rc = dixLookupResourceByType(&pMultibuffers, pWin->drawable.id, - MultibufferResType, client, DixSetAttrAccess); - if (rc != Success) - return BadMatch; - len = stuff->length - bytes_to_int32(sizeof (xMbufSetMBufferAttributesReq)); - vmask = stuff->valueMask; - if (len != Ones (vmask)) - return BadLength; - vlist = (XID *) &stuff[1]; - while (vmask) - { - index2 = (Mask) lowbit (vmask); - vmask &= ~index2; - switch (index2) - { - case MultibufferWindowUpdateHint: - updateHint = (CARD32) *vlist; - switch (updateHint) - { - case MultibufferUpdateHintFrequent: - case MultibufferUpdateHintIntermittent: - case MultibufferUpdateHintStatic: - pMultibuffers->updateHint = updateHint; - break; - default: - client->errorValue = updateHint; - return BadValue; - } - vlist++; - break; - default: - client->errorValue = stuff->valueMask; - return BadValue; - } - } - return Success; -} - -static int -ProcGetMBufferAttributes (client) - ClientPtr client; -{ - REQUEST (xMbufGetMBufferAttributesReq); - WindowPtr pWin; - MultibuffersPtr pMultibuffers; - XID *ids; - xMbufGetMBufferAttributesReply rep; - int i, n, rc; - - REQUEST_SIZE_MATCH (xMbufGetMBufferAttributesReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); - if (rc != Success) - return rc; - rc = dixLookupResourceByType(&pMultibuffers, pWin->drawable.id, - MultibufferResType, client, DixGetAttrAccess); - if (rc != Success) - return BadAccess; - ids = xalloc (pMultibuffers->numMultibuffer * sizeof (XID)); - if (!ids) - return BadAlloc; - for (i = 0; i < pMultibuffers->numMultibuffer; i++) - ids[i] = pMultibuffers->buffers[i].pPixmap->drawable.id; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = pMultibuffers->numMultibuffer; - rep.displayedBuffer = pMultibuffers->displayedMultibuffer; - rep.updateAction = pMultibuffers->updateAction; - rep.updateHint = pMultibuffers->updateHint; - rep.windowMode = pMultibuffers->windowMode; - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.displayedBuffer, n); - SwapLongs (ids, pMultibuffers->numMultibuffer); - } - WriteToClient (client, sizeof(xMbufGetMBufferAttributesReply), - (char *)&rep); - WriteToClient (client, (int)(pMultibuffers->numMultibuffer * sizeof (XID)), - (char *)ids); - xfree((pointer) ids); - return client->noClientException; -} - -static int -ProcSetBufferAttributes (client) - ClientPtr client; -{ - REQUEST(xMbufSetBufferAttributesReq); - MultibufferPtr pMultibuffer; - int len; - Mask vmask, index2; - XID *vlist; - Mask eventMask; - int result; - int rc; - - REQUEST_AT_LEAST_SIZE (xMbufSetBufferAttributesReq); - - rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer, - MultibufferResType, client, DixSetAttrAccess); - if (rc != Success) - return MultibufferErrorBase + MultibufferBadBuffer; - len = stuff->length - bytes_to_int32(sizeof (xMbufSetBufferAttributesReq)); - vmask = stuff->valueMask; - if (len != Ones (vmask)) - return BadLength; - vlist = (XID *) &stuff[1]; - while (vmask) - { - index2 = (Mask) lowbit (vmask); - vmask &= ~index2; - switch (index2) - { - case MultibufferBufferEventMask: - eventMask = (Mask) *vlist; - vlist++; - result = EventSelectForMultibuffer (pMultibuffer, client, eventMask); - if (result != Success) - return result; - break; - default: - client->errorValue = stuff->valueMask; - return BadValue; - } - } - return Success; -} - -int -ProcGetBufferAttributes (client) - ClientPtr client; -{ - REQUEST(xMbufGetBufferAttributesReq); - MultibufferPtr pMultibuffer; - xMbufGetBufferAttributesReply rep; - OtherClientsPtr other; - int n; - int rc; - - REQUEST_SIZE_MATCH (xMbufGetBufferAttributesReq); - rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer, - MultibufferResType, client, DixGetAttrAccess); - if (rc != Success) - return MultibufferErrorBase + MultibufferBadBuffer; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.window = pMultibuffer->pMultibuffers->pWindow->drawable.id; - if (bClient (pMultibuffer) == client) - rep.eventMask = pMultibuffer->eventMask; - else - { - rep.eventMask = (Mask) 0L; - for (other = pMultibuffer->otherClients; other; other = other->next) - if (SameClient (other, client)) - { - rep.eventMask = other->mask; - break; - } - } - rep.bufferIndex = pMultibuffer->number; - rep.side = pMultibuffer->side; - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.window, n); - swapl(&rep.eventMask, n); - swaps(&rep.bufferIndex, n); - } - WriteToClient(client, sizeof (xMbufGetBufferAttributesReply), (char *)&rep); - return (client->noClientException); -} - -static int -ProcGetBufferInfo (client) - ClientPtr client; -{ - REQUEST (xMbufGetBufferInfoReq); - DrawablePtr pDrawable; - xMbufGetBufferInfoReply rep; - ScreenPtr pScreen; - int i, j, k, n, rc; - xMbufBufferInfo *pInfo; - int nInfo; - DepthPtr pDepth; - - rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixUnknownAccess); - if (rc != Success) - return rc; - pScreen = pDrawable->pScreen; - nInfo = 0; - for (i = 0; i < pScreen->numDepths; i++) - { - pDepth = &pScreen->allowedDepths[i]; - nInfo += pDepth->numVids; - } - pInfo = xalloc (nInfo * sizeof (xMbufBufferInfo)); - if (!pInfo) - return BadAlloc; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = nInfo * bytes_to_int32(sizeof (xMbufBufferInfo)); - rep.normalInfo = nInfo; - rep.stereoInfo = 0; - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.normalInfo, n); - swaps(&rep.stereoInfo, n); - } - - k = 0; - for (i = 0; i < pScreen->numDepths; i++) - { - pDepth = &pScreen->allowedDepths[i]; - for (j = 0; j < pDepth->numVids; j++) - { - pInfo[k].visualID = pDepth->vids[j]; - pInfo[k].maxBuffers = 0; - pInfo[k].depth = pDepth->depth; - if (client->swapped) - { - swapl (&pInfo[k].visualID, n); - swaps (&pInfo[k].maxBuffers, n); - } - k++; - } - } - WriteToClient (client, sizeof (xMbufGetBufferInfoReply), (pointer) &rep); - WriteToClient (client, (int) nInfo * sizeof (xMbufBufferInfo), (pointer) pInfo); - xfree ((pointer) pInfo); - return client->noClientException; -} - -static int -ProcClearImageBufferArea (client) - ClientPtr client; -{ - REQUEST (xMbufClearImageBufferAreaReq); - MultibufferPtr pMultibuffer; - WindowPtr pWin; - xRectangle clearRect; - int width, height; - DrawablePtr pDrawable; - ScreenPtr pScreen; - int rc; - - REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq); - rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer, - MultibufferResType, client, DixWriteAccess); - if (rc != Success) - return MultibufferErrorBase + MultibufferBadBuffer; - if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) - { - client->errorValue = stuff->exposures; - return(BadValue); - } - pWin = pMultibuffer->pMultibuffers->pWindow; - width = pWin->drawable.width; - height = pWin->drawable.height; - pScreen = pWin->drawable.pScreen; - - clearRect.x = stuff->x; - clearRect.y = stuff->y; - clearRect.width = stuff->width ? stuff->width : width; - clearRect.height = stuff->height ? stuff->height : height; - - if (pWin->backgroundState != None) - { - GCPtr pClearGC; - pClearGC = GetScratchGC (pWin->drawable.depth, pScreen); - SetupBackgroundPainter (pWin, pClearGC); - - if (pMultibuffer->number == pMultibuffer->pMultibuffers->displayedMultibuffer) - pDrawable = (DrawablePtr)pWin; - else - pDrawable = (DrawablePtr)pMultibuffer->pPixmap; - - ValidateGC(pDrawable, pClearGC); - (*pClearGC->ops->PolyFillRect) (pDrawable, pClearGC, 1, &clearRect); - FreeScratchGC(pClearGC); - } - - if (stuff->exposures) - { - RegionRec region; - BoxRec box; - box.x1 = clearRect.x; - box.y1 = clearRect.y; - box.x2 = clearRect.x + clearRect.width; - box.y2 = clearRect.y + clearRect.height; - REGION_INIT(pScreen, ®ion, &box, 1); - MultibufferExpose(pMultibuffer, ®ion); - REGION_UNINIT(pScreen, ®ion); - } - return Success; -} - -static int -ProcMultibufferDispatch (client) - ClientPtr client; -{ - REQUEST(xReq); - switch (stuff->data) { - case X_MbufGetBufferVersion: - return ProcGetBufferVersion (client); - case X_MbufCreateImageBuffers: - return ProcCreateImageBuffers (client); - case X_MbufDisplayImageBuffers: - return ProcDisplayImageBuffers (client); - case X_MbufDestroyImageBuffers: - return ProcDestroyImageBuffers (client); - case X_MbufSetMBufferAttributes: - return ProcSetMBufferAttributes (client); - case X_MbufGetMBufferAttributes: - return ProcGetMBufferAttributes (client); - case X_MbufSetBufferAttributes: - return ProcSetBufferAttributes (client); - case X_MbufGetBufferAttributes: - return ProcGetBufferAttributes (client); - case X_MbufGetBufferInfo: - return ProcGetBufferInfo (client); - case X_MbufClearImageBufferArea: - return ProcClearImageBufferArea (client); - default: - return BadRequest; - } -} - -static int -SProcGetBufferVersion (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufGetBufferVersionReq); - - swaps (&stuff->length, n); - return ProcGetBufferVersion (client); -} - -static int -SProcCreateImageBuffers (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufCreateImageBuffersReq); - - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); - swapl (&stuff->window, n); - SwapRestL(stuff); - return ProcCreateImageBuffers (client); -} - -static int -SProcDisplayImageBuffers (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufDisplayImageBuffersReq); - - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq); - swaps (&stuff->minDelay, n); - swaps (&stuff->maxDelay, n); - SwapRestL(stuff); - return ProcDisplayImageBuffers (client); -} - -static int -SProcDestroyImageBuffers (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufDestroyImageBuffersReq); - - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq); - swapl (&stuff->window, n); - return ProcDestroyImageBuffers (client); -} - -static int -SProcSetMBufferAttributes (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufSetMBufferAttributesReq); - - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xMbufSetMBufferAttributesReq); - swapl (&stuff->window, n); - swapl (&stuff->valueMask, n); - SwapRestL(stuff); - return ProcSetMBufferAttributes (client); -} - -static int -SProcGetMBufferAttributes (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufGetMBufferAttributesReq); - - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xMbufGetMBufferAttributesReq); - swapl (&stuff->window, n); - return ProcGetMBufferAttributes (client); -} - -static int -SProcSetBufferAttributes (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufSetBufferAttributesReq); - - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xMbufSetBufferAttributesReq); - swapl (&stuff->buffer, n); - swapl (&stuff->valueMask, n); - SwapRestL(stuff); - return ProcSetBufferAttributes (client); -} - -static int -SProcGetBufferAttributes (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufGetBufferAttributesReq); - - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xMbufGetBufferAttributesReq); - swapl (&stuff->buffer, n); - return ProcGetBufferAttributes (client); -} - -static int -SProcGetBufferInfo (client) - ClientPtr client; -{ - int n; - REQUEST (xMbufGetBufferInfoReq); - - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xMbufGetBufferInfoReq); - swapl (&stuff->drawable, n); - return ProcGetBufferInfo (client); -} - -static int -SProcClearImageBufferArea(client) - ClientPtr client; -{ - char n; - REQUEST(xMbufClearImageBufferAreaReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq); - swapl(&stuff->buffer, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return ProcClearImageBufferArea(client); -} - -static int -SProcMultibufferDispatch (client) - ClientPtr client; -{ - REQUEST(xReq); - switch (stuff->data) { - case X_MbufGetBufferVersion: - return SProcGetBufferVersion (client); - case X_MbufCreateImageBuffers: - return SProcCreateImageBuffers (client); - case X_MbufDisplayImageBuffers: - return SProcDisplayImageBuffers (client); - case X_MbufDestroyImageBuffers: - return SProcDestroyImageBuffers (client); - case X_MbufSetMBufferAttributes: - return SProcSetMBufferAttributes (client); - case X_MbufGetMBufferAttributes: - return SProcGetMBufferAttributes (client); - case X_MbufSetBufferAttributes: - return SProcSetBufferAttributes (client); - case X_MbufGetBufferAttributes: - return SProcGetBufferAttributes (client); - case X_MbufGetBufferInfo: - return SProcGetBufferInfo (client); - case X_MbufClearImageBufferArea: - return SProcClearImageBufferArea (client); - default: - return BadRequest; - } -} - -static void -SUpdateNotifyEvent (from, to) - xMbufUpdateNotifyEvent *from, *to; -{ - to->type = from->type; - cpswaps (from->sequenceNumber, to->sequenceNumber); - cpswapl (from->buffer, to->buffer); - cpswapl (from->timeStamp, to->timeStamp); -} - -static void -SClobberNotifyEvent (from, to) - xMbufClobberNotifyEvent *from, *to; -{ - to->type = from->type; - cpswaps (from->sequenceNumber, to->sequenceNumber); - cpswapl (from->buffer, to->buffer); - to->state = from->state; -} - -RegionPtr CreateUnclippedWinSize(WindowPtr pWin); - -RegionPtr -CreateUnclippedWinSize (WindowPtr pWin) -{ - RegionPtr pRgn; - BoxRec box; - - box.x1 = pWin->drawable.x; - box.y1 = pWin->drawable.y; - box.x2 = pWin->drawable.x + (int) pWin->drawable.width; - box.y2 = pWin->drawable.y + (int) pWin->drawable.height; - pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1); - if (wBoundingShape (pWin) || wClipShape (pWin)) { - ScreenPtr pScreen; - pScreen = pWin->drawable.pScreen; - - REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x, - - pWin->drawable.y); - if (wBoundingShape (pWin)) - REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); - if (wClipShape (pWin)) - REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin)); - REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y); - } - return pRgn; -} - -static void -PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf) - MultibufferPtr *pMultibuffer; - MultibuffersPtr *ppMultibuffers; - int nbuf; -{ - GCPtr pGC; - PixmapPtr pPrevPixmap, pNewPixmap; - xRectangle clearRect; - WindowPtr pWin; - RegionPtr pExposed; - int i; - MultibufferPtr pPrevMultibuffer; - XID graphicsExpose; - - UpdateCurrentTime (); - for (i = 0; i < nbuf; i++) - { - pWin = ppMultibuffers[i]->pWindow; - pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen); - pPrevMultibuffer = - &ppMultibuffers[i]->buffers[ppMultibuffers[i]->displayedMultibuffer]; - pPrevPixmap = pPrevMultibuffer->pPixmap; - pNewPixmap = pMultibuffer[i]->pPixmap; - switch (ppMultibuffers[i]->updateAction) - { - case MultibufferUpdateActionUndefined: - break; - case MultibufferUpdateActionBackground: - SetupBackgroundPainter (pWin, pGC); - ValidateGC ((DrawablePtr)pPrevPixmap, pGC); - clearRect.x = 0; - clearRect.y = 0; - clearRect.width = pPrevPixmap->drawable.width; - clearRect.height = pPrevPixmap->drawable.height; - (*pGC->ops->PolyFillRect) ((DrawablePtr)pPrevPixmap, pGC, - 1, &clearRect); - break; - case MultibufferUpdateActionUntouched: - /* copy the window to the pixmap that represents the - * currently displayed buffer - */ - if (pPrevMultibuffer->eventMask & ExposureMask) - { - graphicsExpose = TRUE; - DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE); - } - ValidateGC ((DrawablePtr)pPrevPixmap, pGC); - pExposed = (*pGC->ops->CopyArea) - ((DrawablePtr) pWin, - (DrawablePtr) pPrevPixmap, - pGC, - 0, 0, - pWin->drawable.width, pWin->drawable.height, - 0, 0); - - /* if we couldn't copy the whole window to the buffer, - * send expose events (if any client wants them) - */ - if (pPrevMultibuffer->eventMask & ExposureMask) - { /* some client wants expose events */ - if (pExposed) - { - RegionPtr pWinSize; - - pWinSize = CreateUnclippedWinSize (pWin); - /* pExposed is window-relative, but at this point - * pWinSize is screen-relative. Make pWinSize be - * window-relative so that region ops involving - * pExposed and pWinSize behave sensibly. - */ - REGION_TRANSLATE(pWin->drawable.pScreen, pWinSize, - -pWin->drawable.x, -pWin->drawable.y); - REGION_INTERSECT(pWin->drawable.pScreen, pExposed, - pExposed, pWinSize); - REGION_DESTROY(pWin->drawable.pScreen, pWinSize); - MultibufferExpose (pPrevMultibuffer, pExposed); - REGION_DESTROY(pWin->drawable.pScreen, pExposed); - } - graphicsExpose = FALSE; - DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE); - } - break; /* end case MultibufferUpdateActionUntouched */ - - case MultibufferUpdateActionCopied: - ValidateGC ((DrawablePtr)pPrevPixmap, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, - (DrawablePtr)pPrevPixmap, pGC, - 0, 0, - pWin->drawable.width, pWin->drawable.height, - 0, 0); - break; - } /* end switch on update action */ - - /* display the new buffer */ - ValidateGC ((DrawablePtr)pWin, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin, pGC, - 0, 0, - pWin->drawable.width, pWin->drawable.height, - 0, 0); - ppMultibuffers[i]->lastUpdate = currentTime; - MultibufferUpdate (pMultibuffer[i], - ppMultibuffers[i]->lastUpdate.milliseconds); - AliasMultibuffer (ppMultibuffers[i], - pMultibuffer[i] - ppMultibuffers[i]->buffers); - FreeScratchGC (pGC); - } -} - -DrawablePtr -GetBufferPointer (pWin, i) - WindowPtr pWin; - int i; -{ - MultibuffersPtr pMultibuffers; - - if (!(pMultibuffers = (MultibuffersPtr) dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey))) - return NULL; - return (DrawablePtr) pMultibuffers->buffers[i].pPixmap; -} - -static Bool -QueueDisplayRequest (client, activateTime) - ClientPtr client; - TimeStamp activateTime; -{ - /* see xtest.c:ProcXTestFakeInput for code similar to this */ - - if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) - { - return FALSE; - } - /* swap the request back so we can simply re-execute it */ - if (client->swapped) - { - int n; - REQUEST (xMbufDisplayImageBuffersReq); - - SwapRestL(stuff); - swaps (&stuff->length, n); - swaps (&stuff->minDelay, n); - swaps (&stuff->maxDelay, n); - } - ResetCurrentRequest (client); - client->sequence--; - return TRUE; -} - - -/* - * Deliver events to a buffer - */ - -static int -DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter) - MultibufferPtr pMultibuffer; - xEvent *pEvents; - int count; - Mask filter; -{ - int deliveries = 0, nondeliveries = 0; - int attempt; - OtherClients *other; - - /* if nobody wants the event, we're done */ - if (!((pMultibuffer->otherEventMask|pMultibuffer->eventMask) & filter)) - return 0; - - /* maybe send event to owner */ - if ((attempt = TryClientEvents( - bClient(pMultibuffer), NULL, pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0) - { - if (attempt > 0) - deliveries++; - else - nondeliveries--; - } - - /* maybe send event to other clients */ - for (other = pMultibuffer->otherClients; other; other=other->next) - { - if ((attempt = TryClientEvents( - rClient(other), NULL, pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0) - { - if (attempt > 0) - deliveries++; - else - nondeliveries--; - } - } - if (deliveries) - return deliveries; - return nondeliveries; -} - -/* - * Send Expose events to interested clients - */ - -void -MultibufferExpose (pMultibuffer, pRegion) - MultibufferPtr pMultibuffer; - RegionPtr pRegion; -{ - if (pRegion && !REGION_NIL(pRegion)) - { - xEvent *pEvent; - PixmapPtr pPixmap; - xEvent *pe; - BoxPtr pBox; - int i; - int numRects; - - pPixmap = pMultibuffer->pPixmap; - REGION_TRANSLATE(pPixmap->drawable.pScreen, pRegion, - -pPixmap->drawable.x, -pPixmap->drawable.y); - /* XXX MultibufferExpose "knows" the region representation */ - numRects = REGION_NUM_RECTS(pRegion); - pBox = REGION_RECTS(pRegion); - - pEvent = xalloc(numRects * sizeof(xEvent)); - if (pEvent) { - pe = pEvent; - - for (i=1; i<=numRects; i++, pe++, pBox++) - { - pe->u.u.type = Expose; - pe->u.expose.window = pPixmap->drawable.id; - pe->u.expose.x = pBox->x1; - pe->u.expose.y = pBox->y1; - pe->u.expose.width = pBox->x2 - pBox->x1; - pe->u.expose.height = pBox->y2 - pBox->y1; - pe->u.expose.count = (numRects - i); - } - (void) DeliverEventsToMultibuffer (pMultibuffer, pEvent, numRects, - ExposureMask); - xfree(pEvent); - } - } -} - -/* send UpdateNotify event */ -void -MultibufferUpdate (pMultibuffer, time2) - MultibufferPtr pMultibuffer; - CARD32 time2; -{ - xMbufUpdateNotifyEvent event; - - event.type = MultibufferEventBase + MultibufferUpdateNotify; - event.buffer = pMultibuffer->pPixmap->drawable.id; - event.timeStamp = time2; - (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event, - 1, (Mask)MultibufferUpdateNotifyMask); -} - -/* - * The sample implementation will never generate MultibufferClobberNotify - * events - */ - -void -MultibufferClobber (pMultibuffer) - MultibufferPtr pMultibuffer; -{ - xMbufClobberNotifyEvent event; - - event.type = MultibufferEventBase + MultibufferClobberNotify; - event.buffer = pMultibuffer->pPixmap->drawable.id; - event.state = pMultibuffer->clobber; - (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event, - 1, (Mask)MultibufferClobberNotifyMask); -} - -/* - * make the resource id for buffer i refer to the window - * drawable instead of the pixmap; - */ - -static void -AliasMultibuffer (pMultibuffers, i) - MultibuffersPtr pMultibuffers; - int i; -{ - MultibufferPtr pMultibuffer; - - if (i == pMultibuffers->displayedMultibuffer) - return; - /* - * remove the old association - */ - if (pMultibuffers->displayedMultibuffer >= 0) - { - pMultibuffer = &pMultibuffers->buffers[pMultibuffers->displayedMultibuffer]; - ChangeResourceValue (pMultibuffer->pPixmap->drawable.id, - MultibufferDrawableResType, - (pointer) pMultibuffer->pPixmap); - } - /* - * make the new association - */ - pMultibuffer = &pMultibuffers->buffers[i]; - ChangeResourceValue (pMultibuffer->pPixmap->drawable.id, - MultibufferDrawableResType, - (pointer) pMultibuffers->pWindow); - pMultibuffers->displayedMultibuffer = i; -} - -/* - * free everything associated with multibuffering for this - * window - */ - -void -DestroyImageBuffers (pWin) - WindowPtr pWin; -{ - FreeResourceByType (pWin->drawable.id, MultibuffersResType, FALSE); - /* Zero out the window's pointer to the buffers so they won't be reused */ - dixSetPrivate(&pWin->devPrivates, MultibufferWindowPrivKey, NULL); -} - -/* - * resize the buffers when the window is resized - */ - -static Bool -MultibufferPositionWindow (pWin, x, y) - WindowPtr pWin; - int x, y; -{ - ScreenPtr pScreen; - MultibufferScreenPtr pMultibufferScreen; - MultibuffersPtr pMultibuffers; - MultibufferPtr pMultibuffer; - int width, height; - int i; - int dx, dy, dw, dh; - int sourcex, sourcey; - int destx, desty; - PixmapPtr pPixmap; - GCPtr pGC; - int savewidth, saveheight; - xRectangle clearRect; - Bool clear; - - pScreen = pWin->drawable.pScreen; - pMultibufferScreen = (MultibufferScreenPtr) dixLookupPrivate(&pScreen->devPrivates, MultibufferScreenPrivKey); - (*pMultibufferScreen->PositionWindow) (pWin, x, y); - - /* if this window is not multibuffered, we're done */ - if (!(pMultibuffers = (MultibuffersPtr) dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey))) - return TRUE; - - /* if new size is same as old, we're done */ - if (pMultibuffers->width == pWin->drawable.width && - pMultibuffers->height == pWin->drawable.height) - return TRUE; - - width = pWin->drawable.width; - height = pWin->drawable.height; - dx = pWin->drawable.x - pMultibuffers->x; - dy = pWin->drawable.x - pMultibuffers->y; - dw = width - pMultibuffers->width; - dh = height - pMultibuffers->height; - GravityTranslate (0, 0, -dx, -dy, dw, dh, - pWin->bitGravity, &destx, &desty); - - /* if the window grew, remember to paint the window background, - * and maybe send expose events, for the new areas of the buffers - */ - clear = pMultibuffers->width < width || pMultibuffers->height < height || - pWin->bitGravity == ForgetGravity; - - sourcex = 0; - sourcey = 0; - savewidth = pMultibuffers->width; - saveheight = pMultibuffers->height; - /* clip rectangle to source and destination */ - if (destx < 0) - { - savewidth += destx; - sourcex -= destx; - destx = 0; - } - if (destx + savewidth > width) - savewidth = width - destx; - if (desty < 0) - { - saveheight += desty; - sourcey -= desty; - desty = 0; - } - if (desty + saveheight > height) - saveheight = height - desty; - - pMultibuffers->width = width; - pMultibuffers->height = height; - pMultibuffers->x = pWin->drawable.x; - pMultibuffers->y = pWin->drawable.y; - - pGC = GetScratchGC (pWin->drawable.depth, pScreen); - if (clear) - { - SetupBackgroundPainter (pWin, pGC); - clearRect.x = 0; - clearRect.y = 0; - clearRect.width = width; - clearRect.height = height; - } - for (i = 0; i < pMultibuffers->numMultibuffer; i++) - { - pMultibuffer = &pMultibuffers->buffers[i]; - pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, - pWin->drawable.depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pPixmap) - { - DestroyImageBuffers (pWin); - break; - } - ValidateGC ((DrawablePtr)pPixmap, pGC); - /* - * I suppose this could avoid quite a bit of work if - * it computed the minimal area required. - */ - if (clear) - (*pGC->ops->PolyFillRect) ((DrawablePtr)pPixmap, pGC, 1, &clearRect); - if (pWin->bitGravity != ForgetGravity) - { - (*pGC->ops->CopyArea) ((DrawablePtr)pMultibuffer->pPixmap, - (DrawablePtr)pPixmap, pGC, - sourcex, sourcey, savewidth, saveheight, - destx, desty); - } - pPixmap->drawable.id = pMultibuffer->pPixmap->drawable.id; - (*pScreen->DestroyPixmap) (pMultibuffer->pPixmap); - pMultibuffer->pPixmap = pPixmap; - if (i != pMultibuffers->displayedMultibuffer) - { - ChangeResourceValue (pPixmap->drawable.id, - MultibufferDrawableResType, - (pointer) pPixmap); - } - } - FreeScratchGC (pGC); - return TRUE; -} - -/* Resource delete func for MultibufferDrawableResType */ -/*ARGSUSED*/ -static int -MultibufferDrawableDelete (value, id) - pointer value; - XID id; -{ - DrawablePtr pDrawable = (DrawablePtr)value; - WindowPtr pWin; - MultibuffersPtr pMultibuffers; - PixmapPtr pPixmap; - - if (pDrawable->type == DRAWABLE_WINDOW) - { - pWin = (WindowPtr) pDrawable; - pMultibuffers = (MultibuffersPtr) dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey); - pPixmap = pMultibuffers->buffers[pMultibuffers->displayedMultibuffer].pPixmap; - } - else - { - pPixmap = (PixmapPtr) pDrawable; - } - (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap); - return Success; -} - -/* Resource delete func for MultibufferResType */ -/*ARGSUSED*/ -static int -MultibufferDelete (value, id) - pointer value; - XID id; -{ - MultibufferPtr pMultibuffer = (MultibufferPtr)value; - MultibuffersPtr pMultibuffers; - - pMultibuffers = pMultibuffer->pMultibuffers; - if (--pMultibuffers->refcnt == 0) - { - FreeResourceByType (pMultibuffers->pWindow->drawable.id, - MultibuffersResType, TRUE); - xfree (pMultibuffers); - } - return Success; -} - -/* Resource delete func for MultibuffersResType */ -/*ARGSUSED*/ -static int -MultibuffersDelete (value, id) - pointer value; - XID id; -{ - MultibuffersPtr pMultibuffers = (MultibuffersPtr)value; - int i; - - if (pMultibuffers->refcnt == pMultibuffers->numMultibuffer) - { - for (i = pMultibuffers->numMultibuffer; --i >= 0; ) - FreeResource (pMultibuffers->buffers[i].pPixmap->drawable.id, 0); - } - return Success; -} - -/* Resource delete func for OtherClientResType */ -static int -OtherClientDelete (value, id) - pointer value; - XID id; -{ - MultibufferPtr pMultibuffer = (MultibufferPtr)value; - OtherClientsPtr other, prev; - - prev = 0; - for (other = pMultibuffer->otherClients; other; other = other->next) - { - if (other->resource == id) - { - if (prev) - prev->next = other->next; - else - pMultibuffer->otherClients = other->next; - xfree (other); - RecalculateMultibufferOtherEvents (pMultibuffer); - break; - } - prev = other; - } - return Success; -} - -static int -EventSelectForMultibuffer (pMultibuffer, client, mask) - MultibufferPtr pMultibuffer; - ClientPtr client; - Mask mask; -{ - OtherClientsPtr other; - - if (mask & ~ValidEventMasks) - { - client->errorValue = mask; - return BadValue; - } - if (bClient (pMultibuffer) == client) - { - pMultibuffer->eventMask = mask; - } - else /* some other client besides the creator wants events */ - { - for (other = pMultibuffer->otherClients; other; other = other->next) - { - if (SameClient (other, client)) - { - if (mask == 0) - { - FreeResource (other->resource, RT_NONE); - break; - } - other->mask = mask; - break; - } - } - if (!other) - { /* new client that never selected events on this buffer before */ - other = xalloc (sizeof (OtherClients)); - if (!other) - return BadAlloc; - other->mask = mask; - other->resource = FakeClientID (client->index); - if (!AddResource (other->resource, OtherClientResType, (pointer) pMultibuffer)) - { - xfree (other); - return BadAlloc; - } - other->next = pMultibuffer->otherClients; - pMultibuffer->otherClients = other; - } - RecalculateMultibufferOtherEvents (pMultibuffer); - } - return (client->noClientException); -} - -/* or together all the otherClients event masks */ -static void -RecalculateMultibufferOtherEvents (pMultibuffer) - MultibufferPtr pMultibuffer; -{ - Mask otherEventMask; - OtherClients *other; - - otherEventMask = 0L; - for (other = pMultibuffer->otherClients; other; other = other->next) - otherEventMask |= other->mask; - pMultibuffer->otherEventMask = otherEventMask; -} - -/* add milliseconds to a timestamp, handling overflow */ -static void -BumpTimeStamp (ts, inc) -TimeStamp *ts; -CARD32 inc; -{ - CARD32 newms; - - newms = ts->milliseconds + inc; - if (newms < ts->milliseconds) - ts->months++; - ts->milliseconds = newms; -} diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c deleted file mode 100644 index 7d9d60a4f..000000000 --- a/Xext/mbufbf.c +++ /dev/null @@ -1,1007 +0,0 @@ -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdio.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "extnsionst.h" -#include "dixstruct.h" -#include "resource.h" -#include "opaque.h" -#include "regionstr.h" -#include "gcstruct.h" -#include "inputstr.h" -#include "validate.h" -#include "globals.h" -#include <sys/time.h> - -#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ -#define _MULTIBUF_BUFFER_ -#include <X11/extensions/multibufst.h> - -/* -Support for doublebuffer hardare - -This code is designed to support doublebuffer hardware where the -displayed buffer is selected on a per-pixel basis by an additional bit -plane, called the select plane. It could probably be easily modified -to work with systems that use window-id planes. - -This is done by creating a new drawable type, DRAWABLE_BUFFER. The -type has the same exact layout as a window drawable. Your code should -treat a DRAWABLE_BUFFER the same as it would tread a DRAWABLE_WINDOW -when handling the gc drawing functions. In addition, PaintWindowBackground, -CopyWindow, and all of the gc drawing functions to be able to draw into both -framebuffers. Which framebuffer to draw into is selected by the contents of - pWin->devPrivates[frameWindowPrivateIndex]. -The content of the devPrivate is either from frameBuffer[0] or -frameBuffer[1], depending on which buffer is being drawn into. When - pWin->devPrivates[frameWindowPrivateIndex] == frameBuffer[0], -the functions should draw into the front framebuffer. When - pWin->devPrivates[frameWindowPrivateIndex] == frameBuffer[1], -the functions should draw into the back framebuffer. - -In addition, you need to provide a function that allows you to copy -bits between the buffers (optional since CopyArea can be used) and a -function that draws into the select plane. Then, you need to register -your functions and other information, by calling: - -void -RegisterDoubleBufferHardware(pScreen, nInfo, pInfo, frameBuffer, selectPlane, - CopyBufferBitsFunc, DrawSelectPlaneFunc) - int nInfo; - xMbufBufferInfo *pInfo; - DevUnion *frameBuffer; - DevUnion selectPlane; - -"pInfo" is an array indicating which visuals and depths that double -buffering is supported on. "nInfo" is the length of the array. - -"frameBuffer" is array of length 2. The contents of the array element -is ddx-specific. The content of frameBuffer[0] should, when placed in -the window private, indicate that framebuffer 0 should be drawn into. -The contents of frameBuffer[1], when placed into the window private, -should indicate that framebuffer 1 should be drawn into. - -"selectPlane" is ddx-specific. It should contain information -neccessary for your displayProc to access the select plane. -It is passed to DrawSelectPlaneFunc. - -"CopyBufferBitsFunc" is a ddx-specific function that copies from one -buffer of a multibuffered window to another buffer. If the CopyBufferBitsFunc -is NULL, a default function will be used that calls pScreen->CopyArea. - - void CopyBufferBitsFunc(pMBWindow, srcBufferNum, dstBufferNum) - mbufWindowPtr pMBWindow; - int srcBufferNum, dstBufferNum; - -"DrawSelectPlaneFunc" is a ddx-specific function that fills the -regions "prgn" of select plane with the value "bufferNum". If -selectPlane is a DrawablePtr (such as a PixmapPtr), you can pass -NULL for DrawSelectPlaneFunc, a default function will be used that -calls FillRectangle on the selectPlane. - - void DrawSelectPlaneFunc(pScreen, selectPlane, prgn, bufferNum) - ScreenPtr pScreen; - DevUnion selectPlane; - RegionPtr prgn; - long bufferNum; - -... -... -... - -*/ - -#define MAX_BUFFERS 2 /* Only supports 2 buffers */ -#define FRONT_BUFFER 0 -#define BACK_BUFFER 1 - - -/* Buffer drawables have the same structure as window drawables */ -typedef WindowRec BufferRec; -typedef WindowPtr BufferPtr; - - -/* - * Call RegisterHdwrBuffer for every screen that has doublebuffer hardware. - */ - -static int bufNumInfo[MAXSCREENS]; -static xMbufBufferInfo *bufInfo[MAXSCREENS]; -static DevUnion *bufFrameBuffer[MAXSCREENS]; -static DevUnion bufselectPlane[MAXSCREENS]; -static void (* bufCopyBufferBitsFunc[MAXSCREENS])(); -static void (* bufDrawSelectPlaneFunc[MAXSCREENS])(); - -static Bool bufMultibufferInit(); - - -void -RegisterDoubleBufferHardware(pScreen, nInfo, pInfo, frameBuffer, selectPlane, - CopyBufferBitsFunc, DrawSelectPlaneFunc) - ScreenPtr pScreen; - int nInfo; - xMbufBufferInfo *pInfo; - DevUnion *frameBuffer; - DevUnion selectPlane; - void (* CopyBufferBitsFunc)(); - void (* DrawSelectPlaneFunc)(); -{ - bufNumInfo[pScreen->myNum] = nInfo; - bufInfo[pScreen->myNum] = pInfo; - bufFrameBuffer[pScreen->myNum] = frameBuffer; - bufselectPlane[pScreen->myNum] = selectPlane; - - bufCopyBufferBitsFunc[pScreen->myNum] = CopyBufferBitsFunc; - bufDrawSelectPlaneFunc[pScreen->myNum] = DrawSelectPlaneFunc; - - /* Register ourselves with device-independent multibuffers code */ - RegisterMultibufferInit(pScreen, bufMultibufferInit); -} - - -/* - * Called by Multibuffer extension initialization. - * Initializes mbufScreenRec and its devPrivate. - */ - -static Bool NoopDDA_True() { return TRUE; } -static Bool bufPositionWindow(); -static int bufCreateImageBuffers(); -static void bufDestroyImageBuffers(); -static void bufDisplayImageBuffers(); -static void bufClearImageBufferArea(); -static void bufDestroyBuffer(); -static void bufCopyBufferBits(); -static void bufDrawSelectPlane(); -static void bufWrapScreenFuncs(); -static void bufResetProc(); - -static void bufPostValidateTree(); -static void bufClipNotify(); -static void bufWindowExposures(); -static Bool bufChangeWindowAttributes(); -static void bufClearToBackground(); -static void bufCopyWindow(); - -static Bool -bufMultibufferInit(pScreen, pMBScreen) - ScreenPtr pScreen; - mbufScreenPtr pMBScreen; -{ - mbufBufferPrivPtr pMBPriv; - BoxRec box; - - /* Multibuffer info */ - pMBScreen->nInfo = bufNumInfo[pScreen->myNum]; - pMBScreen->pInfo = bufInfo[pScreen->myNum]; - - /* Hooks */ - pMBScreen->CreateImageBuffers = bufCreateImageBuffers; - pMBScreen->DestroyImageBuffers = bufDestroyImageBuffers; - pMBScreen->DisplayImageBuffers = bufDisplayImageBuffers; - pMBScreen->ClearImageBufferArea = bufClearImageBufferArea; - pMBScreen->ChangeMBufferAttributes = NoopDDA_True; - pMBScreen->ChangeBufferAttributes = NoopDDA_True; - pMBScreen->DeleteBufferDrawable = bufDestroyBuffer; - pMBScreen->WrapScreenFuncs = bufWrapScreenFuncs; - pMBScreen->ResetProc = bufResetProc; - /* Create devPrivate part */ - pMBPriv = xalloc(sizeof *pMBPriv); - if (!pMBPriv) - return (FALSE); - - pMBScreen->devPrivate.ptr = (pointer) pMBPriv; - pMBPriv->frameBuffer = bufFrameBuffer[pScreen->myNum]; - pMBPriv->selectPlane = bufselectPlane[pScreen->myNum]; - - /* - * Initializing the subtractRgn to the screen area will ensure that - * the selectPlane will get cleared on the first PostValidateTree. - */ - - box.x1 = 0; - box.y1 = 0; - box.x2 = pScreen->width; - box.y2 = pScreen->height; - - pMBPriv->rgnChanged = TRUE; - REGION_INIT(pScreen, &pMBPriv->backBuffer, &box, 1); - REGION_INIT(pScreen, &pMBPriv->subtractRgn, &box, 1); - REGION_NULL(pScreen, &pMBPriv->unionRgn); - - /* Misc functions */ - pMBPriv->CopyBufferBits = bufCopyBufferBitsFunc[pScreen->myNum]; - pMBPriv->DrawSelectPlane = bufDrawSelectPlaneFunc[pScreen->myNum]; - - if (!pMBPriv->CopyBufferBits) - pMBPriv->CopyBufferBits = bufCopyBufferBits; - - if (!pMBPriv->DrawSelectPlane) - pMBPriv->DrawSelectPlane = bufDrawSelectPlane; - - /* screen functions */ - pMBPriv->funcsWrapped = 0; - pMBPriv->inClearToBackground = FALSE; - pMBPriv->WindowExposures = NULL; - pMBPriv->CopyWindow = NULL; - pMBPriv->ClearToBackground = NULL; - pMBPriv->ClipNotify = NULL; - pMBPriv->ChangeWindowAttributes = NULL; - - /* Start out wrapped to clear select plane */ - WRAP_SCREEN_FUNC(pScreen,pMBPriv,PostValidateTree, bufPostValidateTree); - return TRUE; -} - -static void -UpdateBufferFromWindow(pBuffer, pWin) - BufferPtr pBuffer; - WindowPtr pWin; -{ - pBuffer->drawable.x = pWin->drawable.x; - pBuffer->drawable.y = pWin->drawable.y; - pBuffer->drawable.width = pWin->drawable.width; - pBuffer->drawable.height = pWin->drawable.height; - - pBuffer->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - /* Update for PaintWindowBackground */ - pBuffer->parent = pWin->parent; - - /* - * Make the borderClip the same as the clipList so - * NotClippedByChildren comes out with just clipList. - */ - - pBuffer->clipList = pWin->clipList; - pBuffer->borderClip = pWin->clipList; - pBuffer->winSize = pWin->winSize; - pBuffer->borderSize = pWin->borderSize; - - pBuffer->origin = pWin->origin; -} - -static BufferPtr -bufCreateBuffer(pScreen, pWin, bufferNum) - ScreenPtr pScreen; - WindowPtr pWin; - int bufferNum; -{ - mbufBufferPrivPtr pMBPriv; - DevUnion *devPrivates; - BufferPtr pBuffer; - int i; - - pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - pBuffer = AllocateWindow(pWin->drawable.pScreen); - if (!pBuffer) - return (NULL); - - /* XXX- Until we know what is needed, copy everything. */ - devPrivates = pBuffer->devPrivates; - *pBuffer = *pWin; - pBuffer->devPrivates = devPrivates; - - pBuffer->drawable.type = DRAWABLE_BUFFER; - pBuffer->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - pBuffer->nextSib = NULL; - pBuffer->prevSib = NULL; - pBuffer->firstChild = NULL; - pBuffer->lastChild = NULL; - - /* XXX - Need to call pScreen->CreateWindow for tile/stipples - * or should I just copy the devPrivates? - */ - - for (i=0; i < pScreen->WindowPrivateLen; i++) - pBuffer->devPrivates[i] = pWin->devPrivates[i]; - - pBuffer->devPrivates[frameWindowPrivateIndex] = - pMBPriv->frameBuffer[bufferNum]; - - return pBuffer; -} - -static void -bufDestroyBuffer(pDrawable) - DrawablePtr pDrawable; -{ - xfree(pDrawable); -} - -/*ARGSUSED*/ -static int -bufCreateImageBuffers (pWin, nbuf, ids, action, hint) - WindowPtr pWin; - int nbuf; - XID *ids; - int action; - int hint; -{ - ScreenPtr pScreen; - mbufScreenPtr pMBScreen; - mbufWindowPtr pMBWindow; - mbufBufferPtr pMBBuffer; - int i; - - pScreen = pWin->drawable.pScreen; - pMBScreen = MB_SCREEN_PRIV(pScreen); - pMBWindow = MB_WINDOW_PRIV(pWin); - - pMBWindow->devPrivate.ptr = (pointer) REGION_CREATE(pScreen, 0,0); - if (!pMBWindow->devPrivate.ptr) - return(0); - REGION_COPY(pScreen, (RegionPtr) pMBWindow->devPrivate.ptr, - &pWin->clipList); - - for (i = 0; i < nbuf; i++) - { - pMBBuffer = pMBWindow->buffers + i; - pMBBuffer->pDrawable = (DrawablePtr) bufCreateBuffer(pScreen,pWin,i); - - if (!pMBBuffer->pDrawable) - break; - - if (!AddResource (ids[i], MultibufferDrawableResType, - (pointer) pMBBuffer->pDrawable)) - { - bufDestroyBuffer((BufferPtr) pMBBuffer->pDrawable); - break; - } - pMBBuffer->pDrawable->id = ids[i]; - - /* - * If window is already mapped, generate exposures and - * clear the area of the newly buffers. - */ - - if ((pWin->realized) && (i != pMBWindow->displayedMultibuffer)) - (* pMBScreen->ClearImageBufferArea)(pMBBuffer, 0,0, 0,0, TRUE); - } - - return i; -} - -static void -bufDestroyImageBuffers(pWin) - WindowPtr pWin; -{ - ScreenPtr pScreen; - mbufWindowPtr pMBWindow; - - pScreen = pWin->drawable.pScreen; - - if (pMBWindow = MB_WINDOW_PRIV(pWin)) - { - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - /* - * if the backbuffer is currently being displayed, move the bits - * to the frontbuffer and display it instead. - */ - - if (pWin->realized && (pMBWindow->displayedMultibuffer == BACK_BUFFER)) - { - (* pMBPriv->CopyBufferBits)(pMBWindow, BACK_BUFFER, FRONT_BUFFER); - REGION_SUBTRACT(pScreen, &pMBPriv->backBuffer, - &pMBPriv->backBuffer, &pWin->clipList); - (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane, - &pWin->clipList, FRONT_BUFFER); - } - - /* Switch window rendering to front buffer */ - pWin->devPrivates[frameWindowPrivateIndex] = - pMBPriv->frameBuffer[FRONT_BUFFER]; - - REGION_DESTROY(pScreen, (RegionPtr) pMBWindow->devPrivate.ptr); - pMBWindow->devPrivate.ptr = NULL; - } -} - -/* - * Can be replaced by pScreen->ClearToBackground if pBuffer->eventMask - * and wOtherEventsMasks(pBuffer) were setup. - */ - -static void -bufClearImageBufferArea(pMBBuffer, x,y, w,h, generateExposures) - mbufBufferPtr pMBBuffer; - short x,y; - unsigned short w,h; - Bool generateExposures; -{ - BoxRec box; - RegionRec reg; - RegionPtr pBSReg = NullRegion; - ScreenPtr pScreen; - BoxPtr extents; - int x1, y1, x2, y2; - BufferPtr pBuffer; - - pBuffer = (BufferPtr) pMBBuffer->pDrawable; - /* compute everything using ints to avoid overflow */ - - x1 = pBuffer->drawable.x + x; - y1 = pBuffer->drawable.y + y; - if (w) - x2 = x1 + (int) w; - else - x2 = x1 + (int) pBuffer->drawable.width - (int) x; - if (h) - y2 = y1 + h; - else - y2 = y1 + (int) pBuffer->drawable.height - (int) y; - - extents = &pBuffer->clipList.extents; - - /* clip the resulting rectangle to the window clipList extents. This - * makes sure that the result will fit in a box, given that the - * screen is < 32768 on a side. - */ - - if (x1 < extents->x1) - x1 = extents->x1; - if (x2 > extents->x2) - x2 = extents->x2; - if (y1 < extents->y1) - y1 = extents->y1; - if (y2 > extents->y2) - y2 = extents->y2; - - if (x2 <= x1 || y2 <= y1) - { - x2 = x1 = 0; - y2 = y1 = 0; - } - - box.x1 = x1; - box.x2 = x2; - box.y1 = y1; - box.y2 = y2; - - pScreen = pBuffer->drawable.pScreen; - REGION_INIT(pScreen, ®, &box, 1); - - REGION_INTERSECT(pScreen, ®, ®, &pBuffer->clipList); - if (pBuffer->backgroundState != None) - miPaintWindow(pBuffer, ®, PW_BACKGROUND); - if (generateExposures) - MultibufferExpose(pMBBuffer, ®); -#ifdef _notdef - /* XXBS - This is the original miClearToBackground code. - * WindowExposures needs to be called (or the functionality emulated) - * in order for backingStore to work, but first, pBuffer->eventMask - * and wOtherEventsMasks(pBuffer) need to be setup correctly. - */ - - if (generateExposures) - (*pScreen->WindowExposures)(pBuffer, ®, pBSReg); - else if (pBuffer->backgroundState != None) - miPaintWindow(pBuffer, ®, PW_BACKGROUND); -#endif - REGION_UNINIT(pScreen, ®); - if (pBSReg) - REGION_DESTROY(pScreen, pBSReg); -} - -static void -bufWrapScreenFuncs(pScreen) - ScreenPtr pScreen; -{ - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - WRAP_SCREEN_FUNC(pScreen,pMBPriv,PostValidateTree, bufPostValidateTree); - WRAP_SCREEN_FUNC(pScreen,pMBPriv,ClipNotify, bufClipNotify); - WRAP_SCREEN_FUNC(pScreen,pMBPriv,WindowExposures,bufWindowExposures); - WRAP_SCREEN_FUNC(pScreen,pMBPriv,ChangeWindowAttributes, bufChangeWindowAttributes); - WRAP_SCREEN_FUNC(pScreen,pMBPriv,ClearToBackground,bufClearToBackground); - WRAP_SCREEN_FUNC(pScreen,pMBPriv,CopyWindow,bufCopyWindow); -} - -static void -bufResetProc(pScreen) - ScreenPtr pScreen; -{ - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - /* - * frameBuffer, selectPlane, and pInfo should be freed by - * whoever called RegisterDoubleBufferHardware - */ - - REGION_UNINIT(pScreen, &pMBPriv->backBuffer); - REGION_UNINIT(pScreen, &pMBPriv->subtractRgn); - REGION_UNINIT(pScreen, &pMBPriv->unionRgn); - xfree(pMBPriv); -} - -/*---------------------------------------------------------------------------*/ - -/* - * Used if CopyBufferBitsFunc is not provided when registering. - * This should work for everybody since CopyArea needs to support - * copying between buffers anyway. - */ - -static void -bufCopyBufferBits(pMBWindow, srcBufferNum, dstBufferNum) - mbufWindowPtr pMBWindow; - int srcBufferNum, dstBufferNum; -{ - DrawablePtr pSrcBuffer, pDstBuffer; - GCPtr pGC; - - pSrcBuffer = pMBWindow->buffers[srcBufferNum].pDrawable; - pDstBuffer = pMBWindow->buffers[dstBufferNum].pDrawable; - - pGC = GetScratchGC (pDstBuffer->depth, pDstBuffer->pScreen); - if (!pGC) - return; - - ValidateGC (pDstBuffer, pGC); - (* pGC->ops->CopyArea) (pSrcBuffer, pDstBuffer, pGC, - 0,0, pDstBuffer->width, pDstBuffer->height, 0,0); - FreeScratchGC (pGC); -} - -/* - * Used if DrawSelectPlanFunc is not provided for when registering. - * However, it only works if selectPlane.ptr is a drawable. Also - * assumes that painting with color 0 selects the front buffer, - * while color 1 selects the back buffer. - */ - -static void -bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum) - ScreenPtr pScreen; - DevUnion selectPlane; - RegionPtr prgn; - long bufferNum; -{ - DrawablePtr pDrawable; - GCPtr pGC; - int i; - BoxPtr pbox; - xRectangle *prect; - int numRects; - XID value; - - if (REGION_NUM_RECTS(prgn) == 0) - return; - - pDrawable = (DrawablePtr) selectPlane.ptr; - pGC = GetScratchGC (pDrawable->depth, pScreen); - if (!pGC) - return; - - prect = xalloc(REGION_NUM_RECTS(prgn) * sizeof(xRectangle)); - if (!prect) - { - FreeScratchGC(pGC); - return; - } - - value = (XID) bufferNum; - DoChangeGC(pGC, GCForeground, &value, 0); - ValidateGC(pDrawable, pGC); - - numRects = REGION_NUM_RECTS(prgn); - pbox = REGION_RECTS(prgn); - for (i= numRects; --i >= 0; pbox++, prect++) - { - prect->x = pbox->x1; - prect->y = pbox->y1; - prect->width = pbox->x2 - pbox->x1; - prect->height = pbox->y2 - pbox->y1; - } - prect -= numRects; - (* pGC->ops->PolyFillRect)(pDrawable, pGC, numRects, prect); - - xfree(prect); - FreeScratchGC (pGC); -} - - -static void -bufDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf) - ScreenPtr pScreen; - mbufBufferPtr *ppMBBuffer; - mbufWindowPtr *ppMBWindow; - int nbuf; -{ - WindowPtr pWin; - BufferPtr pPrevBuffer, pNewBuffer; - int i, number; - mbufBufferPrivPtr pMBPriv; - mbufBufferPtr pPrevMBBuffer; - - pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - for (i = 0; i < nbuf; i++) - { - number = ppMBBuffer[i]->number; /* 0=frontbuffer, 1=backbuffer */ - pWin = ppMBWindow[i]->pWindow; - pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]); - - pPrevBuffer = (BufferPtr) pPrevMBBuffer->pDrawable; - pNewBuffer = (BufferPtr) ppMBBuffer[i]->pDrawable; - - if (pPrevBuffer != pNewBuffer) - { - RegionPtr backBuffer = &pMBPriv->backBuffer; - - /* - * Update the select plane and the backBuffer region. - */ - - (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane, - &pWin->clipList, number); - - if (number == BACK_BUFFER) - REGION_UNION(pScreen, backBuffer, backBuffer, - &pWin->clipList); - else - REGION_SUBTRACT(pScreen, backBuffer, backBuffer, - &pWin->clipList); - - /* Switch which framebuffer the window draws into */ - pWin->devPrivates[frameWindowPrivateIndex] = - pMBPriv->frameBuffer[number]; - } - - switch (ppMBWindow[i]->updateAction) - { - case MultibufferUpdateActionUndefined: - break; - case MultibufferUpdateActionBackground: - (* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea) - (pPrevMBBuffer, 0,0, 0,0, FALSE); - break; - case MultibufferUpdateActionUntouched: - break; - case MultibufferUpdateActionCopied: - if (pPrevBuffer != pNewBuffer) - { - (* pMBPriv->CopyBufferBits) (ppMBWindow[i], - ppMBBuffer[i]->number, pPrevMBBuffer->number); - } - break; - } - } -} - -/* Updates the backBuffer region and paints the selectPlane. */ - -static void -bufPostValidateTree(pParent, pChild, kind) - WindowPtr pParent, pChild; - VTKind kind; -{ - ScreenPtr pScreen; - mbufBufferPrivPtr pMBPriv; - - if (pParent) - pScreen = pParent->drawable.pScreen; - else if (pChild) - pScreen = pChild->drawable.pScreen; - else - return; /* Hopeless */ - - pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, PostValidateTree); - if (pScreen->PostValidateTree) - (* pScreen->PostValidateTree)(pParent, pChild, kind); - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, PostValidateTree); - - /* Does backBuffer need to change? */ - if (pMBPriv->rgnChanged) - { - RegionRec exposed; - RegionPtr pSubtractRgn, pUnionRgn; - Bool overlap; - - pMBPriv->rgnChanged = FALSE; - - pSubtractRgn = &pMBPriv->subtractRgn; - pUnionRgn = &pMBPriv->unionRgn; - REGION_VALIDATE(pScreen, pSubtractRgn, &overlap); -#ifdef DEBUG - if (overlap) - FatalError("bufPostValidateTree: subtractRgn overlaps"); -#endif - REGION_VALIDATE(pScreen, pUnionRgn, &overlap); -#ifdef DEBUG - if (overlap) - FatalError("bufPostValidateTree: unionRgn overlaps"); -#endif - - /* Update backBuffer: subtract must come before union */ - REGION_SUBTRACT(pScreen, &pMBPriv->backBuffer, &pMBPriv->backBuffer, - pSubtractRgn); - REGION_UNION(pScreen, &pMBPriv->backBuffer, &pMBPriv->backBuffer, - pUnionRgn); - - /* Paint gained and lost backbuffer areas in select plane */ - REGION_NULL(pScreen, &exposed); - REGION_SUBTRACT(pScreen, &exposed, pSubtractRgn, pUnionRgn); - (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane, - &exposed, FRONT_BUFFER); - - REGION_SUBTRACT(pScreen, &exposed, pUnionRgn, pSubtractRgn); - (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane, - &exposed, BACK_BUFFER); - - REGION_UNINIT(pScreen, &exposed); - REGION_EMPTY(pScreen, pSubtractRgn); - REGION_EMPTY(pScreen, pUnionRgn); - } -} - -/* - * If the window is multibuffered and displaying the backbuffer, - * add the old clipList to the subtractRgn and add the new clipList - * to the unionRgn. PostValidateTree will use subtractRgn and unionRgn - * to update the backBuffer region and the selectPlane. - * - * Copy changes to the window structure into the buffers. - * Send ClobberNotify events. - */ - -static void -bufClipNotify(pWin, dx,dy) - WindowPtr pWin; - int dx,dy; -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - mbufWindowPtr pMBWindow; - int i; - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClipNotify); - if (pScreen->ClipNotify) - (* pScreen->ClipNotify)(pWin, dx,dy); - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClipNotify); - - if (pMBWindow = MB_WINDOW_PRIV(pWin)) - { - RegionPtr pOldClipList = (RegionPtr) pMBWindow->devPrivate.ptr; - - if (! REGION_EQUAL(pScreen, pOldClipList, &pWin->clipList)) - { - if (pMBWindow->displayedMultibuffer == BACK_BUFFER) - { - pMBPriv->rgnChanged = TRUE; - REGION_APPEND(pScreen, &pMBPriv->subtractRgn, pOldClipList); - REGION_APPEND(pScreen, &pMBPriv->unionRgn, &pWin->clipList); - } - - REGION_COPY(pScreen, pOldClipList,&pWin->clipList); - } - - /* Update buffer x,y,w,h, and clipList */ - for (i=0; i<pMBWindow->numMultibuffer; i++) - { - mbufBufferPtr pMBBuffer = pMBWindow->buffers + i; - if (pMBBuffer->clobber != pWin->visibility) - { - pMBBuffer->clobber = pWin->visibility; - MultibufferClobber(pMBBuffer); - } - UpdateBufferFromWindow(pMBBuffer->pDrawable, pWin); - } - } -} - -/* - * Updates buffer's background fields when the window's changes. - * This is necessary because miPaintWindow is used to paint the buffer. - * - * XXBS - Backingstore state will have be tracked too if it is supported. - */ - -static Bool -bufChangeWindowAttributes(pWin, mask) - WindowPtr pWin; - unsigned long mask; -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - mbufWindowPtr pMBWindow; - Bool ret; - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, ChangeWindowAttributes); - ret = (* pScreen->ChangeWindowAttributes)(pWin, mask); - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, ChangeWindowAttributes); - - if (pMBWindow = MB_WINDOW_PRIV(pWin)) - { - if (mask & (CWBackPixmap | CWBackPixel)) - { - BufferPtr pBuffer; - int i; - - for (i=0; i<pMBWindow->displayedMultibuffer; i++) - { - pBuffer = (BufferPtr) pMBWindow->buffers[i].pDrawable; - pBuffer->backgroundState = pWin->backgroundState; - pBuffer->background = pWin->background; - } - } - } - return ret; -} - -/* - * Send exposures and clear the background for a buffer whenever - * its corresponding window is exposed, except when called by - * ClearToBackground. - */ - -static void -bufWindowExposures(pWin, prgn, other_exposed) - WindowPtr pWin; - RegionPtr prgn, other_exposed; -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - mbufWindowPtr pMBWindow = MB_WINDOW_PRIV(pWin); - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - RegionRec tmp_rgn; - int i; - Bool handleBuffers; - - handleBuffers = (!pMBPriv->inClearToBackground) && - (pWin->drawable.type == DRAWABLE_WINDOW) && - pMBWindow && (prgn && !REGION_NIL(prgn)); - - /* miWindowExposures munges prgn and other_exposed. */ - if (handleBuffers) - { - REGION_NULL(pScreen, &tmp_rgn); - REGION_COPY(pScreen, &tmp_rgn, prgn); - } - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, WindowExposures); - (* pScreen->WindowExposures) (pWin, prgn, other_exposed); - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, WindowExposures); - - if (!handleBuffers) - return; - - /* - * Send expose events to all clients. Paint the exposed region for all - * buffers except the displayed buffer since it is handled when the - * window is painted. - * - * XXBS - Will have to be re-written to handle BackingStore on buffers. - */ - - for (i=0; i<pMBWindow->numMultibuffer; i++) - { - mbufBufferPtr pMBBuffer; - BufferPtr pBuffer; - - pMBBuffer = pMBWindow->buffers + i; - pBuffer = (BufferPtr) pMBBuffer->pDrawable; - - if (i != pMBWindow->displayedMultibuffer) - miPaintWindow(pBuffer, &tmp_rgn, PW_BACKGROUND); - if ((pMBBuffer->otherEventMask | pMBBuffer->eventMask) & ExposureMask) - MultibufferExpose(pMBBuffer, &tmp_rgn); - } - - REGION_UNINIT(pScreen, &tmp_rgn); -} - -/* - * Set ``inClearToBackground'' so that WindowExposures does not attempt - * to send expose events or clear the background on the buffers. - */ - -static void -bufClearToBackground(pWin, x,y,w,h, sendExpose) - WindowPtr pWin; - int x,y, w,h; - Bool sendExpose; -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - - pMBPriv->inClearToBackground = TRUE; - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClearToBackground); - (* pScreen->ClearToBackground)(pWin, x,y,w,h, sendExpose); - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClearToBackground); - - pMBPriv->inClearToBackground = FALSE; -} - -/* - * Move bits in both buffers. It does this by calling pScreen->CopyWindow - * twice, once with the root window's devPrivate[frameWindowPrivateIndex] - * pointing to the frontbuffer pixmap and once with it pointed to the - * backbuffer pixmap. It does this if there are *any* existing multibuffered - * window... a possible optimization is to copy the backbuffer only if this - * window or its inferiors are multibuffered. May be faster, maybe not. - * - * XXX - Only works if your CopyWindow checks the root window's devPrivate - * to see which buffer to draw into. Works for cfbPaintWindow. - */ - -/*ARGSUSED*/ -static void -bufCopyWindow(pWin, ptOldOrg, prgnSrc) - WindowPtr pWin; - DDXPointRec ptOldOrg; - RegionPtr prgnSrc; -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen); - WindowPtr pwinroot; - DevUnion save; - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, CopyWindow); - - pwinroot = WindowTable[pScreen->myNum]; - save = pwinroot->devPrivates[frameWindowPrivateIndex]; - - /* - * Copy front buffer - */ - - pwinroot->devPrivates[frameWindowPrivateIndex] = - pMBPriv->frameBuffer[FRONT_BUFFER]; - (* pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); - - /* - * Copy back buffer - */ - - /* CopyWindow translates prgnSrc... translate it back for 2nd call. */ - REGION_TRANSLATE(pScreen, prgnSrc, - ptOldOrg.x - pWin->drawable.x, - ptOldOrg.y - pWin->drawable.y); - pwinroot->devPrivates[frameWindowPrivateIndex] = - pMBPriv->frameBuffer[BACK_BUFFER]; - (* pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); - - pwinroot->devPrivates[frameWindowPrivateIndex] = save; - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, CopyWindow); -} diff --git a/Xext/mbufpx.c b/Xext/mbufpx.c deleted file mode 100644 index 8421ba9eb..000000000 --- a/Xext/mbufpx.c +++ /dev/null @@ -1,648 +0,0 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdio.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "extnsionst.h" -#include "dixstruct.h" -#include "resource.h" -#include "opaque.h" -#include "regionstr.h" -#include "gcstruct.h" -#include "inputstr.h" -#include <sys/time.h> - -#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ -#define _MULTIBUF_PIXMAP_ -#include <X11/extensions/multibufst.h> - - -static Bool NoopDDA_True() { return TRUE; } - -static Bool pixPositionWindow(); -static int pixCreateImageBuffers(); -static void pixDisplayImageBuffers(); -static void pixClearImageBufferArea(); -static void pixDeleteBufferDrawable(); -static void pixWrapScreenFuncs(); -static void pixResetProc(); - -Bool -pixMultibufferInit(pScreen, pMBScreen) - ScreenPtr pScreen; - mbufScreenPtr pMBScreen; -{ - int i, j, k; - xMbufBufferInfo *pInfo; - int nInfo; - DepthPtr pDepth; - mbufPixmapPrivPtr pMBPriv; - - pMBScreen->CreateImageBuffers = pixCreateImageBuffers; - pMBScreen->DestroyImageBuffers = (void (*)())NoopDDA; - pMBScreen->DisplayImageBuffers = pixDisplayImageBuffers; - pMBScreen->ClearImageBufferArea = pixClearImageBufferArea; - pMBScreen->ChangeMBufferAttributes = NoopDDA_True; - pMBScreen->ChangeBufferAttributes = NoopDDA_True; - pMBScreen->DeleteBufferDrawable = pixDeleteBufferDrawable; - pMBScreen->WrapScreenFuncs = pixWrapScreenFuncs; - pMBScreen->ResetProc = pixResetProc; - - /* Support every depth and visual combination that the screen does */ - - nInfo = 0; - for (i = 0; i < pScreen->numDepths; i++) - { - pDepth = &pScreen->allowedDepths[i]; - nInfo += pDepth->numVids; - } - - pInfo = xalloc (nInfo * sizeof (xMbufBufferInfo)); - if (!pInfo) - return FALSE; - - k = 0; - for (i = 0; i < pScreen->numDepths; i++) - { - pDepth = &pScreen->allowedDepths[i]; - for (j = 0; j < pDepth->numVids; j++) - { - pInfo[k].visualID = pDepth->vids[j]; - pInfo[k].maxBuffers = 0; - pInfo[k].depth = pDepth->depth; - k++; - } - } - - pMBScreen->nInfo = nInfo; - pMBScreen->pInfo = pInfo; - - /* - * Setup the devPrivate to mbufScreenRec - */ - - pMBPriv = xalloc(sizeof(* pMBPriv)); - if (!pMBPriv) - { - xfree(pInfo); - return (FALSE); - } - pMBScreen->devPrivate.ptr = (pointer) pMBPriv; - pMBPriv->PositionWindow = NULL; - pMBPriv->funcsWrapped = 0; - - return TRUE; -} - -/*ARGSUSED*/ -static int -pixCreateImageBuffers (pWin, nbuf, ids, action, hint) - WindowPtr pWin; - int nbuf; - XID *ids; - int action; - int hint; -{ - mbufWindowPtr pMBWindow; - mbufBufferPtr pMBBuffer; - ScreenPtr pScreen; - int width, height, depth; - int i; - - pMBWindow = MB_WINDOW_PRIV(pWin); - - width = pWin->drawable.width; - height = pWin->drawable.height; - depth = pWin->drawable.depth; - pScreen = pWin->drawable.pScreen; - - for (i = 0; i < nbuf; i++) - { - pMBBuffer = &pMBWindow->buffers[i]; - pMBBuffer->pDrawable = (DrawablePtr) - (*pScreen->CreatePixmap) (pScreen, width, height, depth, 0); - if (!pMBBuffer->pDrawable) - break; - - if (!AddResource (ids[i], MultibufferDrawableResType, - (pointer) pMBBuffer->pDrawable)) - { - (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable); - break; - } - pMBBuffer->pDrawable->id = ids[i]; - - /* - * In the description of the CreateImageBuffers request: - * "If the window is mapped, or if these image buffers have - * backing store, their contents will be tiled with the window - * background, and zero or more expose events will be generated - * for each of these buffers." - */ - - (* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea) - (pMBBuffer, 0,0, 0,0, TRUE); - } - - return i; -} - -/* - * set up the gc to clear the pixmaps; - */ -static Bool -SetupBackgroundPainter (pWin, pGC) - WindowPtr pWin; - GCPtr pGC; -{ - XID gcvalues[4]; - int ts_x_origin, ts_y_origin; - PixUnion background; - int backgroundState; - Mask gcmask; - - /* - * 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. - */ - - ts_x_origin = ts_y_origin = 0; - while (pWin->backgroundState == ParentRelative) { - ts_x_origin -= pWin->origin.x; - ts_y_origin -= pWin->origin.y; - pWin = pWin->parent; - } - backgroundState = pWin->backgroundState; - background = pWin->background; - - switch (backgroundState) - { - case BackgroundPixel: - gcvalues[0] = (XID) background.pixel; - gcvalues[1] = FillSolid; - gcmask = GCForeground|GCFillStyle; - break; - - case BackgroundPixmap: - gcvalues[0] = FillTiled; - gcvalues[1] = (XID) background.pixmap; - gcvalues[2] = ts_x_origin; - gcvalues[3] = ts_y_origin; - gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin; - break; - - default: - return FALSE; - } - DoChangeGC(pGC, gcmask, gcvalues, TRUE); - return TRUE; -} - -static void -MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects) - WindowPtr pWin; - DrawablePtr pDrawable; - int nrects; - xRectangle *pRects; -{ - GCPtr pGC; - - pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen); - if (SetupBackgroundPainter(pWin, pGC)) - { - ValidateGC(pDrawable, pGC); - (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrects, pRects); - } - FreeScratchGC(pGC); -} - -static void -MultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion) - WindowPtr pWin; - DrawablePtr pDrawable; - RegionPtr pRegion; -{ - xRectangle *pRects; - int nrects = REGION_NUM_RECTS(pRegion); - BoxPtr pbox = REGION_RECTS(pRegion); - - pRects = xalloc(nrects * sizeof(xRectangle)); - if (pRects) - { - int i; - for (i = 0; i < nrects; i++) - { - pRects[i].x = pbox->x1; - pRects[i].y = pbox->y1; - pRects[i].width = pbox->x2 - pbox->x1; - pRects[i].height = pbox->y2 - pbox->y1; - } - MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects); - xfree(pRects); - } -} - -static void -pixDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf) - mbufBufferPtr *ppMBBuffer; - mbufWindowPtr *ppMBWindow; - int nbuf; -{ - GCPtr pGC = NULL; - PixmapPtr pPrevPixmap, pNewPixmap; - WindowPtr pWin; - RegionPtr pExposed; - int i; - mbufBufferPtr pPrevMBBuffer; - XID bool; - xRectangle r; - - UpdateCurrentTime (); - for (i = 0; i < nbuf; i++) - { - pWin = ppMBWindow[i]->pWindow; - - /* Time to get a different scratch GC? */ - - if (!pGC - || pGC->depth != pWin->drawable.depth - || pGC->pScreen != pWin->drawable.pScreen) - { - if (pGC) FreeScratchGC(pGC); - pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen); - } - pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]); - pPrevPixmap = (PixmapPtr) pPrevMBBuffer->pDrawable; - pNewPixmap = (PixmapPtr) ppMBBuffer[i]->pDrawable; - - if (pPrevPixmap == pNewPixmap) - { - /* "If a specified buffer is already displayed, any delays and - * update action will still be performed for that buffer." - * - * We special-case this because applications do occasionally - * request a redundant DisplayImageBuffers, and we can save - * strokes by recognizing that the only update action that will - * change the buffer contents in this case is Background. - */ - if (ppMBWindow[i]->updateAction == MultibufferUpdateActionBackground) - { - r.x = r.y = 0; - r.width = pWin->drawable.width; - r.height = pWin->drawable.height; - MultibufferPaintBackgroundRectangles(pWin, (DrawablePtr)pWin, - 1, &r); - } - } - else /* different buffer is being displayed */ - { - /* perform update action */ - - switch (ppMBWindow[i]->updateAction) - { - case MultibufferUpdateActionUndefined: - break; - - case MultibufferUpdateActionBackground: - - r.x = r.y = 0; - r.width = pPrevPixmap->drawable.width; - r.height = pPrevPixmap->drawable.height; - MultibufferPaintBackgroundRectangles(pWin, - (DrawablePtr)pPrevPixmap, - 1, &r); - break; - - case MultibufferUpdateActionUntouched: - - /* copy the window to the pixmap that represents the - * currently displayed buffer - */ - - if (pPrevMBBuffer->eventMask & ExposureMask) - { - bool = TRUE; - DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE); - } - ValidateGC ((DrawablePtr)pPrevPixmap, pGC); - pExposed = (*pGC->ops->CopyArea)((DrawablePtr) pWin, - (DrawablePtr) pPrevPixmap, - pGC, - 0, 0, - pWin->drawable.width, - pWin->drawable.height, - 0, 0); - - /* if we couldn't copy the whole window to the buffer, - * send expose events (if any client wants them) - */ - - if (pPrevMBBuffer->eventMask & ExposureMask) - { /* some client wants expose events */ - if (pExposed) - { - RegionPtr pWinSize; - extern RegionPtr CreateUnclippedWinSize(); - ScreenPtr pScreen = pWin->drawable.pScreen; - pWinSize = CreateUnclippedWinSize (pWin); - /* - * pExposed is window-relative, but at this point - * pWinSize is screen-relative. Make pWinSize be - * window-relative so that region ops involving - * pExposed and pWinSize behave sensibly. - */ - REGION_TRANSLATE(pScreen, pWinSize, - -pWin->drawable.x, - -pWin->drawable.y); - REGION_INTERSECT(pScreen, pExposed, pExposed, pWinSize); - REGION_DESTROY(pScreen, pWinSize); - MultibufferExpose (pPrevMBBuffer, pExposed); - REGION_DESTROY(pScreen, pExposed); - } - bool = FALSE; - DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE); - } /* end some client wants expose events */ - - break; /* end case MultibufferUpdateActionUntouched */ - - case MultibufferUpdateActionCopied: - - ValidateGC ((DrawablePtr)pPrevPixmap, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, - (DrawablePtr)pPrevPixmap, pGC, - 0, 0, pWin->drawable.width, - pWin->drawable.height, 0, 0); - break; - - } /* end switch on update action */ - - /* display the new buffer */ - - ValidateGC ((DrawablePtr)pWin, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin, - pGC, 0, 0, - pWin->drawable.width, pWin->drawable.height, - 0, 0); - } - - ppMBWindow[i]->lastUpdate = currentTime; - } - - if (pGC) FreeScratchGC (pGC); - return; -} - -/* - * resize the buffers when the window is resized - */ - -static Bool -pixPositionWindow (pWin, x, y) - WindowPtr pWin; - int x, y; -{ - ScreenPtr pScreen; - mbufPixmapPrivPtr pMBPriv; - mbufWindowPtr pMBWindow; - mbufBufferPtr pMBBuffer; - int width, height; - int i; - int dx, dy, dw, dh; - int sourcex, sourcey; - int destx, desty; - PixmapPtr pPixmap; - GCPtr pGC; - int savewidth, saveheight; - Bool clear; - RegionRec exposedRegion; - Bool ret; - - pScreen = pWin->drawable.pScreen; - pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen); - - UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow); - ret = (* pScreen->PositionWindow) (pWin, x, y); - REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow); - - if (!(pMBWindow = MB_WINDOW_PRIV(pWin))) - return ret; - - /* if new size is same as old, we're done */ - - if (pMBWindow->width == pWin->drawable.width && - pMBWindow->height == pWin->drawable.height) - return ret; - - width = pWin->drawable.width; - height = pWin->drawable.height; - dx = pWin->drawable.x - pMBWindow->x; - dy = pWin->drawable.x - pMBWindow->y; - dw = width - pMBWindow->width; - dh = height - pMBWindow->height; - GravityTranslate (0, 0, -dx, -dy, dw, dh, - pWin->bitGravity, &destx, &desty); - - /* if the window grew, remember to paint the window background, - * and maybe send expose events, for the new areas of the buffers - */ - - clear = pMBWindow->width < width || pMBWindow->height < height || - pWin->bitGravity == ForgetGravity; - - sourcex = 0; - sourcey = 0; - savewidth = pMBWindow->width; - saveheight = pMBWindow->height; - /* clip rectangle to source and destination */ - if (destx < 0) - { - savewidth += destx; - sourcex -= destx; - destx = 0; - } - if (destx + savewidth > width) - savewidth = width - destx; - if (desty < 0) - { - saveheight += desty; - sourcey -= desty; - desty = 0; - } - if (desty + saveheight > height) - saveheight = height - desty; - - pMBWindow->width = width; - pMBWindow->height = height; - pMBWindow->x = pWin->drawable.x; - pMBWindow->y = pWin->drawable.y; - - if (clear) - { - BoxRec box; - - box.x1 = box.y1 = 0; - box.x2 = width; - box.y2 = height; - REGION_INIT(pScreen, &exposedRegion, &box, 1); - if (pWin->bitGravity != ForgetGravity) - { - RegionRec preservedRegion; - box.x1 = destx; - box.y1 = desty; - box.x2 = destx + savewidth; - box.y2 = desty + saveheight; - REGION_INIT(pScreen, &preservedRegion, &box, 1); - REGION_SUBTRACT(pScreen, &exposedRegion, &exposedRegion, &preservedRegion); - REGION_UNINIT(pScreen, &preservedRegion); - } - - } /* end if (clear) */ - - pGC = GetScratchGC (pWin->drawable.depth, pScreen); - - /* create buffers with new window size */ - - for (i = 0; i < pMBWindow->numMultibuffer; i++) - { - pMBBuffer = &pMBWindow->buffers[i]; - pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, pWin->drawable.depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pPixmap) - { - (* MB_SCREEN_PRIV(pScreen)->DestroyImageBuffers)(pWin); - break; - } - if (clear) - { - MultibufferPaintBackgroundRegion(pWin, (DrawablePtr)pPixmap, &exposedRegion); - MultibufferExpose(pMBBuffer, &exposedRegion); - } - if (pWin->bitGravity != ForgetGravity) - { - ValidateGC ((DrawablePtr)pPixmap, pGC); - (*pGC->ops->CopyArea) (pMBBuffer->pDrawable, (DrawablePtr)pPixmap, - pGC, - sourcex, sourcey, savewidth, saveheight, - destx, desty); - } - pPixmap->drawable.id = pMBBuffer->pDrawable->id; - (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable); - pMBBuffer->pDrawable = (DrawablePtr) pPixmap; - if (i != pMBWindow->displayedMultibuffer) - { - ChangeResourceValue (pPixmap->drawable.id, - MultibufferDrawableResType, - (pointer) pPixmap); - } - } - FreeScratchGC (pGC); - if (clear) - REGION_UNINIT(pScreen, &exposedRegion); - return TRUE; -} - -static void -pixWrapScreenFuncs(pScreen) - ScreenPtr pScreen; -{ - mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen); - WRAP_SCREEN_FUNC(pScreen, pMBPriv, PositionWindow, pixPositionWindow); -} - -static void -pixResetProc(pScreen) - ScreenPtr pScreen; -{ - mbufScreenPtr pMBScreen = MB_SCREEN_PRIV(pScreen); - mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen); - - xfree(pMBScreen->pInfo); - xfree(pMBPriv); -} - -static void -pixClearImageBufferArea(pMBBuffer, x,y, width,height, exposures) - mbufBufferPtr pMBBuffer; - short x, y; - unsigned short width, height; - Bool exposures; -{ - WindowPtr pWin; - ScreenPtr pScreen; - BoxRec box; - RegionRec region; - int w_width, w_height; - DrawablePtr pDrawable; - - pWin = pMBBuffer->pMBWindow->pWindow; - pScreen = pWin->drawable.pScreen; - - w_width = pWin->drawable.width; - w_height = pWin->drawable.height; - - box.x1 = x; - box.y1 = y; - box.x2 = width ? (box.x1 + width) : w_width; - box.y2 = height ? (box.y1 + height) : w_height; - - if (box.x1 < 0) box.x1 = 0; - if (box.y1 < 0) box.y1 = 0; - if (box.x2 > w_width) box.x2 = w_width; - if (box.y2 > w_height) box.y2 = w_height; - - REGION_INIT(pScreen, ®ion, &box, 1); - - if (pMBBuffer->number == pMBBuffer->pMBWindow->displayedMultibuffer) - pDrawable = (DrawablePtr) pWin; - else - pDrawable = pMBBuffer->pDrawable; - - MultibufferPaintBackgroundRegion(pWin, pDrawable, ®ion); - - if (exposures) - MultibufferExpose(pMBBuffer, ®ion); - - REGION_UNINIT(pScreen, ®ion); -} - -static void -pixDeleteBufferDrawable(pDrawable) - DrawablePtr pDrawable; -{ - (* pDrawable->pScreen->DestroyPixmap)((PixmapPtr) pDrawable); -} diff --git a/Xext/sync.c b/Xext/sync.c index ce6531467..b68f430d4 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -2174,7 +2174,6 @@ static XSyncValue *pnext_time; /* *** Server Block Handler -*** code inspired by multibuffer extension */ /*ARGSUSED*/ static void diff --git a/Xext/xtest.c b/Xext/xtest.c index 5af2b5c83..5d0bffca5 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -357,8 +357,6 @@ ProcXTestFakeInput(ClientPtr client) activateTime.milliseconds = ms; ev->u.keyButtonPointer.time = 0; - /* see mbuf.c:QueueDisplayRequest for code similar to this */ - if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) { return BadAlloc; diff --git a/configure.ac b/configure.ac index 591d2b445..ec1831e8e 100644 --- a/configure.ac +++ b/configure.ac @@ -632,7 +632,6 @@ AC_ARG_ENABLE(xselinux, AS_HELP_STRING([--disable-xselinux], [Build SELinu AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no]) AC_ARG_ENABLE(xcalibrate, AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no]) AC_ARG_ENABLE(tslib, AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no]) -AC_ARG_ENABLE(multibuffer, AS_HELP_STRING([--enable-multibuffer], [Build Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], [MULTIBUFFER=no]) AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes]) AC_ARG_ENABLE(xf86bigfont, AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no]) AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes]) @@ -1085,12 +1084,6 @@ if test "x$XCSECURITY" = xyes; then AC_DEFINE(XCSECURITY, 1, [Build Security extension]) fi -AM_CONDITIONAL(MULTIBUFFER, [test "x$MULTIBUFFER" = xyes]) -if test "x$MULTIBUFFER" = xyes; then - AC_DEFINE(MULTIBUFFER, 1, [Build Multibuffer extension]) - # Requires xextproto which is always required -fi - AM_CONDITIONAL(DBE, [test "x$DBE" = xyes]) if test "x$DBE" = xyes; then AC_DEFINE(DBE, 1, [Support DBE extension]) diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c index 299562592..7d2086802 100644 --- a/hw/xfree86/dixmods/extmod/modinit.c +++ b/hw/xfree86/dixmods/extmod/modinit.c @@ -47,15 +47,6 @@ static ExtensionModule extensionModules[] = { NULL }, #endif -#ifdef MULTIBUFFER - { - MultibufferExtensionInit, - MULTIBUFFER_PROTOCOL_NAME, - &noMultibufferExtension, - NULL, - NULL - }, -#endif #ifdef SCREENSAVER { ScreenSaverExtensionInit, diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h index 6210526aa..1154e4601 100644 --- a/hw/xfree86/dixmods/extmod/modinit.h +++ b/hw/xfree86/dixmods/extmod/modinit.h @@ -9,11 +9,6 @@ #include <X11/extensions/shapeproto.h> -#ifdef MULTIBUFFER -extern void MultibufferExtensionInit(INITARGS); -#include <X11/extensions/multibufproto.h> -#endif - #ifdef XTEST extern void XTestExtensionInit(INITARGS); #include <X11/extensions/xtestproto.h> diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 058c8fd14..9aff6134e 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -360,9 +360,6 @@ /* Support Xv extension */ #undef XV -/* Build Multibuffer extension */ -#undef MULTIBUFFER - /* Support DRI extension */ #undef XF86DRI diff --git a/include/globals.h b/include/globals.h index 52c19a490..82e86c31a 100644 --- a/include/globals.h +++ b/include/globals.h @@ -69,10 +69,6 @@ extern _X_EXPORT Bool noScreenSaverExtension; extern _X_EXPORT Bool noMITShmExtension; #endif -#ifdef MULTIBUFFER -extern _X_EXPORT Bool noMultibufferExtension; -#endif - #ifdef RANDR extern _X_EXPORT Bool noRRExtension; #endif diff --git a/mi/miinitext.c b/mi/miinitext.c index 692be86f4..a8674a094 100644 --- a/mi/miinitext.c +++ b/mi/miinitext.c @@ -55,7 +55,6 @@ SOFTWARE. #ifdef HAVE_DMX_CONFIG_H #include <dmx-config.h> -#undef MULTIBUFFER #undef XV #undef DBE #undef XF86VIDMODE @@ -116,9 +115,6 @@ extern Bool noScreenSaverExtension; #ifdef MITSHM extern Bool noMITShmExtension; #endif -#ifdef MULTIBUFFER -extern Bool noMultibufferExtension; -#endif #ifdef RANDR extern Bool noRRExtension; #endif @@ -195,9 +191,6 @@ typedef void (*InitExtension)(INITARGS); #ifdef MITSHM extern void ShmExtensionInit(INITARGS); #endif -#ifdef MULTIBUFFER -extern void MultibufferExtensionInit(INITARGS); -#endif #ifdef PANORAMIX extern void PanoramiXExtensionInit(INITARGS); #endif @@ -308,9 +301,6 @@ static ExtensionToggle ExtensionToggleList[] = #ifdef MITSHM { SHMNAME, &noMITShmExtension }, #endif -#ifdef MULTIBUFFER - { "Multi-Buffering", &noMultibufferExtension }, -#endif #ifdef RANDR { "RANDR", &noRRExtension }, #endif @@ -416,9 +406,6 @@ InitExtensions(int argc, char *argv[]) #ifdef MITSHM if (!noMITShmExtension) ShmExtensionInit(); #endif -#ifdef MULTIBUFFER - if (!noMultibufferExtension) MultibufferExtensionInit(); -#endif XInputExtensionInit(); #ifdef XTEST if (!noTestExtensions) XTestExtensionInit(); diff --git a/os/utils.c b/os/utils.c index 13d3b3ff0..127b47bb3 100644 --- a/os/utils.c +++ b/os/utils.c @@ -148,9 +148,6 @@ Bool noScreenSaverExtension = FALSE; #ifdef MITSHM Bool noMITShmExtension = FALSE; #endif -#ifdef MULTIBUFFER -Bool noMultibufferExtension = FALSE; -#endif #ifdef RANDR Bool noRRExtension = FALSE; #endif |