[Xquartz-changes] [273] AppleSGLX/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 27 13:21:34 PST 2009


Revision: 273
          http://trac.macosforge.org/projects/xquartz/changeset/273
Author:   gstaplin at apple.com
Date:     2009-02-27 13:21:33 -0800 (Fri, 27 Feb 2009)
Log Message:
-----------
Move the special case for the same drawable up in the 
apple_glx_make_current_context path.  This may improve
performance a bit, but hasn't seemed to make a difference
in reality.

Also cleanup the glXSwapBuffers path a bit.  There were
some old #if 0, and also don't abort() if the GLXContext
doesn't exist, just let a GLXBadCurrentWindow be sent.

Modified Paths:
--------------
    AppleSGLX/trunk/apple_glx.c
    AppleSGLX/trunk/apple_glx_context.c
    AppleSGLX/trunk/glxcmds.c

Modified: AppleSGLX/trunk/apple_glx.c
===================================================================
--- AppleSGLX/trunk/apple_glx.c	2009-02-27 20:33:57 UTC (rev 272)
+++ AppleSGLX/trunk/apple_glx.c	2009-02-27 21:21:33 UTC (rev 273)
@@ -152,16 +152,7 @@
 
 void apple_glx_swap_buffers(void *ptr) {
     struct apple_glx_context *ac = ptr;
-    assert(NULL != ac);
-
     glFlush();
-
-#if 0    
-    if(XAppleDRISwapBuffers(ac->apple_glx_drawable->display,
-			    ac->screen, ac->apple_glx_drawable->drawable))
-	return;
-#endif
-    
     apple_cgl.flush_drawable(ac->context_obj);
 }
 

Modified: AppleSGLX/trunk/apple_glx_context.c
===================================================================
--- AppleSGLX/trunk/apple_glx_context.c	2009-02-27 20:33:57 UTC (rev 272)
+++ AppleSGLX/trunk/apple_glx_context.c	2009-02-27 21:21:33 UTC (rev 273)
@@ -267,6 +267,7 @@
     CGLError cglerr;
     bool same_drawable = false;
 
+#if 0
     apple_glx_diagnostic("%s: oldac %p ac %p drawable 0x%lx\n",
 			 __func__, (void *)oldac, (void *)ac,
 			 drawable);
@@ -275,9 +276,16 @@
 			__func__, 
 			(void *)(oldac ? oldac->context_obj : NULL),
 			(void *)(ac ? ac->context_obj : NULL));
+#endif
 
-    assert(NULL != dpy);
-
+    /* This a common path for GLUT and other apps, so special case it. */
+    if(ac && ac->drawable && ac->drawable->drawable == drawable) {
+	same_drawable = true;
+	
+	if(ac->is_current)
+	    return false;
+    }
+    
     /* Reset the is_current state of the old context, if non-NULL. */
     if(oldac && (ac != oldac))
 	oldac->is_current = false;
@@ -322,9 +330,6 @@
 	/* Find the drawable if possible, and retain a reference to it. */
 	newagd = apple_glx_drawable_find(drawable, APPLE_GLX_DRAWABLE_REFERENCE);
     }
-
-    if(ac->drawable && ac->drawable == newagd)
-	same_drawable = true;
     
     /*
      * Try to destroy the old drawable, so long as the new one
@@ -401,8 +406,6 @@
 bool apple_glx_is_current_drawable(void *ptr, GLXDrawable drawable) {
     struct apple_glx_context *ac = ptr;
 
-    assert(NULL != ac);
-    
     return (ac->drawable && ac->drawable->drawable == drawable);
 }
 

Modified: AppleSGLX/trunk/glxcmds.c
===================================================================
--- AppleSGLX/trunk/glxcmds.c	2009-02-27 20:33:57 UTC (rev 272)
+++ AppleSGLX/trunk/glxcmds.c	2009-02-27 21:21:33 UTC (rev 273)
@@ -609,13 +609,8 @@
 
 PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) {
     GLXContext gc = glXGetCurrentContext();
-
-    if(NULL == gc || NULL == gc->apple) {
-	fprintf(stderr, "%s: invalid context\n", __func__);
-	abort();
-    }
-
-    if(apple_glx_is_current_drawable(gc->apple, drawable)) {
+    
+    if(gc && apple_glx_is_current_drawable(gc->apple, drawable)) {
 	apple_glx_swap_buffers(gc->apple);
     } else {
 	__glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/xquartz-changes/attachments/20090227/69135772/attachment.html>


More information about the Xquartz-changes mailing list