Commit 2e1d5af7 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

opengl32: Use glReserved1[0] and glReserved1[1] for draw and read DCs.

parent 8c178113
......@@ -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 */
......@@ -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;
}
......
......@@ -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];
}
/***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment