xserver: Branch 'server-1.6-branch' - 11 commits

Eric Anholt anholt at kemper.freedesktop.org
Fri Jan 30 16:53:58 PST 2009


 dix/main.c                          |   14 
 exa/exa_glyphs.c                    |    9 
 hw/xquartz/GL/indirect.c            | 1122 +++++++++---------------------------
 hw/xquartz/X11Application.m         |   12 
 hw/xquartz/X11Controller.m          |   17 
 hw/xquartz/bundle/Makefile.am       |    5 
 hw/xquartz/bundle/mk_bundke.sh      |   16 
 hw/xquartz/darwinEvents.c           |    4 
 hw/xquartz/darwinEvents.h           |    3 
 hw/xquartz/mach-startup/Makefile.am |    4 
 hw/xquartz/xpr/dri.c                |  207 ++++--
 include/Makefile.am                 |    2 
 include/dix-config-apple-verbatim.h |    8 
 include/dix-config.h.in             |    6 
 mi/mieq.c                           |   25 
 15 files changed, 500 insertions(+), 954 deletions(-)

New commits:
commit 840b4da5f29e43ccadc720f075e00237d12ef01b
Author: George Staplin <gstaplin at apple.com>
Date:   Mon Jan 26 03:02:38 2009 -0700

    XQuartz: GL: indirect.c changes to fix the build with newer OpenGL frameworks.
    (cherry picked from commit 143224405ba74929c702a95de52b56df140b0d1b)

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 9ddc0e7..01cf0c6 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -37,6 +37,13 @@
 
 #include "dri.h"
 
+#include <AvailabilityMacros.h>
+
+/*  
+ * These define seem questionable to me, but I'm not sure why they were here
+ * in the first place.
+ */ 
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
 #define GL_EXT_histogram 1
 #define GL_EXT_polygon_offset 1
 #define GL_SGIS_pixel_texture 1
@@ -53,6 +60,7 @@
 #define GL_APPLE_fence 1
 #define GL_IBM_multimode_draw_arrays 1
 #define GL_EXT_fragment_shader 1
+#endif
 
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/CGLContext.h>
@@ -904,12 +912,16 @@ static void setup_dispatch_table(void) {
   SET_ColorTable(disp, glColorTable);
   SET_ColorTableParameterfv(disp, glColorTableParameterfv);
   SET_ColorTableParameteriv(disp, glColorTableParameteriv);
+
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
   SET_CombinerInputNV(disp, glCombinerInputNV);
   SET_CombinerOutputNV(disp, glCombinerOutputNV);
   SET_CombinerParameterfNV(disp, glCombinerParameterfNV);
   SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV);
   SET_CombinerParameteriNV(disp, glCombinerParameteriNV);
   SET_CombinerParameterivNV(disp, glCombinerParameterivNV);
+#endif
   SET_CompileShaderARB(disp, glCompileShaderARB);
   SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB);
   SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB);
@@ -987,7 +999,10 @@ static void setup_dispatch_table(void) {
   SET_EvalPoint2(disp, glEvalPoint2);
 //SET_ExecuteProgramNV(disp, glExecuteProgramNV);
   SET_FeedbackBuffer(disp, glFeedbackBuffer);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
   SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV);
+#endif
   SET_Finish(disp, glFinish);
   SET_FinishFenceNV(disp, glFinishFenceAPPLE);       // <-- APPLE -> NV
   SET_Flush(disp, glFlush);
@@ -1029,10 +1044,12 @@ static void setup_dispatch_table(void) {
   SET_GetColorTable(disp, glGetColorTable);
   SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv);
   SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv);
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
   SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV);
   SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV);
   SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV);
   SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV);
+#endif
   SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB);
   SET_GetConvolutionFilter(disp, glGetConvolutionFilter);
   SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv);
@@ -1040,8 +1057,10 @@ static void setup_dispatch_table(void) {
   SET_GetDoublev(disp, glGetDoublev);
   SET_GetError(disp, glGetError);
 //SET_GetFenceivNV(disp, glGetFenceivNV);
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
   SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV);
   SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV);
+#endif
   SET_GetFloatv(disp, glGetFloatv);
   SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT);
   SET_GetHandleARB(disp, glGetHandleARB);
commit 97a6f55f221e3d470add18db80e3769713480103
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 16 19:26:07 2009 -0800

    XQuartz: SnowLeopard: Help system book name changed in 10.6
    (cherry picked from commit b57cb05c69acbedb00a97234099ea104309aa2cb)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 9b30fa6..adf861c 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -687,18 +687,19 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
     [prefs_panel makeKeyAndOrderFront:sender];
 }
 
-- (IBAction) quit:sender
-{
-  DarwinSendDDXEvent(kXquartzQuit, 0);
+- (IBAction) quit:sender {
+    DarwinSendDDXEvent(kXquartzQuit, 0);
 }
 
-- (IBAction) x11_help:sender
-{
-  AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
+- (IBAction) x11_help:sender {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+    AHLookupAnchor((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR("mchlp2276"));
+#else
+    AHLookupAnchor(CFSTR("com.apple.machelp"), CFSTR("mchlp2276"));
+#endif
 }
 
-- (OSX_BOOL) validateMenuItem:(NSMenuItem *)item
-{
+- (OSX_BOOL) validateMenuItem:(NSMenuItem *)item {
   NSMenu *menu = [item menu];
     
   if (item == toggle_fullscreen_item)
commit e81b4d495ba02d4fc0b05c26a53fd2a816a61eaa
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 16 13:54:08 2009 -0800

    XQuartz: mieq: Wait for the server to finish initializing before letting other threads mieqEnqueue
    
    Avoid possible race condition whereby one thread might call mieqEnqueue before InitAndStartDevices finishes
    (cherry picked from commit 94e417ac87a98cd5c6bf2d7c495d702748398931)

diff --git a/dix/main.c b/dix/main.c
index ee2e10d..0527621 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -234,6 +234,12 @@ static int indexForScanlinePad[ 65 ] = {
 #endif
 
 #ifdef XQUARTZ
+#include <pthread.h>
+
+BOOL serverInitComplete = FALSE;
+pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+
 int dix_main(int argc, char *argv[], char *envp[])
 #else
 int main(int argc, char *argv[], char *envp[])
@@ -378,6 +384,14 @@ int main(int argc, char *argv[], char *envp[])
 	    }
 	}
 
+#ifdef XQUARTZ
+    /* Let the other threads know the server is done with its init */
+    pthread_mutex_lock(&serverInitCompleteMutex);
+    serverInitComplete = TRUE;
+    pthread_cond_broadcast(&serverInitCompleteCond);
+    pthread_mutex_unlock(&serverInitCompleteMutex);
+#endif
+        
 	NotifyParentProcess();
 
 	Dispatch();
diff --git a/mi/mieq.c b/mi/mieq.c
index 15ba8e7..8d68ca1 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -36,11 +36,6 @@ in this Software without prior written authorization from The Open Group.
 #include <dix-config.h>
 #endif
 
-#ifdef XQUARTZ
-#include  <pthread.h>
-static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
-
 # define NEED_EVENTS
 # include   <X11/X.h>
 # include   <X11/Xmd.h>
@@ -87,6 +82,25 @@ typedef struct _EventQueue {
 static EventQueueRec miEventQueue;
 static EventListPtr masterEvents; /* for use in mieqProcessInputEvents */
 
+#ifdef XQUARTZ
+#include  <pthread.h>
+static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
+
+extern BOOL serverInitComplete;
+extern pthread_mutex_t serverInitCompleteMutex;
+extern pthread_cond_t serverInitCompleteCond;
+
+static inline void wait_for_server_init(void) {
+    /* If the server hasn't finished initializing, wait for it... */
+    if(!serverInitComplete) {
+        pthread_mutex_lock(&serverInitCompleteMutex);
+        while(!serverInitComplete)
+            pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
+        pthread_mutex_unlock(&serverInitCompleteMutex);
+    }
+}
+#endif
+
 Bool
 mieqInit(void)
 {
@@ -145,6 +159,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
     int                    evlen;
 
 #ifdef XQUARTZ
+    wait_for_server_init();
     pthread_mutex_lock(&miEventQueueMutex);
 #endif
 
commit d6498ea62117cce6a00ac045ddeefb7268a70f5b
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jan 30 16:17:58 2009 -0800

    Move the apple fat binary hacks back to a header file, and make it apple-only.
    (cherry picked from commit dd098501d800571e71d06ffc936635a6c9d44e05)

diff --git a/configure.ac b/configure.ac
index a90d400..da5f488 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,9 +39,7 @@ dnl drivers.
 AC_CONFIG_HEADERS(include/xorg-server.h)
 dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
 dnl dix/).
-AC_CONFIG_HEADERS(include/dix-config.h, [mv include/dix-config.h include/dix-config.h.tmp
-                                         sed 's|/undef|#undef|' < include/dix-config.h.tmp > include/dix-config.h
-                                         rm include/dix-config.h.tmp])
+AC_CONFIG_HEADERS(include/dix-config.h)
 dnl xorg-config.h covers the Xorg DDX.
 AC_CONFIG_HEADERS(include/xorg-config.h)
 dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
diff --git a/include/Makefile.am b/include/Makefile.am
index f6b3670..cb0b293 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -62,3 +62,5 @@ endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
 
+EXTRA_DIST = 	\
+	dix-config-apple-verbatim.h
diff --git a/include/dix-config-apple-verbatim.h b/include/dix-config-apple-verbatim.h
new file mode 100644
index 0000000..f429d20
--- /dev/null
+++ b/include/dix-config-apple-verbatim.h
@@ -0,0 +1,8 @@
+/* Do not include this file directly.  It is included at the end of <dix-config.h> */
+
+/* Correctly set _XSERVER64 for OSX fat binaries */
+#if defined(__LP64__) && !defined(_XSERVER64)
+#define _XSERVER64 1
+#elif !defined(__LP64__) && defined(_XSERVER64)
+#undef _XSERVER64
+#endif
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index e1d226c..2515d83 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -431,12 +431,7 @@
 
 /* Correctly set _XSERVER64 for OSX fat binaries */
 #ifdef __APPLE__
-#if defined(__LP64__) && !defined(_XSERVER64)
-#define _XSERVER64 1
-#elif !defined(__LP64__) && defined(_XSERVER64)
-/* configure mangles #undef, so we fix this in AC_CONFIG_HEADERS post process */
-/undef _XSERVER64
-#endif
+#include "dix-config-apple-verbatim.h"
 #endif
 
 #endif /* _DIX_CONFIG_H_ */
commit b530a0e97b5737375ca1f4eced26d587a16f843f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Jan 15 20:57:42 2009 -0800

    XQuartz: Fix builddir != srcdir issues and undef _XSERVER64 where appropriate on fat binary compilation
    (cherry picked from commit f020900641b44a1142e5c2198e9678de2744454e)

diff --git a/configure.ac b/configure.ac
index da5f488..a90d400 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,7 +39,9 @@ dnl drivers.
 AC_CONFIG_HEADERS(include/xorg-server.h)
 dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
 dnl dix/).
-AC_CONFIG_HEADERS(include/dix-config.h)
+AC_CONFIG_HEADERS(include/dix-config.h, [mv include/dix-config.h include/dix-config.h.tmp
+                                         sed 's|/undef|#undef|' < include/dix-config.h.tmp > include/dix-config.h
+                                         rm include/dix-config.h.tmp])
 dnl xorg-config.h covers the Xorg DDX.
 AC_CONFIG_HEADERS(include/xorg-config.h)
 dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 03fa1dd..963327b 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -5,7 +5,10 @@ CPP_FILES_FLAGS = \
 	-DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
 
 install-data-hook:
-	./mk_bundke.sh $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app
+	$(srcdir)/mk_bundke.sh $(srcdir) $(builddir) $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app install
+
+uninstall-hook:
+	$(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app	
 
 noinst_PRE = Info.plist.cpp
 noinst_DATA = $(noinst_PRE:plist.cpp=plist)
diff --git a/hw/xquartz/bundle/mk_bundke.sh b/hw/xquartz/bundle/mk_bundke.sh
index 7c8d148..c85b217 100755
--- a/hw/xquartz/bundle/mk_bundke.sh
+++ b/hw/xquartz/bundle/mk_bundke.sh
@@ -2,7 +2,9 @@
 #
 # 'Cause xcodebuild is hard to deal with
 
-BUNDLE_ROOT=$1
+SRCDIR=$1
+BUILDDIR=$2
+BUNDLE_ROOT=$3
 
 localities="Dutch English French German Italian Japanese Spanish da fi ko no pl pt pt_PT ru sv zh_CN zh_TW"
 for lang in ${localities} ; do
@@ -10,18 +12,18 @@ for lang in ${localities} ; do
     [ -d ${BUNDLE_ROOT}/Contents/Resources/${lang}.lproj/main.nib ] || exit 1
 
     for f in InfoPlist.strings Localizable.strings main.nib/keyedobjects.nib ; do
-        install -m 644 Resources/${lang}.lproj/$f ${BUNDLE_ROOT}/Contents/Resources/${lang}.lproj/${f}
+        install -m 644 ${SRCDIR}/Resources/${lang}.lproj/$f ${BUNDLE_ROOT}/Contents/Resources/${lang}.lproj/${f}
     done
 done
 
-install -m 644 Resources/English.lproj/main.nib//designable.nib ${BUNDLE_ROOT}/Contents/Resources/English.lproj/main.nib
-install -m 644 Resources/X11.icns ${BUNDLE_ROOT}/Contents/Resources
+install -m 644 ${SRCDIR}/Resources/English.lproj/main.nib//designable.nib ${BUNDLE_ROOT}/Contents/Resources/English.lproj/main.nib
+install -m 644 ${SRCDIR}/Resources/X11.icns ${BUNDLE_ROOT}/Contents/Resources
 
-install -m 644 Info.plist ${BUNDLE_ROOT}/Contents
-install -m 644 PkgInfo ${BUNDLE_ROOT}/Contents
+install -m 644 ${BUILDDIR}/Info.plist ${BUNDLE_ROOT}/Contents
+install -m 644 ${SRCDIR}/PkgInfo ${BUNDLE_ROOT}/Contents
 
 mkdir -p ${BUNDLE_ROOT}/Contents/MacOS
-install -m 755 X11.sh ${BUNDLE_ROOT}/Contents/MacOS/X11
+install -m 755 ${SRCDIR}/X11.sh ${BUNDLE_ROOT}/Contents/MacOS/X11
 
 if [[ $(id -u) == 0 ]] ; then
 	chown -R root:admin ${BUNDLE_ROOT}
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 40060d0..b011294 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -65,8 +65,8 @@ BUILT_SOURCES = \
 CLEANFILES = \
 	$(BUILT_SOURCES)
 
-$(BUILT_SOURCES): mach_startup.defs
-	mig -sheader mach_startupServer.h mach_startup.defs
+$(BUILT_SOURCES): $(srcdir)/mach_startup.defs
+	mig -sheader mach_startupServer.h $(srcdir)/mach_startup.defs
 
 EXTRA_DIST = \
 	launchd_fd.h \
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 8e047c4..e1d226c 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -434,7 +434,8 @@
 #if defined(__LP64__) && !defined(_XSERVER64)
 #define _XSERVER64 1
 #elif !defined(__LP64__) && defined(_XSERVER64)
-#undef _XSERVER64
+/* configure mangles #undef, so we fix this in AC_CONFIG_HEADERS post process */
+/undef _XSERVER64
 #endif
 #endif
 
commit 82fd4d170824068dddf3b4e6581a12d48e1a069a
Author: George Staplin <gstaplin at apple.com>
Date:   Mon Jan 12 19:30:43 2009 -0700

    XQuartz: xpr: Cleanup some of the code and possibly fix part of the GLX Pixmap problem.
    
    Split DRICreateSurface into 3 functions.
    
    Make CreateSurfaceForPixmap use xp_configure_surface.  I suspect this is partly why
    GLXPixmaps never worked.
    
    It will require some more work and thoughts for pbuffers, unless we fake those with
    pixmaps and surfaces.
    (cherry picked from commit 9cf264e67744262b9f45079e6cd752eb3e3b0e08)

diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 8feba7e..50b478b 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -346,6 +346,121 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
     xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
 }
 
+/* Return NULL if an error occurs. */
+static DRIDrawablePrivPtr
+CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) {
+    DRIDrawablePrivPtr pDRIDrawablePriv;
+    xp_window_id wid = 0;
+
+    *widPtr = 0;
+
+    pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+    if (pDRIDrawablePriv == NULL) {
+	xp_error err;
+	xp_window_changes wc;
+	
+	/* allocate a DRI Window Private record */
+	if (!(pDRIDrawablePriv = xalloc(sizeof(*pDRIDrawablePriv)))) {
+	    return NULL;
+	}
+	
+	pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
+	pDRIDrawablePriv->pScreen = pScreen;
+	pDRIDrawablePriv->refCount = 0;
+	pDRIDrawablePriv->drawableIndex = -1;
+	pDRIDrawablePriv->notifiers = NULL;
+	
+	/* find the physical window */
+	wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
+
+	if (wid == 0) {
+	    xfree(pDRIDrawablePriv);
+	    return NULL;
+	}
+	
+	/* allocate the physical surface */
+	err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
+
+	if (err != Success) {
+	    xfree(pDRIDrawablePriv);
+	    return NULL;
+	}
+
+	/* Make it visible */
+	wc.stack_mode = XP_MAPPED_ABOVE;
+	wc.sibling = 0;
+	err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
+
+	if (err != Success) {
+	    xp_destroy_surface(pDRIDrawablePriv->sid);
+	    xfree(pDRIDrawablePriv);
+	    return NULL;
+	}
+
+	/* save private off of preallocated index */
+	dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+		      pDRIDrawablePriv);
+    }
+
+    *widPtr = wid;
+
+    return pDRIDrawablePriv;
+}
+
+/* Return FALSE if an error occurs. */
+static DRIDrawablePrivPtr
+CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) {
+    DRIDrawablePrivPtr pDRIDrawablePriv;
+     
+    pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+
+    if (pDRIDrawablePriv == NULL) {
+	xp_error err;
+	xp_window_changes wc;
+
+	/* allocate a DRI Window Private record */
+	if (!(pDRIDrawablePriv = xcalloc(1, sizeof(*pDRIDrawablePriv)))) {
+	    return NULL;
+	}
+	
+	pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
+	pDRIDrawablePriv->pScreen = pScreen;
+	pDRIDrawablePriv->refCount = 0;
+	pDRIDrawablePriv->drawableIndex = -1;
+	pDRIDrawablePriv->notifiers = NULL;
+	
+	/* Passing a null window id to Xplugin in 10.3+ asks for
+	   an accelerated offscreen surface. */
+	
+	err = xp_create_surface(0, &pDRIDrawablePriv->sid);
+	if (err != Success) {
+	    xfree(pDRIDrawablePriv);
+	    return NULL;
+	}
+
+	wc.x = 0;
+        wc.y = 0;
+        wc.width = pPix->drawable.width;
+        wc.height = pPix->drawable.height;
+
+	err = xp_configure_surface(pDRIDrawablePriv->sid, XP_BOUNDS, &wc);
+
+	if(err != Success) {
+	    xp_destroy_surface(pDRIDrawablePriv->sid);
+	    xfree(pDRIDrawablePriv);
+	    return NULL;
+	}
+
+	/* save private off of preallocated index */
+	dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
+		      pDRIDrawablePriv);
+    }
+    
+    return pDRIDrawablePriv;
+}
+
+
 Bool
 DRICreateSurface(ScreenPtr pScreen, Drawable id,
                  DrawablePtr pDrawable, xp_client_id client_id,
@@ -353,107 +468,39 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
                  void (*notify) (void *arg, void *data), void *notify_data)
 {
     DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    DRIDrawablePrivPtr  pDRIDrawablePriv;
     xp_window_id        wid = 0;
+    DRIDrawablePrivPtr  pDRIDrawablePriv;
 
     if (pDrawable->type == DRAWABLE_WINDOW) {
-        WindowPtr pWin = (WindowPtr)pDrawable;
-
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-        if (pDRIDrawablePriv == NULL) {
-            xp_error err;
-            xp_window_changes wc;
-
-            /* allocate a DRI Window Private record */
-            if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
-                return FALSE;
-            }
-
-            pDRIDrawablePriv->pDraw = pDrawable;
-            pDRIDrawablePriv->pScreen = pScreen;
-            pDRIDrawablePriv->refCount = 0;
-            pDRIDrawablePriv->drawableIndex = -1;
-            pDRIDrawablePriv->notifiers = NULL;
-
-            /* find the physical window */
-            wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
-            if (wid == 0) {
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* allocate the physical surface */
-            err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
-            if (err != Success) {
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* Make it visible */
-            wc.stack_mode = XP_MAPPED_ABOVE;
-            wc.sibling = 0;
-            err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
-            if (err != Success)
-            {
-                xp_destroy_surface(pDRIDrawablePriv->sid);
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
+	pDRIDrawablePriv = CreateSurfaceForWindow(pScreen, 
+						  (WindowPtr)pDrawable, &wid);
 
-            /* save private off of preallocated index */
-	    dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
-			  pDRIDrawablePriv);
-        }
+	if(NULL == pDRIDrawablePriv)
+	    return FALSE; /*error*/
     }
-
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
     else if (pDrawable->type == DRAWABLE_PIXMAP) {
-        PixmapPtr pPix = (PixmapPtr)pDrawable;
-
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
-        if (pDRIDrawablePriv == NULL) {
-            xp_error err;
+	pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen, 
+						  (PixmapPtr)pDrawable);
 
-            /* allocate a DRI Window Private record */
-            if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) {
-                return FALSE;
-            }
-
-            pDRIDrawablePriv->pDraw = pDrawable;
-            pDRIDrawablePriv->pScreen = pScreen;
-            pDRIDrawablePriv->refCount = 0;
-            pDRIDrawablePriv->drawableIndex = -1;
-            pDRIDrawablePriv->notifiers = NULL;
-
-            /* Passing a null window id to Xplugin in 10.3+ asks for
-               an accelerated offscreen surface. */
-
-            err = xp_create_surface(0, &pDRIDrawablePriv->sid);
-            if (err != Success) {
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* save private off of preallocated index */
-	    dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
-			  pDRIDrawablePriv);
-        }
+	if(NULL == pDRIDrawablePriv)
+	    return FALSE; /*error*/
     }
 #endif
-
     else { /* for GLX 1.3, a PBuffer */
         /* NOT_DONE */
         return FALSE;
     }
 
+    
+
     /* Finish initialization of new surfaces */
     if (pDRIDrawablePriv->refCount == 0) {
         unsigned int key[2] = {0};
         xp_error err;
 
         /* try to give the client access to the surface */
-        if (client_id != 0 && wid != 0)
-        {
+        if (client_id != 0 && wid != 0) {
             err = xp_export_surface(wid, pDRIDrawablePriv->sid,
                                     client_id, key);
             if (err != Success) {
commit 9cbdcf1fa4bdcc115def9f134a57ac96a56c69dd
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Jan 11 14:49:39 2009 -0800

    XQuartz: Only call DarwinUpdateModKeys when needed
    
    Previously, we were calling it on almost every itteration through sendX11Event
    (cherry picked from commit 6461729647ff4441d80811e73f0c0d2f108f2700)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index ec58ab1..9f4738c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -65,6 +65,7 @@ extern BOOL xpbproxy_init (void);
 
 /* Stuck modifier / button state... force release when we context switch */
 static NSEventType keyState[NUM_KEYCODES];
+static int modifierFlagsMask;
 
 int X11EnableKeyEquivalents = TRUE, quartzFullscreenMenu = FALSE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
@@ -200,7 +201,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
         }
     } else {
 
-        DarwinUpdateModKeys(0);
+        if(darwin_modifier_flags)
+            DarwinUpdateModKeys(0);
         for(i=0; i < NUM_KEYCODES; i++) {
             if(keyState[i] == NSKeyDown) {
                 DarwinSendKeyboardEvents(KeyRelease, i);
@@ -872,6 +874,7 @@ environment the next time you start X11?", @"Startup xinitrc dialog");
 
 void X11ApplicationMain (int argc, char **argv, char **envp) {
     NSAutoreleasePool *pool;
+    int *p;
 
 #ifdef DEBUG
     while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
@@ -916,6 +919,10 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
         fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n");
     }
 
+    for(p=darwin_modifier_mask_list, modifierFlagsMask=0; *p; p++) {
+        modifierFlagsMask |= *p;
+    }
+    
     /* Tell the server thread that it can proceed */
     QuartzInitServer(argc, argv, envp);
     
@@ -932,7 +939,6 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
 }
 
 @implementation X11Application (Private)
-extern int darwin_modifier_flags; // darwinEvents.c
 
 #ifdef NX_DEVICELCMDKEYMASK
 /* This is to workaround a bug in the VNC server where we sometimes see the L
@@ -987,6 +993,8 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
     modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK   | NX_DEVICERALTKEYMASK,     NX_DEVICELALTKEYMASK);
 #endif
 
+    modifierFlags &= modifierFlagsMask;
+
     /* We don't receive modifier key events while out of focus, and 3button
      * emulation mucks this up, so we need to check our modifier flag state
      * on every event... ugg
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 1863eff..89d2233 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -146,7 +146,7 @@ static void DarwinPressModifierKey(int pressed, int key) {
  *  Send events to update the modifier state.
  */
 
-static int modifier_mask_list[] = {
+int darwin_modifier_mask_list[] = {
 #ifdef NX_DEVICELCMDKEYMASK
     NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
     NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
@@ -173,7 +173,7 @@ static void DarwinUpdateModifiers(
         DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK);
     }
     
-    for(f=modifier_mask_list; *f; f++)
+    for(f=darwin_modifier_mask_list; *f; f++)
         if(*f & flags) {
             key = DarwinModifierNXMaskToNXKey(*f);
             if(key == -1)
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 2f1d9ff..9ec3bda 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -78,4 +78,7 @@ enum {
 /* Send one of the above events to the server thread. */
 void DarwinSendDDXEvent(int type, int argc, ...);
 
+extern int darwin_modifier_mask_list[];
+extern int darwin_modifier_flags;
+
 #endif  /* _DARWIN_EVENTS_H */
commit 037e52fd7353410397dfd877b3e9af99f791fce1
Author: George Staplin <gstaplin at apple.com>
Date:   Mon Jan 12 14:14:44 2009 -0700

    XQuartz: GL: Make indirect.c build and work in the 1.6 branch.
    
    Reorder some header files and provide some types earlier on.
    
    Remove the static __GLXextensionInfo __glDDXExtensionInfo; that isn't
    used in 1.4 or 1.5, and seems to have been removed from 1.6.  Remove
    the data structures associated with that too.
    
    Remove __glXAquaDrawableResize.  The GLX structure doesn't use
    it anymore, and the Apple version did nothing useful before.
    
    __glXAquaDrawableSwapBuffers(): base no longer contains a drawGlxc
    member.  Now provide the the Apple/Aqua context in the __GLXAquaDrawable
    struct.  Add the context member to the __GLXAquaDrawable struct.
    
    Remove the fallback configs.  They aren't used in 1.4 or 1.5 either.
    
    Remove init_visuals().  It's not used in 1.4 or 1.5 either.
    
    In the drawable constructor initialize the state properly, including
    the new context member.
    
    Remove glAquaResetExtension() -- it's not used anymore.
    
    This has been tested remotely and proven to work with glxgears,
    fire, various texture programs I wrote, and various Mesa demos.
    (cherry picked from commit d514152195452ae11ec7769c76489651620ad380)

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index afaa957..9ddc0e7 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -57,7 +57,6 @@
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/CGLContext.h>
 
-// X11 and X11's glx
 #include <GL/gl.h>
 #include <GL/glxproto.h>
 #include <windowstr.h>
@@ -78,16 +77,13 @@
 
 #include "capabilities.h"
 
-#include <dispatch.h>
-#define GLAPIENTRYP *
 typedef unsigned long long GLuint64EXT;
 typedef long long GLint64EXT;
+#include <dispatch.h>
 #include <Xplugin.h>
 #include <glapi.h>
 #include <glapitable.h>
 
-// ggs: needed to call back to glx with visual configs
-extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
 __GLXprovider * GlxGetDRISWrastProvider (void);
 
 // Write debugging output, or not
@@ -105,15 +101,6 @@ void warn_func(void * p1, char *format, ...);
 static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen);
 static __GLXdrawable * __glXAquaScreenCreateDrawable(__GLXscreen *screen, DrawablePtr pDraw, int type, XID drawId, __GLXconfig *conf);
 
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
-                              int *nvisualp, int *ndepthp,
-                              int *rootDepthp, VisualID *defaultVisp,
-                              unsigned long sizes, int bitsPerRGB);
-
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
-                                   void **privates);
-
-static void glAquaResetExtension(void);
 static void __glXAquaContextDestroy(__GLXcontext *baseContext);
 static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext);
 static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext);
@@ -123,16 +110,16 @@ static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, un
 static CGLPixelFormatObj makeFormat(__GLXconfig *conf);
 
 __GLXprovider __glXDRISWRastProvider = {
-  __glXAquaScreenProbe,
-  "Core OpenGL",
+    __glXAquaScreenProbe,
+    "Core OpenGL",
     NULL
 };
 
 __GLXprovider *
 GlxGetDRISWRastProvider (void)
 {
-  GLAQUA_DEBUG_MSG("GlxGetDRISWRastProvider\n");
-  return &__glXDRISWRastProvider;
+    GLAQUA_DEBUG_MSG("GlxGetDRISWRastProvider\n");
+    return &__glXDRISWRastProvider;
 }
 
 typedef struct __GLXAquaScreen   __GLXAquaScreen;
@@ -143,11 +130,8 @@ struct __GLXAquaScreen {
     __GLXscreen base;
     int index;
     int num_vis;
-    //__GLcontextModes *modes;
 };
 
-static __GLXAquaScreen glAquaScreens[MAXSCREENS];
-
 struct __GLXAquaContext {
     __GLXcontext base;
     CGLContextObj ctx;
@@ -160,71 +144,60 @@ struct __GLXAquaDrawable {
     __GLXdrawable base;
     DrawablePtr pDraw;
     xp_surface_id sid;
+    __GLXAquaContext *context;
 };
 
+
 static __GLXcontext *
 __glXAquaScreenCreateContext(__GLXscreen *screen,
 			     __GLXconfig *conf,
 			     __GLXcontext *baseShareContext)
 {
-  __GLXAquaContext *context;
-  __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
-  CGLError gl_err;
+    __GLXAquaContext *context;
+    __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
+    CGLError gl_err;
   
-  GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
-
-  context = xalloc (sizeof (__GLXAquaContext));
-
-  if (context == NULL)
-      return NULL;
-
-  memset(context, 0, sizeof *context);
-
-  context->base.pGlxScreen = screen;
-
-  context->base.destroy        = __glXAquaContextDestroy;
-  context->base.makeCurrent    = __glXAquaContextMakeCurrent;
-  context->base.loseCurrent    = __glXAquaContextLoseCurrent;
-  context->base.copy           = __glXAquaContextCopy;
-  context->base.forceCurrent   = __glXAquaContextForceCurrent;
-  /*FIXME verify that the context->base is fully initialized. */
-
-  context->pixelFormat = makeFormat(conf);
+    GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
+    
+    context = xalloc (sizeof (__GLXAquaContext));
+    
+    if (context == NULL)
+	return NULL;
 
-  if (!context->pixelFormat) {
+    memset(context, 0, sizeof *context);
+    
+    context->base.pGlxScreen = screen;
+    
+    context->base.destroy        = __glXAquaContextDestroy;
+    context->base.makeCurrent    = __glXAquaContextMakeCurrent;
+    context->base.loseCurrent    = __glXAquaContextLoseCurrent;
+    context->base.copy           = __glXAquaContextCopy;
+    context->base.forceCurrent   = __glXAquaContextForceCurrent;
+    /*FIXME verify that the context->base is fully initialized. */
+    
+    context->pixelFormat = makeFormat(conf);
+    
+    if (!context->pixelFormat) {
         xfree(context);
         return NULL;
-  }
-
-  context->ctx = NULL;
-  gl_err = CGLCreateContext(context->pixelFormat,
-                            shareContext ? shareContext->ctx : NULL,
-                            &context->ctx);
-
-  if (gl_err != 0) {
-      ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
-      CGLDestroyPixelFormat(context->pixelFormat);
-      xfree(context);
-      return NULL;
-  }
+    }
 
-  setup_dispatch_table();
-  GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
+    context->ctx = NULL;
+    gl_err = CGLCreateContext(context->pixelFormat,
+			      shareContext ? shareContext->ctx : NULL,
+			      &context->ctx);
     
-  return &context->base;
-}
-
-/* Nothing seems to use these anymore... */
-static __GLXextensionInfo __glDDXExtensionInfo = {
-    GL_CORE_APPLE,
-    glAquaResetExtension,
-    glAquaInitVisuals,
-    glAquaSetVisualConfigs
-};
-
-void *__glXglDDXExtensionInfo(void) {
-  GLAQUA_DEBUG_MSG("glXAglDDXExtensionInfo\n");
-    return &__glDDXExtensionInfo;
+    if (gl_err != 0) {
+	ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
+	CGLDestroyPixelFormat(context->pixelFormat);
+	xfree(context);
+	return NULL;
+    }
+    
+    setup_dispatch_table();
+    GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
+    
+    return &context->base;
 }
 
 /* maps from surface id -> list of __GLcontext */
@@ -234,7 +207,7 @@ static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
     x_list *lst;
 
     __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
-
+    
     GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx 0x%x)\n",
                      (unsigned int) baseContext);
     if (context != NULL) {
@@ -275,33 +248,33 @@ static void surface_notify(void *_arg, void *data) {
     __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
     __GLXAquaContext *context;
     x_list *lst;
-	if(_arg == NULL || data == NULL) {
-		ErrorF("surface_notify called with bad params");
-		return;
-	}
+    if(_arg == NULL || data == NULL) {
+	    ErrorF("surface_notify called with bad params");
+	    return;
+    }
 	
     GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data);
     switch (arg->kind) {
     case AppleDRISurfaceNotifyDestroyed:
         if (surface_hash != NULL)
             x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
-	        draw->base.pDraw = NULL;
-			draw->sid = 0;
+	draw->base.pDraw = NULL;
+	draw->sid = 0;
         break;
 
     case AppleDRISurfaceNotifyChanged:
         if (surface_hash != NULL) {
             lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
             for (; lst != NULL; lst = lst->next)
-            {
+		{
                 context = lst->data;
                 xp_update_gl_context(context->ctx);
             }
         }
         break;
-	default:
-		ErrorF("surface_notify: unknown kind %d\n", arg->kind);
-		break;
+    default:
+	ErrorF("surface_notify: unknown kind %d\n", arg->kind);
+	break;
     }
 }
 
@@ -316,7 +289,7 @@ static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
     pDraw = draw->base.pDraw;
 
     if(NULL == pDraw) {
-	ErrorF("%s:attach() pDraw is NULL!\n", __FILE__);
+	ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__);
 	return TRUE;
     }
 
@@ -355,10 +328,14 @@ static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
             x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
         }
 	
