opengl32: Store the context current DCs on the opengl32 side.

This commit is contained in:
Alexandre Julliard 2012-07-25 14:28:47 +02:00
parent 2077a58c21
commit 5f157e18e2
5 changed files with 15 additions and 41 deletions

View File

@ -622,7 +622,6 @@ my %wgl_functions =
[ "UINT", "mask" ] ] ],
"wglCreateContext" => [ "struct wgl_context *", [ [ "HDC", "hdc" ] ] ],
"wglDeleteContext" => [ "void", [ [ "struct wgl_context *", "context" ] ] ],
"wglGetCurrentDC" => [ "HDC", [ [ "struct wgl_context *", "context" ] ] ],
"wglGetPixelFormat" => [ "INT", [ [ "HDC", "hdc" ] ] ],
"wglGetProcAddress" => [ "PROC", [ [ "LPCSTR", "name" ] ] ],
"wglMakeCurrent" => [ "BOOL", [ [ "HDC", "hdc" ],

View File

@ -3027,7 +3027,6 @@ void WINAPI wine_glViewport( GLint x, GLint y, GLsizei width, GLsizei height ) {
static BOOL null_wglCopyContext( struct wgl_context * src, struct wgl_context * dst, UINT mask ) { return 0; }
static struct wgl_context * null_wglCreateContext( HDC hdc ) { return 0; }
static void null_wglDeleteContext( struct wgl_context * context ) { }
static HDC null_wglGetCurrentDC( struct wgl_context * context ) { return 0; }
static INT null_wglGetPixelFormat( HDC hdc ) { return 0; }
static PROC null_wglGetProcAddress( LPCSTR name ) { return 0; }
static BOOL null_wglMakeCurrent( HDC hdc, struct wgl_context * context ) { return 0; }
@ -3375,7 +3374,6 @@ struct opengl_funcs null_opengl_funcs =
null_wglCopyContext,
null_wglCreateContext,
null_wglDeleteContext,
null_wglGetCurrentDC,
null_wglGetPixelFormat,
null_wglGetProcAddress,
null_wglMakeCurrent,

View File

@ -68,6 +68,8 @@ enum wgl_handle_type
struct opengl_context
{
DWORD tid; /* thread that the context is current in */
HDC draw_dc; /* current drawing DC */
HDC read_dc; /* current reading DC */
struct wgl_context *drv_ctx; /* driver context */
};
@ -236,6 +238,8 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
{
if (prev) prev->u.context->tid = 0;
ptr->u.context->tid = GetCurrentThreadId();
ptr->u.context->draw_dc = hdc;
ptr->u.context->read_dc = hdc;
NtCurrentTeb()->glCurrentRC = hglrc;
NtCurrentTeb()->glTable = ptr->funcs;
}
@ -315,6 +319,8 @@ BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc )
{
if (prev) prev->u.context->tid = 0;
ptr->u.context->tid = GetCurrentThreadId();
ptr->u.context->draw_dc = draw_hdc;
ptr->u.context->read_dc = read_hdc;
NtCurrentTeb()->glCurrentRC = hglrc;
NtCurrentTeb()->glTable = ptr->funcs;
}
@ -343,10 +349,10 @@ BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc )
*/
HDC WINAPI wglGetCurrentReadDCARB(void)
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_current_context_ptr();
if (!funcs->ext.p_wglGetCurrentReadDCARB) return 0;
return funcs->ext.p_wglGetCurrentReadDCARB();
if (!ptr) return 0;
return ptr->u.context->read_dc;
}
/***********************************************************************
@ -373,9 +379,10 @@ BOOL WINAPI wglShareLists(HGLRC hglrcSrc, HGLRC hglrcDst)
*/
HDC WINAPI wglGetCurrentDC(void)
{
struct wgl_handle *context = get_current_context_ptr();
if (!context) return 0;
return context->funcs->wgl.p_wglGetCurrentDC( context->u.context->drv_ctx );
struct wgl_handle *ptr = get_current_context_ptr();
if (!ptr) return 0;
return ptr->u.context->draw_dc;
}
/***********************************************************************

View File

@ -151,7 +151,6 @@ struct wgl_context
int numAttribs; /* This is needed for delaying wglCreateContextAttribsARB */
int attribList[16]; /* This is needed for delaying wglCreateContextAttribsARB */
GLXContext ctx;
HDC read_hdc;
Drawable drawables[2];
BOOL refresh_drawables;
Pixmap pixmap; /* pixmap for memory DCs */
@ -1497,22 +1496,6 @@ static void glxdrv_wglDeleteContext(struct wgl_context *ctx)
HeapFree( GetProcessHeap(), 0, ctx );
}
/**
* X11DRV_wglGetCurrentReadDCARB
*
* For OpenGL32 wglGetCurrentReadDCARB.
*/
static HDC X11DRV_wglGetCurrentReadDCARB(void)
{
HDC ret = 0;
struct wgl_context *ctx = NtCurrentTeb()->glContext;
if (ctx) ret = ctx->read_hdc;
TRACE(" returning %p (GL drawable %lu)\n", ret, ctx ? ctx->drawables[1] : 0);
return ret;
}
/***********************************************************************
* glxdrv_wglGetProcAddress
*/
@ -1600,7 +1583,6 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
ctx->has_been_current = TRUE;
ctx->hdc = hdc;
ctx->read_hdc = hdc;
ctx->drawables[0] = escape.gl_drawable;
ctx->drawables[1] = escape.gl_drawable;
ctx->refresh_drawables = FALSE;
@ -1663,7 +1645,6 @@ static BOOL X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct
{
ctx->has_been_current = TRUE;
ctx->hdc = draw_hdc;
ctx->read_hdc = read_hdc;
ctx->drawables[0] = escape_draw.gl_drawable;
ctx->drawables[1] = escape_read.gl_drawable;
ctx->refresh_drawables = FALSE;
@ -1731,15 +1712,6 @@ static BOOL glxdrv_wglShareLists(struct wgl_context *org, struct wgl_context *de
return FALSE;
}
/***********************************************************************
* glxdrv_wglGetCurrentDC
*/
static HDC glxdrv_wglGetCurrentDC( struct wgl_context *ctx )
{
TRACE("hdc %p\n", ctx->hdc);
return ctx->hdc;
}
static void flush_pixmap( struct wgl_context *ctx )
{
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
@ -2912,7 +2884,7 @@ static void X11DRV_WineGL_LoadExtensions(void)
if (glxRequireVersion(3))
{
register_extension( "WGL_ARB_make_current_read" );
opengl_funcs.ext.p_wglGetCurrentReadDCARB = X11DRV_wglGetCurrentReadDCARB;
opengl_funcs.ext.p_wglGetCurrentReadDCARB = (void *)1; /* never called */
opengl_funcs.ext.p_wglMakeContextCurrentARB = X11DRV_wglMakeContextCurrentARB;
}
@ -3338,7 +3310,6 @@ static struct opengl_funcs opengl_funcs =
glxdrv_wglCopyContext, /* p_wglCopyContext */
glxdrv_wglCreateContext, /* p_wglCreateContext */
glxdrv_wglDeleteContext, /* p_wglDeleteContext */
glxdrv_wglGetCurrentDC, /* p_wglGetCurrentDC */
glxdrv_wglGetPixelFormat, /* p_wglGetPixelFormat */
glxdrv_wglGetProcAddress, /* p_wglGetProcAddress */
glxdrv_wglMakeCurrent, /* p_wglMakeCurrent */

View File

@ -7,7 +7,7 @@
#define WINE_GLAPI
#endif
#define WINE_WGL_DRIVER_VERSION 4
#define WINE_WGL_DRIVER_VERSION 5
struct wgl_context;
struct wgl_pbuffer;
@ -19,7 +19,6 @@ struct opengl_funcs
BOOL (WINE_GLAPI *p_wglCopyContext)(struct wgl_context *,struct wgl_context *,UINT);
struct wgl_context * (WINE_GLAPI *p_wglCreateContext)(HDC);
void (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *);
HDC (WINE_GLAPI *p_wglGetCurrentDC)(struct wgl_context *);
INT (WINE_GLAPI *p_wglGetPixelFormat)(HDC);
PROC (WINE_GLAPI *p_wglGetProcAddress)(LPCSTR);
BOOL (WINE_GLAPI *p_wglMakeCurrent)(HDC,struct wgl_context *);