diff options
author | Kristian Høgsberg <[email protected]> | 2010-07-19 21:15:50 -0400 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2010-07-19 22:45:51 -0400 |
commit | e3e8196c025bd344a59b4671e473c395a6ea426b (patch) | |
tree | 3178db533025d91fa69563486c5034cf5f37e854 /src/glx | |
parent | 037755122e9011c768e5caa4d4cb83aba783d3e9 (diff) |
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.
Diffstat (limited to 'src/glx')
-rw-r--r-- | src/glx/glx_pbuffer.c | 4 | ||||
-rw-r--r-- | src/glx/glxclient.h | 3 | ||||
-rw-r--r-- | src/glx/glxcmds.c | 42 | ||||
-rw-r--r-- | src/glx/glxcurrent.c | 6 | ||||
-rw-r--r-- | src/glx/glxext.c | 13 |
5 files changed, 27 insertions, 41 deletions
diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c index bbdba34ebde..171ede4660a 100644 --- a/src/glx/glx_pbuffer.c +++ b/src/glx/glx_pbuffer.c @@ -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); } } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 207908f7e25..adfa3ce1b6b 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -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. */ diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index a75226a657c..6753394ae1a 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -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 diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index c423ffcbdf8..43469c371cf 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -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; } diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 445592f1a8a..65aacc5887d 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -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 |