+	
+
         GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
                          (unsigned int) draw->sid);
     } 
 
+    draw->context = context;
+
     return FALSE;
 }
 
@@ -434,27 +411,31 @@ static int __glXAquaContextForceCurrent(__GLXcontext *baseContext)
 
 /* Drawing surface notification callbacks */
 
-static GLboolean __glXAquaDrawableResize(__GLXdrawable *base)  {
-    GLAQUA_DEBUG_MSG("unimplemented glAquaDrawableResize\n");
-    return GL_TRUE;
-}
-
 static GLboolean __glXAquaDrawableSwapBuffers(__GLXdrawable *base) {
-    CGLError gl_err;
-    __GLXAquaContext * drawableCtx;
+    CGLError err;
+    __GLXAquaDrawable *drawable;
+ 
     //    GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base);
 	
     if(!base) {
-	ErrorF("glXAquaDrawbleSwapBuffers passed NULL\n");
+	ErrorF("%s passed NULL\n", __func__);
 	return GL_FALSE;
     }
 
-    drawableCtx = (__GLXAquaContext *)base->drawGlxc;
-    
-    if (drawableCtx != NULL && drawableCtx->ctx != NULL) {
-        gl_err = CGLFlushDrawable(drawableCtx->ctx);
-        if (gl_err != 0)
-            ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err));
+    drawable = (__GLXAquaDrawable *)base;
+
+    if(NULL == drawable->context) {
+	ErrorF("%s called with a NULL->context for drawable %p!\n",
+	       __func__, (void *)drawable);
+	return GL_FALSE;
+    }
+
+    err = CGLFlushDrawable(drawable->context->ctx);
+
+    if(kCGLNoError != err) {
+	ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err),
+	       __func__);
+	return GL_FALSE;
     }
 
     return GL_TRUE;
@@ -518,482 +499,6 @@ static CGLPixelFormatObj makeFormat(__GLXconfig *conf) {
     return fobj;
 }
 
