summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-04-16 05:55:33 -0400
committerKeith Packard <keithp@keithp.com>2010-04-16 14:53:25 -0700
commit22da7aa9d743deee198aaf6df5d370a446db9763 (patch)
tree0506426983d14e5606b0fd8c9323701dcde15a94
parentf0006aa58f6cf7552a239e169ff6e7e4fda532f4 (diff)
glx: Let the resource system destroy pixmaps
GLX pbuffers are implemented using a pixmap allocated by the server. With the change to DRI2 to track DRI2 drawables as resources, we need to make sure that every drawable we create a DRI2 drawable for has an XID. By using the XID of the pbuffer, the resource system will automatically reclaim the hidden pixmap and the DRI2 drawable when the pbuffer is destroyed or the client exits. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--glx/glxcmds.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 04c6d40df..087d52ec2 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -1101,14 +1101,6 @@ __glXDrawableInit(__GLXdrawable *drawable,
void
__glXDrawableRelease(__GLXdrawable *drawable)
{
- ScreenPtr pScreen = drawable->pDraw->pScreen;
-
- switch (drawable->type) {
- case GLX_DRAWABLE_PIXMAP:
- case GLX_DRAWABLE_PBUFFER:
- (*pScreen->DestroyPixmap)((PixmapPtr) drawable->pDraw);
- break;
- }
}
static int
@@ -1117,8 +1109,6 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *conf
{
__GLXdrawable *pGlxDraw;
- LEGAL_NEW_RESOURCE(glxDrawableId, client);
-
if (pGlxScreen->pScreen != pDraw->pScreen)
return BadMatch;
@@ -1135,7 +1125,8 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *conf
/* Add the glx drawable under the XID of the underlying X drawable
* too. That way we'll get a callback in DrawableGone and can
* clean up properly when the drawable is destroyed. */
- if (!AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) {
+ if (pDraw->id != glxDrawableId &&
+ !AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) {
pGlxDraw->destroy (pGlxDraw);
return BadAlloc;
}
@@ -1150,6 +1141,8 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config
DrawablePtr pDraw;
int err;
+ LEGAL_NEW_RESOURCE(glxDrawableId, client);
+
err = dixLookupDrawable(&pDraw, drawableId, client, 0, DixAddAccess);
if (err != Success) {
client->errorValue = drawableId;
@@ -1163,9 +1156,6 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config
err = DoCreateGLXDrawable(client, pGlxScreen, config, pDraw,
glxDrawableId, GLX_DRAWABLE_PIXMAP);
- if (err == Success)
- ((PixmapPtr) pDraw)->refcnt++;
-
return err;
}
@@ -1306,6 +1296,8 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
PixmapPtr pPixmap;
int err;
+ LEGAL_NEW_RESOURCE(glxDrawableId, client);
+
if (!validGlxScreen(client, screenNum, &pGlxScreen, &err))
return err;
if (!validGlxFBConfig(client, pGlxScreen, fbconfigId, &config, &err))
@@ -1316,6 +1308,13 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
width, height, config->rgbBits, 0);
__glXleaveServer(GL_FALSE);
+ /* Assign the pixmap the same id as the pbuffer and add it as a
+ * resource so it and the DRI2 drawable will be reclaimed when the
+ * pbuffer is destroyed. */
+ pPixmap->drawable.id = glxDrawableId;
+ if (!AddResource(pPixmap->drawable.id, RT_PIXMAP, pPixmap))
+ return BadAlloc;
+
return DoCreateGLXDrawable(client, pGlxScreen, config, &pPixmap->drawable,
glxDrawableId, GLX_DRAWABLE_PBUFFER);
}
@@ -1423,6 +1422,8 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc)
DrawablePtr pDraw;
int err;
+ LEGAL_NEW_RESOURCE(req->glxwindow, client);
+
if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
return err;
if (!validGlxFBConfig(client, pGlxScreen, req->fbconfig, &config, &err))