winex11: Store the visual info in the OpenGL pixel format.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-02-09 09:42:53 +01:00
parent 7625a1bb72
commit 9efcd61d01
1 changed files with 19 additions and 27 deletions

View File

@ -201,6 +201,7 @@ struct WineGLInfo {
struct wgl_pixel_format struct wgl_pixel_format
{ {
GLXFBConfig fbconfig; GLXFBConfig fbconfig;
XVisualInfo *visual;
int fmt_id; int fmt_id;
int render_type; int render_type;
DWORD dwFlags; /* We store some PFD_* flags in here for emulated bitmap formats */ DWORD dwFlags; /* We store some PFD_* flags in here for emulated bitmap formats */
@ -212,7 +213,6 @@ struct wgl_context
BOOL has_been_current; BOOL has_been_current;
BOOL sharing; BOOL sharing;
BOOL gl3_context; BOOL gl3_context;
XVisualInfo *vis;
const struct wgl_pixel_format *fmt; const struct wgl_pixel_format *fmt;
int numAttribs; /* This is needed for delaying wglCreateContextAttribsARB */ int numAttribs; /* This is needed for delaying wglCreateContextAttribsARB */
int attribList[16]; /* This is needed for delaying wglCreateContextAttribsARB */ int attribList[16]; /* This is needed for delaying wglCreateContextAttribsARB */
@ -259,7 +259,6 @@ struct gl_drawable
Pixmap pixmap; /* base pixmap if drawable is a GLXPixmap */ Pixmap pixmap; /* base pixmap if drawable is a GLXPixmap */
Colormap colormap; /* colormap used for the drawable */ Colormap colormap; /* colormap used for the drawable */
const struct wgl_pixel_format *format; /* pixel format for the drawable */ const struct wgl_pixel_format *format; /* pixel format for the drawable */
XVisualInfo *visual; /* information about the GL visual */
RECT rect; /* drawable rect, relative to whole window drawable */ RECT rect; /* drawable rect, relative to whole window drawable */
int swap_interval; int swap_interval;
BOOL refresh_swap_interval; BOOL refresh_swap_interval;
@ -1129,6 +1128,7 @@ static void init_pixel_formats( Display *display )
TRACE("Found onscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, size+1, i); TRACE("Found onscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, size+1, i);
list[size].fbconfig = cfgs[i]; list[size].fbconfig = cfgs[i];
list[size].visual = visinfo;
list[size].fmt_id = fmt_id; list[size].fmt_id = fmt_id;
list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
list[size].dwFlags = 0; list[size].dwFlags = 0;
@ -1140,6 +1140,7 @@ static void init_pixel_formats( Display *display )
{ {
TRACE("Found bitmap capable format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, size+1, i); TRACE("Found bitmap capable format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, size+1, i);
list[size].fbconfig = cfgs[i]; list[size].fbconfig = cfgs[i];
list[size].visual = visinfo;
list[size].fmt_id = fmt_id; list[size].fmt_id = fmt_id;
list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
list[size].dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_GENERIC_FORMAT; list[size].dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_GENERIC_FORMAT;
@ -1169,8 +1170,7 @@ static void init_pixel_formats( Display *display )
list[size].dwFlags = 0; list[size].dwFlags = 0;
size++; size++;
} }
else if (visinfo) XFree(visinfo);
if (visinfo) XFree(visinfo);
} }
} }
@ -1310,8 +1310,8 @@ static GLXContext create_glxcontext(Display *display, struct wgl_context *contex
else else
ctx = pglXCreateContextAttribsARB(gdi_display, context->fmt->fbconfig, shareList, GL_TRUE, NULL); ctx = pglXCreateContextAttribsARB(gdi_display, context->fmt->fbconfig, shareList, GL_TRUE, NULL);
} }
else if(context->vis) else if(context->fmt->visual)
ctx = pglXCreateContext(gdi_display, context->vis, shareList, GL_TRUE); ctx = pglXCreateContext(gdi_display, context->fmt->visual, shareList, GL_TRUE);
else /* Create a GLX Context for a pbuffer */ else /* Create a GLX Context for a pbuffer */
ctx = pglXCreateNewContext(gdi_display, context->fmt->fbconfig, context->fmt->render_type, shareList, TRUE); ctx = pglXCreateNewContext(gdi_display, context->fmt->fbconfig, context->fmt->render_type, shareList, TRUE);
@ -1338,7 +1338,6 @@ static void free_gl_drawable( struct gl_drawable *gl )
default: default:
break; break;
} }
if (gl->visual) XFree( gl->visual );
HeapFree( GetProcessHeap(), 0, gl ); HeapFree( GetProcessHeap(), 0, gl );
} }
@ -1348,6 +1347,8 @@ static void free_gl_drawable( struct gl_drawable *gl )
*/ */
static BOOL create_gl_drawable( HWND hwnd, struct gl_drawable *gl ) static BOOL create_gl_drawable( HWND hwnd, struct gl_drawable *gl )
{ {
XVisualInfo *visual = gl->format->visual;
gl->drawable = 0; gl->drawable = 0;
if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow()) /* top-level window */ if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow()) /* top-level window */
@ -1357,7 +1358,7 @@ static BOOL create_gl_drawable( HWND hwnd, struct gl_drawable *gl )
if (data) if (data)
{ {
gl->type = DC_GL_WINDOW; gl->type = DC_GL_WINDOW;
gl->window = create_client_window( data, gl->visual ); gl->window = create_client_window( data, visual );
if (gl->window) if (gl->window)
gl->drawable = pglXCreateWindow( gdi_display, gl->format->fbconfig, gl->window, NULL ); gl->drawable = pglXCreateWindow( gdi_display, gl->format->fbconfig, gl->window, NULL );
release_win_data( data ); release_win_data( data );
@ -1379,10 +1380,10 @@ static BOOL create_gl_drawable( HWND hwnd, struct gl_drawable *gl )
CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib ); CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib );
XMapWindow( gdi_display, dummy_parent ); XMapWindow( gdi_display, dummy_parent );
} }
gl->colormap = XCreateColormap(gdi_display, dummy_parent, gl->visual->visual, gl->colormap = XCreateColormap(gdi_display, dummy_parent, visual->visual,
(gl->visual->class == PseudoColor || (visual->class == PseudoColor ||
gl->visual->class == GrayScale || visual->class == GrayScale ||
gl->visual->class == DirectColor) ? visual->class == DirectColor) ?
AllocAll : AllocNone); AllocAll : AllocNone);
attrib.colormap = gl->colormap; attrib.colormap = gl->colormap;
XInstallColormap(gdi_display, attrib.colormap); XInstallColormap(gdi_display, attrib.colormap);
@ -1390,7 +1391,7 @@ static BOOL create_gl_drawable( HWND hwnd, struct gl_drawable *gl )
gl->type = DC_GL_CHILD_WIN; gl->type = DC_GL_CHILD_WIN;
gl->window = XCreateWindow( gdi_display, dummy_parent, 0, 0, gl->window = XCreateWindow( gdi_display, dummy_parent, 0, 0,
gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top, gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top,
0, gl->visual->depth, InputOutput, gl->visual->visual, 0, visual->depth, InputOutput, visual->visual,
CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib ); CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib );
if (gl->window) if (gl->window)
{ {
@ -1411,7 +1412,7 @@ static BOOL create_gl_drawable( HWND hwnd, struct gl_drawable *gl )
gl->type = DC_GL_PIXMAP_WIN; gl->type = DC_GL_PIXMAP_WIN;
gl->pixmap = XCreatePixmap( gdi_display, root_window, gl->pixmap = XCreatePixmap( gdi_display, root_window,
gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top, gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top,
gl->visual->depth ); visual->depth );
if (gl->pixmap) if (gl->pixmap)
{ {
gl->drawable = pglXCreatePixmap( gdi_display, gl->format->fbconfig, gl->pixmap, NULL ); gl->drawable = pglXCreatePixmap( gdi_display, gl->format->fbconfig, gl->pixmap, NULL );
@ -1432,6 +1433,8 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format )
{ {
struct gl_drawable *gl, *prev; struct gl_drawable *gl, *prev;
if (!format->visual) return FALSE;
gl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*gl) ); gl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*gl) );
/* Default GLX and WGL swap interval is 1, but in case of glXSwapIntervalSGI /* Default GLX and WGL swap interval is 1, but in case of glXSwapIntervalSGI
* there is no way to query it, so we have to store it here. * there is no way to query it, so we have to store it here.
@ -1439,20 +1442,12 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format )
gl->swap_interval = 1; gl->swap_interval = 1;
gl->refresh_swap_interval = TRUE; gl->refresh_swap_interval = TRUE;
gl->format = format; gl->format = format;
gl->visual = pglXGetVisualFromFBConfig( gdi_display, format->fbconfig );
if (!gl->visual)
{
HeapFree( GetProcessHeap(), 0, gl );
return FALSE;
}
GetClientRect( hwnd, &gl->rect ); GetClientRect( hwnd, &gl->rect );
gl->rect.right = min( max( 1, gl->rect.right ), 65535 ); gl->rect.right = min( max( 1, gl->rect.right ), 65535 );
gl->rect.bottom = min( max( 1, gl->rect.bottom ), 65535 ); gl->rect.bottom = min( max( 1, gl->rect.bottom ), 65535 );
if (!create_gl_drawable( hwnd, gl )) if (!create_gl_drawable( hwnd, gl ))
{ {
XFree( gl->visual );
HeapFree( GetProcessHeap(), 0, gl ); HeapFree( GetProcessHeap(), 0, gl );
return FALSE; return FALSE;
} }
@ -1547,7 +1542,8 @@ void sync_gl_drawable( HWND hwnd, const RECT *visible_rect, const RECT *client_r
break; break;
case DC_GL_PIXMAP_WIN: case DC_GL_PIXMAP_WIN:
if (!mask) break; if (!mask) break;
pix = XCreatePixmap(gdi_display, root_window, changes.width, changes.height, gl->visual->depth); pix = XCreatePixmap(gdi_display, root_window, changes.width, changes.height,
gl->format->visual->depth);
if (!pix) goto done; if (!pix) goto done;
glxp = pglXCreatePixmap(gdi_display, gl->format->fbconfig, pix, NULL ); glxp = pglXCreatePixmap(gdi_display, gl->format->fbconfig, pix, NULL );
if (!glxp) if (!glxp)
@ -1610,7 +1606,6 @@ void set_gl_drawable_parent( HWND hwnd, HWND parent )
{ {
XDeleteContext( gdi_display, (XID)hwnd, gl_hwnd_context ); XDeleteContext( gdi_display, (XID)hwnd, gl_hwnd_context );
release_gl_drawable( gl ); release_gl_drawable( gl );
XFree( gl->visual );
HeapFree( GetProcessHeap(), 0, gl ); HeapFree( GetProcessHeap(), 0, gl );
__wine_set_pixel_format( hwnd, 0 ); __wine_set_pixel_format( hwnd, 0 );
return; return;
@ -1833,7 +1828,6 @@ static struct wgl_context *glxdrv_wglCreateContext( HDC hdc )
{ {
ret->hdc = hdc; ret->hdc = hdc;
ret->fmt = gl->format; ret->fmt = gl->format;
ret->vis = pglXGetVisualFromFBConfig(gdi_display, gl->format->fbconfig);
ret->ctx = create_glxcontext(gdi_display, ret, NULL); ret->ctx = create_glxcontext(gdi_display, ret, NULL);
list_add_head( &context_list, &ret->entry ); list_add_head( &context_list, &ret->entry );
} }
@ -1863,7 +1857,6 @@ static BOOL glxdrv_wglDeleteContext(struct wgl_context *ctx)
LeaveCriticalSection( &context_section ); LeaveCriticalSection( &context_section );
if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx ); if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx );
if (ctx->vis) XFree( ctx->vis );
return HeapFree( GetProcessHeap(), 0, ctx ); return HeapFree( GetProcessHeap(), 0, ctx );
} }
@ -2092,7 +2085,6 @@ static struct wgl_context *X11DRV_wglCreateContextAttribsARB( HDC hdc, struct wg
{ {
ret->hdc = hdc; ret->hdc = hdc;
ret->fmt = gl->format; ret->fmt = gl->format;
ret->vis = NULL; /* glXCreateContextAttribsARB requires a fbconfig instead of a visual */
ret->gl3_context = TRUE; ret->gl3_context = TRUE;
if (attribList) if (attribList)
{ {