-// Originally copied from Mesa
-
-static int                 numConfigs     = 0;
-static __GLXvisualConfig  *visualConfigs  = NULL;
-static void              **visualPrivates = NULL;
-
-/*
- * In the case the driver defines no GLX visuals we'll use these.
- * Note that for TrueColor and DirectColor visuals, bufferSize is the 
- * sum of redSize, greenSize, blueSize and alphaSize, which may be larger 
- * than the nplanes/rootDepth of the server's X11 visuals
- */
-#define NUM_FALLBACK_CONFIGS 5
-static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
-  /* [0] = RGB, double buffered, Z */
-  {
-    -1,                 /* vid */
-    -1,                 /* class */
-    True,               /* rgba */
-    -1, -1, -1, 0,      /* rgba sizes */
-    -1, -1, -1, 0,      /* rgba masks */
-     0,  0,  0, 0,      /* rgba accum sizes */
-    True,               /* doubleBuffer */
-    False,              /* stereo */
-    -1,                 /* bufferSize */
-    16,                 /* depthSize */
-    0,                  /* stencilSize */
-    0,                  /* auxBuffers */
-    0,                  /* level */
-    GLX_NONE,           /* visualRating */
-    GLX_NONE,           /* transparentPixel */
-    0, 0, 0, 0,         /* transparent rgba color (floats scaled to ints) */
-    0                   /* transparentIndex */
-  },
-  /* [1] = RGB, double buffered, Z, stencil, accum */
-  {
-    -1,                 /* vid */
-    -1,                 /* class */
-    True,               /* rgba */
-    -1, -1, -1, 0,      /* rgba sizes */
-    -1, -1, -1, 0,      /* rgba masks */
-    16, 16, 16, 0,      /* rgba accum sizes */
-    True,               /* doubleBuffer */
-    False,              /* stereo */
-    -1,                 /* bufferSize */
-    16,                 /* depthSize */
-    8,                  /* stencilSize */
-    0,                  /* auxBuffers */
-    0,                  /* level */
-    GLX_NONE,           /* visualRating */
-    GLX_NONE,           /* transparentPixel */
-    0, 0, 0, 0,         /* transparent rgba color (floats scaled to ints) */
-    0                   /* transparentIndex */
-  },
-  /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
-  {
-    -1,                 /* vid */
-    -1,                 /* class */
-    True,               /* rgba */
-    -1, -1, -1, 8,      /* rgba sizes */
-    -1, -1, -1, -1,     /* rgba masks */
-    16, 16, 16, 16,     /* rgba accum sizes */
-    True,               /* doubleBuffer */
-    False,              /* stereo */
-    -1,                 /* bufferSize */
-    16,                 /* depthSize */
-    8,                  /* stencilSize */
-    0,                  /* auxBuffers */
-    0,                  /* level */
-    GLX_NONE,           /* visualRating */
-    GLX_NONE,           /* transparentPixel */
-    0, 0, 0, 0,         /* transparent rgba color (floats scaled to ints) */
-    0                   /* transparentIndex */
-  },
-  /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
-  {
-    -1,                 /* vid */
-    -1,                 /* class */
-    True,               /* rgba */
-    -1, -1, -1, 8,      /* rgba sizes */
-    -1, -1, -1, -1,     /* rgba masks */
-    16, 16, 16, 16,     /* rgba accum sizes */
-    False,              /* doubleBuffer */
-    False,              /* stereo */
-    -1,                 /* bufferSize */
-    16,                 /* depthSize */
-    8,                  /* stencilSize */
-    0,                  /* auxBuffers */
-    0,                  /* level */
-    GLX_NONE,           /* visualRating */
-    GLX_NONE,           /* transparentPixel */
-    0, 0, 0, 0,         /* transparent rgba color (floats scaled to ints) */
-    0                   /* transparentIndex */
-  },
-  /* [4] = CI, double buffered, Z */
-  {
-    -1,                 /* vid */
-    -1,                 /* class */
-    False,              /* rgba? (false = color index) */
-    -1, -1, -1, 0,      /* rgba sizes */
-    -1, -1, -1, 0,      /* rgba masks */
-     0,  0,  0, 0,      /* rgba accum sizes */
-    True,               /* doubleBuffer */
-    False,              /* stereo */
-    -1,                 /* bufferSize */
-    16,                 /* depthSize */
-    0,                  /* stencilSize */
-    0,                  /* auxBuffers */
-    0,                  /* level */
-    GLX_NONE,           /* visualRating */
-    GLX_NONE,           /* transparentPixel */
-    0, 0, 0, 0,         /* transparent rgba color (floats scaled to ints) */
-    0                   /* transparentIndex */
-  },
-};
-
-static __GLXvisualConfig NullConfig = {
-    -1,                 /* vid */
-    -1,                 /* class */
-    False,              /* rgba */
-    -1, -1, -1, 0,      /* rgba sizes */
-    -1, -1, -1, 0,      /* rgba masks */
-     0,  0,  0, 0,      /* rgba accum sizes */
-    False,              /* doubleBuffer */
-    False,              /* stereo */
-    -1,                 /* bufferSize */
-    16,                 /* depthSize */
-    0,                  /* stencilSize */
-    0,                  /* auxBuffers */
-    0,                  /* level */
-    GLX_NONE_EXT,       /* visualRating */
-    0,                  /* transparentPixel */
-    0, 0, 0, 0,         /* transparent rgba color (floats scaled to ints) */
-    0                   /* transparentIndex */
-};
-
-
-static inline int count_bits(uint32_t x)
-{
-    x = x - ((x >> 1) & 0x55555555);
-    x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
-    x = (x + (x >> 4)) & 0x0f0f0f0f;
-    x = x + (x >> 8);
-    x = x + (x >> 16);
-    return x & 63;
-}
-
-
-static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
-                         VisualID *defaultVisp,
-                         int ndepth, DepthPtr pdepth,
-                         int rootDepth)
-{
-#if 0
-    int numRGBconfigs;
-    int numCIconfigs;
-    int numVisuals = *nvisualp;
-    int numNewVisuals;
-    int numNewConfigs;
-    VisualPtr pVisual = *visualp;
-    VisualPtr pVisualNew = NULL;
-    VisualID *orig_vid = NULL;
-    __GLcontextModes *modes;
-    __GLXvisualConfig *pNewVisualConfigs = NULL;
-    void **glXVisualPriv;
-    void **pNewVisualPriv;
-    int found_default;
-    int i, j, k;
-
-    GLAQUA_DEBUG_MSG("init_visuals\n");
-
-    if (numConfigs > 0)
-        numNewConfigs = numConfigs;
-    else
-        numNewConfigs = NUM_FALLBACK_CONFIGS;
-
-    /* Alloc space for the list of new GLX visuals */
-    pNewVisualConfigs = (__GLXvisualConfig *)
-                     malloc(numNewConfigs * sizeof(__GLXvisualConfig));
-    if (!pNewVisualConfigs) {
-        return FALSE;
-    }
-
-    /* Alloc space for the list of new GLX visual privates */
-    pNewVisualPriv = (void **) malloc(numNewConfigs * sizeof(void *));
-    if (!pNewVisualPriv) {
-        free(pNewVisualConfigs);
-        return FALSE;
-    }
-
-    /*
-    ** If SetVisualConfigs was not called, then use default GLX
-    ** visual configs.
-    */
-    if (numConfigs == 0) {
-        memcpy(pNewVisualConfigs, FallbackConfigs,
-               NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
-        memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
-    }
-    else {
-        /* copy driver's visual config info */
-        for (i = 0; i < numConfigs; i++) {
-            pNewVisualConfigs[i] = visualConfigs[i];
-            pNewVisualPriv[i] = visualPrivates[i];
-        }
-    }
-
-    /* Count the number of RGB and CI visual configs */
-    numRGBconfigs = 0;
-    numCIconfigs = 0;
-    for (i = 0; i < numNewConfigs; i++) {
-        if (pNewVisualConfigs[i].rgba)
-            numRGBconfigs++;
-        else
-            numCIconfigs++;
-    }
-
-    /* Count the total number of visuals to compute */
-    numNewVisuals = 0;
-    for (i = 0; i < numVisuals; i++) {
-        int count;
-
-        count = ((pVisual[i].class == TrueColor ||
-                  pVisual[i].class == DirectColor)
-                ? numRGBconfigs : numCIconfigs);
-        if (count == 0)
-            count = 1;          /* preserve the existing visual */
-
-        numNewVisuals += count;
-    }
-
-    /* Reset variables for use with the next screen/driver's visual configs */
-    visualConfigs = NULL;
-    numConfigs = 0;
-
-    /* Alloc temp space for the list of orig VisualIDs for each new visual */
-    orig_vid = (VisualID *)malloc(numNewVisuals * sizeof(VisualID));
-    if (!orig_vid) {
-        free(pNewVisualPriv);
-        free(pNewVisualConfigs);
-        return FALSE;
-    }
-
-    /* Alloc space for the list of glXVisuals */
-    modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
-    if (modes == NULL) {
-        free(orig_vid);
-        free(pNewVisualPriv);
-        free(pNewVisualConfigs);
-        return FALSE;
-    }
-
-    /* Alloc space for the list of glXVisualPrivates */
-    glXVisualPriv = (void **)malloc(numNewVisuals * sizeof(void *));
-    if (!glXVisualPriv) {
-        _gl_context_modes_destroy( modes );
-        free(orig_vid);
-        free(pNewVisualPriv);
-        free(pNewVisualConfigs);
-        return FALSE;
-    }
-
-    /* Alloc space for the new list of the X server's visuals */
-    pVisualNew = (VisualPtr)malloc(numNewVisuals * sizeof(VisualRec));
-    if (!pVisualNew) {
-        free(glXVisualPriv);
-        _gl_context_modes_destroy( modes );
-        free(orig_vid);
-        free(pNewVisualPriv);
-        free(pNewVisualConfigs);
-        return FALSE;
-    }
-
-    /* Initialize the new visuals */
-    found_default = FALSE;
-    glAquaScreens[screenInfo.numScreens-1].modes = modes;
-    for (i = j = 0; i < numVisuals; i++) {
-        int is_rgb = (pVisual[i].class == TrueColor ||
-                      pVisual[i].class == DirectColor);
-
-        if (!is_rgb)
-        {
-            /* We don't support non-rgb visuals for GL. But we don't
-               want to remove them either, so just pass them through
-               with null glX configs */
-
-            pVisualNew[j] = pVisual[i];
-            pVisualNew[j].vid = FakeClientID(0);
-
-            /* Check for the default visual */
-            if (!found_default && pVisual[i].vid == *defaultVisp) {
-                *defaultVisp = pVisualNew[j].vid;
-                found_default = TRUE;
-            }
-
-            /* Save the old VisualID */
-            orig_vid[j] = pVisual[i].vid;
-
-            /* Initialize the glXVisual */
-            _gl_copy_visual_to_context_mode( modes, & NullConfig );
-            modes->visualID = pVisualNew[j].vid;
-
-            j++;
-
-            continue;
-        }
-
-        for (k = 0; k < numNewConfigs; k++) {
-            if (pNewVisualConfigs[k].rgba != is_rgb)
-                continue;
-
-            assert( modes != NULL );
-
-            /* Initialize the new visual */
-            pVisualNew[j] = pVisual[i];
-            pVisualNew[j].vid = FakeClientID(0);
-
-            /* Check for the default visual */
-            if (!found_default && pVisual[i].vid == *defaultVisp) {
-                *defaultVisp = pVisualNew[j].vid;
-                found_default = TRUE;
-            }
-
-            /* Save the old VisualID */
-            orig_vid[j] = pVisual[i].vid;
-
-            /* Initialize the glXVisual */
-            _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
-            modes->visualID = pVisualNew[j].vid;
-
-            /*
-             * If the class is -1, then assume the X visual information
-             * is identical to what GLX needs, and take them from the X
-             * visual.  NOTE: if class != -1, then all other fields MUST
-             * be initialized.
-             */
-            if (modes->visualType == GLX_NONE) {
-                modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
-                modes->redBits    = count_bits(pVisual[i].redMask);
-                modes->greenBits  = count_bits(pVisual[i].greenMask);
-                modes->blueBits   = count_bits(pVisual[i].blueMask);
-                modes->alphaBits  = modes->alphaBits;
-                modes->redMask    = pVisual[i].redMask;
-                modes->greenMask  = pVisual[i].greenMask;
-                modes->blueMask   = pVisual[i].blueMask;
-                modes->alphaMask  = modes->alphaMask;
-                modes->rgbBits = (is_rgb)
-                    ? (modes->redBits + modes->greenBits +
-                       modes->blueBits + modes->alphaBits)
-                    : rootDepth;
-            }
-
-            /* Save the device-dependent private for this visual */
-            glXVisualPriv[j] = pNewVisualPriv[k];
-
-            j++;
-            modes = modes->next;
-        }
-    }
-
-    assert(j <= numNewVisuals);
-
-    /* Save the GLX visuals in the screen structure */
-    glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
-    //    glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
-
-    /* set up depth's VisualIDs */
-    for (i = 0; i < ndepth; i++) {
-        int numVids = 0;
-        VisualID *pVids = NULL;
-        int k, n = 0;
-
-        /* Count the new number of VisualIDs at this depth */
-        for (j = 0; j < pdepth[i].numVids; j++)
-            for (k = 0; k < numNewVisuals; k++)
-            if (pdepth[i].vids[j] == orig_vid[k])
-                numVids++;
-
-        /* Allocate a new list of VisualIDs for this depth */
-        pVids = (VisualID *)malloc(numVids * sizeof(VisualID));
-
-        /* Initialize the new list of VisualIDs for this depth */
-        for (j = 0; j < pdepth[i].numVids; j++)
-            for (k = 0; k < numNewVisuals; k++)
-            if (pdepth[i].vids[j] == orig_vid[k])
-                pVids[n++] = pVisualNew[k].vid;
-
-        /* Update this depth's list of VisualIDs */
-        free(pdepth[i].vids);
-        pdepth[i].vids = pVids;
-        pdepth[i].numVids = numVids;
-    }
-
-    /* Update the X server's visuals */
-    *nvisualp = numNewVisuals;
-    *visualp = pVisualNew;
-
-    /* Free the old list of the X server's visuals */
-    free(pVisual);
-
-    /* Clean up temporary allocations */
-    free(orig_vid);
-    free(pNewVisualPriv);
-    free(pNewVisualConfigs);
-
-    /* Free the private list created by DDX HW driver */
-    if (visualPrivates)
-        free(visualPrivates);
-    visualPrivates = NULL;
-
-    return TRUE;
-#endif
-    return FALSE;
-}
-
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
-                                   void **privates)
-{
-#if 0
-    GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
-
-    numConfigs = nconfigs;
-    visualConfigs = configs;
-    visualPrivates = privates;
-#endif
-}
-
-
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
-                              int *nvisualp, int *ndepthp,
-                              int *rootDepthp, VisualID *defaultVisp,
-                              unsigned long sizes, int bitsPerRGB)
-{
-    GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
-    
-    /*
-     * setup the visuals supported by this particular screen.
-     */
-    return init_visuals(nvisualp, visualp, defaultVisp,
-                        *ndepthp, *depthp, *rootDepthp);
-}
-
-#if 0
-static void fixup_visuals(int screen)
-{
-    ScreenPtr pScreen = screenInfo.screens[screen];
-    glAquaScreenRec *pScr = &glAquaScreens[screen];
-    int j;
-    __GLcontextModes *modes;
-
-    GLAQUA_DEBUG_MSG("fixup_visuals\n");
-
-    for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) {
-        const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
-        const int nplanes = (modes->rgbBits - modes->alphaBits);
-        const VisualPtr pVis = pScreen->visuals;
-
-        /* Find a visual that matches the GLX visual's class and size */
-        for (j = 0; j < pScreen->numVisuals; j++) {
-            if (pVis[j].class == vis_class &&
-            pVis[j].nplanes == nplanes) {
-
-            /* Fixup the masks */
-            modes->redMask   = pVis[j].redMask;
-            modes->greenMask = pVis[j].greenMask;
-            modes->blueMask  = pVis[j].blueMask;
-
-            /* Recalc the sizes */
-            modes->redBits   = count_bits(modes->redMask);
-            modes->greenBits = count_bits(modes->greenMask);
-            modes->blueBits  = count_bits(modes->blueMask);
-            }
-        }
-    }
-}
-#endif
 static void __glXAquaScreenDestroy(__GLXscreen *screen) {
 
     GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen);
