From cf8a1caa231b748d3ba7c776ab076ad3de99e963 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 14 Mar 2010 11:36:45 +0200 Subject: dri/swrast: port to dri_sw (context) --- src/mesa/drivers/dri/swrast/swrast.c | 41 +++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src/mesa/drivers/dri/swrast/swrast.c') 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; -- cgit v1.2.3