[cairo-commit] glitz/src/glx glitz-glx.h, 1.3, 1.4 glitz_glx_context.c, 1.6, 1.7 glitz_glx_drawable.c, 1.3, 1.4 glitz_glx_extension.c, 1.2, 1.3 glitz_glx_format.c, 1.3, 1.4 glitz_glx_info.c, 1.4, 1.5 glitz_glx_pbuffer.c, 1.2, 1.3 glitz_glxext.h, 1.2, 1.3 glitz_glxint.h, 1.4, 1.5

David Reveman commit at pdx.freedesktop.org
Wed Sep 14 08:57:19 PDT 2005


Committed by: davidr

Update of /cvs/cairo/glitz/src/glx
In directory gabe:/tmp/cvs-serv6486/src/glx

Modified Files:
	glitz-glx.h glitz_glx_context.c glitz_glx_drawable.c 
	glitz_glx_extension.c glitz_glx_format.c glitz_glx_info.c 
	glitz_glx_pbuffer.c glitz_glxext.h glitz_glxint.h 
Log Message:
Merge new code

Index: glitz-glx.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz-glx.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz-glx.h	29 Jun 2005 01:26:39 -0000	1.3
+++ glitz-glx.h	14 Sep 2005 15:57:16 -0000	1.4
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -42,17 +42,24 @@
 
 void
 glitz_glx_fini (void);
-  
-  
+
+
 /* glitz_glx_format.c */
 
 glitz_drawable_format_t *
-glitz_glx_find_drawable_format (Display                       *display,
-                                int                           screen,
-                                unsigned long                 mask,
-                                const glitz_drawable_format_t *templ,
-                                int                           count);
-  
+glitz_glx_find_window_format (Display                       *display,
+			      int                           screen,
+			      unsigned long                 mask,
+			      const glitz_drawable_format_t *templ,
+			      int                           count);
+
+glitz_drawable_format_t *
+glitz_glx_find_pbuffer_format (Display                       *display,
+			       int                           screen,
+			       unsigned long                 mask,
+			       const glitz_drawable_format_t *templ,
+			       int                           count);
+
 glitz_drawable_format_t *
 glitz_glx_find_drawable_format_for_visual (Display  *display,
 					   int       screen,
@@ -60,26 +67,26 @@
 
 XVisualInfo *
 glitz_glx_get_visual_info_from_format (Display                 *display,
-                                       int                     screen,
-                                       glitz_drawable_format_t *format);
-  
+				       int                     screen,
+				       glitz_drawable_format_t *format);
+
 
 /* glitz_glx_drawable.c */
 
 glitz_drawable_t *
 glitz_glx_create_drawable_for_window (Display                 *display,
-                                      int                     screen,
-                                      glitz_drawable_format_t *format,
-                                      Window                  window,
-                                      unsigned int            width,
-                                      unsigned int            height);
+				      int                     screen,
+				      glitz_drawable_format_t *format,
+				      Window                  window,
+				      unsigned int            width,
+				      unsigned int            height);
 
 glitz_drawable_t *
 glitz_glx_create_pbuffer_drawable (Display                 *display,
-                                   int                     screen,
-                                   glitz_drawable_format_t *format,
-                                   unsigned int            width,
-                                   unsigned int            height);
+				   int                     screen,
+				   glitz_drawable_format_t *format,
+				   unsigned int            width,
+				   unsigned int            height);
 
 
 #if defined(__cplusplus) || defined(c_plusplus)

Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_context.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- glitz_glx_context.c	4 Jul 2005 10:33:01 -0000	1.6
+++ glitz_glx_context.c	14 Sep 2005 15:57:16 -0000	1.7
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -35,402 +35,448 @@
 
 static void
 _glitz_glx_context_create (glitz_glx_screen_info_t *screen_info,
-                           XID                     visualid,
-                           GLXContext              share_list,
-                           glitz_glx_context_t     *context)
+			   XID                     visualid,
+			   GLXContext              share_list,
+			   glitz_glx_context_t     *context)
 {
-  int vis_info_count, i;
-  XVisualInfo *vis_infos;
+    int vis_info_count, i;
+    XVisualInfo *vis_infos;
 
-  vis_infos = XGetVisualInfo (screen_info->display_info->display,
-                              0, NULL, &vis_info_count);
-  for (i = 0; i < vis_info_count; i++) {
-    if (vis_infos[i].visual->visualid == visualid)
-      break;
-  }
+    vis_infos = XGetVisualInfo (screen_info->display_info->display,
+				0, NULL, &vis_info_count);
+    for (i = 0; i < vis_info_count; i++) {
+	if (vis_infos[i].visual->visualid == visualid)
+	    break;
+    }
 
-  context->context = glXCreateContext (screen_info->display_info->display,
-                                       &vis_infos[i], share_list,
-                                       GLITZ_GL_TRUE);
-  context->id = visualid;  
-  context->fbconfig = (GLXFBConfig) 0;
+    context->context = glXCreateContext (screen_info->display_info->display,
+					 &vis_infos[i], share_list,
+					 GLITZ_GL_TRUE);
+    context->id = visualid;
+    context->fbconfig = (GLXFBConfig) 0;
 
-  XFree (vis_infos);
+    XFree (vis_infos);
 }
 
 static void
 _glitz_glx_context_create_using_fbconfig (glitz_glx_screen_info_t *screen_info,
-                                          XID                     fbconfigid,
-                                          GLXContext              share_list,
-                                          glitz_glx_context_t     *context)
+					  XID                     fbconfigid,
+					  GLXContext              share_list,
+					  glitz_glx_context_t     *context)
 {
-  GLXFBConfig *fbconfigs;
-  int i, n_fbconfigs;
-  XVisualInfo *vinfo = NULL;
-  glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
+    GLXFBConfig *fbconfigs;
+    int i, n_fbconfigs;
+    XVisualInfo *vinfo = NULL;
+    glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
 
-  fbconfigs = glx->get_fbconfigs (screen_info->display_info->display,
-                                  screen_info->screen, &n_fbconfigs);
-  for (i = 0; i < n_fbconfigs; i++) {
-    int value;
-    
-    glx->get_fbconfig_attrib (screen_info->display_info->display, fbconfigs[i],
-                              GLX_FBCONFIG_ID, &value);
-    if (value == (int) fbconfigid)
-      break;
-  }
+    fbconfigs = glx->get_fbconfigs (screen_info->display_info->display,
+				    screen_info->screen, &n_fbconfigs);
+    for (i = 0; i < n_fbconfigs; i++) {
+	int value;
 
-  if (i < n_fbconfigs)
-    vinfo = glx->get_visual_from_fbconfig (screen_info->display_info->display,
-                                           fbconfigs[i]);
+	glx->get_fbconfig_attrib (screen_info->display_info->display,
+				  fbconfigs[i],
+				  GLX_FBCONFIG_ID, &value);
+	if (value == (int) fbconfigid)
+	    break;
+    }
 
-  context->id = fbconfigid;
-  if (vinfo) {
-    context->context = glXCreateContext (screen_info->display_info->display,
-                                         vinfo, share_list, GLITZ_GL_TRUE);
-    XFree (vinfo);
-  } else if (glx->create_new_context)
-    context->context =
-      glx->create_new_context (screen_info->display_info->display,
-                               fbconfigs[i], GLX_RGBA_TYPE, share_list,
-                               GLITZ_GL_TRUE);
-  
-  if (context->context)
-    context->fbconfig = fbconfigs[i];
-  else
-    context->fbconfig = (GLXFBConfig) 0;
+    if (i < n_fbconfigs)
+	vinfo =
+	    glx->get_visual_from_fbconfig (screen_info->display_info->display,
+					   fbconfigs[i]);
 
-  if (fbconfigs)
-    XFree (fbconfigs);
+    context->id = fbconfigid;
+    if (vinfo) {
+	context->context =
+	    glXCreateContext (screen_info->display_info->display,
+			      vinfo, share_list, GLITZ_GL_TRUE);
+	XFree (vinfo);
+    } else if (glx->create_new_context)
+	context->context =
+	    glx->create_new_context (screen_info->display_info->display,
+				     fbconfigs[i], GLX_RGBA_TYPE, share_list,
+				     GLITZ_GL_TRUE);
+
+    if (context->context)
+	context->fbconfig = fbconfigs[i];
+    else
+	context->fbconfig = (GLXFBConfig) 0;
+
+    if (fbconfigs)
+	XFree (fbconfigs);
 }
 
 static glitz_context_t *
 _glitz_glx_create_context (void                    *abstract_drawable,
-                           glitz_drawable_format_t *format)
+			   glitz_drawable_format_t *format)
 {
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
-  glitz_glx_screen_info_t *screen_info = drawable->screen_info;
-  int format_id = screen_info->format_ids[format->id];
-  glitz_glx_context_t *context;
-  
-  context = malloc (sizeof (glitz_glx_context_t));
-  if (!context)
-    return NULL;
+    glitz_glx_drawable_t   *drawable = (glitz_glx_drawable_t *)
+	abstract_drawable;
+    glitz_glx_screen_info_t *screen_info = drawable->screen_info;
+    unsigned long	    format_id =
+	screen_info->formats[format->id].u.uval;
+    glitz_glx_context_t	    *context;
 
-  _glitz_context_init (&context->base, &drawable->base);
-  
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
-      _glitz_glx_context_create_using_fbconfig (screen_info,
-                                                format_id,
-                                                screen_info->root_context,
-                                                context);
-  else
-      _glitz_glx_context_create (screen_info,
-                                 format_id,
-                                 screen_info->root_context,
-                                 context);
+    context = malloc (sizeof (glitz_glx_context_t));
+    if (!context)
+	return NULL;
 
-  return (glitz_context_t *) context;
+    _glitz_context_init (&context->base, &drawable->base);
+
+    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
+	_glitz_glx_context_create_using_fbconfig (screen_info,
+						  format_id,
+						  screen_info->root_context,
+						  context);
+    else
+	_glitz_glx_context_create (screen_info,
+				   format_id,
+				   screen_info->root_context,
+				   context);
+
+    return (glitz_context_t *) context;
 }
 
 static void
 _glitz_glx_context_destroy (void *abstract_context)
 {
-  glitz_glx_context_t *context = (glitz_glx_context_t *) abstract_context;
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
-      context->base.drawable;
-  
-  if (drawable->screen_info->display_info->thread_info->cctx == &context->base)
-  {
-      glXMakeCurrent (drawable->screen_info->display_info->display,
-                      None, NULL);
-  
-      drawable->screen_info->display_info->thread_info->cctx = NULL;
-  }
+    glitz_glx_context_t *context = (glitz_glx_context_t *) abstract_context;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	context->base.drawable;
 
-  glXDestroyContext (drawable->screen_info->display_info->display,
-                     context->context);
+    if (drawable->screen_info->display_info->thread_info->cctx ==
+	&context->base)
+    {
+	glXMakeCurrent (drawable->screen_info->display_info->display,
+			None, NULL);
 
-  _glitz_context_fini (&context->base);
-  
-  free (context);
+	drawable->screen_info->display_info->thread_info->cctx = NULL;
+    }
+
+    glXDestroyContext (drawable->screen_info->display_info->display,
+		       context->context);
+
+    _glitz_context_fini (&context->base);
+
+    free (context);
 }
 
 static void
 _glitz_glx_copy_context (void          *abstract_src,
-                         void          *abstract_dst,
-                         unsigned long mask)
+			 void          *abstract_dst,
+			 unsigned long mask)
 {
-  glitz_glx_context_t  *src = (glitz_glx_context_t *) abstract_src;
-  glitz_glx_context_t  *dst = (glitz_glx_context_t *) abstract_dst;
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
-      src->base.drawable;
+    glitz_glx_context_t  *src = (glitz_glx_context_t *) abstract_src;
+    glitz_glx_context_t  *dst = (glitz_glx_context_t *) abstract_dst;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	src->base.drawable;
 
-  glXCopyContext (drawable->screen_info->display_info->display,
-                  src->context, dst->context, mask);
+    glXCopyContext (drawable->screen_info->display_info->display,
+		    src->context, dst->context, mask);
 }
 
 static void
-_glitz_glx_make_current (void *abstract_context,
-                         void *abstract_drawable)
+_glitz_glx_make_current (void *abstract_drawable,
+			 void *abstract_context)
 {
-  glitz_glx_context_t  *context = (glitz_glx_context_t *) abstract_context;
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
-  glitz_glx_display_info_t *display_info = drawable->screen_info->display_info;
-  
-  if ((glXGetCurrentContext () != context->context) ||
-      (glXGetCurrentDrawable () != drawable->drawable))
-  {
-   if (display_info->thread_info->cctx)
-   {
-       glitz_context_t *ctx = display_info->thread_info->cctx;
+    glitz_glx_context_t  *context = (glitz_glx_context_t *) abstract_context;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	abstract_drawable;
+    glitz_glx_display_info_t *display_info =
+	drawable->screen_info->display_info;
 
-       if (ctx->lose_current)
-           ctx->lose_current (ctx->closure);
-   }
-   glXMakeCurrent (display_info->display, drawable->drawable,
-                   context->context);
-  }
+    if (drawable->base.width  != drawable->width ||
+	drawable->base.height != drawable->height)
+	_glitz_glx_drawable_update_size (drawable,
+					 drawable->base.width,
+					 drawable->base.height);
 
-  display_info->thread_info->cctx = &context->base;
+    if ((glXGetCurrentContext () != context->context) ||
+	(glXGetCurrentDrawable () != drawable->drawable))
+    {
+	if (display_info->thread_info->cctx)
+	{
+	    glitz_context_t *ctx = display_info->thread_info->cctx;
+
+	    if (ctx->lose_current)
+		ctx->lose_current (ctx->closure);
+	}
+
+	glXMakeCurrent (display_info->display, drawable->drawable,
+			context->context);
+    }
+
+    display_info->thread_info->cctx = &context->base;
 }
 
+static void
+_glitz_glx_notify_dummy (void            *abstract_drawable,
+			 glitz_surface_t *surface) {}
+
 static glitz_function_pointer_t
 _glitz_glx_context_get_proc_address (void       *abstract_context,
-                                     const char *name)
+				     const char *name)
 {
-  glitz_glx_context_t  *context = (glitz_glx_context_t *) abstract_context;
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
-      context->base.drawable;
+    glitz_glx_context_t  *context = (glitz_glx_context_t *) abstract_context;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	context->base.drawable;
 
-  _glitz_glx_make_current (context, drawable);
-  
-  return glitz_glx_get_proc_address (name, drawable->screen_info);
+    /* _glitz_glx_make_current (drawable, context, NULL); */
+
+    return glitz_glx_get_proc_address (name, drawable->screen_info);
 }
 
 glitz_glx_context_t *
 glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
-                       glitz_drawable_format_t *format)
+		       glitz_drawable_format_t *format)
 {
-  glitz_glx_context_t *context;
-  glitz_glx_context_t **contexts = screen_info->contexts;
-  int index, n_contexts = screen_info->n_contexts;
-  XID format_id;
+    glitz_glx_context_t *context;
+    glitz_glx_context_t **contexts = screen_info->contexts;
+    int index, n_contexts = screen_info->n_contexts;
+    unsigned long format_id;
 
-  for (; n_contexts; n_contexts--, contexts++)
-    if ((*contexts)->id == screen_info->format_ids[format->id])
-      return *contexts;
+    for (; n_contexts; n_contexts--, contexts++)
+	if ((*contexts)->id == screen_info->formats[format->id].u.uval)
+	    return *contexts;
 
-  index = screen_info->n_contexts++;
+    index = screen_info->n_contexts++;
 
-  screen_info->contexts =
-    realloc (screen_info->contexts,
-             sizeof (glitz_glx_context_t *) * screen_info->n_contexts);
-  if (!screen_info->contexts)
-    return NULL;
+    screen_info->contexts =
+	realloc (screen_info->contexts,
+		 sizeof (glitz_glx_context_t *) * screen_info->n_contexts);
+    if (!screen_info->contexts)
+	return NULL;
 
-  context = malloc (sizeof (glitz_glx_context_t));
-  if (!context)
-    return NULL;
-  
-  screen_info->contexts[index] = context;
+    context = malloc (sizeof (glitz_glx_context_t));
+    if (!context)
+	return NULL;
 
-  format_id = screen_info->format_ids[format->id];
+    screen_info->contexts[index] = context;
 
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
-    _glitz_glx_context_create_using_fbconfig (screen_info,
-                                              format_id,
-                                              screen_info->root_context,
-                                              context);
-  else
-    _glitz_glx_context_create (screen_info,
-                               format_id,
-                               screen_info->root_context,
-                               context);
-  
-  if (!screen_info->root_context)
-    screen_info->root_context = context->context;
+    format_id = screen_info->formats[format->id].u.uval;
 
-  memcpy (&context->backend.gl,
-          &_glitz_glx_gl_proc_address,
-          sizeof (glitz_gl_proc_address_list_t));
+    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
+	_glitz_glx_context_create_using_fbconfig (screen_info,
+						  format_id,
+						  screen_info->root_context,
+						  context);
+    else
+	_glitz_glx_context_create (screen_info,
+				   format_id,
+				   screen_info->root_context,
+				   context);
 
-  context->backend.create_pbuffer = glitz_glx_create_pbuffer;
-  context->backend.destroy = glitz_glx_destroy;
-  context->backend.push_current = glitz_glx_push_current;
-  context->backend.pop_current = glitz_glx_pop_current;
-  context->backend.swap_buffers = glitz_glx_swap_buffers;
-  
-  context->backend.create_context = _glitz_glx_create_context;
-  context->backend.destroy_context = _glitz_glx_context_destroy;
-  context->backend.copy_context = _glitz_glx_copy_context;
-  context->backend.make_current = _glitz_glx_make_current;
-  context->backend.get_proc_address = _glitz_glx_context_get_proc_address;
-  
-  context->backend.drawable_formats = screen_info->formats;
-  context->backend.n_drawable_formats = screen_info->n_formats;
+    if (!screen_info->root_context)
+	screen_info->root_context = context->context;
 
-  context->backend.texture_formats = NULL;
-  context->backend.formats = NULL;
-  context->backend.n_formats = 0;
-  
-  context->backend.program_map = &screen_info->program_map;
-  context->backend.feature_mask = 0;
+    context->backend.gl = &_glitz_glx_gl_proc_address;
 
-  context->initialized = 0;
-  
-  return context;
+    context->backend.create_pbuffer = glitz_glx_create_pbuffer;
+    context->backend.destroy = glitz_glx_destroy;
+    context->backend.push_current = glitz_glx_push_current;
+    context->backend.pop_current = glitz_glx_pop_current;
+    context->backend.attach_notify = _glitz_glx_notify_dummy;
+    context->backend.detach_notify = _glitz_glx_notify_dummy;
+    context->backend.swap_buffers = glitz_glx_swap_buffers;
+
+    context->backend.create_context = _glitz_glx_create_context;
+    context->backend.destroy_context = _glitz_glx_context_destroy;
+    context->backend.copy_context = _glitz_glx_copy_context;
+    context->backend.make_current = _glitz_glx_make_current;
+    context->backend.get_proc_address = _glitz_glx_context_get_proc_address;
+
+    context->backend.drawable_formats = NULL;
+    context->backend.n_drawable_formats = 0;
+
+    if (screen_info->n_formats)
+    {
+	int size;
+
+	size = sizeof (glitz_int_drawable_format_t) * screen_info->n_formats;
+	context->backend.drawable_formats = malloc (size);
+	if (context->backend.drawable_formats)
+	{
+	    memcpy (context->backend.drawable_formats, screen_info->formats,
+		    size);
+	    context->backend.n_drawable_formats = screen_info->n_formats;
+	}
+    }
+
+    context->backend.texture_formats = NULL;
+    context->backend.formats = NULL;
+    context->backend.n_formats = 0;
+
+    context->backend.program_map = &screen_info->program_map;
+    context->backend.feature_mask = 0;
+
+    context->initialized = 0;
+
+    return context;
 }
 
 void
 glitz_glx_context_destroy (glitz_glx_screen_info_t *screen_info,
-                           glitz_glx_context_t     *context)
+			   glitz_glx_context_t     *context)
 {
-  if (context->backend.formats)
-    free (context->backend.formats);
+    if (context->backend.drawable_formats)
+	free (context->backend.drawable_formats);
 
-  if (context->backend.texture_formats)
-    free (context->backend.texture_formats);
-  
-  glXDestroyContext (screen_info->display_info->display,
-                     context->context);
-  free (context);
+    if (context->backend.formats)
+	free (context->backend.formats);
+
+    if (context->backend.texture_formats)
+	free (context->backend.texture_formats);
+
+    glXDestroyContext (screen_info->display_info->display,
+		       context->context);
+    free (context);
 }
 
 static void
 _glitz_glx_context_initialize (glitz_glx_screen_info_t *screen_info,
-                               glitz_glx_context_t     *context)
+			       glitz_glx_context_t     *context)
 {
-  const char *version;
-    
-  glitz_backend_init (&context->backend,
-                      glitz_glx_get_proc_address,
-                      (void *) screen_info);
+    const char *version;
 
-  context->backend.gl.get_integer_v (GLITZ_GL_MAX_VIEWPORT_DIMS,
-                                     context->max_viewport_dims);
+    glitz_backend_init (&context->backend,
+			glitz_glx_get_proc_address,
+			(void *) screen_info);
 
-  glitz_initiate_state (&_glitz_glx_gl_proc_address);
+    glitz_initiate_state (&_glitz_glx_gl_proc_address);
 
-  version = (const char *) context->backend.gl.get_string (GLITZ_GL_VERSION);
-  if (version)
-  {
-    /* Having trouble with TexSubImage2D to NPOT GL_TEXTURE_2D textures when
-       using nvidia's binary driver. Seems like a driver issue, but I'm not
-       sure yet. Turning of NPOT GL_TEXTURE_2D textures until this have been
-       solved. */
-    if (strstr (version, "NVIDIA 61.11") ||
-        strstr (version, "NVIDIA 66.29"))
+    version = (const char *)
+	context->backend.gl->get_string (GLITZ_GL_VERSION);
+    if (version)
     {
-      context->backend.feature_mask &=
-        ~GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK;
+	/* Having trouble with TexSubImage2D to NPOT GL_TEXTURE_2D textures
+	   when using nvidia's binary driver. Seems like a driver issue, but
+	   I'm not sure yet. Turning of NPOT GL_TEXTURE_2D textures until this
+	   have been solved. */
+	if (strstr (version, "NVIDIA 61.11") ||
+	    strstr (version, "NVIDIA 66.29"))
+	{
+	    context->backend.feature_mask &=
+		~GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK;
+	}
     }
-  }
-    
-  context->initialized = 1;
+
+    context->initialized = 1;
 }
 
 static void
 _glitz_glx_context_make_current (glitz_glx_drawable_t *drawable,
-                                 glitz_bool_t         finish)
+				 glitz_bool_t         finish)
 {
-  glitz_glx_display_info_t *display_info = drawable->screen_info->display_info;
-                                 
-  if (finish)
-    glFinish ();
+    glitz_glx_display_info_t *display_info =
+	drawable->screen_info->display_info;
 
-  if (display_info->thread_info->cctx)
-  {
-      glitz_context_t *ctx = display_info->thread_info->cctx;
+    if (finish)
+	glFinish ();
 
-      if (ctx->lose_current)
-          ctx->lose_current (ctx->closure);
+    if (display_info->thread_info->cctx)
+    {
+	glitz_context_t *ctx = display_info->thread_info->cctx;
 
-      display_info->thread_info->cctx = NULL;
-  }
+	if (ctx->lose_current)
+	    ctx->lose_current (ctx->closure);
 
-  glXMakeCurrent (display_info->display,
-                  drawable->drawable,
-                  drawable->context->context);
-  
-  drawable->base.update_all = 1;
-  
-  if (!drawable->context->initialized)
-    _glitz_glx_context_initialize (drawable->screen_info, drawable->context);
+	display_info->thread_info->cctx = NULL;
+    }
+
+    glXMakeCurrent (display_info->display,
+		    drawable->drawable,
+		    drawable->context->context);
+
+    drawable->base.update_all = 1;
+
+    if (!drawable->context->initialized)
+	_glitz_glx_context_initialize (drawable->screen_info,
+				       drawable->context);
 }
 
 static void
 _glitz_glx_context_update (glitz_glx_drawable_t *drawable,
-                           glitz_constraint_t   constraint)
+			   glitz_constraint_t   constraint)
 {
     glitz_glx_display_info_t *dinfo = drawable->screen_info->display_info;
     GLXContext context = NULL;
-    
+
     switch (constraint) {
     case GLITZ_NONE:
-        break;
+	break;
     case GLITZ_ANY_CONTEXT_CURRENT:
-        if (!dinfo->thread_info->cctx)
-            context = glXGetCurrentContext ();
-        
-        if (context == (GLXContext) 0)
-            _glitz_glx_context_make_current (drawable, 0);
-        break;
-  case GLITZ_CONTEXT_CURRENT:
-      if (!dinfo->thread_info->cctx)
-          context = glXGetCurrentContext ();
+	if (!dinfo->thread_info->cctx)
+	    context = glXGetCurrentContext ();
 
-      if (context != drawable->context->context)
-          _glitz_glx_context_make_current (drawable, (context)? 1: 0);
-      break;
+	if (context == (GLXContext) 0)
+	    _glitz_glx_context_make_current (drawable, 0);
+	break;
+    case GLITZ_CONTEXT_CURRENT:
+	if (!dinfo->thread_info->cctx)
+	    context = glXGetCurrentContext ();
+
+	if (context != drawable->context->context)
+	    _glitz_glx_context_make_current (drawable, (context)? 1: 0);
+	break;
     case GLITZ_DRAWABLE_CURRENT:
-        if (!dinfo->thread_info->cctx)
-            context = glXGetCurrentContext ();
+	if (!dinfo->thread_info->cctx)
+	    context = glXGetCurrentContext ();
 
-        if ((context != drawable->context->context) ||
-            (glXGetCurrentDrawable () != drawable->drawable))
-            _glitz_glx_context_make_current (drawable, (context)? 1: 0);
-        break;
+	if (drawable->base.width  != drawable->width ||
+	    drawable->base.height != drawable->height)
+	    _glitz_glx_drawable_update_size (drawable,
+					     drawable->base.width,
+					     drawable->base.height);
+
+	if ((context != drawable->context->context) ||
+	    (glXGetCurrentDrawable () != drawable->drawable))
+	    _glitz_glx_context_make_current (drawable, (context)? 1: 0);
+	break;
     }
 }
 
-void
+glitz_bool_t
 glitz_glx_push_current (void               *abstract_drawable,
-                        glitz_surface_t    *surface,
-                        glitz_constraint_t constraint)
+			glitz_surface_t    *surface,
+			glitz_constraint_t constraint)
 {
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
-  glitz_glx_context_info_t *context_info;
-  int index;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	abstract_drawable;
+    glitz_glx_context_info_t *context_info;
+    int index;
 
-  index = drawable->screen_info->context_stack_size++;
+    index = drawable->screen_info->context_stack_size++;
 
-  context_info = &drawable->screen_info->context_stack[index];
-  context_info->drawable = drawable;
-  context_info->surface = surface;
-  context_info->constraint = constraint;
-  
-  _glitz_glx_context_update (context_info->drawable, constraint);
+    context_info = &drawable->screen_info->context_stack[index];
+    context_info->drawable = drawable;
+    context_info->surface = surface;
+    context_info->constraint = constraint;
+
+    _glitz_glx_context_update (context_info->drawable, constraint);
+
+    return 1;
 }
 
 glitz_surface_t *
 glitz_glx_pop_current (void *abstract_drawable)
 {
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
-  glitz_glx_context_info_t *context_info = NULL;
-  int index;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	abstract_drawable;
+    glitz_glx_context_info_t *context_info = NULL;
+    int index;
 
-  drawable->screen_info->context_stack_size--;
-  index = drawable->screen_info->context_stack_size - 1;
+    drawable->screen_info->context_stack_size--;
+    index = drawable->screen_info->context_stack_size - 1;
 
-  context_info = &drawable->screen_info->context_stack[index];
+    context_info = &drawable->screen_info->context_stack[index];
 
-  if (context_info->drawable)
-    _glitz_glx_context_update (context_info->drawable,
-                               context_info->constraint);
-  
-  if (context_info->constraint == GLITZ_DRAWABLE_CURRENT)
-      return context_info->surface;
-  
-  return NULL;
+    if (context_info->drawable)
+	_glitz_glx_context_update (context_info->drawable,
+				   context_info->constraint);
+
+    if (context_info->constraint == GLITZ_DRAWABLE_CURRENT)
+	return context_info->surface;
+
+    return NULL;
 }