@@ -1210,10 +715,6 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
     screen->base.fbconfigs = CreateConfigs(&screen->base.numFBConfigs, 
 					   pScreen->myNum);
     
-    /* This seems odd, but visuals is a __GLXconfig too. */
-    screen->base.visuals = screen->base.fbconfigs;
-    screen->base.numVisuals = screen->base.numFBConfigs;
- 
     GlxSetVisualConfig(GLX_ALL_VISUALS);
 
     __glXScreenInit(&screen->base, pScreen);
@@ -1271,8 +772,6 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen,
 			      __GLXconfig *conf) {
   __GLXAquaDrawable *glxPriv;
 
-  GLAQUA_DEBUG_MSG("glAquaScreenCreateDrawable(%p,%p,%d,%p)\n", context, pDraw, drawId, modes);
-
   glxPriv = xalloc(sizeof *glxPriv);
 
   if(glxPriv == NULL)
@@ -1286,19 +785,16 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen,
   }
 
   glxPriv->base.destroy       = __glXAquaDrawableDestroy;
-  glxPriv->base.resize        = __glXAquaDrawableResize;
   glxPriv->base.swapBuffers   = __glXAquaDrawableSwapBuffers;
   glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
 
+  glxPriv->pDraw = pDraw;
+  glxPriv->sid = 0;
+  glxPriv->context = NULL;
+  
   return &glxPriv->base;
 }
 
-static void glAquaResetExtension(void)
-{
-    GLAQUA_DEBUG_MSG("glAquaResetExtension\n");
-    CGLSetOption(kCGLGOResetLibrary, GL_TRUE);
-}
-
 // Extra goodies for glx
 
 GLuint __glFloorLog2(GLuint val)
