diff options
author | George Sapountzis <[email protected]> | 2010-03-14 11:36:45 +0200 |
---|---|---|
committer | George Sapountzis <[email protected]> | 2010-03-15 01:17:17 +0200 |
commit | cf8a1caa231b748d3ba7c776ab076ad3de99e963 (patch) | |
tree | 97da7f8c27abbdd8c991a667ea01d52145858e66 /src/mesa/drivers/dri/swrast/swrast.c | |
parent | 6e376485c10896229f7bfaf5b0cce9c8b67f61b1 (diff) |
dri/swrast: port to dri_sw (context)
Diffstat (limited to 'src/mesa/drivers/dri/swrast/swrast.c')
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 8c858ab2da2..8273439fef3 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -474,25 +474,36 @@ static GLboolean dri_create_context(const __GLcontextModes * visual, __DRIcontext * cPriv, void *sharedContextPrivate) { - GLcontext *mesaCtx; - GLcontext *sharedCtx; + struct dri_context *ctx = NULL; + struct dri_context *share = (struct dri_context *)sharedContextPrivate; + GLcontext *mesaCtx = NULL; + GLcontext *sharedCtx = NULL; struct dd_function_table functions; TRACE; + ctx = CALLOC_STRUCT(dri_context); + if (ctx == NULL) + goto context_fail; + + cPriv->driverPrivate = ctx; + ctx->cPriv = cPriv; + /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); - sharedCtx = sharedContextPrivate; + if (share) { + sharedCtx = &share->Base; + } + + mesaCtx = &ctx->Base; /* basic context setup */ - if (!_mesa_initialize_context(&cPriv->Base, visual, sharedCtx, &functions, (void *) cPriv)) { - return GL_FALSE; + if (!_mesa_initialize_context(mesaCtx, visual, sharedCtx, &functions, (void *) cPriv)) { + goto context_fail; } - mesaCtx = &cPriv->Base; - /* do bounds checking to prevent segfaults and server crashes! */ mesaCtx->Const.CheckArrayBounds = GL_TRUE; @@ -521,16 +532,24 @@ dri_create_context(const __GLcontextModes * visual, driInitExtensions( mesaCtx, NULL, GL_FALSE ); return GL_TRUE; + +context_fail: + + FREE(ctx); + + return GL_FALSE; } static void dri_destroy_context(__DRIcontext * cPriv) { - GLcontext *mesaCtx; TRACE; if (cPriv) { - mesaCtx = &cPriv->Base; + struct dri_context *ctx = dri_context(cPriv); + GLcontext *mesaCtx; + + mesaCtx = &ctx->Base; _mesa_meta_free(mesaCtx); _swsetup_DestroyContext( mesaCtx ); @@ -552,10 +571,12 @@ dri_make_current(__DRIcontext * cPriv, TRACE; if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + if (!driDrawPriv || !driReadPriv) return GL_FALSE; - mesaCtx = &cPriv->Base; + mesaCtx = &ctx->Base; mesaDraw = &driDrawPriv->Base; mesaRead = &driReadPriv->Base; |