Index: glitz_glx_drawable.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_drawable.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_glx_drawable.c	12 Apr 2005 14:54:56 -0000	1.3
+++ glitz_glx_drawable.c	14 Sep 2005 15:57:16 -0000	1.4
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -31,172 +31,212 @@
 
 static glitz_glx_drawable_t *
 _glitz_glx_create_drawable (glitz_glx_screen_info_t *screen_info,
-                            glitz_glx_context_t     *context,
-                            glitz_drawable_format_t *format,
-                            GLXDrawable             glx_drawable,
-                            GLXPbuffer              glx_pbuffer,
-                            int                     width,
-                            int                     height)
+			    glitz_glx_context_t     *context,
+			    glitz_drawable_format_t *format,
+			    GLXDrawable             glx_drawable,
+			    GLXPbuffer              glx_pbuffer,
+			    int                     width,
+			    int                     height)
 {
-  glitz_glx_drawable_t *drawable;
-  
-  if (width <= 0 || height <= 0)
-    return NULL;
+    glitz_glx_drawable_t *drawable;
 
-  drawable = (glitz_glx_drawable_t *) malloc (sizeof (glitz_glx_drawable_t));
-  if (drawable == NULL)
-    return NULL;
+    drawable = (glitz_glx_drawable_t *) malloc (sizeof (glitz_glx_drawable_t));
+    if (drawable == NULL)
+	return NULL;
 
-  drawable->base.ref_count = 1;
-  drawable->screen_info = screen_info;
-  drawable->context = context;
-  drawable->drawable = glx_drawable;
-  drawable->pbuffer = glx_pbuffer;
-  drawable->base.format = format;
-  drawable->base.backend = &context->backend;
+    drawable->screen_info = screen_info;
+    drawable->context = context;
+    drawable->drawable = glx_drawable;
+    drawable->pbuffer = glx_pbuffer;
+    drawable->width = width;
+    drawable->height = height;
 
-  glitz_drawable_update_size (&drawable->base, width, height);
+    _glitz_drawable_init (&drawable->base,
+			  &screen_info->formats[format->id],
+			  &context->backend,
+			  width, height);
 
-  if (!context->initialized) {
-    glitz_glx_push_current (drawable, NULL, GLITZ_CONTEXT_CURRENT);
-    glitz_glx_pop_current (drawable);
-  }
-  
-  if (width > context->max_viewport_dims[0] ||
-      height > context->max_viewport_dims[1]) {
-    free (drawable);
-    return NULL;
-  }
-  
-  screen_info->drawables++;
-  
-  return drawable;
+    if (!context->initialized) {
+	glitz_glx_push_current (drawable, NULL, GLITZ_CONTEXT_CURRENT);
+	glitz_glx_pop_current (drawable);
+    }
+
+    if (width > context->backend.max_viewport_dims[0] ||
+	height > context->backend.max_viewport_dims[1]) {
+	free (drawable);
+	return NULL;
+    }
+
+    screen_info->drawables++;
+
+    return drawable;
+}
+
+glitz_bool_t
+_glitz_glx_drawable_update_size (glitz_glx_drawable_t *drawable,
+				 int                  width,
+				 int                  height)
+{
+    if (drawable->pbuffer)
+    {
+	glitz_glx_pbuffer_destroy (drawable->screen_info, drawable->pbuffer);
+	drawable->drawable = drawable->pbuffer =
+	    glitz_glx_pbuffer_create (drawable->screen_info,
+				      drawable->context->fbconfig,
+				      (int) width, (int) height);
+	if (!drawable->pbuffer)
+	    return 0;
+    }
+
+    drawable->width  = width;
+    drawable->height = height;
+
+    return 1;
 }
 
 static glitz_drawable_t *
 _glitz_glx_create_pbuffer_drawable (glitz_glx_screen_info_t *screen_info,
-                                    glitz_drawable_format_t *format,
-                                    unsigned int            width,
-                                    unsigned int            height)
+				    glitz_drawable_format_t *format,
+				    unsigned int            width,
+				    unsigned int            height)
 {
-  glitz_glx_drawable_t *drawable;
-  glitz_glx_context_t *context;
-  GLXPbuffer pbuffer;
+    glitz_glx_drawable_t *drawable;
+    glitz_glx_context_t *context;
+    GLXPbuffer pbuffer;
 
-  if (!format->types.pbuffer)
-    return NULL;
-  
-  context = glitz_glx_context_get (screen_info, format);
-  if (!context)
-    return NULL;
+    context = glitz_glx_context_get (screen_info, format);
+    if (!context)
+	return NULL;
 
-  pbuffer = glitz_glx_pbuffer_create (screen_info, context->fbconfig,
-                                      (int) width, (int) height);
-  if (!pbuffer)
-    return NULL;
-  
-  drawable = _glitz_glx_create_drawable (screen_info, context, format,
-                                         pbuffer, pbuffer,
-                                         width, height);
-  if (!drawable) {
-    glitz_glx_pbuffer_destroy (screen_info, pbuffer);
-    return NULL;
-  }
-  
-  return &drawable->base;
+    pbuffer = glitz_glx_pbuffer_create (screen_info, context->fbconfig,
+					(int) width, (int) height);
+    if (!pbuffer)
+	return NULL;
+
+    drawable = _glitz_glx_create_drawable (screen_info, context, format,
+					   pbuffer, pbuffer,
+					   width, height);
+    if (!drawable) {
+	glitz_glx_pbuffer_destroy (screen_info, pbuffer);
+	return NULL;
+    }
+
+    return &drawable->base;
 }
 
 glitz_drawable_t *
 glitz_glx_create_pbuffer (void                    *abstract_templ,
-                          glitz_drawable_format_t *format,
-                          unsigned int            width,
-                          unsigned int            height)
+			  glitz_drawable_format_t *format,
+			  unsigned int            width,
+			  unsigned int            height)
 {
-  glitz_glx_drawable_t *templ = (glitz_glx_drawable_t *) abstract_templ;
+    glitz_glx_drawable_t *templ = (glitz_glx_drawable_t *) abstract_templ;
 
-  return _glitz_glx_create_pbuffer_drawable (templ->screen_info, format,
-                                             width, height);
+    return _glitz_glx_create_pbuffer_drawable (templ->screen_info, format,
+					       width, height);
 }
 
 glitz_drawable_t *
 glitz_glx_create_drawable_for_window (Display                 *display,
-                                      int                     screen,
-                                      glitz_drawable_format_t *format,
-                                      Window                  window,
-                                      unsigned int            width,
-                                      unsigned int            height)
+				      int                     screen,
+				      glitz_drawable_format_t *format,
+				      Window                  window,
+				      unsigned int            width,
+				      unsigned int            height)
 {
-  glitz_glx_drawable_t *drawable;
-  glitz_glx_screen_info_t *screen_info;
-  glitz_glx_context_t *context;
+    glitz_glx_drawable_t        *drawable;
+    glitz_glx_screen_info_t     *screen_info;
+    glitz_glx_context_t         *context;
+    glitz_int_drawable_format_t *iformat;
 
-  screen_info = glitz_glx_screen_info_get (display, screen);
-  if (!screen_info)
-    return NULL;
-  
-  context = glitz_glx_context_get (screen_info, format);
-  if (!context)
-    return NULL;
-  
-  drawable = _glitz_glx_create_drawable (screen_info, context, format,
-                                         window, (GLXPbuffer) 0,
-                                         width, height);
-  if (!drawable)
-    return NULL;
+    screen_info = glitz_glx_screen_info_get (display, screen);
+    if (!screen_info)
+	return NULL;
 
-  return &drawable->base;
+    if (format->id >= screen_info->n_formats)
+	return NULL;
+
+    iformat = &screen_info->formats[format->id];
+    if (!(iformat->types & GLITZ_DRAWABLE_TYPE_WINDOW_MASK))
+	return NULL;
+
+    context = glitz_glx_context_get (screen_info, format);
+    if (!context)
+	return NULL;
+
+    drawable = _glitz_glx_create_drawable (screen_info, context, format,
+					   window, (GLXPbuffer) 0,
+					   width, height);
+    if (!drawable)
+	return NULL;
+
+    return &drawable->base;
 }
 slim_hidden_def(glitz_glx_create_drawable_for_window);
 
 glitz_drawable_t *
 glitz_glx_create_pbuffer_drawable (Display                 *display,
-                                   int                     screen,
-                                   glitz_drawable_format_t *format,
-                                   unsigned int            width,
-                                   unsigned int            height)
+				   int                     screen,
+				   glitz_drawable_format_t *format,
+				   unsigned int            width,
+				   unsigned int            height)
 {
-  glitz_glx_screen_info_t *screen_info;
+    glitz_glx_screen_info_t     *screen_info;
+    glitz_int_drawable_format_t *iformat;
 
-  screen_info = glitz_glx_screen_info_get (display, screen);
-  if (!screen_info)
-    return NULL;
+    screen_info = glitz_glx_screen_info_get (display, screen);
+    if (!screen_info)
+	return NULL;
 
-  return _glitz_glx_create_pbuffer_drawable (screen_info, format,
-                                             width, height);
+    if (format->id >= screen_info->n_formats)
+	return NULL;
+
+    iformat = &screen_info->formats[format->id];
+    if (!(iformat->types & GLITZ_DRAWABLE_TYPE_PBUFFER_MASK))
+	return NULL;
+
+    return _glitz_glx_create_pbuffer_drawable (screen_info, format,
+					       width, height);
 }
 slim_hidden_def(glitz_glx_create_pbuffer_drawable);
 
 void
 glitz_glx_destroy (void *abstract_drawable)
 {
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	abstract_drawable;
 
-  drawable->screen_info->drawables--;
-  if (drawable->screen_info->drawables == 0) {
-    /*
-     * Last drawable? We have to destroy all fragment programs as this may
-     * be our last chance to have a context current.
-     */
-    glitz_glx_push_current (abstract_drawable, NULL, GLITZ_CONTEXT_CURRENT);
-    glitz_program_map_fini (&drawable->base.backend->gl,
-                            &drawable->screen_info->program_map);
-    glitz_glx_pop_current (abstract_drawable);
-  }
+    drawable->screen_info->drawables--;
+    if (drawable->screen_info->drawables == 0) {
+	/*
+	 * Last drawable? We have to destroy all fragment programs as this may
+	 * be our last chance to have a context current.
+	 */
+	glitz_glx_push_current (abstract_drawable, NULL,
+				GLITZ_CONTEXT_CURRENT);
+	glitz_program_map_fini (drawable->base.backend->gl,
+				&drawable->screen_info->program_map);
+	glitz_glx_pop_current (abstract_drawable);
+    }
 
-  if (glXGetCurrentDrawable () == drawable->drawable)
-    glXMakeCurrent (drawable->screen_info->display_info->display, None, NULL);
-  
-  if (drawable->pbuffer)
-    glitz_glx_pbuffer_destroy (drawable->screen_info, drawable->pbuffer);
-  
-  free (drawable);
+    if (glXGetCurrentDrawable () == drawable->drawable)
+	glXMakeCurrent (drawable->screen_info->display_info->display,
+			None, NULL);
+
+    if (drawable->pbuffer)
+	glitz_glx_pbuffer_destroy (drawable->screen_info, drawable->pbuffer);
+
+    free (drawable);
 }
 
-void
+glitz_bool_t
 glitz_glx_swap_buffers (void *abstract_drawable)
 {
-  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
+    glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+	abstract_drawable;
 
-  glXSwapBuffers (drawable->screen_info->display_info->display,
-                  drawable->drawable);
+    glXSwapBuffers (drawable->screen_info->display_info->display,
+		    drawable->drawable);
+
+    return 1;
 }

Index: glitz_glx_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_extension.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_glx_extension.c	25 Jan 2005 19:50:26 -0000	1.2
+++ glitz_glx_extension.c	14 Sep 2005 15:57:16 -0000	1.3
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -30,41 +30,42 @@
 #include "glitz_glxint.h"
 
 static glitz_extension_map glx_extensions[] = {
-  { 0.0, "GLX_SGIX_fbconfig", GLITZ_GLX_FEATURE_FBCONFIG_MASK },
-  { 0.0, "GLX_SGIX_pbuffer", GLITZ_GLX_FEATURE_PBUFFER_MASK },
-  { 0.0, "GLX_SGI_make_current_read",
-    GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK },
-  { 0.0, "GLX_ARB_multisample", GLITZ_GLX_FEATURE_MULTISAMPLE_MASK },
-  { 0.0, NULL, 0 }
+    { 0.0, "GLX_EXT_visual_rating", GLITZ_GLX_FEATURE_VISUAL_RATING_MASK },
+    { 0.0, "GLX_SGIX_fbconfig", GLITZ_GLX_FEATURE_FBCONFIG_MASK },
+    { 0.0, "GLX_SGIX_pbuffer", GLITZ_GLX_FEATURE_PBUFFER_MASK },
+    { 0.0, "GLX_SGI_make_current_read",
+      GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK },
+    { 0.0, "GLX_ARB_multisample", GLITZ_GLX_FEATURE_MULTISAMPLE_MASK },
+    { 0.0, NULL, 0 }
 };
 
 void
 glitz_glx_query_extensions (glitz_glx_screen_info_t *screen_info,
-                            glitz_gl_float_t        glx_version)
+			    glitz_gl_float_t        glx_version)
 {
-  const char *glx_extensions_string;
+    const char *glx_extensions_string;
 
-  glx_extensions_string =
-    glXQueryExtensionsString (screen_info->display_info->display,
-                              screen_info->screen);
-  
-  screen_info->glx_feature_mask =
-    glitz_extensions_query (glx_version,
-                            glx_extensions_string,
-                            glx_extensions);
-  
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK) {
-    const char *vendor;
+    glx_extensions_string =
+	glXQueryExtensionsString (screen_info->display_info->display,
+				  screen_info->screen);
 
-    vendor = glXGetClientString (screen_info->display_info->display,
-                                 GLX_VENDOR);
-    
-    if (vendor) {
-      
-      /* NVIDIA's driver seem to support multisample with pbuffers */
-      if (!strncmp ("NVIDIA", vendor, 6))
-        screen_info->glx_feature_mask |=
-          GLITZ_GLX_FEATURE_PBUFFER_MULTISAMPLE_MASK;
+    screen_info->glx_feature_mask =
+	glitz_extensions_query (glx_version,
+				glx_extensions_string,
+				glx_extensions);
+
+    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK) {
+	const char *vendor;
+
+	vendor = glXGetClientString (screen_info->display_info->display,
+				     GLX_VENDOR);
+
+	if (vendor) {
+
+	    /* NVIDIA's driver seem to support multisample with pbuffers */
+	    if (!strncmp ("NVIDIA", vendor, 6))
+		screen_info->glx_feature_mask |=
+		    GLITZ_GLX_FEATURE_PBUFFER_MULTISAMPLE_MASK;
+	}
     }
-  }
 }

Index: glitz_glx_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_format.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_glx_format.c	29 Jun 2005 01:26:39 -0000	1.3
+++ glitz_glx_format.c	14 Sep 2005 15:57:16 -0000	1.4
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -34,390 +34,459 @@
 
 static int
 _glitz_glx_format_compare (const void *elem1,
-                           const void *elem2)
+			   const void *elem2)
 {
-  int i, score[2];
-  glitz_drawable_format_t *format[2];
-  
-  format[0] = (glitz_drawable_format_t *) elem1;
-  format[1] = (glitz_drawable_format_t *) elem2;
-  i = score[0] = score[1] = 0;
+    glitz_int_drawable_format_t *format[2];
+    int				i, score[2];
 
-  for (; i < 2; i++) {
-    if (format[i]->color.red_size) {
-      if (format[i]->color.red_size == 8)
-        score[i] += 5;
-      score[i] += 10;
-    }
+    format[0] = (glitz_int_drawable_format_t *) elem1;
+    format[1] = (glitz_int_drawable_format_t *) elem2;
+    i = score[0] = score[1] = 0;
 
-    if (format[i]->color.green_size) {
-      if (format[i]->color.green_size == 8)
-        score[i] += 5;
-      score[i] += 10;
-    }
-    
-    if (format[i]->color.alpha_size) {
-      if (format[i]->color.alpha_size == 8)
-        score[i] += 5;
-      score[i] += 10;
-    }
+    for (; i < 2; i++)
+    {
+	if (format[i]->d.color.red_size)
+	{
+	    if (format[i]->d.color.red_size >= 8)
+		score[i] += 5;
 
-    if (format[i]->stencil_size)
-      score[i] += 5;
+	    score[i] += 10;
+	}
 
-    if (format[i]->depth_size)
-      score[i] += 5;
+	if (format[i]->d.color.alpha_size)
+	{
+	    if (format[i]->d.color.alpha_size >= 8)
+		score[i] += 5;
 
-    if (format[i]->doublebuffer)
-      score[i] += 10;
-    
-    if (format[i]->types.window)
-      score[i] += 10;
-    
-    if (format[i]->types.pbuffer)
-      score[i] += 10;
-    
-    if (format[i]->samples > 1) 
-      score[i] -= (20 - format[i]->samples);
-  }
-  
-  return score[1] - score[0];
+	    score[i] += 10;
+	}
+
+	if (format[i]->d.stencil_size)
+	    score[i] += 5;
+
+	if (format[i]->d.depth_size)
+	    score[i] += 5;
+
+	if (format[i]->d.doublebuffer)
+	    score[i] += 10;
+
+	if (format[i]->d.samples > 1)
+	    score[i] -= (20 - format[i]->d.samples);
+
+	if (format[i]->types & GLITZ_DRAWABLE_TYPE_WINDOW_MASK)
+	    score[i] += 10;
+
+	if (format[i]->types & GLITZ_DRAWABLE_TYPE_PBUFFER_MASK)
+	    score[i] += 10;
+
+	if (format[i]->caveat)
+	    score[i] -= 1000;
+    }
+
+    return score[1] - score[0];
 }
 
 static void
