From f17eb0b13c6a2e70746edd1d882bf71adec129fb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 28 Jan 2009 12:25:25 +0000 Subject: wgl: move context functions to shared --- .../state_trackers/wgl/shared/stw_context.h | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/gallium/state_trackers/wgl/shared/stw_context.h (limited to 'src/gallium/state_trackers/wgl/shared/stw_context.h') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h new file mode 100644 index 0000000000..b418e4e02a --- /dev/null +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -0,0 +1,73 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef WGL_CONTEXT_H +#define WGL_CONTEXT_H + +#include + +struct st_context; + +struct wgl_context +{ + struct st_context *st; + HDC hdc; + DWORD color_bits; + struct wgl_context *next; +}; + +struct wgl_context * +wgl_context_from_hdc(HDC hdc ); + +////////////////// + + +BOOL stw_wgl_copy_context( HGLRC hglrcSrc, + HGLRC hglrcDst, + UINT mask ); + +HGLRC stw_wgl_create_context( HDC hdc, int iLayerPlane ); + +BOOL stw_wgl_delete_context( HGLRC hglrc ); + +HGLRC stw_wgl_get_current_context( void ); + +HDC stw_wgl_get_current_dc( void ); + +BOOL stw_wgl_make_current( HDC hdc, HGLRC hglrc ); + + + + + + + + + + + +#endif /* WGL_CONTEXT_H */ -- cgit v1.2.3 From 507498af1077390c684ca24e6ce6e0ee6ddcc479 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 28 Jan 2009 13:45:01 +0000 Subject: stw: rename stw_wgl_ --> stw_ --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 6 +++--- src/gallium/state_trackers/wgl/shared/stw_context.c | 12 ++++++------ src/gallium/state_trackers/wgl/shared/stw_context.h | 12 ++++++------ src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 14 +++++++------- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/gallium/state_trackers/wgl/shared/stw_context.h') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 0c1cfade78..9c28442c1f 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -62,7 +62,7 @@ DrvCopyContext( dst == NULL) return FALSE; - return stw_wgl_copy_context( src, dst, fuMask ); + return stw_copy_context( src, dst, fuMask ); } DHGLRC APIENTRY @@ -82,7 +82,7 @@ DrvCreateLayerContext( return 0; found_slot: - stw_dev->ctx_array[i].hglrc = stw_wgl_create_context( hdc, iLayerPlane ); + stw_dev->ctx_array[i].hglrc = stw_create_context( hdc, iLayerPlane ); if (stw_dev->ctx_array[i].hglrc == NULL) return 0; @@ -104,7 +104,7 @@ DrvDeleteContext( BOOL success = FALSE; if (hglrc != NULL) { - success = stw_wgl_delete_context( hglrc ); + success = stw_delete_context( hglrc ); if (success) stw_dev->ctx_array[dhglrc - 1].hglrc = NULL; } diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 75cfcda35d..b2cb612416 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -47,7 +47,7 @@ static HDC current_hdc = NULL; static HGLRC current_hrc = NULL; BOOL -stw_wgl_copy_context( +stw_copy_context( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) @@ -60,7 +60,7 @@ stw_wgl_copy_context( } HGLRC -stw_wgl_create_context( +stw_create_context( HDC hdc, int iLayerPlane ) { @@ -136,7 +136,7 @@ stw_wgl_create_context( BOOL -stw_wgl_delete_context( +stw_delete_context( HGLRC hglrc ) { struct wgl_context **link = &ctx_head; @@ -193,19 +193,19 @@ get_window_size( HDC hdc, GLuint *width, GLuint *height ) } HGLRC -stw_wgl_get_current_context( void ) +stw_get_current_context( void ) { return current_hrc; } HDC -stw_wgl_get_current_dc( void ) +stw_get_current_dc( void ) { return current_hdc; } BOOL -stw_wgl_make_current( +stw_make_current( HDC hdc, HGLRC hglrc ) { diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index b418e4e02a..91e71cf087 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -46,19 +46,19 @@ wgl_context_from_hdc(HDC hdc ); ////////////////// -BOOL stw_wgl_copy_context( HGLRC hglrcSrc, +BOOL stw_copy_context( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ); -HGLRC stw_wgl_create_context( HDC hdc, int iLayerPlane ); +HGLRC stw_create_context( HDC hdc, int iLayerPlane ); -BOOL stw_wgl_delete_context( HGLRC hglrc ); +BOOL stw_delete_context( HGLRC hglrc ); -HGLRC stw_wgl_get_current_context( void ); +HGLRC stw_get_current_context( void ); -HDC stw_wgl_get_current_dc( void ); +HDC stw_get_current_dc( void ); -BOOL stw_wgl_make_current( HDC hdc, HGLRC hglrc ); +BOOL stw_make_current( HDC hdc, HGLRC hglrc ); diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index 92fd340658..f6a4f66dd7 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -38,14 +38,14 @@ wglCopyContext( HGLRC hglrcDst, UINT mask ) { - return stw_wgl_copy_context( hglrcSrc, hglrcDst, mask ); + return stw_copy_context( hglrcSrc, hglrcDst, mask ); } WINGDIAPI HGLRC APIENTRY wglCreateContext( HDC hdc ) { - return (HGLRC) stw_wgl_create_context( hdc, 0 ); + return (HGLRC) stw_create_context( hdc, 0 ); } WINGDIAPI HGLRC APIENTRY @@ -53,27 +53,27 @@ wglCreateLayerContext( HDC hdc, int iLayerPlane ) { - return (HGLRC) stw_wgl_create_context( hdc, iLayerPlane ); + return (HGLRC) stw_create_context( hdc, iLayerPlane ); } WINGDIAPI BOOL APIENTRY wglDeleteContext( HGLRC hglrc ) { - return stw_wgl_delete_context( hglrc ); + return stw_delete_context( hglrc ); } WINGDIAPI HGLRC APIENTRY wglGetCurrentContext( VOID ) { - return stw_wgl_get_current_context(); + return stw_get_current_context(); } WINGDIAPI HDC APIENTRY wglGetCurrentDC( VOID ) { - return stw_wgl_get_current_dc(); + return stw_get_current_dc(); } WINGDIAPI BOOL APIENTRY @@ -81,7 +81,7 @@ wglMakeCurrent( HDC hdc, HGLRC hglrc ) { - return stw_wgl_make_current( hdc, hglrc ); + return stw_make_current( hdc, hglrc ); } -- cgit v1.2.3 From 7dbd95618f3e50fe2818d4152527092a96e70474 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 28 Jan 2009 19:14:57 +0000 Subject: stw: remove duplicate function declarations --- src/gallium/state_trackers/wgl/shared/stw_context.c | 1 + src/gallium/state_trackers/wgl/shared/stw_context.h | 20 -------------------- 2 files changed, 1 insertion(+), 20 deletions(-) (limited to 'src/gallium/state_trackers/wgl/shared/stw_context.h') diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 6c1f353f96..bf1f0f83c4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -37,6 +37,7 @@ #include "shared/stw_winsys.h" #include "shared/stw_framebuffer.h" #include "shared/stw_pixelformat.h" +#include "stw_public.h" #include "stw_context.h" static struct wgl_context *ctx_head = NULL; diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index 91e71cf087..5e84fc28e6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -43,26 +43,6 @@ struct wgl_context struct wgl_context * wgl_context_from_hdc(HDC hdc ); -////////////////// - - -BOOL stw_copy_context( HGLRC hglrcSrc, - HGLRC hglrcDst, - UINT mask ); - -HGLRC stw_create_context( HDC hdc, int iLayerPlane ); - -BOOL stw_delete_context( HGLRC hglrc ); - -HGLRC stw_get_current_context( void ); - -HDC stw_get_current_dc( void ); - -BOOL stw_make_current( HDC hdc, HGLRC hglrc ); - - - - -- cgit v1.2.3 From cbd368e91be121f1381ef132b64839f5638009f7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 28 Jan 2009 20:39:06 +0000 Subject: stw: use proper stw_context pointers in shared interface Move away from hglrc. --- src/gallium/state_trackers/wgl/icd/stw_icd.c | 79 ++++++++++++---------- .../state_trackers/wgl/shared/stw_context.c | 44 ++++++------ .../state_trackers/wgl/shared/stw_context.h | 14 ++-- src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 15 ++-- 4 files changed, 82 insertions(+), 70 deletions(-) (limited to 'src/gallium/state_trackers/wgl/shared/stw_context.h') diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 35a8eee220..70e346a539 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -42,7 +42,7 @@ struct stw_icd { struct { - HGLRC hglrc; + struct stw_context *ctx; } ctx_array[DRV_CONTEXT_MAX]; DHGLRC ctx_current; @@ -60,7 +60,7 @@ stw_icd_init( void ) assert(!stw_icd); stw_icd = &stw_icd_storage; - memset(stw_icd, 0, sizeof(*stw_icd)); + memset(stw_icd, 0, sizeof *stw_icd); return TRUE; } @@ -68,28 +68,28 @@ stw_icd_init( void ) 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 @@ -98,8 +98,8 @@ DrvCopyContext( 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) @@ -116,7 +116,7 @@ DrvCreateLayerContext( 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; } @@ -125,8 +125,8 @@ DrvCreateLayerContext( 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; @@ -143,18 +143,20 @@ BOOL APIENTRY 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 @@ -228,21 +230,23 @@ 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 @@ -265,15 +269,16 @@ DrvSetContext( 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 ) ); diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 62e26ab5da..2abf97b5ad 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -40,32 +40,32 @@ #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; @@ -78,7 +78,7 @@ stw_create_context( pf = pixelformat_get_info( pfi - 1 ); - ctx = CALLOC_STRUCT( wgl_context ); + ctx = CALLOC_STRUCT( stw_context ); if (ctx == NULL) return NULL; @@ -122,7 +122,7 @@ stw_create_context( ctx->next = ctx_head; ctx_head = ctx; - return (HGLRC) ctx; + return ctx; fail: if (visual) @@ -138,13 +138,13 @@ fail: 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; @@ -193,7 +193,7 @@ get_window_size( HDC hdc, GLuint *width, GLuint *height ) } } -HGLRC +struct stw_context * stw_get_current_context( void ) { return current_hrc; @@ -208,9 +208,9 @@ stw_get_current_dc( void ) 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; @@ -225,7 +225,7 @@ stw_make_current( } while (ctx != NULL) { - if (ctx == (struct wgl_context *) hglrc) + if (ctx == hglrc) break; ctx = ctx->next; } @@ -235,7 +235,7 @@ stw_make_current( /* 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; @@ -274,11 +274,11 @@ stw_make_current( 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) diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index 5e84fc28e6..89a8f900d8 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -25,23 +25,23 @@ * **************************************************************************/ -#ifndef WGL_CONTEXT_H -#define WGL_CONTEXT_H +#ifndef STW_CONTEXT_H +#define STW_CONTEXT_H #include struct st_context; -struct wgl_context +struct stw_context { struct st_context *st; HDC hdc; DWORD color_bits; - struct wgl_context *next; + struct stw_context *next; }; -struct wgl_context * -wgl_context_from_hdc(HDC hdc ); +struct stw_context * +stw_context_from_hdc(HDC hdc ); @@ -50,4 +50,4 @@ wgl_context_from_hdc(HDC hdc ); -#endif /* WGL_CONTEXT_H */ +#endif /* STW_CONTEXT_H */ diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index d03341815e..f50b79b4e1 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -42,6 +42,11 @@ void stw_wgl_cleanup( void ) { } +static INLINE struct stw_context *stw_context( HGLRC hglrc ) +{ + return (struct stw_context *)hglrc; +} + WINGDIAPI BOOL APIENTRY wglCopyContext( @@ -49,7 +54,9 @@ 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 @@ -71,14 +78,14 @@ WINGDIAPI BOOL 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 @@ -92,7 +99,7 @@ wglMakeCurrent( HDC hdc, HGLRC hglrc ) { - return stw_make_current( hdc, hglrc ); + return stw_make_current( hdc, stw_context(hglrc) ); } -- cgit v1.2.3