* \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);
}
{
__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;
if (gc->driContext) {
(*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy);
gc->driContext = NULL;
- GarbageCollectDRIDrawables(dpy, gc->psc);
+ GarbageCollectDRIDrawables(gc->psc);
}
#endif
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... */
}
#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
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;
}
psc->driver_configs = NULL;
}
if (psc->driScreen) {
- __glxHashDestroy(psc->drawHash);
psc->driScreen->destroyScreen(psc);
psc->driScreen = NULL;
} else {
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)
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);
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;
}
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