[cairo-commit] glitz/src Makefile.am, 1.3, 1.4 glitz.c, 1.16, 1.17 glitz.h, 1.13, 1.14 glitz_agl_context.c, 1.4, 1.5 glitz_agl_format.c, 1.3, 1.4 glitz_agl_info.c, 1.4, 1.5 glitz_agl_pbuffer.c, 1.4, 1.5 glitz_agl_surface.c, 1.10, 1.11 glitz_color_range.c, 1.1.1.1, 1.2 glitz_format.c, 1.4, 1.5 glitz_gl.h, 1.3, 1.4 glitz_glx_context.c, 1.7, 1.8 glitz_glx_format.c, 1.6, 1.7 glitz_glx_info.c, 1.9, 1.10 glitz_glx_surface.c, 1.12, 1.13 glitz_operator.c, 1.2, 1.3 glitz_pixel.c, NONE, 1.1 glitz_programmatic.c, 1.8, 1.9 glitz_render.c, 1.1, 1.2 glitz_surface.c, 1.13, 1.14 glitz_texture.c, 1.7, 1.8 glitz_util.c, 1.5, 1.6 glitzint.h, 1.18, 1.19

David Reveman commit at pdx.freedesktop.org
Mon Jun 21 14:26:59 PDT 2004


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv8842/src

Modified Files:
	Makefile.am glitz.c glitz.h glitz_agl_context.c 
	glitz_agl_format.c glitz_agl_info.c glitz_agl_pbuffer.c 
	glitz_agl_surface.c glitz_color_range.c glitz_format.c 
	glitz_gl.h glitz_glx_context.c glitz_glx_format.c 
	glitz_glx_info.c glitz_glx_surface.c glitz_operator.c 
	glitz_programmatic.c glitz_render.c glitz_surface.c 
	glitz_texture.c glitz_util.c glitzint.h 
Added Files:
	glitz_pixel.c 
Log Message:
Added new pixel interface and support for none 24bit visuals

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/glitz/src/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.am	11 Jun 2004 14:35:41 -0000	1.3
--- Makefile.am	21 Jun 2004 21:26:56 -0000	1.4
***************
*** 43,46 ****
--- 43,47 ----
  	glitz_render.c \
  	glitz_stencil.c \
+ 	glitz_pixel.c \
  	glitz_gl.h \
  	glitzint.h

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** glitz.c	11 Jun 2004 14:35:41 -0000	1.16
--- glitz.c	21 Jun 2004 21:26:56 -0000	1.17
***************
*** 530,534 ****
    
    glitz_set_operator (gl, op);
! 
    glitz_render_enable (type, src, NULL, dst, texture, NULL, opacity);
    
--- 530,534 ----
    
    glitz_set_operator (gl, op);
!   
    glitz_render_enable (type, src, NULL, dst, texture, NULL, opacity);
    
***************
*** 765,774 ****
      
      gl->begin (GLITZ_GL_QUADS);
-     
      gl->vertex_2d (0.0, 0.0);
      gl->vertex_2d (dst->width, 0.0);
      gl->vertex_2d (dst->width, dst->height);
      gl->vertex_2d (0.0, dst->height);
-     
      gl->end ();
    }
--- 765,772 ----
***************
*** 852,856 ****
        glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
  
-       gl->pixel_zoom (1.0, 1.0);
        glitz_set_raster_pos (gl, x_dst, dst->height - (y_dst + height));
        gl->copy_pixels (x_src, src->height - (y_src + height),
--- 850,853 ----
***************
*** 869,872 ****
--- 866,870 ----
                         GLITZ_GL_TEXTURE_ENV_MODE,
                         GLITZ_GL_REPLACE);
+         gl->color_4us (0x0, 0x0, 0x0, 0xffff);
  
          glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
***************
*** 923,941 ****
  
    if (!status) {
!     int rowstride, bytes_per_pixel;
!     char *pixel_buf;
!     
!     bytes_per_pixel = MAX (dst->format->bpp, src->format->bpp) / 8;
      
-     rowstride = width * bytes_per_pixel;
      rowstride = (rowstride + 3) & -4;
!     pixel_buf = malloc (height * rowstride);
!     if (!pixel_buf) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
        return;
      }
!     glitz_surface_read_pixels (src, x_src, y_src, width, height, pixel_buf);
!     glitz_surface_draw_pixels (dst, x_dst, y_dst, width, height, pixel_buf);
!     free (pixel_buf);
    }
  }
--- 921,949 ----
  
    if (!status) {
!     int rowstride = 1;
!     char *data;
!     static glitz_pixel_format_t pf = {
!       {
!         32,
!         0xff000000,
!         0x00ff0000,
!         0x0000ff00,
!         0x000000ff
!       },
!       0, 0,
!       GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
!     };
      
      rowstride = (rowstride + 3) & -4;
!     data = malloc (height * rowstride);
!     if (!data) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
        return;
      }
!     
!     glitz_get_pixels (src, x_src, y_src, width, height, &pf, data);
!     glitz_put_pixels (dst, x_dst, y_dst, width, height, &pf, data);
!     
!     free (data);
    }
  }

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz.h	11 Jun 2004 14:42:20 -0000	1.13
--- glitz.h	21 Jun 2004 21:26:56 -0000	1.14
***************
*** 151,159 ****
    
  #define GLITZ_FORMAT_ID_MASK                  (1L <<  0)
- #define GLITZ_FORMAT_BPP_MASK                 (1L <<  1)
- #define GLITZ_FORMAT_RED_MASK_MASK            (1L <<  2)
- #define GLITZ_FORMAT_GREEN_MASK_MASK          (1L <<  3)
- #define GLITZ_FORMAT_BLUE_MASK_MASK           (1L <<  4)
- #define GLITZ_FORMAT_ALPHA_MASK_MASK          (1L <<  5)
  #define GLITZ_FORMAT_RED_SIZE_MASK            (1L <<  6)
  #define GLITZ_FORMAT_GREEN_SIZE_MASK          (1L <<  7)
--- 151,154 ----
***************
*** 184,194 ****
  typedef struct _glitz_format_t {
    glitz_format_id_t id;
- 
-   /* bpp and mask values specifies the pixel format for read/draw pixels */
-   int bpp;
-   unsigned long red_mask;
-   unsigned long green_mask;
-   unsigned long blue_mask;
-   unsigned long alpha_mask;
    
    unsigned short red_size;
--- 179,182 ----
***************
*** 211,215 ****
  #define GLITZ_FORMAT_OPTION_MULTISAMPLE_MASK    (1L << 4)
  #define GLITZ_FORMAT_OPTION_NO_MULTISAMPLE_MASK (1L << 5)
! #define GLITZ_FORMAT_OPTION_READONLY_MASK       (1L << 6)
  
  /* glitz_status.c */
--- 199,204 ----
  #define GLITZ_FORMAT_OPTION_MULTISAMPLE_MASK    (1L << 4)
  #define GLITZ_FORMAT_OPTION_NO_MULTISAMPLE_MASK (1L << 5)
! #define GLITZ_FORMAT_OPTION_READDRAW_MASK       (1L << 6)
! #define GLITZ_FORMAT_OPTION_READONLY_MASK       (1L << 7)
  
  /* glitz_status.c */
***************
*** 309,312 ****
--- 298,311 ----
  
  typedef enum {
+   GLITZ_POLYEDGE_SMOOTH_HINT_FAST,
+   GLITZ_POLYEDGE_SMOOTH_HINT_GOOD,
+   GLITZ_POLYEDGE_SMOOTH_HINT_BEST
+ } glitz_polyedge_smooth_hint_t;
+ 
+ void
+ glitz_surface_set_polyedge_smooth_hint (glitz_surface_t *surface,
+                                         glitz_polyedge_smooth_hint_t hint);
+ 
+ typedef enum {
    GLITZ_CLIP_OPERATOR_SET,
    GLITZ_CLIP_OPERATOR_UNION,
***************
*** 361,380 ****
  
  void
- glitz_surface_read_pixels (glitz_surface_t *surface,
-                            int x,
-                            int y,
-                            unsigned int width,
-                            unsigned int height,
-                            char *pixels);
- 
- void
- glitz_surface_draw_pixels (glitz_surface_t *surface,
-                            int x,
-                            int y,
-                            unsigned int width,
-                            unsigned int height,
-                            char *pixels);
- 
- void
  glitz_surface_get_gl_texture (glitz_surface_t *surface,
                                unsigned int *name,
--- 360,363 ----
***************
*** 423,427 ****
--- 406,451 ----
  unsigned long
  glitz_surface_get_hints (glitz_surface_t *surface);
+ 
+   
+ /* glitz_pixel.c */
    
+ typedef enum {
+   GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN,
+   GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
+ } glitz_pixel_scanline_order_t;
+ 
+ typedef struct _glitz_pixel_masks {
+   int bpp;
+   unsigned long alpha_mask;
+   unsigned long red_mask;
+   unsigned long green_mask;
+   unsigned long blue_mask;
+ } glitz_pixel_masks_t;
+ 
+ typedef struct _glitz_pixel_format {
+   glitz_pixel_masks_t masks;
+   int xoffset;
+   int bytes_per_line;
+   glitz_pixel_scanline_order_t scanline_order;
+ } glitz_pixel_format_t;
+ 
+ void
+ glitz_put_pixels (glitz_surface_t *dst,
+                   int x_dst,
+                   int y_dst,
+                   int width,
+                   int height,
+                   glitz_pixel_format_t *format,
+                   char *pixels);
+ 
+ void
+ glitz_get_pixels (glitz_surface_t *src,
+                   int x_src,
+                   int y_src,
+                   int width,
+                   int height,
+                   glitz_pixel_format_t *format,
+                   char *pixels);
+ 
    
  /* glitz_rect.c */

Index: glitz_agl_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_context.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glitz_agl_context.c	24 May 2004 07:16:42 -0000	1.4
--- glitz_agl_context.c	21 Jun 2004 21:26:56 -0000	1.5
***************
*** 91,96 ****
        glEnable (GLITZ_GL_MULTISAMPLE_ARB);
        if (surface->thread_info->agl_feature_mask &
!           GLITZ_AGL_FEATURE_MULTISAMPLE_FILTER_MASK)
!         glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV, GLITZ_GL_NICEST);
      } else
        glDisable (GLITZ_GL_MULTISAMPLE_ARB);
--- 91,101 ----
        glEnable (GLITZ_GL_MULTISAMPLE_ARB);
        if (surface->thread_info->agl_feature_mask &
!           GLITZ_AGL_FEATURE_MULTISAMPLE_FILTER_MASK) {
!         if (surface->base.polyedge_smooth_hint ==
!             GLITZ_POLYEDGE_SMOOTH_HINT_FAST)
!           glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV, GLITZ_GL_FASTEST);
!         else
!           glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV, GLITZ_GL_NICEST);
!       }
      } else
        glDisable (GLITZ_GL_MULTISAMPLE_ARB);

Index: glitz_agl_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_format.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glitz_agl_format.c	24 May 2004 07:16:42 -0000	1.3
--- glitz_agl_format.c	21 Jun 2004 21:26:56 -0000	1.4
***************
*** 34,37 ****
--- 34,39 ----
  #include <stdlib.h>
  
+ extern glitz_gl_proc_address_list_t _glitz_agl_gl_proc_address;
+ 
  static const struct _glx_pixel_format_attrib {
    GLint attrib[20];
***************
*** 225,230 ****
                     glitz_format_t *format)
  {
-   glitz_format_calculate_pixel_transfer_info (format);
-   
    if (!glitz_format_find (thread_info->formats, thread_info->n_formats,
                            GLITZ_FORMAT_ALL_EXCEPT_ID_MASK, format, 0)) {
--- 227,230 ----
***************
*** 254,257 ****
--- 254,269 ----
  }
  
+ static void
+ _glitz_agl_add_texture_format (glitz_format_t *texture_format, void *ptr)
+ {
+   glitz_agl_thread_info_t *thread_info = (glitz_agl_thread_info_t *) ptr;
+   glitz_format_t format;
+ 
+   format = *texture_format;
+   format.id = 0;
+ 
+   _glitz_add_format (thread_info, &format);
+ }
+ 
  void
  glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info)
***************
*** 320,341 ****
      }
  
!     _glitz_add_format (thread_info, &format);
! 
!     if (format.alpha_size &&
!         (format.red_size || format.green_size || format.blue_size)) {
!       unsigned short tmp;
!       
!       tmp = format.alpha_size;
!       format.alpha_size = 0;
!       _glitz_add_format (thread_info, &format);
!       format.alpha_size = tmp;
!       format.red_size = format.green_size = format.blue_size = 0;
        _glitz_add_format (thread_info, &format);
-     }
    }
  
-   qsort (thread_info->formats, thread_info->n_formats,
-          sizeof (glitz_format_t), _glitz_agl_format_compare);
- 
    if (!glitz_format_find_standard (thread_info->formats,
                                     thread_info->n_formats,
--- 332,340 ----
      }
  
!     if (format.red_size || format.green_size || format.blue_size ||
!         format.alpha_size)
        _glitz_add_format (thread_info, &format);
    }
  
    if (!glitz_format_find_standard (thread_info->formats,
                                     thread_info->n_formats,
***************
*** 346,361 ****
    }
  
!   /* Adding read only offscreen formats. Surfaces created with these format
!      can only be used with draw/read pixel functions and as source. */
!   memset (&format, 0, sizeof (glitz_format_t));
!   format.read.offscreen = 1;
!   format.alpha_size = format.red_size = format.green_size =
!     format.blue_size = 8;
!   _glitz_add_format (thread_info, &format);
!   format.alpha_size = 0;
!   _glitz_add_format (thread_info, &format);
!   format.alpha_size = 8;
!   format.red_size = format.green_size = format.blue_size = 0;
!   _glitz_add_format (thread_info, &format);
    
    _glitz_move_out_ids (thread_info);
--- 345,354 ----
    }
  
!   qsort (thread_info->formats, thread_info->n_formats,
!          sizeof (glitz_format_t), _glitz_agl_format_compare);
! 
!   glitz_format_for_each_texture_format (&_glitz_agl_add_texture_format,
! 					&_glitz_agl_gl_proc_address,
! 					(void *) thread_info);
    
    _glitz_move_out_ids (thread_info);

Index: glitz_agl_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_info.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glitz_agl_info.c	11 Jun 2004 14:35:41 -0000	1.4
--- glitz_agl_info.c	21 Jun 2004 21:26:56 -0000	1.5
***************
*** 76,81 ****
    (glitz_gl_read_pixels_t) glReadPixels,
    (glitz_gl_get_tex_image_t) glGetTexImage,
-   (glitz_gl_pixel_zoom_t) glPixelZoom,
-   (glitz_gl_draw_pixels_t) glDrawPixels,
    (glitz_gl_tex_sub_image_2d_t) glTexSubImage2D,
    (glitz_gl_gen_textures_t) glGenTextures,
--- 76,79 ----
***************
*** 85,88 ****
--- 83,87 ----
    (glitz_gl_tex_image_2d_t) glTexImage2D,
    (glitz_gl_tex_parameter_i_t) glTexParameteri,
+   (glitz_gl_get_tex_level_parameter_iv_t) glGetTexLevelParameteriv,
    (glitz_gl_copy_tex_sub_image_2d_t) glCopyTexSubImage2D,
    (glitz_gl_get_integer_v_t) glGetIntegerv,
***************
*** 195,200 ****
  
    aglSetCurrentContext (thread_info->root_context.context);
-   glPixelStorei (GL_PACK_ALIGNMENT, 4);
-   glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
    
    glitz_agl_query_extensions (thread_info);
--- 194,197 ----

Index: glitz_agl_pbuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_pbuffer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glitz_agl_pbuffer.c	18 May 2004 15:01:50 -0000	1.4
--- glitz_agl_pbuffer.c	21 Jun 2004 21:26:56 -0000	1.5
***************
*** 40,44 ****
  
    aglCreatePBuffer (texture->width, texture->height,
!                     texture->target, texture->internal_format, 0, &pbuffer);
  
    return pbuffer;
--- 40,44 ----
  
    aglCreatePBuffer (texture->width, texture->height,
!                     texture->target, texture->format, 0, &pbuffer);
  
    return pbuffer;

Index: glitz_agl_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_surface.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glitz_agl_surface.c	30 May 2004 15:59:54 -0000	1.10
--- glitz_agl_surface.c	21 Jun 2004 21:26:56 -0000	1.11
***************
*** 353,358 ****
        glitz_texture_init (&texture,
                            width, height,
!                           glitz_get_gl_format_from_bpp
!                           (surface->base.format->bpp),
                            surface->thread_info->texture_mask);
        
--- 353,357 ----
        glitz_texture_init (&texture,
                            width, height,
!                           surface->base.texture.format,
                            surface->thread_info->texture_mask);
        

Index: glitz_color_range.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_color_range.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** glitz_color_range.c	30 Mar 2004 17:07:18 -0000	1.1.1.1
--- glitz_color_range.c	21 Jun 2004 21:26:56 -0000	1.2
***************
*** 125,130 ****
      gl->tex_image_1d (GLITZ_GL_TEXTURE_1D, 0, GLITZ_GL_RGBA,
                        color_range->size, 0,
!                       glitz_get_gl_format_from_bpp (32),
!                       glitz_get_gl_data_type_from_bpp (32),
                        color_range->data);
      
--- 125,136 ----
      gl->tex_image_1d (GLITZ_GL_TEXTURE_1D, 0, GLITZ_GL_RGBA,
                        color_range->size, 0,
!                       GLITZ_GL_BGRA,
!                       
! #if IMAGE_BYTE_ORDER == MSBFirst
!                       GLITZ_GL_UNSIGNED_INT_8_8_8_8_REV,
! #else
!                       GLITZ_GL_UNSIGNED_BYTE,
! #endif
!                       
                        color_range->data);
      

Index: glitz_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_format.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glitz_format.c	24 May 2004 07:16:42 -0000	1.4
--- glitz_format.c	21 Jun 2004 21:26:56 -0000	1.5
***************
*** 34,37 ****
--- 34,125 ----
  #include <stdlib.h>
  
