Mesa (master): glx: Handle imported contexts outside of CreateContext

Ian Romanick idr at kemper.freedesktop.org
Wed Feb 17 19:44:23 UTC 2010


Module: Mesa
Branch: master
Commit: 2243029eeec9e31b92079ff0e8fafdc0315053d6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2243029eeec9e31b92079ff0e8fafdc0315053d6

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Feb  4 16:43:46 2010 -0800

glx: Handle imported contexts outside of CreateContext

A long time ago I was a bit over-agressive in refactoring context
creation into a single function.  The creation code for
glXImportContextEXT does not belong  in CreateContext because it does
not use any GLX protocol.  The big if-statement for the import case
routed around almost the entire function anyway.

---

 src/glx/glxcmds.c |   26 ++++++++++----------------
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 2eee005..48f7049 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -365,7 +365,7 @@ static GLXContext
 CreateContext(Display * dpy, XVisualInfo * vis,
               const __GLcontextModes * const fbconfig,
               GLXContext shareList,
-              Bool allowDirect, GLXContextID contextID,
+              Bool allowDirect,
 	      unsigned code, int renderType, int screen)
 {
    GLXContext gc;
@@ -382,7 +382,6 @@ CreateContext(Display * dpy, XVisualInfo * vis,
    if (!gc)
       return NULL;
 
-   if (None == contextID) {
       if ((vis == NULL) && (fbconfig == NULL))
          return NULL;
 
@@ -489,11 +488,6 @@ CreateContext(Display * dpy, XVisualInfo * vis,
       UnlockDisplay(dpy);
       SyncHandle();
       gc->imported = GL_FALSE;
-   }
-   else {
-      gc->xid = contextID;
-      gc->imported = GL_TRUE;
-   }
 
    gc->renderType = renderType;
 
@@ -504,7 +498,7 @@ PUBLIC GLXContext
 glXCreateContext(Display * dpy, XVisualInfo * vis,
                  GLXContext shareList, Bool allowDirect)
 {
-   return CreateContext(dpy, vis, NULL, shareList, allowDirect, None,
+   return CreateContext(dpy, vis, NULL, shareList, allowDirect,
                         X_GLXCreateContext, 0, vis->screen);
 }
 
@@ -1754,14 +1748,14 @@ glXImportContextEXT(Display * dpy, GLXContextID contextID)
       return NULL;
    }
 
-   /* FIXME: Why does this call CreateContext?  There is no protocol sent for
-    * FIXME: this function.
-    */
-   ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID,
-		       X_GLXCreateContext, 0, 0);
+   ctx = AllocateGLXContext(dpy);
    if (NULL != ctx) {
+      ctx->xid = contextID;
+      ctx->imported = GL_TRUE;
+
       if (Success != __glXQueryContextInfo(dpy, ctx)) {
-         return NULL;
+	 __glXFreeContext(ctx);
+	 ctx = NULL;
       }
    }
    return ctx;
@@ -1811,7 +1805,7 @@ glXCreateNewContext(Display * dpy, GLXFBConfig config,
       (const __GLcontextModes *const) config;
 
    return CreateContext(dpy, NULL, fbconfig, shareList,
-                        allowDirect, None, X_GLXCreateNewContext, renderType,
+                        allowDirect, X_GLXCreateNewContext, renderType,
 			fbconfig->screen);
 }
 
@@ -2300,7 +2294,7 @@ glXCreateContextWithConfigSGIX(Display * dpy,
    if ((psc != NULL)
        && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
       gc = CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList,
-                         allowDirect, None,
+                         allowDirect,
 			 X_GLXvop_CreateContextWithConfigSGIX, renderType,
 			 fbconfig->screen);
    }




More information about the mesa-commit mailing list