-_glitz_add_format (glitz_glx_screen_info_t *screen_info,
-                   glitz_drawable_format_t *format,
-                   XID                     id)
+_glitz_add_format (glitz_glx_screen_info_t     *screen_info,
+		   glitz_int_drawable_format_t *format)
 {
     int n = screen_info->n_formats;
-    
-    screen_info->formats =
-      realloc (screen_info->formats,
-               sizeof (glitz_drawable_format_t) * (n + 1));
-    screen_info->format_ids =
-      realloc (screen_info->format_ids, sizeof (XID) * (n + 1));
 
-    if (screen_info->formats && screen_info->format_ids) {
-      screen_info->formats[n] = *format;
-      screen_info->formats[n].id = n;
-      screen_info->format_ids[n] = id;
-      screen_info->n_formats++;
+    screen_info->formats =
+	realloc (screen_info->formats,
+		 sizeof (glitz_int_drawable_format_t) * (n + 1));
+    if (screen_info->formats)
+    {
+	screen_info->formats[n] = *format;
+	screen_info->formats[n].d.id = n;
+	screen_info->n_formats++;
     }
 }
 
 static void
 _glitz_glx_query_formats (glitz_glx_screen_info_t *screen_info)
 {
-  Display *display;
-  glitz_drawable_format_t format;
-  XVisualInfo visual_templ;
-  XVisualInfo *visuals;
-  int i, num_visuals;
-  
-  display = screen_info->display_info->display;
+    Display			*display;
+    glitz_int_drawable_format_t format;
+    XVisualInfo			visual_templ;
+    XVisualInfo			*visuals;
+    int				i, num_visuals;
 
-  visual_templ.screen = screen_info->screen;
-  visuals = XGetVisualInfo (display, VisualScreenMask,
-                            &visual_templ, &num_visuals);
+    display = screen_info->display_info->display;
 
-  /* No pbuffers without fbconfigs */
-  format.types.window = 1;
-  format.types.pbuffer = 0;
-  format.id = 0;
+    visual_templ.screen = screen_info->screen;
+    visuals = XGetVisualInfo (display, VisualScreenMask,
+			      &visual_templ, &num_visuals);
 
-  for (i = 0; i < num_visuals; i++) {
-    int value;
-    
-    if ((glXGetConfig (display, &visuals[i], GLX_USE_GL, &value) != 0) ||
-        (value == 0))
-      continue;
-    
-    glXGetConfig (display, &visuals[i], GLX_RGBA, &value);
-    if (value == 0)
-      continue;
+    /* No pbuffers without fbconfigs */
+    format.types = GLITZ_DRAWABLE_TYPE_WINDOW_MASK;
+    format.d.id  = 0;
 
-    /* Stereo is not supported yet */
-    glXGetConfig (display, &visuals[i], GLX_STEREO, &value);
-    if (value != 0)
-      continue;
-    
-    glXGetConfig (display, &visuals[i], GLX_RED_SIZE, &value);
-    format.color.red_size = (unsigned short) value;
-    glXGetConfig (display, &visuals[i], GLX_GREEN_SIZE, &value);
-    format.color.green_size = (unsigned short) value;
-    glXGetConfig (display, &visuals[i], GLX_BLUE_SIZE, &value);
-    format.color.blue_size = (unsigned short) value;
-    glXGetConfig (display, &visuals[i], GLX_ALPHA_SIZE, &value);
-    format.color.alpha_size = (unsigned short) value;
-    glXGetConfig (display, &visuals[i], GLX_DEPTH_SIZE, &value);
-    format.depth_size = (unsigned short) value;
-    glXGetConfig (display, &visuals[i], GLX_STENCIL_SIZE, &value);
-    format.stencil_size = (unsigned short) value;
-    glXGetConfig (display, &visuals[i], GLX_DOUBLEBUFFER, &value);
-    format.doublebuffer = (value) ? 1: 0;
+    for (i = 0; i < num_visuals; i++)
+    {
+	int value;
 
-    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK) {
-      glXGetConfig (display, &visuals[i], GLX_SAMPLE_BUFFERS_ARB, &value);
-      if (value) {
-        glXGetConfig (display, &visuals[i], GLX_SAMPLES_ARB, &value);
-        format.samples = (unsigned short) (value > 1)? value: 1;
-      } else
-        format.samples = 1;
-    } else
-      format.samples = 1;
-    
-    _glitz_add_format (screen_info, &format, visuals[i].visualid);
-  }
-  
-  if (visuals)
-    XFree (visuals);
+	if ((glXGetConfig (display, &visuals[i], GLX_USE_GL, &value) != 0) ||
+	    (value == 0))
+	    continue;
+
+	glXGetConfig (display, &visuals[i], GLX_RGBA, &value);
+	if (value == 0)
+	    continue;
+
+	/* Stereo is not supported yet */
+	glXGetConfig (display, &visuals[i], GLX_STEREO, &value);
+	if (value != 0)
+	    continue;
+
+	glXGetConfig (display, &visuals[i], GLX_RED_SIZE, &value);
+	format.d.color.red_size = (unsigned short) value;
+	glXGetConfig (display, &visuals[i], GLX_GREEN_SIZE, &value);
+	format.d.color.green_size = (unsigned short) value;
+	glXGetConfig (display, &visuals[i], GLX_BLUE_SIZE, &value);
+	format.d.color.blue_size = (unsigned short) value;
+	glXGetConfig (display, &visuals[i], GLX_ALPHA_SIZE, &value);
+	format.d.color.alpha_size = (unsigned short) value;
+	glXGetConfig (display, &visuals[i], GLX_DEPTH_SIZE, &value);
+	format.d.depth_size = (unsigned short) value;
+	glXGetConfig (display, &visuals[i], GLX_STENCIL_SIZE, &value);
+	format.d.stencil_size = (unsigned short) value;
+	glXGetConfig (display, &visuals[i], GLX_DOUBLEBUFFER, &value);
+	format.d.doublebuffer = (value) ? 1: 0;
+
+	if (screen_info->glx_feature_mask &
+	    GLITZ_GLX_FEATURE_VISUAL_RATING_MASK)
+	{
+	    glXGetConfig (display, &visuals[i], GLX_VISUAL_CAVEAT_EXT, &value);
+	    switch (value) {
+	    case GLX_SLOW_VISUAL_EXT:
+	    case GLX_NON_CONFORMANT_VISUAL_EXT:
+		format.caveat = 1;
+		break;
+	    default:
+		format.caveat = 0;
+		break;
+	    }
+	}
+	else
+	    format.caveat = 0;
+
+	if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK)
+	{
+	    glXGetConfig (display, &visuals[i], GLX_SAMPLE_BUFFERS_ARB,
+			  &value);
+	    if (value)
+	    {
+		glXGetConfig (display, &visuals[i], GLX_SAMPLES_ARB, &value);
+		format.d.samples = (unsigned short) (value > 1)? value: 1;
+	    }
+	    else
+		format.d.samples = 1;
+	}
+	else
+	    format.d.samples = 1;
+
+	format.u.uval = visuals[i].visualid;
+
+	_glitz_add_format (screen_info, &format);
+    }
+
+    if (visuals)
+	XFree (visuals);
 }
 
 static glitz_status_t
 _glitz_glx_query_formats_using_fbconfigs (glitz_glx_screen_info_t *screen_info)
 {
-  glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
-  Display *display;
-  glitz_drawable_format_t format;
-  GLXFBConfig *fbconfigs;
-  int i, num_configs;
-  XID id;
-  
-  display = screen_info->display_info->display;
+    glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
+    Display				 *display;
+    glitz_int_drawable_format_t		 format;
+    GLXFBConfig				 *fbconfigs;
+    int					 i, num_configs;
 
-  fbconfigs = glx->get_fbconfigs (display, screen_info->screen, &num_configs);
-  if (!fbconfigs) {
-    /* fbconfigs are not supported, falling back to visuals */
-    screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_FBCONFIG_MASK;
-    screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
-    
-    return GLITZ_STATUS_NOT_SUPPORTED;
-  }
+    display = screen_info->display_info->display;
 
-  for (i = 0; i < num_configs; i++) {
-    int value;
-    
-    if ((glx->get_fbconfig_attrib (display, fbconfigs[i],
-                                   GLX_RENDER_TYPE, &value) != 0) ||
-        (!(value & GLX_RGBA_BIT)))
-      continue;
+    fbconfigs = glx->get_fbconfigs (display, screen_info->screen,
+				    &num_configs);
+    if (!fbconfigs)
+    {
+	/* fbconfigs are not supported, falling back to visuals */
+	screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_FBCONFIG_MASK;
+	screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
 
-    /* Stereo is not supported yet */
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_STEREO, &value);
-    if (value != 0)
-      continue;
+	return GLITZ_STATUS_NOT_SUPPORTED;
+    }
 
-    glx->get_fbconfig_attrib (display, fbconfigs[i],
-                              GLX_DRAWABLE_TYPE, &value);
-    if (!((value & GLX_WINDOW_BIT) || (value & GLX_PBUFFER_BIT)))
-      continue;
-    
-    format.types.window = (value & GLX_WINDOW_BIT)? 1: 0;
-    format.types.pbuffer = (value & GLX_PBUFFER_BIT)? 1: 0;
-    format.id = 0;
-    
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value);
-    id = (XID) value;
+    for (i = 0; i < num_configs; i++)
+    {
+	int value;
 
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_RED_SIZE, &value);
-    format.color.red_size = (unsigned short) value;
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_GREEN_SIZE, &value);
-    format.color.green_size = (unsigned short) value;
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_BLUE_SIZE, &value);
-    format.color.blue_size = (unsigned short) value;
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_ALPHA_SIZE, &value);
-    format.color.alpha_size = (unsigned short) value;
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_DEPTH_SIZE, &value);
-    format.depth_size = (unsigned short) value;
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_STENCIL_SIZE, &value);
-    format.stencil_size = (unsigned short) value;
-    glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_DOUBLEBUFFER, &value);
-    format.doublebuffer = (value)? 1: 0;
+	if ((glx->get_fbconfig_attrib (display, fbconfigs[i],
+				       GLX_RENDER_TYPE, &value) != 0) ||
+	    (!(value & GLX_RGBA_BIT)))
+	    continue;
 
-    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK) {
-      glx->get_fbconfig_attrib (display, fbconfigs[i],
-                                GLX_SAMPLE_BUFFERS_ARB, &value);
-      if (value) {
-        glx->get_fbconfig_attrib (display, fbconfigs[i],
-                                  GLX_SAMPLES_ARB, &value);
-        format.samples = (unsigned short) (value > 1)? value: 1;
-        if (format.samples > 1) {
-          if (!(screen_info->glx_feature_mask &
-                GLITZ_GLX_FEATURE_PBUFFER_MULTISAMPLE_MASK))
-            format.types.pbuffer = 0;
-        }
-      } else
-        format.samples = 1;
-    } else
-      format.samples = 1;
-    
-    _glitz_add_format (screen_info, &format, id);
-  }
-  
-  if (fbconfigs)
-    XFree (fbconfigs);
+	/* Stereo is not supported yet */
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_STEREO, &value);
+	if (value != 0)
+	    continue;
 
-  return GLITZ_STATUS_SUCCESS;
+	glx->get_fbconfig_attrib (display, fbconfigs[i],
+				  GLX_DRAWABLE_TYPE, &value);
+	if (!((value & GLX_WINDOW_BIT) || (value & GLX_PBUFFER_BIT)))
+	    continue;
+
+	format.types = 0;
+	if (value & GLX_WINDOW_BIT)
+	    format.types |= GLITZ_DRAWABLE_TYPE_WINDOW_MASK;
+
+	if (value & GLX_PBUFFER_BIT)
+	    format.types |= GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+
+	format.d.id = 0;
+
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_FBCONFIG_ID,
+				  &value);
+	format.u.uval = value;
+
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_RED_SIZE, &value);
+	format.d.color.red_size = (unsigned short) value;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_GREEN_SIZE,
+				  &value);
+	format.d.color.green_size = (unsigned short) value;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_BLUE_SIZE,
+				  &value);
+	format.d.color.blue_size = (unsigned short) value;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_ALPHA_SIZE,
+				  &value);
+	format.d.color.alpha_size = (unsigned short) value;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_DEPTH_SIZE,
+				  &value);
+	format.d.depth_size = (unsigned short) value;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_STENCIL_SIZE,
+				  &value);
+	format.d.stencil_size = (unsigned short) value;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_DOUBLEBUFFER,
+				  &value);
+	format.d.doublebuffer = (value)? 1: 0;
+	glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_CONFIG_CAVEAT,
+				  &value);
+	switch (value) {
+	case GLX_SLOW_VISUAL_EXT:
+	case GLX_NON_CONFORMANT_VISUAL_EXT:
+	    format.caveat = 1;
+	    break;
+	default:
+	    format.caveat = 0;
+	    break;
+	}
+
+	if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK)
+	{
+	    glx->get_fbconfig_attrib (display, fbconfigs[i],
+				      GLX_SAMPLE_BUFFERS_ARB, &value);
+	    if (value)
+	    {
+		glx->get_fbconfig_attrib (display, fbconfigs[i],
+					  GLX_SAMPLES_ARB, &value);
+		format.d.samples = (unsigned short) (value > 1)? value: 1;
+		if (format.d.samples > 1)
+		{
+		    if (!(screen_info->glx_feature_mask &
+			  GLITZ_GLX_FEATURE_PBUFFER_MULTISAMPLE_MASK))
+			format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+		}
+	    }
+	    else
+		format.d.samples = 1;
+	}
+	else
+	    format.d.samples = 1;
+
+	_glitz_add_format (screen_info, &format);
+    }
+
+    if (fbconfigs)
+	XFree (fbconfigs);
+
+    return GLITZ_STATUS_SUCCESS;
 }
 
 void
 glitz_glx_query_formats (glitz_glx_screen_info_t *screen_info)
 {
-  glitz_status_t status = GLITZ_STATUS_NOT_SUPPORTED;
-  XID *new_ids;
-  int i;
+    glitz_status_t status = GLITZ_STATUS_NOT_SUPPORTED;
+    int		   i;
 
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
-    status = _glitz_glx_query_formats_using_fbconfigs (screen_info);
+    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
+	status = _glitz_glx_query_formats_using_fbconfigs (screen_info);
 
-  if (status)
-    _glitz_glx_query_formats (screen_info);
+    if (status)
+	_glitz_glx_query_formats (screen_info);
 
-  if (!screen_info->n_formats)
-    return;
+    if (!screen_info->n_formats)
+	return;
 
-  qsort (screen_info->formats, screen_info->n_formats, 
-         sizeof (glitz_drawable_format_t), _glitz_glx_format_compare);
+    qsort (screen_info->formats, screen_info->n_formats,
+	   sizeof (glitz_int_drawable_format_t), _glitz_glx_format_compare);
 
-  /*
-   * Update XID list so that it matches the sorted format list.
-   */
-  new_ids = malloc (sizeof (XID) * screen_info->n_formats);
-  if (!new_ids) {
-    screen_info->n_formats = 0;
-    return;
-  }
-  
-  for (i = 0; i < screen_info->n_formats; i++) {
-    new_ids[i] = screen_info->format_ids[screen_info->formats[i].id];
-    screen_info->formats[i].id = i;
-  }
-  
-  free (screen_info->format_ids);
-  screen_info->format_ids = new_ids;
+    for (i = 0; i < screen_info->n_formats; i++)
+	screen_info->formats[i].d.id = i;
 }
 
 glitz_drawable_format_t *