+ static glitz_format_t _texture_formats[] = {
+   {
+     GLITZ_GL_INTENSITY4, 0, 0, 0, 4, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_INTENSITY8, 0, 0, 0, 8, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_INTENSITY12, 0, 0, 0, 12, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_INTENSITY16, 0, 0, 0, 16, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_R3_G3_B2, 3, 3, 2, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB4, 4, 4, 4, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB5,5, 5, 5, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB8, 8, 8, 8, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB10, 10, 10, 10, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB12, 12, 12, 12, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB16, 16, 16, 16, 0, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGBA2, 2, 2, 2, 2, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB5_A1, 5, 5, 5, 1, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGBA8, 8, 8, 8, 8, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGB10_A2, 10, 10, 10, 2, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGBA12, 12, 12, 12, 12, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }, {
+     GLITZ_GL_RGBA16, 16, 16, 16, 16, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
+   }
+ };
+ 
+ void
+ glitz_format_for_each_texture_format (glitz_format_call_back_t call_back,
+ 				      glitz_gl_proc_address_list_t *gl,
+                                       void *ptr)
+ {
+   glitz_gl_uint_t name;
+   glitz_gl_int_t value;
+   int i, n_texture_formats =
+     sizeof (_texture_formats) / sizeof (glitz_format_t);
+ 
+   gl->gen_textures (1, &name);
+   gl->enable (GLITZ_GL_PROXY_TEXTURE_2D);
+   gl->bind_texture (GLITZ_GL_PROXY_TEXTURE_2D, name);
+   
+   for (i = 0; i < n_texture_formats; i++) {
+     gl->tex_image_2d (GLITZ_GL_PROXY_TEXTURE_2D, 0,
+ 		      _texture_formats[i].id, 1, 1,
+ 		      0, GLITZ_GL_RGBA, GLITZ_GL_UNSIGNED_BYTE, NULL);
+     gl->get_tex_level_parameter_iv (GLITZ_GL_PROXY_TEXTURE_2D, 0,
+ 				    GLITZ_GL_TEXTURE_RED_SIZE, &value);
+     if (value != _texture_formats[i].red_size)
+       continue;
+ 
+     gl->get_tex_level_parameter_iv (GLITZ_GL_PROXY_TEXTURE_2D, 0,
+ 				    GLITZ_GL_TEXTURE_GREEN_SIZE, &value);
+     if (value != _texture_formats[i].green_size)
+       continue;
+ 
+     gl->get_tex_level_parameter_iv (GLITZ_GL_PROXY_TEXTURE_2D, 0,
+ 				    GLITZ_GL_TEXTURE_BLUE_SIZE, &value);
+     if (value != _texture_formats[i].blue_size)
+       continue;
+ 
+     gl->get_tex_level_parameter_iv (GLITZ_GL_PROXY_TEXTURE_2D, 0,
+ 				    GLITZ_GL_TEXTURE_ALPHA_SIZE, &value);
+     if (value != _texture_formats[i].alpha_size) {
+       gl->get_tex_level_parameter_iv (GLITZ_GL_PROXY_TEXTURE_2D, 0,
+                                       GLITZ_GL_TEXTURE_INTENSITY_SIZE, &value);
+       if (value != _texture_formats[i].alpha_size)
+         continue;
+     }
+ 
+     call_back (&_texture_formats[i], ptr);
+   }
+ 
+   gl->bind_texture (GLITZ_GL_PROXY_TEXTURE_2D, 0);
+   gl->disable (GLITZ_GL_PROXY_TEXTURE_2D);
+   gl->delete_textures (1, &name);
+ }
+ 
  glitz_format_t *
  glitz_format_find (glitz_format_t *formats,
***************
*** 46,69 ****
          continue;
  
-     if (mask & GLITZ_FORMAT_BPP_MASK)
-       if (templ->bpp != formats->bpp)
-         continue;
-         
-     if (mask & GLITZ_FORMAT_RED_MASK_MASK)
-       if (templ->red_mask != formats->red_mask)
-         continue;
- 
-     if (mask & GLITZ_FORMAT_GREEN_MASK_MASK)
-       if (templ->green_mask != formats->green_mask)
-         continue;
- 
-     if (mask & GLITZ_FORMAT_BLUE_MASK_MASK)
-       if (templ->blue_mask != formats->blue_mask)
-         continue;
- 
-     if (mask & GLITZ_FORMAT_ALPHA_MASK_MASK)
-       if (templ->alpha_mask != formats->alpha_mask)
-         continue;
- 
      if (mask & GLITZ_FORMAT_RED_SIZE_MASK)
        if (templ->red_size != formats->red_size)
--- 134,137 ----
***************
*** 119,124 ****
  
      if (count-- == 0)
!       return formats;
!       
    }
  
--- 187,191 ----
  
      if (count-- == 0)
!       return formats;    
    }
  
***************
*** 126,129 ****
--- 193,271 ----
  }
  
+ static glitz_format_t *
+ glitz_format_find_best (glitz_format_t *formats,
+                         int n_formats,
+                         unsigned long mask,
+                         const glitz_format_t *templ)
+ {
+   glitz_format_t *format, *best_format;
+   int best_diff, best_above;
+   int i, diff, above, red_diff, green_diff, blue_diff, alpha_diff;
+   unsigned long templ_mask;
+   
+   best_diff = MAXSHORT;
+   best_above = 0;
+   best_format = NULL;
+   
+   templ_mask = mask & ~(GLITZ_FORMAT_RED_SIZE_MASK |
+                         GLITZ_FORMAT_GREEN_SIZE_MASK |
+                         GLITZ_FORMAT_BLUE_SIZE_MASK |
+                         GLITZ_FORMAT_ALPHA_SIZE_MASK);
+   
+   i = 0;
+   do {
+     format = glitz_format_find (formats, n_formats, templ_mask, templ, i++);
+     if (format) {
+       if (mask & GLITZ_FORMAT_RED_SIZE_MASK) {
+         if (templ->red_size != 0 && format->red_size == 0)
+           continue;
+         
+         red_diff = format->red_size - templ->red_size;
+       } else
+         red_diff = format->red_size;
+ 
+       if (mask & GLITZ_FORMAT_GREEN_SIZE_MASK) {
+         if (templ->green_size != 0 && format->green_size == 0)
+           continue;
+ 
+         green_diff = format->green_size - templ->green_size;
+       } else
+         green_diff = format->green_size;
+ 
+       if (mask & GLITZ_FORMAT_BLUE_SIZE_MASK) {
+         if (templ->blue_size != 0 && format->blue_size == 0)
+           continue;
+ 
+         blue_diff = format->blue_size - templ->blue_size;
+       } else
+         blue_diff = format->blue_size;
+ 
+       if (mask & GLITZ_FORMAT_ALPHA_SIZE_MASK) {
+         if (templ->alpha_size != 0 && format->alpha_size == 0)
+           continue;
+ 
+         alpha_diff = format->alpha_size - templ->alpha_size;
+       } else
+         alpha_diff = format->alpha_size;
+       
+       if (red_diff < 0 || green_diff < 0 || blue_diff < 0 || alpha_diff < 0)
+         above = 0;
+       else
+         above = 1;
+     
+       diff = abs (red_diff) + abs (green_diff) + abs (blue_diff) +
+         abs (alpha_diff);
+       
+       if (above > best_above || (above == best_above && diff < best_diff)) {
+         best_diff = diff;
+         best_above = above;
+         best_format = format;
+       }
+     }
+   } while (format);
+ 
+   return best_format;
+ }
+ 
  static void
  _glitz_format_add_options (unsigned long options,
***************
*** 161,168 ****
    }
  
    if (options & GLITZ_FORMAT_OPTION_READONLY_MASK) {
!     format->draw.offscreen = format->draw.onscreen = 0;
!     *mask |= GLITZ_FORMAT_DRAW_ONSCREEN_MASK;
      *mask |= GLITZ_FORMAT_DRAW_OFFSCREEN_MASK;
    }
  }
--- 303,318 ----
    }
  
+   if (options & GLITZ_FORMAT_OPTION_READDRAW_MASK) {
+     if (*mask & GLITZ_FORMAT_READ_OFFSCREEN_MASK) {
+       format->draw.offscreen = 1;
+       *mask |= GLITZ_FORMAT_DRAW_OFFSCREEN_MASK;
+     }
+   }
+   
    if (options & GLITZ_FORMAT_OPTION_READONLY_MASK) {
!     format->draw.offscreen = 0;
!     format->draw.onscreen = 0;
      *mask |= GLITZ_FORMAT_DRAW_OFFSCREEN_MASK;
+     *mask |= GLITZ_FORMAT_DRAW_ONSCREEN_MASK;
    }
  }
***************
*** 208,233 ****
    _glitz_format_add_options (options, &templ, &mask);
  
!   return glitz_format_find (formats, n_formats, mask, &templ, 0);
  }
  
! void
! glitz_format_calculate_pixel_transfer_info (glitz_format_t *format)
  {
!   long int mask = 0x000000ff;
!   format->bpp = 0;
! 
!   if (format->red_size || format->green_size || format->blue_size) {
!     format->blue_mask = mask;
!     format->green_mask = mask << 8;
!     format->red_mask = mask << 16;
!     format->bpp += 24;
!     mask = 0xff000000;
!   } else
!     format->blue_mask = format->green_mask = format->red_mask = 0x0;
    
!   if (format->alpha_size) {
!     format->alpha_mask = mask;
!     format->bpp += 8;
    } else
!     format->alpha_mask = 0x0;
  }
--- 358,401 ----
    _glitz_format_add_options (options, &templ, &mask);
  
!   return glitz_format_find_best (formats, n_formats, mask, &templ);
  }
  
! glitz_gl_int_t
! glitz_format_get_best_texture_format (glitz_format_t *formats,
! 				      int n_formats,
! 				      glitz_format_t *format)
  {
!   glitz_format_t templ;
!   unsigned long mask;
!   glitz_format_t *best_format, *texture_format;
!   int n_texture_formats =
!     sizeof (_texture_formats) / sizeof (glitz_format_t);
    
!   if ((!format->read.offscreen) ||
!       format->draw.offscreen || format->draw.onscreen) {
!     templ = *format;
!     templ.draw.offscreen = templ.draw.onscreen = 0;
!     templ.read.offscreen = 1;
!   
!     mask = GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK | 
!       GLITZ_FORMAT_BLUE_SIZE_MASK | GLITZ_FORMAT_ALPHA_SIZE_MASK |
!       GLITZ_FORMAT_READ_OFFSCREEN_MASK | GLITZ_FORMAT_DRAW_ONSCREEN_MASK |
!       GLITZ_FORMAT_DRAW_OFFSCREEN_MASK;
!   
!     best_format = glitz_format_find_best (formats, n_formats, mask, format);
!     if (!best_format)
!       return GLITZ_GL_RGBA;
    } else
!     best_format = format;
! 
!   mask = GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK | 
!     GLITZ_FORMAT_BLUE_SIZE_MASK | GLITZ_FORMAT_ALPHA_SIZE_MASK;
!   
!   texture_format = 
!     glitz_format_find (_texture_formats, n_texture_formats,
! 		       mask, best_format, 0);
!   if (!texture_format)
!     return GLITZ_GL_RGBA;
! 
!   return (glitz_gl_int_t) texture_format->id;
  }

