[cairo-commit] glitz/src glitz.c, 1.26, 1.27 glitz.h, 1.22, 1.23 glitz_agl_context.c, 1.9, 1.10 glitz_agl_extension.c, 1.13, 1.14 glitz_agl_info.c, 1.14, 1.15 glitz_agl_surface.c, 1.20, 1.21 glitz_aglint.h, 1.13, 1.14 glitz_buffer.c, 1.3, 1.4 glitz_compose.c, 1.8, 1.9 glitz_geometry.c, 1.2, 1.3 glitz_gl.h, 1.11, 1.12 glitz_glx_context.c, 1.16, 1.17 glitz_glx_extension.c, 1.15, 1.16 glitz_glx_format.c, 1.10, 1.11 glitz_glx_info.c, 1.21, 1.22 glitz_glx_pbuffer.c, 1.4, 1.5 glitz_glx_surface.c, 1.21, 1.22 glitz_glxint.h, 1.17, 1.18 glitz_pixel.c, 1.9, 1.10 glitz_rect.c, 1.12, 1.13 glitz_surface.c, 1.22, 1.23 glitz_texture.c, 1.14, 1.15 glitzint.h, 1.28, 1.29

David Reveman commit at pdx.freedesktop.org
Mon Oct 4 04:40:50 PDT 2004


Committed by: davidr

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

Modified Files:
	glitz.c glitz.h glitz_agl_context.c glitz_agl_extension.c 
	glitz_agl_info.c glitz_agl_surface.c glitz_aglint.h 
	glitz_buffer.c glitz_compose.c glitz_geometry.c glitz_gl.h 
	glitz_glx_context.c glitz_glx_extension.c glitz_glx_format.c 
	glitz_glx_info.c glitz_glx_pbuffer.c glitz_glx_surface.c 
	glitz_glxint.h glitz_pixel.c glitz_rect.c glitz_surface.c 
	glitz_texture.c glitzint.h 
Log Message:
Added user memory buffer support and better extension checking

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** glitz.c	15 Sep 2004 22:28:50 -0000	1.26
--- glitz.c	4 Oct 2004 11:40:48 -0000	1.27
***************
*** 261,270 ****
    gl->scissor (rect.x1,
                 dst->height - rect.y2,
!                rect.x2 - rect.x1,
!                rect.y2 - rect.y1);
  
    gl->push_matrix ();
  
!   glitz_geometry_enable (gl, dst, &primitive, &first, &count);
  
    if (dst->indirect) {
--- 261,269 ----
    gl->scissor (rect.x1,
                 dst->height - rect.y2,
!                width, height);
  
    gl->push_matrix ();
  
!   glitz_geometry_enable (gl, dst, &primitive, &first, &count, &rect);
  
    if (dst->indirect) {
***************
*** 295,300 ****
      gl->color_mask (GLITZ_GL_TRUE, GLITZ_GL_TRUE, GLITZ_GL_TRUE,
                      GLITZ_GL_TRUE);
      
-     glitz_geometry_enable_default (gl, dst);
      primitive = GLITZ_GL_QUADS;
      first = 0;
--- 294,301 ----
      gl->color_mask (GLITZ_GL_TRUE, GLITZ_GL_TRUE, GLITZ_GL_TRUE,
                      GLITZ_GL_TRUE);
+ 
+     glitz_geometry_disable (gl, dst);
+     glitz_geometry_enable_default (gl, dst, &rect);
      
      primitive = GLITZ_GL_QUADS;
      first = 0;
***************
*** 488,496 ****
                       width, height);
          
!         glitz_geometry_enable_default (gl, dst);
          
          gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);
-         
-         glitz_geometry_disable (gl, dst);
  
          glitz_texture_unbind (gl, texture);
--- 489,495 ----
                       width, height);
          
!         glitz_geometry_enable_default (gl, dst, &box);
          
          gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);
  
          glitz_texture_unbind (gl, texture);

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** glitz.h	13 Sep 2004 17:50:38 -0000	1.22
--- glitz.h	4 Oct 2004 11:40:48 -0000	1.23
***************
*** 109,112 ****
--- 109,113 ----
  #define GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK      (1L << 12)
  #define GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK  (1L << 13)
+ #define GLITZ_FEATURE_BLEND_COLOR_MASK              (1L << 14)
  
  typedef enum {
***************
*** 313,316 ****
--- 314,320 ----
                             unsigned int size,
                             glitz_buffer_hint_t hint);
+ 
+ glitz_buffer_t *
+ glitz_buffer_create_for_data (void *data);
    
  void

Index: glitz_agl_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_context.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glitz_agl_context.c	20 Sep 2004 04:59:34 -0000	1.9
--- glitz_agl_context.c	4 Oct 2004 11:40:48 -0000	1.10
***************
*** 109,232 ****
    bundle = glitz_agl_get_bundle ("OpenGL.framework");
  
!   if (thread_info->gl_version >= 1.3) {
!     context->backend.gl.active_texture =
!       (glitz_gl_active_texture_t)
!       glitz_agl_get_proc_address (bundle, "glActiveTexture");
!   } else {
!     context->backend.gl.active_texture =
!       (glitz_gl_active_texture_t)
!       glitz_agl_get_proc_address (bundle, "glActiveTextureARB");
    }
-   
-   context->backend.gl.gen_programs =
-     (glitz_gl_gen_programs_t)
-     glitz_agl_get_proc_address (bundle, "glGenProgramsARB");
-   context->backend.gl.delete_programs =
-     (glitz_gl_delete_programs_t)
-     glitz_agl_get_proc_address (bundle, "glDeleteProgramsARB");
-   context->backend.gl.program_string =
-     (glitz_gl_program_string_t)
-     glitz_agl_get_proc_address (bundle, "glProgramStringARB");
-   context->backend.gl.bind_program =
-     (glitz_gl_bind_program_t)
-     glitz_agl_get_proc_address (bundle, "glBindProgramARB");
-   context->backend.gl.program_local_param_4fv =
-     (glitz_gl_program_local_param_4fv_t)
-     glitz_agl_get_proc_address (bundle, "glProgramLocalParameter4fvARB");
-   context->backend.gl.get_program_iv =
-     (glitz_gl_get_program_iv_t)
-     glitz_agl_get_proc_address (bundle, "glGetProgramivARB");
  
!   if (thread_info->gl_version >= 1.5) {
!     context->backend.gl.gen_buffers =
!       (glitz_gl_gen_buffers_t)
!       glitz_agl_get_proc_address (bundle, "glGenBuffers");
!     context->backend.gl.delete_buffers =
!       (glitz_gl_delete_buffers_t)
!       glitz_agl_get_proc_address (bundle, "glDeleteBuffers");
!     context->backend.gl.bind_buffer =
!       (glitz_gl_bind_buffer_t)
!       glitz_agl_get_proc_address (bundle, "glBindBuffer");
!     context->backend.gl.buffer_data =
!       (glitz_gl_buffer_data_t)
!       glitz_agl_get_proc_address (bundle, "glBufferData");
!     context->backend.gl.buffer_sub_data =
!       (glitz_gl_buffer_sub_data_t)
!       glitz_agl_get_proc_address (bundle, "glBufferSubData");
!     context->backend.gl.get_buffer_sub_data =
!       (glitz_gl_get_buffer_sub_data_t)
!       glitz_agl_get_proc_address (bundle, "glGetBufferSubData");
!     context->backend.gl.map_buffer =
!       (glitz_gl_map_buffer_t)
!       glitz_agl_get_proc_address (bundle, "glMapBuffer");
!     context->backend.gl.unmap_buffer =
!       (glitz_gl_unmap_buffer_t)
!       glitz_agl_get_proc_address (bundle, "glUnmapBuffer");
!   } else {
!     context->backend.gl.gen_buffers =
!       (glitz_gl_gen_buffers_t)
!       glitz_agl_get_proc_address (bundle, "glGenBuffersARB");
!     context->backend.gl.delete_buffers =
!       (glitz_gl_delete_buffers_t)
!       glitz_agl_get_proc_address (bundle, "glDeleteBuffersARB");
!     context->backend.gl.bind_buffer =
!       (glitz_gl_bind_buffer_t)
!       glitz_agl_get_proc_address (bundle, "glBindBufferARB");
!     context->backend.gl.buffer_data =
!       (glitz_gl_buffer_data_t)
!       glitz_agl_get_proc_address (bundle, "glBufferDataARB");
!     context->backend.gl.buffer_sub_data =
!       (glitz_gl_buffer_sub_data_t)
!       glitz_agl_get_proc_address (bundle, "glBufferSubDataARB");
!     context->backend.gl.get_buffer_sub_data =
!       (glitz_gl_get_buffer_sub_data_t)
!       glitz_agl_get_proc_address (bundle, "glGetBufferSubDataARB");
!     context->backend.gl.map_buffer =
!       (glitz_gl_map_buffer_t)
!       glitz_agl_get_proc_address (bundle, "glMapBufferARB");
!     context->backend.gl.unmap_buffer =
!       (glitz_gl_unmap_buffer_t)
!       glitz_agl_get_proc_address (bundle, "glUnmapBufferARB");
    }
  
!   glitz_agl_release_bundle (bundle);
  
!   context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  
!   if (context->backend.gl.active_texture) {
!     context->backend.feature_mask |= GLITZ_FEATURE_MULTITEXTURE_MASK;
  
!     if (thread_info->feature_mask & GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK)
!       context->backend.feature_mask |=
!         GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
!     
!     if (context->backend.gl.gen_programs &&
!         context->backend.gl.delete_programs &&
!         context->backend.gl.program_string &&
!         context->backend.gl.bind_program &&
!         context->backend.gl.program_local_param_4fv) {
!       if (thread_info->feature_mask & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK)
!         context->backend.feature_mask |= GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
      }
    }
  
!   if (context->backend.gl.gen_buffers &&
!       context->backend.gl.delete_buffers &&
!       context->backend.gl.bind_buffer &&
!       context->backend.gl.buffer_data &&
!       context->backend.gl.buffer_sub_data &&
!       context->backend.gl.get_buffer_sub_data &&
!       context->backend.gl.map_buffer &&
!       context->backend.gl.unmap_buffer) {
!     if (thread_info->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK)
!       context->backend.feature_mask |= GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
!     
!     if (thread_info->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
!       context->backend.feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
!   }
    
    context->backend.gl.need_lookup = 0;
--- 109,231 ----
    bundle = glitz_agl_get_bundle ("OpenGL.framework");
  
!   if (thread_info->feature_mask & GLITZ_FEATURE_BLEND_COLOR_MASK) {
!     if (thread_info->gl_version >= 1.4f) {
!       context->backend.gl.blend_color = (glitz_gl_blend_color_t)
!         glitz_agl_get_proc_address (bundle, "glBlendColor");
!     } else {
!       context->backend.gl.blend_color = (glitz_gl_blend_color_t)
!         glitz_agl_get_proc_address (bundle, "glBlendColorEXT");
!     }
! 
!     if (!context->backend.gl.blend_color)
!       context->backend.feature_mask &= ~GLITZ_FEATURE_BLEND_COLOR_MASK;
    }
  
!   if (thread_info->feature_mask & GLITZ_FEATURE_MULTITEXTURE_MASK) {
!     if (thread_info->gl_version >= 1.3f) {
!       context->backend.gl.active_texture = (glitz_gl_active_texture_t)
!         glitz_agl_get_proc_address (bundle, "glActiveTexture");
!     } else {
!       context->backend.gl.active_texture = (glitz_gl_active_texture_t)
!         glitz_agl_get_proc_address (bundle, "glActiveTextureARB");
!     }
! 
!     if (!context->backend.gl.active_texture) {
!       context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK;
!       context->backend.feature_mask &=
!         ~GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
!     }
    }
  
!   if (thread_info->feature_mask & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK) {
!     context->backend.gl.gen_programs = (glitz_gl_gen_programs_t)
!       glitz_agl_get_proc_address (bundle, "glGenProgramsARB");
!     context->backend.gl.delete_programs = (glitz_gl_delete_programs_t)
!       glitz_agl_get_proc_address (bundle, "glDeleteProgramsARB");
!     context->backend.gl.program_string = (glitz_gl_program_string_t)
!       glitz_agl_get_proc_address (bundle, "glProgramStringARB");
!     context->backend.gl.bind_program = (glitz_gl_bind_program_t)
!       glitz_agl_get_proc_address (bundle, "glBindProgramARB");
!     context->backend.gl.program_local_param_4fv =
!       (glitz_gl_program_local_param_4fv_t)
!       glitz_agl_get_proc_address (bundle,
!                                   "glProgramLocalParameter4fvARB");
!     context->backend.gl.get_program_iv = (glitz_gl_get_program_iv_t)
!       glitz_agl_get_proc_address (bundle, "glGetProgramivARB");
  
!     if ((!context->backend.gl.gen_programs) ||
!         (!context->backend.gl.delete_programs) ||
!         (!context->backend.gl.program_string) ||
!         (!context->backend.gl.bind_program) ||
!         (!context->backend.gl.program_local_param_4fv))
!       context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
!   }
  
!   if ((thread_info->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK) ||
!       (thread_info->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)) {
!     if (thread_info->gl_version >= 1.5f) {
!       context->backend.gl.gen_buffers = (glitz_gl_gen_buffers_t)
!         glitz_agl_get_proc_address (bundle, "glGenBuffers");
!       context->backend.gl.delete_buffers = (glitz_gl_delete_buffers_t)
!         glitz_agl_get_proc_address (bundle, "glDeleteBuffers");
!       context->backend.gl.bind_buffer = (glitz_gl_bind_buffer_t)
!         glitz_agl_get_proc_address (bundle, "glBindBuffer");
!       context->backend.gl.buffer_data = (glitz_gl_buffer_data_t)
!         glitz_agl_get_proc_address (bundle, "glBufferData");
!       context->backend.gl.buffer_sub_data = (glitz_gl_buffer_sub_data_t)
!         glitz_agl_get_proc_address (bundle, "glBufferSubData");
!       context->backend.gl.get_buffer_sub_data =
!         (glitz_gl_get_buffer_sub_data_t)
!         glitz_agl_get_proc_address (bundle, "glGetBufferSubData");
!       context->backend.gl.map_buffer = (glitz_gl_map_buffer_t)
!         glitz_agl_get_proc_address (bundle, "glMapBuffer");
!       context->backend.gl.unmap_buffer = (glitz_gl_unmap_buffer_t)
!         glitz_agl_get_proc_address (bundle, "glUnmapBuffer");
!     } else {
!       context->backend.gl.gen_buffers = (glitz_gl_gen_buffers_t)
!         glitz_agl_get_proc_address (bundle, "glGenBuffersARB");
!       context->backend.gl.delete_buffers = (glitz_gl_delete_buffers_t)
!         glitz_agl_get_proc_address (bundle, "glDeleteBuffersARB");
!       context->backend.gl.bind_buffer = (glitz_gl_bind_buffer_t)
!         glitz_agl_get_proc_address (bundle, "glBindBufferARB");
!       context->backend.gl.buffer_data = (glitz_gl_buffer_data_t)
!         glitz_agl_get_proc_address (bundle, "glBufferDataARB");
!       context->backend.gl.buffer_sub_data = (glitz_gl_buffer_sub_data_t)
!         glitz_agl_get_proc_address (bundle, "glBufferSubDataARB");
!       context->backend.gl.get_buffer_sub_data =
!         (glitz_gl_get_buffer_sub_data_t)
!         glitz_agl_get_proc_address (bundle, "glGetBufferSubDataARB");
!       context->backend.gl.map_buffer = (glitz_gl_map_buffer_t)
!         glitz_agl_get_proc_address (bundle, "glMapBufferARB");
!       context->backend.gl.unmap_buffer = (glitz_gl_unmap_buffer_t)
!         glitz_agl_get_proc_address (bundle, "glUnmapBufferARB");
!     }
  
!     if ((!context->backend.gl.gen_buffers) ||
!         (!context->backend.gl.delete_buffers) ||
!         (!context->backend.gl.bind_buffer) ||
!         (!context->backend.gl.buffer_data) ||
!         (!context->backend.gl.buffer_sub_data) ||
!         (!context->backend.gl.get_buffer_sub_data) ||
!         (!context->backend.gl.map_buffer) ||
!         (!context->backend.gl.unmap_buffer)) {
!       context->backend.feature_mask &=
!         ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
!       context->backend.feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
      }
    }
  
!   glitz_agl_release_bundle (bundle);
! 
!   context->backend.gl.get_integer_v (GLITZ_GL_MAX_VIEWPORT_DIMS,
!                                      context->max_viewport_dims);
!   context->backend.gl.get_integer_v (GLITZ_GL_MAX_TEXTURE_SIZE,
!                                      &context->max_texture_2d_size);
!   
!   if (thread_info->feature_mask & GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK)
!     context->backend.gl.get_integer_v (GLITZ_GL_MAX_RECTANGLE_TEXTURE_SIZE,
!                                        &context->max_texture_rect_size);
!   else
!     context->max_texture_rect_size = 0;
    
    context->backend.gl.need_lookup = 0;

Index: glitz_agl_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_extension.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz_agl_extension.c	20 Sep 2004 04:59:34 -0000	1.13
--- glitz_agl_extension.c	4 Oct 2004 11:40:48 -0000	1.14
***************
*** 61,64 ****
--- 61,68 ----
    { 0.0, "GL_EXT_pixel_buffer_object",
      GLITZ_AGL_FEATURE_PIXEL_BUFFER_OBJECT_MASK },
+   { 0.0, "GL_EXT_blend_color",
+     GLITZ_AGL_FEATURE_BLEND_COLOR_MASK },
+   { 0.0, "GL_ARB_imaging",
+     GLITZ_AGL_FEATURE_BLEND_COLOR_MASK },
    { 0.0, NULL, 0 }
  };