-glitz_glx_find_drawable_format (Display                       *display,
-                                int                           screen,
-                                unsigned long                 mask,
-                                const glitz_drawable_format_t *templ,
-                                int                           count)
+glitz_glx_find_window_format (Display                       *display,
+			      int                           screen,
+			      unsigned long                 mask,
+			      const glitz_drawable_format_t *templ,
+			      int                           count)
 {
-  glitz_glx_screen_info_t *screen_info =
-    glitz_glx_screen_info_get (display, screen);
+    glitz_int_drawable_format_t itempl;
+    glitz_glx_screen_info_t *screen_info =
+	glitz_glx_screen_info_get (display, screen);
 
-  return glitz_drawable_format_find (screen_info->formats,
-                                     screen_info->n_formats,
-                                     mask, templ, count);
+    glitz_drawable_format_copy (templ, &itempl.d, mask);
+
+    itempl.types = GLITZ_DRAWABLE_TYPE_WINDOW_MASK;
+    mask |= GLITZ_INT_FORMAT_WINDOW_MASK;
+
+    return glitz_drawable_format_find (screen_info->formats,
+				       screen_info->n_formats,
+				       mask, &itempl, count);
 }
-slim_hidden_def(glitz_glx_find_drawable_format);
+slim_hidden_def(glitz_glx_find_window_format);
+
+glitz_drawable_format_t *
+glitz_glx_find_pbuffer_format (Display                       *display,
+			       int                           screen,
+			       unsigned long                 mask,
+			       const glitz_drawable_format_t *templ,
+			       int                           count)
+{
+    glitz_int_drawable_format_t itempl;
+    glitz_glx_screen_info_t *screen_info =
+	glitz_glx_screen_info_get (display, screen);
+
+    glitz_drawable_format_copy (templ, &itempl.d, mask);
+
+    itempl.types = GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+    mask |= GLITZ_INT_FORMAT_PBUFFER_MASK;
+
+    return glitz_drawable_format_find (screen_info->formats,
+				       screen_info->n_formats,
+				       mask, &itempl, count);
+}
+slim_hidden_def(glitz_glx_find_pbuffer_format);
 
 glitz_drawable_format_t *
 glitz_glx_find_drawable_format_for_visual (Display  *display,
-                                           int       screen,
-                                           VisualID  visual_id)
+					   int       screen,
+					   VisualID  visual_id)
 {
     glitz_drawable_format_t *format = NULL;
     glitz_glx_screen_info_t *screen_info;
-    int                     i; 
+    int                     i;
 
     screen_info = glitz_glx_screen_info_get (display, screen);
     if (!screen_info)
-        return NULL;
+	return NULL;
 
     if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
     {
-        glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
-        GLXFBConfig                          *fbconfigs;
-        int                                  fid, n_fbconfigs;
-        
-        fid = -1;
-        fbconfigs = glx->get_fbconfigs (display, screen, &n_fbconfigs);
-        for (i = 0; i < n_fbconfigs; i++)
-        {
-            XVisualInfo *visinfo;
-            
-            visinfo = glx->get_visual_from_fbconfig (display, fbconfigs[i]);
-            if (visinfo && visinfo->visualid == visual_id)
-            {
-                int value;
+	glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
+	GLXFBConfig                          *fbconfigs;
+	int                                  fid, n_fbconfigs;
 
-                glx->get_fbconfig_attrib (display, fbconfigs[i],
-                                          GLX_FBCONFIG_ID, &value);
-                for (fid = 0; fid < screen_info->n_formats; fid++)
-                {
-                    if (screen_info->format_ids[fid] == value)
-                    {
-                        format = screen_info->formats + fid;
-                        break;
-                    }
-                }
-                
-                if (format)
-                    break;
-            }
-        }
-        
-        if (fbconfigs)
-            XFree (fbconfigs);
+	fid = -1;
+	fbconfigs = glx->get_fbconfigs (display, screen, &n_fbconfigs);
+	for (i = 0; i < n_fbconfigs; i++)
+	{
+	    XVisualInfo *visinfo;
+
+	    visinfo = glx->get_visual_from_fbconfig (display, fbconfigs[i]);
+	    if (visinfo && visinfo->visualid == visual_id)
+	    {
+		int value;
+
+		glx->get_fbconfig_attrib (display, fbconfigs[i],
+					  GLX_FBCONFIG_ID, &value);
+		for (fid = 0; fid < screen_info->n_formats; fid++)
+		{
+		    if (screen_info->formats[fid].u.uval == value)
+		    {
+			format = &screen_info->formats[fid].d;
+			break;
+		    }
+		}
+
+		if (format)
+		    break;
+	    }
+	}
+
+	if (fbconfigs)
+	    XFree (fbconfigs);
     }
     else
     {
-        for (i = 0; i < screen_info->n_formats; i++)
-        {
-            if (visual_id == screen_info->format_ids[i])
-            {
-                format = screen_info->formats + i;
-                break;
-            }
-        }
+	for (i = 0; i < screen_info->n_formats; i++)
+	{
+	    if (visual_id == screen_info->formats[i].u.uval)
+	    {
+		format = &screen_info->formats[i].d;
+		break;
+	    }
+	}
     }
-    
+
     return format;
 }
 slim_hidden_def(glitz_glx_find_drawable_format_for_visual);
 
 XVisualInfo *
 glitz_glx_get_visual_info_from_format (Display                 *display,
-                                       int                     screen,
-                                       glitz_drawable_format_t *format)
+				       int                     screen,
+				       glitz_drawable_format_t *format)
 {
-  XVisualInfo *vinfo = NULL;
-  glitz_glx_screen_info_t *screen_info =
-    glitz_glx_screen_info_get (display, screen);
-  glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
+    XVisualInfo *vinfo = NULL;
+    glitz_glx_screen_info_t *screen_info =
+	glitz_glx_screen_info_get (display, screen);
+    glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
 
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK) {
-    GLXFBConfig *fbconfigs;
-    int i, n_fbconfigs;
-    int fbconfigid = screen_info->format_ids[format->id];
+    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
+    {
+	GLXFBConfig *fbconfigs;
+	int	    i, n_fbconfigs;
+	int	    fbconfigid = screen_info->formats[format->id].u.uval;
+
+	fbconfigs = glx->get_fbconfigs (display, screen, &n_fbconfigs);
+	for (i = 0; i < n_fbconfigs; i++)
+	{
+	    int value;
+
+	    glx->get_fbconfig_attrib (display, fbconfigs[i],
+				      GLX_FBCONFIG_ID, &value);
+	    if (value == fbconfigid)
+		break;
+	}
+
+	if (i < n_fbconfigs)
+	    vinfo = glx->get_visual_from_fbconfig (display, fbconfigs[i]);
+
+	if (fbconfigs)
+	    XFree (fbconfigs);
 
-    fbconfigs = glx->get_fbconfigs (display, screen, &n_fbconfigs);
-    for (i = 0; i < n_fbconfigs; i++) {
-      int value;
-      
-      glx->get_fbconfig_attrib (display, fbconfigs[i],
-                                GLX_FBCONFIG_ID, &value);
-      if (value == fbconfigid)
-        break;
     }
-    
-    if (i < n_fbconfigs)
-      vinfo = glx->get_visual_from_fbconfig (display, fbconfigs[i]);
-    
-    if (fbconfigs)
-      XFree (fbconfigs);
-    
-  } else {
-    XVisualInfo templ;
-    int n_items;
-    
-    templ.visualid = screen_info->format_ids[format->id];
-    
-    vinfo = XGetVisualInfo (display, VisualIDMask, &templ, &n_items);
-  }
-  
-  return vinfo;
+    else
+    {
+	XVisualInfo templ;
+	int	    n_items;
+
+	templ.visualid = screen_info->formats[format->id].u.uval;
+
+	vinfo = XGetVisualInfo (display, VisualIDMask, &templ, &n_items);
+    }
+
+    return vinfo;
 }
 slim_hidden_def(glitz_glx_get_visual_info_from_format);

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_info.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glitz_glx_info.c	12 Apr 2005 14:54:56 -0000	1.4
+++ glitz_glx_info.c	14 Sep 2005 15:57:16 -0000	1.5
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -34,219 +34,244 @@
 
 glitz_gl_proc_address_list_t _glitz_glx_gl_proc_address = {
 
-  /* core */
-  (glitz_gl_enable_t) glEnable,
-  (glitz_gl_disable_t) glDisable,
-  (glitz_gl_get_error_t) glGetError,
-  (glitz_gl_get_string_t) glGetString,
-  (glitz_gl_enable_client_state_t) glEnableClientState,
-  (glitz_gl_disable_client_state_t) glDisableClientState,
-  (glitz_gl_vertex_pointer_t) glVertexPointer,
-  (glitz_gl_tex_coord_pointer_t) glTexCoordPointer,
-  (glitz_gl_draw_arrays_t) glDrawArrays,
-  (glitz_gl_tex_env_f_t) glTexEnvf,
-  (glitz_gl_tex_env_fv_t) glTexEnvfv,
-  (glitz_gl_tex_gen_i_t) glTexGeni,
-  (glitz_gl_tex_gen_fv_t) glTexGenfv,
-  (glitz_gl_color_4us_t) glColor4us,
-  (glitz_gl_color_4f_t) glColor4f,
-  (glitz_gl_scissor_t) glScissor,
-  (glitz_gl_blend_func_t) glBlendFunc,
-  (glitz_gl_clear_t) glClear,
-  (glitz_gl_clear_color_t) glClearColor,
-  (glitz_gl_clear_stencil_t) glClearStencil,
-  (glitz_gl_stencil_func_t) glStencilFunc,
-  (glitz_gl_stencil_op_t) glStencilOp,
-  (glitz_gl_push_attrib_t) glPushAttrib,
-  (glitz_gl_pop_attrib_t) glPopAttrib,
-  (glitz_gl_matrix_mode_t) glMatrixMode,
-  (glitz_gl_push_matrix_t) glPushMatrix,
-  (glitz_gl_pop_matrix_t) glPopMatrix,
-  (glitz_gl_load_identity_t) glLoadIdentity,
-  (glitz_gl_load_matrix_f_t) glLoadMatrixf,
-  (glitz_gl_depth_range_t) glDepthRange,
-  (glitz_gl_viewport_t) glViewport,
-  (glitz_gl_raster_pos_2f_t) glRasterPos2f,
-  (glitz_gl_bitmap_t) glBitmap,
-  (glitz_gl_read_buffer_t) glReadBuffer,
-  (glitz_gl_draw_buffer_t) glDrawBuffer,
-  (glitz_gl_copy_pixels_t) glCopyPixels,
-  (glitz_gl_flush_t) glFlush,
-  (glitz_gl_finish_t) glFinish,
-  (glitz_gl_pixel_store_i_t) glPixelStorei,
-  (glitz_gl_ortho_t) glOrtho,
-  (glitz_gl_scale_f_t) glScalef,
-  (glitz_gl_translate_f_t) glTranslatef,
-  (glitz_gl_hint_t) glHint,
-  (glitz_gl_depth_mask_t) glDepthMask,
-  (glitz_gl_polygon_mode_t) glPolygonMode,
-  (glitz_gl_shade_model_t) glShadeModel,
-  (glitz_gl_color_mask_t) glColorMask,
-  (glitz_gl_read_pixels_t) glReadPixels,
-  (glitz_gl_get_tex_image_t) glGetTexImage,
-  (glitz_gl_tex_sub_image_2d_t) glTexSubImage2D,
-  (glitz_gl_gen_textures_t) glGenTextures,
-  (glitz_gl_delete_textures_t) glDeleteTextures,
-  (glitz_gl_bind_texture_t) glBindTexture,
-  (glitz_gl_tex_image_2d_t) glTexImage2D,
-  (glitz_gl_tex_parameter_i_t) glTexParameteri,
-  (glitz_gl_get_tex_level_parameter_iv_t) glGetTexLevelParameteriv,
-  (glitz_gl_copy_tex_sub_image_2d_t) glCopyTexSubImage2D,
-  (glitz_gl_get_integer_v_t) glGetIntegerv,
+    /* core */
+    (glitz_gl_enable_t) glEnable,
+    (glitz_gl_disable_t) glDisable,
+    (glitz_gl_get_error_t) glGetError,
+    (glitz_gl_get_string_t) glGetString,
+    (glitz_gl_enable_client_state_t) glEnableClientState,
+    (glitz_gl_disable_client_state_t) glDisableClientState,
+    (glitz_gl_vertex_pointer_t) glVertexPointer,
+    (glitz_gl_tex_coord_pointer_t) glTexCoordPointer,
+    (glitz_gl_draw_arrays_t) glDrawArrays,
+    (glitz_gl_tex_env_f_t) glTexEnvf,
+    (glitz_gl_tex_env_fv_t) glTexEnvfv,
+    (glitz_gl_tex_gen_i_t) glTexGeni,
+    (glitz_gl_tex_gen_fv_t) glTexGenfv,
+    (glitz_gl_color_4us_t) glColor4us,
+    (glitz_gl_color_4f_t) glColor4f,
+    (glitz_gl_scissor_t) glScissor,
+    (glitz_gl_blend_func_t) glBlendFunc,
+    (glitz_gl_clear_t) glClear,
+    (glitz_gl_clear_color_t) glClearColor,
+    (glitz_gl_clear_stencil_t) glClearStencil,
+    (glitz_gl_stencil_func_t) glStencilFunc,
+    (glitz_gl_stencil_op_t) glStencilOp,
+    (glitz_gl_push_attrib_t) glPushAttrib,
+    (glitz_gl_pop_attrib_t) glPopAttrib,
+    (glitz_gl_matrix_mode_t) glMatrixMode,
+    (glitz_gl_push_matrix_t) glPushMatrix,
+    (glitz_gl_pop_matrix_t) glPopMatrix,
+    (glitz_gl_load_identity_t) glLoadIdentity,
+    (glitz_gl_load_matrix_f_t) glLoadMatrixf,
+    (glitz_gl_depth_range_t) glDepthRange,
+    (glitz_gl_viewport_t) glViewport,
+    (glitz_gl_raster_pos_2f_t) glRasterPos2f,
+    (glitz_gl_bitmap_t) glBitmap,
+    (glitz_gl_read_buffer_t) glReadBuffer,
+    (glitz_gl_draw_buffer_t) glDrawBuffer,
+    (glitz_gl_copy_pixels_t) glCopyPixels,
+    (glitz_gl_flush_t) glFlush,
+    (glitz_gl_finish_t) glFinish,
+    (glitz_gl_pixel_store_i_t) glPixelStorei,
+    (glitz_gl_ortho_t) glOrtho,
+    (glitz_gl_scale_f_t) glScalef,
+    (glitz_gl_translate_f_t) glTranslatef,
+    (glitz_gl_hint_t) glHint,
+    (glitz_gl_depth_mask_t) glDepthMask,
+    (glitz_gl_polygon_mode_t) glPolygonMode,
+    (glitz_gl_shade_model_t) glShadeModel,
+    (glitz_gl_color_mask_t) glColorMask,
+    (glitz_gl_read_pixels_t) glReadPixels,
+    (glitz_gl_get_tex_image_t) glGetTexImage,
+    (glitz_gl_tex_sub_image_2d_t) glTexSubImage2D,
+    (glitz_gl_gen_textures_t) glGenTextures,
+    (glitz_gl_delete_textures_t) glDeleteTextures,
+    (glitz_gl_bind_texture_t) glBindTexture,
+    (glitz_gl_tex_image_2d_t) glTexImage2D,
+    (glitz_gl_tex_parameter_i_t) glTexParameteri,
+    (glitz_gl_tex_parameter_fv_t) glTexParameterfv,
+    (glitz_gl_get_tex_level_parameter_iv_t) glGetTexLevelParameteriv,
+    (glitz_gl_copy_tex_sub_image_2d_t) glCopyTexSubImage2D,
+    (glitz_gl_get_integer_v_t) glGetIntegerv,
 
-  /* extensions */
-  (glitz_gl_blend_color_t) 0,
-  (glitz_gl_active_texture_t) 0,
-  (glitz_gl_client_active_texture_t) 0,
-  (glitz_gl_multi_draw_arrays_t) 0,
-  (glitz_gl_gen_programs_t) 0,
-  (glitz_gl_delete_programs_t) 0,
-  (glitz_gl_program_string_t) 0,
-  (glitz_gl_bind_program_t) 0,
-  (glitz_gl_program_local_param_4fv_t) 0,
-  (glitz_gl_get_program_iv_t) 0,
-  (glitz_gl_gen_buffers_t) 0,
-  (glitz_gl_delete_buffers_t) 0,
-  (glitz_gl_bind_buffer_t) 0,
-  (glitz_gl_buffer_data_t) 0,
-  (glitz_gl_buffer_sub_data_t) 0,
-  (glitz_gl_get_buffer_sub_data_t) 0,
-  (glitz_gl_map_buffer_t) 0,
-  (glitz_gl_unmap_buffer_t) 0
+    /* extensions */
+    (glitz_gl_blend_color_t) 0,
+    (glitz_gl_active_texture_t) 0,
+    (glitz_gl_client_active_texture_t) 0,
+    (glitz_gl_multi_draw_arrays_t) 0,
+    (glitz_gl_gen_programs_t) 0,
+    (glitz_gl_delete_programs_t) 0,
+    (glitz_gl_program_string_t) 0,
+    (glitz_gl_bind_program_t) 0,
+    (glitz_gl_program_local_param_4fv_t) 0,
+    (glitz_gl_get_program_iv_t) 0,
+    (glitz_gl_gen_buffers_t) 0,
+    (glitz_gl_delete_buffers_t) 0,
+    (glitz_gl_bind_buffer_t) 0,
+    (glitz_gl_buffer_data_t) 0,
+    (glitz_gl_buffer_sub_data_t) 0,
+    (glitz_gl_get_buffer_sub_data_t) 0,
+    (glitz_gl_map_buffer_t) 0,
+    (glitz_gl_unmap_buffer_t) 0,
+    (glitz_gl_gen_framebuffers_t) 0,
+    (glitz_gl_delete_framebuffers_t) 0,
+    (glitz_gl_bind_framebuffer_t) 0,
+    (glitz_gl_framebuffer_renderbuffer_t) 0,
+    (glitz_gl_framebuffer_texture_2d_t) 0,
+    (glitz_gl_check_framebuffer_status_t) 0,
+    (glitz_gl_gen_renderbuffers_t) 0,
+    (glitz_gl_delete_renderbuffers_t) 0,
+    (glitz_gl_bind_renderbuffer_t) 0,
+    (glitz_gl_renderbuffer_storage_t) 0,
+    (glitz_gl_get_renderbuffer_parameter_iv_t) 0
 };
 
 glitz_function_pointer_t
 glitz_glx_get_proc_address (const char *name,
-                            void       *closure)
+			    void       *closure)
 {
-  glitz_glx_screen_info_t *screen_info = (glitz_glx_screen_info_t *) closure;
-  glitz_glx_thread_info_t *info = screen_info->display_info->thread_info;
-  glitz_function_pointer_t address = NULL;
+    glitz_glx_screen_info_t *screen_info = (glitz_glx_screen_info_t *) closure;
+    glitz_glx_thread_info_t *info = screen_info->display_info->thread_info;
+    glitz_function_pointer_t address = NULL;
 
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK)
-    address = screen_info->glx.get_proc_address ((glitz_gl_ubyte_t *) name);
-  
-  if (!address) {
-    if (!info->dlhand)
-      info->dlhand = dlopen (info->gl_library, RTLD_LAZY);
-    
-    if (info->dlhand) {
-      dlerror ();
-      address = (glitz_function_pointer_t) dlsym (info->dlhand, name);
-      if (dlerror () != NULL)
-        address = NULL;
+    if (screen_info->glx_feature_mask &
+	GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK)
+	address =
+	    screen_info->glx.get_proc_address ((glitz_gl_ubyte_t *) name);
+
+    if (!address) {
+	if (!info->dlhand)
+	    info->dlhand = dlopen (info->gl_library, RTLD_LAZY);
+
+	if (info->dlhand) {
+	    dlerror ();
+	    address = (glitz_function_pointer_t) dlsym (info->dlhand, name);
+	    if (dlerror () != NULL)
+		address = NULL;
+	}
     }
-  }
-  
-  return address;
+
+    return address;
 }
 
 static void
 _glitz_glx_proc_address_lookup (glitz_glx_screen_info_t *screen_info)
 {
-  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK) {
-    if (screen_info->glx_version >= 1.3f) {
-      screen_info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
-        glitz_glx_get_proc_address ("glXGetFBConfigs", (void *) screen_info);
-      screen_info->glx.get_fbconfig_attrib = (glitz_glx_get_fbconfig_attrib_t)
-        glitz_glx_get_proc_address ("glXGetFBConfigAttrib",
-                                    (void *) screen_info);
-      screen_info->glx.get_visual_from_fbconfig =
-        (glitz_glx_get_visual_from_fbconfig_t)
-        glitz_glx_get_proc_address ("glXGetVisualFromFBConfig",
-                                    (void *) screen_info);
-      screen_info->glx.create_new_context = (glitz_glx_create_new_context_t)
-        glitz_glx_get_proc_address ("glXCreateNewContext",
-                                    (void *) screen_info);
+    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK) {
+	if (screen_info->glx_version >= 1.3f) {
+	    screen_info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
+		glitz_glx_get_proc_address ("glXGetFBConfigs",
+					    (void *) screen_info);
+	    screen_info->glx.get_fbconfig_attrib =
+		(glitz_glx_get_fbconfig_attrib_t)
+		glitz_glx_get_proc_address ("glXGetFBConfigAttrib",
+					    (void *) screen_info);
+	    screen_info->glx.get_visual_from_fbconfig =
+		(glitz_glx_get_visual_from_fbconfig_t)
+		glitz_glx_get_proc_address ("glXGetVisualFromFBConfig",
+					    (void *) screen_info);
+	    screen_info->glx.create_new_context =
+		(glitz_glx_create_new_context_t)
+		glitz_glx_get_proc_address ("glXCreateNewContext",
+					    (void *) screen_info);
 
-      if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_PBUFFER_MASK) {
-        screen_info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
-          glitz_glx_get_proc_address ("glXCreatePbuffer",
-                                      (void *) screen_info);
-        screen_info->glx.destroy_pbuffer = (glitz_glx_destroy_pbuffer_t)
-          glitz_glx_get_proc_address ("glXDestroyPbuffer",
-                                      (void *) screen_info);
-        screen_info->glx.query_drawable = (glitz_glx_query_drawable_t)
-          glitz_glx_get_proc_address ("glXQueryDrawable",
-                                      (void *) screen_info);
-      }      
-    } else {
-      screen_info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
-        glitz_glx_get_proc_address ("glXGetFBConfigsSGIX",
-                                    (void *) screen_info);
-      screen_info->glx.get_fbconfig_attrib = (glitz_glx_get_fbconfig_attrib_t)
-        glitz_glx_get_proc_address ("glXGetFBConfigAttribSGIX",
-                                    (void *) screen_info);
-      screen_info->glx.get_visual_from_fbconfig =
-        (glitz_glx_get_visual_from_fbconfig_t)
-        glitz_glx_get_proc_address ("glXGetVisualFromFBConfigSGIX",
-                                    (void *) screen_info);
-      screen_info->glx.create_new_context = (glitz_glx_create_new_context_t)
-        glitz_glx_get_proc_address ("glXCreateContextWithConfigSGIX",
-                                    (void *) screen_info);
+	    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_PBUFFER_MASK)
+	    {
+		screen_info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
+		    glitz_glx_get_proc_address ("glXCreatePbuffer",
+						(void *) screen_info);
+		screen_info->glx.destroy_pbuffer =
+		    (glitz_glx_destroy_pbuffer_t)
+		    glitz_glx_get_proc_address ("glXDestroyPbuffer",
+						(void *) screen_info);
+		screen_info->glx.query_drawable =
+		    (glitz_glx_query_drawable_t)
+		    glitz_glx_get_proc_address ("glXQueryDrawable",
+						(void *) screen_info);
+	    }
+	} else {
+	    screen_info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
+		glitz_glx_get_proc_address ("glXGetFBConfigsSGIX",
+					    (void *) screen_info);
+	    screen_info->glx.get_fbconfig_attrib =
+		(glitz_glx_get_fbconfig_attrib_t)
+		glitz_glx_get_proc_address ("glXGetFBConfigAttribSGIX",
+					    (void *) screen_info);
+	    screen_info->glx.get_visual_from_fbconfig =
+		(glitz_glx_get_visual_from_fbconfig_t)
+		glitz_glx_get_proc_address ("glXGetVisualFromFBConfigSGIX",
+					    (void *) screen_info);
+	    screen_info->glx.create_new_context =
+		(glitz_glx_create_new_context_t)
+		glitz_glx_get_proc_address ("glXCreateContextWithConfigSGIX",
+					    (void *) screen_info);
 
-      if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_PBUFFER_MASK) {
-        screen_info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
-          glitz_glx_get_proc_address ("glXCreateGLXPbufferSGIX",
-                                      (void *) screen_info);
-        screen_info->glx.destroy_pbuffer = (glitz_glx_destroy_pbuffer_t)
-          glitz_glx_get_proc_address ("glXDestroyGLXPbufferSGIX",
-                                      (void *) screen_info);
-        screen_info->glx.query_drawable = (glitz_glx_query_drawable_t)
-          glitz_glx_get_proc_address ("glXQueryGLXPbufferSGIX",
-                                      (void *) screen_info);
-      }
-    }
+	    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_PBUFFER_MASK)
+	    {
+		screen_info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
+		    glitz_glx_get_proc_address ("glXCreateGLXPbufferSGIX",
+						(void *) screen_info);
+		screen_info->glx.destroy_pbuffer =
+		    (glitz_glx_destroy_pbuffer_t)
+		    glitz_glx_get_proc_address ("glXDestroyGLXPbufferSGIX",
+						(void *) screen_info);
+		screen_info->glx.query_drawable = (glitz_glx_query_drawable_t)
+		    glitz_glx_get_proc_address ("glXQueryGLXPbufferSGIX",
+						(void *) screen_info);
+	    }
+	}
 
