diff options
Diffstat (limited to 'fb')
-rw-r--r-- | fb/fb.h | 21 | ||||
-rw-r--r-- | fb/fballpriv.c | 48 | ||||
-rw-r--r-- | fb/fboverlay.c | 19 | ||||
-rw-r--r-- | fb/fboverlay.h | 9 | ||||
-rw-r--r-- | fb/fbpixmap.c | 1 | ||||
-rw-r--r-- | fb/fbpseudocolor.c | 50 | ||||
-rw-r--r-- | fb/fbscreen.c | 6 | ||||
-rw-r--r-- | fb/fbwindow.c | 4 | ||||
-rw-r--r-- | fb/wfbrename.h | 22 |
9 files changed, 65 insertions, 115 deletions
@@ -37,9 +37,11 @@ #include "miscstruct.h" #include "servermd.h" #include "windowstr.h" +#include "privates.h" #include "mi.h" #include "migc.h" #include "mibstore.h" +#include "privates.h" #ifdef RENDER #include "picturestr.h" #else @@ -598,13 +600,9 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); } \ } -/* XXX fb*PrivateIndex should be static, but it breaks the ABI */ - -extern int fbGCPrivateIndex; -extern int fbGetGCPrivateIndex(void); +extern DevPrivateKey fbGetGCPrivateKey(void); #ifndef FB_NO_WINDOW_PIXMAPS -extern int fbWinPrivateIndex; -extern int fbGetWinPrivateIndex(void); +extern DevPrivateKey fbGetWinPrivateKey(void); #endif extern const GCOps fbGCOps; extern const GCFuncs fbGCFuncs; @@ -640,8 +638,7 @@ typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw); #ifdef FB_SCREEN_PRIVATE -extern int fbScreenPrivateIndex; -extern int fbGetScreenPrivateIndex(void); +extern DevPrivateKey fbGetScreenPrivateKey(void); /* private field of a screen */ typedef struct { @@ -654,7 +651,7 @@ typedef struct { } FbScreenPrivRec, *FbScreenPrivPtr; #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ - (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr) + dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey())) #endif /* private field of GC */ @@ -669,7 +666,7 @@ typedef struct { } FbGCPrivRec, *FbGCPrivPtr; #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ - (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr) + dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey())) #define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip) #define fbGetExpose(pGC) ((pGC)->fExpose) @@ -681,7 +678,7 @@ typedef struct { #define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen) #else #define fbGetWindowPixmap(pWin) ((PixmapPtr)\ - ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr) + dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey())) #endif #ifdef ROOTLESS @@ -834,7 +831,7 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap, * fballpriv.c */ Bool -fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex); +fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex); /* * fbarc.c diff --git a/fb/fballpriv.c b/fb/fballpriv.c index 8efb8fa99..68cb2e4c0 100644 --- a/fb/fballpriv.c +++ b/fb/fballpriv.c @@ -27,51 +27,33 @@ #include "fb.h" #ifdef FB_SCREEN_PRIVATE -int fbScreenPrivateIndex; -int fbGetScreenPrivateIndex(void) +static DevPrivateKey fbScreenPrivateKey = &fbScreenPrivateKey; +DevPrivateKey fbGetScreenPrivateKey(void) { - return fbScreenPrivateIndex; + return fbScreenPrivateKey; } #endif -int fbGCPrivateIndex; -int fbGetGCPrivateIndex(void) +static DevPrivateKey fbGCPrivateKey = &fbGCPrivateKey; +DevPrivateKey fbGetGCPrivateKey(void) { - return fbGCPrivateIndex; + return fbGCPrivateKey; } #ifndef FB_NO_WINDOW_PIXMAPS -int fbWinPrivateIndex; -int fbGetWinPrivateIndex(void) +static DevPrivateKey fbWinPrivateKey = &fbWinPrivateKey; +DevPrivateKey fbGetWinPrivateKey(void) { - return fbWinPrivateIndex; + return fbWinPrivateKey; } #endif -int fbGeneration; Bool -fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex) +fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey) { - if (fbGeneration != serverGeneration) - { - fbGCPrivateIndex = miAllocateGCPrivateIndex (); -#ifndef FB_NO_WINDOW_PIXMAPS - fbWinPrivateIndex = AllocateWindowPrivateIndex(); -#endif -#ifdef FB_SCREEN_PRIVATE - fbScreenPrivateIndex = AllocateScreenPrivateIndex (); - if (fbScreenPrivateIndex == -1) - return FALSE; -#endif - - fbGeneration = serverGeneration; - } - if (pGCIndex) - *pGCIndex = fbGCPrivateIndex; - if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec))) + if (pGCKey) + *pGCKey = fbGCPrivateKey; + + if (!dixRequestPrivate(fbGCPrivateKey, sizeof(FbGCPrivRec))) return FALSE; -#ifndef FB_NO_WINDOW_PIXMAPS - if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0)) - return FALSE; -#endif #ifdef FB_SCREEN_PRIVATE { FbScreenPrivPtr pScreenPriv; @@ -79,7 +61,7 @@ fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex) pScreenPriv = (FbScreenPrivPtr) xalloc (sizeof (FbScreenPrivRec)); if (!pScreenPriv) return FALSE; - pScreen->devPrivates[fbScreenPrivateIndex].ptr = (pointer) pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, fbScreenPrivateKey, pScreenPriv); } #endif return TRUE; diff --git a/fb/fboverlay.c b/fb/fboverlay.c index 456c921a6..f9f7c52a3 100644 --- a/fb/fboverlay.c +++ b/fb/fboverlay.c @@ -33,12 +33,11 @@ #include "fboverlay.h" #include "shmint.h" -int fbOverlayGeneration; -int fbOverlayScreenPrivateIndex = -1; +static DevPrivateKey fbOverlayScreenPrivateKey = &fbOverlayScreenPrivateKey; -int fbOverlayGetScreenPrivateIndex(void) +DevPrivateKey fbOverlayGetScreenPrivateKey(void) { - return fbOverlayScreenPrivateIndex; + return fbOverlayScreenPrivateKey; } /* @@ -65,7 +64,7 @@ fbOverlayCreateWindow(WindowPtr pWin) pPixmap = pScrPriv->layer[i].u.run.pixmap; if (pWin->drawable.depth == pPixmap->drawable.depth) { - pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap; + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap); /* * Make sure layer keys are written correctly by * having non-root layers set to full while the @@ -108,7 +107,7 @@ fbOverlayWindowLayer(WindowPtr pWin) int i; for (i = 0; i < pScrPriv->nlayers; i++) - if (pWin->devPrivates[fbWinPrivateIndex].ptr == + if (dixLookupPrivate(&pWin->devPrivates, fbGetWinPrivateKey()) == (pointer) pScrPriv->layer[i].u.run.pixmap) return i; return 0; @@ -348,12 +347,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, VisualID defaultVisual; FbOverlayScrPrivPtr pScrPriv; - if (fbOverlayGeneration != serverGeneration) - { - fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex (); - fbOverlayGeneration = serverGeneration; - } - pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec)); if (!pScrPriv) return FALSE; @@ -423,7 +416,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, pScrPriv->layer[1].u.init.width = width2; pScrPriv->layer[1].u.init.depth = depth2; - pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv; + dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv); /* overwrite miCloseScreen with our own */ pScreen->CloseScreen = fbOverlayCloseScreen; diff --git a/fb/fboverlay.h b/fb/fboverlay.h index 55135ea4e..f3db0bb7d 100644 --- a/fb/fboverlay.h +++ b/fb/fboverlay.h @@ -25,9 +25,9 @@ #ifndef _FBOVERLAY_H_ #define _FBOVERLAY_H_ -extern int fbOverlayGeneration; -extern int fbOverlayScreenPrivateIndex; /* XXX should be static */ -extern int fbOverlayGetScreenPrivateIndex(void); +#include "privates.h" + +extern DevPrivateKey fbOverlayGetScreenPrivateKey(void); #ifndef FB_OVERLAY_MAX #define FB_OVERLAY_MAX 2 @@ -58,8 +58,7 @@ typedef struct _fbOverlayScrPriv { } FbOverlayScrPrivRec, *FbOverlayScrPrivPtr; #define fbOverlayGetScrPriv(s) \ - ((fbOverlayGetScreenPrivateIndex() != -1) ? \ - (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL) + dixLookupPrivate(&(s)->devPrivates, fbOverlayGetScreenPrivateKey()) Bool fbOverlayCreateWindow(WindowPtr pWin); diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c index cddab3ee3..d097bb7d0 100644 --- a/fb/fbpixmap.c +++ b/fb/fbpixmap.c @@ -97,6 +97,7 @@ fbDestroyPixmap (PixmapPtr pPixmap) { if(--pPixmap->refcnt) return TRUE; + dixFreePrivates(pPixmap->devPrivates); xfree(pPixmap); return TRUE; } diff --git a/fb/fbpseudocolor.c b/fb/fbpseudocolor.c index 8a48c3819..06cf15992 100644 --- a/fb/fbpseudocolor.c +++ b/fb/fbpseudocolor.c @@ -123,13 +123,11 @@ typedef struct { } xxScrPrivRec, *xxScrPrivPtr; #define xxGetScrPriv(s) ((xxScrPrivPtr) \ - (xxScrPrivateIndex != -1) \ - ? (s)->devPrivates[xxScrPrivateIndex].ptr\ - : NULL) + dixLookupPrivate(&(s)->devPrivates, xxScrPrivateKey)) #define xxScrPriv(s) xxScrPrivPtr pScrPriv = xxGetScrPriv(s) #define xxGetCmapPriv(s) ((xxCmapPrivPtr) \ - (s)->devPrivates[xxColormapPrivateIndex].ptr) + dixLookupPrivate(&(s)->devPrivates, xxColormapPrivateKey)) #define xxCmapPriv(s) xxCmapPrivPtr pCmapPriv = xxGetCmapPriv(s); typedef struct _xxGCPriv { @@ -138,13 +136,12 @@ typedef struct _xxGCPriv { } xxGCPrivRec, *xxGCPrivPtr; #define xxGetGCPriv(pGC) ((xxGCPrivPtr) \ - (pGC)->devPrivates[xxGCPrivateIndex].ptr) + dixLookupPrivate(&(pGC)->devPrivates, xxGCPrivateKey)) #define xxGCPriv(pGC) xxGCPrivPtr pGCPriv = xxGetGCPriv(pGC) -int xxScrPrivateIndex = -1; -int xxGCPrivateIndex; -int xxColormapPrivateIndex = -1; -int xxGeneration; +static DevPrivateKey xxScrPrivateKey = &xxScrPrivateKey; +static DevPrivateKey xxGCPrivateKey = &xxGCPrivateKey; +static DevPrivateKey xxColormapPrivateKey = &xxColormapPrivateKey; #define wrap(priv,real,mem,func) {\ @@ -354,26 +351,20 @@ xxMyVisual(ScreenPtr pScreen, VisualID vid) } static Bool -xxInitColormapDummy(ColormapPtr pmap, int index) -{ - return TRUE; -} - -static Bool xxInitColormapPrivate(ColormapPtr pmap) { xxScrPriv(pmap->pScreen); xxCmapPrivPtr pCmapPriv; pointer cmap; - pmap->devPrivates[xxColormapPrivateIndex].ptr = (pointer) -1; + dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, (pointer) -1); if (xxMyVisual(pmap->pScreen,pmap->pVisual->vid)) { DBG("CreateColormap\n"); pCmapPriv = (xxCmapPrivPtr) xalloc (sizeof (xxCmapPrivRec)); if (!pCmapPriv) return FALSE; - pmap->devPrivates[xxColormapPrivateIndex].ptr = (pointer) pCmapPriv; + dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, pCmapPriv); cmap = xalloc(sizeof (CARD32) * (1 << pScrPriv->myDepth)); if (!cmap) return FALSE; @@ -675,7 +666,7 @@ xxCreateWindow(WindowPtr pWin) DBG("CreateWindow\n"); - pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pScrPriv->pPixmap; + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pScrPriv->pPixmap); PRINT_RECTS(pScrPriv->region); if (!pWin->parent) { REGION_EMPTY (pWin->drawable.pScreen, &pScrPriv->region); @@ -744,9 +735,10 @@ xxCopyWindow(WindowPtr pWin, xxPickMyWindows(pWin,&rgn); unwrap (pScrPriv, pScreen, CopyWindow); - pWin->devPrivates[fbWinPrivateIndex].ptr = fbGetScreenPixmap(pScreen); + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), + fbGetScreenPixmap(pScreen)); pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc); - pWin->devPrivates[fbWinPrivateIndex].ptr = pPixmap; + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap); wrap(pScrPriv, pScreen, CopyWindow, xxCopyWindow); REGION_INTERSECT(pScreen,&rgn,&rgn,&rgn_new); @@ -1032,21 +1024,7 @@ xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sy PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif - if (xxGeneration != serverGeneration) { - xxScrPrivateIndex = AllocateScreenPrivateIndex (); - if (xxScrPrivateIndex == -1) - return FALSE; - xxColormapPrivateIndex - = AllocateColormapPrivateIndex (xxInitColormapDummy); - if (xxColormapPrivateIndex == -1) - return FALSE; - xxGCPrivateIndex = AllocateGCPrivateIndex (); - if (xxGCPrivateIndex == -1) - return FALSE; - xxGeneration = serverGeneration; - } - - if (!AllocateGCPrivate (pScreen, xxGCPrivateIndex, sizeof (xxGCPrivRec))) + if (!dixRequestPrivate(xxGCPrivateKey, sizeof (xxGCPrivRec))) return FALSE; pScrPriv = (xxScrPrivPtr) xalloc (sizeof (xxScrPrivRec)); @@ -1122,7 +1100,7 @@ xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sy } #endif pScrPriv->addr = addr; - pScreen->devPrivates[xxScrPrivateIndex].ptr = (pointer) pScrPriv; + dixSetPrivate(&pScreen->devPrivates, xxScrPrivateKey, pScrPriv); pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); if (!xxInitColormapPrivate(pDefMap)) diff --git a/fb/fbscreen.c b/fb/fbscreen.c index 41bef4739..12b19e419 100644 --- a/fb/fbscreen.c +++ b/fb/fbscreen.c @@ -38,7 +38,7 @@ fbCloseScreen (int index, ScreenPtr pScreen) xfree (pScreen->visuals); xfree (pScreen->devPrivate); #ifdef FB_SCREEN_PRIVATE - xfree (pScreen->devPrivates[fbScreenPrivateIndex].ptr); + xfree (dixLookupPrivate(&pScreen->devPrivates, fbGetScreenPrivateKey())); #endif return TRUE; } @@ -93,7 +93,7 @@ _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) #ifdef FB_NO_WINDOW_PIXMAPS FatalError ("Attempted to set window pixmap without fb support\n"); #else - pWindow->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap; + dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap); #endif } @@ -107,7 +107,7 @@ fbSetupScreen(ScreenPtr pScreen, int width, /* pixel width of frame buffer */ int bpp) /* bits per pixel for screen */ { - if (!fbAllocatePrivates(pScreen, (int *) 0)) + if (!fbAllocatePrivates(pScreen, NULL)) return FALSE; pScreen->defColormap = FakeClientID(0); /* let CreateDefColormap do whatever it wants for pixels */ diff --git a/fb/fbwindow.c b/fb/fbwindow.c index 602b7e0dc..89f601f29 100644 --- a/fb/fbwindow.c +++ b/fb/fbwindow.c @@ -32,8 +32,8 @@ Bool fbCreateWindow(WindowPtr pWin) { #ifndef FB_NO_WINDOW_PIXMAPS - pWin->devPrivates[fbWinPrivateIndex].ptr = - (pointer) fbGetScreenPixmap(pWin->drawable.pScreen); + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), + fbGetScreenPixmap(pWin->drawable.pScreen)); #endif #ifdef FB_SCREEN_PRIVATE if (pWin->drawable.bitsPerPixel == 32) diff --git a/fb/wfbrename.h b/fb/wfbrename.h index 93ce41baf..93822442f 100644 --- a/fb/wfbrename.h +++ b/fb/wfbrename.h @@ -84,14 +84,14 @@ #define fbFixCoordModePrevious wfbFixCoordModePrevious #define fbGCFuncs wfbGCFuncs #define fbGCOps wfbGCOps -#define fbGCPrivateIndex wfbGCPrivateIndex +#define fbGCPrivateKey wfbGCPrivateKey #define fbGeneration wfbGeneration -#define fbGetGCPrivateIndex wfbGetGCPrivateIndex +#define fbGetGCPrivateKey wfbGetGCPrivateKey #define fbGetImage wfbGetImage -#define fbGetScreenPrivateIndex wfbGetScreenPrivateIndex +#define fbGetScreenPrivateKey wfbGetScreenPrivateKey #define fbGetSpans wfbGetSpans #define _fbGetWindowPixmap _wfbGetWindowPixmap -#define fbGetWinPrivateIndex wfbGetWinPrivateIndex +#define fbGetWinPrivateKey wfbGetWinPrivateKey #define fbGlyph16 wfbGlyph16 #define fbGlyph24 wfbGlyph24 #define fbGlyph32 wfbGlyph32 @@ -117,9 +117,9 @@ #define fbOverlayCreateWindow wfbOverlayCreateWindow #define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit #define fbOverlayGeneration wfbOverlayGeneration -#define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex +#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey #define fbOverlayPaintKey wfbOverlayPaintKey -#define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex +#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey #define fbOverlaySetupScreen wfbOverlaySetupScreen #define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion #define fbOverlayWindowExposures wfbOverlayWindowExposures @@ -158,7 +158,7 @@ #define fbResolveColor wfbResolveColor #define fbRestoreAreas wfbRestoreAreas #define fbSaveAreas wfbSaveAreas -#define fbScreenPrivateIndex wfbScreenPrivateIndex +#define fbScreenPrivateKey wfbScreenPrivateKey #define fbSegment wfbSegment #define fbSelectBres wfbSelectBres #define fbSetSpans wfbSetSpans @@ -183,14 +183,14 @@ #define fbUnrealizeFont wfbUnrealizeFont #define fbValidateGC wfbValidateGC #define fbWalkCompositeRegion wfbWalkCompositeRegion -#define fbWinPrivateIndex wfbWinPrivateIndex +#define fbWinPrivateKey wfbWinPrivateKey #define fbZeroLine wfbZeroLine #define fbZeroSegment wfbZeroSegment #define free_pixman_pict wfb_free_pixman_pict #define image_from_pict wfb_image_from_pict -#define xxScrPrivateIndex wfbxxScrPrivateIndex -#define xxGCPrivateIndex wfbxxGCPrivateIndex -#define xxColormapPrivateIndex wfbxxColormapPrivateIndex +#define xxScrPrivateKey wfbxxScrPrivateKey +#define xxGCPrivateKey wfbxxGCPrivateKey +#define xxColormapPrivateKey wfbxxColormapPrivateKey #define xxGeneration wfbxxGeneration #define xxPrintVisuals wfbxxPrintVisuals #define xxGCFuncs wfbxxGCFuncs |