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