Index: glitz_gl.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_gl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glitz_gl.h	11 Jun 2004 14:35:41 -0000	1.3
--- glitz_gl.h	21 Jun 2004 21:26:56 -0000	1.4
***************
*** 46,51 ****
  #define GLITZ_GL_TRUE  0x1
  
! #define GLITZ_GL_UNSIGNED_BYTE            0x1401
! #define GLITZ_GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
  
  #define GLITZ_GL_MODELVIEW  0x1700
--- 46,61 ----
  #define GLITZ_GL_TRUE  0x1
  
! #define GLITZ_GL_UNSIGNED_BYTE               0x1401
! #define GLITZ_GL_UNSIGNED_BYTE_3_3_2         0x8032
! #define GLITZ_GL_UNSIGNED_BYTE_2_3_3_REV     0x8362
! #define GLITZ_GL_UNSIGNED_SHORT_5_6_5        0x8363
! #define GLITZ_GL_UNSIGNED_SHORT_5_6_5_REV    0x8364
! #define GLITZ_GL_UNSIGNED_SHORT_4_4_4_4      0x8033
! #define GLITZ_GL_UNSIGNED_SHORT_4_4_4_4_REV  0x8365
! #define GLITZ_GL_UNSIGNED_SHORT_5_5_5_1      0x8034
! #define GLITZ_GL_UNSIGNED_SHORT_1_5_5_5_REV  0x8366
! #define GLITZ_GL_UNSIGNED_INT_8_8_8_8_REV    0x8367
! #define GLITZ_GL_UNSIGNED_INT_10_10_10_2     0x8036
! #define GLITZ_GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
  
  #define GLITZ_GL_MODELVIEW  0x1700
***************
*** 65,81 ****
  #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_TEXTURE_WRAP_S     0x2802
! #define GLITZ_GL_TEXTURE_WRAP_T     0x2803
! #define GLITZ_GL_TEXTURE_MAG_FILTER 0x2800
! #define GLITZ_GL_TEXTURE_MIN_FILTER 0x2801
! #define GLITZ_GL_MODULATE           0x2100
! #define GLITZ_GL_NEAREST            0x2600
! #define GLITZ_GL_LINEAR             0x2601
! #define GLITZ_GL_REPEAT             0x2901
! #define GLITZ_GL_CLAMP_TO_EDGE      0x812F
  
  #define GLITZ_GL_STENCIL_TEST 0x0B90
--- 75,97 ----
  #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
! #define GLITZ_GL_TEXTURE_WRAP_S         0x2802
! #define GLITZ_GL_TEXTURE_WRAP_T         0x2803
! #define GLITZ_GL_TEXTURE_MAG_FILTER     0x2800
! #define GLITZ_GL_TEXTURE_MIN_FILTER     0x2801
! #define GLITZ_GL_MODULATE               0x2100
! #define GLITZ_GL_NEAREST                0x2600
! #define GLITZ_GL_LINEAR                 0x2601
! #define GLITZ_GL_REPEAT                 0x2901
! #define GLITZ_GL_CLAMP_TO_EDGE          0x812F
! #define GLITZ_GL_TEXTURE_RED_SIZE       0x805C
! #define GLITZ_GL_TEXTURE_GREEN_SIZE     0x805D
! #define GLITZ_GL_TEXTURE_BLUE_SIZE      0x805E
! #define GLITZ_GL_TEXTURE_ALPHA_SIZE     0x805F
! #define GLITZ_GL_TEXTURE_INTENSITY_SIZE	0x8061
  
  #define GLITZ_GL_STENCIL_TEST 0x0B90
***************
*** 96,107 ****
  #define GLITZ_GL_COLOR_BUFFER_BIT   0x00004000
  
! #define GLITZ_GL_ALPHA           0x1906
! #define GLITZ_GL_RGB             0x1907
! #define GLITZ_GL_LUMINANCE_ALPHA 0x190A
! #define GLITZ_GL_COLOR           0x1800
! #define GLITZ_GL_DITHER          0x0BD0
! #define GLITZ_GL_RGBA            0x1908
! #define GLITZ_GL_BGR             0x80E0
! #define GLITZ_GL_BGRA            0x80E1
  
  #define GLITZ_GL_FRONT_AND_BACK 0x0408
--- 112,143 ----
  #define GLITZ_GL_COLOR_BUFFER_BIT   0x00004000
  
! #define GLITZ_GL_ALPHA     0x1906
! #define GLITZ_GL_RGB       0x1907
! #define GLITZ_GL_LUMINANCE 0x1909
! #define GLITZ_GL_COLOR     0x1800
! #define GLITZ_GL_DITHER    0x0BD0
! #define GLITZ_GL_RGBA      0x1908
! #define GLITZ_GL_BGR       0x80E0
! #define GLITZ_GL_BGRA      0x80E1
! 
! #define GLITZ_GL_INTENSITY   0x8049
! #define GLITZ_GL_INTENSITY4  0x804A
! #define GLITZ_GL_INTENSITY8  0x804B
! #define GLITZ_GL_INTENSITY12 0x804C
! #define GLITZ_GL_INTENSITY16 0x804D
! #define GLITZ_GL_R3_G3_B2    0x2A10
! #define GLITZ_GL_RGB4        0x804F
! #define GLITZ_GL_RGB5        0x8050
! #define GLITZ_GL_RGB8        0x8051
! #define GLITZ_GL_RGB10       0x8052
! #define GLITZ_GL_RGB12       0x8053
! #define GLITZ_GL_RGB16       0x8054
! #define GLITZ_GL_RGBA2       0x8055
! #define GLITZ_GL_RGBA4       0x8056
! #define GLITZ_GL_RGB5_A1     0x8057
! #define GLITZ_GL_RGBA8       0x8058
! #define GLITZ_GL_RGB10_A2    0x8059
! #define GLITZ_GL_RGBA12      0x805A
! #define GLITZ_GL_RGBA16      0x805B
  
  #define GLITZ_GL_FRONT_AND_BACK 0x0408
***************
*** 118,129 ****
  #define GLITZ_GL_SRC_ALPHA_SATURATE  0x0308
  
! #define GLITZ_GL_PACK_ALIGNMENT     0x0D05
! #define GLITZ_GL_PACK_ROW_LENGTH    0x0D02
! #define GLITZ_GL_PACK_SKIP_PIXELS   0x0D04
! #define GLITZ_GL_PACK_SKIP_ROWS     0x0D03
! #define GLITZ_GL_UNPACK_ALIGNMENT   0x0CF5
! #define GLITZ_GL_UNPACK_ROW_LENGTH  0x0CF2
! #define GLITZ_GL_UNPACK_SKIP_PIXELS 0x0CF4
! #define GLITZ_GL_UNPACK_SKIP_ROWS   0x0CF3
  
  #define GLITZ_GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
--- 154,165 ----
  #define GLITZ_GL_SRC_ALPHA_SATURATE  0x0308
  
! #define GLITZ_GL_PACK_ALIGNMENT      0x0D05
! #define GLITZ_GL_PACK_ROW_LENGTH     0x0D02
! #define GLITZ_GL_PACK_SKIP_PIXELS    0x0D04
! #define GLITZ_GL_PACK_SKIP_ROWS      0x0D03
! #define GLITZ_GL_UNPACK_ALIGNMENT    0x0CF5
! #define GLITZ_GL_UNPACK_ROW_LENGTH   0x0CF2
! #define GLITZ_GL_UNPACK_SKIP_PIXELS  0x0CF4
! #define GLITZ_GL_UNPACK_SKIP_ROWS    0x0CF3
  
  #define GLITZ_GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
***************
*** 255,264 ****
        glitz_gl_enum_t format, glitz_gl_enum_t type,
        glitz_gl_void_t *pixels);
- typedef glitz_gl_void_t (* glitz_gl_pixel_zoom_t)
-      (glitz_gl_float_t xfactor, glitz_gl_float_t yfactor);
- typedef glitz_gl_void_t (* glitz_gl_draw_pixels_t)
-      (glitz_gl_sizei_t width, glitz_gl_sizei_t height,
-       glitz_gl_enum_t format, glitz_gl_enum_t type,
-       const glitz_gl_void_t *pixels);
  typedef glitz_gl_void_t (* glitz_gl_tex_sub_image_2d_t)
       (glitz_gl_enum_t target, glitz_gl_int_t level,
--- 291,294 ----
***************
*** 287,290 ****
--- 317,323 ----
  typedef glitz_gl_void_t (* glitz_gl_tex_parameter_i_t)
       (glitz_gl_enum_t target, glitz_gl_enum_t pname, glitz_gl_int_t param);
+ typedef glitz_gl_void_t (* glitz_gl_get_tex_level_parameter_iv_t)
+      (glitz_gl_enum_t target, glitz_gl_int_t level,
+       glitz_gl_enum_t pname, glitz_gl_int_t *param);
  typedef glitz_gl_void_t (* glitz_gl_copy_tex_sub_image_2d_t)
       (glitz_gl_enum_t target, glitz_gl_int_t level,

Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_context.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glitz_glx_context.c	28 May 2004 01:04:29 -0000	1.7
--- glitz_glx_context.c	21 Jun 2004 21:26:56 -0000	1.8
***************
*** 257,262 ****
        glEnable (GLITZ_GL_MULTISAMPLE_ARB);
        if (surface->screen_info->glx_feature_mask &
!           GLITZ_GLX_FEATURE_MULTISAMPLE_FILTER_MASK)
!         glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV, GLITZ_GL_NICEST);
      } else
        glDisable (GLITZ_GL_MULTISAMPLE_ARB);