commit ee9736b26b1021fac2cf259e6b2142ea780b2af8
Author: George Staplin <gstaplin at apple.com>
Date:   Fri Jan 9 16:08:26 2009 -0700

    XQuartz: GL: Set the __GLXconfig renderType to GLX_RGBA_BIT.
    (cherry picked from commit 3c14546f58f8a138fe67c9cacc3bd0b7fa90c29a)
    (cherry picked from commit a665ed16f736cf1901b89448dc5d37f4d16dfaf4)

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index fbf13ce..afaa957 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -1137,7 +1137,7 @@ static __GLXconfig *CreateConfigs(int *numConfigsPtr, int screenNumber) {
 
 					/* SGIX_fbconfig / GLX 1.3 */
 					c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
-					c->renderType = /*FIXME*/ GL_TRUE;
+					c->renderType = GLX_RGBA_BIT;
 					c->xRenderable = GL_TRUE;
 					c->fbconfigID = -1;
 					
commit b646513861aac9538ba3ebd8e2c7ef530392ff5d
Author: George Staplin <gstaplin at apple.com>
Date:   Fri Jan 9 15:53:39 2009 -0700

    XQuartz: GL: Make many more fbconfigs and visuals available for the 1.5 branch.
    
    Use a __GLXconfig linked list struct to store the configurations for the
    fbconfigs and visuals in a pGlxScreen.
    
    Also, remove the __GLXvisualConfig/GlxSetVisualConfigs code that isn't used
    anymore.  There is more code we can remove later, but I want to do that in
    separate commits.
    (cherry picked from commit 94162b0f8a25267aca280d25e216cc6bde47da6e)
    (cherry picked from commit 15bb6abd59fdefe7037237faaea1a39711a972ed)

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 32b9dd4..fbf13ce 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -1,8 +1,8 @@
 /*
  * GLX implementation that uses Apple's OpenGL.framework
- * (Indirect rendering path)
+ * (Indirect rendering path -- it's also used for some direct mode code too)
  *
- * Copyright (c) 2007 Apple Inc.
+ * Copyright (c) 2007, 2008, 2009 Apple Inc.
  * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
  * Copyright (c) 2002 Greg Parker. All Rights Reserved.
  *
@@ -76,6 +76,8 @@
 #include "x-hash.h"
 #include "x-list.h"
 
+#include "capabilities.h"
+
 #include <dispatch.h>
 #define GLAPIENTRYP *
 typedef unsigned long long GLuint64EXT;
@@ -212,6 +214,7 @@ __glXAquaScreenCreateContext(__GLXscreen *screen,
   return &context->base;
 }
 
+/* Nothing seems to use these anymore... */
 static __GLXextensionInfo __glDDXExtensionInfo = {
     GL_CORE_APPLE,
     glAquaResetExtension,
@@ -930,100 +933,6 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
     return FALSE;
 }
 
-Bool enable_stereo = FALSE;
-/* based on code in i830_dri.c
-   This ends calling glAquaSetVisualConfigs to set the static
-   numconfigs, etc. */
-static void
-glAquaInitVisualConfigs(void)
-{
-#if 0
-    int                 lclNumConfigs     = 0;
-    __GLXvisualConfig  *lclVisualConfigs  = NULL;
-    void              **lclVisualPrivates = NULL;
-
-    int stereo, depth, aux, buffers, stencil, accum;
-    int i = 0;
-
-    GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
-        
-    /* count num configs:
-        2 stereo (on, off) (optional)
-        2 Z buffer (0, 24 bit)
-        2 AUX buffer (0, 2)
-        2 buffers (single, double)
-        2 stencil (0, 8 bit)
-        2 accum (0, 64 bit)
-        = 64 configs with stereo, or 32 without */
-
-    if (enable_stereo) lclNumConfigs = 2 * 2 * 2 * 2 * 2 * 2; /* 64 */
-    else               lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
-
-    /* alloc */
-    lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
-    lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
-
-    /* fill in configs */
-    if (NULL != lclVisualConfigs) {
-        i = 0; /* current buffer */
-        for (stereo = 0; stereo < (enable_stereo ? 2 : 1); stereo++) {
-	  for (depth = 0; depth < 2; depth++) {
-            for (aux = 0; aux < 2; aux++) {
-	      for (buffers = 0; buffers < 2; buffers++) {
-		for (stencil = 0; stencil < 2; stencil++) {
-		  for (accum = 0; accum < 2; accum++) {
-		    lclVisualConfigs[i].vid = -1;
-		    lclVisualConfigs[i].class = -1;
-		    lclVisualConfigs[i].rgba = TRUE;
-		    lclVisualConfigs[i].redSize = -1;
-		    lclVisualConfigs[i].greenSize = -1;
-		    lclVisualConfigs[i].blueSize = -1;
-		    lclVisualConfigs[i].redMask = -1;
-		    lclVisualConfigs[i].greenMask = -1;
-		    lclVisualConfigs[i].blueMask = -1;
-		    lclVisualConfigs[i].alphaMask = 0;
-		    if (accum) {
-		      lclVisualConfigs[i].accumRedSize = 16;
-		      lclVisualConfigs[i].accumGreenSize = 16;
-		      lclVisualConfigs[i].accumBlueSize = 16;
-		      lclVisualConfigs[i].accumAlphaSize = 16;
-		    } else {
-		      lclVisualConfigs[i].accumRedSize = 0;
-		      lclVisualConfigs[i].accumGreenSize = 0;
-		      lclVisualConfigs[i].accumBlueSize = 0;
-		      lclVisualConfigs[i].accumAlphaSize = 0;
-		    }
-		    lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
-		    lclVisualConfigs[i].stereo = stereo ? TRUE : FALSE;
-		    lclVisualConfigs[i].bufferSize = -1;
-		    
-		    lclVisualConfigs[i].depthSize = depth? 24 : 0;
-		    lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
-		    lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
-		    lclVisualConfigs[i].level = 0;
-		    lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
-		    lclVisualConfigs[i].transparentPixel = 0;
-		    lclVisualConfigs[i].transparentRed = 0;
-		    lclVisualConfigs[i].transparentGreen = 0;
-		    lclVisualConfigs[i].transparentBlue = 0;
-		    lclVisualConfigs[i].transparentAlpha = 0;
-		    lclVisualConfigs[i].transparentIndex = 0;
-		    i++;
-		  }
-		}
-	      }
-            }
-	  }
-	}
-    }
-    if (i != lclNumConfigs)
-        GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
-
-    GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
-#endif
-}
-
-
 static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
                                    void **privates)
 {
@@ -1044,9 +953,6 @@ static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
 {
     GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
     
-    if (numConfigs == 0) /* if no configs */
-        glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
-
     /*
      * setup the visuals supported by this particular screen.
      */
@@ -1096,157 +1002,193 @@ static void __glXAquaScreenDestroy(__GLXscreen *screen) {
     xfree(screen);
 }
 
-static void init_screen_visuals(__GLXAquaScreen *screen) {
-#if 0
-  ScreenPtr pScreen = screen->base.pScreen;
-  __GLcontextModes *modes;
-  int *used;
-  int i, j;
-  
-    GLAQUA_DEBUG_MSG("init_screen_visuals\n");
+static __GLXconfig *CreateConfigs(int *numConfigsPtr, int screenNumber) {
+    __GLXconfig *c, *result;
+    struct glCapabilities cap;
+    struct glCapabilitiesConfig *conf = NULL;
+    int numConfigs = 0;
+    int i;
 
-    /* FIXME: Change 'used' to be a array of bits (rather than of ints),
-     * FIXME: create a stack array of 8 or 16 bytes.  If 'numVisuals' is less
-     * FIXME: than 64 or 128 the stack array can be used instead of calling
-     * FIXME: malloc / free.  If nothing else, convert 'used' to
-     * FIXME: array of bytes instead of ints!
-     */
-    used = (int *)malloc(pScreen->numVisuals * sizeof(int));
-    memset(used, 0, pScreen->numVisuals * sizeof(int));
+    if(getGlCapabilities(&cap))
+	FatalError("error from getGlCapabilities() in %s\n", __func__);
 
-    i = 0;
-    for ( modes = screen -> base.modes
-          ; modes != NULL
-          ; modes = modes->next ) {
-        const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
-        const int nplanes = (modes->rgbBits - modes->alphaBits);
-        const VisualPtr pVis = pScreen->visuals;
+    assert(NULL != cap.configurations);
 
-        for (j = 0; j < pScreen->numVisuals; j++) {
-            if (pVis[j].class     == vis_class &&
-                pVis[j].nplanes   == nplanes &&
-                pVis[j].redMask   == modes->redMask &&
-                pVis[j].greenMask == modes->greenMask &&
-                pVis[j].blueMask  == modes->blueMask &&
-                !used[j]) {
-
-                    /* set the VisualID */
-                    modes->visualID = pVis[j].vid;
-
-                    /* Mark this visual used */
-                    used[j] = 1;
-                    break;
-            }
-        }
-        if ( j == pScreen->numVisuals ) {
-            ErrorF("No matching visual for __GLcontextMode with "
-                   "visual class = %d (%d), nplanes = %u\n",
-                   vis_class, 
-                   (int)modes->visualType,
-                   (unsigned int)(modes->rgbBits - modes->alphaBits) );
-        }
-        else if ( modes->visualID == -1 ) {
-            FatalError( "Matching visual found, but visualID still -1!\n" );
-        }
+    for(conf = cap.configurations; conf; conf = conf->next) {
+        if(conf->total_color_buffers <= 0)
+            continue;
 
-        i++;
+        numConfigs += (conf->stereo ? 2 : 1) 
+            * (conf->aux_buffers ? 2 : 1) 
+            * conf->buffers
+            * ((conf->total_stencil_bit_depths > 0) ? 
+	       conf->total_stencil_bit_depths : 1)
+            * conf->total_color_buffers
+            * ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
+            * conf->total_depth_buffer_depths
+            * (conf->multisample_buffers + 1);
     }
 
-    free(used);
-#endif
-}
-
-/* This will eventually need to use the capabilities.c code.  
- * We can probably update the visualConfigs.c code to work with __GLXconfig.
- */
-static __GLXconfig *createConfigs(void) {
-    __GLXconfig *conf;
-
-    conf = xalloc(sizeof *conf);
+    *numConfigsPtr = numConfigs;
+    
+    c = xalloc(sizeof(*c) * numConfigs);
     
-    if(NULL == conf)
+    if(NULL == c)
 	return NULL;
 
-    conf->next = NULL;
-    conf->doubleBufferMode = GL_TRUE;
-    conf->stereoMode = GL_FALSE;
-    conf->redBits = 8;
-    conf->greenBits = 8;
-    conf->blueBits = 8;
-    conf->alphaBits = 0;
-
-    conf->redMask = -1;
-    conf->greenMask = -1;
-    conf->blueMask = -1;
-    conf->alphaMask = -1;
-
-    conf->rgbBits = conf->redBits + conf->greenBits + conf->blueBits + conf->alphaBits;
-    conf->indexBits = 0;
-
-    conf->accumRedBits = 0;
-    conf->accumGreenBits = 0;
-    conf->accumBlueBits = 0;
-    conf->accumAlphaBits = 0;
     
-    conf->depthBits = 24;
 
-    conf->stencilBits = 0;
-    
-    conf->numAuxBuffers = 0;
+    result = c;
     
-    conf->level = 0;
+    memset(result, 0, sizeof(*c) * numConfigs);
 
-    conf->pixmapMode = 0;
-    
-    conf->visualID = -1;
-    conf->visualType = GLX_TRUE_COLOR;
-    conf->visualRating = 0;
-
-    conf->transparentPixel = 0;
-    conf->transparentRed = 0;
-    conf->transparentGreen = 0;
-    conf->transparentAlpha = 0;
-    conf->transparentIndex = 0;
+    i = 0;
+
+    for(conf = cap.configurations; conf; conf = conf->next) {
+	int stereo, aux, buffers, stencil, color, accum, depth, msample;
+	
+	for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
+	    for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
+		for(buffers = 0; buffers < conf->buffers; ++buffers) {
+		    for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ? 
+						conf->total_stencil_bit_depths : 1); ++stencil) {
+			for(color = 0; color < conf->total_color_buffers; ++color) {
+			    for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
+						    conf->total_accum_buffers : 1); ++accum) {
+				for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
+				    for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
+					if((i + 1) < numConfigs) {
+					    c->next = c + 1;
+					} else {
+					    c->next = NULL;
+					}
+
+					c->doubleBufferMode = buffers ? GL_TRUE : GL_FALSE;
+					c->stereoMode = stereo ? GL_TRUE : GL_FALSE;
+					
+					c->redBits = conf->color_buffers[color].r;
+					c->greenBits = conf->color_buffers[color].g;
+					c->blueBits = conf->color_buffers[color].b;
+					c->alphaBits = 0;
+					
+					if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) {
+					    c->alphaBits = conf->color_buffers[color].a;
+					}
+
+					c->redMask = -1;
+					c->greenMask = -1;
+					c->blueMask = -1;
+					c->alphaMask = -1;
+					
+					c->rgbBits = c->redBits + c->greenBits + c->blueBits + c->alphaBits;
+					c->indexBits = 0;
+	    
+					c->accumRedBits = 0;
+					c->accumGreenBits = 0;
+					c->accumBlueBits = 0;
+					c->accumAlphaBits = 0;
+					
+					if(conf->total_accum_buffers > 0) {
+					    c->accumRedBits = conf->accum_buffers[accum].r;
+					    c->accumGreenBits = conf->accum_buffers[accum].g;
+					    c->accumBlueBits = conf->accum_buffers[accum].b;
+					    if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
+						c->accumAlphaBits = conf->accum_buffers[accum].a;
+					    }
+					}
+
+					c->depthBits = conf->depth_buffers[depth];
+					
+					c->stencilBits = 0;
+	    
+					if(conf->total_stencil_bit_depths > 0) {
+					    c->stencilBits = conf->stencil_bit_depths[stencil];
+					}
+
+
+					c->numAuxBuffers = aux ? conf->aux_buffers : 0;
+
+					c->level = 0;
+					/*TODO what should this be? */
+					c->pixmapMode = 0;
+					
+					c->visualID = -1;
+					c->visualType = GLX_TRUE_COLOR;
+
+					if(conf->accelerated) {
+					    c->visualRating = GLX_NONE;
+					} else {
+					    c->visualRating = GLX_SLOW_VISUAL_EXT;
+					}
+	
+					c->transparentPixel = GLX_NONE;
+					c->transparentRed = GLX_NONE;
+					c->transparentGreen = GLX_NONE;
+					c->transparentAlpha = GLX_NONE;
+					c->transparentIndex = GLX_NONE;
+	    
+					c->sampleBuffers = 0;
+					c->samples = 0;
+
+					if(msample > 0) {
+					    c->sampleBuffers = conf->multisample_buffers;
+					    c->samples = conf->multisample_samples;
+					}
+
+					/* SGIX_fbconfig / GLX 1.3 */
+					c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+					c->renderType = /*FIXME*/ GL_TRUE;
+					c->xRenderable = GL_TRUE;
+					c->fbconfigID = -1;
+					
+					/*TODO add querying code to capabilities.c for the Pbuffer maximums.
+					 *I'm not sure we can even use CGL for Pbuffers yet...
+					 */
+					/* SGIX_pbuffer / GLX 1.3 */
+					c->maxPbufferWidth = 0;
+					c->maxPbufferHeight = 0;
+					c->maxPbufferPixels = 0;
+					c->optimalPbufferWidth = 0;
+					c->optimalPbufferHeight = 0;
+					c->visualSelectGroup = 0;
+					
+					c->swapMethod = GLX_SWAP_UNDEFINED_OML;
+	
+					c->screen = screenNumber;
+	    
+					/* EXT_texture_from_pixmap */
+					c->bindToTextureRgb = 0;
+					c->bindToTextureRgba = 0;
+					c->bindToMipmapTexture = 0;
+					c->bindToTextureTargets = 0;
+					c->yInverted = 0;
+
+					if(c->next)
+					    c = c->next;
+					
+					++i;
+				    }
+				}
+			    }
+			}
+		    }
+		}
+	    }	
+	}
+    }
+
+    if(i != numConfigs)
+	FatalError("The number of __GLXconfig generated does not match the initial calculation!\n");
     
