diff options
author | Kristian Høgsberg <krh@redhat.com> | 2006-06-28 17:00:23 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2006-07-06 00:28:53 -0400 |
commit | 7cf3ec7b59223f15314a0629f122ecb796678421 (patch) | |
tree | 7ff91618027625ed203a11c05738cd614a92c327 /GL/glx | |
parent | eea8efe4516750b2505b52ebc9f769f5e8a6f94c (diff) |
Move createDrawable from __GLXcontext to __GLXscreen.
Diffstat (limited to 'GL/glx')
-rw-r--r-- | GL/glx/glxcontext.h | 6 | ||||
-rw-r--r-- | GL/glx/glxdri.c | 91 | ||||
-rw-r--r-- | GL/glx/glxscreens.h | 13 | ||||
-rw-r--r-- | GL/glx/glxutil.c | 24 | ||||
-rw-r--r-- | GL/glx/glxutil.h | 12 |
5 files changed, 85 insertions, 61 deletions
diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h index d57745a25..68e26609d 100644 --- a/GL/glx/glxcontext.h +++ b/GL/glx/glxcontext.h @@ -58,7 +58,7 @@ struct __GLXtextureFromPixmap { struct __GLXcontext { - void (*destroy) (__GLXcontext *context); + void (*destroy) (__GLXcontext *context); int (*makeCurrent) (__GLXcontext *context); int (*loseCurrent) (__GLXcontext *context); int (*copy) (__GLXcontext *dst, @@ -66,10 +66,6 @@ struct __GLXcontext { unsigned long mask); int (*forceCurrent) (__GLXcontext *context); - __GLXdrawable *(*createDrawable)(__GLXcontext *context, - DrawablePtr pDraw, - XID drawId); - __GLXtextureFromPixmap *textureFromPixmap; /* diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c index c0339050f..423922966 100644 --- a/GL/glx/glxdri.c +++ b/GL/glx/glxdri.c @@ -177,48 +177,6 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *basePrivate) return TRUE; } -static __GLXdrawable * -__glXDRIcontextCreateDrawable(__GLXcontext *context, - DrawablePtr pDraw, - XID drawId) -{ - __GLXDRIdrawable *private; - - private = xalloc(sizeof *private); - if (private == NULL) - return NULL; - - memset(private, 0, sizeof *private); - - if (!__glXDrawableInit(&private->base, context, pDraw, drawId)) { - xfree(private); - return NULL; - } - - private->base.destroy = __glXDRIdrawableDestroy; - private->base.resize = __glXDRIdrawableResize; - private->base.swapBuffers = __glXDRIdrawableSwapBuffers; - -#if 0 - /* FIXME: It would only be natural that we called - * driScreen->createNewDrawable here but the DRI drivers manage - * them a little oddly. FIXME: describe this better.*/ - - /* The last argument is 'attrs', which is used with pbuffers which - * we currently don't support. */ - - glxPriv->driDrawable.private = - (pGlxScreen->driScreen.createNewDrawable)(NULL, modes, - drawId, - &glxPriv->driDrawable, - 0, - NULL); -#endif - - return &private->base; -} - - static void __glXDRIcontextDestroy(__GLXcontext *baseContext) { @@ -483,7 +441,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, context->base.loseCurrent = __glXDRIcontextLoseCurrent; context->base.copy = __glXDRIcontextCopy; context->base.forceCurrent = __glXDRIcontextForceCurrent; - context->base.createDrawable = __glXDRIcontextCreateDrawable; context->base.textureFromPixmap = &__glXDRItextureFromPixmap; @@ -498,6 +455,49 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, return &context->base; } +static __GLXdrawable * +__glXDRIscreenCreateDrawable(__GLXscreen *screen, + DrawablePtr pDraw, + XID drawId, + __GLcontextModes *modes) +{ + __GLXDRIdrawable *private; + + private = xalloc(sizeof *private); + if (private == NULL) + return NULL; + + memset(private, 0, sizeof *private); + + if (!__glXDrawableInit(&private->base, screen, pDraw, drawId, modes)) { + xfree(private); + return NULL; + } + + private->base.destroy = __glXDRIdrawableDestroy; + private->base.resize = __glXDRIdrawableResize; + private->base.swapBuffers = __glXDRIdrawableSwapBuffers; + +#if 0 + /* FIXME: It would only be natural that we called + * driScreen->createNewDrawable here but the DRI drivers manage + * them a little oddly. FIXME: describe this better.*/ + + /* The last argument is 'attrs', which is used with pbuffers which + * we currently don't support. */ + + glxPriv->driDrawable.private = + (screen->driScreen.createNewDrawable)(NULL, modes, + drawId, + &glxPriv->driDrawable, + 0, + NULL); +#endif + + return &private->base; +} + + static unsigned filter_modes(__GLcontextModes **server_modes, const __GLcontextModes *driver_modes) @@ -798,8 +798,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen) return NULL; memset(screen, 0, sizeof *screen); - screen->base.destroy = __glXDRIscreenDestroy; - screen->base.createContext = __glXDRIscreenCreateContext; + screen->base.destroy = __glXDRIscreenDestroy; + screen->base.createContext = __glXDRIscreenCreateContext; + screen->base.createDrawable = __glXDRIscreenCreateDrawable; screen->base.pScreen = pScreen; /* DRI protocol version. */ diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h index 8a2b2388f..96373dbee 100644 --- a/GL/glx/glxscreens.h +++ b/GL/glx/glxscreens.h @@ -53,11 +53,16 @@ */ typedef struct __GLXscreen __GLXscreen; struct __GLXscreen { - void (*destroy)(__GLXscreen *screen); + void (*destroy) (__GLXscreen *screen); - __GLXcontext *(*createContext)(__GLXscreen *screen, - __GLcontextModes *modes, - __GLXcontext *shareContext); + __GLXcontext *(*createContext) (__GLXscreen *screen, + __GLcontextModes *modes, + __GLXcontext *shareContext); + + __GLXdrawable *(*createDrawable)(__GLXscreen *context, + DrawablePtr pDraw, + XID drawId, + __GLcontextModes *modes); ScreenPtr pScreen; diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c index f1f9c06c5..ed5bafa34 100644 --- a/GL/glx/glxutil.c +++ b/GL/glx/glxutil.c @@ -140,12 +140,14 @@ __glXUnrefDrawable(__GLXdrawable *glxPriv) GLboolean __glXDrawableInit(__GLXdrawable *drawable, - __GLXcontext *ctx, DrawablePtr pDraw, XID drawId) + __GLXscreen *screen, DrawablePtr pDraw, XID drawId, + __GLcontextModes *modes) { drawable->type = pDraw->type; drawable->pDraw = pDraw; drawable->drawId = drawId; drawable->refCount = 1; + drawable->modes = modes; /* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */ drawable->pGlxPixmap = (__GLXpixmap *) @@ -167,13 +169,31 @@ __glXFindDrawable(XID drawId) __GLXdrawable * __glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId) { + __GLXscreen *pGlxScreen = ctx->pGlxScreen; __GLXdrawable *glxPriv; + __GLcontextModes *modes; glxPriv = __glXFindDrawable(drawId); if (glxPriv == NULL) { - glxPriv = ctx->createDrawable(ctx, pDraw, drawId); + if (pDraw->type == DRAWABLE_WINDOW) { + VisualID vid = wVisual((WindowPtr)pDraw); + + modes = _gl_context_modes_find_visual(pGlxScreen->modes, vid); + } else { + __GLXpixmap *pGlxPixmap = + (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes); + + /* We never get here without a valid pixmap. + * GetDrawableOrPixmap weeds out X Pixmaps without GLX + * pixmaps for us. */ + + modes = pGlxPixmap->modes; + } + + glxPriv = + pGlxScreen->createDrawable(ctx->pGlxScreen, pDraw, drawId, modes); /* since we are creating the drawablePrivate, drawId should be new */ if (!AddResource(drawId, __glXDrawableRes, glxPriv)) diff --git a/GL/glx/glxutil.h b/GL/glx/glxutil.h index d5cfa20b5..7b5494c9a 100644 --- a/GL/glx/glxutil.h +++ b/GL/glx/glxutil.h @@ -58,11 +58,13 @@ extern GLboolean __glXResizeDrawableBuffers(__GLXdrawable *glxPriv); extern void __glXRefDrawable(__GLXdrawable *glxPriv); extern void __glXUnrefDrawable(__GLXdrawable *glxPriv); -extern __GLXdrawable *__glXCreateDrawable(__GLXcontext *ctx, - DrawablePtr pDraw, - XID glxpixmapId); -extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXcontext *ctx, - DrawablePtr pDraw, XID drawID); +extern __GLXdrawable *__glXCreateDrawable(__GLXscreen *screen, + DrawablePtr pDraw, XID drawId, + __GLcontextModes *modes); +extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, + __GLXscreen *screen, + DrawablePtr pDraw, XID drawID, + __GLcontextModes *modes); extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv); extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId); extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx, |