From a7084487250937bfe5386e5facb1a1eaff1c6865 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 7 May 2012 12:48:30 +0200 Subject: [PATCH] winex11: Define an enum to manage the various types of GL device contexts. --- dlls/winex11.drv/init.c | 7 ++++--- dlls/winex11.drv/opengl.c | 40 ++++++++++++++++++++++----------------- dlls/winex11.drv/window.c | 6 ++++-- dlls/winex11.drv/x11drv.h | 14 ++++++++++++-- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 051b293205f..b9de8263c75 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -353,13 +353,14 @@ static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_d physDev->current_pf = pixelformat_from_fbconfig_id( data->fbconfig_id ); physDev->gl_drawable = data->gl_drawable; physDev->pixmap = data->pixmap; - physDev->gl_copy = data->gl_copy; + physDev->gl_type = data->gl_type; wine_tsx11_lock(); XSetSubwindowMode( gdi_display, physDev->gc, data->mode ); wine_tsx11_unlock(); - TRACE( "SET_DRAWABLE hdc %p drawable %lx gl_drawable %lx pf %u dc_rect %s drawable_rect %s\n", + TRACE( "SET_DRAWABLE hdc %p drawable %lx gl_drawable %lx pf %u gl %u dc_rect %s drawable_rect %s\n", dev->hdc, physDev->drawable, physDev->gl_drawable, physDev->current_pf, - wine_dbgstr_rect(&physDev->dc_rect), wine_dbgstr_rect(&physDev->drawable_rect) ); + physDev->gl_type, wine_dbgstr_rect(&physDev->dc_rect), + wine_dbgstr_rect(&physDev->drawable_rect) ); return TRUE; } break; diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 8f850231fd4..7c1251dbefc 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1624,6 +1624,7 @@ static BOOL internal_SetPixelFormat(X11DRV_PDEVICE *physDev, return FALSE; } physDev->current_pf = iPixelFormat; + physDev->gl_type = DC_GL_BITMAP; } else { FIXME("called on a non-window, non-bitmap object?\n"); @@ -1839,7 +1840,6 @@ BOOL X11DRV_wglMakeCurrent(PHYSDEV dev, HGLRC hglrc) X11DRV_PDEVICE *physDev = get_x11drv_dev( dev ); BOOL ret; HDC hdc = dev->hdc; - DWORD type = GetObjectType(hdc); Wine_GLContext *ctx = (Wine_GLContext *) hglrc; TRACE("(%p,%p)\n", hdc, hglrc); @@ -1894,7 +1894,7 @@ BOOL X11DRV_wglMakeCurrent(PHYSDEV dev, HGLRC hglrc) ctx->drawables[1] = physDev->gl_drawable; ctx->refresh_drawables = FALSE; - if (type == OBJ_MEMDC) pglDrawBuffer(GL_FRONT_LEFT); + if (physDev->gl_type == DC_GL_BITMAP) pglDrawBuffer(GL_FRONT_LEFT); } else SetLastError(ERROR_INVALID_HANDLE); @@ -2200,19 +2200,19 @@ static void WINAPI X11DRV_wglGetIntegerv(GLenum pname, GLint* params) void flush_gl_drawable(X11DRV_PDEVICE *physDev) { - int w, h; RECT rect; + int w = physDev->dc_rect.right - physDev->dc_rect.left; + int h = physDev->dc_rect.bottom - physDev->dc_rect.top; + Drawable src = physDev->gl_drawable; - if (!physDev->gl_copy || !physDev->gl_drawable) - return; - - w = physDev->dc_rect.right - physDev->dc_rect.left; - h = physDev->dc_rect.bottom - physDev->dc_rect.top; - - if(w > 0 && h > 0) { - Drawable src = physDev->pixmap; - if(!src) src = physDev->gl_drawable; + if (w <= 0 || h <= 0) return; + switch (physDev->gl_type) + { + case DC_GL_PIXMAP_WIN: + src = physDev->pixmap; + /* fall through */ + case DC_GL_CHILD_WIN: /* The GL drawable may be lagged behind if we don't flush first, so * flush the display make sure we copy up-to-date data */ wine_tsx11_lock(); @@ -2223,6 +2223,8 @@ void flush_gl_drawable(X11DRV_PDEVICE *physDev) wine_tsx11_unlock(); SetRect( &rect, 0, 0, w, h ); add_device_bounds( physDev, &rect ); + default: + break; } } @@ -2622,6 +2624,7 @@ HDC X11DRV_wglGetPbufferDCARB(PHYSDEV dev, HPBUFFERARB hPbuffer) physDev->current_pf = object->fmt->iPixelFormat; physDev->drawable = object->drawable; physDev->gl_drawable = object->drawable; + physDev->gl_type = DC_GL_PBUFFER; SetRect( &physDev->drawable_rect, 0, 0, object->width, object->height ); physDev->dc_rect = physDev->drawable_rect; @@ -3756,7 +3759,9 @@ BOOL X11DRV_SwapBuffers(PHYSDEV dev) wine_tsx11_lock(); sync_context(ctx); - if(physDev->pixmap) { + switch (physDev->gl_type) + { + case DC_GL_PIXMAP_WIN: if(pglXCopySubBufferMESA) { int w = physDev->dc_rect.right - physDev->dc_rect.left; int h = physDev->dc_rect.bottom - physDev->dc_rect.top; @@ -3767,12 +3772,13 @@ BOOL X11DRV_SwapBuffers(PHYSDEV dev) pglFlush(); if(w > 0 && h > 0) pglXCopySubBufferMESA(gdi_display, physDev->gl_drawable, 0, 0, w, h); + break; } - else - pglXSwapBuffers(gdi_display, physDev->gl_drawable); - } - else + /* fall through */ + default: pglXSwapBuffers(gdi_display, physDev->gl_drawable); + break; + } flush_gl_drawable(physDev); wine_tsx11_unlock(); diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 30593a99e23..193a1656c34 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2267,7 +2267,7 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, escape.fbconfig_id = 0; escape.gl_drawable = 0; escape.pixmap = 0; - escape.gl_copy = FALSE; + escape.gl_type = DC_GL_NONE; escape.dc_rect.left = win_rect->left - top_rect->left; escape.dc_rect.top = win_rect->top - top_rect->top; @@ -2289,6 +2289,7 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, else escape.drawable = escape.gl_drawable; + if (escape.gl_drawable) escape.gl_type = DC_GL_WINDOW; /* special case: when repainting the root window, clip out top-level windows */ if (data && data->whole_window == root_window) escape.mode = ClipByChildren; } @@ -2310,7 +2311,7 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, escape.fbconfig_id = data ? data->fbconfig_id : (XID)GetPropA( hwnd, fbconfig_id_prop ); escape.gl_drawable = data ? data->gl_drawable : (Drawable)GetPropA( hwnd, gl_drawable_prop ); escape.pixmap = data ? data->pixmap : (Pixmap)GetPropA( hwnd, pixmap_prop ); - escape.gl_copy = (escape.gl_drawable != 0); + if (escape.gl_drawable) escape.gl_type = escape.pixmap ? DC_GL_PIXMAP_WIN : DC_GL_CHILD_WIN; if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren; } @@ -2335,6 +2336,7 @@ void CDECL X11DRV_ReleaseDC( HWND hwnd, HDC hdc ) escape.fbconfig_id = 0; escape.gl_drawable = 0; escape.pixmap = 0; + escape.gl_type = DC_GL_NONE; ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 58ecf599c09..6496d0f5b4a 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -115,6 +115,16 @@ typedef struct BOOL trueColor; } X_PHYSBITMAP; +enum dc_gl_type +{ + DC_GL_NONE, /* no GL support (pixel format not set yet) */ + DC_GL_WINDOW, /* normal top-level window */ + DC_GL_CHILD_WIN, /* child window using XComposite */ + DC_GL_PIXMAP_WIN, /* child window using intermediate pixmap */ + DC_GL_BITMAP, /* memory DC with a standard bitmap */ + DC_GL_PBUFFER /* pseudo memory DC using a PBuffer */ +}; + /* X physical device */ typedef struct { @@ -134,7 +144,7 @@ typedef struct int current_pf; Drawable gl_drawable; Pixmap pixmap; /* Pixmap for a GLXPixmap gl_drawable */ - int gl_copy; + enum dc_gl_type gl_type; /* type of GL device context */ } X11DRV_PDEVICE; static inline X11DRV_PDEVICE *get_x11drv_dev( PHYSDEV dev ) @@ -345,7 +355,7 @@ struct x11drv_escape_set_drawable XID fbconfig_id; /* fbconfig id used by the GL drawable */ Drawable gl_drawable; /* GL drawable */ Pixmap pixmap; /* Pixmap for a GLXPixmap gl_drawable */ - int gl_copy; /* whether the GL contents need explicit copying */ + enum dc_gl_type gl_type; /* type of GL device context */ }; /**************************************************************************