--- 257,267 ----
        glEnable (GLITZ_GL_MULTISAMPLE_ARB);
        if (surface->screen_info->glx_feature_mask &
!           GLITZ_GLX_FEATURE_MULTISAMPLE_FILTER_MASK) {
!         if (surface->base.polyedge_smooth_hint ==
!             GLITZ_POLYEDGE_SMOOTH_HINT_FAST)
!           glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV, GLITZ_GL_FASTEST);
!         else
!           glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV, GLITZ_GL_NICEST);
!       }
      } else
        glDisable (GLITZ_GL_MULTISAMPLE_ARB);

Index: glitz_glx_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_format.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glitz_glx_format.c	24 May 2004 07:16:42 -0000	1.6
--- glitz_glx_format.c	21 Jun 2004 21:26:56 -0000	1.7
***************
*** 74,79 ****
                     glitz_format_t *format)
  {
-   glitz_format_calculate_pixel_transfer_info (format);
-   
    if (!glitz_format_find (screen_info->formats, screen_info->n_formats,
                            GLITZ_FORMAT_ALL_EXCEPT_ID_MASK, format, 0)) {
--- 74,77 ----
***************
*** 119,123 ****
  
    /* Offscreen drawing never supported if GLX is older than 1.3 */
!   format.draw.offscreen = 0;
    format.draw.onscreen = format.read.onscreen = 1;
  
--- 117,121 ----
  
    /* 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;
  
***************
*** 164,184 ****
      }
  
!     _glitz_add_format (screen_info, &format);
! 
!     if (format.alpha_size &&
!         (format.red_size || format.green_size || format.blue_size)) {
!       unsigned short tmp;
!       
!       tmp = format.alpha_size;
!       format.alpha_size = 0;
!       _glitz_add_format (screen_info, &format);
!       format.alpha_size = tmp;
!       format.red_size = format.green_size = format.blue_size = 0;
        _glitz_add_format (screen_info, &format);
-     }
    }
- 
-   qsort (screen_info->formats, screen_info->n_formats,
-          sizeof (glitz_format_t), _glitz_glx_format_compare);
    
    if (visuals)
--- 162,169 ----
      }
  
!     if (format.red_size || format.green_size || format.blue_size ||
!         format.alpha_size)
        _glitz_add_format (screen_info, &format);
    }
    
    if (visuals)
***************
*** 192,196 ****
    glitz_format_t format;
    GLXFBConfig *fbconfigs;
!   int i, num_configs;
    glitz_glx_static_proc_address_list_t *glx =
      &screen_info->display_info->thread_info->glx;
--- 177,181 ----
    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;
***************
*** 227,234 ****
        (value & GLX_WINDOW_BIT)? 1: 0;
      format.read.offscreen = format.draw.offscreen =
!       (value & GLX_PBUFFER_BIT)? 1: 0;
      
      glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value);
      format.id = (XID) value;
      
      glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_RED_SIZE, &value);
--- 212,227 ----
        (value & GLX_WINDOW_BIT)? 1: 0;
      format.read.offscreen = format.draw.offscreen =
!       (pbuffer_support && (value & GLX_PBUFFER_BIT))? 1: 0;
      
      glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value);
      format.id = (XID) value;
+ 
+     if (pbuffer_check && format.draw.offscreen) {
+       if (glitz_glx_ensure_pbuffer_support (screen_info, format.id)) {
+ 	pbuffer_support = 0;
+ 	format.draw.offscreen = 0;
+       }
+       pbuffer_check = 0;
+     }
      
      glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_RED_SIZE, &value);
***************
*** 259,279 ****
      }
  
!     _glitz_add_format (screen_info, &format);
! 
!     if (format.alpha_size &&
!         (format.red_size || format.green_size || format.blue_size)) {
!       unsigned short tmp;
!       
!       tmp = format.alpha_size;
!       format.alpha_size = 0;
!       _glitz_add_format (screen_info, &format);
!       format.alpha_size = tmp;
!       format.red_size = format.green_size = format.blue_size = 0;
        _glitz_add_format (screen_info, &format);
-     }    
    }
- 
-   qsort (screen_info->formats, screen_info->n_formats,
-          sizeof (glitz_format_t), _glitz_glx_format_compare);
    
    if (fbconfigs)
--- 252,259 ----
      }
  
!     if (format.red_size || format.green_size || format.blue_size ||
!         format.alpha_size)
        _glitz_add_format (screen_info, &format);
    }
    
    if (fbconfigs)
***************
*** 284,296 ****
  
  static void
! glitz_glx_remove_offscreen_drawing (glitz_glx_screen_info_t *screen_info)
  {
!   glitz_format_t *formats = screen_info->formats;
!   int n_formats = screen_info->n_formats;
!   
!   screen_info->feature_mask &= ~GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK;
  
!   for (; n_formats; n_formats--, formats++)
!     formats->draw.offscreen = 0;
  }
  
--- 264,276 ----
  
  static void
! _glitz_glx_add_texture_format (glitz_format_t *texture_format, void *ptr)
  {
!   glitz_glx_screen_info_t *screen_info = (glitz_glx_screen_info_t *) ptr;
!   glitz_format_t format;
  
!   format = *texture_format;
!   format.id = 0;
! 
!   _glitz_add_format (screen_info, &format);
  }
  
***************
*** 299,304 ****
  {
    glitz_bool_t status = 1;
-   glitz_format_t *formats;
-   glitz_format_t format;
  
    if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_GLX13_MASK)
--- 279,282 ----
***************
*** 307,332 ****
    if (status)
      glitz_glx_query_formats_glx12 (screen_info);
-   
-   formats = glitz_format_find_standard (screen_info->formats,
-                                         screen_info->n_formats,
-                                         GLITZ_FORMAT_OPTION_OFFSCREEN_MASK,
-                                         GLITZ_STANDARD_ARGB32);
  
!   if (formats == NULL ||
!       glitz_glx_ensure_pbuffer_support (screen_info, formats->id))
!     glitz_glx_remove_offscreen_drawing (screen_info);
! 
!   /* Adding read only offscreen formats. Surfaces created with these format
!      can only be used with draw/read pixel functions and as source. */
!   memset (&format, 0, sizeof (glitz_format_t));
!   format.read.offscreen = 1;
!   format.alpha_size = format.red_size = format.green_size =
!     format.blue_size = 8;
!   _glitz_add_format (screen_info, &format);
!   format.alpha_size = 0;
!   _glitz_add_format (screen_info, &format);
!   format.alpha_size = 8;
!   format.red_size = format.green_size = format.blue_size = 0;
!   _glitz_add_format (screen_info, &format);
    
    _glitz_move_out_ids (screen_info);
--- 285,295 ----
    if (status)
      glitz_glx_query_formats_glx12 (screen_info);
  
!   qsort (screen_info->formats, screen_info->n_formats, 
!          sizeof (glitz_format_t), _glitz_glx_format_compare);
!  
!   glitz_format_for_each_texture_format (&_glitz_glx_add_texture_format,
! 					&screen_info->root_context.gl,
! 					(void *) screen_info);
    
    _glitz_move_out_ids (screen_info);
***************
*** 356,360 ****
    glitz_glx_screen_info_t *screen_info =
      glitz_glx_screen_info_get (display, screen);
!   
    return
      glitz_format_find_standard (screen_info->formats, screen_info->n_formats,
--- 319,323 ----
    glitz_glx_screen_info_t *screen_info =
      glitz_glx_screen_info_get (display, screen);
! 
    return
      glitz_format_find_standard (screen_info->formats, screen_info->n_formats,

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_info.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glitz_glx_info.c	11 Jun 2004 14:35:41 -0000	1.9
--- glitz_glx_info.c	21 Jun 2004 21:26:56 -0000	1.10
***************
*** 77,82 ****
    (glitz_gl_read_pixels_t) glReadPixels,
    (glitz_gl_get_tex_image_t) glGetTexImage,
-   (glitz_gl_pixel_zoom_t) glPixelZoom,
-   (glitz_gl_draw_pixels_t) glDrawPixels,
    (glitz_gl_tex_sub_image_2d_t) glTexSubImage2D,
    (glitz_gl_gen_textures_t) glGenTextures,
--- 77,80 ----
***************
*** 86,89 ****
--- 84,88 ----
    (glitz_gl_tex_image_2d_t) glTexImage2D,
    (glitz_gl_tex_parameter_i_t) glTexParameteri,
+   (glitz_gl_get_tex_level_parameter_iv_t) glGetTexLevelParameteriv,
    (glitz_gl_copy_tex_sub_image_2d_t) glCopyTexSubImage2D,
    (glitz_gl_get_integer_v_t) glGetIntegerv,
***************
*** 416,423 ****
                        screen_info->root_drawable,
                        screen_info->root_context.context)) {
-     
-     glPixelStorei (GL_PACK_ALIGNMENT, 4);
-     glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
- 
      glitz_glx_context_proc_address_lookup (screen_info,
                                             &screen_info->root_context);
--- 415,418 ----

Index: glitz_glx_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_surface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** glitz_glx_surface.c	30 May 2004 15:59:54 -0000	1.12
--- glitz_glx_surface.c	21 Jun 2004 21:26:56 -0000	1.13
***************
*** 386,391 ****
        glitz_texture_init (&texture,
                            width, height,
!                           glitz_get_gl_format_from_bpp
!                           (surface->base.format->bpp),
                            surface->screen_info->texture_mask);
        
--- 386,390 ----
        glitz_texture_init (&texture,
                            width, height,
!                           surface->base.texture.format,
                            surface->screen_info->texture_mask);
        

Index: glitz_operator.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_operator.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glitz_operator.c	11 Jun 2004 14:35:41 -0000	1.2
--- glitz_operator.c	21 Jun 2004 21:26:56 -0000	1.3
***************
*** 108,112 ****
    case GLITZ_STENCIL_OPERATOR_SET:
    case GLITZ_STENCIL_OPERATOR_UNION:
!     gl->stencil_func (GLITZ_GL_ALWAYS, ~0x0, ~0x0);
      gl->stencil_op (GLITZ_GL_REPLACE, GLITZ_GL_REPLACE, GLITZ_GL_REPLACE);
      break;
--- 108,112 ----
    case GLITZ_STENCIL_OPERATOR_SET:
    case GLITZ_STENCIL_OPERATOR_UNION:
!     gl->stencil_func (GLITZ_GL_ALWAYS, mask, ~0x0);
      gl->stencil_op (GLITZ_GL_REPLACE, GLITZ_GL_REPLACE, GLITZ_GL_REPLACE);
      break;

--- NEW FILE: glitz_pixel.c ---
(This appears to be a binary file; contents omitted.)

Index: glitz_programmatic.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_programmatic.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glitz_programmatic.c	11 Jun 2004 14:35:41 -0000	1.8
--- glitz_programmatic.c	21 Jun 2004 21:26:56 -0000	1.9
***************
*** 141,145 ****
      surface->base.texture.texcoord_height = 1.0;
    surface->base.texture.repeatable = surface->base.texture.repeat = 1;
!   surface->transform = identity;
    
    return surface;
--- 141,145 ----
      surface->base.texture.texcoord_height = 1.0;
    surface->base.texture.repeatable = surface->base.texture.repeat = 1;
!   surface->matrix = identity;
    
    return surface;
***************
*** 224,234 ****
      (glitz_programmatic_surface_t *) abstract_surface;
    
!   surface->transform.m[0][0] = FIXED_TO_DOUBLE (transform->matrix[0][0]);
!   surface->transform.m[1][0] = FIXED_TO_DOUBLE (transform->matrix[0][1]);
!   surface->transform.m[2][0] = FIXED_TO_DOUBLE (transform->matrix[0][2]);
    
!   surface->transform.m[0][1] = FIXED_TO_DOUBLE (transform->matrix[1][0]);
!   surface->transform.m[1][1] = FIXED_TO_DOUBLE (transform->matrix[1][1]);
!   surface->transform.m[2][1] = FIXED_TO_DOUBLE (transform->matrix[1][2]);
  }
  
--- 224,234 ----
      (glitz_programmatic_surface_t *) abstract_surface;
    
!   surface->matrix.m[0][0] = FIXED_TO_DOUBLE (transform->matrix[0][0]);
!   surface->matrix.m[1][0] = FIXED_TO_DOUBLE (transform->matrix[0][1]);
!   surface->matrix.m[2][0] = FIXED_TO_DOUBLE (transform->matrix[0][2]);
    
!   surface->matrix.m[0][1] = FIXED_TO_DOUBLE (transform->matrix[1][0]);
!   surface->matrix.m[1][1] = FIXED_TO_DOUBLE (transform->matrix[1][1]);
!   surface->matrix.m[2][1] = FIXED_TO_DOUBLE (transform->matrix[1][2]);
  }
  
***************
*** 275,285 ****
                                      -sin (angle));
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
!                                     surface->transform.m[0][0],
!                                     surface->transform.m[0][1],
!                                     surface->transform.m[1][0],
!                                     surface->transform.m[1][1]);
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 2,
!                                     surface->transform.m[2][0],
!                                     surface->transform.m[2][1],
                                      surface->base.height, 0.0);
  
