DRI2: Track DRI2 drawables as resources, not privates

The main motivation here is to have the resource system clean up the
DRI2 drawable automatically so glx doesn't have to.  Right now, the
glx drawable resource must be destroyed before the X drawable, so that
calling DRI2DestroyDrawable doesn't crash.  By making the DRI2
drawable a resource, GLX doesn't have to worry about that and the
resource destruction order becomes irrelevant.

https://bugs.freedesktop.org/show_bug.cgi?id=26394

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Kristian Høgsberg 2010-04-16 05:55:34 -04:00 • committed by Keith Packard
commit 1da1f33f2d
3 changed files with 38 additions and 128 deletions

View file

@ -51,7 +51,6 @@
#include "xf86Module.h"
static ExtensionEntry *dri2Extension;
static RESTYPE dri2DrawableRes;
static Bool
validDrawable(ClientPtr client, XID drawable, Mask access_mode,
@ -172,11 +171,6 @@ ProcDRI2CreateDrawable(ClientPtr client)
if (status != Success)
return status;
if (!AddResource(stuff->drawable, dri2DrawableRes, pDrawable)) {
DRI2DestroyDrawable(pDrawable);
return BadAlloc;
}
return client->noClientException;
}
@ -192,8 +186,6 @@ ProcDRI2DestroyDrawable(ClientPtr client)
&pDrawable, &status))
return status;
FreeResourceByType(stuff->drawable, dri2DrawableRes, FALSE);
return client->noClientException;
}
@ -627,25 +619,11 @@ SProcDRI2Dispatch (ClientPtr client)
}
}
static int DRI2DrawableGone(pointer p, XID id)
{
DrawablePtr pDrawable = p;
DRI2DestroyDrawable(pDrawable);
return Success;
}
int DRI2EventBase;
static void
DRI2ExtensionInit(void)
{
dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
if (!dri2DrawableRes)
return;
dri2Extension = AddExtension(DRI2_NAME,
DRI2NumberEvents,
DRI2NumberErrors,