mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
xlib: remove vishandle from XMesaVisual and fix XVisualInfo leak
Remove the unused vishandle pointer and rely solely on visualid-based
matching. This also eliminates the leak.
This mirrors the cleanup previously done in fakeglx.c. (781232e0ac)
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40422>
This commit is contained in:
parent
59ef73d71f
commit
96cbc791d5
2 changed files with 11 additions and 37 deletions
|
|
@ -192,7 +192,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
|
|||
GLboolean ximageFlag = GL_TRUE;
|
||||
XMesaVisual xmvis;
|
||||
GLint i;
|
||||
GLboolean comparePointers;
|
||||
|
||||
if (!rgbFlag)
|
||||
return NULL;
|
||||
|
|
@ -221,13 +220,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
|
|||
if (stencil_size > 0 && depth_size > 0)
|
||||
depth_size = 24;
|
||||
|
||||
/* Comparing IDs uses less memory but sometimes fails. */
|
||||
/* XXX revisit this after 3.0 is finished. */
|
||||
if (os_get_option("MESA_GLX_VISUAL_HACK"))
|
||||
comparePointers = GL_TRUE;
|
||||
else
|
||||
comparePointers = GL_FALSE;
|
||||
|
||||
/* Force the visual to have an alpha channel */
|
||||
if (rgbFlag && os_get_option("MESA_GLX_FORCE_ALPHA"))
|
||||
alphaFlag = GL_TRUE;
|
||||
|
|
@ -247,9 +239,8 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
|
|||
&& (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
|
||||
&& (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
|
||||
&& (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
|
||||
/* now either compare XVisualInfo pointers or visual IDs */
|
||||
if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
|
||||
|| (comparePointers && v->vishandle == vinfo)) {
|
||||
/* now compare visual IDs */
|
||||
if (v->visinfo->visualid == vinfo->visualid) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
|
@ -264,10 +255,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
|
|||
accumBlueSize, accumAlphaSize, num_samples, level,
|
||||
GLX_NONE_EXT );
|
||||
if (xmvis) {
|
||||
/* Save a copy of the pointer now so we can find this visual again
|
||||
* if we need to search for it in find_glx_visual().
|
||||
*/
|
||||
xmvis->vishandle = vinfo;
|
||||
/* Allocate more space for additional visual */
|
||||
VisualTable = realloc(VisualTable, sizeof(XMesaVisual) * (NumVisuals + 1));
|
||||
/* add xmvis to the list */
|
||||
|
|
@ -375,13 +362,6 @@ find_glx_visual( Display *dpy, XVisualInfo *vinfo )
|
|||
}
|
||||
}
|
||||
|
||||
/* if that fails, try to match pointers */
|
||||
for (i=0;i<NumVisuals;i++) {
|
||||
if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
|
||||
return VisualTable[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1083,6 +1063,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
|
|||
accumRedSize, accumGreenSize,
|
||||
accumBlueSize, accumAlphaSize, level, numAux,
|
||||
num_samples );
|
||||
free(vis);
|
||||
}
|
||||
|
||||
return xmvis;
|
||||
|
|
@ -1099,12 +1080,11 @@ glXChooseVisual( Display *dpy, int screen, int *list )
|
|||
|
||||
xmvis = choose_visual(dpy, screen, list, GL_FALSE);
|
||||
if (xmvis) {
|
||||
/* create a new vishandle - the cached one may be stale */
|
||||
xmvis->vishandle = malloc(sizeof(XVisualInfo));
|
||||
if (xmvis->vishandle) {
|
||||
memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
|
||||
XVisualInfo* visinfo = malloc(sizeof(XVisualInfo));
|
||||
if (visinfo) {
|
||||
memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo));
|
||||
}
|
||||
return xmvis->vishandle;
|
||||
return visinfo;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
|
@ -1866,16 +1846,11 @@ glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
|
|||
{
|
||||
if (dpy && config) {
|
||||
XMesaVisual xmvis = (XMesaVisual) config;
|
||||
#if 0
|
||||
return xmvis->vishandle;
|
||||
#else
|
||||
/* create a new vishandle - the cached one may be stale */
|
||||
xmvis->vishandle = malloc(sizeof(XVisualInfo));
|
||||
if (xmvis->vishandle) {
|
||||
memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
|
||||
XVisualInfo* visinfo = malloc(sizeof(XVisualInfo));
|
||||
if (visinfo) {
|
||||
memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo));
|
||||
}
|
||||
return xmvis->vishandle;
|
||||
#endif
|
||||
return visinfo;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -291,7 +291,6 @@ struct xmesa_visual {
|
|||
int screen, visualID, visualType;
|
||||
Display *display; /* The X11 display */
|
||||
XVisualInfo * visinfo; /* X's visual info (pointer to private copy) */
|
||||
XVisualInfo *vishandle; /* Only used in fakeglx.c */
|
||||
GLint BitsPerPixel; /* True bits per pixel for XImages */
|
||||
|
||||
GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue