xserver: Branch 'dri2-swapbuffers'
Kristian Høgsberg
krh at kemper.freedesktop.org
Fri Jul 17 17:20:46 PDT 2009
hw/xfree86/dri2/dri2.c | 15 +++++++++++----
hw/xfree86/dri2/dri2.h | 7 ++++---
2 files changed, 15 insertions(+), 7 deletions(-)
New commits:
commit 28e55588e45c2b215bf7aaa6fc84088b3c220021
Author: Kristian Høgsberg <krh at redhat.com>
Date: Fri Jul 17 12:20:06 2009 -0400
Change DRI2SwapComplete() to not take a DrawablePtr, which may have been freed
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 787cdd7..78eb101 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -393,7 +393,7 @@ DRI2SwapBuffers(DrawablePtr pDraw)
return BadValue;
if (DRI2FlipCheck(pDraw) &&
- (*ds->SwapBuffers)(pDraw, pDestBuffer, pSrcBuffer))
+ (*ds->SwapBuffers)(pDraw, pDestBuffer, pSrcBuffer, pPriv))
{
pPriv->swapPending = TRUE;
return Success;
@@ -429,15 +429,18 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
}
void
-DRI2SwapComplete(DrawablePtr pDrawable)
+DRI2SwapComplete(void *data)
{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+ DRI2DrawablePtr pPriv = data;
if (pPriv->blockedClient)
AttendClient(pPriv->blockedClient);
pPriv->swapPending = FALSE;
pPriv->blockedClient = NULL;
+
+ if (pPriv->refCount == 0)
+ xfree(pPriv);
}
void
@@ -465,7 +468,11 @@ DRI2DestroyDrawable(DrawablePtr pDraw)
xfree(pPriv->buffers);
}
- xfree(pPriv);
+ /* If the window is destroyed while we have a swap pending, don't
+ * actually free the priv yet. We'll need it in the DRI2SwapComplete()
+ * callback and we'll free it there once we're done. */
+ if (!pPriv->swapPending)
+ xfree(pPriv);
if (pDraw->type == DRAWABLE_WINDOW)
{
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 8cf2308..42bdb09 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -60,7 +60,8 @@ typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer);
typedef Bool (*DRI2SwapBuffersProcPtr)(DrawablePtr pDraw,
DRI2BufferPtr pFrontBuffer,
- DRI2BufferPtr pBackBuffer);
+ DRI2BufferPtr pBackBuffer,
+ void *data);
typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
unsigned int sequence);
@@ -140,8 +141,8 @@ extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
int *width, int *height, unsigned int *attachments, int count,
int *out_count);
-extern _X_EXPORT int DRI2SwapBuffers(DrawablePtr pDraw);
+extern _X_EXPORT int DRI2SwapBuffers(DrawablePtr pDrawable);
extern _X_EXPORT Bool DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable);
-extern _X_EXPORT void DRI2SwapComplete(DrawablePtr pDrawable);
+extern _X_EXPORT void DRI2SwapComplete(void *data);
#endif
More information about the xorg-commit
mailing list