***************
*** 67,76 ****
  _glitz_agl_extension_query_gl (glitz_gl_float_t gl_version)
  {
!   const char *gl_extensions_strings;
    
!   gl_extensions_strings = (const char *) glGetString (GL_EXTENSIONS);
  
    return glitz_extensions_query (gl_version,
!                                  gl_extensions_strings,
                                   gl_extensions);
  }
--- 71,80 ----
  _glitz_agl_extension_query_gl (glitz_gl_float_t gl_version)
  {
!   const char *gl_extensions_string;
    
!   gl_extensions_string = (const char *) glGetString (GL_EXTENSIONS);
  
    return glitz_extensions_query (gl_version,
!                                  gl_extensions_string,
                                   gl_extensions);
  }
***************
*** 154,157 ****
--- 158,164 ----
      thread_info->feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  
+   if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_BLEND_COLOR_MASK)
+     thread_info->feature_mask |= GLITZ_FEATURE_BLEND_COLOR_MASK;
+ 
    return GLITZ_STATUS_SUCCESS;
  }

Index: glitz_agl_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_info.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** glitz_agl_info.c	20 Sep 2004 04:59:34 -0000	1.14
--- glitz_agl_info.c	4 Oct 2004 11:40:48 -0000	1.15
***************
*** 50,54 ****
    (glitz_gl_scissor_t) glScissor,
    (glitz_gl_blend_func_t) glBlendFunc,
-   (glitz_gl_blend_color_t) glBlendColor,
    (glitz_gl_clear_t) glClear,
    (glitz_gl_clear_color_t) glClearColor,
--- 50,53 ----
***************
*** 92,96 ****
    (glitz_gl_copy_tex_sub_image_2d_t) glCopyTexSubImage2D,
    (glitz_gl_get_integer_v_t) glGetIntegerv,
!   
    (glitz_gl_active_texture_t) 0,
    (glitz_gl_gen_programs_t) 0,
--- 91,96 ----
    (glitz_gl_copy_tex_sub_image_2d_t) glCopyTexSubImage2D,
    (glitz_gl_get_integer_v_t) glGetIntegerv,
! 
!   (glitz_gl_blend_color_t) 0,
    (glitz_gl_active_texture_t) 0,
    (glitz_gl_gen_programs_t) 0,
***************
*** 294,297 ****
--- 294,310 ----
  
    glitz_program_map_init (&thread_info->program_map);
+ 
+   glitz_agl_surface_backend_init (&thread_info->root_context.backend);
+ 
+   memcpy (&thread_info->root_context.backend.gl,
+           &_glitz_agl_gl_proc_address,
+           sizeof (glitz_gl_proc_address_list_t));
+   
+   thread_info->root_context.backend.formats = NULL;
+   thread_info->root_context.backend.n_formats = 0;
+   thread_info->root_context.backend.program_map = NULL;
+   thread_info->root_context.backend.feature_mask = 0;
+ 
+   thread_info->agl_feature_mask = thread_info->feature_mask = 0;
    
    thread_info->root_context.pixel_format =
***************
*** 305,308 ****
--- 318,323 ----
    
        if (glitz_agl_query_extensions (thread_info) == GLITZ_STATUS_SUCCESS) {
+           thread_info->root_context.backend.feature_mask =
+             thread_info->feature_mask;
          glitz_agl_context_proc_address_lookup (thread_info,
                                                 &thread_info->root_context);
***************
*** 312,327 ****
    }
  
-   glitz_agl_surface_backend_init (&thread_info->root_context.backend);
- 
-   memcpy (&thread_info->root_context.backend.gl,
-           &_glitz_agl_gl_proc_address,
-           sizeof (glitz_gl_proc_address_list_t));
-   
    thread_info->root_context.backend.formats = thread_info->formats;
    thread_info->root_context.backend.n_formats = thread_info->n_formats;
    thread_info->root_context.backend.program_map = &thread_info->program_map;
-   thread_info->root_context.backend.feature_mask = thread_info->feature_mask;
-   
-   thread_info->root_context.backend.gl.need_lookup = 1;
  
    thread_info->context_stack_size = 1;
--- 327,333 ----

Index: glitz_agl_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_surface.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** glitz_agl_surface.c	20 Sep 2004 04:59:34 -0000	1.20
--- glitz_agl_surface.c	4 Oct 2004 11:40:48 -0000	1.21
***************
*** 126,129 ****
--- 126,132 ----
    glitz_agl_context_t *context;
  
+   if (width <= 0 || height <= 0)
+     return NULL;
+ 
    context = glitz_agl_context_get (thread_info, format, 1);
    if (!context)
***************
*** 153,156 ****
--- 156,175 ----
    }
  
+   if (width > 64 || height > 64) {
+     glitz_agl_context_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+     glitz_texture_size_check (&surface->base.backend->gl,
+                               &surface->base.texture,
+                               context->max_texture_2d_size,
+                               context->max_texture_rect_size);
+     glitz_agl_context_pop_current (surface);
+     if (TEXTURE_INVALID_SIZE (&surface->base.texture) ||
+         (format->draw.offscreen &&
+          ((width > context->max_viewport_dims[0]) ||
+           (height > context->max_viewport_dims[1])))) {
+       glitz_surface_destroy (&surface->base);
+       return NULL;
+     }
+   }
+ 
    return &surface->base;
  }
***************
*** 161,166 ****
                            int height)
  {
!   return _glitz_agl_surface_create (glitz_agl_thread_info_get (),
!                                     format, width, height);
  }
  slim_hidden_def(glitz_agl_surface_create_offscreen);
--- 180,190 ----
                            int height)
  {
!   glitz_agl_thread_info_t *thread_info;
! 
!   thread_info = glitz_agl_thread_info_get ();
!   if (!thread_info)
!     return NULL;
!   
!   return _glitz_agl_surface_create (thread_info, format, width, height);
  }
  slim_hidden_def(glitz_agl_surface_create_offscreen);
***************
*** 174,178 ****
    glitz_agl_surface_t *surface;
    glitz_agl_context_t *context;
!   glitz_agl_thread_info_t *thread_info = glitz_agl_thread_info_get ();
  
    context = glitz_agl_context_get (thread_info, format, 0);
--- 198,214 ----
    glitz_agl_surface_t *surface;
    glitz_agl_context_t *context;
!   glitz_agl_thread_info_t *thread_info;
!   AGLDrawable drawable;
! 
!   if (width <= 0 || height <= 0)
!     return NULL;
! 
!   drawable = GetWindowPort (window);
!   if (!drawable)
!     return NULL;
! 
!   thread_info = glitz_agl_thread_info_get ();
!   if (!thread_info)
!     return NULL;
  
    context = glitz_agl_context_get (thread_info, format, 0);
***************
*** 193,197 ****
    surface->context = context;
    surface->window = window;
!   surface->drawable = GetWindowPort (window);
  
    surface->base.flags |= GLITZ_SURFACE_FLAG_DRAWABLE_MASK;
--- 229,233 ----
    surface->context = context;
    surface->window = window;
!   surface->drawable = drawable;
  
    surface->base.flags |= GLITZ_SURFACE_FLAG_DRAWABLE_MASK;
***************
*** 201,204 ****
--- 237,255 ----
      glitz_agl_context_pop_current (surface);
    }
+ 
+   if (width > 64 || height > 64) {
+     glitz_agl_context_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+     glitz_texture_size_check (&surface->base.backend->gl,
+                               &surface->base.texture,
+                               context->max_texture_2d_size,
+                               context->max_texture_rect_size);
+     glitz_agl_context_pop_current (surface);
+     if (TEXTURE_INVALID_SIZE (&surface->base.texture) ||
+         (width > context->max_viewport_dims[0]) ||
+         (height > context->max_viewport_dims[1])) {
+       glitz_surface_destroy (&surface->base);
+       return NULL;
+     }
+   }
    
    return &surface->base;

Index: glitz_aglint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_aglint.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz_aglint.h	20 Sep 2004 04:59:34 -0000	1.13
--- glitz_aglint.h	4 Oct 2004 11:40:48 -0000	1.14
***************
*** 50,53 ****
--- 50,54 ----
  #define GLITZ_AGL_FEATURE_VERTEX_BUFFER_OBJECT_MASK     (1L << 11)
  #define GLITZ_AGL_FEATURE_PIXEL_BUFFER_OBJECT_MASK      (1L << 12)
+ #define GLITZ_AGL_FEATURE_BLEND_COLOR_MASK              (1L << 13)
  
  typedef struct _glitz_agl_surface_t glitz_agl_surface_t;
***************
*** 63,66 ****
--- 64,70 ----
    glitz_bool_t offscreen;
    glitz_surface_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_agl_context_t;
  

Index: glitz_buffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_buffer.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glitz_buffer.c	16 Sep 2004 23:56:20 -0000	1.3
--- glitz_buffer.c	4 Oct 2004 11:40:48 -0000	1.4
***************
*** 34,37 ****
--- 34,38 ----
                      glitz_surface_t *surface,
                      void *data,
