glx: Move drawHash to display private
The XIDs are display wide so the natural location of the hash is here. This way we don't have to lookup in each of the screen hashes.
This commit is contained in:
@@ -202,7 +202,7 @@ CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig,
|
||||
return;
|
||||
}
|
||||
|
||||
if (__glxHashInsert(psc->drawHash, glxdrawable, pdraw)) {
|
||||
if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) {
|
||||
(*pdraw->destroyDrawable) (pdraw);
|
||||
return; /* FIXME: Check what we're supposed to do here... */
|
||||
}
|
||||
@@ -223,7 +223,7 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
|
||||
if (destroy_xdrawable)
|
||||
XFreePixmap(psc->dpy, pdraw->xDrawable);
|
||||
(*pdraw->destroyDrawable) (pdraw);
|
||||
__glxHashDelete(psc->drawHash, drawable);
|
||||
__glxHashDelete(priv->drawHash, drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -529,7 +529,6 @@ struct __GLXscreenConfigsRec
|
||||
/**
|
||||
* Per screen direct rendering interface functions and data.
|
||||
*/
|
||||
__glxHashTable *drawHash;
|
||||
Display *dpy;
|
||||
int scr;
|
||||
|
||||
@@ -607,6 +606,8 @@ struct __GLXdisplayPrivateRec
|
||||
__GLXscreenConfigs **screenConfigs;
|
||||
|
||||
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
||||
__glxHashTable *drawHash;
|
||||
|
||||
/**
|
||||
* Per display direct rendering interface functions and data.
|
||||
*/
|
||||
|
@@ -86,32 +86,33 @@ windowExistsErrorHandler(Display * dpy, XErrorEvent * xerr)
|
||||
* \param screen Screen number to destroy drawables for
|
||||
*/
|
||||
static void
|
||||
GarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc)
|
||||
GarbageCollectDRIDrawables(__GLXscreenConfigs * sc)
|
||||
{
|
||||
XID draw;
|
||||
__GLXDRIdrawable *pdraw;
|
||||
__GLXdisplayPrivate *priv = sc->display;
|
||||
XWindowAttributes xwa;
|
||||
int (*oldXErrorHandler) (Display *, XErrorEvent *);
|
||||
|
||||
/* Set no-op error handler so Xlib doesn't bail out if the windows
|
||||
* has alreay been destroyed on the server. */
|
||||
XSync(dpy, GL_FALSE);
|
||||
XSync(priv->dpy, GL_FALSE);
|
||||
oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
|
||||
|
||||
if (__glxHashFirst(sc->drawHash, &draw, (void *) &pdraw) == 1) {
|
||||
if (__glxHashFirst(priv->drawHash, &draw, (void *) &pdraw) == 1) {
|
||||
do {
|
||||
windowExistsFlag = GL_TRUE;
|
||||
XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
|
||||
XGetWindowAttributes(priv->dpy, draw, &xwa); /* dummy request */
|
||||
if (!windowExistsFlag) {
|
||||
/* Destroy the local drawable data, if the drawable no
|
||||
longer exists in the Xserver */
|
||||
(*pdraw->destroyDrawable) (pdraw);
|
||||
__glxHashDelete(sc->drawHash, draw);
|
||||
__glxHashDelete(priv->drawHash, draw);
|
||||
}
|
||||
} while (__glxHashNext(sc->drawHash, &draw, (void *) &pdraw) == 1);
|
||||
} while (__glxHashNext(priv->drawHash, &draw, (void *) &pdraw) == 1);
|
||||
}
|
||||
|
||||
XSync(dpy, GL_FALSE);
|
||||
XSync(priv->dpy, GL_FALSE);
|
||||
XSetErrorHandler(oldXErrorHandler);
|
||||
}
|
||||
|
||||
@@ -129,23 +130,14 @@ GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable, int *const scrn_num)
|
||||
{
|
||||
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable *pdraw;
|
||||
const unsigned screen_count = ScreenCount(dpy);
|
||||
unsigned i;
|
||||
__GLXscreenConfigs *psc;
|
||||
|
||||
if (priv == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < screen_count; i++) {
|
||||
psc = priv->screenConfigs[i];
|
||||
if (psc->drawHash == NULL)
|
||||
continue;
|
||||
|
||||
if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) {
|
||||
if (scrn_num != NULL)
|
||||
*scrn_num = i;
|
||||
return pdraw;
|
||||
}
|
||||
if (__glxHashLookup(priv->drawHash, drawable, (void *) &pdraw) == 0) {
|
||||
if (scrn_num != NULL)
|
||||
*scrn_num = pdraw->psc->scr;
|
||||
return pdraw;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -583,7 +575,7 @@ DestroyContext(Display * dpy, GLXContext gc)
|
||||
if (gc->driContext) {
|
||||
(*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy);
|
||||
gc->driContext = NULL;
|
||||
GarbageCollectDRIDrawables(dpy, gc->psc);
|
||||
GarbageCollectDRIDrawables(gc->psc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1002,7 +994,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
|
||||
break;
|
||||
}
|
||||
|
||||
if (__glxHashInsert(psc->drawHash, req->glxpixmap, pdraw)) {
|
||||
if (__glxHashInsert(priv->drawHash, req->glxpixmap, pdraw)) {
|
||||
(*pdraw->destroyDrawable) (pdraw);
|
||||
return None; /* FIXME: Check what we're supposed to do here... */
|
||||
}
|
||||
@@ -1042,14 +1034,12 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
|
||||
|
||||
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
||||
{
|
||||
int screen;
|
||||
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen);
|
||||
__GLXscreenConfigs *psc = priv->screenConfigs[screen];
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, NULL);
|
||||
|
||||
if (pdraw != NULL) {
|
||||
(*pdraw->destroyDrawable) (pdraw);
|
||||
__glxHashDelete(psc->drawHash, glxpixmap);
|
||||
__glxHashDelete(priv->drawHash, glxpixmap);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -296,15 +296,15 @@ FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc)
|
||||
return NULL;
|
||||
|
||||
psc = priv->screenConfigs[gc->screen];
|
||||
if (psc->drawHash == NULL)
|
||||
if (priv->drawHash == NULL)
|
||||
return NULL;
|
||||
|
||||
if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
|
||||
if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
|
||||
return pdraw;
|
||||
|
||||
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
|
||||
glxDrawable, gc->mode);
|
||||
if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
|
||||
if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
|
||||
(*pdraw->destroyDrawable) (pdraw);
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -268,7 +268,6 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv)
|
||||
psc->driver_configs = NULL;
|
||||
}
|
||||
if (psc->driScreen) {
|
||||
__glxHashDestroy(psc->drawHash);
|
||||
psc->driScreen->destroyScreen(psc);
|
||||
psc->driScreen = NULL;
|
||||
} else {
|
||||
@@ -302,6 +301,8 @@ __glXFreeDisplayPrivate(XExtData * extension)
|
||||
priv->serverGLXversion = 0x0; /* to protect against double free's */
|
||||
}
|
||||
|
||||
__glxHashDestroy(priv->drawHash);
|
||||
|
||||
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
||||
/* Free the direct rendering per display data */
|
||||
if (priv->driswDisplay)
|
||||
@@ -758,10 +759,7 @@ glx_screen_init(__GLXscreenConfigs *psc,
|
||||
psc->ext_list_first_time = GL_TRUE;
|
||||
psc->scr = screen;
|
||||
psc->dpy = priv->dpy;
|
||||
psc->drawHash = __glxHashCreate();
|
||||
psc->display = priv;
|
||||
if (psc->drawHash == NULL)
|
||||
return GL_FALSE;
|
||||
|
||||
getVisualConfigs(psc, priv, screen);
|
||||
getFBConfigs(psc, priv, screen);
|
||||
@@ -815,11 +813,6 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
|
||||
psc = (*priv->driswDisplay->createScreen) (i, priv);
|
||||
if (psc == NULL)
|
||||
psc = createIndirectScreen (i, priv);
|
||||
|
||||
if (psc == NULL) {
|
||||
__glxHashDestroy(psc->drawHash);
|
||||
psc->drawHash = NULL;
|
||||
}
|
||||
#endif
|
||||
priv->screenConfigs[i] = psc;
|
||||
}
|
||||
@@ -899,6 +892,8 @@ __glXInitialize(Display * dpy)
|
||||
glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
|
||||
glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
|
||||
|
||||
dpyPriv->drawHash = __glxHashCreate();
|
||||
|
||||
/*
|
||||
** Initialize the direct rendering per display data and functions.
|
||||
** Note: This _must_ be done before calling any other DRI routines
|
||||
|
Reference in New Issue
Block a user