summaryrefslogtreecommitdiffstats
path: root/src/glx
diff options
context:
space:
mode:
authorAdam Jackson <[email protected]>2019-09-26 15:43:46 -0400
committerAdam Jackson <[email protected]>2019-09-27 11:18:15 -0400
commit90d58286cc76c9f6652a8f8342fe568d2fc0bb15 (patch)
tree516f8a441f2a41c847936a1d81a357a0de697541 /src/glx
parent3c0eb762e27f9028a8f59e2fa31603292e02d9ef (diff)
drisw: Fix and simplify drawable setup
We don't want to require a visual for the drawable, because there exist fbconfigs that don't correspond to any visual (say a 565 pixmap|pbuffer config on a depth-24 display). Fortunately, we don't need one either. Passing the visual to XCreateImage serves only to fill in the XImage's {red,green,blue}_mask fields, which libX11 itself never uses, they exist only for the client's convenience, and we don't care. And we already have the drawable depth in glx_config::rgbBits. So replace the XVisualInfo field in the drawable private with a pointer to the glx_config. Having done that driswCreateGCs becomes trivial, so inline it into its caller. Gitlab: https://gitlab.freedesktop.org/mesa/mesa/issues/1194 Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/drisw_glx.c40
-rw-r--r--src/glx/drisw_priv.h3
2 files changed, 7 insertions, 36 deletions
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index b3e00f9a4e0..45a61e654c7 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -31,27 +31,6 @@
#include <X11/extensions/shmproto.h>
#include <assert.h>
-static Bool
-driswCreateGCs(struct drisw_drawable * pdp,
- Display * dpy, XID drawable, int visualid)
-{
- long visMask;
- XVisualInfo visTemp;
- int num_visuals;
-
- pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
-
- /* visual */
- visTemp.visualid = visualid;
- visMask = VisualIDMask;
- pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
-
- if (!pdp->visinfo || num_visuals == 0)
- return False;
-
- return True;
-}
-
static int xshm_error = 0;
static int xshm_opcode = -1;
@@ -82,8 +61,8 @@ XCreateDrawable(struct drisw_drawable * pdp, int shmid, Display * dpy)
if (!xshm_error && shmid >= 0) {
pdp->shminfo.shmid = shmid;
pdp->ximage = XShmCreateImage(dpy,
- pdp->visinfo->visual,
- pdp->visinfo->depth,
+ NULL,
+ pdp->config->rgbBits,
ZPixmap, /* format */
NULL, /* data */
&pdp->shminfo, /* shminfo */
@@ -112,8 +91,8 @@ XCreateDrawable(struct drisw_drawable * pdp, int shmid, Display * dpy)
if (pdp->ximage == NULL) {
pdp->shminfo.shmid = -1;
pdp->ximage = XCreateImage(dpy,
- pdp->visinfo->visual,
- pdp->visinfo->depth,
+ NULL,
+ pdp->config->rgbBits,
ZPixmap, 0, /* format, offset */
NULL, /* data */
0, 0, /* width, height */
@@ -140,8 +119,6 @@ XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable)
if (pdp->shminfo.shmid > 0)
XShmDetach(dpy, &pdp->shminfo);
- free(pdp->visinfo);
-
XFreeGC(dpy, pdp->gc);
}
@@ -667,7 +644,6 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
struct drisw_screen *psc = (struct drisw_screen *) base;
- Bool ret;
const __DRIswrastExtension *swrast = psc->swrast;
pdp = calloc(1, sizeof(*pdp));
@@ -677,12 +653,8 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
pdp->base.xDrawable = xDrawable;
pdp->base.drawable = drawable;
pdp->base.psc = &psc->base;
-
- ret = driswCreateGCs(pdp, psc->base.dpy, xDrawable, modes->visualID);
- if (!ret) {
- free(pdp);
- return NULL;
- }
+ pdp->config = modes;
+ pdp->gc = XCreateGC(psc->base.dpy, xDrawable, 0, NULL);
/* Create a new drawable */
pdp->driDrawable =
diff --git a/src/glx/drisw_priv.h b/src/glx/drisw_priv.h
index 816d1d87cc9..bfcf5946c57 100644
--- a/src/glx/drisw_priv.h
+++ b/src/glx/drisw_priv.h
@@ -62,9 +62,8 @@ struct drisw_drawable
__GLXDRIdrawable base;
GC gc;
-
__DRIdrawable *driDrawable;
- XVisualInfo *visinfo;
+ struct glx_config *config;
XImage *ximage;
XShmSegmentInfo shminfo;
};