struct stw_icd
{
struct {
- HGLRC hglrc;
+ struct stw_context *ctx;
} ctx_array[DRV_CONTEXT_MAX];
DHGLRC ctx_current;
assert(!stw_icd);
stw_icd = &stw_icd_storage;
- memset(stw_icd, 0, sizeof(*stw_icd));
+ memset(stw_icd, 0, sizeof *stw_icd);
return TRUE;
}
void
stw_icd_cleanup(void)
{
- DHGLRC dhglrc;
+ int i;
if(!stw_icd)
return;
/* Ensure all contexts are destroyed */
- for (dhglrc = 1; dhglrc <= DRV_CONTEXT_MAX; dhglrc++)
- if (stw_icd->ctx_array[dhglrc - 1].hglrc)
- DrvDeleteContext( dhglrc );
+ for (i = 0; i < DRV_CONTEXT_MAX; i++)
+ if (stw_icd->ctx_array[i].ctx)
+ stw_delete_context( stw_icd->ctx_array[i].ctx );
stw_icd = NULL;
}
-static HGLRC
-lookup_hglrc( DHGLRC dhglrc )
+static struct stw_context *
+lookup_context( DHGLRC dhglrc )
{
if (dhglrc == 0 ||
dhglrc >= DRV_CONTEXT_MAX)
return NULL;
- return stw_icd->ctx_array[dhglrc - 1].hglrc;
+ return stw_icd->ctx_array[dhglrc - 1].ctx;
}
BOOL APIENTRY
DHGLRC dhrcDest,
UINT fuMask )
{
- HGLRC src = lookup_hglrc( dhrcSource );
- HGLRC dst = lookup_hglrc( dhrcDest );
+ struct stw_context *src = lookup_context( dhrcSource );
+ struct stw_context *dst = lookup_context( dhrcDest );
if (src == NULL ||
dst == NULL)
DWORD i;
for (i = 0; i < DRV_CONTEXT_MAX; i++) {
- if (stw_icd->ctx_array[i].hglrc == NULL)
+ if (stw_icd->ctx_array[i].ctx == NULL)
goto found_slot;
}
return 0;
found_slot:
- stw_icd->ctx_array[i].hglrc = stw_create_context( hdc, iLayerPlane );
- if (stw_icd->ctx_array[i].hglrc == NULL)
+ stw_icd->ctx_array[i].ctx = stw_create_context( hdc, iLayerPlane );
+ if (stw_icd->ctx_array[i].ctx == NULL)
return 0;
return (DHGLRC) i + 1;
DrvDeleteContext(
DHGLRC dhglrc )
{
- HGLRC hglrc = lookup_hglrc( dhglrc );
- BOOL success = FALSE;
+ struct stw_context *ctx;
- if (hglrc != NULL) {
- success = stw_delete_context( hglrc );
- if (success)
- stw_icd->ctx_array[dhglrc - 1].hglrc = NULL;
- }
+ ctx = lookup_context( dhglrc );
+ if (ctx == NULL)
+ goto fail;
- debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" );
+ if (stw_delete_context( ctx ) == FALSE)
+ goto fail;
- return success;
+ stw_icd->ctx_array[dhglrc - 1].ctx = NULL;
+ return TRUE;
+
+fail:
+ return FALSE;
}
BOOL APIENTRY
DrvReleaseContext(
DHGLRC dhglrc )
{
- BOOL success = FALSE;
+ struct stw_context *ctx;
- if (dhglrc == stw_icd->ctx_current) {
- HGLRC hglrc = lookup_hglrc( dhglrc );
+ if (dhglrc != stw_icd->ctx_current)
+ goto fail;
- if (hglrc != NULL) {
- success = stw_make_current( NULL, NULL );
- if (success)
- stw_icd->ctx_current = 0;
- }
- }
+ ctx = lookup_context( dhglrc );
+ if (ctx == NULL)
+ goto fail;
+
+ if (stw_make_current( NULL, NULL ) == FALSE)
+ goto fail;
- debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" );
+ stw_icd->ctx_current = 0;
+ return TRUE;
- return success;
+fail:
+ return FALSE;
}
void APIENTRY
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
- HGLRC hglrc = lookup_hglrc( dhglrc );
+ struct stw_context *ctx;
GLDISPATCHTABLE *disp = &cpt.glDispatchTable;
debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable );
- if (hglrc == NULL)
+ ctx = lookup_context( dhglrc );
+ if (ctx == NULL)
return NULL;
- if (!stw_make_current( hdc, hglrc ))
+ if (!stw_make_current( hdc, ctx ))
return NULL;
memset( &cpt, 0, sizeof( cpt ) );
#include "stw_public.h"
#include "stw_context.h"
-static struct wgl_context *ctx_head = NULL;
+static struct stw_context *ctx_head = NULL;
static HDC current_hdc = NULL;
-static HGLRC current_hrc = NULL;
+static struct stw_context *current_hrc = NULL;
BOOL
stw_copy_context(
- HGLRC hglrcSrc,
- HGLRC hglrcDst,
+ struct stw_context *src,
+ struct stw_context *dst,
UINT mask )
{
- (void) hglrcSrc;
- (void) hglrcDst;
+ (void) src;
+ (void) dst;
(void) mask;
return FALSE;
}
-HGLRC
+struct stw_context *
stw_create_context(
HDC hdc,
int iLayerPlane )
{
uint pfi;
const struct pixelformat_info *pf = NULL;
- struct wgl_context *ctx = NULL;
+ struct stw_context *ctx = NULL;
GLvisual *visual = NULL;
struct pipe_context *pipe = NULL;
pf = pixelformat_get_info( pfi - 1 );
- ctx = CALLOC_STRUCT( wgl_context );
+ ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
return NULL;
ctx->next = ctx_head;
ctx_head = ctx;
- return (HGLRC) ctx;
+ return ctx;
fail:
if (visual)
BOOL
stw_delete_context(
- HGLRC hglrc )
+ struct stw_context *hglrc )
{
- struct wgl_context **link = &ctx_head;
- struct wgl_context *ctx = ctx_head;
+ struct stw_context **link = &ctx_head;
+ struct stw_context *ctx = ctx_head;
while (ctx != NULL) {
- if (ctx == (struct wgl_context *) hglrc) {
+ if (ctx == hglrc) {
GLcontext *glctx = ctx->st->ctx;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
}
}
-HGLRC
+struct stw_context *
stw_get_current_context( void )
{
return current_hrc;
BOOL
stw_make_current(
HDC hdc,
- HGLRC hglrc )
+ struct stw_context *hglrc )
{
- struct wgl_context *ctx = ctx_head;
+ struct stw_context *ctx = ctx_head;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
GLuint width = 0;
}
while (ctx != NULL) {
- if (ctx == (struct wgl_context *) hglrc)
+ if (ctx == hglrc)
break;
ctx = ctx->next;
}
/* Return if already current.
*/
if (glcurctx != NULL) {
- struct wgl_context *curctx = (struct wgl_context *) glcurctx->DriverCtx;
+ struct stw_context *curctx = (struct stw_context *) glcurctx->DriverCtx;
if (curctx != NULL && curctx == ctx && ctx->hdc == hdc)
return TRUE;
return TRUE;
}
-struct wgl_context *
-wgl_context_from_hdc(
+struct stw_context *
+stw_context_from_hdc(
HDC hdc )
{
- struct wgl_context *ctx = ctx_head;
+ struct stw_context *ctx = ctx_head;
while (ctx != NULL) {
if (ctx->hdc == hdc)
{
}
+static INLINE struct stw_context *stw_context( HGLRC hglrc )
+{
+ return (struct stw_context *)hglrc;
+}
+
WINGDIAPI BOOL APIENTRY
wglCopyContext(
HGLRC hglrcDst,
UINT mask )
{
- return stw_copy_context( hglrcSrc, hglrcDst, mask );
+ return stw_copy_context( stw_context(hglrcSrc),
+ stw_context(hglrcDst),
+ mask );
}
WINGDIAPI HGLRC APIENTRY
wglDeleteContext(
HGLRC hglrc )
{
- return stw_delete_context( hglrc );
+ return stw_delete_context( stw_context(hglrc) );
}
WINGDIAPI HGLRC APIENTRY
wglGetCurrentContext( VOID )
{
- return stw_get_current_context();
+ return (HGLRC) stw_get_current_context();
}
WINGDIAPI HDC APIENTRY
HDC hdc,
HGLRC hglrc )
{
- return stw_make_current( hdc, hglrc );
+ return stw_make_current( hdc, stw_context(hglrc) );
}