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

Alexandre Julliard julliard at winehq.org
Wed Jul 25 16:06:53 CDT 2012


Module: wine
Branch: master
Commit: 5f157e18e2267f29a2051bca602640bd42c9070d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5f157e18e2267f29a2051bca602640bd42c9070d

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jul 25 14:28:47 2012 +0200

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

---

 dlls/opengl32/make_opengl   |    1 -
 dlls/opengl32/opengl_norm.c |    2 --
 dlls/opengl32/wgl.c         |   19 +++++++++++++------
 dlls/winex11.drv/opengl.c   |   31 +------------------------------
 include/wine/wgl_driver.h   |    3 +--
 5 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl
index fd5a264..cf6d4e1 100755
--- a/dlls/opengl32/make_opengl
+++ b/dlls/opengl32/make_opengl
@@ -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" ],
diff --git a/dlls/opengl32/opengl_norm.c b/dlls/opengl32/opengl_norm.c
index 41898a9..2f5dab7 100644
--- a/dlls/opengl32/opengl_norm.c
+++ b/dlls/opengl32/opengl_norm.c
@@ -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,
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 3dc2b18..84b37c8 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -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;
 }
 
 /***********************************************************************
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 22c608e..4f906e2 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -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 */
diff --git a/include/wine/wgl_driver.h b/include/wine/wgl_driver.h
index 79fc321..209c361 100644
--- a/include/wine/wgl_driver.h
+++ b/include/wine/wgl_driver.h
@@ -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 *);




More information about the wine-cvs mailing list