Xext: shm: use PixmapDestroy hook
Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new pixmap destroy notify hook instead. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
befc3d22cf
commit
63485bcc02
45
Xext/shm.c
45
Xext/shm.c
|
@ -98,7 +98,6 @@ in this Software without prior written authorization from The Open Group.
|
||||||
|
|
||||||
typedef struct _ShmScrPrivateRec {
|
typedef struct _ShmScrPrivateRec {
|
||||||
ShmFuncsPtr shmFuncs;
|
ShmFuncsPtr shmFuncs;
|
||||||
DestroyPixmapProcPtr destroyPixmap;
|
|
||||||
} ShmScrPrivateRec;
|
} ShmScrPrivateRec;
|
||||||
|
|
||||||
Bool noMITShmExtension = FALSE;
|
Bool noMITShmExtension = FALSE;
|
||||||
|
@ -109,8 +108,6 @@ static void ShmResetProc(ExtensionEntry *extEntry);
|
||||||
static void SShmCompletionEvent(xShmCompletionEvent *from,
|
static void SShmCompletionEvent(xShmCompletionEvent *from,
|
||||||
xShmCompletionEvent *to);
|
xShmCompletionEvent *to);
|
||||||
|
|
||||||
static Bool ShmDestroyPixmap(PixmapPtr pPixmap);
|
|
||||||
|
|
||||||
static unsigned char ShmReqCode;
|
static unsigned char ShmReqCode;
|
||||||
int ShmCompletionCode;
|
int ShmCompletionCode;
|
||||||
int BadShmSegCode;
|
int BadShmSegCode;
|
||||||
|
@ -244,28 +241,6 @@ ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs)
|
||||||
ShmInitScreenPriv(pScreen)->shmFuncs = funcs;
|
ShmInitScreenPriv(pScreen)->shmFuncs = funcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
|
||||||
ShmDestroyPixmap(PixmapPtr pPixmap)
|
|
||||||
{
|
|
||||||
ScreenPtr pScreen = pPixmap->drawable.pScreen;
|
|
||||||
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
|
|
||||||
void *shmdesc = NULL;
|
|
||||||
Bool ret = TRUE;
|
|
||||||
|
|
||||||
if (pPixmap->refcnt == 1)
|
|
||||||
shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey);
|
|
||||||
|
|
||||||
pScreen->DestroyPixmap = screen_priv->destroyPixmap;
|
|
||||||
if (pScreen->DestroyPixmap)
|
|
||||||
ret = pScreen->DestroyPixmap(pPixmap);
|
|
||||||
screen_priv->destroyPixmap = pScreen->DestroyPixmap;
|
|
||||||
pScreen->DestroyPixmap = ShmDestroyPixmap;
|
|
||||||
|
|
||||||
if (shmdesc)
|
|
||||||
ShmDetachSegment(shmdesc, 0);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShmRegisterFbFuncs(ScreenPtr pScreen)
|
ShmRegisterFbFuncs(ScreenPtr pScreen)
|
||||||
|
@ -434,6 +409,9 @@ ShmDetachSegment(void *value, /* must conform to DeleteType */
|
||||||
ShmDescPtr shmdesc = (ShmDescPtr) value;
|
ShmDescPtr shmdesc = (ShmDescPtr) value;
|
||||||
ShmDescPtr *prev;
|
ShmDescPtr *prev;
|
||||||
|
|
||||||
|
if (!shmdesc)
|
||||||
|
return Success;
|
||||||
|
|
||||||
if (--shmdesc->refcnt)
|
if (--shmdesc->refcnt)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#if SHM_FD_PASSING
|
#if SHM_FD_PASSING
|
||||||
|
@ -1511,6 +1489,14 @@ SProcShmDispatch(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ShmPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
|
||||||
|
{
|
||||||
|
ShmDetachSegment(
|
||||||
|
dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey),
|
||||||
|
0);
|
||||||
|
dixSetPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShmExtensionInit(void)
|
ShmExtensionInit(void)
|
||||||
{
|
{
|
||||||
|
@ -1541,13 +1527,8 @@ ShmExtensionInit(void)
|
||||||
sharedPixmaps = xFalse;
|
sharedPixmaps = xFalse;
|
||||||
}
|
}
|
||||||
if (sharedPixmaps)
|
if (sharedPixmaps)
|
||||||
for (i = 0; i < screenInfo.numScreens; i++) {
|
for (i = 0; i < screenInfo.numScreens; i++)
|
||||||
ShmScrPrivateRec *screen_priv =
|
dixScreenHookPixmapDestroy(screenInfo.screens[i], ShmPixmapDestroy);
|
||||||
ShmGetScreenPriv(screenInfo.screens[i]);
|
|
||||||
screen_priv->destroyPixmap =
|
|
||||||
screenInfo.screens[i]->DestroyPixmap;
|
|
||||||
screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
|
ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
|
||||||
if (ShmSegType &&
|
if (ShmSegType &&
|
||||||
|
|
Loading…
Reference in New Issue