devPrivates rework: since API is already broken, switch everything

over to new system.

Need to update documentation and address some remaining vestiges of
old system such as CursorRec structure, fb "offman" structure, and
FontRec privates.
This commit is contained in:
Eamon Walsh
2007-08-28 09:28:25 -04:00
committed by Eamon Walsh
parent 8554707326
commit 4017d31902
261 changed files with 1642 additions and 3957 deletions

20
fb/fb.h
View File

@@ -37,6 +37,7 @@
#include "miscstruct.h"
#include "servermd.h"
#include "windowstr.h"
#include "privates.h"
#include "mi.h"
#include "migc.h"
#include "mibstore.h"
@@ -599,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;
@@ -641,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 {
@@ -655,7 +651,7 @@ typedef struct {
} FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
(pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
#endif
/* private field of GC */
@@ -670,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)
@@ -682,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
@@ -835,7 +831,7 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
* fballpriv.c
*/
Bool
fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex);
fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
/*
* fbarc.c

View File

@@ -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;

View File

@@ -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;
@@ -358,12 +357,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv;
if (fbOverlayGeneration != serverGeneration)
{
fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex ();
fbOverlayGeneration = serverGeneration;
}
pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
if (!pScrPriv)
return FALSE;
@@ -433,7 +426,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;

View File

@@ -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);

View File

@@ -96,7 +96,7 @@ fbDestroyPixmap (PixmapPtr pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
dixFreePrivates(*DEVPRIV_PTR(pPixmap));
dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}

View File

@@ -125,13 +125,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 {
@@ -140,13 +138,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) {\
@@ -355,12 +352,6 @@ xxMyVisual(ScreenPtr pScreen, VisualID vid)
return FALSE;
}
static Bool
xxInitColormapDummy(ColormapPtr pmap, int index)
{
return TRUE;
}
static Bool
xxInitColormapPrivate(ColormapPtr pmap)
{
@@ -368,14 +359,14 @@ xxInitColormapPrivate(ColormapPtr pmap)
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;
@@ -677,7 +668,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);
@@ -746,9 +737,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);
@@ -1098,21 +1090,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));
@@ -1190,7 +1168,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))

View File

@@ -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 */

View File

@@ -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)

View File

@@ -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,10 +117,10 @@
#define fbOverlayCreateWindow wfbOverlayCreateWindow
#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit
#define fbOverlayGeneration wfbOverlayGeneration
#define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex
#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
#define fbOverlayPaintKey wfbOverlayPaintKey
#define fbOverlayPaintWindow wfbOverlayPaintWindow
#define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex
#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey
#define fbOverlaySetupScreen wfbOverlaySetupScreen
#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
#define fbOverlayWindowExposures wfbOverlayWindowExposures
@@ -160,7 +160,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
@@ -185,14 +185,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