-    if ((!screen_info->glx.create_pbuffer) ||
-        (!screen_info->glx.destroy_pbuffer) ||
-        (!screen_info->glx.query_drawable))
-      screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
+	if ((!screen_info->glx.create_pbuffer) ||
+	    (!screen_info->glx.destroy_pbuffer) ||
+	    (!screen_info->glx.query_drawable))
+	    screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
 
-    if ((!screen_info->glx.get_fbconfigs) ||
-        (!screen_info->glx.get_fbconfig_attrib) ||
-        (!screen_info->glx.get_visual_from_fbconfig) ||
-        (!screen_info->glx.create_new_context)) {
-      screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_FBCONFIG_MASK;
-      screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
-    }
-  } else
-    screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
+	if ((!screen_info->glx.get_fbconfigs) ||
+	    (!screen_info->glx.get_fbconfig_attrib) ||
+	    (!screen_info->glx.get_visual_from_fbconfig) ||
+	    (!screen_info->glx.create_new_context)) {
+	    screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_FBCONFIG_MASK;
+	    screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
+	}
+    } else
+	screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_PBUFFER_MASK;
 
-  if (screen_info->glx_feature_mask &
-      GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK) {
-    if (screen_info->glx_version >= 1.3f) {
-      screen_info->glx.make_context_current =
-        (glitz_glx_make_context_current_t)
-        glitz_glx_get_proc_address ("glXMakeContextCurrent",
-                                    (void *) screen_info);
-    } else {
-      screen_info->glx.make_context_current =
-        (glitz_glx_make_context_current_t)
-        glitz_glx_get_proc_address ("glXMakeCurrentReadSGI",
-                                    (void *) screen_info);
-    }
-      
-    if (!screen_info->glx.make_context_current)
-      screen_info->glx_feature_mask &=
-        ~GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK;
-  }
-  
-  if (screen_info->glx_feature_mask &
-      GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK) {
-    if (screen_info->glx_version >= 1.4f) {
-      screen_info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
-        glitz_glx_get_proc_address ("glXGetProcAddress", (void *) screen_info);
-    } else {
-      screen_info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
-        glitz_glx_get_proc_address ("glXGetProcAddressARB",
-                                    (void *) screen_info);
+    if (screen_info->glx_feature_mask &
+	GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK) {
+	if (screen_info->glx_version >= 1.3f) {
+	    screen_info->glx.make_context_current =
+		(glitz_glx_make_context_current_t)
+		glitz_glx_get_proc_address ("glXMakeContextCurrent",
+					    (void *) screen_info);
+	} else {
+	    screen_info->glx.make_context_current =
+		(glitz_glx_make_context_current_t)
+		glitz_glx_get_proc_address ("glXMakeCurrentReadSGI",
+					    (void *) screen_info);
+	}
+
+	if (!screen_info->glx.make_context_current)
+	    screen_info->glx_feature_mask &=
+		~GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK;
     }
 
-    if (!screen_info->glx.get_proc_address)
-      screen_info->glx_feature_mask &=
-        ~GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK;
-  }
+    if (screen_info->glx_feature_mask &
+	GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK) {
+	if (screen_info->glx_version >= 1.4f) {
+	    screen_info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
+		glitz_glx_get_proc_address ("glXGetProcAddress",
+					    (void *) screen_info);
+	} else {
+	    screen_info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
+		glitz_glx_get_proc_address ("glXGetProcAddressARB",
+					    (void *) screen_info);
+	}
+
+	if (!screen_info->glx.get_proc_address)
+	    screen_info->glx_feature_mask &=
+		~GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK;
+    }
 }
 
 static void
