winex11: Define an enum to manage the various types of GL device contexts.

This commit is contained in:
Alexandre Julliard 2012-05-07 12:48:30 +02:00
parent 1b76949d69
commit a708448725
4 changed files with 43 additions and 24 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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 );
}

View File

@ -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 */
};
/**************************************************************************