From 7d8b90a47051152e24ead666ea52494d7d43d1e1 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 6 Jan 2023 16:51:12 -0500 Subject: [PATCH] glx: Harmonize glXCreateGLXPixmap with glXCreatePixmap This was open-coding some things, and not perfectly. Likewise for the destroy path. Part-of: --- src/glx/glx_pbuffer.c | 66 +++++-------------------------------------- 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c index 48289d7bb3d..e0a0b662816 100644 --- a/src/glx/glx_pbuffer.c +++ b/src/glx/glx_pbuffer.c @@ -974,39 +974,16 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) /* FIXME: Maybe delay __DRIdrawable creation until the drawable * is actually bound to a context... */ - __GLXDRIdrawable *pdraw; - struct glx_screen *psc; - struct glx_config *config; + struct glx_screen *psc = GetGLXScreenConfigs(dpy, vis->screen); + struct glx_config *config = glx_config_find_visual(psc->visuals, + vis->visualid); - psc = priv->screens[vis->screen]; - if (psc->driScreen == NULL) - return xid; - - config = glx_config_find_visual(psc->visuals, vis->visualid); - pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, GLX_PIXMAP_BIT, config); - if (pdraw == NULL) { - fprintf(stderr, "failed to create pixmap\n"); + if (!CreateDRIDrawable(dpy, config, pixmap, xid, GLX_PIXMAP_BIT, + NULL, 0)) { + protocolDestroyDrawable(dpy, xid, X_GLXDestroyGLXPixmap); xid = None; - break; - } - - if (__glxHashInsert(priv->drawHash, xid, pdraw)) { - pdraw->destroyDrawable(pdraw); - xid = None; - break; } } while (0); - - if (xid == None) { - xGLXDestroyGLXPixmapReq *dreq; - LockDisplay(dpy); - GetReq(GLXDestroyGLXPixmap, dreq); - dreq->reqType = opcode; - dreq->glxCode = X_GLXDestroyGLXPixmap; - dreq->glxpixmap = xid; - UnlockDisplay(dpy); - SyncHandle(); - } #endif return xid; @@ -1023,36 +1000,7 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap) if(apple_glx_pixmap_destroy(dpy, glxpixmap)) __glXSendError(dpy, GLXBadPixmap, glxpixmap, X_GLXDestroyPixmap, false); #else - xGLXDestroyGLXPixmapReq *req; - CARD8 opcode; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) { - return; - } - - /* Send the glXDestroyGLXPixmap request */ - LockDisplay(dpy); - GetReq(GLXDestroyGLXPixmap, req); - req->reqType = opcode; - req->glxCode = X_GLXDestroyGLXPixmap; - req->glxpixmap = glxpixmap; - UnlockDisplay(dpy); - SyncHandle(); - - DestroyGLXDrawable(dpy, glxpixmap); - -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - { - struct glx_display *const priv = __glXInitialize(dpy); - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap); - - if (priv != NULL && pdraw != NULL) { - pdraw->destroyDrawable(pdraw); - __glxHashDelete(priv->drawHash, glxpixmap); - } - } -#endif + DestroyDrawable(dpy, glxpixmap, X_GLXDestroyGLXPixmap); #endif /* GLX_USE_APPLEGL */ }