@@ -258,27 +283,27 @@
 static void
 _glitz_glx_thread_info_fini (glitz_glx_thread_info_t *thread_info)
 {
-  int i;
-  
-  for (i = 0; i < thread_info->n_displays; i++)
-    _glitz_glx_display_destroy (thread_info->displays[i]);
+    int i;
 
-  free (thread_info->displays);
-  
-  thread_info->displays = NULL;
-  thread_info->n_displays = 0;
+    for (i = 0; i < thread_info->n_displays; i++)
+	_glitz_glx_display_destroy (thread_info->displays[i]);
 
-  if (thread_info->gl_library) {
-    free (thread_info->gl_library);
-    thread_info->gl_library = NULL;
-  }
+    free (thread_info->displays);
 
-  if (thread_info->dlhand) {
-    dlclose (thread_info->dlhand);
-    thread_info->dlhand = NULL;
-  }
-  
-  thread_info->cctx = NULL;
+    thread_info->displays = NULL;
+    thread_info->n_displays = 0;
+
+    if (thread_info->gl_library) {
+	free (thread_info->gl_library);
+	thread_info->gl_library = NULL;
+    }
+
+    if (thread_info->dlhand) {
+	dlclose (thread_info->dlhand);
+	thread_info->dlhand = NULL;
+    }
+
+    thread_info->cctx = NULL;
 }
 
 #ifdef XTHREADS
@@ -293,108 +318,108 @@
 static void
 _glitz_glx_thread_info_init (glitz_glx_thread_info_t *thread_info)
 {
-  thread_info->displays = NULL;
-  thread_info->n_displays = 0;
-  thread_info->gl_library = NULL;
-  thread_info->dlhand = NULL;
-  thread_info->cctx = NULL;
+    thread_info->displays = NULL;
+    thread_info->n_displays = 0;
+    thread_info->gl_library = NULL;
+    thread_info->dlhand = NULL;
+    thread_info->cctx = NULL;
 }
 
 static void
 _glitz_glx_thread_info_destroy (glitz_glx_thread_info_t *thread_info)
 {
-  xthread_set_specific (info_tsd, NULL);
-  
-  if (thread_info) {
-    _glitz_glx_thread_info_fini (thread_info);
-    free (thread_info);
-  }
+    xthread_set_specific (info_tsd, NULL);
+
+    if (thread_info) {
+	_glitz_glx_thread_info_fini (thread_info);
+	free (thread_info);
+    }
 }
 
 static void
 _tsd_destroy (void *p)
 {
-  if (p) {
-    _glitz_glx_thread_info_fini ((glitz_glx_thread_info_t *) p);
-    free (p);
-  }
+    if (p) {
+	_glitz_glx_thread_info_fini ((glitz_glx_thread_info_t *) p);
+	free (p);
+    }
 }
 
 static glitz_glx_thread_info_t *
 _glitz_glx_thread_info_get (const char *gl_library)
 {
-  glitz_glx_thread_info_t *thread_info;
-  void *p;
-    
-  if (!tsd_initialized) {
-    xthread_key_create (&info_tsd, _tsd_destroy);
-    tsd_initialized = 1;
-  }
-
-  xthread_get_specific (info_tsd, &p);
-  
-  if (p == NULL) {
-    thread_info = malloc (sizeof (glitz_glx_thread_info_t));
-    _glitz_glx_thread_info_init (thread_info);
-    
-    xthread_set_specific (info_tsd, thread_info);
-  } else
-    thread_info = (glitz_glx_thread_info_t *) p;
-  
-  if (gl_library) {
-    int len = strlen (gl_library);
+    glitz_glx_thread_info_t *thread_info;
+    void *p;
 
-    if (thread_info->gl_library) {
-      free (thread_info->gl_library);
-      thread_info->gl_library = NULL;
+    if (!tsd_initialized) {
+	xthread_key_create (&info_tsd, _tsd_destroy);
+	tsd_initialized = 1;
     }
-      
-    thread_info->gl_library = malloc (len + 1);
-    if (thread_info->gl_library) {
-      memcpy (thread_info->gl_library, gl_library, len);
-      thread_info->gl_library[len] = '\0';
+
+    xthread_get_specific (info_tsd, &p);
+
+    if (p == NULL) {
+	thread_info = malloc (sizeof (glitz_glx_thread_info_t));
+	_glitz_glx_thread_info_init (thread_info);
+
+	xthread_set_specific (info_tsd, thread_info);
+    } else
+	thread_info = (glitz_glx_thread_info_t *) p;
+
+    if (gl_library) {
+	int len = strlen (gl_library);
+
+	if (thread_info->gl_library) {
+	    free (thread_info->gl_library);
+	    thread_info->gl_library = NULL;
+	}
+
+	thread_info->gl_library = malloc (len + 1);
+	if (thread_info->gl_library) {
+	    memcpy (thread_info->gl_library, gl_library, len);
+	    thread_info->gl_library[len] = '\0';
+	}
     }
-  }
 
-  return thread_info;
+    return thread_info;
 }
 
 #else
 
 /* not thread safe */
 static glitz_glx_thread_info_t thread_info = {
-  NULL,
-  0,
-  NULL,
-  NULL
+    NULL,
+    0,
+    NULL,
+    NULL
 };
 
 static void
 _glitz_glx_thread_info_destroy (glitz_glx_thread_info_t *thread_info)
 {
-  if (thread_info)
-    _glitz_glx_thread_info_fini (thread_info);
+    if (thread_info)
+	_glitz_glx_thread_info_fini (thread_info);
 }
 
 static glitz_glx_thread_info_t *
 _glitz_glx_thread_info_get (const char *gl_library)
 {
-  if (gl_library) {
-    int len = strlen (gl_library);
+    if (gl_library) {
+	int len = strlen (gl_library);
 
-    if (thread_info.gl_library) {
-      free (thread_info.gl_library);
-      thread_info.gl_library = NULL;
-    }
-    
-    thread_info.gl_library = malloc (len + 1);
-    if (thread_info.gl_library) {
-      memcpy (thread_info.gl_library, gl_library, len);
-      thread_info.gl_library[len] = '\0';
+	if (thread_info.gl_library) {
+	    free (thread_info.gl_library);
+	    thread_info.gl_library = NULL;
+	}
+
+	thread_info.gl_library = malloc (len + 1);
+	if (thread_info.gl_library) {
+	    memcpy (thread_info.gl_library, gl_library, len);
+	    thread_info.gl_library[len] = '\0';
+	}
     }
-  }
-  
-  return &thread_info;
+
+    return &thread_info;
 }
 
 #endif
@@ -402,143 +427,142 @@
 static glitz_glx_display_info_t *
 _glitz_glx_display_info_get (Display *display)
 {
-  glitz_glx_display_info_t *display_info;
-  glitz_glx_thread_info_t *thread_info = _glitz_glx_thread_info_get (NULL);
-  glitz_glx_display_info_t **displays = thread_info->displays;
-  int index, n_displays = thread_info->n_displays;
+    glitz_glx_display_info_t *display_info;
+    glitz_glx_thread_info_t *thread_info = _glitz_glx_thread_info_get (NULL);
+    glitz_glx_display_info_t **displays = thread_info->displays;
+    int index, n_displays = thread_info->n_displays;
 
-  for (; n_displays; n_displays--, displays++)
-    if ((*displays)->display == display)
-      return *displays;
+    for (; n_displays; n_displays--, displays++)
+	if ((*displays)->display == display)
+	    return *displays;
 
-  index = thread_info->n_displays++;
+    index = thread_info->n_displays++;
 
-  thread_info->displays =
-    realloc (thread_info->displays,
-             sizeof (glitz_glx_display_info_t *) * thread_info->n_displays);
+    thread_info->displays =
+	realloc (thread_info->displays,
+		 sizeof (glitz_glx_display_info_t *) *
+		 thread_info->n_displays);
 
-  display_info = malloc (sizeof (glitz_glx_display_info_t));
-  thread_info->displays[index] = display_info;
-  
-  display_info->thread_info = thread_info;
-  display_info->display = display;
-  display_info->screens = NULL;
-  display_info->n_screens = 0;
-  
-  return display_info;
+    display_info = malloc (sizeof (glitz_glx_display_info_t));
+    thread_info->displays[index] = display_info;
+
+    display_info->thread_info = thread_info;
+    display_info->display = display;
+    display_info->screens = NULL;
+    display_info->n_screens = 0;
+
+    return display_info;
 }
 
 static void
 _glitz_glx_display_destroy (glitz_glx_display_info_t *display_info)
 {
-  int i;
-  
-  for (i = 0; i < display_info->n_screens; i++)
-    _glitz_glx_screen_destroy (display_info->screens[i]);
+    int i;
 
-  if (display_info->screens)
-    free (display_info->screens);
-  
-  free (display_info);
+    for (i = 0; i < display_info->n_screens; i++)
+	_glitz_glx_screen_destroy (display_info->screens[i]);
+
+    if (display_info->screens)
+	free (display_info->screens);
+
+    free (display_info);
 }
 
 glitz_glx_screen_info_t *
 glitz_glx_screen_info_get (Display *display,
-                           int     screen)
+			   int     screen)
 {
-  glitz_glx_screen_info_t *screen_info;
-  glitz_glx_display_info_t *display_info =
-    _glitz_glx_display_info_get (display);
-  glitz_glx_screen_info_t **screens = display_info->screens;
-  int error_base, event_base, index, n_screens = display_info->n_screens;
+    glitz_glx_screen_info_t *screen_info;
+    glitz_glx_display_info_t *display_info =
+	_glitz_glx_display_info_get (display);
+    glitz_glx_screen_info_t **screens = display_info->screens;
+    int error_base, event_base, index, n_screens = display_info->n_screens;
 
-  for (; n_screens; n_screens--, screens++)
-    if ((*screens)->screen == screen)
-      return *screens;
+    for (; n_screens; n_screens--, screens++)
+	if ((*screens)->screen == screen)
+	    return *screens;
 
-  index = display_info->n_screens++;
+    index = display_info->n_screens++;
 
-  display_info->screens =
-    realloc (display_info->screens,
-             sizeof (glitz_glx_screen_info_t *) * display_info->n_screens);
-  
-  screen_info = malloc (sizeof (glitz_glx_screen_info_t));
-  display_info->screens[index] = screen_info;
-  
-  screen_info->display_info = display_info;
-  screen_info->screen = screen;
-  screen_info->drawables = 0;
-  screen_info->formats = NULL;
-  screen_info->format_ids = NULL;
-  screen_info->n_formats = 0;
+    display_info->screens =
+	realloc (display_info->screens,
+		 sizeof (glitz_glx_screen_info_t *) * display_info->n_screens);
 
-  screen_info->contexts = NULL;
-  screen_info->n_contexts = 0;
-  
-  memset (&screen_info->glx, 0, sizeof (glitz_glx_static_proc_address_list_t));
+    screen_info = malloc (sizeof (glitz_glx_screen_info_t));
+    display_info->screens[index] = screen_info;
 
-  glitz_program_map_init (&screen_info->program_map);
-  
-  screen_info->root_context = (GLXContext) 0;
-  screen_info->glx_feature_mask = 0;
+    screen_info->display_info = display_info;
+    screen_info->screen = screen;
+    screen_info->drawables = 0;
+    screen_info->formats = NULL;
+    screen_info->n_formats = 0;
 
-  if (glXQueryExtension (display, &error_base, &event_base)) {
-    int major, minor;
-    
-    if (glXQueryVersion (display, &major, &minor)) {
-      screen_info->glx_version = major + minor / 10.0f;
-      if (major > 1 || (major > 0 || minor >= 2)) {
-        glitz_glx_query_extensions (screen_info, screen_info->glx_version);
-        _glitz_glx_proc_address_lookup (screen_info);
-        glitz_glx_query_formats (screen_info);
-      }
+    screen_info->contexts = NULL;
+    screen_info->n_contexts = 0;
+
+    memset (&screen_info->glx, 0,
+	    sizeof (glitz_glx_static_proc_address_list_t));
+
+    glitz_program_map_init (&screen_info->program_map);
+
+    screen_info->root_context = (GLXContext) 0;
+    screen_info->glx_feature_mask = 0;
+
+    if (glXQueryExtension (display, &error_base, &event_base)) {
+	int major, minor;
+
+	if (glXQueryVersion (display, &major, &minor)) {
+	    screen_info->glx_version = major + minor / 10.0f;
+	    if (major > 1 || (major > 0 || minor >= 2)) {
+		glitz_glx_query_extensions (screen_info,
+					    screen_info->glx_version);
+		_glitz_glx_proc_address_lookup (screen_info);
+		glitz_glx_query_formats (screen_info);
+	    }
+	}
     }
-  }
 
-  screen_info->context_stack_size = 1;
-  screen_info->context_stack->drawable = NULL;
-  screen_info->context_stack->surface = NULL;
-  screen_info->context_stack->constraint = GLITZ_NONE;
-  
-  return screen_info;
+    screen_info->context_stack_size = 1;
+    screen_info->context_stack->drawable = NULL;
+    screen_info->context_stack->surface = NULL;
+    screen_info->context_stack->constraint = GLITZ_NONE;
+
+    return screen_info;
 }
 
 static void
 _glitz_glx_screen_destroy (glitz_glx_screen_info_t *screen_info)
 {
-  Display *display = screen_info->display_info->display;
-  int     i;
+    Display *display = screen_info->display_info->display;
+    int     i;
 
-  if (screen_info->root_context)
-    glXMakeCurrent (display, None, NULL);
-  
-  for (i = 0; i < screen_info->n_contexts; i++)
-    glitz_glx_context_destroy (screen_info, screen_info->contexts[i]);
+    if (screen_info->root_context)
+	glXMakeCurrent (display, None, NULL);
 
-  if (screen_info->contexts)
-    free (screen_info->contexts);
-  
-  if (screen_info->formats)
-    free (screen_info->formats);
+    for (i = 0; i < screen_info->n_contexts; i++)
+	glitz_glx_context_destroy (screen_info, screen_info->contexts[i]);
 
-  if (screen_info->format_ids)
-    free (screen_info->format_ids);
+    if (screen_info->contexts)
+	free (screen_info->contexts);
 
-  free (screen_info);
+    if (screen_info->formats)
+	free (screen_info->formats);
+
+    free (screen_info);
 }
 
 void
 glitz_glx_init (const char *gl_library)
 {
-  _glitz_glx_thread_info_get (gl_library);
+    _glitz_glx_thread_info_get (gl_library);
 }
 slim_hidden_def(glitz_glx_init);
 
 void
 glitz_glx_fini (void)
 {
-  glitz_glx_thread_info_t *info = _glitz_glx_thread_info_get (NULL);
+    glitz_glx_thread_info_t *info = _glitz_glx_thread_info_get (NULL);
 
-  _glitz_glx_thread_info_destroy (info);
+    _glitz_glx_thread_info_destroy (info);
 }
 slim_hidden_def(glitz_glx_fini);

Index: glitz_glx_pbuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_pbuffer.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_glx_pbuffer.c	25 Jan 2005 19:50:26 -0000	1.2
+++ glitz_glx_pbuffer.c	14 Sep 2005 15:57:16 -0000	1.3
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -31,37 +31,37 @@
 
 GLXPbuffer
 glitz_glx_pbuffer_create (glitz_glx_screen_info_t *screen_info,
-                          GLXFBConfig             fbconfig,
-                          int                     width,
-                          int                     height)
+			  GLXFBConfig             fbconfig,
+			  int                     width,
+			  int                     height)
 {
-  if (fbconfig) {
-    int attributes[9];
+    Display *dpy = screen_info->display_info->display;
 
-    attributes[0] = GLX_PBUFFER_WIDTH;
-    attributes[1] = width;
+    if (fbconfig) {
+	int attributes[9];
 
-    attributes[2] = GLX_PBUFFER_HEIGHT;
-    attributes[3] = height;
-    
-    attributes[4] = GLX_LARGEST_PBUFFER;
-    attributes[5] = 0;
+	attributes[0] = GLX_PBUFFER_WIDTH;
+	attributes[1] = width;
 
-    attributes[6] = GLX_PRESERVED_CONTENTS;
-    attributes[7] = 1;
-    attributes[8] = 0;
+	attributes[2] = GLX_PBUFFER_HEIGHT;
+	attributes[3] = height;
 
-    return
-        screen_info->glx.create_pbuffer (screen_info->display_info->display,
-                                         fbconfig, attributes);
-  } else
-    return (GLXPbuffer) 0;
+	attributes[4] = GLX_LARGEST_PBUFFER;
+	attributes[5] = 0;
+
+	attributes[6] = GLX_PRESERVED_CONTENTS;
+	attributes[7] = 1;
+	attributes[8] = 0;
+
+	return screen_info->glx.create_pbuffer (dpy, fbconfig, attributes);
+    } else
+	return (GLXPbuffer) 0;
 }
 
-void 
+void
 glitz_glx_pbuffer_destroy (glitz_glx_screen_info_t *screen_info,
-                           GLXPbuffer              pbuffer)
+			   GLXPbuffer              pbuffer)
 {
-  screen_info->glx.destroy_pbuffer (screen_info->display_info->display,
-                                    pbuffer);
+    screen_info->glx.destroy_pbuffer (screen_info->display_info->display,
+				      pbuffer);
 }

Index: glitz_glxext.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glxext.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_glxext.h	25 Jan 2005 19:50:26 -0000	1.2
+++ glitz_glxext.h	14 Sep 2005 15:57:16 -0000	1.3
@@ -95,25 +95,25 @@
 #endif
 
 typedef glitz_function_pointer_t (* glitz_glx_get_proc_address_t)
-     (const glitz_gl_ubyte_t *);
+    (const glitz_gl_ubyte_t *);
 typedef GLXFBConfig *(* glitz_glx_get_fbconfigs_t)
-     (Display *display, int screen, int *n_elements);
+    (Display *display, int screen, int *n_elements);
 typedef int (* glitz_glx_get_fbconfig_attrib_t)
-     (Display *display, GLXFBConfig config, int attribute, int *value);
+    (Display *display, GLXFBConfig config, int attribute, int *value);
 typedef XVisualInfo *(* glitz_glx_get_visual_from_fbconfig_t)
-     (Display *display, GLXFBConfig config);
+    (Display *display, GLXFBConfig config);
 typedef GLXPbuffer (* glitz_glx_create_pbuffer_t)
-     (Display *display, GLXFBConfig config, const int *attrib_list);
+    (Display *display, GLXFBConfig config, const int *attrib_list);
 typedef void (* glitz_glx_destroy_pbuffer_t)
-     (Display *display, GLXPbuffer pbuffer);
+    (Display *display, GLXPbuffer pbuffer);
 typedef void (* glitz_glx_query_drawable_t)
-     (Display *display, GLXDrawable drawable,
-      int attribute, unsigned int *value);
+    (Display *display, GLXDrawable drawable,
+     int attribute, unsigned int *value);
 typedef Bool (* glitz_glx_make_context_current_t)
-     (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+    (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
 typedef GLXContext (* glitz_glx_create_new_context_t)
-     (Display *display, GLXFBConfig config, int render_type,
-      GLXContext share_list, Bool direct);
+    (Display *display, GLXFBConfig config, int render_type,
+     GLXContext share_list, Bool direct);
 
 #ifndef GLX_ARB_multisample
 #define GLX_SAMPLE_BUFFERS_ARB              0x186a0
@@ -121,8 +121,8 @@
 #endif
 
 typedef Bool *(* glitz_glx_bind_tex_image_t)
-     (Display *display, GLXPbuffer pbuffer, int buffer);
+    (Display *display, GLXPbuffer pbuffer, int buffer);
 typedef Bool (* glitz_glx_release_tex_image_t)
-     (Display *display, GLXPbuffer pbuffer, int buffer);
+    (Display *display, GLXPbuffer pbuffer, int buffer);
 
 #endif /* GLITZ_GLXEXT_H_INCLUDED */

Index: glitz_glxint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glxint.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glitz_glxint.h	29 Jun 2005 01:26:39 -0000	1.4
+++ glitz_glxint.h	14 Sep 2005 15:57:16 -0000	1.5
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 David Reveman
- * 
+ *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
  * fee, provided that the above copyright notice appear in all copies
@@ -12,11 +12,11 @@
  * software for any purpose. It is provided "as is" without express or
  * implied warranty.
  *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
+ * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
@@ -36,139 +36,143 @@
 
 #include "glitz_glxext.h"
 
-#define GLITZ_GLX_FEATURE_FBCONFIG_MASK            (1L << 0)
-#define GLITZ_GLX_FEATURE_PBUFFER_MASK             (1L << 1)
-#define GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK   (1L << 2)
-#define GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK    (1L << 3)
-#define GLITZ_GLX_FEATURE_MULTISAMPLE_MASK         (1L << 4)
-#define GLITZ_GLX_FEATURE_PBUFFER_MULTISAMPLE_MASK (1L << 5)
+#define GLITZ_GLX_FEATURE_VISUAL_RATING_MASK       (1L << 0)
+#define GLITZ_GLX_FEATURE_FBCONFIG_MASK            (1L << 1)
+#define GLITZ_GLX_FEATURE_PBUFFER_MASK             (1L << 2)
+#define GLITZ_GLX_FEATURE_MAKE_CURRENT_READ_MASK   (1L << 3)
+#define GLITZ_GLX_FEATURE_GET_PROC_ADDRESS_MASK    (1L << 4)
+#define GLITZ_GLX_FEATURE_MULTISAMPLE_MASK         (1L << 5)
+#define GLITZ_GLX_FEATURE_PBUFFER_MULTISAMPLE_MASK (1L << 6)
 
 typedef struct _glitz_glx_drawable glitz_glx_drawable_t;
 typedef struct _glitz_glx_screen_info_t glitz_glx_screen_info_t;
 typedef struct _glitz_glx_display_info_t glitz_glx_display_info_t;
 
 typedef struct _glitz_glx_static_proc_address_list_t {
-  glitz_glx_get_proc_address_t         get_proc_address;
-  glitz_glx_get_fbconfigs_t            get_fbconfigs;
-  glitz_glx_get_fbconfig_attrib_t      get_fbconfig_attrib;
-  glitz_glx_get_visual_from_fbconfig_t get_visual_from_fbconfig;
-  glitz_glx_create_pbuffer_t           create_pbuffer;
-  glitz_glx_destroy_pbuffer_t          destroy_pbuffer;
-  glitz_glx_query_drawable_t           query_drawable;
-  glitz_glx_make_context_current_t     make_context_current;
-  glitz_glx_create_new_context_t       create_new_context;
+    glitz_glx_get_proc_address_t         get_proc_address;
+    glitz_glx_get_fbconfigs_t            get_fbconfigs;
+    glitz_glx_get_fbconfig_attrib_t      get_fbconfig_attrib;
+    glitz_glx_get_visual_from_fbconfig_t get_visual_from_fbconfig;
+    glitz_glx_create_pbuffer_t           create_pbuffer;
+    glitz_glx_destroy_pbuffer_t          destroy_pbuffer;
+    glitz_glx_query_drawable_t           query_drawable;
+    glitz_glx_make_context_current_t     make_context_current;
+    glitz_glx_create_new_context_t       create_new_context;
 } glitz_glx_static_proc_address_list_t;
 
 typedef struct _glitz_glx_thread_info_t {
-  glitz_glx_display_info_t **displays;
-  int                      n_displays;
-  char                     *gl_library;
-  void                     *dlhand;
-  glitz_context_t          *cctx;
+    glitz_glx_display_info_t **displays;
+    int                      n_displays;
+    char                     *gl_library;
+    void                     *dlhand;
+    glitz_context_t          *cctx;
 } glitz_glx_thread_info_t;
 
 struct _glitz_glx_display_info_t {
-  glitz_glx_thread_info_t *thread_info;
-  Display                 *display;
-  glitz_glx_screen_info_t **screens;
-  int n_screens;
+    glitz_glx_thread_info_t *thread_info;
+    Display                 *display;
+    glitz_glx_screen_info_t **screens;
+    int n_screens;
 };
 
 typedef struct _glitz_glx_context_info_t {
-  glitz_glx_drawable_t *drawable;
-  glitz_surface_t      *surface;
-  glitz_constraint_t   constraint;
+    glitz_glx_drawable_t *drawable;
+    glitz_surface_t      *surface;
+    glitz_constraint_t   constraint;
 } glitz_glx_context_info_t;
 
 typedef struct _glitz_glx_context_t {
-  glitz_context_t   base;
-  GLXContext        context;
-  glitz_format_id_t id;
-  GLXFBConfig       fbconfig;
-  glitz_backend_t   backend;
-  glitz_gl_int_t    max_viewport_dims[2];
-  glitz_gl_int_t    max_texture_2d_size;
-  glitz_gl_int_t    max_texture_rect_size;
-  glitz_bool_t      initialized;
+    glitz_context_t   base;
+    GLXContext        context;
+    glitz_format_id_t id;
+    GLXFBConfig       fbconfig;
+    glitz_backend_t   backend;
+    glitz_bool_t      initialized;
 } glitz_glx_context_t;
 
 struct _glitz_glx_screen_info_t {
-  glitz_glx_display_info_t             *display_info;
-  int                                  screen;
-  int                                  drawables;
-  glitz_drawable_format_t              *formats;
-  XID                                  *format_ids;
-  int                                  n_formats;  
-  glitz_glx_context_t                  **contexts;
-  int                                  n_contexts;
-  glitz_glx_context_info_t             context_stack[GLITZ_CONTEXT_STACK_SIZE];
-  int                                  context_stack_size;
-  GLXContext                           root_context;
-  unsigned long                        glx_feature_mask;
-  glitz_gl_float_t                     glx_version;
-  glitz_glx_static_proc_address_list_t glx;
-  glitz_program_map_t                  program_map;
+    glitz_glx_display_info_t             *display_info;
+    int                                  screen;
+    int                                  drawables;
+    glitz_int_drawable_format_t          *formats;
+    int                                  n_formats;
+    glitz_glx_context_t                  **contexts;
+    int                                  n_contexts;
+    glitz_glx_context_info_t           context_stack[GLITZ_CONTEXT_STACK_SIZE];
+    int                                  context_stack_size;
+    GLXContext                           root_context;
+    unsigned long                        glx_feature_mask;
+    glitz_gl_float_t                     glx_version;
+    glitz_glx_static_proc_address_list_t glx;
+    glitz_program_map_t                  program_map;
 };
 
 struct _glitz_glx_drawable {
-  glitz_drawable_t        base;
-  
-  glitz_glx_screen_info_t *screen_info;
-  glitz_glx_context_t     *context;
-  GLXDrawable             drawable;
-  GLXDrawable             pbuffer;
+    glitz_drawable_t        base;
+
+    glitz_glx_screen_info_t *screen_info;
+    glitz_glx_context_t     *context;
+    GLXDrawable             drawable;
+    GLXDrawable             pbuffer;
+    int                     width;
+    int                     height;
 };
 
 extern void __internal_linkage
 glitz_glx_query_extensions (glitz_glx_screen_info_t *screen_info,
-                            glitz_gl_float_t        glx_version);
+			    glitz_gl_float_t        glx_version);
 
 extern glitz_glx_screen_info_t __internal_linkage *
 glitz_glx_screen_info_get (Display *display,
-                           int     screen);
+			   int     screen);
 
 extern glitz_function_pointer_t __internal_linkage
 glitz_glx_get_proc_address (const char *name,
-                            void       *closure);
+			    void       *closure);
 
 extern glitz_glx_context_t __internal_linkage *
 glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