--- 275,285 ----
                                      -sin (angle));
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
!                                     surface->matrix.m[0][0],
!                                     surface->matrix.m[0][1],
!                                     surface->matrix.m[1][0],
!                                     surface->matrix.m[1][1]);
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 2,
!                                     surface->matrix.m[2][0],
!                                     surface->matrix.m[2][1],
                                      surface->base.height, 0.0);
  
***************
*** 297,307 ****
         FIXED_TO_DOUBLE (surface->u.radial.radius0));
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
!                                     surface->transform.m[0][0],
!                                     surface->transform.m[0][1],
!                                     surface->transform.m[1][0],
!                                     surface->transform.m[1][1]);
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 2,
!                                     surface->transform.m[2][0],
!                                     surface->transform.m[2][1],
                                      surface->base.height, 0.0);
  
--- 297,307 ----
         FIXED_TO_DOUBLE (surface->u.radial.radius0));
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
!                                     surface->matrix.m[0][0],
!                                     surface->matrix.m[0][1],
!                                     surface->matrix.m[1][0],
!                                     surface->matrix.m[1][1]);
      gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 2,
!                                     surface->matrix.m[2][0],
!                                     surface->matrix.m[2][1],
                                      surface->base.height, 0.0);
  

Index: glitz_render.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_render.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glitz_render.c	11 Jun 2004 14:35:41 -0000	1.1
--- glitz_render.c	21 Jun 2004 21:26:56 -0000	1.2
***************
*** 56,60 ****
    if ((!src_conv) &&
        mask && (!SURFACE_PROGRAMMATIC (mask)) && (!mask_conv)) {
!     if ((mask->texture.internal_format == GLITZ_GL_LUMINANCE_ALPHA) &&
          (dst->feature_mask & GLITZ_FEATURE_ARB_MULTITEXTURE_MASK)) {
        if (SURFACE_SOLID (src))
--- 56,63 ----
    if ((!src_conv) &&
        mask && (!SURFACE_PROGRAMMATIC (mask)) && (!mask_conv)) {
!     if ((mask->texture.format == GLITZ_GL_INTENSITY4 ||
!          mask->texture.format == GLITZ_GL_INTENSITY8 ||
!          mask->texture.format == GLITZ_GL_INTENSITY12 ||
!          mask->texture.format == GLITZ_GL_INTENSITY16) &&
          (dst->feature_mask & GLITZ_FEATURE_ARB_MULTITEXTURE_MASK)) {
        if (SURFACE_SOLID (src))
***************
*** 105,112 ****
                            GLITZ_GL_MODULATE);
        dst->gl->color_4us (opacity, opacity, opacity, opacity);
!     } else
        dst->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV,
                            GLITZ_GL_TEXTURE_ENV_MODE,
                            GLITZ_GL_REPLACE);
      break;
    case GLITZ_RENDER_TYPE_ARGB_ARGB:
--- 108,117 ----
                            GLITZ_GL_MODULATE);
        dst->gl->color_4us (opacity, opacity, opacity, opacity);
!     } else {
        dst->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV,
                            GLITZ_GL_TEXTURE_ENV_MODE,
                            GLITZ_GL_REPLACE);
+       dst->gl->color_4us (0x0, 0x0, 0x0, 0xffff);
+     }
      break;
    case GLITZ_RENDER_TYPE_ARGB_ARGB:

Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz_surface.c	11 Jun 2004 14:35:41 -0000	1.13
--- glitz_surface.c	21 Jun 2004 21:26:56 -0000	1.14
***************
*** 51,54 ****
--- 51,55 ----
    surface->filter = GLITZ_FILTER_NEAREST;
    surface->polyedge = GLITZ_POLYEDGE_SMOOTH;
+   surface->polyedge_smooth_hint = GLITZ_POLYEDGE_SMOOTH_HINT_GOOD;
    surface->polyopacity = 0xffff;
  
***************
*** 69,73 ****
      glitz_texture_init (&surface->texture,
                          width, height,
!                         glitz_get_gl_format_from_bpp (format->bpp),
                          texture_mask);
    }
--- 70,74 ----
      glitz_texture_init (&surface->texture,
                          width, height,
!                         glitz_surface_texture_format (surface),
                          texture_mask);
    }
***************
*** 90,93 ****
--- 91,103 ----
  }
  
+ glitz_gl_int_t
+ glitz_surface_texture_format (glitz_surface_t *surface)
+ {
+   return
+     glitz_format_get_best_texture_format (surface->formats,
+ 					  surface->n_formats,
+ 					  surface->format);
+ }
+ 
  glitz_format_t *
  glitz_surface_find_similar_standard_format (glitz_surface_t *surface,
***************
*** 117,124 ****
                                int height)
  {
    if (width < 1 || height < 1)
      return NULL;
    
!   return templ->backend->create_similar (templ, format, width, height);
  }
  
--- 127,144 ----
                                int height)
  {
+   glitz_surface_t *surface;
+   
    if (width < 1 || height < 1)
      return NULL;
    
!   surface = templ->backend->create_similar (templ, format, width, height);
!   if (surface) {
!     surface->filter = templ->filter;
!     surface->polyedge = templ->polyedge;
!     surface->polyedge_smooth_hint = templ->polyedge_smooth_hint;
!     surface->polyopacity = templ->polyopacity;
!   }
!   
!   return surface;
  }
  
***************
*** 250,253 ****
--- 270,274 ----
      if (transform == NULL)
        transform = &identity;
+     
      glitz_programmatic_surface_set_transform (surface, transform);
      return;
***************
*** 538,543 ****
    glitz_gl_proc_address_list_t *gl = surface->gl;
    
