diff options
author | Keith Packard <keithp@keithp.com> | 2010-04-26 17:22:21 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2010-06-05 19:23:03 -0700 |
commit | faeebead7bfcc78535757ca7acc1faf7554c03b7 (patch) | |
tree | 1a8f13a3b1ae968011efb9679bc3ed79a29020be /miext | |
parent | c865a24401f06bcf1347d8b41f736a066ab25693 (diff) |
Change the devPrivates API to require dixRegisterPrivateKey
This patch only changes the API, not the implementation of the
devPrivates infrastructure. This will permit a new devPrivates
implementation to be layed into the server without requiring
simultaneous changes in every devPrivates user.
Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Diffstat (limited to 'miext')
-rw-r--r-- | miext/cw/cw.c | 24 | ||||
-rw-r--r-- | miext/cw/cw.h | 13 | ||||
-rw-r--r-- | miext/damage/damage.c | 34 | ||||
-rw-r--r-- | miext/rootless/rootlessCommon.h | 15 | ||||
-rw-r--r-- | miext/rootless/rootlessScreen.c | 22 | ||||
-rw-r--r-- | miext/shadow/shadow.c | 7 |
6 files changed, 71 insertions, 44 deletions
diff --git a/miext/cw/cw.c b/miext/cw/cw.c index 563831a49..7623de75e 100644 --- a/miext/cw/cw.c +++ b/miext/cw/cw.c @@ -43,14 +43,11 @@ #define CW_ASSERT(x) do {} while (0) #endif -static int cwGCKeyIndex; -DevPrivateKey cwGCKey = &cwGCKeyIndex; -static int cwScreenKeyIndex; -DevPrivateKey cwScreenKey = &cwScreenKeyIndex; -static int cwWindowKeyIndex; -DevPrivateKey cwWindowKey = &cwWindowKeyIndex; -static int cwPictureKeyIndex; -DevPrivateKey cwPictureKey = &cwPictureKeyIndex; +DevPrivateKeyRec cwGCKeyRec; +DevPrivateKeyRec cwScreenKeyRec; +DevPrivateKeyRec cwWindowKeyRec; +DevPrivateKeyRec cwPictureKeyRec; + extern GCOps cwGCOps; static Bool @@ -477,7 +474,16 @@ miInitializeCompositeWrapper(ScreenPtr pScreen) cwScreenPtr pScreenPriv; Bool has_render = GetPictureScreenIfSet(pScreen) != NULL; - if (!dixRequestPrivate(cwGCKey, sizeof(cwGCRec))) + if (!dixRegisterPrivateKey(&cwScreenKeyRec, PRIVATE_SCREEN, 0)) + return; + + if (!dixRegisterPrivateKey(&cwGCKeyRec, PRIVATE_GC, sizeof(cwGCRec))) + return; + + if (!dixRegisterPrivateKey(&cwWindowKeyRec, PRIVATE_WINDOW, 0)) + return; + + if (!dixRegisterPrivateKey(&cwPictureKeyRec, PRIVATE_PICTURE, 0)) return; pScreenPriv = malloc(sizeof(cwScreenRec)); diff --git a/miext/cw/cw.h b/miext/cw/cw.h index 79051dfa2..31eb9e57c 100644 --- a/miext/cw/cw.h +++ b/miext/cw/cw.h @@ -44,7 +44,8 @@ typedef struct { GCFuncs *wrapFuncs; /* wrapped funcs */ } cwGCRec, *cwGCPtr; -extern _X_EXPORT DevPrivateKey cwGCKey; +extern _X_EXPORT DevPrivateKeyRec cwGCKeyRec; +#define cwGCKey (&cwGCKeyRec) #define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey)) #define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p) @@ -60,12 +61,15 @@ typedef struct { unsigned long stateChanges; } cwPictureRec, *cwPicturePtr; +extern _X_EXPORT DevPrivateKeyRec cwPictureKeyRec; +#define cwPictureKey (&cwPictureKeyRec) + #define getCwPicture(pPicture) (pPicture->pDrawable ? \ (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0) #define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p) -extern _X_EXPORT DevPrivateKey cwPictureKey; -extern _X_EXPORT DevPrivateKey cwWindowKey; +extern _X_EXPORT DevPrivateKeyRec cwWindowKeyRec; +#define cwWindowKey (&cwWindowKeyRec) #define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey) #define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow)) @@ -108,7 +112,8 @@ typedef struct { RasterizeTrapezoidProcPtr RasterizeTrapezoid; } cwScreenRec, *cwScreenPtr; -extern _X_EXPORT DevPrivateKey cwScreenKey; +extern _X_EXPORT DevPrivateKeyRec cwScreenKeyRec; +#define cwScreenKey (&cwScreenKeyRec) #define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey)) #define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p) diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 935b1c048..e8a119127 100644 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -70,14 +70,14 @@ #define pixmapDamage(pPixmap) damagePixPriv(pPixmap) -static int damageScrPrivateKeyIndex; -static DevPrivateKey damageScrPrivateKey = &damageScrPrivateKeyIndex; -static int damagePixPrivateKeyIndex; -static DevPrivateKey damagePixPrivateKey = &damagePixPrivateKeyIndex; -static int damageGCPrivateKeyIndex; -static DevPrivateKey damageGCPrivateKey = &damageGCPrivateKeyIndex; -static int damageWinPrivateKeyIndex; -static DevPrivateKey damageWinPrivateKey = &damageWinPrivateKeyIndex; +static DevPrivateKeyRec damageScrPrivateKeyRec; +#define damageScrPrivateKey (&damageScrPrivateKeyRec) +static DevPrivateKeyRec damagePixPrivateKeyRec; +#define damagePixPrivateKey (&damagePixPrivateKeyRec) +static DevPrivateKeyRec damageGCPrivateKeyRec; +#define damageGCPrivateKey (&damageGCPrivateKeyRec) +static DevPrivateKeyRec damageWinPrivateKeyRec; +#define damageWinPrivateKey (&damageWinPrivateKeyRec) static DamagePtr * getDrawableDamageRef (DrawablePtr pDrawable) @@ -1884,10 +1884,19 @@ DamageSetup (ScreenPtr pScreen) miDamageCreate, miDamageRegister, miDamageUnregister, miDamageDestroy }; + if (!dixRegisterPrivateKey(&damageScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + if (dixLookupPrivate(&pScreen->devPrivates, damageScrPrivateKey)) return TRUE; - if (!dixRequestPrivate(damageGCPrivateKey, sizeof(DamageGCPrivRec))) + if (!dixRegisterPrivateKey(&damageGCPrivateKeyRec, PRIVATE_GC, sizeof(DamageGCPrivRec))) + return FALSE; + + if (!dixRegisterPrivateKey(&damagePixPrivateKeyRec, PRIVATE_PICTURE, 0)) + return FALSE; + + if (!dixRegisterPrivateKey(&damageWinPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; pScrPriv = malloc(sizeof (DamageScrPrivRec)); @@ -1926,7 +1935,7 @@ DamageCreate (DamageReportFunc damageReport, damageScrPriv(pScreen); DamagePtr pDamage; - pDamage = malloc(sizeof (DamageRec)); + pDamage = dixAllocateObjectWithPrivates(DamageRec, PRIVATE_DAMAGE); if (!pDamage) return 0; pDamage->pNext = 0; @@ -1946,7 +1955,6 @@ DamageCreate (DamageReportFunc damageReport, pDamage->damageDestroy = damageDestroy; pDamage->damageMarker = NULL; pDamage->pScreen = pScreen; - pDamage->devPrivates = NULL; (*pScrPriv->funcs.Create) (pDamage); @@ -2050,11 +2058,9 @@ DamageDestroy (DamagePtr pDamage) if (pDamage->damageDestroy) (*pDamage->damageDestroy) (pDamage, pDamage->closure); (*pScrPriv->funcs.Destroy) (pDamage); - dixFreePrivates(pDamage->devPrivates); - pDamage->devPrivates = NULL; RegionUninit(&pDamage->damage); RegionUninit(&pDamage->pendingDamage); - free(pDamage); + dixFreeObjectWithPrivates(pDamage, PRIVATE_DAMAGE); } Bool diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h index 8a4b81321..6faf1febd 100644 --- a/miext/rootless/rootlessCommon.h +++ b/miext/rootless/rootlessCommon.h @@ -54,10 +54,17 @@ // Global variables -extern DevPrivateKey rootlessGCPrivateKey; -extern DevPrivateKey rootlessScreenPrivateKey; -extern DevPrivateKey rootlessWindowPrivateKey; -extern DevPrivateKey rootlessWindowOldPixmapPrivateKey; +extern DevPrivateKeyRec rootlessGCPrivateKeyRec; +#define rootlessGCPrivateKey (&rootlessGCPrivateKeyRec) + +extern DevPrivateKeyRec rootlessScreenPrivateKeyRec; +#define rootlessScreenPrivateKey (&rootlessScreenPrivateKeyRec) + +extern DevPrivateKeyRec rootlessWindowPrivateKeyRec; +#define rootlessWindowPrivateKey (&rootlessWindowPrivateKeyRec) + +extern DevPrivateKeyRec rootlessWindowOldPixmapPrivateKeyRec; +#define rootlessWindowOldPixmapPrivateKey (&rootlessWindowOldPixmapPrivateKeyRec) // RootlessGCRec: private per-gc data diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c index 24dcfe80a..43b9cbb53 100644 --- a/miext/rootless/rootlessScreen.c +++ b/miext/rootless/rootlessScreen.c @@ -62,15 +62,10 @@ extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild, extern Bool RootlessCreateGC(GCPtr pGC); // Initialize globals -static int rootlessGCPrivateKeyIndex; -DevPrivateKey rootlessGCPrivateKey = &rootlessGCPrivateKeyIndex; -static int rootlessScreenPrivateKeyIndex; -DevPrivateKey rootlessScreenPrivateKey = &rootlessScreenPrivateKeyIndex; -static int rootlessWindowPrivateKeyIndex; -DevPrivateKey rootlessWindowPrivateKey = &rootlessWindowPrivateKeyIndex; -static int rootlessWindowOldPixmapPrivateKeyIndex; -DevPrivateKey rootlessWindowOldPixmapPrivateKey = &rootlessWindowOldPixmapPrivateKeyIndex; - +DevPrivateKeyRec rootlessGCPrivateKeyRec; +DevPrivateKeyRec rootlessScreenPrivateKeyRec; +DevPrivateKeyRec rootlessWindowPrivateKeyRec; +DevPrivateKeyRec rootlessWindowOldPixmapPrivateKeyRec; /* * RootlessUpdateScreenPixmap @@ -637,8 +632,13 @@ RootlessAllocatePrivates(ScreenPtr pScreen) { RootlessScreenRec *s; - // no allocation needed for screen privates - if (!dixRequestPrivate(rootlessGCPrivateKey, sizeof(RootlessGCRec))) + if (!dixRegisterPrivateKey(&rootlessGCPrivateKeyRec, PRIVATE_GC, sizeof(RootlessGCRec))) + return FALSE; + if (!dixRegisterPrivateKey(&rootlessScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&rootlessWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&rootlessWindowOldPixmapPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; s = malloc(sizeof(RootlessScreenRec)); diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c index 893014bf4..111f46a60 100644 --- a/miext/shadow/shadow.c +++ b/miext/shadow/shadow.c @@ -36,8 +36,8 @@ #include "gcstruct.h" #include "shadow.h" -static int shadowScrPrivateKeyIndex; -DevPrivateKey shadowScrPrivateKey = &shadowScrPrivateKeyIndex; +static DevPrivateKeyRec shadowScrPrivateKeyRec; +#define shadowScrPrivateKey (&shadowScrPrivateKeyRec) #define wrap(priv, real, mem) {\ priv->mem = real->mem; \ @@ -233,6 +233,9 @@ shadowInit(ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window) { PixmapPtr pPixmap; + if (!dixRegisterPrivateKey(&shadowScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + pPixmap = pScreen->CreatePixmap(pScreen, pScreen->width, pScreen->height, pScreen->rootDepth, 0); if (!pPixmap) |