-                       glitz_drawable_format_t *format);
+		       glitz_drawable_format_t *format);
 
 extern void __internal_linkage
 glitz_glx_context_destroy (glitz_glx_screen_info_t *screen_info,
-                           glitz_glx_context_t     *context);
+			   glitz_glx_context_t     *context);
 
 extern void __internal_linkage
 glitz_glx_query_formats (glitz_glx_screen_info_t *screen_info);
 
+extern glitz_bool_t __internal_linkage
+_glitz_glx_drawable_update_size (glitz_glx_drawable_t *drawable,
+				 int                  width,
+				 int                  height);
+
 extern GLXPbuffer __internal_linkage
 glitz_glx_pbuffer_create (glitz_glx_screen_info_t    *screen_info,
-                          GLXFBConfig                fbconfig,
-                          int                        width,
-                          int                        height);
+			  GLXFBConfig                fbconfig,
+			  int                        width,
+			  int                        height);
 
 extern void __internal_linkage
 glitz_glx_pbuffer_destroy (glitz_glx_screen_info_t *screen_info,
-                           GLXPbuffer              pbuffer);
+			   GLXPbuffer              pbuffer);
 
 extern glitz_drawable_t __internal_linkage *
 glitz_glx_create_pbuffer (void                    *abstract_templ,
-                          glitz_drawable_format_t *format,
-                          unsigned int            width,
-                          unsigned int            height);
+			  glitz_drawable_format_t *format,
+			  unsigned int            width,
+			  unsigned int            height);
 
-extern void __internal_linkage
+extern glitz_bool_t __internal_linkage
 glitz_glx_push_current (void               *abstract_drawable,
-                        glitz_surface_t    *surface,
-                        glitz_constraint_t constraint);
+			glitz_surface_t    *surface,
+			glitz_constraint_t constraint);
 
 extern glitz_surface_t __internal_linkage *
 glitz_glx_pop_current (void *abstract_drawable);
 
 void
 glitz_glx_make_current (void               *abstract_drawable,
-                        glitz_constraint_t constraint);
+			glitz_constraint_t constraint);
 
 extern glitz_status_t __internal_linkage
 glitz_glx_make_current_read (void *abstract_surface);
@@ -176,14 +180,15 @@
 extern void __internal_linkage
 glitz_glx_destroy (void *abstract_drawable);
 
-extern void __internal_linkage
+extern glitz_bool_t __internal_linkage
 glitz_glx_swap_buffers (void *abstract_drawable);
 
-/* Avoid unnecessary PLT entries.  */
+/* Avoid unnecessary PLT entries. */
 
 slim_hidden_proto(glitz_glx_init)
 slim_hidden_proto(glitz_glx_fini)
-slim_hidden_proto(glitz_glx_find_drawable_format)
+slim_hidden_proto(glitz_glx_find_window_format)
+slim_hidden_proto(glitz_glx_find_pbuffer_format)
 slim_hidden_proto(glitz_glx_find_drawable_format_for_visual)
 slim_hidden_proto(glitz_glx_get_visual_info_from_format)
 slim_hidden_proto(glitz_glx_create_drawable_for_window)



More information about the cairo-commit mailing list