-   gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 4);
-   gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 4);
    gl->viewport (0, 0, surface->width, surface->height);
    gl->matrix_mode (GLITZ_GL_PROJECTION);
--- 559,562 ----
***************
*** 569,577 ****
  }
  
! /* This is supposed to be a 4x rotated grid multi-sample pattern. I'm not
!    sure it's actually correct. */
  static glitz_sample_offset_t _4x_multi_sample_offsets[] = {
    { -0.125, -0.375 },
!   {  0.375, -0.124 },
    {  0.125,  0.375 },
    { -0.375,  0.125 }
--- 588,617 ----
  }
  
! /* This is supposed to be 8x, 4x and 2x rotated grid multi-sample
!    patterns. I'm not sure they're actually correct. */
! static glitz_sample_offset_t _8x_multi_sample_offsets[] = {
!   { -0.375, -0.375 },
!   { -0.125, -0.125 },
!   {  0.375, -0.375 },
!   {  0.125, -0.125 },
!   {  0.375,  0.375 },
!   {  0.125,  0.125 },
!   { -0.375,  0.375 },
!   { -0.125,  0.125 }
! };
! 
! static unsigned short _8x_multi_sample_weights[] = {
!   0x2000, 0x4000, 0x6000, 0x8000, 0xa000, 0xbfff, 0xdfff, 0xffff
! };
! 
! static glitz_multi_sample_info_t _8x_multi_sample = {
!   _8x_multi_sample_offsets,
!   _8x_multi_sample_weights,
!   8
! };
! 
  static glitz_sample_offset_t _4x_multi_sample_offsets[] = {
    { -0.125, -0.375 },
!   {  0.375, -0.125 },
    {  0.125,  0.375 },
    { -0.375,  0.125 }
***************
*** 588,591 ****
--- 628,646 ----
  };
  
+ static glitz_sample_offset_t _2x_multi_sample_offsets[] = {
+   { -0.24, -0.24 },
+   {  0.24,  0.24 }
+ };
+ 
+ static unsigned short _2x_multi_sample_weights[] = {
+   0x8000, 0xffff
+ };
+ 
+ static glitz_multi_sample_info_t _2x_multi_sample = {
+   _2x_multi_sample_offsets,
+   _2x_multi_sample_weights,
+   2
+ };
+ 
  void
  glitz_surface_enable_anti_aliasing (glitz_surface_t *surface)
***************
*** 595,600 ****
  
    if (surface->polyedge == GLITZ_POLYEDGE_SMOOTH &&
!       surface->format->stencil_size >= 4)
!     surface->multi_sample = &_4x_multi_sample;
  }
  
--- 650,669 ----
  
    if (surface->polyedge == GLITZ_POLYEDGE_SMOOTH &&
!       surface->format->stencil_size >= 4) {
!     switch (surface->polyedge_smooth_hint) {
!     case GLITZ_POLYEDGE_SMOOTH_HINT_BEST:
!       if (surface->format->stencil_size >= 8) {
!         surface->multi_sample = &_8x_multi_sample;
!         break;
!       }
!       /* fall-through */
!     case GLITZ_POLYEDGE_SMOOTH_HINT_GOOD:
!       surface->multi_sample = &_4x_multi_sample;
!       break;
!     case GLITZ_POLYEDGE_SMOOTH_HINT_FAST:
!       surface->multi_sample = &_2x_multi_sample;
!       break;
!     }
!   }
  }
  
***************
*** 606,835 ****
  
  void
! glitz_surface_read_pixels (glitz_surface_t *surface,
!                            int x,
!                            int y,
!                            unsigned int width,
!                            unsigned int height,
!                            char *pixels)
! {
!   unsigned char *pixel_buf = NULL;
!   int rowstride, area_rowstride, bytes_per_pixel;
!   glitz_gl_enum_t format, type;
! 
!   if (SURFACE_PROGRAMMATIC (surface))
!     return;
! 
!   if (x < 0 || x > (int) surface->width - (int) width ||
!       y < 0 || y > (int) surface->height - (int) height) {
!     glitz_surface_status_add (surface, GLITZ_STATUS_BAD_COORDINATE_MASK);
!     return;
!   }
! 
!   bytes_per_pixel = (surface->format->bpp / 8);
!   format = glitz_get_gl_format_from_bpp (surface->format->bpp);
!   type = glitz_get_gl_data_type_from_bpp (surface->format->bpp);
! 
!   /* We currently read the whole image to a temporary buffer and then
!      copy the part we want, not very efficient. We only want to read the
!      area requested. I think it can be fixed with glPixelStore parameters. */
!   if (glitz_surface_try_push_current (surface,
!                                       GLITZ_CN_SURFACE_DRAWABLE_CURRENT)) {
! 
!     if (format == GLITZ_GL_LUMINANCE_ALPHA)
!       rowstride = surface->width * 2;
!     else
!       rowstride = surface->width * bytes_per_pixel;
!     
!     rowstride = (rowstride + 3) & -4;
!     pixel_buf = malloc (surface->height * rowstride);
!     if (!pixel_buf) {
!       glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
!       glitz_surface_pop_current (surface);
!       return;
!     }
!     if (surface->format->doublebuffer)
!       surface->gl->read_buffer (surface->read_buffer);
!     
!     surface->gl->read_pixels (0, 0, surface->width, surface->height,
!                               format, type, pixel_buf);
!   } else {
!     glitz_texture_t *texture;
! 
!     texture = glitz_surface_get_texture (surface);
! 
!     /* Texture has not been allocated, hence pixel data of this surface
!        is undefined. */
!     if (!texture)
!       return;
!     
!     glitz_texture_bind (surface->gl, texture);
! 
!     if (format == GLITZ_GL_LUMINANCE_ALPHA) {
!       rowstride = texture->width * 2;
!     } else
!       rowstride = texture->width * bytes_per_pixel;
! 
!     rowstride = (rowstride + 3) & -4;
!     pixel_buf = malloc (texture->height * rowstride);
!     if (!pixel_buf) {
!       glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
!       glitz_surface_pop_current (surface);
!       return;
!     }
! 
!     surface->gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
!     surface->gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_ROWS, 0);
!     surface->gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_PIXELS, 0);
!     
!     surface->gl->get_tex_image (texture->target, 0,
!                                 format,
!                                 type,
!                                 pixel_buf);
! 
!     glitz_texture_unbind (surface->gl, texture);
!   }
! 
!   glitz_surface_pop_current (surface);
! 
!   area_rowstride = (width * bytes_per_pixel + 3) & -4;
! 
!   if (format == GLITZ_GL_LUMINANCE_ALPHA) {
!     int i, j, k;
!     
!     /* Unpad and flip A8 image data. */
!     for (i = 0; i < (int) height; i++) {
!       for (j = 0, k = 1; j < (int) width; j++, k += 2) {
!         pixels[(height - i - 1) * area_rowstride + j] =
!           pixel_buf[(surface->height - y - height + i) * rowstride + x + k];
!       }
!     }
!   } else {
!     int i;
!     
!     /* Flip image data. */
!     for (i = 0; i < (int) height; i++) {
!       memcpy (&pixels[(height - i - 1) * area_rowstride],
!               &pixel_buf[(surface->height - y - height + i) * rowstride + x],
!               area_rowstride);
!     }
!   }
! 
!   if (pixel_buf)
!     free (pixel_buf);
! }
! 
! void
! glitz_surface_draw_pixels (glitz_surface_t *surface,
!                            int x,
!                            int y,
!                            unsigned int width,
!                            unsigned int height,
!                            char *pixels)
  {
!   char *pixel_buf = NULL;
!   glitz_gl_enum_t format, type;
!   int bytes_per_pixel;
!   glitz_bool_t drawable = 0;
! 
!   if (SURFACE_PROGRAMMATIC (surface))
!     return;
! 
!   if (x < 0 || x > (surface->width - (int) width) ||
!       y < 0 || y > (surface->height - (int) height)) {
!     glitz_surface_status_add (surface, GLITZ_STATUS_BAD_COORDINATE_MASK);
!     return;
!   }
! 
!   bytes_per_pixel = (surface->format->bpp / 8);
!   format = glitz_get_gl_format_from_bpp (surface->format->bpp);
!   type = glitz_get_gl_data_type_from_bpp (surface->format->bpp);
! 
!   drawable =
!     glitz_surface_try_push_current (surface,
!                                     GLITZ_CN_SURFACE_DRAWABLE_CURRENT);
!   
!   if (format == GLITZ_GL_LUMINANCE_ALPHA) {
!     int i, j, k, src_rowstride, dst_rowstride;
! 
!     src_rowstride = (width + 3) & -4;
!     dst_rowstride = (width * 2 + 3) & -4;
!     pixel_buf = malloc (dst_rowstride * height);
!     if (!pixel_buf) {
!       glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
!       glitz_surface_pop_current (surface);
!       return;
!     }
! 
!     /* Pad and flip A8 image data. */
!     for (i = 0; i < (int) height; i++) {
!       for (j = 0, k = 0; j < (int) width; j++, k += 2) {
!         pixel_buf[i * dst_rowstride + k] =
!           pixel_buf[i * dst_rowstride + k + 1] =
!           pixels[(height - i - 1) * src_rowstride + j];
!       }
!     }
!     pixels = pixel_buf;
!   } else if (!drawable) {
!     int i, rowstride;
! 
!     rowstride = (width * bytes_per_pixel + 3) & -4;
!     pixel_buf = malloc (rowstride * height);
!     if (!pixel_buf) {
!       glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
!       glitz_surface_pop_current (surface);
!       return;
!     }
!     
!     /* Flip image data. */
!     for (i = 0; i < (int) height; i++)
!       memcpy (&pixel_buf[i * rowstride],
!               &pixels[(height - i - 1) * rowstride], rowstride);
! 
!     pixels = pixel_buf;
!   }
! 
!   if (drawable) {
!     glitz_bounding_box_t bounds;
! 
!     bounds.x1 = x;
!     bounds.x2 = x + width;
!     bounds.y1 = y;
!     bounds.y2 = y + height;
! 
!     surface->gl->disable (GLITZ_GL_SCISSOR_TEST);
!     surface->gl->disable (GLITZ_GL_DITHER);
!     glitz_set_operator (surface->gl, GLITZ_OPERATOR_SRC);
! 
!     if (format == GLITZ_GL_LUMINANCE_ALPHA) {
!       surface->gl->pixel_zoom (1.0, 1.0);
!       glitz_set_raster_pos (surface->gl, x, surface->height - y - height);
!     } else {
!       surface->gl->pixel_zoom (1.0, -1.0);
!       glitz_set_raster_pos (surface->gl, x, surface->height - y);
!     }
! 
!     surface->gl->draw_pixels (width, height, format, type, pixels);
! 
!     glitz_surface_dirty (surface, &bounds);
!   } else {
!     glitz_texture_bind (surface->gl, &surface->texture);
!     
!     surface->gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, 0);
!     surface->gl->pixel_store_i (GLITZ_GL_PACK_SKIP_ROWS, 0);
!     surface->gl->pixel_store_i (GLITZ_GL_PACK_SKIP_PIXELS, 0);
! 
!     surface->gl->tex_sub_image_2d (surface->texture.target, 0,
!                                    x, surface->height - y - height,
!                                    width, height,
!                                    format, type,
!                                    pixel_buf);
! 
!     glitz_texture_unbind (surface->gl, &surface->texture);
!   }
! 
!   glitz_surface_pop_current (surface);
! 
!   if (pixel_buf)
!     free (pixel_buf);
  }
  
