From 8264e0ae21a3ee123f68416e273e6083e8d15f33 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 4 Oct 2024 16:05:09 +0200 Subject: [PATCH] Xext: xv: 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 --- Xext/xvdix.h | 1 - Xext/xvmain.c | 33 +++++++-------------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Xext/xvdix.h b/Xext/xvdix.h index e1f33e1b4..b7b85380b 100644 --- a/Xext/xvdix.h +++ b/Xext/xvdix.h @@ -173,7 +173,6 @@ typedef struct { int version, revision; int nAdaptors; XvAdaptorPtr pAdaptors; - DestroyPixmapProcPtr DestroyPixmap; } XvScreenRec, *XvScreenPtr; extern _X_EXPORT int XvScreenInit(ScreenPtr); diff --git a/Xext/xvmain.c b/Xext/xvmain.c index f2b7de8ef..488ee70f1 100644 --- a/Xext/xvmain.c +++ b/Xext/xvmain.c @@ -143,7 +143,6 @@ static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *); static Bool CreateResourceTypes(void); static void XvScreenClose(CallbackListPtr *pcbl, ScreenPtr, void *arg); -static Bool XvDestroyPixmap(PixmapPtr); static void XvResetProc(ExtensionEntry *); static int XvdiDestroyGrab(void *, XID); static int XvdiDestroyEncoding(void *, XID); @@ -263,6 +262,11 @@ static void XvWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr XvStopAdaptors(&pWin->drawable); } +static void XvPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap) +{ + XvStopAdaptors(&pPixmap->drawable); +} + int XvScreenInit(ScreenPtr pScreen) { @@ -296,12 +300,9 @@ XvScreenInit(ScreenPtr pScreen) dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs); - pxvs->DestroyPixmap = pScreen->DestroyPixmap; - dixScreenHookWindowDestroy(pScreen, XvWindowDestroy); dixScreenHookClose(pScreen, XvScreenClose); - - pScreen->DestroyPixmap = XvDestroyPixmap; + dixScreenHookPixmapDestroy(pScreen, XvPixmapDestroy); return Success; } @@ -314,8 +315,7 @@ static void XvScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused dixScreenUnhookWindowDestroy(pScreen, XvWindowDestroy); dixScreenUnhookClose(pScreen, XvScreenClose); - - pScreen->DestroyPixmap = pxvs->DestroyPixmap; + dixScreenUnhookPixmapDestroy(pScreen, XvPixmapDestroy); free(pxvs); @@ -369,25 +369,6 @@ XvStopAdaptors(DrawablePtr pDrawable) } } -static Bool -XvDestroyPixmap(PixmapPtr pPix) -{ - ScreenPtr pScreen = pPix->drawable.pScreen; - Bool status = TRUE; - - if (pPix->refcnt == 1) - XvStopAdaptors(&pPix->drawable); - - SCREEN_PROLOGUE(pScreen, DestroyPixmap); - if (pScreen->DestroyPixmap) - status = pScreen->DestroyPixmap(pPix); - SCREEN_EPILOGUE(pScreen, DestroyPixmap, XvDestroyPixmap); - - return status; - -} - - static int XvdiDestroyPort(void *pPort, XID id) {