diff options
author | Kristian Høgsberg <[email protected]> | 2010-07-22 22:24:00 -0400 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2010-07-22 22:24:00 -0400 |
commit | 7b7845a076c933e096ac511b4184141ba194449a (patch) | |
tree | 3dd59fa57af0df40f5676229fe567f3c30534bda /src/glx | |
parent | 31819830b66a49f1b62e09090cc65aefc657aeb8 (diff) |
glx: Move WaitGL, WaitX, UseXFont to context vtable functions
Diffstat (limited to 'src/glx')
-rw-r--r-- | src/glx/dri2_glx.c | 21 | ||||
-rw-r--r-- | src/glx/dri_glx.c | 5 | ||||
-rw-r--r-- | src/glx/drisw_glx.c | 11 | ||||
-rw-r--r-- | src/glx/glxclient.h | 9 | ||||
-rw-r--r-- | src/glx/glxcmds.c | 148 | ||||
-rw-r--r-- | src/glx/xfont.c | 4 |
6 files changed, 97 insertions, 101 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 778607dd1c3..aa01203c61b 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -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; diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index 959fc7425a4..352d833fd7d 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -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; diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 367aa6a6f2e..0ad73914575 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -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; diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index dcb75d4959f..581db97a6ea 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -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); diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 5eae5a914df..eef2b621ba3 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, }; diff --git a/src/glx/xfont.c b/src/glx/xfont.c index 797fd7a4900..db3a5701100 100644 --- a/src/glx/xfont.c +++ b/src/glx/xfont.c @@ -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; |