Move createDrawable from __GLXcontext to __GLXscreen.
This commit is contained in:
parent
eea8efe451
commit
7cf3ec7b59
|
@ -66,10 +66,6 @@ struct __GLXcontext {
|
|||
unsigned long mask);
|
||||
int (*forceCurrent) (__GLXcontext *context);
|
||||
|
||||
__GLXdrawable *(*createDrawable)(__GLXcontext *context,
|
||||
DrawablePtr pDraw,
|
||||
XID drawId);
|
||||
|
||||
__GLXtextureFromPixmap *textureFromPixmap;
|
||||
|
||||
/*
|
||||
|
|
|
@ -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)
|
||||
|
@ -800,6 +800,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
|
|||
|
||||
screen->base.destroy = __glXDRIscreenDestroy;
|
||||
screen->base.createContext = __glXDRIscreenCreateContext;
|
||||
screen->base.createDrawable = __glXDRIscreenCreateDrawable;
|
||||
screen->base.pScreen = pScreen;
|
||||
|
||||
/* DRI protocol version. */
|
||||
|
|
|
@ -59,6 +59,11 @@ struct __GLXscreen {
|
|||
__GLcontextModes *modes,
|
||||
__GLXcontext *shareContext);
|
||||
|
||||
__GLXdrawable *(*createDrawable)(__GLXscreen *context,
|
||||
DrawablePtr pDraw,
|
||||
XID drawId,
|
||||
__GLcontextModes *modes);
|
||||
|
||||
ScreenPtr pScreen;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -140,12 +140,12 @@ __glXMesaDrawableSwapBuffers(__GLXdrawable *base)
|
|||
|
||||
|
||||
static __GLXdrawable *
|
||||
__glXMesaContextCreateDrawable(__GLXcontext *context,
|
||||
__glXMesaScreenCreateDrawable(__GLXscreen *screen,
|
||||
DrawablePtr pDraw,
|
||||
XID drawId)
|
||||
XID drawId,
|
||||
__GLcontextModes *modes)
|
||||
{
|
||||
__GLXMESAdrawable *glxPriv;
|
||||
__GLXscreen *pGlxScreen;
|
||||
XMesaVisual xm_vis;
|
||||
|
||||
glxPriv = xalloc(sizeof *glxPriv);
|
||||
|
@ -154,7 +154,7 @@ __glXMesaContextCreateDrawable(__GLXcontext *context,
|
|||
|
||||
memset(glxPriv, 0, sizeof *glxPriv);
|
||||
|
||||
if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) {
|
||||
if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
|
||||
xfree(glxPriv);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -163,21 +163,10 @@ __glXMesaContextCreateDrawable(__GLXcontext *context,
|
|||
glxPriv->base.resize = __glXMesaDrawableResize;
|
||||
glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
|
||||
|
||||
pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum];
|
||||
|
||||
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);
|
||||
xm_vis = find_mesa_visual(screen, modes->visualID);
|
||||
if (xm_vis == NULL) {
|
||||
ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
|
||||
glxPriv->base.modes->visualID);
|
||||
modes->visualID);
|
||||
xfree(glxPriv);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -197,7 +186,7 @@ __glXMesaContextDestroy(__GLXcontext *baseContext)
|
|||
__GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
|
||||
|
||||
XMesaDestroyContext(context->xmesa);
|
||||
__glXContextDestroy(context);
|
||||
__glXContextDestroy(&context->base);
|
||||
xfree(context);
|
||||
}
|
||||
|
||||
|
@ -268,7 +257,6 @@ __glXMesaScreenCreateContext(__GLXscreen *screen,
|
|||
context->base.loseCurrent = __glXMesaContextLoseCurrent;
|
||||
context->base.copy = __glXMesaContextCopy;
|
||||
context->base.forceCurrent = __glXMesaContextForceCurrent;
|
||||
context->base.createDrawable = __glXMesaContextCreateDrawable;
|
||||
|
||||
xm_vis = find_mesa_visual(screen, modes->visualID);
|
||||
if (!xm_vis) {
|
||||
|
@ -419,6 +407,7 @@ __glXMesaScreenProbe(ScreenPtr pScreen)
|
|||
|
||||
screen->base.destroy = __glXMesaScreenDestroy;
|
||||
screen->base.createContext = __glXMesaScreenCreateContext;
|
||||
screen->base.createDrawable = __glXMesaScreenCreateDrawable;
|
||||
screen->base.pScreen = pScreen;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue
Block a user