diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-11-02 15:26:35 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-11-02 15:26:35 +0000 |
commit | dbca69c8a4f3e2d1ccb4f89152213b2861b33af6 (patch) | |
tree | f8963ef73903a7b4374adc2354dffbaa905112ac /xserver/mi/misprite.c | |
parent | 33b2029f322f3c238b7ba528083195ad8dde33e1 (diff) |
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/mi/misprite.c')
-rw-r--r-- | xserver/mi/misprite.c | 135 |
1 files changed, 43 insertions, 92 deletions
diff --git a/xserver/mi/misprite.c b/xserver/mi/misprite.c index 286c7552a..0af3368b6 100644 --- a/xserver/mi/misprite.c +++ b/xserver/mi/misprite.c @@ -67,8 +67,7 @@ in this Software without prior written authorization from The Open Group. * screen wrappers */ -static int miSpriteScreenIndex; -static unsigned long miSpriteGeneration = 0; +static DevPrivateKey miSpriteScreenKey = &miSpriteScreenKey; static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen); static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, @@ -89,15 +88,11 @@ static void miSpriteInstallColormap(ColormapPtr pMap); static void miSpriteStoreColors(ColormapPtr pMap, int ndef, xColorItem *pdef); -static void miSpriteSaveDoomedAreas(WindowPtr pWin, - RegionPtr pObscured, int dx, - int dy); static void miSpriteComputeSaved(ScreenPtr pScreen); -#define SCREEN_PROLOGUE(pScreen, field)\ - ((pScreen)->field = \ - ((miSpriteScreenPtr) (pScreen)->devPrivates[miSpriteScreenIndex].ptr)->field) - +#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ + ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \ + miSpriteScreenKey))->field) #define SCREEN_EPILOGUE(pScreen, field)\ ((pScreen)->field = miSprite##field) @@ -131,8 +126,8 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) ScreenPtr pScreen = closure; miSpriteScreenPtr pScreenPriv; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); if (pScreenPriv->isUp && RECT_IN_REGION (pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) { @@ -159,14 +154,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) if (!DamageSetup (pScreen)) return FALSE; - if (miSpriteGeneration != serverGeneration) - { - miSpriteScreenIndex = AllocateScreenPrivateIndex (); - if (miSpriteScreenIndex < 0) - return FALSE; - miSpriteGeneration = serverGeneration; - } - pScreenPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec)); if (!pScreenPriv) return FALSE; @@ -195,8 +182,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreenPriv->CopyWindow = pScreen->CopyWindow; - pScreenPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas; - pScreenPriv->InstallColormap = pScreen->InstallColormap; pScreenPriv->StoreColors = pScreen->StoreColors; @@ -219,7 +204,7 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreenPriv->colors[MASK_COLOR].red = 0; pScreenPriv->colors[MASK_COLOR].green = 0; pScreenPriv->colors[MASK_COLOR].blue = 0; - pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv); pScreen->CloseScreen = miSpriteCloseScreen; pScreen->GetImage = miSpriteGetImage; @@ -228,8 +213,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreen->CopyWindow = miSpriteCopyWindow; - pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas; - pScreen->InstallColormap = miSpriteInstallColormap; pScreen->StoreColors = miSpriteStoreColors; @@ -254,8 +237,8 @@ miSpriteCloseScreen (i, pScreen) { miSpriteScreenPtr pScreenPriv; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->GetImage = pScreenPriv->GetImage; pScreen->GetSpans = pScreenPriv->GetSpans; @@ -264,7 +247,6 @@ miSpriteCloseScreen (i, pScreen) pScreen->InstallColormap = pScreenPriv->InstallColormap; pScreen->StoreColors = pScreenPriv->StoreColors; - pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas; miSpriteIsUpFALSE (pScreen, pScreenPriv); DamageDestroy (pScreenPriv->pDamage); @@ -286,8 +268,8 @@ miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine) SCREEN_PROLOGUE (pScreen, GetImage); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp && ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h)) @@ -316,15 +298,15 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) SCREEN_PROLOGUE (pScreen, GetSpans); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp) { - register DDXPointPtr pts; - register int *widths; - register int nPts; - register int xorg, - yorg; + DDXPointPtr pts; + int *widths; + int nPts; + int xorg, + yorg; xorg = pDrawable->x; yorg = pDrawable->y; @@ -358,8 +340,8 @@ miSpriteSourceValidate (pDrawable, x, y, width, height) SCREEN_PROLOGUE (pScreen, SourceValidate); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp && ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y, x, y, width, height)) @@ -382,7 +364,8 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) SCREEN_PROLOGUE (pScreen, CopyWindow); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); /* * Damage will take care of destination check */ @@ -407,8 +390,8 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask) ScreenPtr pScreen = screenInfo.screens[i]; miSpriteScreenPtr pPriv; - pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); SCREEN_PROLOGUE(pScreen, BlockHandler); (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); @@ -429,8 +412,8 @@ miSpriteInstallColormap (pMap) ScreenPtr pScreen = pMap->pScreen; miSpriteScreenPtr pPriv; - pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); SCREEN_PROLOGUE(pScreen, InstallColormap); (*pScreen->InstallColormap) (pMap); @@ -458,8 +441,8 @@ miSpriteStoreColors (pMap, ndef, pdef) int updated; VisualPtr pVisual; - pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - + pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); SCREEN_PROLOGUE(pScreen, StoreColors); (*pScreen->StoreColors) (pMap, ndef, pdef); @@ -526,7 +509,7 @@ static void miSpriteFindColors (ScreenPtr pScreen) { miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) - pScreen->devPrivates[miSpriteScreenIndex].ptr; + dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); CursorPtr pCursor; xColorItem *sourceColor, *maskColor; @@ -558,45 +541,6 @@ miSpriteFindColors (ScreenPtr pScreen) } /* - * BackingStore wrappers - */ - -static void -miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy) - WindowPtr pWin; - RegionPtr pObscured; - int dx, dy; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - BoxRec cursorBox; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, SaveDoomedAreas); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) - { - cursorBox = pScreenPriv->saved; - - if (dx || dy) - { - cursorBox.x1 += dx; - cursorBox.y1 += dy; - cursorBox.x2 += dx; - cursorBox.y2 += dy; - } - if (RECT_IN_REGION( pScreen, pObscured, &cursorBox) != rgnOUT) - miSpriteRemoveCursor (pScreen); - } - - (*pScreen->SaveDoomedAreas) (pWin, pObscured, dx, dy); - - SCREEN_EPILOGUE (pScreen, SaveDoomedAreas); -} - -/* * miPointer interface routines */ @@ -609,7 +553,8 @@ miSpriteRealizeCursor (pScreen, pCursor) { miSpriteScreenPtr pScreenPriv; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); if (pCursor == pScreenPriv->pCursor) pScreenPriv->checkPixels = TRUE; return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor); @@ -622,7 +567,8 @@ miSpriteUnrealizeCursor (pScreen, pCursor) { miSpriteScreenPtr pScreenPriv; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor); } @@ -635,7 +581,8 @@ miSpriteSetCursor (pScreen, pCursor, x, y) { miSpriteScreenPtr pScreenPriv; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); if (!pCursor) { pScreenPriv->shouldBeUp = FALSE; @@ -735,7 +682,8 @@ miSpriteMoveCursor (pScreen, x, y) { miSpriteScreenPtr pScreenPriv; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); miSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y); } @@ -750,7 +698,8 @@ miSpriteRemoveCursor (pScreen) miSpriteScreenPtr pScreenPriv; DamageDrawInternal (pScreen, TRUE); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); miSpriteIsUpFALSE (pScreen, pScreenPriv); pScreenPriv->pCacheWin = NullWindow; if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen, @@ -779,7 +728,8 @@ miSpriteRestoreCursor (pScreen) DamageDrawInternal (pScreen, TRUE); miSpriteComputeSaved (pScreen); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); pCursor = pScreenPriv->pCursor; x = pScreenPriv->x - (int)pCursor->bits->xhot; y = pScreenPriv->y - (int)pCursor->bits->yhot; @@ -814,7 +764,8 @@ miSpriteComputeSaved (pScreen) int wpad, hpad; CursorPtr pCursor; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miSpriteScreenKey); pCursor = pScreenPriv->pCursor; x = pScreenPriv->x - (int)pCursor->bits->xhot; y = pScreenPriv->y - (int)pCursor->bits->yhot; |