glx: Move WaitGL, WaitX, UseXFont to context vtable functions

This commit is contained in:
Kristian Høgsberg 2010-07-22 22:24:00 -04:00
parent 31819830b6
commit 7b7845a076
6 changed files with 110 additions and 114 deletions

View file

@ -394,22 +394,24 @@ dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src)
}
static void
dri2WaitX(__GLXDRIdrawable *pdraw)
dri2_wait_x(__GLXcontext *gc)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
struct dri2_drawable *priv = (struct dri2_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
if (!priv->have_fake_front)
if (priv == NULL || !priv->have_fake_front)
return;
dri2_copy_drawable(priv, DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
}
static void
dri2WaitGL(__GLXDRIdrawable * pdraw)
dri2_wait_gl(__GLXcontext *gc)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
struct dri2_drawable *priv = (struct dri2_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
if (!priv->have_fake_front)
if (priv == NULL || !priv->have_fake_front)
return;
dri2_copy_drawable(priv, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
@ -426,7 +428,7 @@ dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate)
if (!pdp->invalidateAvailable)
dri2InvalidateBuffers(priv->dpy, pdraw->base.drawable);
dri2WaitGL(loaderPrivate);
dri2_copy_drawable(pdraw, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
}
@ -672,6 +674,9 @@ dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
}
static const struct glx_context_vtable dri2_context_vtable = {
dri2_wait_gl,
dri2_wait_x,
DRI_glXUseXFont,
dri2_bind_tex_image,
dri2_release_tex_image,
};
@ -804,8 +809,6 @@ dri2CreateScreen(int screen, __GLXdisplayPrivate * priv)
psp->createContext = dri2CreateContext;
psp->createDrawable = dri2CreateDrawable;
psp->swapBuffers = dri2SwapBuffers;
psp->waitGL = dri2WaitGL;
psp->waitX = dri2WaitX;
psp->getDrawableMSC = NULL;
psp->waitForMSC = NULL;
psp->waitForSBC = NULL;

View file

@ -95,6 +95,9 @@ struct dri_drawable
static const struct glx_context_vtable dri_context_vtable = {
NULL,
NULL,
DRI_glXUseXFont,
NULL,
NULL,
};
/*
@ -879,8 +882,6 @@ driCreateScreen(int screen, __GLXdisplayPrivate *priv)
psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
psp->swapBuffers = driSwapBuffers;
psp->waitX = NULL;
psp->waitGL = NULL;
#ifdef __DRI_SWAP_BUFFER_COUNTER
psp->getDrawableMSC = driDrawableGetMSC;

View file

@ -272,6 +272,14 @@ driUnbindContext(__GLXcontext * context)
(*psc->core->unbindContext) (pcp->driContext);
}
static const struct glx_context_vtable drisw_context_vtable = {
NULL,
NULL,
DRI_glXUseXFont,
NULL,
NULL,
};
static __GLXcontext *
driCreateContext(__GLXscreenConfigs *base,
const __GLcontextModes *mode,
@ -308,6 +316,7 @@ driCreateContext(__GLXscreenConfigs *base,
return NULL;
}
pcp->base.vtable = &drisw_context_vtable;
pcp->base.driContext = &pcp->dri_vtable;
pcp->dri_vtable.destroyContext = driDestroyContext;
pcp->dri_vtable.bindContext = driBindContext;
@ -472,8 +481,6 @@ driCreateScreen(int screen, __GLXdisplayPrivate *priv)
psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
psp->swapBuffers = driSwapBuffers;
psp->waitX = NULL;
psp->waitGL = NULL;
return &psc->base;

View file

@ -95,7 +95,8 @@ typedef struct _glapi_table __GLapi;
#define containerOf(ptr, type, member) \
(type *)( (char *)ptr - offsetof(type,member) )
extern void DRI_glXUseXFont(Font font, int first, int count, int listbase);
extern void DRI_glXUseXFont(GLXContext CC,
Font font, int first, int count, int listbase);
#endif
@ -139,8 +140,6 @@ struct __GLXDRIscreenRec {
int64_t divisor, int64_t remainder);
void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
int x, int y, int width, int height);
void (*waitX)(__GLXDRIdrawable *pdraw);
void (*waitGL)(__GLXDRIdrawable *pdraw);
int (*getDrawableMSC)(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
int64_t *ust, int64_t *msc, int64_t *sbc);
int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc,
@ -242,6 +241,10 @@ typedef struct __GLXattributeMachineRec
} __GLXattributeMachine;
struct glx_context_vtable {
void (*wait_gl)(__GLXcontext *ctx);
void (*wait_x)(__GLXcontext *ctx);
void (*use_x_font)(__GLXcontext *ctx,
Font font, int first, int count, int listBase);
void (*bind_tex_image)(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list);

View file

@ -672,42 +672,14 @@ glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
return rv;
}
/*
** Put a barrier in the token stream that forces the GL to finish its
** work before X can proceed.
*/
PUBLIC void
glXWaitGL(void)
static void
indirect_wait_gl(__GLXcontext *gc)
{
#ifndef GLX_USE_APPLEGL
xGLXWaitGLReq *req;
#endif
GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
if (!dpy)
return;
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_USE_APPLEGL
glFinish();
#else
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
int screen;
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen);
if (pdraw != NULL) {
__GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
glFlush();
if (psc->driScreen->waitGL != NULL)
(*psc->driScreen->waitGL) (pdraw);
}
return;
}
#endif
/* Send the glXWaitGL request */
LockDisplay(dpy);
@ -717,7 +689,37 @@ glXWaitGL(void)
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
#endif /* GLX_USE_APPLEGL */
}
/*
** Put a barrier in the token stream that forces the GL to finish its
** work before X can proceed.
*/
PUBLIC void
glXWaitGL(void)
{
GLXContext gc = __glXGetCurrentContext();
if (gc && gc->vtable->use_x_font)
gc->vtable->wait_gl(gc);
}
static void
indirect_wait_x(__GLXcontext *gc)
{
xGLXWaitXReq *req;
Display *dpy = gc->currentDpy;
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
LockDisplay(dpy);
GetReq(GLXWaitX, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXWaitX;
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
}
/*
@ -727,75 +729,22 @@ glXWaitGL(void)
PUBLIC void
glXWaitX(void)
{
#ifndef GLX_USE_APPLEGL
xGLXWaitXReq *req;
#endif
GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
if (!dpy)
return;
if (gc && gc->vtable->use_x_font)
gc->vtable->wait_x(gc);
}
static void
indirect_use_x_font(__GLXcontext *gc,
Font font, int first, int count, int listBase)
{
xGLXUseXFontReq *req;
Display *dpy = gc->currentDpy;
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_USE_APPLEGL
apple_glx_waitx(dpy, gc->driContext);
#else
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
int screen;
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen);
if (pdraw != NULL) {
__GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
if (psc->driScreen->waitX != NULL)
(*psc->driScreen->waitX) (pdraw);
}
else
XSync(dpy, False);
return;
}
#endif
/*
** Send the glXWaitX request.
*/
LockDisplay(dpy);
GetReq(GLXWaitX, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXWaitX;
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
#endif /* GLX_USE_APPLEGL */
}
PUBLIC void
glXUseXFont(Font font, int first, int count, int listBase)
{
#ifndef GLX_USE_APPLEGL
xGLXUseXFontReq *req;
#endif
GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
if (!dpy)
return;
/* Flush any pending commands out */
(void) __glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_USE_APPLEGL
DRI_glXUseXFont(font, first, count, listBase);
#else
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
DRI_glXUseXFont(font, first, count, listBase);
return;
}
#endif
/* Send the glXUseFont request */
LockDisplay(dpy);
GetReq(GLXUseXFont, req);
@ -808,7 +757,39 @@ glXUseXFont(Font font, int first, int count, int listBase)
req->listBase = listBase;
UnlockDisplay(dpy);
SyncHandle();
#endif /* GLX_USE_APPLEGL */
}
#ifdef GLX_USE_APPLEGL
static void
applegl_wait_gl(__GLXcontext *gc)
{
glFinish();
}
static void
applegl_wait_x(__GLXcontext *gc)
{
apple_glx_waitx(gc->dpy, gc->driContext);
}
static const struct glx_context_vtable applegl_context_vtable = {
applegl_wait_gl,
applegl_wait_x,
DRI_glXUseXFont,
NULL, /* bind_tex_image, */
NULL, /* release_tex_image, */
};
#endif
PUBLIC void
glXUseXFont(Font font, int first, int count, int listBase)
{
GLXContext gc = __glXGetCurrentContext();
if (gc && gc->vtable->use_x_font)
gc->vtable->use_x_font(gc, font, first, count, listBase);
}
/************************************************************************/
@ -2800,6 +2781,9 @@ indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
}
static const struct glx_context_vtable indirect_context_vtable = {
indirect_wait_gl,
indirect_wait_x,
indirect_use_x_font,
indirect_bind_tex_image,
indirect_release_tex_image,
};

View file

@ -212,9 +212,8 @@ isvalid(XFontStruct * fs, int which)
}
_X_HIDDEN void
DRI_glXUseXFont(Font font, int first, int count, int listbase)
DRI_glXUseXFont(GLXContext CC, Font font, int first, int count, int listbase)
{
GLXContext CC;
Display *dpy;
Window win;
Pixmap pixmap;
@ -231,7 +230,6 @@ DRI_glXUseXFont(Font font, int first, int count, int listbase)
int i;
CC = __glXGetCurrentContext();
dpy = CC->currentDpy;
win = CC->currentDrawable;