Move createDrawable from __GLXcontext to __GLXscreen.

This commit is contained in:
Kristian Høgsberg 2006-06-28 17:00:23 -04:00
parent eea8efe451
commit 7cf3ec7b59
6 changed files with 99 additions and 86 deletions

View File

@ -58,7 +58,7 @@ struct __GLXtextureFromPixmap {
struct __GLXcontext { struct __GLXcontext {
void (*destroy) (__GLXcontext *context); void (*destroy) (__GLXcontext *context);
int (*makeCurrent) (__GLXcontext *context); int (*makeCurrent) (__GLXcontext *context);
int (*loseCurrent) (__GLXcontext *context); int (*loseCurrent) (__GLXcontext *context);
int (*copy) (__GLXcontext *dst, int (*copy) (__GLXcontext *dst,
@ -66,10 +66,6 @@ struct __GLXcontext {
unsigned long mask); unsigned long mask);
int (*forceCurrent) (__GLXcontext *context); int (*forceCurrent) (__GLXcontext *context);
__GLXdrawable *(*createDrawable)(__GLXcontext *context,
DrawablePtr pDraw,
XID drawId);
__GLXtextureFromPixmap *textureFromPixmap; __GLXtextureFromPixmap *textureFromPixmap;
/* /*

View File

@ -177,48 +177,6 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *basePrivate)
return TRUE; 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 static void
__glXDRIcontextDestroy(__GLXcontext *baseContext) __glXDRIcontextDestroy(__GLXcontext *baseContext)
{ {
@ -483,7 +441,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
context->base.loseCurrent = __glXDRIcontextLoseCurrent; context->base.loseCurrent = __glXDRIcontextLoseCurrent;
context->base.copy = __glXDRIcontextCopy; context->base.copy = __glXDRIcontextCopy;
context->base.forceCurrent = __glXDRIcontextForceCurrent; context->base.forceCurrent = __glXDRIcontextForceCurrent;
context->base.createDrawable = __glXDRIcontextCreateDrawable;
context->base.textureFromPixmap = &__glXDRItextureFromPixmap; context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
@ -498,6 +455,49 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
return &context->base; 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 static unsigned
filter_modes(__GLcontextModes **server_modes, filter_modes(__GLcontextModes **server_modes,
const __GLcontextModes *driver_modes) const __GLcontextModes *driver_modes)
@ -798,8 +798,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
return NULL; return NULL;
memset(screen, 0, sizeof *screen); memset(screen, 0, sizeof *screen);
screen->base.destroy = __glXDRIscreenDestroy; screen->base.destroy = __glXDRIscreenDestroy;
screen->base.createContext = __glXDRIscreenCreateContext; screen->base.createContext = __glXDRIscreenCreateContext;
screen->base.createDrawable = __glXDRIscreenCreateDrawable;
screen->base.pScreen = pScreen; screen->base.pScreen = pScreen;
/* DRI protocol version. */ /* DRI protocol version. */

View File

@ -53,11 +53,16 @@
*/ */
typedef struct __GLXscreen __GLXscreen; typedef struct __GLXscreen __GLXscreen;
struct __GLXscreen { struct __GLXscreen {
void (*destroy)(__GLXscreen *screen); void (*destroy) (__GLXscreen *screen);
__GLXcontext *(*createContext)(__GLXscreen *screen, __GLXcontext *(*createContext) (__GLXscreen *screen,
__GLcontextModes *modes, __GLcontextModes *modes,
__GLXcontext *shareContext); __GLXcontext *shareContext);
__GLXdrawable *(*createDrawable)(__GLXscreen *context,
DrawablePtr pDraw,
XID drawId,
__GLcontextModes *modes);
ScreenPtr pScreen; ScreenPtr pScreen;

View File

@ -140,12 +140,14 @@ __glXUnrefDrawable(__GLXdrawable *glxPriv)
GLboolean GLboolean
__glXDrawableInit(__GLXdrawable *drawable, __glXDrawableInit(__GLXdrawable *drawable,
__GLXcontext *ctx, DrawablePtr pDraw, XID drawId) __GLXscreen *screen, DrawablePtr pDraw, XID drawId,
__GLcontextModes *modes)
{ {
drawable->type = pDraw->type; drawable->type = pDraw->type;
drawable->pDraw = pDraw; drawable->pDraw = pDraw;
drawable->drawId = drawId; drawable->drawId = drawId;
drawable->refCount = 1; drawable->refCount = 1;
drawable->modes = modes;
/* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */ /* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */
drawable->pGlxPixmap = (__GLXpixmap *) drawable->pGlxPixmap = (__GLXpixmap *)
@ -167,13 +169,31 @@ __glXFindDrawable(XID drawId)
__GLXdrawable * __GLXdrawable *
__glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId) __glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId)
{ {
__GLXscreen *pGlxScreen = ctx->pGlxScreen;
__GLXdrawable *glxPriv; __GLXdrawable *glxPriv;
__GLcontextModes *modes;
glxPriv = __glXFindDrawable(drawId); glxPriv = __glXFindDrawable(drawId);
if (glxPriv == NULL) 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 */ /* since we are creating the drawablePrivate, drawId should be new */
if (!AddResource(drawId, __glXDrawableRes, glxPriv)) if (!AddResource(drawId, __glXDrawableRes, glxPriv))

View File

@ -58,11 +58,13 @@ extern GLboolean __glXResizeDrawableBuffers(__GLXdrawable *glxPriv);
extern void __glXRefDrawable(__GLXdrawable *glxPriv); extern void __glXRefDrawable(__GLXdrawable *glxPriv);
extern void __glXUnrefDrawable(__GLXdrawable *glxPriv); extern void __glXUnrefDrawable(__GLXdrawable *glxPriv);
extern __GLXdrawable *__glXCreateDrawable(__GLXcontext *ctx, extern __GLXdrawable *__glXCreateDrawable(__GLXscreen *screen,
DrawablePtr pDraw, DrawablePtr pDraw, XID drawId,
XID glxpixmapId); __GLcontextModes *modes);
extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXcontext *ctx, extern GLboolean __glXDrawableInit(__GLXdrawable *drawable,
DrawablePtr pDraw, XID drawID); __GLXscreen *screen,
DrawablePtr pDraw, XID drawID,
__GLcontextModes *modes);
extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv); extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv);
extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId); extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId);
extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx, extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx,

View File

@ -140,12 +140,12 @@ __glXMesaDrawableSwapBuffers(__GLXdrawable *base)
static __GLXdrawable * static __GLXdrawable *
__glXMesaContextCreateDrawable(__GLXcontext *context, __glXMesaScreenCreateDrawable(__GLXscreen *screen,
DrawablePtr pDraw, DrawablePtr pDraw,
XID drawId) XID drawId,
__GLcontextModes *modes)
{ {
__GLXMESAdrawable *glxPriv; __GLXMESAdrawable *glxPriv;
__GLXscreen *pGlxScreen;
XMesaVisual xm_vis; XMesaVisual xm_vis;
glxPriv = xalloc(sizeof *glxPriv); glxPriv = xalloc(sizeof *glxPriv);
@ -154,30 +154,19 @@ __glXMesaContextCreateDrawable(__GLXcontext *context,
memset(glxPriv, 0, sizeof *glxPriv); memset(glxPriv, 0, sizeof *glxPriv);
if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) { if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
xfree(glxPriv); xfree(glxPriv);
return NULL; return NULL;
} }
glxPriv->base.destroy = __glXMesaDrawableDestroy; glxPriv->base.destroy = __glXMesaDrawableDestroy;
glxPriv->base.resize = __glXMesaDrawableResize; glxPriv->base.resize = __glXMesaDrawableResize;
glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers; glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum]; xm_vis = find_mesa_visual(screen, modes->visualID);
if (glxPriv->base.type == DRAWABLE_WINDOW) {
VisualID vid = wVisual((WindowPtr)pDraw);
glxPriv->base.modes = _gl_context_modes_find_visual(pGlxScreen->modes,
vid);
} else {
glxPriv->base.modes = glxPriv->base.pGlxPixmap->modes;
}
xm_vis = find_mesa_visual(pGlxScreen, glxPriv->base.modes->visualID);
if (xm_vis == NULL) { if (xm_vis == NULL) {
ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n", ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
glxPriv->base.modes->visualID); modes->visualID);
xfree(glxPriv); xfree(glxPriv);
return NULL; return NULL;
} }
@ -197,7 +186,7 @@ __glXMesaContextDestroy(__GLXcontext *baseContext)
__GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
XMesaDestroyContext(context->xmesa); XMesaDestroyContext(context->xmesa);
__glXContextDestroy(context); __glXContextDestroy(&context->base);
xfree(context); xfree(context);
} }
@ -268,7 +257,6 @@ __glXMesaScreenCreateContext(__GLXscreen *screen,
context->base.loseCurrent = __glXMesaContextLoseCurrent; context->base.loseCurrent = __glXMesaContextLoseCurrent;
context->base.copy = __glXMesaContextCopy; context->base.copy = __glXMesaContextCopy;
context->base.forceCurrent = __glXMesaContextForceCurrent; context->base.forceCurrent = __glXMesaContextForceCurrent;
context->base.createDrawable = __glXMesaContextCreateDrawable;
xm_vis = find_mesa_visual(screen, modes->visualID); xm_vis = find_mesa_visual(screen, modes->visualID);
if (!xm_vis) { if (!xm_vis) {
@ -417,8 +405,9 @@ __glXMesaScreenProbe(ScreenPtr pScreen)
__glXScreenInit(&screen->base, pScreen); __glXScreenInit(&screen->base, pScreen);
screen->base.destroy = __glXMesaScreenDestroy; screen->base.destroy = __glXMesaScreenDestroy;
screen->base.createContext = __glXMesaScreenCreateContext; screen->base.createContext = __glXMesaScreenCreateContext;
screen->base.createDrawable = __glXMesaScreenCreateDrawable;
screen->base.pScreen = pScreen; screen->base.pScreen = pScreen;
/* /*