Module: wine Branch: master Commit: 2e1d5af7023e13f6e3599c6267c23f25bebe6a95 URL: https://gitlab.winehq.org/wine/wine/-/commit/2e1d5af7023e13f6e3599c6267c23f2...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Oct 6 11:51:30 2022 +0200
opengl32: Use glReserved1[0] and glReserved1[1] for draw and read DCs.
---
dlls/opengl32/opengl_ext.h | 45 ------------------------------------- dlls/opengl32/unix_wgl.c | 56 +++++++++++++++++++++++++++++++++++++++------- dlls/opengl32/wgl.c | 12 ++++------ 3 files changed, 52 insertions(+), 61 deletions(-)
diff --git a/dlls/opengl32/opengl_ext.h b/dlls/opengl32/opengl_ext.h index c668e92fd9b..9cffc5a06f7 100644 --- a/dlls/opengl32/opengl_ext.h +++ b/dlls/opengl32/opengl_ext.h @@ -49,51 +49,6 @@ static inline struct opengl_funcs *get_dc_funcs( HDC hdc ) return funcs; }
-#define MAX_WGL_HANDLES 1024 - -/* handle management */ - -enum wgl_handle_type -{ - HANDLE_PBUFFER = 0 << 12, - HANDLE_CONTEXT = 1 << 12, - HANDLE_CONTEXT_V3 = 3 << 12, - HANDLE_TYPE_MASK = 15 << 12 -}; - -struct opengl_context -{ - DWORD tid; /* thread that the context is current in */ - HDC draw_dc; /* current drawing DC */ - HDC read_dc; /* current reading DC */ - void (CALLBACK *debug_callback)( GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void * ); /* debug callback */ - const void *debug_user; /* debug user parameter */ - GLubyte *extensions; /* extension string */ - GLuint *disabled_exts; /* indices of disabled extensions */ - struct wgl_context *drv_ctx; /* driver context */ -}; - -struct wgl_handle -{ - UINT handle; - struct opengl_funcs *funcs; - union - { - struct opengl_context *context; /* for HANDLE_CONTEXT */ - struct wgl_pbuffer *pbuffer; /* for HANDLE_PBUFFER */ - struct wgl_handle *next; /* for free handles */ - } u; -}; - -extern struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; - -/* the current context is assumed valid and doesn't need locking */ -static inline struct wgl_handle *get_current_context_ptr(void) -{ - if (!NtCurrentTeb()->glCurrentRC) return NULL; - return &wgl_handles[LOWORD(NtCurrentTeb()->glCurrentRC) & ~HANDLE_TYPE_MASK]; -} - extern int WINAPI wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR *ppfd );
#endif /* __DLLS_OPENGL32_OPENGL_EXT_H */ diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 159753276bc..8f3fa70556e 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -38,10 +38,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
-struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; -static struct wgl_handle *next_free; -static unsigned int handle_count; - static CRITICAL_SECTION wgl_section; static CRITICAL_SECTION_DEBUG critsect_debug = { @@ -51,6 +47,50 @@ static CRITICAL_SECTION_DEBUG critsect_debug = }; static CRITICAL_SECTION wgl_section = { &critsect_debug, -1, 0, 0, 0, 0 };
+/* handle management */ + +enum wgl_handle_type +{ + HANDLE_PBUFFER = 0 << 12, + HANDLE_CONTEXT = 1 << 12, + HANDLE_CONTEXT_V3 = 3 << 12, + HANDLE_TYPE_MASK = 15 << 12 +}; + +struct opengl_context +{ + DWORD tid; /* thread that the context is current in */ + void (CALLBACK *debug_callback)( GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void * ); /* debug callback */ + const void *debug_user; /* debug user parameter */ + GLubyte *extensions; /* extension string */ + GLuint *disabled_exts; /* indices of disabled extensions */ + struct wgl_context *drv_ctx; /* driver context */ +}; + +struct wgl_handle +{ + UINT handle; + struct opengl_funcs *funcs; + union + { + struct opengl_context *context; /* for HANDLE_CONTEXT */ + struct wgl_pbuffer *pbuffer; /* for HANDLE_PBUFFER */ + struct wgl_handle *next; /* for free handles */ + } u; +}; + +#define MAX_WGL_HANDLES 1024 +static struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; +static struct wgl_handle *next_free; +static unsigned int handle_count; + +/* the current context is assumed valid and doesn't need locking */ +static inline struct wgl_handle *get_current_context_ptr(void) +{ + if (!NtCurrentTeb()->glCurrentRC) return NULL; + return &wgl_handles[LOWORD(NtCurrentTeb()->glCurrentRC) & ~HANDLE_TYPE_MASK]; +} + static inline HANDLE next_handle( struct wgl_handle *ptr, enum wgl_handle_type type ) { WORD generation = HIWORD( ptr->handle ) + 1; @@ -498,8 +538,8 @@ static BOOL wrap_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()->glReserved1[0] = hdc; + NtCurrentTeb()->glReserved1[1] = hdc; NtCurrentTeb()->glCurrentRC = hglrc; NtCurrentTeb()->glTable = ptr->funcs; } @@ -672,8 +712,8 @@ static BOOL wrap_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hgl { 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()->glReserved1[0] = draw_hdc; + NtCurrentTeb()->glReserved1[1] = read_hdc; NtCurrentTeb()->glCurrentRC = hglrc; NtCurrentTeb()->glTable = ptr->funcs; } diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 1492f9b20b1..8a648318a42 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -50,10 +50,8 @@ static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} }; */ HDC WINAPI wglGetCurrentReadDCARB(void) { - struct wgl_handle *ptr = get_current_context_ptr(); - - if (!ptr) return 0; - return ptr->u.context->read_dc; + if (!NtCurrentTeb()->glCurrentRC) return 0; + return NtCurrentTeb()->glReserved1[1]; }
/*********************************************************************** @@ -61,10 +59,8 @@ HDC WINAPI wglGetCurrentReadDCARB(void) */ HDC WINAPI wglGetCurrentDC(void) { - struct wgl_handle *ptr = get_current_context_ptr(); - - if (!ptr) return 0; - return ptr->u.context->draw_dc; + if (!NtCurrentTeb()->glCurrentRC) return 0; + return NtCurrentTeb()->glReserved1[0]; }
/***********************************************************************