+                     unsigned int size,
                      glitz_buffer_hint_t hint)
  {
***************
*** 39,42 ****
--- 40,44 ----
  
    buffer->ref_count = 1;
+   buffer->name = 0;
    
    switch (hint) {
***************
*** 73,96 ****
      buffer->surface = surface;
      glitz_surface_reference (surface);
!     
      surface->backend->gl.gen_buffers (1, &buffer->name);
      if (buffer->name) {
        surface->backend->gl.bind_buffer (buffer->target, buffer->name);
!       surface->backend->gl.buffer_data (buffer->target, buffer->size,
!                                         data, usage);
        surface->backend->gl.bind_buffer (buffer->target, 0);
      }
    } else
      buffer->surface = NULL;
    
!   if (buffer->name == 0) {
!     buffer->data = malloc (buffer->size);
      if (buffer->data == NULL)
        return GLITZ_STATUS_NO_MEMORY;
      
      if (data)
!       memcpy (buffer->data, data, buffer->size);
      
      buffer->owns_data = 1;
    }
    
--- 75,103 ----
      buffer->surface = surface;
      glitz_surface_reference (surface);
! 
!     glitz_surface_push_current (buffer->surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
! 
      surface->backend->gl.gen_buffers (1, &buffer->name);
      if (buffer->name) {
        surface->backend->gl.bind_buffer (buffer->target, buffer->name);
!       surface->backend->gl.buffer_data (buffer->target, size, data, usage);
        surface->backend->gl.bind_buffer (buffer->target, 0);
      }
+     glitz_surface_pop_current (buffer->surface);
    } else
      buffer->surface = NULL;
    
!   if (size > 0 && buffer->name == 0) {
!     buffer->data = malloc (size);
      if (buffer->data == NULL)
        return GLITZ_STATUS_NO_MEMORY;
      
      if (data)
!       memcpy (buffer->data, data, size);
      
      buffer->owns_data = 1;
+   } else {
+     buffer->owns_data = 0;
+     buffer->data = data;
    }
    
***************
*** 107,122 ****
    glitz_status_t status;
  
    buffer = malloc (sizeof (glitz_buffer_t));
    if (buffer == NULL)
      return NULL;
    
-   buffer->size = size;
-   buffer->name = 0;
    buffer->target = GLITZ_GL_ARRAY_BUFFER;
  
    if (surface->backend->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK)
!     status = _glitz_buffer_init (buffer, surface, data, hint);
    else
!     status = _glitz_buffer_init (buffer, NULL, data, hint);
    
    if (status != GLITZ_STATUS_SUCCESS) {
--- 114,130 ----
    glitz_status_t status;
  
+   if (size == 0)
+     return NULL;
+ 
    buffer = malloc (sizeof (glitz_buffer_t));
    if (buffer == NULL)
      return NULL;
    
    buffer->target = GLITZ_GL_ARRAY_BUFFER;
  
    if (surface->backend->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK)
!     status = _glitz_buffer_init (buffer, surface, data, size, hint);
    else
!     status = _glitz_buffer_init (buffer, NULL, data, size, hint);
    
    if (status != GLITZ_STATUS_SUCCESS) {
***************
*** 136,139 ****
--- 144,150 ----
    glitz_buffer_t *buffer;
    glitz_status_t status;
+ 
+   if (size == 0)
+     return NULL;
    
    buffer = malloc (sizeof (glitz_buffer_t));
***************
*** 141,147 ****
      return NULL;
    
-   buffer->size = size;
-   buffer->name = 0;
-   
    switch (hint) {
    case GLITZ_BUFFER_HINT_STREAM_READ:
--- 152,155 ----
***************
*** 154,162 ****
      break;
    }
!   
    if (surface->backend->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
!     status = _glitz_buffer_init (buffer, surface, data, hint);
    else
!     status = _glitz_buffer_init (buffer, NULL, data, hint);
  
    if (status != GLITZ_STATUS_SUCCESS) {
--- 162,170 ----
      break;
    }
! 
    if (surface->backend->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
!     status = _glitz_buffer_init (buffer, surface, data, size, hint);
    else
!     status = _glitz_buffer_init (buffer, NULL, data, size, hint);
  
    if (status != GLITZ_STATUS_SUCCESS) {
***************
*** 168,171 ****
--- 176,199 ----
  }
  
+ glitz_buffer_t *
+ glitz_buffer_create_for_data (void *data)
+ {
+   glitz_buffer_t *buffer;
+   
+   if (data == NULL)
+     return NULL;
+   
+   buffer = malloc (sizeof (glitz_buffer_t));
+   if (buffer == NULL)
+     return NULL;
+ 
+   if (_glitz_buffer_init (buffer, NULL, data, 0, 0)) {
+     free (buffer);
+     return NULL;
+   }
+   
+   return buffer;
+ }
+ 
  void
  glitz_buffer_destroy (glitz_buffer_t *buffer)
***************
*** 179,183 ****
--- 207,213 ----
    
    if (buffer->surface) {
+     glitz_surface_push_current (buffer->surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
      buffer->surface->backend->gl.delete_buffers (1, &buffer->name);
+     glitz_surface_pop_current (buffer->surface);
      glitz_surface_destroy (buffer->surface);
    } else if (buffer->owns_data)

Index: glitz_compose.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_compose.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glitz_compose.c	14 Sep 2004 21:07:08 -0000	1.8
--- glitz_compose.c	4 Oct 2004 11:40:48 -0000	1.9
***************
*** 510,527 ****
      op->alpha_mask = mask->solid;
      op->mask = NULL;
-     op->combine = combine;
      
!     if (op->src)
        op->per_component = 4;
      
    } else if (mask_type != GLITZ_SURFACE_TYPE_NULL) {
      if (mask_type == GLITZ_SURFACE_TYPE_ARGBC) {
!       if (op->src)
          op->per_component = 4;
!       else
          op->combine = combine;
!     }
! 
!     if (dst->backend->feature_mask & GLITZ_FEATURE_TEXTURE_ENV_COMBINE_MASK)
        op->combine = combine;
    } else
--- 510,531 ----
      op->alpha_mask = mask->solid;
      op->mask = NULL;
      
!     if (op->src) {
        op->per_component = 4;
+       op->combine = combine;
+     } else if (dst->backend->feature_mask & GLITZ_FEATURE_BLEND_COLOR_MASK)
+       op->combine = combine;
      
    } else if (mask_type != GLITZ_SURFACE_TYPE_NULL) {
      if (mask_type == GLITZ_SURFACE_TYPE_ARGBC) {
!       if (op->src) {
          op->per_component = 4;
!         if (dst->backend->feature_mask &
!             GLITZ_FEATURE_TEXTURE_ENV_COMBINE_MASK)
!           op->combine = combine;
!       } else if (dst->backend->feature_mask & GLITZ_FEATURE_BLEND_COLOR_MASK)
          op->combine = combine;
!     } else if (dst->backend->feature_mask &
!                GLITZ_FEATURE_TEXTURE_ENV_COMBINE_MASK)
        op->combine = combine;
    } else

Index: glitz_geometry.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_geometry.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glitz_geometry.c	6 Sep 2004 22:23:29 -0000	1.2
--- glitz_geometry.c	4 Oct 2004 11:40:48 -0000	1.3
***************
*** 212,233 ****
  void
  glitz_geometry_enable_default (glitz_gl_proc_address_list_t *gl,
!                                glitz_surface_t *dst)
  {
!   if (dst->backend->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK) {
!     if (!dst->geometry.default_name) {
!       gl->gen_buffers (1, &dst->geometry.default_name);
!       if (dst->geometry.default_name) {
!         gl->bind_buffer (GLITZ_GL_ARRAY_BUFFER,
!                          dst->geometry.default_name);
!         gl->buffer_data (GLITZ_GL_ARRAY_BUFFER, sizeof (dst->geometry.data),
!                          dst->geometry.data, GLITZ_GL_STATIC_DRAW);
!       }
!     } else
!       gl->bind_buffer (GLITZ_GL_ARRAY_BUFFER,
!                        dst->geometry.default_name);
!     
!     gl->vertex_pointer (2, GLITZ_GL_FLOAT, 0, NULL);
!   } else
!     gl->vertex_pointer (2, GLITZ_GL_FLOAT, 0, dst->geometry.data);
  }
  
--- 212,228 ----
  void
  glitz_geometry_enable_default (glitz_gl_proc_address_list_t *gl,
!                                glitz_surface_t *dst,
!                                glitz_bounding_box_t *box)
  {
!   dst->geometry.data[0] = box->x1;
!   dst->geometry.data[1] = box->y1;
!   dst->geometry.data[2] = box->x2;
!   dst->geometry.data[3] = box->y1;
!   dst->geometry.data[4] = box->x2;
!   dst->geometry.data[5] = box->y2;
!   dst->geometry.data[6] = box->x1;
!   dst->geometry.data[7] = box->y2;
!   
!   gl->vertex_pointer (2, GLITZ_GL_FLOAT, 0, dst->geometry.data);
  }
  
***************
*** 237,241 ****
                         glitz_gl_enum_t *primitive,
                         glitz_gl_int_t *first,
!                        glitz_gl_sizei_t *count)
  {
    if (dst->geometry.buffer) {
--- 232,237 ----
                         glitz_gl_enum_t *primitive,
                         glitz_gl_int_t *first,
!                        glitz_gl_sizei_t *count,
!                        glitz_bounding_box_t *box)
  {
    if (dst->geometry.buffer) {
***************
*** 253,257 ****
      *count = dst->geometry.count;
    } else {
!     glitz_geometry_enable_default (gl, dst);
      *primitive = GLITZ_GL_QUADS;
      *first = 0;
--- 249,253 ----
      *count = dst->geometry.count;
    } else {
!     glitz_geometry_enable_default (gl, dst, box);
      *primitive = GLITZ_GL_QUADS;
      *first = 0;
***************
*** 264,268 ****
                          glitz_surface_t *dst)
  {
!   if (dst->backend->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK)
      gl->bind_buffer (GLITZ_GL_ARRAY_BUFFER, 0);
  }
--- 260,265 ----
                          glitz_surface_t *dst)
  {
!   if (dst->geometry.buffer &&
!       (dst->backend->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK))
      gl->bind_buffer (GLITZ_GL_ARRAY_BUFFER, 0);
  }

Index: glitz_gl.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_gl.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** glitz_gl.h	20 Sep 2004 04:59:34 -0000	1.11
--- glitz_gl.h	4 Oct 2004 11:40:48 -0000	1.12
***************
*** 93,99 ****
  #define GLITZ_GL_SCISSOR_TEST 0x0C11
  
  #define GLITZ_GL_TEXTURE_ENV            0x2300
  #define GLITZ_GL_TEXTURE_ENV_MODE       0x2200
- #define GLITZ_GL_TEXTURE_1D             0x0DE0
  #define GLITZ_GL_TEXTURE_2D             0x0DE1
  #define GLITZ_GL_PROXY_TEXTURE_2D       0x8064
--- 93,104 ----
  #define GLITZ_GL_SCISSOR_TEST 0x0C11
  
+ #define GLITZ_GL_MAX_TEXTURE_SIZE  0x0D33
+ #define GLITZ_GL_MAX_VIEWPORT_DIMS 0x0D3A
+ 
+ #define GLITZ_GL_TEXTURE_WIDTH  0x1000
+ #define GLITZ_GL_TEXTURE_HEIGHT 0x1001
+ 
  #define GLITZ_GL_TEXTURE_ENV            0x2300
  #define GLITZ_GL_TEXTURE_ENV_MODE       0x2200
  #define GLITZ_GL_TEXTURE_2D             0x0DE1
  #define GLITZ_GL_PROXY_TEXTURE_2D       0x8064
***************
*** 225,229 ****
  #define GLITZ_GL_COMPILE 0x1300
  
! #define GLITZ_GL_TEXTURE_RECTANGLE 0x84F5
  
  #define GLITZ_GL_MIRRORED_REPEAT 0x8370
--- 230,236 ----
  #define GLITZ_GL_COMPILE 0x1300
  
! #define GLITZ_GL_TEXTURE_RECTANGLE          0x84F5
! #define GLITZ_GL_PROXY_TEXTURE_RECTANGLE    0x84F7
! #define GLITZ_GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
  
  #define GLITZ_GL_MIRRORED_REPEAT 0x8370

Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_context.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** glitz_glx_context.c	21 Sep 2004 12:01:25 -0000	1.16
--- glitz_glx_context.c	4 Oct 2004 11:40:48 -0000	1.17
***************
*** 37,44 ****
  
  static void
! _glitz_glx_context_create_glx12 (glitz_glx_screen_info_t *screen_info,
!                                  XID visualid,
!                                  GLXContext share_list,
!                                  glitz_glx_context_t *context)
  {
    int vis_info_count, i;
--- 37,44 ----
  
  static void
! _glitz_glx_context_create (glitz_glx_screen_info_t *screen_info,
!                            XID visualid,
!                            GLXContext share_list,
!                            glitz_glx_context_t *context)
  {
    int vis_info_count, i;
***************
*** 62,75 ****
  
  static void
! _glitz_glx_context_create_glx13 (glitz_glx_screen_info_t *screen_info,
!                                  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->display_info->thread_info->glx;
  
    fbconfigs = glx->get_fbconfigs (screen_info->display_info->display,
--- 62,74 ----
  
  static void
! _glitz_glx_context_create_fbconfig (glitz_glx_screen_info_t *screen_info,
!                                     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;
  
    fbconfigs = glx->get_fbconfigs (screen_info->display_info->display,
***************
*** 114,119 ****
    GLXFBConfig *fbconfigs;
    int i, n_fbconfigs;
!   glitz_glx_static_proc_address_list_t *glx =
!     &screen_info->display_info->thread_info->glx;
    int status = 1;
    
--- 113,117 ----
    GLXFBConfig *fbconfigs;
    int i, n_fbconfigs;
!   glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
    int status = 1;
    
***************
*** 134,142 ****
      
      texture.width = texture.height = 1;
!     pbuffer = glitz_glx_pbuffer_create (screen_info->display_info,
!                                         fbconfigs[i],
!                                         &texture);
      if (pbuffer) {
!       glitz_glx_pbuffer_destroy (screen_info->display_info, pbuffer);
        
        status = 0;
--- 132,138 ----
      
      texture.width = texture.height = 1;
!     pbuffer = glitz_glx_pbuffer_create (screen_info, fbconfigs[i], &texture);
      if (pbuffer) {
!       glitz_glx_pbuffer_destroy (screen_info, pbuffer);
        
        status = 0;
***************
*** 174,187 ****
    screen_info->contexts[index] = context;
  
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX13_MASK)
!     _glitz_glx_context_create_glx13 (screen_info,
!                                      screen_info->format_ids[format->id],
!                                      screen_info->root_context.context,
!                                      context);
    else
!     _glitz_glx_context_create_glx12 (screen_info,
!                                      screen_info->format_ids[format->id],
!                                      screen_info->root_context.context,
!                                      context);
  
    glitz_glx_surface_backend_init (&context->backend);
--- 170,183 ----
    screen_info->contexts[index] = context;
  
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX_FBCONFIG_MASK)
!     _glitz_glx_context_create_fbconfig (screen_info,
!                                         screen_info->format_ids[format->id],
!                                         screen_info->root_context.context,
!                                         context);
    else
!     _glitz_glx_context_create (screen_info,
!                                screen_info->format_ids[format->id],
!                                screen_info->root_context.context,
!                                context);
  
    glitz_glx_surface_backend_init (&context->backend);
***************
*** 214,338 ****
                                         glitz_glx_context_t *context)
  {
!   glitz_glx_thread_info_t *thread_info =
!     screen_info->display_info->thread_info;
  
!   if (screen_info->gl_version >= 1.3) {
!     context->backend.gl.active_texture =
!       (glitz_gl_active_texture_t)
!       glitz_glx_get_proc_address (thread_info, "glActiveTexture");
!   } else {
!     context->backend.gl.active_texture =
!       (glitz_gl_active_texture_t)
!       glitz_glx_get_proc_address (thread_info, "glActiveTextureARB");
    }
-   
-   context->backend.gl.gen_programs =
-     (glitz_gl_gen_programs_t)
-     glitz_glx_get_proc_address (thread_info, "glGenProgramsARB");
-   context->backend.gl.delete_programs =
-     (glitz_gl_delete_programs_t)
-     glitz_glx_get_proc_address (thread_info, "glDeleteProgramsARB");
-   context->backend.gl.program_string =
-     (glitz_gl_program_string_t)
-     glitz_glx_get_proc_address (thread_info, "glProgramStringARB");
-   context->backend.gl.bind_program =
-     (glitz_gl_bind_program_t)
-     glitz_glx_get_proc_address (thread_info, "glBindProgramARB");
-   context->backend.gl.program_local_param_4fv =
-     (glitz_gl_program_local_param_4fv_t)
-     glitz_glx_get_proc_address (thread_info, "glProgramLocalParameter4fvARB");
-   context->backend.gl.get_program_iv =
-     (glitz_gl_get_program_iv_t)
-     glitz_glx_get_proc_address (thread_info, "glGetProgramivARB");
  
!   if (screen_info->gl_version >= 1.5) {
!     context->backend.gl.gen_buffers =
!       (glitz_gl_gen_buffers_t)
!       glitz_glx_get_proc_address (thread_info, "glGenBuffers");
!     context->backend.gl.delete_buffers =
!       (glitz_gl_delete_buffers_t)
!       glitz_glx_get_proc_address (thread_info, "glDeleteBuffers");
!     context->backend.gl.bind_buffer =
!       (glitz_gl_bind_buffer_t)
!       glitz_glx_get_proc_address (thread_info, "glBindBuffer");
!     context->backend.gl.buffer_data =
!       (glitz_gl_buffer_data_t)
!       glitz_glx_get_proc_address (thread_info, "glBufferData");
!     context->backend.gl.buffer_sub_data =
!       (glitz_gl_buffer_sub_data_t)
!       glitz_glx_get_proc_address (thread_info, "glBufferSubData");
!     context->backend.gl.get_buffer_sub_data =
!       (glitz_gl_get_buffer_sub_data_t)
!       glitz_glx_get_proc_address (thread_info, "glGetBufferSubData");
!     context->backend.gl.map_buffer =
!       (glitz_gl_map_buffer_t)
!       glitz_glx_get_proc_address (thread_info, "glMapBuffer");
!     context->backend.gl.unmap_buffer =
!       (glitz_gl_unmap_buffer_t)
!       glitz_glx_get_proc_address (thread_info, "glUnmapBuffer");
!   } else {
!     context->backend.gl.gen_buffers =
!       (glitz_gl_gen_buffers_t)
!       glitz_glx_get_proc_address (thread_info, "glGenBuffersARB");
!     context->backend.gl.delete_buffers =
!       (glitz_gl_delete_buffers_t)
!       glitz_glx_get_proc_address (thread_info, "glDeleteBuffersARB");
!     context->backend.gl.bind_buffer =
!       (glitz_gl_bind_buffer_t)
!       glitz_glx_get_proc_address (thread_info, "glBindBufferARB");
!     context->backend.gl.buffer_data =
!       (glitz_gl_buffer_data_t)
!       glitz_glx_get_proc_address (thread_info, "glBufferDataARB");
!     context->backend.gl.buffer_sub_data =
!       (glitz_gl_buffer_sub_data_t)
!       glitz_glx_get_proc_address (thread_info, "glBufferSubDataARB");
!     context->backend.gl.get_buffer_sub_data =
!       (glitz_gl_get_buffer_sub_data_t)
!       glitz_glx_get_proc_address (thread_info, "glGetBufferSubDataARB");
!     context->backend.gl.map_buffer =
!       (glitz_gl_map_buffer_t)
!       glitz_glx_get_proc_address (thread_info, "glMapBufferARB");
!     context->backend.gl.unmap_buffer =
!       (glitz_gl_unmap_buffer_t)
!       glitz_glx_get_proc_address (thread_info, "glUnmapBufferARB");
    }
  
!   context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  
!   if (context->backend.gl.active_texture) {
!     context->backend.feature_mask |= GLITZ_FEATURE_MULTITEXTURE_MASK;
  
!     if (screen_info->feature_mask & GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK)
!       context->backend.feature_mask |=
!         GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
!     
!     if (context->backend.gl.gen_programs &&
!         context->backend.gl.delete_programs &&
!         context->backend.gl.program_string &&
!         context->backend.gl.bind_program &&
!         context->backend.gl.program_local_param_4fv) {
!       if (screen_info->feature_mask & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK)
!         context->backend.feature_mask |= GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
      }
-   }
  
!   if (context->backend.gl.gen_buffers &&
!       context->backend.gl.delete_buffers &&
!       context->backend.gl.bind_buffer &&
!       context->backend.gl.buffer_data &&
!       context->backend.gl.buffer_sub_data &&
!       context->backend.gl.get_buffer_sub_data &&
!       context->backend.gl.map_buffer &&
!       context->backend.gl.unmap_buffer) {
!     if (screen_info->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK)
!       context->backend.feature_mask |= GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
!     
!     if (screen_info->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
!       context->backend.feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
    }
    
    context->backend.gl.need_lookup = 0;
--- 210,330 ----
                                         glitz_glx_context_t *context)
  {
!   if (screen_info->feature_mask & GLITZ_FEATURE_BLEND_COLOR_MASK) {
!     if (screen_info->gl_version >= 1.4f) {
!       context->backend.gl.blend_color = (glitz_gl_blend_color_t)
!         glitz_glx_get_proc_address (screen_info, "glBlendColor");
!     } else {
!       context->backend.gl.blend_color = (glitz_gl_blend_color_t)
!         glitz_glx_get_proc_address (screen_info, "glBlendColorEXT");
!     }
  
!     if (!context->backend.gl.blend_color)
!       context->backend.feature_mask &= ~GLITZ_FEATURE_BLEND_COLOR_MASK;
    }
  
!   if (screen_info->feature_mask & GLITZ_FEATURE_MULTITEXTURE_MASK) {
!     if (screen_info->gl_version >= 1.3f) {
!       context->backend.gl.active_texture = (glitz_gl_active_texture_t)
!         glitz_glx_get_proc_address (screen_info, "glActiveTexture");
!     } else {
!       context->backend.gl.active_texture = (glitz_gl_active_texture_t)
!         glitz_glx_get_proc_address (screen_info, "glActiveTextureARB");
!     }
! 
!     if (!context->backend.gl.active_texture) {
!       context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK;
!       context->backend.feature_mask &=
!         ~GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
!     }
    }
  
!   if (screen_info->feature_mask & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK) {
!     context->backend.gl.gen_programs = (glitz_gl_gen_programs_t)
!       glitz_glx_get_proc_address (screen_info, "glGenProgramsARB");
!     context->backend.gl.delete_programs = (glitz_gl_delete_programs_t)
!       glitz_glx_get_proc_address (screen_info, "glDeleteProgramsARB");
!     context->backend.gl.program_string = (glitz_gl_program_string_t)
!       glitz_glx_get_proc_address (screen_info, "glProgramStringARB");
!     context->backend.gl.bind_program = (glitz_gl_bind_program_t)
!       glitz_glx_get_proc_address (screen_info, "glBindProgramARB");
!     context->backend.gl.program_local_param_4fv =
!       (glitz_gl_program_local_param_4fv_t)
!       glitz_glx_get_proc_address (screen_info,
!                                   "glProgramLocalParameter4fvARB");
!     context->backend.gl.get_program_iv = (glitz_gl_get_program_iv_t)
!       glitz_glx_get_proc_address (screen_info, "glGetProgramivARB");
  
!     if ((!context->backend.gl.gen_programs) ||
!         (!context->backend.gl.delete_programs) ||
!         (!context->backend.gl.program_string) ||
!         (!context->backend.gl.bind_program) ||
!         (!context->backend.gl.program_local_param_4fv))
!       context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
!   }
  
!   if ((screen_info->feature_mask & GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK) ||
!       (screen_info->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)) {
!     if (screen_info->gl_version >= 1.5f) {
!       context->backend.gl.gen_buffers = (glitz_gl_gen_buffers_t)
!         glitz_glx_get_proc_address (screen_info, "glGenBuffers");
!       context->backend.gl.delete_buffers = (glitz_gl_delete_buffers_t)
!         glitz_glx_get_proc_address (screen_info, "glDeleteBuffers");
!       context->backend.gl.bind_buffer = (glitz_gl_bind_buffer_t)
!         glitz_glx_get_proc_address (screen_info, "glBindBuffer");
!       context->backend.gl.buffer_data = (glitz_gl_buffer_data_t)
!         glitz_glx_get_proc_address (screen_info, "glBufferData");
!       context->backend.gl.buffer_sub_data = (glitz_gl_buffer_sub_data_t)
!         glitz_glx_get_proc_address (screen_info, "glBufferSubData");
!       context->backend.gl.get_buffer_sub_data =
!         (glitz_gl_get_buffer_sub_data_t)
!         glitz_glx_get_proc_address (screen_info, "glGetBufferSubData");
!       context->backend.gl.map_buffer = (glitz_gl_map_buffer_t)
!         glitz_glx_get_proc_address (screen_info, "glMapBuffer");
!       context->backend.gl.unmap_buffer = (glitz_gl_unmap_buffer_t)
!         glitz_glx_get_proc_address (screen_info, "glUnmapBuffer");
!     } else {
!       context->backend.gl.gen_buffers = (glitz_gl_gen_buffers_t)
!         glitz_glx_get_proc_address (screen_info, "glGenBuffersARB");
!       context->backend.gl.delete_buffers = (glitz_gl_delete_buffers_t)
!         glitz_glx_get_proc_address (screen_info, "glDeleteBuffersARB");
!       context->backend.gl.bind_buffer = (glitz_gl_bind_buffer_t)
!         glitz_glx_get_proc_address (screen_info, "glBindBufferARB");
!       context->backend.gl.buffer_data = (glitz_gl_buffer_data_t)
!         glitz_glx_get_proc_address (screen_info, "glBufferDataARB");
!       context->backend.gl.buffer_sub_data = (glitz_gl_buffer_sub_data_t)
!         glitz_glx_get_proc_address (screen_info, "glBufferSubDataARB");
!       context->backend.gl.get_buffer_sub_data =
!         (glitz_gl_get_buffer_sub_data_t)
!         glitz_glx_get_proc_address (screen_info, "glGetBufferSubDataARB");
!       context->backend.gl.map_buffer = (glitz_gl_map_buffer_t)
!         glitz_glx_get_proc_address (screen_info, "glMapBufferARB");
!       context->backend.gl.unmap_buffer = (glitz_gl_unmap_buffer_t)
!         glitz_glx_get_proc_address (screen_info, "glUnmapBufferARB");
      }
  
!     if ((!context->backend.gl.gen_buffers) ||
!         (!context->backend.gl.delete_buffers) ||
!         (!context->backend.gl.bind_buffer) ||
!         (!context->backend.gl.buffer_data) ||
!         (!context->backend.gl.buffer_sub_data) ||
!         (!context->backend.gl.get_buffer_sub_data) ||
!         (!context->backend.gl.map_buffer) ||
!         (!context->backend.gl.unmap_buffer)) {
!       context->backend.feature_mask &=
!         ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
!       context->backend.feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
!     }
    }
+ 
+   context->backend.gl.get_integer_v (GLITZ_GL_MAX_VIEWPORT_DIMS,
+                                      context->max_viewport_dims);
+   context->backend.gl.get_integer_v (GLITZ_GL_MAX_TEXTURE_SIZE,
+                                      &context->max_texture_2d_size);
+ 
+   if (screen_info->feature_mask & GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK)
+     context->backend.gl.get_integer_v (GLITZ_GL_MAX_RECTANGLE_TEXTURE_SIZE,
+                                        &context->max_texture_rect_size);
+   else
+     context->max_texture_rect_size = 0;
    
    context->backend.gl.need_lookup = 0;

Index: glitz_glx_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_extension.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** glitz_glx_extension.c	15 Sep 2004 20:26:44 -0000	1.15
--- glitz_glx_extension.c	4 Oct 2004 11:40:48 -0000	1.16
***************
*** 32,37 ****
  #include "glitz_glxint.h"
  
! static glitz_extension_map client_glx_extensions[] = {
!   { 0.0, "GLX_ARB_multisample", GLITZ_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK },
    { 0.0, NULL, 0 }
  }, gl_extensions[] = {
--- 32,41 ----
  #include "glitz_glxint.h"
  
! static glitz_extension_map glx_extensions[] = {
!   { 0.0, "GLX_SGIX_fbconfig", GLITZ_GLX_FEATURE_GLX_FBCONFIG_MASK },
!   { 0.0, "GLX_SGIX_pbuffer", GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK },
!   { 0.0, "GLX_SGI_make_current_read",
!     GLITZ_GLX_FEATURE_GLX_MAKE_CURRENT_READ_MASK },
!   { 0.0, "GLX_ARB_multisample", GLITZ_GLX_FEATURE_GLX_MULTISAMPLE_MASK },
    { 0.0, NULL, 0 }
  }, gl_extensions[] = {
***************
*** 61,77 ****
    { 0.0, "GL_EXT_pixel_buffer_object",
      GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK },
    { 0.0, NULL, 0 }
  };
  
  static unsigned long
! _glitz_glx_extension_query_client_glx (Display *display)
  {
!   const char *client_glx_extensions_strings;
    
!   client_glx_extensions_strings = glXGetClientString (display, GLX_EXTENSIONS);
    
!   return glitz_extensions_query (0.0,
!                                  client_glx_extensions_strings,
!                                  client_glx_extensions);
  }
  
--- 65,87 ----
    { 0.0, "GL_EXT_pixel_buffer_object",
      GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK },
+   { 0.0, "GL_EXT_blend_color",
+     GLITZ_GLX_FEATURE_BLEND_COLOR_MASK },
+   { 0.0, "GL_ARB_imaging",
+     GLITZ_GLX_FEATURE_BLEND_COLOR_MASK },
    { 0.0, NULL, 0 }
  };
  
  static unsigned long
! _glitz_glx_extension_query_glx (Display *display,
!                                 int screen,
!                                 glitz_gl_float_t glx_version)
  {
!   const char *glx_extensions_string;
    
!   glx_extensions_string = glXQueryExtensionsString (display, screen);
    
!   return glitz_extensions_query (glx_version,
!                                  glx_extensions_string,
!                                  glx_extensions);
  }
  
***************
*** 79,88 ****
  _glitz_glx_extension_query_gl (glitz_gl_float_t gl_version)
  {
!   const char *gl_extensions_strings;
    
!   gl_extensions_strings = (const char *) glGetString (GL_EXTENSIONS);
  
    return glitz_extensions_query (gl_version,
!                                  gl_extensions_strings,
                                   gl_extensions);
  }
--- 89,98 ----
  _glitz_glx_extension_query_gl (glitz_gl_float_t gl_version)
  {
!   const char *gl_extensions_string;
    
!   gl_extensions_string = (const char *) glGetString (GL_EXTENSIONS);
  
    return glitz_extensions_query (gl_version,
!                                  gl_extensions_string,
                                   gl_extensions);
  }
***************
*** 91,117 ****
  glitz_glx_query_extensions (glitz_glx_screen_info_t *screen_info)
  {
-   glitz_glx_static_proc_address_list_t *glx =
-     &screen_info->display_info->thread_info->glx;
- 
    screen_info->gl_version = atof ((const char *) glGetString (GL_VERSION));
!   if (screen_info->gl_version < 1.2)
      return GLITZ_STATUS_NOT_SUPPORTED;
    
    screen_info->glx_feature_mask |=
!     _glitz_glx_extension_query_client_glx (screen_info->display_info->display);
    
    screen_info->glx_feature_mask |=
      _glitz_glx_extension_query_gl (screen_info->gl_version);
  
!   if (glx->get_fbconfigs &&
!       glx->get_fbconfig_attrib &&
!       glx->get_visual_from_fbconfig &&
!       glx->create_pbuffer &&
!       glx->destroy_pbuffer)
!     screen_info->glx_feature_mask |= GLITZ_GLX_FEATURE_GLX13_MASK;
! 
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK &&
!       screen_info->glx_feature_mask &
!       GLITZ_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK) {
      const glitz_gl_ubyte_t *renderer = glGetString (GL_RENDERER);
      
--- 101,119 ----
  glitz_glx_query_extensions (glitz_glx_screen_info_t *screen_info)
  {
    screen_info->gl_version = atof ((const char *) glGetString (GL_VERSION));
!   if (screen_info->gl_version < 1.2f)
      return GLITZ_STATUS_NOT_SUPPORTED;
    
    screen_info->glx_feature_mask |=
!     _glitz_glx_extension_query_glx (screen_info->display_info->display,
!                                     screen_info->screen,
!                                     screen_info->glx_version);
    
    screen_info->glx_feature_mask |=
      _glitz_glx_extension_query_gl (screen_info->gl_version);
  
!   if ((screen_info->glx_feature_mask &
!        GLITZ_GLX_FEATURE_GLX_MULTISAMPLE_MASK) &&
!       (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_MULTISAMPLE_MASK)) {
      const glitz_gl_ubyte_t *renderer = glGetString (GL_RENDERER);
      
***************
*** 133,142 ****
  
    if (screen_info->glx_feature_mask &
-       GLITZ_GLX_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK)
-     screen_info->feature_mask |= GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK;
- 
-   if (screen_info->glx_feature_mask &
        GLITZ_GLX_FEATURE_TEXTURE_RECTANGLE_MASK)
      screen_info->feature_mask |= GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK;
  
    if (screen_info->glx_feature_mask &
--- 135,144 ----
  
    if (screen_info->glx_feature_mask &
        GLITZ_GLX_FEATURE_TEXTURE_RECTANGLE_MASK)
      screen_info->feature_mask |= GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK;
+   
+   if (screen_info->glx_feature_mask &
+       GLITZ_GLX_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK)
+     screen_info->feature_mask |= GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK;
  
    if (screen_info->glx_feature_mask &
***************
*** 182,185 ****
--- 184,190 ----
      screen_info->feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  
+   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_BLEND_COLOR_MASK)
+     screen_info->feature_mask |= GLITZ_FEATURE_BLEND_COLOR_MASK;
+ 
    return GLITZ_STATUS_SUCCESS;
  }

Index: glitz_glx_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_format.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glitz_glx_format.c	3 Sep 2004 14:27:58 -0000	1.10
--- glitz_glx_format.c	4 Oct 2004 11:40:48 -0000	1.11
***************
*** 100,104 ****
  
  static void
! glitz_glx_query_formats_glx12 (glitz_glx_screen_info_t *screen_info)
  {
    Display *display;
--- 100,104 ----
  
  static void
! _glitz_glx_query_formats (glitz_glx_screen_info_t *screen_info)
  {
    Display *display;
***************
*** 114,118 ****
                              &visual_templ, &num_visuals);
  
!   /* Offscreen drawing never supported if GLX is older than 1.3 */
    format.draw.offscreen = format.read.offscreen = 0;
    format.draw.onscreen = format.read.onscreen = 1;
--- 114,118 ----
                              &visual_templ, &num_visuals);
  
!   /* Offscreen drawing never supported without fbconfigs */
    format.draw.offscreen = format.read.offscreen = 0;
    format.draw.onscreen = format.read.onscreen = 1;
***************
*** 170,181 ****
  
  static glitz_bool_t
! glitz_glx_query_formats_glx13 (glitz_glx_screen_info_t *screen_info)
  {
    Display *display;
    glitz_format_t format;
    GLXFBConfig *fbconfigs;
!   int i, num_configs, pbuffer_check = 1, pbuffer_support = 1;
!   glitz_glx_static_proc_address_list_t *glx =
!     &screen_info->display_info->thread_info->glx;
    
    display = screen_info->display_info->display;
--- 170,180 ----
  
  static glitz_bool_t
! _glitz_glx_query_formats_fbconfig (glitz_glx_screen_info_t *screen_info)
  {
    Display *display;
    glitz_format_t format;
    GLXFBConfig *fbconfigs;
!   int i, num_configs, pbuffer_support, pbuffer_check = 1;
!   glitz_glx_static_proc_address_list_t *glx = &screen_info->glx;
    
    display = screen_info->display_info->display;
***************
*** 183,190 ****
    fbconfigs = glx->get_fbconfigs (display, screen_info->screen, &num_configs);
    if (!fbconfigs) {
!     /* GLX 1.3 is not support, falling back to GLX 1.2 */
!     screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_GLX13_MASK;
      return 1;
    }
    
    for (i = 0; i < num_configs; i++) {
--- 182,195 ----
    fbconfigs = glx->get_fbconfigs (display, screen_info->screen, &num_configs);
    if (!fbconfigs) {
!     /* fbconfigs are not support, falling back to visuals */
!     screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_GLX_FBCONFIG_MASK;
!     screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK;
      return 1;
    }
+ 
+   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK)
+     pbuffer_support = 1;
+   else
+     pbuffer_support = 0;
    
    for (i = 0; i < num_configs; i++) {
***************
*** 277,285 ****
    glitz_bool_t status = 1;
  
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX13_MASK)
!     status = glitz_glx_query_formats_glx13 (screen_info);
  
    if (status)
!     glitz_glx_query_formats_glx12 (screen_info);
  
    qsort (screen_info->formats, screen_info->n_formats, 
--- 282,290 ----
    glitz_bool_t status = 1;
  
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX_FBCONFIG_MASK)
!     status = _glitz_glx_query_formats_fbconfig (screen_info);
  
    if (status)
!     _glitz_glx_query_formats (screen_info);
  
    qsort (screen_info->formats, screen_info->n_formats, 
***************
*** 330,337 ****
    glitz_glx_screen_info_t *screen_info =
      glitz_glx_screen_info_get (display, screen);
!   glitz_glx_static_proc_address_list_t *glx =
!     &screen_info->display_info->thread_info->glx;
  
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX13_MASK) {
      GLXFBConfig *fbconfigs;
      int i, n_fbconfigs;
--- 335,341 ----
    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_GLX_FBCONFIG_MASK) {
      GLXFBConfig *fbconfigs;
      int i, n_fbconfigs;

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_info.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** glitz_glx_info.c	21 Sep 2004 12:01:25 -0000	1.21
--- glitz_glx_info.c	4 Oct 2004 11:40:48 -0000	1.22
***************
*** 51,55 ****
    (glitz_gl_scissor_t) glScissor,
    (glitz_gl_blend_func_t) glBlendFunc,
-   (glitz_gl_blend_color_t) glBlendColor,
    (glitz_gl_clear_t) glClear,
    (glitz_gl_clear_color_t) glClearColor,
--- 51,54 ----
***************
*** 94,97 ****
--- 93,97 ----
    (glitz_gl_get_integer_v_t) glGetIntegerv,
  
+   (glitz_gl_blend_color_t) 0,
    (glitz_gl_active_texture_t) 0,
    (glitz_gl_gen_programs_t) 0,
***************
*** 114,128 ****
  
  glitz_function_pointer_t
! glitz_glx_get_proc_address (glitz_glx_thread_info_t *info, const char *name)
  {
    glitz_function_pointer_t address = NULL;
!   
!   if (info->glx.get_proc_address)
!     address = 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 ();
--- 114,131 ----
  
  glitz_function_pointer_t
! glitz_glx_get_proc_address (glitz_glx_screen_info_t *screen_info,
!                             const char *name)
  {
    glitz_function_pointer_t address = NULL;
!   glitz_glx_thread_info_t *info = screen_info->display_info->thread_info;
! 
!   if (screen_info->glx_feature_mask &
!       GLITZ_GLX_FEATURE_GLX_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 ();
***************
*** 137,175 ****
  
  static void
! glitz_glx_proc_address_lookup (glitz_glx_thread_info_t *info)
  {
!   info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
!     glitz_glx_get_proc_address (info, "glXGetFBConfigs");
!   info->glx.get_fbconfig_attrib = (glitz_glx_get_fbconfig_attrib_t)
!     glitz_glx_get_proc_address (info, "glXGetFBConfigAttrib");
!   info->glx.get_visual_from_fbconfig = (glitz_glx_get_visual_from_fbconfig_t)
!     glitz_glx_get_proc_address (info, "glXGetVisualFromFBConfig");
!   info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
!     glitz_glx_get_proc_address (info, "glXCreatePbuffer");
!   info->glx.destroy_pbuffer = (glitz_glx_destroy_pbuffer_t)
!     glitz_glx_get_proc_address (info, "glXDestroyPbuffer");
!   info->glx.make_context_current = (glitz_glx_make_context_current_t)
!     glitz_glx_get_proc_address (info, "glXMakeContextCurrent");
!   info->glx.create_new_context = (glitz_glx_create_new_context_t)
!     glitz_glx_get_proc_address (info, "glXCreateNewContext");
!   info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
!     glitz_glx_get_proc_address (info, "glXGetProcAddressARB");
    
!   info->glx.need_lookup = 0;
  }
  
  static void
! glitz_glx_display_destroy (glitz_glx_display_info_t *display_info);
  
  static void
! glitz_glx_screen_destroy (glitz_glx_screen_info_t *screen_info);
  
  static void
! glitz_glx_thread_info_init (glitz_glx_thread_info_t *thread_info)
  {
    thread_info->displays = NULL;
    thread_info->n_displays = 0;
-   memset (&thread_info->glx, 0, sizeof (glitz_glx_static_proc_address_list_t));
-   thread_info->glx.need_lookup = 1;
    thread_info->gl_library = NULL;
    thread_info->dlhand = NULL;
--- 140,242 ----
  
  static void
! _glitz_glx_proc_address_lookup (glitz_glx_screen_info_t *screen_info)
  {
!   if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX_FBCONFIG_MASK) {
!     if (screen_info->glx_version >= 1.3f) {
!       screen_info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
!         glitz_glx_get_proc_address (screen_info, "glXGetFBConfigs");
!       screen_info->glx.get_fbconfig_attrib = (glitz_glx_get_fbconfig_attrib_t)
!         glitz_glx_get_proc_address (screen_info, "glXGetFBConfigAttrib");
!       screen_info->glx.get_visual_from_fbconfig =
!         (glitz_glx_get_visual_from_fbconfig_t)
!         glitz_glx_get_proc_address (screen_info, "glXGetVisualFromFBConfig");
!       screen_info->glx.create_new_context = (glitz_glx_create_new_context_t)
!         glitz_glx_get_proc_address (screen_info, "glXCreateNewContext");
! 
!       if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK) {
!         screen_info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
!           glitz_glx_get_proc_address (screen_info, "glXCreatePbuffer");
!         screen_info->glx.destroy_pbuffer = (glitz_glx_destroy_pbuffer_t)
!           glitz_glx_get_proc_address (screen_info, "glXDestroyPbuffer");
!       }      
!     } else {
!       screen_info->glx.get_fbconfigs = (glitz_glx_get_fbconfigs_t)
!         glitz_glx_get_proc_address (screen_info, "glXGetFBConfigsSGIX");
!       screen_info->glx.get_fbconfig_attrib = (glitz_glx_get_fbconfig_attrib_t)
!         glitz_glx_get_proc_address (screen_info, "glXGetFBConfigAttribSGIX");
!       screen_info->glx.get_visual_from_fbconfig =
!         (glitz_glx_get_visual_from_fbconfig_t)
!         glitz_glx_get_proc_address (screen_info,
!                                     "glXGetVisualFromFBConfigSGIX");
!       screen_info->glx.create_new_context = (glitz_glx_create_new_context_t)
!         glitz_glx_get_proc_address (screen_info,
!                                     "glXCreateContextWithConfigSGIX");
! 
!       if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK) {
!         screen_info->glx.create_pbuffer = (glitz_glx_create_pbuffer_t)
!           glitz_glx_get_proc_address (screen_info, "glXCreatePbufferSGIX");
!         screen_info->glx.destroy_pbuffer = (glitz_glx_destroy_pbuffer_t)
!           glitz_glx_get_proc_address (screen_info, "glXDestroyPbufferSGIX");
!       }
!     }
! 
!     if ((!screen_info->glx.create_pbuffer) ||
!         (!screen_info->glx.destroy_pbuffer))
!       screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_GLX_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_GLX_FBCONFIG_MASK;
!       screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK;
!     }
!   } else
!     screen_info->glx_feature_mask &= ~GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK;
! 
!   if (screen_info->glx_feature_mask &
!       GLITZ_GLX_FEATURE_GLX_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 (screen_info, "glXMakeContextCurrent");
!     } else {
!       screen_info->glx.make_context_current =
!         (glitz_glx_make_context_current_t)
!         glitz_glx_get_proc_address (screen_info, "glXMakeCurrentReadSGI");
!     }
!       
!     if (!screen_info->glx.make_context_current)
!       screen_info->glx_feature_mask &=
!         ~GLITZ_GLX_FEATURE_GLX_MAKE_CURRENT_READ_MASK;
!   }
    
!   if (screen_info->glx_feature_mask &
!       GLITZ_GLX_FEATURE_GLX_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 (screen_info, "glXGetProcAddress");
!     } else {
!       screen_info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
!         glitz_glx_get_proc_address (screen_info, "glXGetProcAddressARB");
!     }
! 
!     if (!screen_info->glx.get_proc_address)
!       screen_info->glx_feature_mask &=
!         ~GLITZ_GLX_FEATURE_GLX_GET_PROC_ADDRESS_MASK;
!   }
  }
  
  static void
! _glitz_glx_display_destroy (glitz_glx_display_info_t *display_info);
  
  static void
! _glitz_glx_screen_destroy (glitz_glx_screen_info_t *screen_info);
  
  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;
***************
*** 177,186 ****
  
  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]);
  
    free (thread_info->displays);
--- 244,253 ----
  
  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]);
  
    free (thread_info->displays);
***************
*** 210,219 ****
  
  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);
    }
--- 277,286 ----
  
  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);
    }
***************
*** 224,228 ****
  {
    if (p) {
!     glitz_glx_thread_info_fini ((glitz_glx_thread_info_t *) p);
      free (p);
    }
--- 291,295 ----
  {
    if (p) {
!     _glitz_glx_thread_info_fini ((glitz_glx_thread_info_t *) p);
      free (p);
    }
***************
*** 230,234 ****
  
  static glitz_glx_thread_info_t *
! glitz_glx_thread_info_get (const char *gl_library)
  {
    glitz_glx_thread_info_t *thread_info;
--- 297,301 ----
  
  static glitz_glx_thread_info_t *
! _glitz_glx_thread_info_get (const char *gl_library)
  {
    glitz_glx_thread_info_t *thread_info;
***************
*** 244,248 ****
    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);
--- 311,315 ----
    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);
***************
*** 250,265 ****
      thread_info = (glitz_glx_thread_info_t *) p;
    
!   if (thread_info->glx.need_lookup) {
!     if (gl_library) {
!       int len = strlen (gl_library);
        
!       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';
!       }
      }
-     
-     glitz_glx_proc_address_lookup (thread_info);
    }
  
--- 317,333 ----
      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';
      }
    }
  
***************
*** 273,277 ****
    NULL,
    0,
-   { 0, 0, 0, 0, 0, 0, 1 },
    NULL,
    NULL
--- 341,344 ----
***************
*** 279,303 ****
  
  static void
! glitz_glx_thread_info_destroy (glitz_glx_thread_info_t *thread_info)
  {
    if (thread_info)
!     glitz_glx_thread_info_fini (thread_info);
  }
  
  static glitz_glx_thread_info_t *
! glitz_glx_thread_info_get (char *gl_library)
  {
!   if (!thread_info.glx.need_lookup) {
!     if (gl_library) {
!       int len = strlen (gl_library);
!       
!       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';
!       }
      }
      
!     glitz_glx_proc_address_lookup (&thread_info);
    }
    
--- 346,371 ----
  
  static void
! _glitz_glx_thread_info_destroy (glitz_glx_thread_info_t *thread_info)
  {
    if (thread_info)
!     _glitz_glx_thread_info_fini (thread_info);
  }
  
  static glitz_glx_thread_info_t *
! _glitz_glx_thread_info_get (char *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';
!     }
    }
    
***************
*** 308,315 ****
  
  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;
--- 376,383 ----
  
  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;
***************
*** 337,346 ****
  
  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]);
  
    if (display_info->screens)
--- 405,414 ----
  
  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]);
  
    if (display_info->screens)
***************
*** 351,379 ****
  
  static void
! glitz_glx_create_root_context (glitz_glx_screen_info_t *screen_info)
  {
    XVisualInfo *vinfo;
    XSetWindowAttributes win_attrib;
!   int attrib_single[] = {
!       GLX_RGBA,
!       GLX_RED_SIZE, 1,
!       GLX_GREEN_SIZE, 1,
!       GLX_BLUE_SIZE, 1,
!       None
    };
-    int attrib_double[] = {
-       GLX_RGBA,
-       GLX_RED_SIZE, 1,
-       GLX_GREEN_SIZE, 1,
-       GLX_BLUE_SIZE, 1,
-       GLX_DOUBLEBUFFER,
-       None
-    };
    int screen = screen_info->screen;
    Display *display = screen_info->display_info->display;
  
!   vinfo = glXChooseVisual (display, screen, attrib_single);
    if (!vinfo)
!     vinfo = glXChooseVisual (display, screen, attrib_double);
    
    if (vinfo) {
--- 419,443 ----
  
  static void
! _glitz_glx_create_root_context (glitz_glx_screen_info_t *screen_info)
  {
    XVisualInfo *vinfo;
    XSetWindowAttributes win_attrib;
!   static int attrib_double[] = {
!     GLX_RGBA,
!     GLX_RED_SIZE, 1,
!     GLX_DOUBLEBUFFER,
!     None
!   };
!   static int attrib_single[] = {
!     GLX_RGBA,
!     GLX_RED_SIZE, 1,
!     None
    };
    int screen = screen_info->screen;
    Display *display = screen_info->display_info->display;
  
!   vinfo = glXChooseVisual (display, screen, attrib_double);
    if (!vinfo)
!     vinfo = glXChooseVisual (display, screen, attrib_single);
    
    if (vinfo) {
***************
*** 388,392 ****
      screen_info->root_drawable =
        XCreateWindow (display, RootWindow (display, screen),
!                      0, 0, 100, 100, 0, vinfo->depth, InputOutput,
                       vinfo->visual,
                       CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
--- 452,456 ----
      screen_info->root_drawable =
        XCreateWindow (display, RootWindow (display, screen),
!                      -1, -1, 1, 1, 0, vinfo->depth, InputOutput,
                       vinfo->visual,
                       CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
***************
*** 427,433 ****
    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 index, n_screens = display_info->n_screens;
  
    for (; n_screens; n_screens--, screens++)
--- 491,497 ----
    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++)
***************
*** 452,462 ****
    screen_info->contexts = NULL;
    screen_info->n_contexts = 0;
  
    glitz_program_map_init (&screen_info->program_map);
  
!   glitz_glx_create_root_context (screen_info);
  
!   screen_info->glx_feature_mask = 0;
!   screen_info->feature_mask = 0;
  
    if (screen_info->root_context.context &&
--- 516,537 ----
    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.context = (GLXContext) 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_create_root_context (screen_info);
!     }
!   }
  
!   screen_info->glx_feature_mask = screen_info->feature_mask = 0;
  
    if (screen_info->root_context.context &&
***************
*** 465,471 ****
                        screen_info->root_context.context)) {
      if (glitz_glx_query_extensions (screen_info) == GLITZ_STATUS_SUCCESS) {
!       glitz_glx_context_proc_address_lookup (screen_info,
!                                              &screen_info->root_context);
!       glitz_glx_query_formats (screen_info);
      }
    }
--- 540,551 ----
                        screen_info->root_context.context)) {
      if (glitz_glx_query_extensions (screen_info) == GLITZ_STATUS_SUCCESS) {
!         screen_info->root_context.backend.feature_mask =
!           screen_info->feature_mask;
! 
!         _glitz_glx_proc_address_lookup (screen_info);
!         
!         glitz_glx_context_proc_address_lookup (screen_info,
!                                                &screen_info->root_context);
!         glitz_glx_query_formats (screen_info);
      }
    }
***************
*** 474,478 ****
    screen_info->root_context.backend.n_formats = screen_info->n_formats;
    screen_info->root_context.backend.program_map = &screen_info->program_map;
-   screen_info->root_context.backend.feature_mask = screen_info->feature_mask;
    
    screen_info->context_stack_size = 1;
--- 554,557 ----
***************
*** 484,488 ****
  
  static void
! glitz_glx_screen_destroy (glitz_glx_screen_info_t *screen_info)
  {
    int i;
--- 563,567 ----
  
  static void
! _glitz_glx_screen_destroy (glitz_glx_screen_info_t *screen_info)
  {
    int i;
***************
*** 525,529 ****
  glitz_glx_init (const char *gl_library)
  {
!   glitz_glx_thread_info_get (gl_library);
  }
  slim_hidden_def(glitz_glx_init);
--- 604,608 ----
  glitz_glx_init (const char *gl_library)
  {
!   _glitz_glx_thread_info_get (gl_library);
  }
  slim_hidden_def(glitz_glx_init);
***************
*** 532,539 ****
  glitz_glx_fini (void)
  {
!   glitz_glx_thread_info_t *info =
!     glitz_glx_thread_info_get (NULL);
  
!   glitz_glx_thread_info_destroy (info);
  }
  slim_hidden_def(glitz_glx_fini);
--- 611,617 ----
  glitz_glx_fini (void)
  {
!   glitz_glx_thread_info_t *info = _glitz_glx_thread_info_get (NULL);
  
!   _glitz_glx_thread_info_destroy (info);
  }
  slim_hidden_def(glitz_glx_fini);

Index: glitz_glx_pbuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_pbuffer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glitz_glx_pbuffer.c	21 Sep 2004 12:01:25 -0000	1.4
--- glitz_glx_pbuffer.c	4 Oct 2004 11:40:48 -0000	1.5
***************
*** 33,37 ****
  
  GLXPbuffer
! glitz_glx_pbuffer_create (glitz_glx_display_info_t *display_info,
                            GLXFBConfig fbconfig,
                            glitz_texture_t *texture)
--- 33,37 ----
  
  GLXPbuffer
! glitz_glx_pbuffer_create (glitz_glx_screen_info_t *screen_info,
                            GLXFBConfig fbconfig,
                            glitz_texture_t *texture)
***************
*** 49,56 ****
      pbuffer_attr[i++] = 0;
      pbuffer_attr[i++] = 0;
!   
      return
!       display_info->thread_info->glx.create_pbuffer (display_info->display,
!                                                      fbconfig, pbuffer_attr);
    } else
      return (GLXPbuffer) 0;
--- 49,56 ----
      pbuffer_attr[i++] = 0;
      pbuffer_attr[i++] = 0;
! 
      return
!       screen_info->glx.create_pbuffer (screen_info->display_info->display,
!                                        fbconfig, pbuffer_attr);
    } else
      return (GLXPbuffer) 0;
***************
*** 58,65 ****
  
  void 
! glitz_glx_pbuffer_destroy (glitz_glx_display_info_t *display_info,
                             GLXPbuffer pbuffer)
  {
!   display_info->thread_info->glx.destroy_pbuffer (display_info->display,
!                                                   pbuffer);
  }
--- 58,65 ----
  
  void 
! glitz_glx_pbuffer_destroy (glitz_glx_screen_info_t *screen_info,
                             GLXPbuffer pbuffer)
  {
!   screen_info->glx.destroy_pbuffer (screen_info->display_info->display,
!                                     pbuffer);
  }

Index: glitz_glx_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_surface.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** glitz_glx_surface.c	21 Sep 2004 12:01:25 -0000	1.21
--- glitz_glx_surface.c	4 Oct 2004 11:40:48 -0000	1.22
***************
*** 43,47 ****
      if (surface->base.format->draw.offscreen) {
        surface->drawable = surface->pbuffer =
!         glitz_glx_pbuffer_create (surface->screen_info->display_info,
                                    surface->context->fbconfig,
                                    &surface->base.texture);
--- 43,47 ----
      if (surface->base.format->draw.offscreen) {
        surface->drawable = surface->pbuffer =
!         glitz_glx_pbuffer_create (surface->screen_info,
                                    surface->context->fbconfig,
                                    &surface->base.texture);
***************
*** 76,87 ****
  _glitz_glx_surface_make_current_read (void *abstract_surface)
  {
!   /* This doesn't seem to work. 
    glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
    glitz_glx_static_proc_address_list_t *glx =
      &surface->screen_info->display_info->thread_info->glx;
!     
!   if (glx->make_context_current && surface->drawable) {
      GLXContext context = glXGetCurrentContext ();
! 
      if (context == surface->context->context)
        return
--- 76,88 ----
  _glitz_glx_surface_make_current_read (void *abstract_surface)
  {
!   /* This doesn't seem to work.
    glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
    glitz_glx_static_proc_address_list_t *glx =
      &surface->screen_info->display_info->thread_info->glx;
!   
!   if ((screen_info->glx_feature_mask &
!        GLITZ_GLX_FEATURE_GLX_MAKE_CURRENT_READ_MASK) && surface->drawable) {
      GLXContext context = glXGetCurrentContext ();
!     
      if (context == surface->context->context)
        return
***************
*** 147,150 ****
--- 148,154 ----
    glitz_glx_context_t *context;
  
+   if (width <= 0 || height <= 0)
+     return NULL;
+ 
    context = glitz_glx_context_get (screen_info, format);
    if (!context)
***************
*** 174,177 ****
--- 178,197 ----
    }
  
+   if (width > 64 || height > 64) {
+     glitz_glx_context_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+     glitz_texture_size_check (&surface->base.backend->gl,
+                               &surface->base.texture,
+                               context->max_texture_2d_size,
+                               context->max_texture_rect_size);
+     glitz_glx_context_pop_current (surface);
+     if (TEXTURE_INVALID_SIZE (&surface->base.texture) ||
+         (format->draw.offscreen &&
+          ((width > context->max_viewport_dims[0]) ||
+           (height > context->max_viewport_dims[1])))) {
+       glitz_surface_destroy (&surface->base);
+       return NULL;
+     }
+   }
+ 
    return &surface->base;
  }
***************
*** 184,191 ****
                            int height)
  {
  
!   return
!     _glitz_glx_surface_create (glitz_glx_screen_info_get (display, screen),
!                                format, width, height);
  }
  slim_hidden_def(glitz_glx_surface_create);
--- 204,214 ----
                            int height)
  {
+   glitz_glx_screen_info_t *screen_info;
  
!   screen_info = glitz_glx_screen_info_get (display, screen);
!   if (!screen_info)
!     return NULL;
!   
!   return _glitz_glx_surface_create (screen_info, format, width, height);
  }
  slim_hidden_def(glitz_glx_surface_create);
***************
*** 201,206 ****
    glitz_glx_surface_t *surface;
    glitz_glx_context_t *context;
!   glitz_glx_screen_info_t *screen_info =
!     glitz_glx_screen_info_get (display, screen);
    
    context = glitz_glx_context_get (screen_info, format);
--- 224,235 ----
    glitz_glx_surface_t *surface;
    glitz_glx_context_t *context;
!   glitz_glx_screen_info_t *screen_info;
! 
!   if (width <= 0 || height <= 0)
!     return NULL;
! 
!   screen_info = glitz_glx_screen_info_get (display, screen);
!   if (!screen_info)
!     return NULL;
    
    context = glitz_glx_context_get (screen_info, format);
***************
*** 228,232 ****
      glitz_glx_context_pop_current (surface);
    }
!   
    return &surface->base;
  }
--- 257,276 ----
      glitz_glx_context_pop_current (surface);
    }
! 
!   if (width > 64 || height > 64) {
!     glitz_glx_context_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
!     glitz_texture_size_check (&surface->base.backend->gl,
!                               &surface->base.texture,
!                               context->max_texture_2d_size,
!                               context->max_texture_rect_size);
!     glitz_glx_context_pop_current (surface);
!     if (TEXTURE_INVALID_SIZE (&surface->base.texture) ||
!         (width > context->max_viewport_dims[0]) ||
!         (height > context->max_viewport_dims[1])) {
!       glitz_surface_destroy (&surface->base);
!       return NULL;
!     }
!   }
!     
    return &surface->base;
  }
***************
*** 261,266 ****
  
    if (surface->pbuffer)
!     glitz_glx_pbuffer_destroy (surface->screen_info->display_info,
!                                surface->pbuffer);
    
    free (surface);
--- 305,309 ----
  
    if (surface->pbuffer)
!     glitz_glx_pbuffer_destroy (surface->screen_info, surface->pbuffer);
    
    free (surface);

Index: glitz_glxint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glxint.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** glitz_glxint.h	21 Sep 2004 12:01:25 -0000	1.17
--- glitz_glxint.h	4 Oct 2004 11:40:48 -0000	1.18
***************
*** 43,55 ****
  #define GLITZ_GLX_FEATURE_TEXTURE_BORDER_CLAMP_MASK     (1L <<  3)
  #define GLITZ_GLX_FEATURE_MULTISAMPLE_MASK              (1L <<  4)
! #define GLITZ_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK       (1L <<  5)
! #define GLITZ_GLX_FEATURE_MULTISAMPLE_FILTER_HINT_MASK  (1L <<  6)
! #define GLITZ_GLX_FEATURE_MULTITEXTURE_MASK             (1L <<  7)
! #define GLITZ_GLX_FEATURE_TEXTURE_ENV_COMBINE_MASK      (1L <<  8)
! #define GLITZ_GLX_FEATURE_TEXTURE_ENV_DOT3_MASK         (1L <<  9)
! #define GLITZ_GLX_FEATURE_FRAGMENT_PROGRAM_MASK         (1L << 10)
! #define GLITZ_GLX_FEATURE_GLX13_MASK                    (1L << 11)
! #define GLITZ_GLX_FEATURE_VERTEX_BUFFER_OBJECT_MASK     (1L << 12)
! #define GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK      (1L << 13)
  
  typedef struct _glitz_glx_surface glitz_glx_surface_t;
--- 43,59 ----
  #define GLITZ_GLX_FEATURE_TEXTURE_BORDER_CLAMP_MASK     (1L <<  3)
  #define GLITZ_GLX_FEATURE_MULTISAMPLE_MASK              (1L <<  4)
! #define GLITZ_GLX_FEATURE_MULTISAMPLE_FILTER_HINT_MASK  (1L <<  5)
! #define GLITZ_GLX_FEATURE_MULTITEXTURE_MASK             (1L <<  6)
! #define GLITZ_GLX_FEATURE_TEXTURE_ENV_COMBINE_MASK      (1L <<  7)
! #define GLITZ_GLX_FEATURE_TEXTURE_ENV_DOT3_MASK         (1L <<  8)
! #define GLITZ_GLX_FEATURE_FRAGMENT_PROGRAM_MASK         (1L <<  9)
! #define GLITZ_GLX_FEATURE_VERTEX_BUFFER_OBJECT_MASK     (1L << 10)
! #define GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK      (1L << 11)
! #define GLITZ_GLX_FEATURE_BLEND_COLOR_MASK              (1L << 12)
! #define GLITZ_GLX_FEATURE_GLX_FBCONFIG_MASK             (1L << 13)
! #define GLITZ_GLX_FEATURE_GLX_PBUFFER_MASK              (1L << 14)
! #define GLITZ_GLX_FEATURE_GLX_MAKE_CURRENT_READ_MASK    (1L << 15)
! #define GLITZ_GLX_FEATURE_GLX_GET_PROC_ADDRESS_MASK     (1L << 16)
! #define GLITZ_GLX_FEATURE_GLX_MULTISAMPLE_MASK          (1L << 17)
  
  typedef struct _glitz_glx_surface glitz_glx_surface_t;
***************
*** 66,70 ****
    glitz_glx_make_context_current_t make_context_current;
    glitz_glx_create_new_context_t create_new_context;
-   glitz_bool_t need_lookup;
  } glitz_glx_static_proc_address_list_t;
  
--- 70,73 ----
***************
*** 72,76 ****
    glitz_glx_display_info_t **displays;
    int n_displays;
-   glitz_glx_static_proc_address_list_t glx;
    char *gl_library;
    void *dlhand;
--- 75,78 ----
***************
*** 94,97 ****
--- 96,102 ----
    GLXFBConfig fbconfig;
    glitz_surface_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_glx_context_t;
  
***************
*** 117,120 ****
--- 122,128 ----
    unsigned long glx_feature_mask;
    glitz_gl_float_t gl_version;
+   glitz_gl_float_t glx_version;
+ 
+   glitz_glx_static_proc_address_list_t glx;
  
    glitz_program_map_t program_map;
***************
*** 138,142 ****
  
  extern glitz_function_pointer_t __internal_linkage
! glitz_glx_get_proc_address (glitz_glx_thread_info_t *info, const char *name);
  
  extern glitz_glx_context_t *__internal_linkage
--- 146,151 ----
  
  extern glitz_function_pointer_t __internal_linkage
! glitz_glx_get_proc_address (glitz_glx_screen_info_t *screen_info,
!                             const char *name);
  
  extern glitz_glx_context_t *__internal_linkage
***************
*** 175,184 ****
  
  extern GLXPbuffer __internal_linkage
! glitz_glx_pbuffer_create (glitz_glx_display_info_t *display_info,
                            GLXFBConfig fbconfig,
                            glitz_texture_t *texture);
  
  extern void __internal_linkage
! glitz_glx_pbuffer_destroy (glitz_glx_display_info_t *display_info,
                             GLXPbuffer pbuffer);
  
--- 184,193 ----
  
  extern GLXPbuffer __internal_linkage
! glitz_glx_pbuffer_create (glitz_glx_screen_info_t *screen_info,
                            GLXFBConfig fbconfig,
                            glitz_texture_t *texture);
  
  extern void __internal_linkage
! glitz_glx_pbuffer_destroy (glitz_glx_screen_info_t *screen_info,
                             GLXPbuffer pbuffer);
  

Index: glitz_pixel.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_pixel.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glitz_pixel.c	16 Sep 2004 23:56:20 -0000	1.9
--- glitz_pixel.c	4 Oct 2004 11:40:48 -0000	1.10
***************
*** 537,540 ****
--- 537,547 ----
  
    if (to_drawable) {
+     glitz_bounding_box_t box;
+ 
+     box.x1 = x_dst;
+     box.y1 = y_dst;
+     box.x2 = box.x1 + width;
+     box.y2 = box.y1 + height;
+     
      glitz_texture_set_tex_gen (gl, texture, x_dst, y_dst, 0); 
  
***************
*** 548,561 ****
      glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
  
!     gl->scissor (x_dst,
!                  dst->height - (y_dst + height),
                   width, height);
  
!     glitz_geometry_enable_default (gl, dst);
  
      gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);
  
-     glitz_geometry_disable (gl, dst);
- 
      if (x_dst == 0 && y_dst == 0 &&
          width == dst->width && height == dst->height)
--- 555,566 ----
      glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
  
!     gl->scissor (box.x1,
!                  dst->height - box.y2,
                   width, height);
  
!     glitz_geometry_enable_default (gl, dst, &box);
  
      gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);
  
      if (x_dst == 0 && y_dst == 0 &&
          width == dst->width && height == dst->height)
***************
*** 629,634 ****
        src_w = texture->width;
        src_h = texture->height;
!       src_x = x_src + texture->box.x1;
!       src_y = y_src + texture->box.y1;
      }
  
--- 634,639 ----
        src_w = texture->width;
        src_h = texture->height;
!       src_x = x_src + src->texture.box.x1;
!       src_y = y_src + src->texture.box.y1;
      }
  
***************
*** 672,675 ****
--- 677,684 ----
  
    if (from_drawable) {
+     if (SURFACE_OFFSCREEN (src)) {
+        x_src += src->texture.box.x1;
+        y_src += src->texture.box.y1;
+     }
      gl->read_pixels (x_src, src->height - y_src - height,
                       width, height,
***************
*** 686,701 ****
    if (transform) {
      glitz_image_t src_image, dst_image;
  
!     src_image.data = data + src_y * gl_format->pixel.bytes_per_line;
      src_image.format = &gl_format->pixel;
!     src_image.width = src_w;
!     src_image.height = src_h;
  
      dst_image.data = glitz_buffer_map (buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
!     dst_image.data += format->skip_lines * format->bytes_per_line;
      dst_image.format = format;
      dst_image.width = width;
      dst_image.height = height;
! 
      _glitz_pixel_transform (transform,
                              &src_image,
--- 695,716 ----
    if (transform) {
      glitz_image_t src_image, dst_image;
+     int stride;
  
!     src_image.data = data + src_y * bytes_per_line;
      src_image.format = &gl_format->pixel;
!     src_image.width = src->width;
!     src_image.height = src->height;
  
+     if (format->bytes_per_line)
+       stride = format->bytes_per_line;
+     else
+       stride = (((width * format->masks.bpp) / 8) + 3) & -4;
+     
      dst_image.data = glitz_buffer_map (buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
!     dst_image.data += format->skip_lines * stride;
      dst_image.format = format;
      dst_image.width = width;
      dst_image.height = height;
!     
      _glitz_pixel_transform (transform,
                              &src_image,

Index: glitz_rect.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_rect.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** glitz_rect.c	11 Sep 2004 14:47:44 -0000	1.12
--- glitz_rect.c	4 Oct 2004 11:40:48 -0000	1.13
***************
*** 110,126 ****
      };
      glitz_buffer_t *buffer;
!     unsigned int size, pixel, *p;
  
!     size = (bounds.x2 - bounds.x1) * (bounds.y2 - bounds.y1);
!     buffer =
!       glitz_pixel_buffer_create (dst,
!                                  NULL,
!                                  size * 4,
!                                  GLITZ_BUFFER_HINT_STREAM_DRAW);
!     if (!buffer) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
        return;
      }
      
      pixel =
        ((((unsigned int) color->alpha * 0xff) / 0xffff) << 24) |
--- 110,131 ----
      };
      glitz_buffer_t *buffer;
!     unsigned int i, width, height, pixel, *data;
  
!     width = bounds.x2 - bounds.x1;
!     height = bounds.y2 - bounds.y1;
! 
!     data = malloc (width * height * 4);
!     if (data == NULL) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
        return;
      }
      
+     buffer = glitz_buffer_create_for_data (data);
+     if (buffer == NULL) {
+       free (data);
+       glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
+       return;
+     }        
+     
      pixel =
        ((((unsigned int) color->alpha * 0xff) / 0xffff) << 24) |
***************
*** 129,138 ****
        ((((unsigned int) color->blue * 0xff) / 0xffff));
      
!     p = glitz_buffer_map (buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
!     
!     for (; size; size--, p++)
!       *p = pixel;
      
!     glitz_buffer_unmap (buffer);
  
      for (; n_rects; n_rects--, rects++)
--- 134,142 ----
        ((((unsigned int) color->blue * 0xff) / 0xffff));
      
!     for (i = 0; i < width; i++)
!       data[i] = pixel;
      
!     for (i = 1; i < height; i++)
!       memcpy (&data[i * width], data, width * sizeof (unsigned int));
  
      for (; n_rects; n_rects--, rects++)
***************
*** 143,146 ****
--- 147,151 ----
  
      glitz_buffer_destroy (buffer);
+     free (data);
    }
    

Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** glitz_surface.c	9 Sep 2004 23:09:03 -0000	1.22
--- glitz_surface.c	4 Oct 2004 11:40:48 -0000	1.23
***************
*** 51,63 ****
    surface->update_mask = GLITZ_UPDATE_ALL_MASK;
  
-   surface->geometry.data[0] = 0.0f;
-   surface->geometry.data[1] = 0.0f;
-   surface->geometry.data[2] = (glitz_float_t) width;
-   surface->geometry.data[3] = 0.0f;
-   surface->geometry.data[4] = (glitz_float_t) width;
-   surface->geometry.data[5] = (glitz_float_t) height;
-   surface->geometry.data[6] = 0.0f;
-   surface->geometry.data[7] = (glitz_float_t) height;
- 
    if (format->doublebuffer)
      surface->draw_buffer = surface->read_buffer = GLITZ_GL_BACK;
--- 51,54 ----
***************
*** 82,85 ****
--- 73,79 ----
  glitz_surface_fini (glitz_surface_t *surface)
  {
+   if (surface->geometry.buffer)
+     glitz_buffer_destroy (surface->geometry.buffer);
+    
    if (surface->texture.name) {
      glitz_surface_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
***************
*** 90,99 ****
    if (surface->transform)
      free (surface->transform);
! 
    if (surface->filter_params)
      glitz_filter_params_destroy (surface->filter_params);
-   
-   if (surface->geometry.default_name)
-     surface->backend->gl.delete_buffers (1, &surface->geometry.default_name);
  }
  
--- 84,90 ----
    if (surface->transform)
      free (surface->transform);
!   
    if (surface->filter_params)
      glitz_filter_params_destroy (surface->filter_params);
  }
  
***************
*** 159,169 ****
  
    if (SURFACE_DRAWABLE (surface)) {
      gl->color_4us (surface->solid.red,
                     surface->solid.green,
                     surface->solid.blue,
                     surface->solid.alpha);
      glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
! 
!     glitz_geometry_enable_default (gl, surface);
      
      gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);
--- 150,166 ----
  
    if (SURFACE_DRAWABLE (surface)) {
+     glitz_bounding_box_t box;
+ 
+     box.x1 = box.y1 = 0;
+     box.x2 = box.y2 = 1;
+     
      gl->color_4us (surface->solid.red,
                     surface->solid.green,
                     surface->solid.blue,
                     surface->solid.alpha);
+     
      glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
!     
!     glitz_geometry_enable_default (gl, surface, &box);
      
      gl->draw_arrays (GLITZ_GL_QUADS, 0, 4);

Index: glitz_texture.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_texture.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** glitz_texture.c	20 Sep 2004 04:59:34 -0000	1.14
--- glitz_texture.c	4 Oct 2004 11:40:48 -0000	1.15
***************
*** 64,68 ****
    } else {
      texture->flags &= ~GLITZ_TEXTURE_FLAG_REPEATABLE_MASK;
!       
      if (feature_mask & GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK) {
        texture->target = GLITZ_GL_TEXTURE_RECTANGLE;
--- 64,68 ----
    } else {
      texture->flags &= ~GLITZ_TEXTURE_FLAG_REPEATABLE_MASK;
! 
      if (feature_mask & GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK) {
        texture->target = GLITZ_GL_TEXTURE_RECTANGLE;
***************
*** 81,85 ****
    if (texture->target == GLITZ_GL_TEXTURE_2D) {
      texture->texcoord_width_unit = 1.0f / texture->width;
!     texture->texcoord_height_unit = 1.0f / texture->height;
    } else {
      texture->texcoord_width_unit = 1.0f;
--- 81,85 ----
    if (texture->target == GLITZ_GL_TEXTURE_2D) {
      texture->texcoord_width_unit = 1.0f / texture->width;
!     texture->texcoord_height_unit = 1.0f / texture->height;   
    } else {
      texture->texcoord_width_unit = 1.0f;
***************
*** 89,92 ****
--- 89,129 ----
  
  void
+ glitz_texture_size_check (glitz_gl_proc_address_list_t *gl,
+                           glitz_texture_t *texture,
+                           glitz_gl_int_t max_2d,
+                           glitz_gl_int_t max_rect) {
+   glitz_gl_enum_t proxy_target;
+   glitz_gl_int_t value, max;
+ 
+   if (texture->target == GLITZ_GL_TEXTURE_2D) {
+     max = max_2d;
+     proxy_target = GLITZ_GL_PROXY_TEXTURE_2D;
+   } else {
+     max = max_rect;
+     proxy_target = GLITZ_GL_PROXY_TEXTURE_RECTANGLE;
+   }
+     
+   if (texture->width > max || texture->height > max) {
+     texture->flags |= GLITZ_TEXTURE_FLAG_INVALID_SIZE_MASK;
+     return;
+   }
+     
+   gl->tex_image_2d (proxy_target, 0,
+                     texture->format, texture->width, texture->height,
+                     0, GLITZ_GL_RGBA, GLITZ_GL_UNSIGNED_BYTE, NULL);
+   gl->get_tex_level_parameter_iv (proxy_target, 0,
+                                   GLITZ_GL_TEXTURE_WIDTH, &value);
+   if (value != texture->width) {
+     texture->flags |= GLITZ_TEXTURE_FLAG_INVALID_SIZE_MASK;
+     return;
+   }
+   
+   gl->get_tex_level_parameter_iv (proxy_target, 0,
+                                   GLITZ_GL_TEXTURE_HEIGHT, &value);
+   if (value != texture->height)
+     texture->flags |= GLITZ_TEXTURE_FLAG_INVALID_SIZE_MASK;
+ }
+ 
+ void
  glitz_texture_allocate (glitz_gl_proc_address_list_t *gl,
                          glitz_texture_t *texture)
***************
*** 96,100 ****
    if (!texture->name)
      gl->gen_textures (1, &texture->name);
! 
    texture->flags |= GLITZ_TEXTURE_FLAG_ALLOCATED_MASK;
    
--- 133,137 ----
    if (!texture->name)
      gl->gen_textures (1, &texture->name);
!   
    texture->flags |= GLITZ_TEXTURE_FLAG_ALLOCATED_MASK;
    
***************
*** 103,115 ****
    if (texture->box.x2 != texture->width ||
        texture->box.y2 != texture->height) {
!     data = malloc (texture->width * texture->height * 4);
      if (data)
!       memset (data, 0, texture->width * texture->height * 4);
    }
!   
    gl->tex_image_2d (texture->target, 0, texture->format,
!                     texture->width, texture->height,
!                     0, GLITZ_GL_RGBA, GLITZ_GL_UNSIGNED_BYTE, data);
!   
    glitz_texture_unbind (gl, texture);
  
--- 140,158 ----
    if (texture->box.x2 != texture->width ||
        texture->box.y2 != texture->height) {
!     data = malloc (texture->width * texture->height);
      if (data)
!       memset (data, 0, texture->width * texture->height);
! 
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
!     gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_ROWS, 0);
!     gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_PIXELS, 0);
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
    }
! 
    gl->tex_image_2d (texture->target, 0, texture->format,
!                     texture->width, texture->height, 0,
!                     GLITZ_GL_ALPHA, GLITZ_GL_UNSIGNED_BYTE, data);
! 
    glitz_texture_unbind (gl, texture);
  

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** glitzint.h	13 Sep 2004 17:50:38 -0000	1.28
--- glitzint.h	4 Oct 2004 11:40:48 -0000	1.29
***************
*** 90,94 ****
    glitz_gl_scissor_t scissor;
    glitz_gl_blend_func_t blend_func;
-   glitz_gl_blend_color_t blend_color;
    glitz_gl_clear_t clear;
    glitz_gl_clear_color_t clear_color;
--- 90,93 ----
***************
*** 132,136 ****
    glitz_gl_copy_tex_sub_image_2d_t copy_tex_sub_image_2d;
    glitz_gl_get_integer_v_t get_integer_v;
!   
    glitz_gl_active_texture_t active_texture;
    glitz_gl_gen_programs_t gen_programs;
--- 131,136 ----
    glitz_gl_copy_tex_sub_image_2d_t copy_tex_sub_image_2d;
    glitz_gl_get_integer_v_t get_integer_v;
! 
!   glitz_gl_blend_color_t blend_color;
    glitz_gl_active_texture_t active_texture;
    glitz_gl_gen_programs_t gen_programs;
***************
*** 232,238 ****
  } glitz_vec4_t;
  
! #define GLITZ_TEXTURE_FLAG_ALLOCATED_MASK     (1L <<  0)
! #define GLITZ_TEXTURE_FLAG_REPEATABLE_MASK    (1L <<  1)
! #define GLITZ_TEXTURE_FLAG_PADABLE_MASK       (1L <<  2)
  
  #define TEXTURE_ALLOCATED(texture) \
--- 232,239 ----
  } glitz_vec4_t;
  
! #define GLITZ_TEXTURE_FLAG_ALLOCATED_MASK    (1L <<  0)
! #define GLITZ_TEXTURE_FLAG_REPEATABLE_MASK   (1L <<  1)
! #define GLITZ_TEXTURE_FLAG_PADABLE_MASK      (1L <<  2)
! #define GLITZ_TEXTURE_FLAG_INVALID_SIZE_MASK (1L <<  3)
  
  #define TEXTURE_ALLOCATED(texture) \
***************
*** 245,248 ****
--- 246,252 ----
    ((texture)->flags & GLITZ_TEXTURE_FLAG_PADABLE_MASK)
  
+ #define TEXTURE_INVALID_SIZE(texture) \
+   ((texture)->flags & GLITZ_TEXTURE_FLAG_INVALID_SIZE_MASK)
+ 
  typedef struct _glitz_texture {
    glitz_gl_uint_t name;
***************
*** 264,268 ****
  
  struct _glitz_buffer {
-   glitz_gl_sizei_t size;
    glitz_gl_uint_t name;
    glitz_gl_enum_t target;
--- 268,271 ----
***************
*** 281,286 ****
    glitz_float_t x_offset;
    glitz_float_t y_offset;
- 
-   glitz_gl_uint_t default_name;
    glitz_gl_float_t data[8];
  } glitz_geometry_t;
--- 284,287 ----
***************
*** 510,513 ****
--- 511,520 ----
  
  void
+ glitz_texture_size_check (glitz_gl_proc_address_list_t *gl,
+                           glitz_texture_t *texture,
+                           glitz_gl_int_t max_2d,
+                           glitz_gl_int_t max_rect);
+ 
+ void
  glitz_texture_allocate (glitz_gl_proc_address_list_t *gl,
                          glitz_texture_t *texture);
***************
*** 674,678 ****
  extern void __internal_linkage
  glitz_geometry_enable_default (glitz_gl_proc_address_list_t *gl,
!                                glitz_surface_t *dst);
  
  extern void __internal_linkage
--- 681,686 ----
  extern void __internal_linkage
  glitz_geometry_enable_default (glitz_gl_proc_address_list_t *gl,
!                                glitz_surface_t *dst,
!                                glitz_bounding_box_t *box);
  
  extern void __internal_linkage
***************
*** 681,685 ****
                         glitz_gl_enum_t *primitive,
                         glitz_gl_int_t *first,
!                        glitz_gl_sizei_t *count);
  
  extern void __internal_linkage
--- 689,694 ----
                         glitz_gl_enum_t *primitive,
                         glitz_gl_int_t *first,
!                        glitz_gl_sizei_t *count,
!                        glitz_bounding_box_t *box);
  
  extern void __internal_linkage




More information about the cairo-commit mailing list