__DRIcontext *shared, void *data)
{
__DRIcontext *pcp;
- void * const shareCtx = (shared != NULL) ? &shared->Base : NULL;
+ void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
pcp = CALLOC_STRUCT(__DRIcontextRec);
if (!pcp)
struct __DRIcontextRec {
- GLcontext Base;
+ void *driverPrivate;
void *loaderPrivate;
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;
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 );
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;
/**
* Data types
*/
+struct dri_context
+{
+ /* mesa */
+ GLcontext Base;
+
+ /* dri */
+ __DRIcontext *cPriv;
+};
+
+static INLINE struct dri_context *
+dri_context(__DRIcontext * driContextPriv)
+{
+ return (struct dri_context *)driContextPriv->driverPrivate;
+}
+
+static INLINE struct dri_context *
+swrast_context(GLcontext *ctx)
+{
+ return (struct dri_context *) ctx;
+}
+
struct swrast_renderbuffer {
struct gl_renderbuffer Base;
GLuint bpp;
};
-static INLINE __DRIcontext *
-swrast_context(GLcontext *ctx)
-{
- return (__DRIcontext *) ctx;
-}
-
static INLINE __DRIdrawable *
swrast_drawable(GLframebuffer *fb)
{
static INLINE void
PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p )
{
- __DRIcontext *ctx = swrast_context(glCtx);
+ __DRIcontext *ctx = swrast_context(glCtx)->cPriv;
__DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer);
__DRIscreen *screen = ctx->driScreenPriv;
static INLINE void
GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p )
{
- __DRIcontext *ctx = swrast_context(glCtx);
+ __DRIcontext *ctx = swrast_context(glCtx)->cPriv;
__DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer);
__DRIscreen *screen = ctx->driScreenPriv;
static INLINE void
PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row )
{
- __DRIcontext *ctx = swrast_context(glCtx);
+ __DRIcontext *ctx = swrast_context(glCtx)->cPriv;
__DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer);
__DRIscreen *screen = ctx->driScreenPriv;
static INLINE void
GET_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row )
{
- __DRIcontext *ctx = swrast_context(glCtx);
+ __DRIcontext *ctx = swrast_context(glCtx)->cPriv;
__DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer);
__DRIscreen *screen = ctx->driScreenPriv;