diff options
author | Brian Paul <[email protected]> | 2011-05-19 19:21:21 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-05-19 21:18:33 -0600 |
commit | 7be3e507317a0e731fef91a1505f8500e8d1c050 (patch) | |
tree | 9488599ed87050ba5a2a51136403b7c66fec11f2 /src/gallium | |
parent | 43bdabd47d98975b56a759954fb5f37d2942c101 (diff) |
st/glx: refactor create-context functions
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/glx_api.c | 101 |
1 files changed, 40 insertions, 61 deletions
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 351267bae4d..7e2b6d201a0 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -1018,15 +1018,16 @@ glXChooseVisual( Display *dpy, int screen, int *list ) } -PUBLIC GLXContext -glXCreateContext( Display *dpy, XVisualInfo *visinfo, - GLXContext share_list, Bool direct ) +/** + * Helper function used by other glXCreateContext functions. + */ +static GLXContext +create_context(Display *dpy, XMesaVisual xmvis, + XMesaContext shareCtx, Bool direct) { - XMesaVisual xmvis; GLXContext glxCtx; - GLXContext shareCtx = share_list; - if (!dpy || !visinfo) + if (!dpy || !xmvis) return 0; glxCtx = CALLOC_STRUCT(__GLXcontextRec); @@ -1038,19 +1039,7 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo, XMesaGarbageCollect(); #endif - xmvis = find_glx_visual( dpy, visinfo ); - if (!xmvis) { - /* This visual wasn't found with glXChooseVisual() */ - xmvis = create_glx_visual( dpy, visinfo ); - if (!xmvis) { - /* unusable visual */ - free(glxCtx); - return NULL; - } - } - - glxCtx->xmesaContext = XMesaCreateContext(xmvis, - shareCtx ? shareCtx->xmesaContext : NULL); + glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx); if (!glxCtx->xmesaContext) { free(glxCtx); return NULL; @@ -1064,6 +1053,28 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo, } +PUBLIC GLXContext +glXCreateContext( Display *dpy, XVisualInfo *visinfo, + GLXContext shareCtx, Bool direct ) +{ + XMesaVisual xmvis; + + xmvis = find_glx_visual( dpy, visinfo ); + if (!xmvis) { + /* This visual wasn't found with glXChooseVisual() */ + xmvis = create_glx_visual( dpy, visinfo ); + if (!xmvis) { + /* unusable visual */ + return NULL; + } + } + + return create_context(dpy, xmvis, + shareCtx ? shareCtx->xmesaContext : NULL, + direct); +} + + /* XXX these may have to be removed due to thread-safety issues. */ static GLXContext MakeCurrent_PrevContext = 0; static GLXDrawable MakeCurrent_PrevDrawable = 0; @@ -2084,35 +2095,17 @@ glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, PUBLIC GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config, - int renderType, GLXContext shareList, Bool direct ) + int renderType, GLXContext shareCtx, Bool direct ) { - GLXContext glxCtx; - GLXContext shareCtx = shareList; XMesaVisual xmvis = (XMesaVisual) config; if (!dpy || !config || (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) return 0; - glxCtx = CALLOC_STRUCT(__GLXcontextRec); - if (!glxCtx) - return 0; - - /* deallocate unused windows/buffers */ - XMesaGarbageCollect(); - - glxCtx->xmesaContext = XMesaCreateContext(xmvis, - shareCtx ? shareCtx->xmesaContext : NULL); - if (!glxCtx->xmesaContext) { - free(glxCtx); - return NULL; - } - - glxCtx->isDirect = DEFAULT_DIRECT; - glxCtx->currentDpy = dpy; - glxCtx->xid = (XID) glxCtx; /* self pointer */ - - return glxCtx; + return create_context(dpy, xmvis, + shareCtx ? shareCtx->xmesaContext : NULL, + direct); } @@ -2315,32 +2308,18 @@ glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, - int render_type, GLXContext share_list, + int renderType, GLXContext shareCtx, Bool direct) { XMesaVisual xmvis = (XMesaVisual) config; - GLXContext glxCtx; - GLXContext shareCtx = share_list; - glxCtx = CALLOC_STRUCT(__GLXcontextRec); - if (!glxCtx) + if (!dpy || !config || + (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) return 0; - /* deallocate unused windows/buffers */ - XMesaGarbageCollect(); - - glxCtx->xmesaContext = XMesaCreateContext(xmvis, - shareCtx ? shareCtx->xmesaContext : NULL); - if (!glxCtx->xmesaContext) { - free(glxCtx); - return NULL; - } - - glxCtx->isDirect = DEFAULT_DIRECT; - glxCtx->currentDpy = dpy; - glxCtx->xid = (XID) glxCtx; /* self pointer */ - - return glxCtx; + return create_context(dpy, xmvis, + shareCtx ? shareCtx->xmesaContext : NULL, + direct); } |