--- 675,682 ----
  
  void
! glitz_surface_set_polyedge_smooth_hint (glitz_surface_t *surface,
!                                         glitz_polyedge_smooth_hint_t hint)
  {
!   surface->polyedge_smooth_hint = hint;
  }
  

Index: glitz_texture.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_texture.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glitz_texture.c	30 May 2004 15:59:54 -0000	1.7
--- glitz_texture.c	21 Jun 2004 21:26:56 -0000	1.8
***************
*** 63,75 ****
    texture->name = 0;
  
-   switch (texture->format) {
-   case GLITZ_GL_LUMINANCE_ALPHA:
-     texture->internal_format = GLITZ_GL_LUMINANCE_ALPHA;
-     break;
-   default:
-     texture->internal_format = GLITZ_GL_RGBA;
-     break;
-   }
- 
    if (!(target_mask & GLITZ_TEXTURE_TARGET_NPOT_MASK)) {
      _glitz_texture_find_best_target (width, height,
--- 63,66 ----
***************
*** 110,117 ****
    glitz_texture_bind (gl, texture);
  
!   gl->tex_image_2d (texture->target, 0,
!                     texture->internal_format,
                      texture->width, texture->height,
!                     0, texture->format, GLITZ_GL_UNSIGNED_BYTE, NULL);
  
    glitz_texture_unbind (gl, texture);
--- 101,107 ----
    glitz_texture_bind (gl, texture);
  
!   gl->tex_image_2d (texture->target, 0, texture->format,
                      texture->width, texture->height,
!                     0, GLITZ_GL_RGB, GLITZ_GL_UNSIGNED_BYTE, NULL);
  
    glitz_texture_unbind (gl, texture);

Index: glitz_util.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glitz_util.c	11 Jun 2004 14:35:41 -0000	1.5
--- glitz_util.c	21 Jun 2004 21:26:56 -0000	1.6
***************
*** 80,124 ****
  }
  
- static int
- big_endian (void)
- {
-   int a = 1;
-   char *c;
-   
-   c = (char *) &a;
-   if (c[0])
-     return 0;
-   else
-     return 1;
- }
- 
- glitz_gl_enum_t
- glitz_get_gl_format_from_bpp (unsigned short bpp)
- {
-   switch (bpp) {
-   case 8:
-     return GLITZ_GL_LUMINANCE_ALPHA;
-     break;
-   case 24:
-     if (big_endian ())
-       return GLITZ_GL_RGB;
-     else
-       return GLITZ_GL_BGR;
-     break;
-   default:
-     return GLITZ_GL_BGRA;
-     break;
-   }
- }
- 
- glitz_gl_enum_t
- glitz_get_gl_data_type_from_bpp (unsigned short bpp)
- {
-   if (bpp == 32 && big_endian ())
-     return GLITZ_GL_UNSIGNED_INT_8_8_8_8_REV;
-   else
-     return GLITZ_GL_UNSIGNED_BYTE;
- }
- 
  static glitz_bool_t
  _glitz_extension_check (const char *extensions,
--- 80,83 ----

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** glitzint.h	11 Jun 2004 14:35:41 -0000	1.18
--- glitzint.h	21 Jun 2004 21:26:56 -0000	1.19
***************
*** 123,128 ****
    glitz_gl_read_pixels_t read_pixels;
    glitz_gl_get_tex_image_t get_tex_image;
-   glitz_gl_pixel_zoom_t pixel_zoom;
-   glitz_gl_draw_pixels_t draw_pixels;
    glitz_gl_tex_sub_image_2d_t tex_sub_image_2d;
    glitz_gl_gen_textures_t gen_textures;
--- 123,126 ----
***************
*** 132,135 ****
--- 130,134 ----
    glitz_gl_tex_image_2d_t tex_image_2d;
    glitz_gl_tex_parameter_i_t tex_parameter_i;
+   glitz_gl_get_tex_level_parameter_iv_t get_tex_level_parameter_iv;
    glitz_gl_copy_tex_sub_image_2d_t copy_tex_sub_image_2d;
    glitz_gl_get_integer_v_t get_integer_v;
***************
*** 239,243 ****
    glitz_gl_enum_t target;
    glitz_gl_enum_t format;
-   glitz_gl_enum_t internal_format;
    glitz_bool_t allocated;
    
--- 238,241 ----
***************
*** 330,333 ****
--- 328,332 ----
    glitz_filter_t filter;
    glitz_polyedge_t polyedge;
+   glitz_polyedge_smooth_hint_t polyedge_smooth_hint;
    glitz_matrix_t *transform;
    glitz_matrix_t *inverse_transform;
***************
*** 365,369 ****
    glitz_surface_t base;
    
!   glitz_matrix_t transform;
    
    glitz_programmatic_surface_type_t type;
--- 364,368 ----
    glitz_surface_t base;
    
!   glitz_matrix_t matrix;
    
    glitz_programmatic_surface_type_t type;
***************
*** 453,462 ****
                          glitz_bounding_box_double_t *return_box);
  
- glitz_gl_enum_t
- glitz_get_gl_format_from_bpp (unsigned short bpp);
- 
- extern glitz_gl_enum_t __internal_linkage
- glitz_get_gl_data_type_from_bpp (unsigned short bpp);
- 
  long int
  glitz_extensions_query (const char *extensions_string,
--- 452,455 ----
***************
*** 469,473 ****
  glitz_uint_to_power_of_two (unsigned int *value);
  
! void
  glitz_set_raster_pos (glitz_gl_proc_address_list_t *gl,
                        int x,
--- 462,466 ----
  glitz_uint_to_power_of_two (unsigned int *value);
  
! extern void __internal_linkage
  glitz_set_raster_pos (glitz_gl_proc_address_list_t *gl,
                        int x,
***************
*** 528,536 ****
  glitz_surface_fini (glitz_surface_t *surface);
  
! extern void __internal_linkage
! glitz_surface_push_transform (glitz_surface_t *surface);
! 
! extern void __internal_linkage
! glitz_surface_pop_transform (glitz_surface_t *surface);
  
  extern glitz_texture_t *__internal_linkage
--- 521,526 ----
  glitz_surface_fini (glitz_surface_t *surface);
  
! glitz_gl_int_t
! glitz_surface_texture_format (glitz_surface_t *surface);
  
  extern glitz_texture_t *__internal_linkage
***************
*** 585,588 ****
--- 575,585 ----
                                     int height);
  
+ typedef void (*glitz_format_call_back_t) (glitz_format_t *, void *ptr);
+ 
+ void
+ glitz_format_for_each_texture_format (glitz_format_call_back_t call_back,
+ 				      glitz_gl_proc_address_list_t *gl,
+                                       void *ptr);
+ 
  glitz_format_t *
  glitz_format_find (glitz_format_t *formats,
***************
*** 598,603 ****
                              glitz_format_name_t format_name);
  
! void
! glitz_format_calculate_pixel_transfer_info (glitz_format_t *format);
  
  void
--- 595,602 ----
                              glitz_format_name_t format_name);
  
! extern glitz_gl_int_t __internal_linkage
! glitz_format_get_best_texture_format (glitz_format_t *formats,
! 				      int n_formats,
! 				      glitz_format_t *format);
  
  void
***************
*** 736,739 ****
--- 735,749 ----
  #define MAX(a,b) ((a) > (b) ? (a) : (b))
  
+ #define LSBFirst 0
+ #define MSBFirst 1
+ 
+ #ifdef WORDS_BIGENDIAN
+ #  define IMAGE_BYTE_ORDER MSBFirst
+ #  define BITMAP_BIT_ORDER MSBFirst
+ #else
+ #  define IMAGE_BYTE_ORDER LSBFirst
+ #  define BITMAP_BIT_ORDER LSBFirst
+ #endif
+ 
  /* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
  





More information about the cairo-commit mailing list