summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-06-16 21:30:59 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-06-17 10:08:25 +0100
commitd22828f716fba0c63522101bd18f9660db17b364 (patch)
treea031ac5e8ff1d1b70ef87e929f68a573267a3161
parent992000cce7388eb864fec8c625ba8ff0d177daf6 (diff)
wgl: Factor out some repetitive code into inline functions.
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index 662b5fbcd2a..1c217699ab1 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -47,6 +47,23 @@
#include "stw_context.h"
#include "stw_tls.h"
+
+static INLINE struct stw_context *
+stw_context(GLcontext *glctx)
+{
+ if(!glctx)
+ return NULL;
+ assert(glctx->DriverCtx);
+ return (struct stw_context *)glctx->DriverCtx;
+}
+
+static INLINE struct stw_context *
+stw_current_context(void)
+{
+ GET_CURRENT_CONTEXT( glctx );
+ return stw_context(glctx);
+}
+
BOOL
stw_copy_context(
UINT_PTR hglrcSrc,
@@ -194,11 +211,10 @@ stw_delete_context(
pipe_mutex_unlock( stw_dev->mutex );
if (ctx) {
- GLcontext *glctx = ctx->st->ctx;
- GET_CURRENT_CONTEXT( glcurctx );
-
+ struct stw_context *curctx = stw_current_context();
+
/* Unbind current if deleting current context. */
- if (glcurctx == glctx)
+ if (curctx == ctx)
st_make_current( NULL, NULL, NULL );
st_destroy_context(ctx->st);
@@ -230,13 +246,8 @@ stw_release_context(
* current for this thread. We should check that and return False
* if not the case.
*/
- {
- GLcontext *glctx = ctx->st->ctx;
- GET_CURRENT_CONTEXT( glcurctx );
-
- if (glcurctx != glctx)
- return FALSE;
- }
+ if (ctx != stw_current_context())
+ return FALSE;
if (stw_make_current( NULL, 0 ) == FALSE)
return FALSE;
@@ -248,14 +259,9 @@ stw_release_context(
UINT_PTR
stw_get_current_context( void )
{
- GET_CURRENT_CONTEXT( glcurctx );
struct stw_context *ctx;
- if(!glcurctx)
- return 0;
-
- ctx = (struct stw_context *)glcurctx->DriverCtx;
- assert(ctx);
+ ctx = stw_current_context();
if(!ctx)
return 0;
@@ -265,14 +271,9 @@ stw_get_current_context( void )
HDC
stw_get_current_dc( void )
{
- GET_CURRENT_CONTEXT( glcurctx );
struct stw_context *ctx;
- if(!glcurctx)
- return NULL;
-
- ctx = (struct stw_context *)glcurctx->DriverCtx;
- assert(ctx);
+ ctx = stw_current_context();
if(!ctx)
return NULL;
@@ -284,19 +285,17 @@ stw_make_current(
HDC hdc,
UINT_PTR hglrc )
{
+ struct stw_context *curctx;
struct stw_context *ctx;
- GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
if (!stw_dev)
goto fail;
- if (glcurctx != NULL) {
- struct stw_context *curctx;
- curctx = (struct stw_context *) glcurctx->DriverCtx;
-
+ curctx = stw_current_context();
+ if (curctx != NULL) {
if (curctx->hglrc != hglrc)
- st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
/* Return if already current. */
if (curctx->hglrc == hglrc && curctx->hdc == hdc)