Module: wine Branch: master Commit: 11013af0a1a7f9c7d4854c376f8a3b46f955f1e2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=11013af0a1a7f9c7d4854c376f...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Sep 7 15:53:00 2012 +0200
winex11: Get the current pixel format from the drawable structure in wglMakeCurrent.
---
dlls/winex11.drv/opengl.c | 57 +++++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 33 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 97055ae..a6fb974 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1662,8 +1662,9 @@ static PROC glxdrv_wglGetProcAddress(LPCSTR lpszProc) */ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx) { - BOOL ret; - struct x11drv_escape_get_drawable escape; + BOOL ret = FALSE; + HWND hwnd; + struct gl_drawable *gl;
TRACE("(%p,%p)\n", hdc, ctx);
@@ -1674,51 +1675,41 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx) return TRUE; }
- escape.code = X11DRV_GET_DRAWABLE; - if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code, - sizeof(escape), (LPSTR)&escape )) - return FALSE; + hwnd = WindowFromDC( hdc ); + EnterCriticalSection( &context_section );
- if (!escape.pixel_format) - { - WARN("Trying to use an invalid drawable\n"); - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if (ctx->fmt - pixel_formats != escape.pixel_format - 1) - { - WARN( "mismatched pixel format hdc %p %u ctx %p\n", hdc, escape.pixel_format, ctx ); - SetLastError( ERROR_INVALID_PIXEL_FORMAT ); - return FALSE; - } - else + if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&gl ) || + !XFindContext( gdi_display, (XID)hdc, gl_pbuffer_context, (char **)&gl )) { + if (ctx->fmt != gl->format) + { + WARN( "mismatched pixel format hdc %p %p ctx %p %p\n", hdc, gl->format, ctx, ctx->fmt ); + SetLastError( ERROR_INVALID_PIXEL_FORMAT ); + goto done; + } + if (TRACE_ON(wgl)) { - int vis_id; - pglXGetFBConfigAttrib(gdi_display, ctx->fmt->fbconfig, GLX_VISUAL_ID, &vis_id); describeContext(ctx); - TRACE("hdc %p drawable %lx fmt %u vis %x ctx %p\n", hdc, - escape.gl_drawable, escape.pixel_format, vis_id, ctx->ctx); + TRACE("hdc %p drawable %lx fmt %p ctx %p\n", hdc, gl->drawable, gl->format, ctx->ctx ); }
- ret = pglXMakeCurrent(gdi_display, escape.gl_drawable, ctx->ctx); - + ret = pglXMakeCurrent(gdi_display, gl->drawable, ctx->ctx); if (ret) { NtCurrentTeb()->glContext = ctx; - - EnterCriticalSection( &context_section ); ctx->has_been_current = TRUE; ctx->hdc = hdc; - ctx->drawables[0] = escape.gl_drawable; - ctx->drawables[1] = escape.gl_drawable; + ctx->drawables[0] = gl->drawable; + ctx->drawables[1] = gl->drawable; ctx->refresh_drawables = FALSE; - LeaveCriticalSection( &context_section ); + goto done; } - else - SetLastError(ERROR_INVALID_HANDLE); } - TRACE(" returning %s\n", (ret ? "True" : "False")); + SetLastError( ERROR_INVALID_HANDLE ); + +done: + LeaveCriticalSection( &context_section ); + TRACE( "%p,%p returning %d\n", hdc, ctx, ret ); return ret; }