From dd823c737039b48c162aaa86cebcbb9e14b463d2 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 11 Jun 2025 17:44:29 -0700 Subject: [PATCH] Revert "dix: use dixDestroyPixmap() instead of direct driver call" This reverts commit 5b541780c18923af44fa827441c6c2b418196e62. Part-of: --- dix/dispatch.c | 2 +- dix/gc.c | 20 +++++++++++--------- dix/glyphcurs.c | 5 +++-- dix/pixmap.c | 7 ++++--- dix/window.c | 18 +++++++++--------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 2308cfe6d..efb6818df 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1525,7 +1525,7 @@ ProcCreatePixmap(ClientPtr client) rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) { - dixDestroyPixmap(pMap, 0); + (*pDraw->pScreen->DestroyPixmap) (pMap); return rc; } if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap)) diff --git a/dix/gc.c b/dix/gc.c index ab5844353..5f7535803 100644 --- a/dix/gc.c +++ b/dix/gc.c @@ -254,7 +254,7 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion) else { pPixmap->refcnt++; if (!pGC->tileIsPixel) - dixDestroyPixmap(pGC->tile.pixmap, 0); + (*pGC->pScreen->DestroyPixmap) (pGC->tile.pixmap); pGC->tileIsPixel = FALSE; pGC->tile.pixmap = pPixmap; } @@ -271,7 +271,7 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion) if (pPixmap) pPixmap->refcnt++; if (pGC->stipple) - dixDestroyPixmap(pGC->stipple, 0); + (*pGC->pScreen->DestroyPixmap) (pGC->stipple); pGC->stipple = pPixmap; } break; @@ -588,7 +588,8 @@ CreateDefaultTile(GCPtr pGC) (*pGC->pScreen->CreatePixmap) (pGC->pScreen, w, h, pGC->depth, 0); pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen); if (!pTile || !pgcScratch) { - dixDestroyPixmap(pTile, 0); + if (pTile) + (*pTile->drawable.pScreen->DestroyPixmap) (pTile); if (pgcScratch) FreeScratchGC(pgcScratch); return FALSE; @@ -667,7 +668,7 @@ CopyGC(GC * pgcSrc, GC * pgcDst, BITS32 mask) break; } if (!pgcDst->tileIsPixel) - dixDestroyPixmap(pgcDst->tile.pixmap, 0); + (*pgcDst->pScreen->DestroyPixmap) (pgcDst->tile.pixmap); pgcDst->tileIsPixel = pgcSrc->tileIsPixel; pgcDst->tile = pgcSrc->tile; if (!pgcDst->tileIsPixel) @@ -679,7 +680,7 @@ CopyGC(GC * pgcSrc, GC * pgcDst, BITS32 mask) if (pgcDst->stipple == pgcSrc->stipple) break; if (pgcDst->stipple) - dixDestroyPixmap(pgcDst->stipple, 0); + (*pgcDst->pScreen->DestroyPixmap) (pgcDst->stipple); pgcDst->stipple = pgcSrc->stipple; if (pgcDst->stipple) pgcDst->stipple->refcnt++; @@ -774,9 +775,9 @@ FreeGC(void *value, XID gid) (*pGC->funcs->DestroyClip) (pGC); if (!pGC->tileIsPixel) - dixDestroyPixmap(pGC->tile.pixmap, 0); + (*pGC->pScreen->DestroyPixmap) (pGC->tile.pixmap); if (pGC->stipple) - dixDestroyPixmap(pGC->stipple, 0); + (*pGC->pScreen->DestroyPixmap) (pGC->stipple); if (pGC->funcs) (*pGC->funcs->DestroyGC) (pGC); @@ -884,7 +885,7 @@ CreateDefaultStipple(int screenNum) tmpval[2].val = FillSolid; pgcScratch = GetScratchGC(1, pScreen); if (!pgcScratch) { - dixDestroyPixmap(pScreen->defaultStipple, 0); + (*pScreen->DestroyPixmap) (pScreen->defaultStipple); return FALSE; } (void) ChangeGC(NullClient, pgcScratch, @@ -904,7 +905,8 @@ void FreeDefaultStipple(int screenNum) { ScreenPtr pScreen = screenInfo.screens[screenNum]; - dixDestroyPixmap(pScreen->defaultStipple, 0); + + (*pScreen->DestroyPixmap) (pScreen->defaultStipple); } int diff --git a/dix/glyphcurs.c b/dix/glyphcurs.c index 5747d0b20..012af910e 100644 --- a/dix/glyphcurs.c +++ b/dix/glyphcurs.c @@ -96,7 +96,8 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm, CREATE_PIXMAP_USAGE_SCRATCH); pGC = GetScratchGC(1, pScreen); if (!ppix || !pGC) { - dixDestroyPixmap(ppix, 0); + if (ppix) + (*pScreen->DestroyPixmap) (ppix); if (pGC) FreeScratchGC(pGC); free(pbits); @@ -126,7 +127,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm, XYPixmap, 1, pbits); *ppbits = (unsigned char *) pbits; FreeScratchGC(pGC); - dixDestroyPixmap(ppix, 0); + (*pScreen->DestroyPixmap) (ppix); return Success; } diff --git a/dix/pixmap.c b/dix/pixmap.c index f7812804a..020ceb83a 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -63,7 +63,7 @@ GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, if ((*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData)) return pPixmap; - dixDestroyPixmap(pPixmap, 0); + (*pScreen->DestroyPixmap) (pPixmap); } return NullPixmap; } @@ -73,8 +73,9 @@ void FreeScratchPixmapHeader(PixmapPtr pPixmap) { if (pPixmap) { + ScreenPtr pScreen = pPixmap->drawable.pScreen; pPixmap->devPrivate.ptr = NULL; /* help catch/avoid heap-use-after-free */ - dixDestroyPixmap(pPixmap, 0); + (*pScreen->DestroyPixmap)(pPixmap); } } @@ -150,7 +151,7 @@ PixmapPtr PixmapShareToSecondary(PixmapPtr pixmap, ScreenPtr secondary) ret = secondary->SetSharedPixmapBacking(spix, handle); if (ret == FALSE) { - dixDestroyPixmap(spix, 0); + secondary->DestroyPixmap(spix); return NULL; } diff --git a/dix/window.c b/dix/window.c index 672593512..6b7fc808e 100644 --- a/dix/window.c +++ b/dix/window.c @@ -1014,9 +1014,9 @@ FreeWindowResources(WindowPtr pWin) if (wInputShape(pWin)) RegionDestroy(wInputShape(pWin)); if (pWin->borderIsPixel == FALSE) - dixDestroyPixmap(pWin->border.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->border.pixmap); if (pWin->backgroundState == BackgroundPixmap) - dixDestroyPixmap(pWin->background.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->background.pixmap); DeleteAllWindowProperties(pWin); /* We SHOULD check for an error value here XXX */ @@ -1195,7 +1195,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) borderRelative = TRUE; if (pixID == None) { if (pWin->backgroundState == BackgroundPixmap) - dixDestroyPixmap(pWin->background.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->background.pixmap); if (!pWin->parent) SetRootWindowBackground(pWin, pScreen, &index2); else { @@ -1210,7 +1210,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) goto PatchUp; } if (pWin->backgroundState == BackgroundPixmap) - dixDestroyPixmap(pWin->background.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->background.pixmap); if (!pWin->parent) SetRootWindowBackground(pWin, pScreen, &index2); else @@ -1229,7 +1229,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) goto PatchUp; } if (pWin->backgroundState == BackgroundPixmap) - dixDestroyPixmap(pWin->background.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->background.pixmap); pWin->backgroundState = BackgroundPixmap; pWin->background.pixmap = pPixmap; pPixmap->refcnt++; @@ -1245,7 +1245,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) if (pWin->backgroundState == ParentRelative) borderRelative = TRUE; if (pWin->backgroundState == BackgroundPixmap) - dixDestroyPixmap(pWin->background.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->background.pixmap); pWin->backgroundState = BackgroundPixel; pWin->background.pixel = (CARD32) *pVlist; /* background pixel overrides background pixmap, @@ -1264,7 +1264,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) } if (pWin->parent->borderIsPixel == TRUE) { if (pWin->borderIsPixel == FALSE) - dixDestroyPixmap(pWin->border.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->border.pixmap); pWin->border = pWin->parent->border; pWin->borderIsPixel = TRUE; index2 = CWBorderPixel; @@ -1283,7 +1283,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) goto PatchUp; } if (pWin->borderIsPixel == FALSE) - dixDestroyPixmap(pWin->border.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->border.pixmap); pWin->borderIsPixel = FALSE; pWin->border.pixmap = pPixmap; pPixmap->refcnt++; @@ -1296,7 +1296,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) break; case CWBorderPixel: if (pWin->borderIsPixel == FALSE) - dixDestroyPixmap(pWin->border.pixmap, 0); + (*pScreen->DestroyPixmap) (pWin->border.pixmap); pWin->borderIsPixel = TRUE; pWin->border.pixel = (CARD32) *pVlist; /* border pixel overrides border pixmap,