From 7b7845a076c933e096ac511b4184141ba194449a Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 22 Jul 2010 22:24:00 -0400 Subject: glx: Move WaitGL, WaitX, UseXFont to context vtable functions --- src/glx/glxcmds.c | 148 ++++++++++++++++++++++++------------------------------ 1 file changed, 66 insertions(+), 82 deletions(-) (limited to 'src/glx/glxcmds.c') diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 5eae5a914d..eef2b621ba 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -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,51 +689,30 @@ glXWaitGL(void) req->contextTag = gc->currentContextTag; UnlockDisplay(dpy); SyncHandle(); -#endif /* GLX_USE_APPLEGL */ } /* -** Put a barrier in the token stream that forces X to finish its -** work before GL can proceed. +** Put a barrier in the token stream that forces the GL to finish its +** work before X can proceed. */ PUBLIC void -glXWaitX(void) +glXWaitGL(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_gl(gc); +} + +static void +indirect_wait_x(__GLXcontext *gc) +{ + xGLXWaitXReq *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; @@ -769,32 +720,30 @@ glXWaitX(void) req->contextTag = gc->currentContextTag; UnlockDisplay(dpy); SyncHandle(); -#endif /* GLX_USE_APPLEGL */ } +/* +** Put a barrier in the token stream that forces X to finish its +** work before GL can proceed. +*/ PUBLIC void -glXUseXFont(Font font, int first, int count, int listBase) +glXWaitX(void) { -#ifndef GLX_USE_APPLEGL - xGLXUseXFontReq *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 */ - (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 + __glXFlushRenderBuffer(gc, gc->pc); /* Send the glXUseFont request */ LockDisplay(dpy); @@ -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, }; -- cgit v1.2.3