-    conf->sampleBuffers = 0;
-    conf->samples = 0;
-
-    /* SGIX_fbconfig / GLX 1.3 */
-    conf->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
-    conf->renderType = GL_TRUE;
-    conf->xRenderable = GL_TRUE;
-    conf->fbconfigID = -1;
-
-    /*TODO add querying code to capabilities.c for the Pbuffer maximums. */
-    /* SGIX_pbuffer / GLX 1.3 */
-    conf->maxPbufferWidth = 0;
-    conf->maxPbufferHeight = 0;
-    conf->maxPbufferPixels = 0;
-    conf->optimalPbufferWidth = 0;
-    conf->optimalPbufferHeight = 0;
-
-    conf->visualSelectGroup = 0;
-
-    conf->swapMethod = GLX_SWAP_UNDEFINED_OML;
-
-    /* FIXME */
-    conf->screen = 0;
-
-    /* EXT_texture_from_pixmap */
-    conf->bindToTextureRgb = 0;
-    conf->bindToTextureRgba = 0;
-    conf->bindToMipmapTexture = 0;
-    conf->bindToTextureTargets = 0;
-    conf->yInverted = 0;
-
-    return conf;
-}
 
+    freeGlCapabilities(&cap);
+
+    return result;
+}
 
 /* This is called by __glXInitScreens(). */
 static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
     __GLXAquaScreen *screen;
-    __GLXconfig *configs;
 
     GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n");
 
@@ -1265,41 +1207,28 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
     screen->base.swapBarrierFuncs = NULL;
     screen->base.pScreen       = pScreen;
     
-    configs = createConfigs();
-
-    screen->base.fbconfigs = configs;
-    screen->base.numFBConfigs = 1; 
-
-    screen->base.visuals = NULL;
-    screen->base.numVisuals = 0;
-
+    screen->base.fbconfigs = CreateConfigs(&screen->base.numFBConfigs, 
+					   pScreen->myNum);
+    
+    /* This seems odd, but visuals is a __GLXconfig too. */
+    screen->base.visuals = screen->base.fbconfigs;
+    screen->base.numVisuals = screen->base.numFBConfigs;
+ 
     GlxSetVisualConfig(GLX_ALL_VISUALS);
 
     __glXScreenInit(&screen->base, pScreen);
 
     /* __glXScreenInit initializes these, so the order here is important, if we need these... */
-    screen->base.GLextensions = "";
-    screen->base.GLXvendor = "Apple";
-    screen->base.GLXversion = "1.4";
-    screen->base.GLXextensions = "GLX_SGIX_fbconfig "
-	"GLX_SGIS_multisample "
-	"GLX_ARB_multisample "
-	"GLX_EXT_visual_info "
-	"GLX_EXT_import_context "
-	"GLX_EXT_texture_from_pixmap "; 
-    /*We may be able to add more GLXextensions at a later time. */
+    //  screen->base.GLextensions = "";
+    // screen->base.GLXvendor = "Apple";
+    screen->base.GLXversion = xstrdup("1.4");
+    screen->base.GLXextensions = xstrdup("GLX_SGIX_fbconfig "
+					 "GLX_SGIS_multisample "
+					 "GLX_ARB_multisample "
+					 "GLX_EXT_visual_info "
+					 "GLX_EXT_import_context ");
     
-
-    /* 
-     * These are both commented out, because they cause problems with
-     * the other visual config code, and visuals.
-     * This probe function is called normally on startup in direct
-     * mode too.
-     * They don't seem to be needed now that we have better visual
-     * setup.
-     */
-    //init_screen_visuals(screen);
-    //glAquaInitVisualConfigs();
+    /*We may be able to add more GLXextensions at a later time. */
     
     return &screen->base;
 }
@@ -1359,7 +1288,7 @@ __glXAquaScreenCreateDrawable(__GLXscreen *screen,
   glxPriv->base.destroy       = __glXAquaDrawableDestroy;
   glxPriv->base.resize        = __glXAquaDrawableResize;
   glxPriv->base.swapBuffers   = __glXAquaDrawableSwapBuffers;
-  glxPriv->base.copySubBuffer = __glXAquaDrawableCopySubBuffer;
+  glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
 
   return &glxPriv->base;
 }
commit 9e03178ae2da6beb939141f662d875c4c1d40354
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Tue Jan 13 13:05:32 2009 +0100

    EXA: Declare glyph cache picture as component-alpha when necessary.
    
    Without this, rendering component-alpha glyphs may break without a mask.
    
    Fixes http://bugs.freedesktop.org/show_bug.cgi?id=19233 .
    (cherry picked from commit 639f289dcdbe00a516820f573c01a8339e120ed4)

diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index 169763f..688081d 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -140,6 +140,8 @@ exaUnrealizeGlyphCaches(ScreenPtr    pScreen,
     }
 }
 
+#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
+
 /* All caches for a single format share a single pixmap for glyph storage,
  * allowing mixing glyphs of different sizes without paying a penalty
  * for switching between source pixmaps. (Note that for a size of font
@@ -159,6 +161,7 @@ exaRealizeGlyphCaches(ScreenPtr    pScreen,
     PictFormatPtr pPictFormat;
     PixmapPtr pPixmap;
     PicturePtr pPicture;
+    CARD32 component_alpha;
     int height;
     int i;
     int	error;
@@ -191,8 +194,10 @@ exaRealizeGlyphCaches(ScreenPtr    pScreen,
     if (!pPixmap)
 	return FALSE;
 
+    component_alpha = NeedsComponent(pPictFormat->format);
     pPicture = CreatePicture(0, &pPixmap->drawable, pPictFormat,
-			     0, 0, serverClient, &error);
+			     CPComponentAlpha, &component_alpha, serverClient,
+			     &error);
 
     (*pScreen->DestroyPixmap) (pPixmap); /* picture holds a refcount */
 
@@ -741,8 +746,6 @@ exaGlyphsIntersect(int nlist, GlyphListPtr list, GlyphPtr *glyphs)
     return FALSE;
 }
 
-#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
-
 void
 exaGlyphs (CARD8 	 op,
 	   PicturePtr	 pSrc,


More information about the xorg-commit mailing list