[cairo-commit] glitz/src glitz.c, 1.17, 1.18 glitz.h, 1.15, 1.16 glitz_agl_context.c, 1.5, 1.6 glitz_agl_extension.c, 1.3, 1.4 glitz_agl_info.c, 1.5, 1.6 glitz_agl_surface.c, 1.11, 1.12 glitz_aglint.h, 1.6, 1.7 glitz_color_range.c, 1.2, 1.3 glitz_format.c, 1.5, 1.6 glitz_gl.h, 1.4, 1.5 glitz_glx_context.c, 1.8, 1.9 glitz_glx_extension.c, 1.6, 1.7 glitz_glx_info.c, 1.10, 1.11 glitz_glx_surface.c, 1.13, 1.14 glitz_glxext.h, 1.5, 1.6 glitz_glxint.h, 1.9, 1.10 glitz_pixel.c, 1.1, 1.2 glitz_program.c, 1.8, 1.9 glitz_programmatic.c, 1.9, 1.10 glitz_render.c, 1.2, 1.3 glitz_surface.c, 1.14, 1.15 glitz_texture.c, 1.8, 1.9 glitzint.h, 1.19, 1.20

David Reveman commit at pdx.freedesktop.org
Tue Jul 20 00:51:16 PDT 2004


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv23709/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_color_range.c glitz_format.c glitz_gl.h 
	glitz_glx_context.c glitz_glx_extension.c glitz_glx_info.c 
	glitz_glx_surface.c glitz_glxext.h glitz_glxint.h 
	glitz_pixel.c glitz_program.c glitz_programmatic.c 
	glitz_render.c glitz_surface.c glitz_texture.c glitzint.h 
Log Message:
Component-alpha among other things

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** glitz.c	21 Jun 2004 21:26:56 -0000	1.17
--- glitz.c	20 Jul 2004 07:51:14 -0000	1.18
***************
*** 1,5 ****
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
!  *
   * Permission to use, copy, modify, distribute, and sell this software
   * and its documentation for any purpose is hereby granted without
--- 1,5 ----
  /*
!  * Copyright © 2004 David Reveman
!  * 
   * Permission to use, copy, modify, distribute, and sell this software
[...1238 lines suppressed...]
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      };
!     glitz_pixel_buffer_t *buffer =
!       glitz_pixel_buffer_create (src,
!                                  NULL,
!                                  width * height * 4,
!                                  GLITZ_PIXEL_BUFFER_HINT_STATIC_COPY);
!     if (!buffer) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
        return;
      }
+ 
+     glitz_pixel_buffer_set_format (buffer, &pf);
      
!     glitz_get_pixels (src, x_src, y_src, width, height, buffer);
!     glitz_put_pixels (dst, x_dst, y_dst, width, height, buffer);
      
!     glitz_pixel_buffer_destroy (buffer);
    }
  }

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** glitz.h	21 Jun 2004 21:49:15 -0000	1.15
--- glitz.h	20 Jul 2004 07:51:14 -0000	1.16
***************
*** 132,145 ****
  } glitz_operator_t;
  
! #define GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK       (1L << 0)
! #define GLITZ_FEATURE_CONVOLUTION_FILTER_MASK      (1L << 1)
! #define GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK       (1L << 2)
! #define GLITZ_FEATURE_TEXTURE_NPOT_MASK            (1L << 3)
! #define GLITZ_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L << 4)
! #define GLITZ_FEATURE_MULTISAMPLE_MASK             (1L << 5)
! #define GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK   (1L << 6)
! #define GLITZ_FEATURE_ARB_MULTITEXTURE_MASK        (1L << 7)
! #define GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L << 8)
! #define GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 9)
  
  typedef enum {  
--- 132,149 ----
  } glitz_operator_t;
  
! #define GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK       (1L <<  0)
! #define GLITZ_FEATURE_CONVOLUTION_FILTER_MASK      (1L <<  1)
! #define GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK       (1L <<  2)
! #define GLITZ_FEATURE_TEXTURE_NPOT_MASK            (1L <<  3)
! #define GLITZ_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L <<  4)
! #define GLITZ_FEATURE_MULTISAMPLE_MASK             (1L <<  5)
! #define GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK   (1L <<  6)
! #define GLITZ_FEATURE_ARB_MULTITEXTURE_MASK        (1L <<  7)
! #define GLITZ_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK (1L <<  8)
! #define GLITZ_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK    (1L <<  9)  
! #define GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L << 10)
! #define GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 11)
! #define GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK     (1L << 12)
! #define GLITZ_FEATURE_COMPONENT_ALPHA_MASK         (1L << 13)
  
  typedef enum {  
***************
*** 216,223 ****
  glitz_status_string (glitz_status_t status);
  
  /* glitz_color_range.c */
  
  typedef struct _glitz_color_range glitz_color_range_t;
! 
  typedef enum {
    GLITZ_EXTEND_PAD,
--- 220,229 ----
  glitz_status_string (glitz_status_t status);
  
+   
  /* glitz_color_range.c */
  
+ typedef struct _glitz_surface glitz_surface_t;
  typedef struct _glitz_color_range glitz_color_range_t;
!   
  typedef enum {
    GLITZ_EXTEND_PAD,
***************
*** 227,236 ****
    
  glitz_color_range_t *
! glitz_color_range_create (unsigned int size);
  
  void
  glitz_color_range_destroy (glitz_color_range_t *color_range);
  
! unsigned char *
  glitz_color_range_get_data (glitz_color_range_t *color_range);
  
--- 233,243 ----
    
  glitz_color_range_t *
! glitz_color_range_create (glitz_surface_t *surface,
!                           unsigned int size);
  
  void
  glitz_color_range_destroy (glitz_color_range_t *color_range);
  
! char *
  glitz_color_range_get_data (glitz_color_range_t *color_range);
  
***************
*** 249,254 ****
  /* glitz_surface.c */
  
- typedef struct _glitz_surface glitz_surface_t;
- 
  typedef enum {
    GLITZ_POLYEDGE_SHARP,
--- 256,259 ----
***************
*** 286,289 ****
--- 291,298 ----
  
  void
+ glitz_surface_set_component_alpha (glitz_surface_t *surface,
+                                    glitz_bool_t component_alpha);
+ 
+ void
  glitz_surface_set_filter (glitz_surface_t *surface,
                            glitz_filter_t filter);
***************
*** 406,410 ****
  unsigned long
  glitz_surface_get_hints (glitz_surface_t *surface);
! 
    
  /* glitz_pixel.c */
--- 415,419 ----
  unsigned long
  glitz_surface_get_hints (glitz_surface_t *surface);
!   
    
  /* glitz_pixel.c */
***************
*** 426,433 ****
--- 435,491 ----
    glitz_pixel_masks_t masks;
    int xoffset;
+   int skip_lines;
    int bytes_per_line;
    glitz_pixel_scanline_order_t scanline_order;
  } glitz_pixel_format_t;
  
+ typedef struct _glitz_pixel_buffer glitz_pixel_buffer_t;
+ 
+ typedef enum {
+   GLITZ_PIXEL_BUFFER_HINT_STREAM_DRAW,
+   GLITZ_PIXEL_BUFFER_HINT_STREAM_READ,
+   GLITZ_PIXEL_BUFFER_HINT_STREAM_COPY,
+   GLITZ_PIXEL_BUFFER_HINT_STATIC_DRAW,
+   GLITZ_PIXEL_BUFFER_HINT_STATIC_READ,
+   GLITZ_PIXEL_BUFFER_HINT_STATIC_COPY,
+   GLITZ_PIXEL_BUFFER_HINT_DYNAMIC_DRAW,
+   GLITZ_PIXEL_BUFFER_HINT_DYNAMIC_READ,
+   GLITZ_PIXEL_BUFFER_HINT_DYNAMIC_COPY
+ } glitz_buffer_hint_t;
+ 
+ glitz_pixel_buffer_t *
+ glitz_pixel_buffer_create (glitz_surface_t *surface,
+                            char *data,
+                            unsigned int size,
+                            glitz_buffer_hint_t hint);
+   
+ glitz_pixel_buffer_t *
+ glitz_pixel_buffer_create_for_data (char *data,
+                                     glitz_pixel_format_t *format);
+ 
+ void
+ glitz_pixel_buffer_destroy (glitz_pixel_buffer_t *buffer);
+ 
+ void
+ glitz_pixel_buffer_set_format (glitz_pixel_buffer_t *buffer,
+                                glitz_pixel_format_t *format);
+ 
+ void
+ glitz_pixel_buffer_get_format (glitz_pixel_buffer_t *buffer,
+                                glitz_pixel_format_t *format);
+ 
+ typedef enum {
+   GLITZ_PIXEL_BUFFER_ACCESS_READ_ONLY,
+   GLITZ_PIXEL_BUFFER_ACCESS_WRITE_ONLY,
+   GLITZ_PIXEL_BUFFER_ACCESS_READ_WRITE
+ } glitz_pixel_buffer_access_t;
+ 
+ char *
+ glitz_pixel_buffer_get_data (glitz_pixel_buffer_t *buffer,
+                              glitz_pixel_buffer_access_t access);
+   
+ void
+ glitz_pixel_buffer_put_back_data (glitz_pixel_buffer_t *buffer);
+ 
  void
  glitz_put_pixels (glitz_surface_t *dst,
***************
*** 436,441 ****
                    int width,
                    int height,
!                   glitz_pixel_format_t *format,
!                   char *pixels);
  
  void
--- 494,499 ----
                    int width,
                    int height,
!                   glitz_pixel_buffer_t *buffer);
!                   
  
  void
***************
*** 445,451 ****
                    int width,
                    int height,
!                   glitz_pixel_format_t *format,
!                   char *pixels);
! 
    
  /* glitz_rect.c */
--- 503,508 ----
                    int width,
                    int height,
!                   glitz_pixel_buffer_t *buffer);
!   
    
  /* glitz_rect.c */

Index: glitz_agl_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_context.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glitz_agl_context.c	21 Jun 2004 21:26:56 -0000	1.5
--- glitz_agl_context.c	20 Jul 2004 07:51:14 -0000	1.6
***************
*** 89,103 ****
    if (surface->base.format->multisample.supported) {
      if (surface->base.polyedge == GLITZ_POLYEDGE_SMOOTH) {
!       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);
    }
  }
--- 89,103 ----
    if (surface->base.format->multisample.supported) {
      if (surface->base.polyedge == GLITZ_POLYEDGE_SMOOTH) {
!       glEnable (GLITZ_GL_MULTISAMPLE);
        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, GLITZ_GL_FASTEST);
          else
!           glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT, GLITZ_GL_NICEST);
        }
      } else
!       glDisable (GLITZ_GL_MULTISAMPLE);
    }
  }

Index: glitz_agl_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_extension.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glitz_agl_extension.c	6 May 2004 14:55:03 -0000	1.3
--- glitz_agl_extension.c	20 Jul 2004 07:51:14 -0000	1.4
***************
*** 39,42 ****
--- 39,45 ----
    { "GL_ARB_texture_mirrored_repeat",
      GLITZ_AGL_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK },
+   { "GL_ARB_texture_env_combine",
+     GLITZ_AGL_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK },
+   { "GL_ARB_texture_env_dot3", GLITZ_AGL_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK },
    { "GL_ARB_multisample", GLITZ_AGL_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint",
***************
*** 45,48 ****
--- 48,52 ----
    { "GL_ARB_vertex_program", GLITZ_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK },
    { "GL_ARB_fragment_program", GLITZ_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK },
+   { "GL_EXT_pixel_buffer_object", GLITZ_AGL_FEATURE_PIXEL_BUFFER_OBJECT_MASK },
    { NULL, 0 }
  };
***************
*** 99,102 ****
--- 103,125 ----
        GLITZ_AGL_FEATURE_ARB_MULTITEXTURE_MASK) {
      thread_info->feature_mask |= GLITZ_FEATURE_ARB_MULTITEXTURE_MASK;
+ 
+     if (thread_info->agl_feature_mask &
+         GLITZ_AGL_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK)
+       thread_info->feature_mask |= GLITZ_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK;
+     
+     if (thread_info->agl_feature_mask &
+         GLITZ_AGL_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK)
+       thread_info->feature_mask |= GLITZ_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK;
+     
+     if ((thread_info->feature_mask &
+          GLITZ_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK) &&
+         (thread_info->feature_mask &
+          GLITZ_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK)) {
+       GLint max_texture_units;
+       
+       glGetIntegerv (GLITZ_GL_MAX_TEXTURE_UNITS, &max_texture_units);
+       if (max_texture_units >= 3)
+         thread_info->feature_mask |= GLITZ_FEATURE_COMPONENT_ALPHA_MASK;
+     }
      
      if (thread_info->agl_feature_mask &
***************
*** 108,110 ****
--- 131,137 ----
        thread_info->feature_mask |= GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
    }
+ 
+     if (thread_info->agl_feature_mask &
+       GLITZ_AGL_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
+     thread_info->feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  }

Index: glitz_agl_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_info.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glitz_agl_info.c	21 Jun 2004 21:26:56 -0000	1.5
--- glitz_agl_info.c	20 Jul 2004 07:51:14 -0000	1.6
***************
*** 42,47 ****
--- 42,49 ----
    (glitz_gl_vertex_2d_t) glVertex2d,
    (glitz_gl_tex_env_f_t) glTexEnvf,
+   (glitz_gl_tex_env_fv_t) glTexEnvfv,
    (glitz_gl_tex_coord_2d_t) glTexCoord2d,
    (glitz_gl_color_4us_t) glColor4us,
+   (glitz_gl_color_4d_t) glColor4d,
    (glitz_gl_scissor_t) glScissor,
    (glitz_gl_blend_func_t) glBlendFunc,
***************
*** 92,103 ****
    (glitz_gl_call_list_t) glCallList,
    
!   (glitz_gl_active_texture_arb_t) glActiveTextureARB,
!   (glitz_gl_multi_tex_coord_2d_arb_t) glMultiTexCoord2dARB,
!   (glitz_gl_gen_programs_arb_t) glGenProgramsARB,
!   (glitz_gl_delete_programs_arb_t) glDeleteProgramsARB,
!   (glitz_gl_program_string_arb_t) glProgramStringARB,
!   (glitz_gl_bind_program_arb_t) glBindProgramARB,
!   (glitz_gl_program_local_param_4d_arb_t) glProgramLocalParameter4dARB,
!   (glitz_gl_get_program_iv_arb_t) glGetProgramivARB,
    0
  };
--- 94,111 ----
    (glitz_gl_call_list_t) glCallList,
    
!   (glitz_gl_active_texture_t) glActiveTextureARB,
!   (glitz_gl_multi_tex_coord_2d_t) glMultiTexCoord2dARB,
!   (glitz_gl_gen_programs_t) glGenProgramsARB,
!   (glitz_gl_delete_programs_t) glDeleteProgramsARB,
!   (glitz_gl_program_string_t) glProgramStringARB,
!   (glitz_gl_bind_program_t) glBindProgramARB,
!   (glitz_gl_program_local_param_4d_t) glProgramLocalParameter4dARB,
!   (glitz_gl_get_program_iv_t) glGetProgramivARB,
!   (glitz_gl_gen_buffers_t) 0,
!   (glitz_gl_delete_buffers_t) 0,
!   (glitz_gl_bind_buffer_t) 0,
!   (glitz_gl_buffer_data_t) 0,
!   (glitz_gl_map_buffer_t) 0,
!   (glitz_gl_unmap_buffer_t) 0,
    0
  };
***************
*** 128,142 ****
  glitz_agl_thread_info_get (void)
  {
    if (!tsd_initialized) {
-     glitz_agl_thread_info_t *info = malloc (sizeof (glitz_agl_thread_info_t));
-     glitz_agl_thread_info_init (info);
-     
      pthread_key_create (&info_tsd, glitz_agl_thread_info_destroy);
-     pthread_setspecific (info_tsd, info);
-     
      tsd_initialized = 1;
!     return info;
    } else
!     return (glitz_agl_thread_info_t *) pthread_getspecific (info_tsd);
  }
  
--- 136,158 ----
  glitz_agl_thread_info_get (void)
  {
+   glitz_agl_thread_info_t *thread_info;
+   void *p;
+   
    if (!tsd_initialized) {
      pthread_key_create (&info_tsd, glitz_agl_thread_info_destroy);
      tsd_initialized = 1;
!   }
!   
!   p = pthread_getspecific (info_tsd);
! 
!   if (p == NULL) {
!     thread_info = malloc (sizeof (glitz_agl_thread_info_t));
!     glitz_agl_thread_info_init (thread_info);
!   
!     pthread_setspecific (info_tsd, thread_info);
    } else
!     thread_info = (glitz_agl_thread_info_t *) p;
!   
!   return thread_info;
  }
  
***************
*** 186,190 ****
    thread_info->n_contexts = 0;
  
!   memset (&thread_info->programs, 0, sizeof (glitz_programs_t));
    
    thread_info->root_context.pixel_format =
--- 202,206 ----
    thread_info->n_contexts = 0;
  
!   glitz_program_map_init (&thread_info->program_map);
    
    thread_info->root_context.pixel_format =
***************
*** 202,208 ****
      glitz_gl_uint_t texture_indirections;
      
!      _glitz_agl_gl_proc_address.get_program_iv_arb
!        (GLITZ_GL_FRAGMENT_PROGRAM_ARB,
!         GLITZ_GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB,
          &texture_indirections);
  
--- 218,224 ----
      glitz_gl_uint_t texture_indirections;
      
!      _glitz_agl_gl_proc_address.get_program_iv
!        (GLITZ_GL_FRAGMENT_PROGRAM,
!         GLITZ_GL_MAX_PROGRAM_TEX_INDIRECTIONS,
          &texture_indirections);
  
***************
*** 227,232 ****
    
    aglSetCurrentContext (thread_info->root_context.context);
!   glitz_programs_fini (&_glitz_agl_gl_proc_address,
!                        &thread_info->programs);
    aglSetCurrentContext (NULL);
  
--- 243,248 ----
    
    aglSetCurrentContext (thread_info->root_context.context);
!   glitz_program_map_fini (&_glitz_agl_gl_proc_address,
!                           &thread_info->program_map);
    aglSetCurrentContext (NULL);
  
***************
*** 247,252 ****
  
    aglDestroyContext (thread_info->root_context.context);
- 
-   free (thread_info);
  }
  
--- 263,266 ----

Index: glitz_agl_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_surface.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** glitz_agl_surface.c	21 Jun 2004 21:26:56 -0000	1.11
--- glitz_agl_surface.c	20 Jul 2004 07:51:14 -0000	1.12
***************
*** 216,220 ****
                        width,
                        height,
!                       &thread_info->programs,
                        texture_mask);
    
--- 216,220 ----
                        width,
                        height,
!                       &thread_info->program_map,
                        texture_mask);
    
***************
*** 280,284 ****
                        width,
                        height,
!                       &thread_info->programs,
                        thread_info->texture_mask);
    
--- 280,284 ----
                        width,
                        height,
!                       &thread_info->program_map,
                        thread_info->texture_mask);
    

Index: glitz_aglint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_aglint.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glitz_aglint.h	24 May 2004 07:16:42 -0000	1.6
--- glitz_aglint.h	20 Jul 2004 07:51:14 -0000	1.7
***************
*** 37,49 ****
  #include <AGL/agl.h>
  
! #define GLITZ_AGL_FEATURE_PBUFFER_MASK                 (1L << 0)
! #define GLITZ_AGL_FEATURE_TEXTURE_RECTANGLE_MASK       (1L << 1)
! #define GLITZ_AGL_FEATURE_TEXTURE_NPOT_MASK            (1L << 2)
! #define GLITZ_AGL_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L << 3)
! #define GLITZ_AGL_FEATURE_MULTISAMPLE_MASK             (1L << 4)
! #define GLITZ_AGL_FEATURE_MULTISAMPLE_FILTER_MASK      (1L << 5)
! #define GLITZ_AGL_FEATURE_ARB_MULTITEXTURE_MASK        (1L << 6)
! #define GLITZ_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L << 7)
! #define GLITZ_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 8)
  
  typedef struct _glitz_agl_surface_t glitz_agl_surface_t;
--- 37,52 ----
  #include <AGL/agl.h>
  
! #define GLITZ_AGL_FEATURE_PBUFFER_MASK                 (1L <<  0)
! #define GLITZ_AGL_FEATURE_TEXTURE_RECTANGLE_MASK       (1L <<  1)
! #define GLITZ_AGL_FEATURE_TEXTURE_NPOT_MASK            (1L <<  2)
! #define GLITZ_AGL_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L <<  3)
! #define GLITZ_AGL_FEATURE_MULTISAMPLE_MASK             (1L <<  4)
! #define GLITZ_AGL_FEATURE_MULTISAMPLE_FILTER_MASK      (1L <<  5)
! #define GLITZ_AGL_FEATURE_ARB_MULTITEXTURE_MASK        (1L <<  6)
! #define GLITZ_AGL_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK (1L <<  7)
! #define GLITZ_AGL_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK    (1L <<  8)
! #define GLITZ_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L <<  9)
! #define GLITZ_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 10)
! #define GLITZ_AGL_FEATURE_PIXEL_BUFFER_OBJECT_MASK     (1L << 11)
  
  typedef struct _glitz_agl_surface_t glitz_agl_surface_t;
***************
*** 78,82 ****
    long int texture_mask;
  
!   glitz_programs_t programs;
  } glitz_agl_thread_info_t;
  
--- 81,85 ----
    long int texture_mask;
  
!   glitz_program_map_t program_map;
  } glitz_agl_thread_info_t;
  

Index: glitz_color_range.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_color_range.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glitz_color_range.c	21 Jun 2004 21:26:56 -0000	1.2
--- glitz_color_range.c	20 Jul 2004 07:51:14 -0000	1.3
***************
*** 32,61 ****
  #include "glitzint.h"
  
! static void
! glitz_color_range_init (glitz_color_range_t *color_range,
!                         unsigned int size)
! {
!   color_range->texture = 0;
!   color_range->filter = GLITZ_FILTER_NEAREST;
!   color_range->extend = GLITZ_EXTEND_PAD;
!   color_range->ref_count = 1;
!   color_range->data = malloc (size * 4);
!   color_range->size = size;
!   color_range->update_mask = GLITZ_COLOR_RANGE_UPDATE_ALL_MASK;
!   color_range->delete_textures = NULL;
! }
! 
! static void
! glitz_color_range_fini (glitz_color_range_t *color_range)
! {
!   if (color_range->texture)
!     color_range->delete_textures (1, &color_range->texture);
  
!   if (color_range->data)
!     free (color_range->data);
! }
  
  glitz_color_range_t *
! glitz_color_range_create (unsigned int size)
  {
    glitz_color_range_t *color_range;
--- 32,54 ----
  #include "glitzint.h"
  
! #define GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK (1L << 0)
! #define GLITZ_COLOR_RANGE_UPDATE_FILTER_MASK  (1L << 1)
! #define GLITZ_COLOR_RANGE_UPDATE_EXTEND_MASK  (1L << 2)
! #define GLITZ_COLOR_RANGE_UPDATE_ALL_MASK     ((1L << 3) - 1)
  
! struct _glitz_color_range {
!   unsigned int size;
!   glitz_gl_uint_t texture;
!   glitz_filter_t filter;
!   glitz_extend_t extend;
!   unsigned long update_mask;
!   unsigned int ref_count;
!   glitz_pixel_buffer_t *buffer;
!   glitz_surface_t *surface;
! };
  
  glitz_color_range_t *
! glitz_color_range_create (glitz_surface_t *surface,
!                           unsigned int size)
  {
    glitz_color_range_t *color_range;
***************
*** 65,75 ****
      return NULL;
  
!   glitz_color_range_init (color_range, size);
  
!   if (!color_range->data) {
      free (color_range);
      return NULL;
    }
    
    return color_range;
  }
--- 58,85 ----
      return NULL;
  
!   color_range->texture = 0;
!   color_range->filter = GLITZ_FILTER_NEAREST;
!   color_range->extend = GLITZ_EXTEND_PAD;
!   color_range->ref_count = 1;
  
!   /* If data is not POT and NPOT texture support is missing we force
!      the size to POT */
!   if ((!(surface->feature_mask & GLITZ_FEATURE_TEXTURE_NPOT_MASK)) &&
!       (!glitz_uint_is_power_of_two (size)))
!     glitz_uint_to_power_of_two (&size);
!   
!   color_range->size = size;
!   color_range->buffer =
!     glitz_pixel_buffer_create (surface, NULL, size * 4 /* ARGB32 */,
!                                GLITZ_PIXEL_BUFFER_HINT_STATIC_DRAW);
!   if (color_range->buffer == NULL) {
      free (color_range);
      return NULL;
    }
    
+   color_range->update_mask = GLITZ_COLOR_RANGE_UPDATE_ALL_MASK;
+   color_range->surface = surface;
+   glitz_surface_reference (surface);
+ 
    return color_range;
  }
***************
*** 80,84 ****
  {
    if (color_range == NULL)
! 	return;
  
    color_range->ref_count++;
--- 90,94 ----
  {
    if (color_range == NULL)
!     return;
  
    color_range->ref_count++;
***************
*** 95,99 ****
      return;
  
!   glitz_color_range_fini (color_range);
    free (color_range);
  }
--- 105,121 ----
      return;
  
!   glitz_pixel_buffer_destroy (color_range->buffer);
!   
!   if (color_range->texture) {
!     glitz_surface_push_current (color_range->surface,
!                                 GLITZ_CN_ANY_CONTEXT_CURRENT);
!     
!     color_range->surface->gl->delete_textures (1, &color_range->texture);
! 
!     glitz_surface_pop_current (color_range->surface);
!   }
! 
!   glitz_surface_destroy (color_range->surface);
!   
    free (color_range);
  }
***************
*** 105,125 ****
  {
    if (color_range->update_mask & GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK) {
      
!     if (!color_range->texture) {
        gl->gen_textures (1, &color_range->texture);
-       color_range->delete_textures = gl->delete_textures;
-     }
      
      gl->enable (GLITZ_GL_TEXTURE_1D);
      gl->bind_texture (GLITZ_GL_TEXTURE_1D, color_range->texture);
!     
!     /* If data is not POT and NPOT texture support is missing we reallocate
!        a POT sized memory block for glTexImage1D */
!     if ((!(feature_mask & GLITZ_FEATURE_TEXTURE_NPOT_MASK)) &&
!         (!glitz_uint_is_power_of_two (color_range->size))) {
!       glitz_uint_to_power_of_two (&color_range->size);
!       
!       color_range->data = realloc (color_range->data, color_range->size * 4);
!     }
      
      gl->tex_image_1d (GLITZ_GL_TEXTURE_1D, 0, GLITZ_GL_RGBA,
--- 127,140 ----
  {
    if (color_range->update_mask & GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK) {
+     char *data;
      
!     if (!color_range->texture)
        gl->gen_textures (1, &color_range->texture);
      
      gl->enable (GLITZ_GL_TEXTURE_1D);
      gl->bind_texture (GLITZ_GL_TEXTURE_1D, color_range->texture);
! 
!     data = glitz_pixel_buffer_bind (color_range->buffer,
!                                     GLITZ_GL_PIXEL_UNPACK_BUFFER);
      
      gl->tex_image_1d (GLITZ_GL_TEXTURE_1D, 0, GLITZ_GL_RGBA,
***************
*** 133,137 ****
  #endif
                        
!                       color_range->data);
      
      color_range->update_mask &= ~GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK;
--- 148,154 ----
  #endif
                        
!                       data);
! 
!     glitz_pixel_buffer_unbind (color_range->buffer);
      
      color_range->update_mask &= ~GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK;
***************
*** 186,190 ****
          gl->tex_parameter_i (GLITZ_GL_TEXTURE_1D,
                               GLITZ_GL_TEXTURE_WRAP_S,
!                              GLITZ_GL_MIRRORED_REPEAT_ARB);
        else
          gl->tex_parameter_i (GLITZ_GL_TEXTURE_1D,
--- 203,207 ----
          gl->tex_parameter_i (GLITZ_GL_TEXTURE_1D,
                               GLITZ_GL_TEXTURE_WRAP_S,
!                              GLITZ_GL_MIRRORED_REPEAT);
        else
          gl->tex_parameter_i (GLITZ_GL_TEXTURE_1D,
***************
*** 197,204 ****
  }
  
! unsigned char *
  glitz_color_range_get_data (glitz_color_range_t *color_range)
  {
!   return color_range->data;
  }
  slim_hidden_def(glitz_color_range_get_data);
--- 214,222 ----
  }
  
! char *
  glitz_color_range_get_data (glitz_color_range_t *color_range)
  {
!   return glitz_pixel_buffer_get_data (color_range->buffer,
!                                       GLITZ_PIXEL_BUFFER_ACCESS_WRITE_ONLY);
  }
  slim_hidden_def(glitz_color_range_get_data);
***************
*** 207,210 ****
--- 225,230 ----
  glitz_color_range_put_back_data (glitz_color_range_t *color_range)
  {
+   glitz_pixel_buffer_put_back_data (color_range->buffer);
+   
    color_range->update_mask |= GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK;
  }

Index: glitz_format.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_format.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glitz_format.c	21 Jun 2004 21:26:56 -0000	1.5
--- glitz_format.c	20 Jul 2004 07:51:14 -0000	1.6
***************
*** 36,46 ****
  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 }
--- 36,46 ----
  static glitz_format_t _texture_formats[] = {
    {
!     GLITZ_GL_ALPHA4, 0, 0, 0, 4, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
    }, {
!     GLITZ_GL_ALPHA8, 0, 0, 0, 8, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
    }, {
!     GLITZ_GL_ALPHA12, 0, 0, 0, 12, 0, 0, 0, { 0, 1 }, { 0, 0 }, { 0, 0 }
    }, {
!     GLITZ_GL_ALPHA16, 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 }
***************
*** 107,116 ****
      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);
--- 107,112 ----
      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)
!       continue;
  
      call_back (&_texture_formats[i], ptr);

Index: glitz_gl.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_gl.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glitz_gl.h	21 Jun 2004 21:26:56 -0000	1.4
--- glitz_gl.h	20 Jul 2004 07:51:14 -0000	1.5
***************
*** 29,32 ****
--- 29,34 ----
  #define GLITZ_GL_H_INCLUDED
  
+ #include <stddef.h>
+ 
  typedef unsigned int glitz_gl_enum_t;
  typedef unsigned char glitz_gl_boolean_t;
***************
*** 42,45 ****
--- 44,49 ----
  typedef float glitz_gl_clampf_t;
  typedef unsigned char glitz_gl_ubyte_t;
+ typedef ptrdiff_t glitz_gl_sizeiptr_t;
+ 
  
  #define GLITZ_GL_FALSE 0x0
***************
*** 84,87 ****
--- 88,92 ----
  #define GLITZ_GL_TEXTURE_MAG_FILTER     0x2800
  #define GLITZ_GL_TEXTURE_MIN_FILTER     0x2801
+ #define GLITZ_GL_TEXTURE_ENV_COLOR      0x2201
  #define GLITZ_GL_MODULATE               0x2100
  #define GLITZ_GL_NEAREST                0x2600
***************
*** 93,97 ****
  #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
--- 98,129 ----
  #define GLITZ_GL_TEXTURE_BLUE_SIZE      0x805E
  #define GLITZ_GL_TEXTURE_ALPHA_SIZE     0x805F
! 
! #define GLITZ_GL_TEXTURE        0x1702
! #define GLITZ_GL_SRC_COLOR      0x0300
! 
! #define GLITZ_GL_COMBINE        0x8570
! #define GLITZ_GL_COMBINE_RGB    0x8571
! #define GLITZ_GL_COMBINE_ALPHA  0x8572
! #define GLITZ_GL_SOURCE0_RGB    0x8580
! #define GLITZ_GL_SOURCE1_RGB    0x8581
! #define GLITZ_GL_SOURCE2_RGB    0x8582
! #define GLITZ_GL_SOURCE0_ALPHA  0x8588
! #define GLITZ_GL_SOURCE1_ALPHA  0x8589
! #define GLITZ_GL_SOURCE2_ALPHA  0x858A
! #define GLITZ_GL_OPERAND0_RGB   0x8590
! #define GLITZ_GL_OPERAND1_RGB   0x8591
! #define GLITZ_GL_OPERAND2_RGB   0x8592
! #define GLITZ_GL_OPERAND0_ALPHA	0x8598
! #define GLITZ_GL_OPERAND1_ALPHA	0x8599
! #define GLITZ_GL_OPERAND2_ALPHA	0x859A
! #define GLITZ_GL_RGB_SCALE      0x8573
! #define GLITZ_GL_ADD_SIGNED     0x8574
! #define GLITZ_GL_INTERPOLATE    0x8575
! #define GLITZ_GL_SUBTRACT       0x84E7
! #define GLITZ_GL_CONSTANT       0x8576
! #define GLITZ_GL_PRIMARY_COLOR  0x8577
! #define GLITZ_GL_PREVIOUS       0x8578
! #define GLITZ_GL_DOT3_RGB       0x86AE
! #define GLITZ_GL_DOT3_RGBA      0x86AF
  
  #define GLITZ_GL_STENCIL_TEST 0x0B90
***************
*** 121,143 ****
  #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
--- 153,174 ----
  #define GLITZ_GL_BGRA      0x80E1
  
! #define GLITZ_GL_ALPHA4   0x803B
! #define GLITZ_GL_ALPHA8   0x803C
! #define GLITZ_GL_ALPHA12  0x803D
! #define GLITZ_GL_ALPHA16  0x803E
! #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
***************
*** 169,192 ****
  #define GLITZ_GL_COMPILE 0x1300
  
! #define GLITZ_GL_TEXTURE_RECTANGLE_EXT 0x84F5
  
! #define GLITZ_GL_MIRRORED_REPEAT_ARB 0x8370
  
! #define GLITZ_GL_TEXTURE0_ARB       0x84C0
! #define GLITZ_GL_TEXTURE1_ARB       0x84C1
! #define GLITZ_GL_TEXTURE2_ARB       0x84C2
! #define GLITZ_GL_ACTIVE_TEXTURE_ARB 0x84E0
  
! #define GLITZ_GL_MULTISAMPLE_ARB 0x809D
  
! #define GLITZ_GL_MULTISAMPLE_FILTER_HINT_NV 0x8534
  
! #define GLITZ_GL_VERTEX_PROGRAM_ARB         0x8620
! #define GLITZ_GL_PROGRAM_STRING_ARB         0x8628
! #define GLITZ_GL_PROGRAM_FORMAT_ASCII_ARB   0x8875
! #define GLITZ_GL_PROGRAM_ERROR_POSITION_ARB 0x864B
  
- #define GLITZ_GL_FRAGMENT_PROGRAM_ARB             0x8804
- #define GLITZ_GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
  
  typedef glitz_gl_void_t (* glitz_gl_enable_t)
--- 200,242 ----
  #define GLITZ_GL_COMPILE 0x1300
  
! #define GLITZ_GL_TEXTURE_RECTANGLE 0x84F5
  
! #define GLITZ_GL_MIRRORED_REPEAT 0x8370
  
! #define GLITZ_GL_TEXTURE0          0x84C0
! #define GLITZ_GL_TEXTURE1          0x84C1
! #define GLITZ_GL_TEXTURE2          0x84C2
! #define GLITZ_GL_ACTIVE_TEXTURE    0x84E0
! #define GLITZ_GL_MAX_TEXTURE_UNITS 0x84E2
  
! #define GLITZ_GL_MULTISAMPLE 0x809D
  
! #define GLITZ_GL_MULTISAMPLE_FILTER_HINT 0x8534
  
! #define GLITZ_GL_VERTEX_PROGRAM         0x8620
! #define GLITZ_GL_PROGRAM_STRING         0x8628
! #define GLITZ_GL_PROGRAM_FORMAT_ASCII   0x8875
! #define GLITZ_GL_PROGRAM_ERROR_POSITION 0x864B
! 
! #define GLITZ_GL_FRAGMENT_PROGRAM             0x8804
! #define GLITZ_GL_MAX_PROGRAM_TEX_INDIRECTIONS 0x880D
! 
! #define GLITZ_GL_PIXEL_PACK_BUFFER   0x88EB
! #define GLITZ_GL_PIXEL_UNPACK_BUFFER 0x88EC
! 
! #define GLITZ_GL_STREAM_DRAW  0x88E0
! #define GLITZ_GL_STREAM_READ  0x88E1
! #define GLITZ_GL_STREAM_COPY  0x88E2
! #define GLITZ_GL_STATIC_DRAW  0x88E4
! #define GLITZ_GL_STATIC_READ  0x88E5
! #define GLITZ_GL_STATIC_COPY  0x88E6
! #define GLITZ_GL_DYNAMIC_DRAW 0x88E8
! #define GLITZ_GL_DYNAMIC_READ 0x88E9
! #define GLITZ_GL_DYNAMIC_COPY 0x88EA
! 
! #define GLITZ_GL_READ_ONLY  0x88B8
! #define GLITZ_GL_WRITE_ONLY 0x88B9
! #define GLITZ_GL_READ_WRITE 0x88BA
  
  
  typedef glitz_gl_void_t (* glitz_gl_enable_t)
***************
*** 204,207 ****
--- 254,260 ----
  typedef glitz_gl_void_t (* glitz_gl_tex_env_f_t)
       (glitz_gl_enum_t target, glitz_gl_enum_t pname, glitz_gl_float_t param);
+ typedef glitz_gl_void_t (* glitz_gl_tex_env_fv_t)
+      (glitz_gl_enum_t target, glitz_gl_enum_t pname,
+       const glitz_gl_float_t *params);
  typedef glitz_gl_void_t (* glitz_gl_tex_coord_2d_t)
       (glitz_gl_double_t s, glitz_gl_double_t t);
***************
*** 212,215 ****
--- 265,271 ----
       (glitz_gl_ushort_t red, glitz_gl_ushort_t green, glitz_gl_ushort_t blue,
        glitz_gl_ushort_t alpha);
+ typedef glitz_gl_void_t (* glitz_gl_color_4d_t)
+      (glitz_gl_double_t red, glitz_gl_double_t green, glitz_gl_double_t blue,
+       glitz_gl_double_t alpha);
  typedef glitz_gl_void_t (* glitz_gl_blend_func_t)
       (glitz_gl_enum_t sfactor, glitz_gl_enum_t dfactor);
***************
*** 327,330 ****
--- 383,388 ----
  typedef glitz_gl_void_t (* glitz_gl_get_integer_v_t)
       (glitz_gl_enum_t pname, glitz_gl_int_t *params);
+ typedef glitz_gl_void_t (* glitz_gl_get_pointer_v_t)
+      (glitz_gl_enum_t pname, glitz_gl_void_t **params);
  typedef glitz_gl_void_t (* glitz_gl_delete_lists_t)
       (glitz_gl_uint_t list, glitz_gl_sizei_t range);
***************
*** 337,359 ****
  typedef glitz_gl_void_t (* glitz_gl_call_list_t)
       (glitz_gl_uint_t list);
! typedef glitz_gl_void_t (* glitz_gl_active_texture_arb_t)
       (glitz_gl_enum_t);
! typedef glitz_gl_void_t (* glitz_gl_multi_tex_coord_2d_arb_t)
       (glitz_gl_enum_t, glitz_gl_double_t, glitz_gl_double_t);
! typedef glitz_gl_void_t (* glitz_gl_gen_programs_arb_t)
       (glitz_gl_sizei_t, glitz_gl_uint_t *);
! typedef glitz_gl_void_t (* glitz_gl_delete_programs_arb_t)
       (glitz_gl_sizei_t, const glitz_gl_uint_t *);
! typedef glitz_gl_void_t (* glitz_gl_program_string_arb_t)
       (glitz_gl_enum_t, glitz_gl_enum_t, glitz_gl_sizei_t,
        const glitz_gl_void_t *);
! typedef glitz_gl_void_t (* glitz_gl_bind_program_arb_t)
       (glitz_gl_enum_t, glitz_gl_uint_t);
! typedef glitz_gl_void_t (* glitz_gl_program_local_param_4d_arb_t)
       (glitz_gl_enum_t, glitz_gl_uint_t,
        glitz_gl_double_t, glitz_gl_double_t,
        glitz_gl_double_t, glitz_gl_double_t);
! typedef glitz_gl_void_t (* glitz_gl_get_program_iv_arb_t)
       (glitz_gl_enum_t, glitz_gl_enum_t, glitz_gl_uint_t *);
  
  #endif /* GLITZ_GL_H_INCLUDED */
--- 395,430 ----
  typedef glitz_gl_void_t (* glitz_gl_call_list_t)
       (glitz_gl_uint_t list);
! typedef glitz_gl_void_t (* glitz_gl_active_texture_t)
       (glitz_gl_enum_t);
! typedef glitz_gl_void_t (* glitz_gl_multi_tex_coord_2d_t)
       (glitz_gl_enum_t, glitz_gl_double_t, glitz_gl_double_t);
! typedef glitz_gl_void_t (* glitz_gl_gen_programs_t)
       (glitz_gl_sizei_t, glitz_gl_uint_t *);
! typedef glitz_gl_void_t (* glitz_gl_delete_programs_t)
       (glitz_gl_sizei_t, const glitz_gl_uint_t *);
! typedef glitz_gl_void_t (* glitz_gl_program_string_t)
       (glitz_gl_enum_t, glitz_gl_enum_t, glitz_gl_sizei_t,
        const glitz_gl_void_t *);
! typedef glitz_gl_void_t (* glitz_gl_bind_program_t)
       (glitz_gl_enum_t, glitz_gl_uint_t);
! typedef glitz_gl_void_t (* glitz_gl_program_local_param_4d_t)
       (glitz_gl_enum_t, glitz_gl_uint_t,
        glitz_gl_double_t, glitz_gl_double_t,
        glitz_gl_double_t, glitz_gl_double_t);
! typedef glitz_gl_void_t (* glitz_gl_get_program_iv_t)
       (glitz_gl_enum_t, glitz_gl_enum_t, glitz_gl_uint_t *);
+ typedef glitz_gl_void_t (* glitz_gl_gen_buffers_t)
+      (glitz_gl_sizei_t, glitz_gl_uint_t *buffers);
+ typedef glitz_gl_void_t (* glitz_gl_delete_buffers_t)
+      (glitz_gl_sizei_t, const glitz_gl_uint_t *buffers);
+ typedef glitz_gl_void_t (* glitz_gl_bind_buffer_t)
+      (glitz_gl_enum_t, glitz_gl_uint_t buffer);
+ typedef glitz_gl_void_t (* glitz_gl_buffer_data_t)
+      (glitz_gl_enum_t, glitz_gl_sizeiptr_t, const glitz_gl_void_t *,
+       glitz_gl_enum_t);
+ typedef glitz_gl_void_t *(* glitz_gl_map_buffer_t)
+      (glitz_gl_enum_t, glitz_gl_enum_t);
+ typedef glitz_gl_boolean_t (* glitz_gl_unmap_buffer_t)
+      (glitz_gl_enum_t);
  
  #endif /* GLITZ_GL_H_INCLUDED */

Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_context.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glitz_glx_context.c	21 Jun 2004 21:26:56 -0000	1.8
--- glitz_glx_context.c	20 Jul 2004 07:51:14 -0000	1.9
***************
*** 204,246 ****
      screen_info->display_info->thread_info;
      
!   context->glx.bind_tex_image_arb =
!     (glitz_glx_bind_tex_image_arb_t)
      glitz_glx_get_proc_address (thread_info, "glXBindTexImageARB");
!   context->glx.release_tex_image_arb =
!     (glitz_glx_release_tex_image_arb_t)
      glitz_glx_get_proc_address (thread_info, "glXReleaseTexImageARB");
  
!   context->gl.active_texture_arb =
!     (glitz_gl_active_texture_arb_t)
      glitz_glx_get_proc_address (thread_info, "glActiveTextureARB");
!   context->gl.multi_tex_coord_2d_arb =
!     (glitz_gl_multi_tex_coord_2d_arb_t)
      glitz_glx_get_proc_address (thread_info, "glMultiTexCoord2dARB");
  
!   context->gl.gen_programs_arb =
!     (glitz_gl_gen_programs_arb_t)
      glitz_glx_get_proc_address (thread_info, "glGenProgramsARB");
!   context->gl.delete_programs_arb =
!     (glitz_gl_delete_programs_arb_t)
      glitz_glx_get_proc_address (thread_info, "glDeleteProgramsARB");
!   context->gl.program_string_arb =
!     (glitz_gl_program_string_arb_t)
      glitz_glx_get_proc_address (thread_info, "glProgramStringARB");
!   context->gl.bind_program_arb =
!     (glitz_gl_bind_program_arb_t)
      glitz_glx_get_proc_address (thread_info, "glBindProgramARB");
!   context->gl.program_local_param_4d_arb =
!     (glitz_gl_program_local_param_4d_arb_t)
      glitz_glx_get_proc_address (thread_info, "glProgramLocalParameter4dARB");
!   context->gl.get_program_iv_arb =
!     (glitz_gl_get_program_iv_arb_t)
      glitz_glx_get_proc_address (thread_info, "glGetProgramivARB");
  
    if (screen_info->feature_mask & GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
!     if (context->gl.get_program_iv_arb) {
!       context->gl.get_program_iv_arb
!         (GLITZ_GL_FRAGMENT_PROGRAM_ARB,
!          GLITZ_GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB,
!          &context->texture_indirections);
      }
    }
--- 204,264 ----
      screen_info->display_info->thread_info;
      
!   context->glx.bind_tex_image =
!     (glitz_glx_bind_tex_image_t)
      glitz_glx_get_proc_address (thread_info, "glXBindTexImageARB");
!   context->glx.release_tex_image =
!     (glitz_glx_release_tex_image_t)
      glitz_glx_get_proc_address (thread_info, "glXReleaseTexImageARB");
  
!   context->gl.active_texture =
!     (glitz_gl_active_texture_t)
      glitz_glx_get_proc_address (thread_info, "glActiveTextureARB");
!   context->gl.multi_tex_coord_2d =
!     (glitz_gl_multi_tex_coord_2d_t)
      glitz_glx_get_proc_address (thread_info, "glMultiTexCoord2dARB");
  
!   context->gl.gen_programs =
!     (glitz_gl_gen_programs_t)
      glitz_glx_get_proc_address (thread_info, "glGenProgramsARB");
!   context->gl.delete_programs =
!     (glitz_gl_delete_programs_t)
      glitz_glx_get_proc_address (thread_info, "glDeleteProgramsARB");
!   context->gl.program_string =
!     (glitz_gl_program_string_t)
      glitz_glx_get_proc_address (thread_info, "glProgramStringARB");
!   context->gl.bind_program =
!     (glitz_gl_bind_program_t)
      glitz_glx_get_proc_address (thread_info, "glBindProgramARB");
!   context->gl.program_local_param_4d =
!     (glitz_gl_program_local_param_4d_t)
      glitz_glx_get_proc_address (thread_info, "glProgramLocalParameter4dARB");
!   context->gl.get_program_iv =
!     (glitz_gl_get_program_iv_t)
      glitz_glx_get_proc_address (thread_info, "glGetProgramivARB");
  
+   context->gl.gen_buffers =
+     (glitz_gl_gen_buffers_t)
+     glitz_glx_get_proc_address (thread_info, "glGenBuffers");
+   context->gl.delete_buffers =
+     (glitz_gl_delete_buffers_t)
+     glitz_glx_get_proc_address (thread_info, "glDeleteBuffers");
+   context->gl.bind_buffer =
+     (glitz_gl_bind_buffer_t)
+     glitz_glx_get_proc_address (thread_info, "glBindBuffer");
+   context->gl.buffer_data =
+     (glitz_gl_buffer_data_t)
+     glitz_glx_get_proc_address (thread_info, "glBufferData");
+   context->gl.map_buffer =
+     (glitz_gl_map_buffer_t)
+     glitz_glx_get_proc_address (thread_info, "glMapBuffer");
+   context->gl.unmap_buffer =
+     (glitz_gl_unmap_buffer_t)
+     glitz_glx_get_proc_address (thread_info, "glUnmapBuffer");
+ 
    if (screen_info->feature_mask & GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
!     if (context->gl.get_program_iv) {
!       context->gl.get_program_iv (GLITZ_GL_FRAGMENT_PROGRAM,
!                                   GLITZ_GL_MAX_PROGRAM_TEX_INDIRECTIONS,
!                                   &context->texture_indirections);
      }
    }
***************
*** 255,269 ****
    if (surface->base.format->multisample.supported) {
      if (surface->base.polyedge == GLITZ_POLYEDGE_SMOOTH) {
!       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);
    }
  }
--- 273,287 ----
    if (surface->base.format->multisample.supported) {
      if (surface->base.polyedge == GLITZ_POLYEDGE_SMOOTH) {
!       glEnable (GLITZ_GL_MULTISAMPLE);
        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, GLITZ_GL_FASTEST);
          else
!           glHint (GLITZ_GL_MULTISAMPLE_FILTER_HINT, GLITZ_GL_NICEST);
        }
      } else
!       glDisable (GLITZ_GL_MULTISAMPLE);
    }
  }

Index: glitz_glx_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_extension.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glitz_glx_extension.c	9 May 2004 20:54:51 -0000	1.6
--- glitz_glx_extension.c	20 Jul 2004 07:51:14 -0000	1.7
***************
*** 44,47 ****
--- 44,50 ----
    { "GL_ARB_texture_mirrored_repeat",
      GLITZ_GLX_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK },
+   { "GL_ARB_texture_env_combine",
+     GLITZ_GLX_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK },
+   { "GL_ARB_texture_env_dot3", GLITZ_GLX_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK },
    { "GL_ARB_multisample", GLITZ_GLX_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint",
***************
*** 50,53 ****
--- 53,57 ----
    { "GL_ARB_vertex_program", GLITZ_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK },
    { "GL_ARB_fragment_program", GLITZ_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK },
+   { "GL_EXT_pixel_buffer_object", GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK },
    { NULL, 0 }
  };
***************
*** 135,138 ****
--- 139,161 ----
  
      if (screen_info->glx_feature_mask &
+         GLITZ_GLX_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK)
+       screen_info->feature_mask |= GLITZ_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK;
+     
+     if (screen_info->glx_feature_mask &
+         GLITZ_GLX_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK)
+       screen_info->feature_mask |= GLITZ_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK;
+       
+     if ((screen_info->feature_mask &
+          GLITZ_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK) &&
+         (screen_info->feature_mask &
+          GLITZ_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK)) {
+       glitz_gl_int_t max_texture_units;
+       
+       glGetIntegerv (GLITZ_GL_MAX_TEXTURE_UNITS, &max_texture_units);
+       if (max_texture_units >= 3)
+         screen_info->feature_mask |= GLITZ_FEATURE_COMPONENT_ALPHA_MASK;
+     }
+         
+     if (screen_info->glx_feature_mask &
          GLITZ_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK)
        screen_info->feature_mask |= GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK;
***************
*** 146,148 ****
--- 169,175 ----
        screen_info->feature_mask |= GLITZ_FEATURE_CONVOLUTION_FILTER_MASK;
    }
+ 
+   if (screen_info->glx_feature_mask &
+       GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
+     screen_info->feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  }

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_info.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glitz_glx_info.c	21 Jun 2004 21:26:56 -0000	1.10
--- glitz_glx_info.c	20 Jul 2004 07:51:14 -0000	1.11
***************
*** 43,48 ****
--- 43,50 ----
    (glitz_gl_vertex_2d_t) glVertex2d,
    (glitz_gl_tex_env_f_t) glTexEnvf,
+   (glitz_gl_tex_env_fv_t) glTexEnvfv,
    (glitz_gl_tex_coord_2d_t) glTexCoord2d,
    (glitz_gl_color_4us_t) glColor4us,
+   (glitz_gl_color_4d_t) glColor4d,
    (glitz_gl_scissor_t) glScissor,
    (glitz_gl_blend_func_t) glBlendFunc,
***************
*** 93,104 ****
    (glitz_gl_call_list_t) glCallList,
  
!   (glitz_gl_active_texture_arb_t) 0,
!   (glitz_gl_multi_tex_coord_2d_arb_t) 0,
!   (glitz_gl_gen_programs_arb_t) 0,
!   (glitz_gl_delete_programs_arb_t) 0,
!   (glitz_gl_program_string_arb_t) 0,
!   (glitz_gl_bind_program_arb_t) 0,
!   (glitz_gl_program_local_param_4d_arb_t) 0,
!   (glitz_gl_get_program_iv_arb_t) 0,
    1
  };
--- 95,112 ----
    (glitz_gl_call_list_t) glCallList,
  
!   (glitz_gl_active_texture_t) 0,
!   (glitz_gl_multi_tex_coord_2d_t) 0,
!   (glitz_gl_gen_programs_t) 0,
!   (glitz_gl_delete_programs_t) 0,
!   (glitz_gl_program_string_t) 0,
!   (glitz_gl_bind_program_t) 0,
!   (glitz_gl_program_local_param_4d_t) 0,
!   (glitz_gl_get_program_iv_t) 0,
!   (glitz_gl_gen_buffers_t) 0,
!   (glitz_gl_delete_buffers_t) 0,
!   (glitz_gl_bind_buffer_t) 0,
!   (glitz_gl_buffer_data_t) 0,
!   (glitz_gl_map_buffer_t) 0,
!   (glitz_gl_unmap_buffer_t) 0,
    1
  };
***************
*** 109,114 ****
    glitz_function_pointer_t address = NULL;
    
!   if (info->glx.get_proc_address_arb)
!     address = info->glx.get_proc_address_arb ((glitz_gl_ubyte_t *) name);
    
    if (!address) {
--- 117,122 ----
    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) {
***************
*** 142,146 ****
    info->glx.make_context_current = (glitz_glx_make_context_current_t)
      glitz_glx_get_proc_address (info, "glXMakeContextCurrent");
!   info->glx.get_proc_address_arb = (glitz_glx_get_proc_address_arb_t)
      glitz_glx_get_proc_address (info, "glXGetProcAddressARB");
    
--- 150,154 ----
    info->glx.make_context_current = (glitz_glx_make_context_current_t)
      glitz_glx_get_proc_address (info, "glXMakeContextCurrent");
!   info->glx.get_proc_address = (glitz_glx_get_proc_address_t)
      glitz_glx_get_proc_address (info, "glXGetProcAddressARB");
    
***************
*** 212,234 ****
  {
    glitz_glx_thread_info_t *thread_info;
      
    if (!tsd_initialized) {
-     thread_info = malloc (sizeof (glitz_glx_thread_info_t));
-     glitz_glx_thread_info_init (thread_info);
-       
      xthread_key_create (&info_tsd, glitz_glx_thread_info_destroy);
-     xthread_set_specific (info_tsd, thread_info);
-     
      tsd_initialized = 1;
!   } else {
!     void *p;
  
!     xthread_get_specific (info_tsd, &p);
      thread_info = (glitz_glx_thread_info_t *) p;
-   }
    
    if (thread_info->glx.need_lookup) {
!     if (gl_library)
!       thread_info->gl_library = strdup (gl_library);
      
      glitz_glx_proc_address_lookup (thread_info);
--- 220,250 ----
  {
    glitz_glx_thread_info_t *thread_info;
+   void *p;
      
    if (!tsd_initialized) {
      xthread_key_create (&info_tsd, glitz_glx_thread_info_destroy);
      tsd_initialized = 1;
!   }
  
!   xthread_get_specific (info_tsd, &p);
!   
!   if (p == NULL) {
!     thread_info = malloc (sizeof (glitz_glx_thread_info_t));
!     glitz_glx_thread_info_init (thread_info);
!     
!     xthread_set_specific (info_tsd, thread_info);
!   } else
      thread_info = (glitz_glx_thread_info_t *) p;
    
    if (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);
***************
*** 301,305 ****
      glitz_glx_screen_destroy (display_info->screens[i]);
  
!   free (display_info->screens);
  }
  
--- 317,324 ----
      glitz_glx_screen_destroy (display_info->screens[i]);
  
!   if (display_info->screens)
!     free (display_info->screens);
!   
!   free (display_info);
  }
  
***************
*** 403,407 ****
    screen_info->n_contexts = 0;
  
!   memset (&screen_info->programs, 0, sizeof (glitz_programs_t));
  
    glitz_glx_create_root_context (screen_info);
--- 422,426 ----
    screen_info->n_contexts = 0;
  
!   glitz_program_map_init (&screen_info->program_map);
  
    glitz_glx_create_root_context (screen_info);
***************
*** 440,445 ****
                        screen_info->root_drawable,
                        screen_info->root_context.context)) {
!     glitz_programs_fini (&screen_info->root_context.gl,
!                          &screen_info->programs);
    }
  
--- 459,464 ----
                        screen_info->root_drawable,
                        screen_info->root_context.context)) {
!     glitz_program_map_fini (&screen_info->root_context.gl,
!                             &screen_info->program_map);
    }
  

Index: glitz_glx_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_surface.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz_glx_surface.c	21 Jun 2004 21:26:56 -0000	1.13
--- glitz_glx_surface.c	20 Jul 2004 07:51:14 -0000	1.14
***************
*** 172,180 ****
    surface->base.feature_mask = surface->screen_info->feature_mask;
  
    surface->base.feature_mask &= ~GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK;
    surface->base.feature_mask &= ~GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
    surface->base.feature_mask &= ~GLITZ_FEATURE_CONVOLUTION_FILTER_MASK;
!   surface->base.feature_mask &= ~GLITZ_FEATURE_MULTISAMPLE_MASK;
!   surface->base.feature_mask &= ~GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
  
    if (surface->context->glx.need_lookup) {
--- 172,180 ----
    surface->base.feature_mask = surface->screen_info->feature_mask;
  
+   surface->base.feature_mask &= ~GLITZ_FEATURE_ARB_MULTITEXTURE_MASK;
    surface->base.feature_mask &= ~GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK;
    surface->base.feature_mask &= ~GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
    surface->base.feature_mask &= ~GLITZ_FEATURE_CONVOLUTION_FILTER_MASK;
!   surface->base.feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  
    if (surface->context->glx.need_lookup) {
***************
*** 186,224 ****
    if ((surface->screen_info->glx_feature_mask &
         GLITZ_GLX_FEATURE_ARB_RENDER_TEXTURE_MASK) &&
!       surface->context->glx.bind_tex_image_arb &&
!       surface->context->glx.release_tex_image_arb)
      surface->render_texture = 1;
  
!   if (surface->context->gl.active_texture_arb &&
!       surface->context->gl.multi_tex_coord_2d_arb &&
!       surface->context->gl.gen_programs_arb &&
!       surface->context->gl.delete_programs_arb &&
!       surface->context->gl.program_string_arb &&
!       surface->context->gl.bind_program_arb) {
!     if (surface->screen_info->feature_mask &
!         GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
!       surface->base.feature_mask |= GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
!     
!     if (surface->screen_info->feature_mask &
!         GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK)
!       surface->base.feature_mask |= GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK;
      
!     if ((surface->base.feature_mask & GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&
!         (surface->base.feature_mask &
!          GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
!         surface->context->gl.program_local_param_4d_arb &&
!         surface->context->texture_indirections >= 9) {
!       /* Convolution filter programs require support for at least nine
!          texture indirections. */
!       surface->base.feature_mask |= GLITZ_FEATURE_CONVOLUTION_FILTER_MASK;
      }
    }
  
!   if (surface->screen_info->feature_mask & GLITZ_FEATURE_MULTISAMPLE_MASK)
!     surface->base.feature_mask |= GLITZ_FEATURE_MULTISAMPLE_MASK;
!   
!   if (surface->screen_info->feature_mask &
!       GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK)
!     surface->base.feature_mask |= GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
  }
  
--- 186,232 ----
    if ((surface->screen_info->glx_feature_mask &
         GLITZ_GLX_FEATURE_ARB_RENDER_TEXTURE_MASK) &&
!       surface->context->glx.bind_tex_image &&
!       surface->context->glx.release_tex_image)
      surface->render_texture = 1;
  
!   if (surface->context->gl.active_texture &&
!       surface->context->gl.multi_tex_coord_2d) {
!     surface->base.feature_mask |= GLITZ_FEATURE_ARB_MULTITEXTURE_MASK;
! 
!     if (surface->context->gl.gen_programs &&
!         surface->context->gl.delete_programs &&
!         surface->context->gl.program_string &&
!         surface->context->gl.bind_program &&
!         surface->context->gl.program_local_param_4d) {
!       
!       if (surface->screen_info->feature_mask &
!           GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
!         surface->base.feature_mask |= GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
!       
!       if (surface->screen_info->feature_mask &
!           GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK)
!         surface->base.feature_mask |= GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK;
      
!       if ((surface->base.feature_mask &
!            GLITZ_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&
!           (surface->base.feature_mask &
!            GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
!           surface->context->texture_indirections >= 9) {
!         /* Convolution filter programs require support for at least nine
!            texture indirections. */
!         surface->base.feature_mask |= GLITZ_FEATURE_CONVOLUTION_FILTER_MASK;
!       }
      }
    }
  
!   if (surface->context->gl.gen_buffers &&
!       surface->context->gl.delete_buffers &&
!       surface->context->gl.bind_buffer &&
!       surface->context->gl.buffer_data &&
!       surface->context->gl.map_buffer &&
!       surface->context->gl.unmap_buffer)
!     if (surface->screen_info->feature_mask &
!         GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
!       surface->base.feature_mask |= GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
  }
  
***************
*** 248,252 ****
                        width,
                        height,
!                       &screen_info->programs,
                        screen_info->texture_mask);
    
--- 256,260 ----
                        width,
                        height,
!                       &screen_info->program_map,
                        screen_info->texture_mask);
    
***************
*** 319,323 ****
                        width,
                        height,
!                       &screen_info->programs,
                        screen_info->texture_mask);
    
--- 327,331 ----
                        width,
                        height,
!                       &screen_info->program_map,
                        screen_info->texture_mask);
    

Index: glitz_glxext.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glxext.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glitz_glxext.h	18 May 2004 15:01:50 -0000	1.5
--- glitz_glxext.h	20 Jul 2004 07:51:14 -0000	1.6
***************
*** 95,99 ****
  #endif
  
! typedef glitz_function_pointer_t (* glitz_glx_get_proc_address_arb_t)
       (const glitz_gl_ubyte_t *);
  typedef GLXFBConfig *(* glitz_glx_get_fbconfigs_t)
--- 95,99 ----
  #endif
  
! typedef glitz_function_pointer_t (* glitz_glx_get_proc_address_t)
       (const glitz_gl_ubyte_t *);
  typedef GLXFBConfig *(* glitz_glx_get_fbconfigs_t)
***************
*** 115,121 ****
  #endif
  
! typedef Bool *(* glitz_glx_bind_tex_image_arb_t)
       (Display *display, GLXPbuffer pbuffer, int buffer);
! typedef Bool (* glitz_glx_release_tex_image_arb_t)
       (Display *display, GLXPbuffer pbuffer, int buffer);
  
--- 115,121 ----
  #endif
  
! typedef Bool *(* glitz_glx_bind_tex_image_t)
       (Display *display, GLXPbuffer pbuffer, int buffer);
! typedef Bool (* glitz_glx_release_tex_image_t)
       (Display *display, GLXPbuffer pbuffer, int buffer);
  

Index: glitz_glxint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glxint.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glitz_glxint.h	28 May 2004 01:04:29 -0000	1.9
--- glitz_glxint.h	20 Jul 2004 07:51:14 -0000	1.10
***************
*** 45,52 ****
  #define GLITZ_GLX_FEATURE_MULTISAMPLE_FILTER_MASK      (1L <<  5)
  #define GLITZ_GLX_FEATURE_ARB_MULTITEXTURE_MASK        (1L <<  6)
! #define GLITZ_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L <<  7)
! #define GLITZ_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L <<  8)
! #define GLITZ_GLX_FEATURE_GLX13_MASK                   (1L <<  9)
! #define GLITZ_GLX_FEATURE_ARB_RENDER_TEXTURE_MASK      (1L << 10)
  
  typedef struct _glitz_glx_surface glitz_glx_surface_t;
--- 45,55 ----
  #define GLITZ_GLX_FEATURE_MULTISAMPLE_FILTER_MASK      (1L <<  5)
  #define GLITZ_GLX_FEATURE_ARB_MULTITEXTURE_MASK        (1L <<  6)
! #define GLITZ_GLX_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK (1L <<  7)
! #define GLITZ_GLX_FEATURE_ARB_TEXTURE_ENV_DOT3_MASK    (1L <<  8)
! #define GLITZ_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L <<  9)
! #define GLITZ_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 10)
! #define GLITZ_GLX_FEATURE_GLX13_MASK                   (1L << 11)
! #define GLITZ_GLX_FEATURE_ARB_RENDER_TEXTURE_MASK      (1L << 12)
! #define GLITZ_GLX_FEATURE_PIXEL_BUFFER_OBJECT_MASK     (1L << 13)
  
  typedef struct _glitz_glx_surface glitz_glx_surface_t;
***************
*** 55,59 ****
  
  typedef struct _glitz_glx_static_proc_address_list_t {
!   glitz_glx_get_proc_address_arb_t get_proc_address_arb;
    glitz_glx_get_fbconfigs_t get_fbconfigs;
    glitz_glx_get_fbconfig_attrib_t get_fbconfig_attrib;
--- 58,62 ----
  
  typedef struct _glitz_glx_static_proc_address_list_t {
!   glitz_glx_get_proc_address_t get_proc_address;
    glitz_glx_get_fbconfigs_t get_fbconfigs;
    glitz_glx_get_fbconfig_attrib_t get_fbconfig_attrib;
***************
*** 66,71 ****
  
  typedef struct _glitz_glx_proc_address_list_t {
!   glitz_glx_bind_tex_image_arb_t bind_tex_image_arb;
!   glitz_glx_release_tex_image_arb_t release_tex_image_arb;
    glitz_bool_t need_lookup;
  } glitz_glx_proc_address_list_t;
--- 69,74 ----
  
  typedef struct _glitz_glx_proc_address_list_t {
!   glitz_glx_bind_tex_image_t bind_tex_image;
!   glitz_glx_release_tex_image_t release_tex_image;
    glitz_bool_t need_lookup;
  } glitz_glx_proc_address_list_t;
***************
*** 121,125 ****
    long int texture_mask;
  
!   glitz_programs_t programs;
  };
  
--- 124,128 ----
    long int texture_mask;
  
!   glitz_program_map_t program_map;
  };
  

Index: glitz_pixel.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_pixel.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glitz_pixel.c	21 Jun 2004 21:26:56 -0000	1.1
--- glitz_pixel.c	20 Jul 2004 07:51:14 -0000	1.2
***************
*** 1,5 ****
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
!  *
   * Permission to use, copy, modify, distribute, and sell this software
   * and its documentation for any purpose is hereby granted without
--- 1,5 ----
  /*
!  * Copyright © 2004 David Reveman
!  * 
   * Permission to use, copy, modify, distribute, and sell this software
   * and its documentation for any purpose is hereby granted without
***************
*** 7,24 ****
   * and that both that copyright notice and this permission notice
   * appear in supporting documentation, and that the names of
!  * David Reveman and Peter Nilsson not be used in advertising or
!  * publicity pertaining to distribution of the software without
!  * specific, written prior permission. David Reveman and Peter Nilsson
!  * makes no representations about the suitability of this software for
!  * any purpose. It is provided "as is" without express or implied warranty.
   *
!  * DAVID REVEMAN AND PETER NILSSON DISCLAIMS ALL WARRANTIES WITH
!  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
!  * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DAVID REVEMAN AND
!  * PETER NILSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
!  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
!  * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
!  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
!  * PERFORMANCE OF THIS SOFTWARE.
   *
   * Author: David Reveman <c99drn at cs.umu.se>
--- 7,23 ----
   * and that both that copyright notice and this permission notice
   * appear in supporting documentation, and that the names of
!  * David Reveman not be used in advertising or publicity pertaining to
!  * distribution of the software without specific, written prior permission.
!  * David Reveman makes no representations about the suitability of this
!  * software for any purpose. It is provided "as is" without express or
!  * implied warranty.
   *
!  * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
!  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
!  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
!  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
!  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
!  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
!  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * Author: David Reveman <c99drn at cs.umu.se>
***************
*** 49,53 ****
          0x00000000
        },
!       0, 0,
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      },
--- 48,52 ----
          0x00000000
        },
!       0, 0, 0,
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      },
***************
*** 63,67 ****
          0x000000ff
        },
!       0, 0,
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      },
--- 62,66 ----
          0x000000ff
        },
!       0, 0, 0,
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      },
***************
*** 74,78 ****
      
      GLITZ_GL_UNSIGNED_BYTE
-     
    }, {
      {
--- 73,76 ----
***************
*** 84,88 ****
          0x000000ff
        },
!       0, 0,
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      },
--- 82,86 ----
          0x000000ff
        },
!       0, 0, 0,
        GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
      },
***************
*** 290,296 ****
                          glitz_image_t *dst,
                          int x_src,
-                         int y_src,
                          int x_dst,
-                         int y_dst,
                          int width,
                          int height)
--- 288,292 ----
***************
*** 357,365 ****
    for (y = 0; y < height; y++) {
      if (src->format->scanline_order != dst->format->scanline_order)
!       src_op.line = &src->data[(src->height - (y + y_src) - 1) * src_stride];
      else
!       src_op.line = &src->data[(y + y_src) * src_stride];
  
!     dst_op.line = &dst->data[(y + y_dst) * dst_stride];
      
      if (transform & GLITZ_TRANSFORM_PIXELS_MASK) {
--- 353,361 ----
    for (y = 0; y < height; y++) {
      if (src->format->scanline_order != dst->format->scanline_order)
!       src_op.line = &src->data[(src->height - y - 1) * src_stride];
      else
!       src_op.line = &src->data[y * src_stride];
  
!     dst_op.line = &dst->data[y * dst_stride];
      
      if (transform & GLITZ_TRANSFORM_PIXELS_MASK) {
***************
*** 411,414 ****
--- 407,648 ----
  }
  
+ struct _glitz_pixel_buffer {
+   glitz_gl_sizei_t size;
+   glitz_gl_uint_t name;
+   glitz_gl_enum_t target;
+   char *data;
+   int owns_data;
+   glitz_surface_t *surface;
+   glitz_pixel_format_t format;
+ };
+ 
+ glitz_pixel_buffer_t *
+ glitz_pixel_buffer_create (glitz_surface_t *surface,
+                            char *data,
+                            unsigned int size,
+                            glitz_buffer_hint_t hint)
+ {
+   glitz_pixel_buffer_t *buffer;
+   glitz_gl_enum_t usage;
+ 
+   buffer = malloc (sizeof (glitz_pixel_buffer_t));
+   if (buffer == NULL)
+     return NULL;
+ 
+   buffer->size = size;
+   buffer->name = 0;
+   
+   switch (hint) {
+   case GLITZ_PIXEL_BUFFER_HINT_STREAM_DRAW:
+     usage = GLITZ_GL_STREAM_DRAW;
+     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_STREAM_READ:
+     usage = GLITZ_GL_STREAM_READ;
+     buffer->target = GLITZ_GL_PIXEL_PACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_STREAM_COPY:
+     usage = GLITZ_GL_STREAM_COPY;
+     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_STATIC_DRAW:
+     usage = GLITZ_GL_STATIC_DRAW;
+     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_STATIC_READ:
+     usage = GLITZ_GL_STATIC_READ;
+     buffer->target = GLITZ_GL_PIXEL_PACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_STATIC_COPY:
+     usage = GLITZ_GL_STATIC_COPY;
+     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_DYNAMIC_DRAW:
+     usage = GLITZ_GL_DYNAMIC_DRAW;
+     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+     break;
+   case GLITZ_PIXEL_BUFFER_HINT_DYNAMIC_READ:
+     usage = GLITZ_GL_DYNAMIC_READ;
+     buffer->target = GLITZ_GL_PIXEL_PACK_BUFFER;
+     break;
+   default:
+     usage = GLITZ_GL_DYNAMIC_COPY;
+     buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+     break;
+   }
+ 
+   if (surface->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK) {
+     buffer->surface = surface;
+     glitz_surface_reference (surface);
+     
+     glitz_surface_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+     
+     surface->gl->gen_buffers (1, &buffer->name);
+     if (buffer->name) {
+       surface->gl->bind_buffer (buffer->target, buffer->name);
+       surface->gl->buffer_data (buffer->target, size, data, usage);
+     }
+     
+     glitz_surface_pop_current (surface); 
+   } else
+     buffer->surface = NULL;
+   
+   if (buffer->name == 0) {
+     buffer->data = malloc (size);
+     if (buffer->data == NULL) {
+       free (buffer);
+       return NULL;
+     }
+ 
+     if (data)
+       memcpy (buffer->data, data, size);
+     
+     buffer->owns_data = 1;
+   }
+   
+   buffer->format = _glitz_best_gl_pixel_format (surface->format)->pixel;
+   
+   return buffer;
+ }
+ 
+ glitz_pixel_buffer_t *
+ glitz_pixel_buffer_create_for_data (char *data,
+                                     glitz_pixel_format_t *format)
+ {
+   glitz_pixel_buffer_t *buffer;
+ 
+   buffer = malloc (sizeof (glitz_pixel_buffer_t));
+   if (buffer == NULL)
+     return NULL;
+ 
+   buffer->name = 0;
+   buffer->size = 0;
+   buffer->data = data;
+   buffer->owns_data = 0;
+   buffer->surface = NULL;
+   buffer->target = 0;
+   buffer->format = *format;
+ 
+   return buffer;
+ }
+ 
+ void
+ glitz_pixel_buffer_destroy (glitz_pixel_buffer_t *buffer)
+ {
+   glitz_surface_t *surface = buffer->surface;
+   
+   if (surface &&
+       surface->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK) {
+     glitz_surface_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+     
+     surface->gl->delete_buffers (1, &buffer->name);
+     
+     glitz_surface_pop_current (surface);
+     
+     glitz_surface_destroy (surface);
+   } else if (buffer->owns_data)
+     free (buffer->data);
+   
+   free (buffer);
+ }
+ 
+ void
+ glitz_pixel_buffer_set_format (glitz_pixel_buffer_t *buffer,
+                                glitz_pixel_format_t *format)
+ {
+   buffer->format = *format;
+ }
+ 
+ void
+ glitz_pixel_buffer_get_format (glitz_pixel_buffer_t *buffer,
+                                glitz_pixel_format_t *format)
+ {
+   *format = buffer->format;
+ }
+ 
+ char *
+ glitz_pixel_buffer_get_data (glitz_pixel_buffer_t *buffer,
+                              glitz_pixel_buffer_access_t access)
+ {
+   char *pointer = NULL;
+   glitz_surface_t *surface = buffer->surface;
+   
+   if (surface &&
+       surface->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK) {
+     glitz_gl_enum_t buffer_access;
+     
+     glitz_surface_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+ 
+     switch (access) {
+     case GLITZ_PIXEL_BUFFER_ACCESS_READ_ONLY:
+       buffer_access = GLITZ_GL_READ_ONLY;
+       break;
+     case GLITZ_PIXEL_BUFFER_ACCESS_WRITE_ONLY:
+       buffer_access = GLITZ_GL_WRITE_ONLY;
+       break;
+     default:
+       buffer_access = GLITZ_GL_READ_WRITE;
+       break;
+     }
+ 
+     surface->gl->bind_buffer (buffer->target, buffer->name);
+     pointer = (char *) surface->gl->map_buffer (buffer->target,
+                                                 buffer_access);
+     
+     glitz_surface_pop_current (surface);
+   }
+   
+   if (pointer == NULL)
+     pointer = buffer->data;
+   
+   return pointer;
+ }
+ 
+ void
+ glitz_pixel_buffer_put_back_data (glitz_pixel_buffer_t *buffer)
+ {
+   glitz_surface_t *surface = buffer->surface;
+   
+   if (surface &&
+       surface->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK) {
+     glitz_surface_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
+     
+     if (surface->gl->unmap_buffer (buffer->target)) {
+       /* don't know what to do here, maybe glitz_pixel_buffer_put_back_data
+          should return a status value */
+     }
+     surface->gl->bind_buffer (buffer->target, 0);
+     
+     glitz_surface_pop_current (surface);
+   }
+ }
+ 
+ char *
+ glitz_pixel_buffer_bind (glitz_pixel_buffer_t *buffer,
+                           glitz_gl_enum_t target)
+ {
+   glitz_surface_t *surface = buffer->surface;
+   
+   if (surface &&
+       surface->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK) {
+     surface->gl->bind_buffer (target, buffer->name);
+     buffer->target = target;
+     
+     return NULL;
+   }
+   
+   return buffer->data;
+ }
+ 
+ void
+ glitz_pixel_buffer_unbind (glitz_pixel_buffer_t *buffer)
+ {
+   glitz_surface_t *surface = buffer->surface;
+   
+   if (surface &&
+       surface->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
+     surface->gl->bind_buffer (buffer->target, 0);
+ }
+ 
  void
  glitz_put_pixels (glitz_surface_t *dst,
***************
*** 417,429 ****
                    int width,
                    int height,
!                   glitz_pixel_format_t *format,
!                   char *pixels)
  {
    glitz_gl_proc_address_list_t *gl;
    glitz_bool_t drawable;
!   char *data = NULL;
!   glitz_gl_pixel_format_t *gl_format = NULL;
    unsigned long transform = 0;
-   glitz_gl_enum_t image_format;
    int xoffset, bytes_per_line;
    
--- 651,661 ----
                    int width,
                    int height,
!                   glitz_pixel_buffer_t *buffer)
  {
    glitz_gl_proc_address_list_t *gl;
    glitz_bool_t drawable;
!   char *pixels, *data = NULL;
!   glitz_gl_pixel_format_t *format = NULL;
    unsigned long transform = 0;
    int xoffset, bytes_per_line;
    
***************
*** 439,451 ****
    gl = dst->gl;
  
!   if (format->scanline_order == GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN)
      transform |= GLITZ_TRANSFORM_SCANLINE_ORDER_MASK;
  
    /* find direct format */
!   gl_format = _glitz_find_gl_pixel_format (format);
!   if (gl_format == NULL) {
      transform |= GLITZ_TRANSFORM_PIXELS_MASK;
!     gl_format = _glitz_best_gl_pixel_format (dst->format);
    }
    
    if (transform) {
--- 671,688 ----
    gl = dst->gl;
  
!   if (buffer->format.scanline_order == GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN)
      transform |= GLITZ_TRANSFORM_SCANLINE_ORDER_MASK;
  
    /* find direct format */
!   format = _glitz_find_gl_pixel_format (&buffer->format);
!   if (format == NULL) {
      transform |= GLITZ_TRANSFORM_PIXELS_MASK;
!     format = _glitz_best_gl_pixel_format (dst->format);
    }
+ 
+   if (glitz_surface_try_push_current (dst, GLITZ_CN_SURFACE_DRAWABLE_CURRENT))
+     drawable = 1;
+   else
+     drawable = 0;
    
    if (transform) {
***************
*** 453,457 ****
      int stride;
      
!     stride = (((width * gl_format->pixel.masks.bpp) / 8) + 3) & -4;
      
      data = malloc (stride * height);
--- 690,694 ----
      int stride;
      
!     stride = (((width * format->pixel.masks.bpp) / 8) + 3) & -4;
      
      data = malloc (stride * height);
***************
*** 462,471 ****
  
      dst_image.data = data;
!     dst_image.format = &gl_format->pixel;
      dst_image.width = width;
      dst_image.height = height;
  
!     src_image.data = pixels;
!     src_image.format = format;
      src_image.width = width;
      src_image.height = height;
--- 699,712 ----
  
      dst_image.data = data;
!     dst_image.format = &format->pixel;
      dst_image.width = width;
      dst_image.height = height;
  
!     src_image.data =
!       glitz_pixel_buffer_get_data (buffer,
!                                    GLITZ_PIXEL_BUFFER_ACCESS_READ_ONLY);
!     src_image.data += buffer->format.skip_lines *
!       buffer->format.bytes_per_line;
!     src_image.format = &buffer->format;
      src_image.width = width;
      src_image.height = height;
***************
*** 474,493 ****
                              &src_image,
                              &dst_image,
!                             format->xoffset, 0,
!                             0, 0,
                              width, height);
      pixels = data;
      xoffset = 0;
      bytes_per_line = stride;
    } else {
!     xoffset = format->xoffset;
!     bytes_per_line = format->bytes_per_line;
    }
!   
!   if (glitz_surface_try_push_current (dst, GLITZ_CN_SURFACE_DRAWABLE_CURRENT))
!     drawable = 1;
!   else
!     drawable = 0;
!   
    glitz_texture_bind (gl, &dst->texture);
  
--- 715,734 ----
                              &src_image,
                              &dst_image,
!                             buffer->format.xoffset,
!                             0,
                              width, height);
+ 
+     glitz_pixel_buffer_put_back_data (buffer);
+                                  
      pixels = data;
      xoffset = 0;
      bytes_per_line = stride;
    } else {
!     xoffset = buffer->format.xoffset;
!     bytes_per_line = buffer->format.bytes_per_line;
!     pixels = glitz_pixel_buffer_bind (buffer, GLITZ_GL_PIXEL_UNPACK_BUFFER);
!     pixels += buffer->format.skip_lines * bytes_per_line;
    }
! 
    glitz_texture_bind (gl, &dst->texture);
  
***************
*** 506,527 ****
        gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
    } else
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
!     
!   if (gl_format->format == GLITZ_GL_ALPHA)
!     image_format = GLITZ_GL_LUMINANCE;
!   else
!     image_format = gl_format->format;
  
    gl->tex_sub_image_2d (dst->texture.target, 0,
                          x_dst, dst->height - y_dst - height,
                          width, height,
!                         image_format, gl_format->type,
                          pixels);
!   
    if (drawable) {
      glitz_point_t tl, br;
      
!     gl->tex_env_f (GLITZ_GL_TEXTURE_ENV,
!                    GLITZ_GL_TEXTURE_ENV_MODE,
                     GLITZ_GL_REPLACE);
      dst->gl->color_4us (0x0, 0x0, 0x0, 0xffff);
--- 747,762 ----
        gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
    } else
!     gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);    
  
    gl->tex_sub_image_2d (dst->texture.target, 0,
                          x_dst, dst->height - y_dst - height,
                          width, height,
!                         format->format, format->type,
                          pixels);
! 
    if (drawable) {
      glitz_point_t tl, br;
      
!     gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
                     GLITZ_GL_REPLACE);
      dst->gl->color_4us (0x0, 0x0, 0x0, 0xffff);
***************
*** 560,563 ****
--- 795,801 ----
    
    glitz_texture_unbind (dst->gl, &dst->texture);
+ 
+   if (transform == 0)
+     glitz_pixel_buffer_unbind (buffer);
    
    glitz_surface_pop_current (dst);
***************
*** 573,584 ****
                    int width,
                    int height,
!                   glitz_pixel_format_t *format,
!                   char *pixels)
  {
    glitz_gl_proc_address_list_t *gl;
    glitz_bool_t drawable;
    glitz_texture_t *texture = NULL;
!   char *p, *data = NULL;
!   glitz_gl_pixel_format_t *gl_format = NULL;
    unsigned long transform = 0;
    int src_x = 0, src_y = 0, src_w = width, src_h = height;
--- 811,821 ----
                    int width,
                    int height,
!                   glitz_pixel_buffer_t *buffer)
  {
    glitz_gl_proc_address_list_t *gl;
    glitz_bool_t drawable;
    glitz_texture_t *texture = NULL;
!   char *pixels, *data = NULL;
!   glitz_gl_pixel_format_t *format = NULL;
    unsigned long transform = 0;
    int src_x = 0, src_y = 0, src_w = width, src_h = height;
***************
*** 610,621 ****
    }
    
!   if (format->scanline_order == GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN)
      transform |= GLITZ_TRANSFORM_SCANLINE_ORDER_MASK;
    
    /* find direct format */
!   gl_format = _glitz_find_gl_pixel_format (format);
!   if (gl_format == NULL) {
      transform |= GLITZ_TRANSFORM_PIXELS_MASK;
!     gl_format = _glitz_best_gl_pixel_format (src->format);
    }
    
--- 847,858 ----
    }
    
!   if (buffer->format.scanline_order == GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN)
      transform |= GLITZ_TRANSFORM_SCANLINE_ORDER_MASK;
    
    /* find direct format */
!   format = _glitz_find_gl_pixel_format (&buffer->format);
!   if (format == NULL) {
      transform |= GLITZ_TRANSFORM_PIXELS_MASK;
!     format = _glitz_best_gl_pixel_format (src->format);
    }
    
***************
*** 630,634 ****
      }
  
!     stride = (((src_w * gl_format->pixel.masks.bpp) / 8) + 3) & -4;
  
      data = malloc (stride * src_h);
--- 867,871 ----
      }
  
!     stride = (((src_w * format->pixel.masks.bpp) / 8) + 3) & -4;
  
      data = malloc (stride * src_h);
***************
*** 637,647 ****
        return;
      }
!     p = data;
      xoffset = 0;
      bytes_per_line = stride;
    } else {
!     xoffset = format->xoffset;
!     bytes_per_line = format->bytes_per_line;
!     p = pixels;
    }
    
--- 874,885 ----
        return;
      }
!     pixels = data;
      xoffset = 0;
      bytes_per_line = stride;
    } else {
!     xoffset = buffer->format.xoffset;
!     bytes_per_line = buffer->format.bytes_per_line;
!     pixels = glitz_pixel_buffer_bind (buffer, GLITZ_GL_PIXEL_PACK_BUFFER);
!     pixels += buffer->format.skip_lines * bytes_per_line;
    }
    
***************
*** 665,690 ****
      gl->read_pixels (x_src, src->height - y_src - height,
                       width, height,
!                      gl_format->format, gl_format->type,
!                      p);
    } else {
      glitz_texture_bind (gl, texture);
      gl->get_tex_image (texture->target, 0,
!                        gl_format->format, gl_format->type,
!                        p);
      glitz_texture_unbind (gl, texture);
    }
  
-   glitz_surface_pop_current (src);
-   
    if (transform) {
      glitz_image_t src_image, dst_image;
  
!     src_image.data = data;
!     src_image.format = &gl_format->pixel;
      src_image.width = src_w;
      src_image.height = src_h;
  
!     dst_image.data = pixels;
!     dst_image.format = format;
      dst_image.width = width;
      dst_image.height = height;
--- 903,930 ----
      gl->read_pixels (x_src, src->height - y_src - height,
                       width, height,
!                      format->format, format->type,
!                      pixels);
    } else {
      glitz_texture_bind (gl, texture);
      gl->get_tex_image (texture->target, 0,
!                        format->format, format->type,
!                        pixels);
      glitz_texture_unbind (gl, texture);
    }
  
    if (transform) {
      glitz_image_t src_image, dst_image;
  
!     src_image.data = data + src_y * format->pixel.bytes_per_line;
!     src_image.format = &format->pixel;
      src_image.width = src_w;
      src_image.height = src_h;
  
!     dst_image.data =
!       glitz_pixel_buffer_get_data (buffer,
!                                    GLITZ_PIXEL_BUFFER_ACCESS_WRITE_ONLY);
!     dst_image.data += buffer->format.skip_lines *
!       buffer->format.bytes_per_line;
!     dst_image.format = &buffer->format;
      dst_image.width = width;
      dst_image.height = height;
***************
*** 693,700 ****
                              &src_image,
                              &dst_image,
!                             src_x, src_y,
!                             format->xoffset, 0,
                              width, height);
!   }
  
    if (data)
--- 933,945 ----
                              &src_image,
                              &dst_image,
!                             src_x,
!                             buffer->format.xoffset,
                              width, height);
! 
!     glitz_pixel_buffer_put_back_data (buffer);
!   } else
!     glitz_pixel_buffer_unbind (buffer);
! 
!   glitz_surface_pop_current (src);
  
    if (data)

Index: glitz_program.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_program.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glitz_program.c	11 Jun 2004 14:35:41 -0000	1.8
--- glitz_program.c	20 Jul 2004 07:51:14 -0000	1.9
***************
*** 1,5 ****
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
!  *
   * Permission to use, copy, modify, distribute, and sell this software
   * and its documentation for any purpose is hereby granted without
--- 1,5 ----
  /*
!  * Copyright © 2004 David Reveman
!  * 
   * Permission to use, copy, modify, distribute, and sell this software
[...1311 lines suppressed...]
  
!   return *program;
  }
  
! glitz_gl_uint_t
! glitz_get_fragment_program (glitz_render_op_t *op)
  {
!   glitz_gl_uint_t *program;
!   int index1 = _texture_index (op->src_texture);
!   int index2 = _texture_index (op->mask_texture);
!     
!   program = &op->dst->program_map->info[op->type].fragment[index1][index2];
    
!   if (*program == 0)
!     *program =
!       _glitz_create_fragment_program (op,
!                                       &_program_expand_map[index1][index2]);
  
!   return *program;
  }

Index: glitz_programmatic.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_programmatic.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glitz_programmatic.c	21 Jun 2004 21:26:56 -0000	1.9
--- glitz_programmatic.c	20 Jul 2004 07:51:14 -0000	1.10
***************
*** 32,37 ****
  #include "glitzint.h"
  
- #include <math.h>
- 
  static glitz_surface_t *
  _glitz_programmatic_surface_create_similar (void *abstract_templ,
--- 32,35 ----
***************
*** 50,57 ****
  
    switch (surface->type) {
!   case GLITZ_PROGRAMMATIC_SURFACE_LINEAR_TYPE:
      glitz_color_range_destroy (surface->u.linear.color_range);
      break;
!   case GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE:
      glitz_color_range_destroy (surface->u.radial.color_range);
    default:
--- 48,55 ----
  
    switch (surface->type) {
!   case GLITZ_PROGRAMMATIC_SURFACE_TYPE_LINEAR:
      glitz_color_range_destroy (surface->u.linear.color_range);
      break;
!   case GLITZ_PROGRAMMATIC_SURFACE_TYPE_RADIAL:
      glitz_color_range_destroy (surface->u.radial.color_range);
    default:
***************
*** 138,143 ****
    surface->base.texture.format = GLITZ_GL_RGBA;
    surface->base.texture.filter = surface->base.filter;
!   surface->base.texture.texcoord_width =
!     surface->base.texture.texcoord_height = 1.0;
    surface->base.texture.repeatable = surface->base.texture.repeat = 1;
    surface->matrix = identity;
--- 136,143 ----
    surface->base.texture.format = GLITZ_GL_RGBA;
    surface->base.texture.filter = surface->base.filter;
!   surface->base.texture.texcoord_width = surface->base.width =
!     surface->base.texture.width = MAXSHORT;
!   surface->base.texture.texcoord_height = surface->base.height =
!     surface->base.texture.height = MAXSHORT;
    surface->base.texture.repeatable = surface->base.texture.repeat = 1;
    surface->matrix = identity;
***************
*** 146,163 ****
  }
  
- void
- glitz_programmatic_surface_setup (glitz_surface_t *abstract_surface,
-                                   int width,
-                                   int height)
- {
-   glitz_programmatic_surface_t *surface =
-     (glitz_programmatic_surface_t *) abstract_surface;
-   
-   surface->base.texture.texcoord_width = surface->base.width =
-     surface->base.texture.width = width;
-   surface->base.texture.texcoord_height = surface->base.height =
-     surface->base.texture.height = height;
- }
- 
  glitz_surface_t *
  glitz_programmatic_surface_create_solid (glitz_color_t *color)
--- 146,149 ----
***************
*** 169,173 ****
      return NULL;
  
!   surface->type = GLITZ_PROGRAMMATIC_SURFACE_SOLID_TYPE;
    surface->u.solid.color = *color;
    
--- 155,159 ----
      return NULL;
  
!   surface->type = GLITZ_PROGRAMMATIC_SURFACE_TYPE_SOLID;
    surface->u.solid.color = *color;
    
***************
*** 186,190 ****
      return NULL;
  
!   surface->type = GLITZ_PROGRAMMATIC_SURFACE_LINEAR_TYPE;
    surface->u.linear.start = *start;
    surface->u.linear.stop = *stop;
--- 172,176 ----
      return NULL;
  
!   surface->type = GLITZ_PROGRAMMATIC_SURFACE_TYPE_LINEAR;
    surface->u.linear.start = *start;
    surface->u.linear.stop = *stop;
***************
*** 207,211 ****
      return NULL;
  
!   surface->type = GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE;
    surface->u.radial.center = *start;
    surface->u.radial.radius0 = radius0;
--- 193,197 ----
      return NULL;
  
!   surface->type = GLITZ_PROGRAMMATIC_SURFACE_TYPE_RADIAL;
    surface->u.radial.center = *start;
    surface->u.radial.radius0 = radius0;
***************
*** 232,314 ****
    surface->matrix.m[2][1] = FIXED_TO_DOUBLE (transform->matrix[1][2]);
  }
- 
- void
- glitz_programmatic_surface_bind (glitz_gl_proc_address_list_t *gl,
-                                  glitz_programmatic_surface_t *surface,
-                                  unsigned long feature_mask,
-                                  unsigned short opacity)
- {
-   switch (surface->type) {
-   case GLITZ_PROGRAMMATIC_SURFACE_SOLID_TYPE:
-     if (opacity != 0xffff) {
-       gl->color_4us (SHORT_MODULATE (surface->u.solid.color.red, opacity),
-                      SHORT_MODULATE (surface->u.solid.color.green, opacity),
-                      SHORT_MODULATE (surface->u.solid.color.blue, opacity),
-                      SHORT_MODULATE (surface->u.solid.color.alpha, opacity));
-     } else
-       gl->color_4us (surface->u.solid.color.red,
-                      surface->u.solid.color.green,
-                      surface->u.solid.color.blue,
-                      surface->u.solid.color.alpha);
-     break;
-   case GLITZ_PROGRAMMATIC_SURFACE_LINEAR_TYPE: {
-     glitz_point_t p1, p2;
-     double length, angle, start;
-     
-     p1.x = FIXED_TO_DOUBLE (surface->u.linear.start.x);
-     p1.y = FIXED_TO_DOUBLE (surface->u.linear.start.y);
-     p2.x = FIXED_TO_DOUBLE (surface->u.linear.stop.x);
-     p2.y = FIXED_TO_DOUBLE (surface->u.linear.stop.y);
-     
-     length = sqrt ((p2.x - p1.x) * (p2.x - p1.x) +
-                    (p2.y - p1.y) * (p2.y - p1.y));
-   
-     angle = -atan2 (p2.y - p1.y, p2.x - p1.x);
- 
-     start = cos (angle) * p1.x;
-     start += -sin (angle) * p1.y;
- 
-     gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 0,
-                                     start,
-                                     (length)? 1.0 / length: INT_MAX,
-                                     cos (angle),
-                                     -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);
- 
-     gl->active_texture_arb (GLITZ_GL_TEXTURE2_ARB);
-     glitz_color_range_bind (gl, surface->u.linear.color_range, feature_mask);
-     gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
-   } break;
-   case GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE:
-     gl->program_local_param_4d_arb
-       (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 0,
-        FIXED_TO_DOUBLE (surface->u.radial.center.x),
-        FIXED_TO_DOUBLE (surface->u.radial.center.y),
-        1.0 / (FIXED_TO_DOUBLE (surface->u.radial.radius1) -
-               FIXED_TO_DOUBLE (surface->u.radial.radius0)),
-        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);
- 
-     gl->active_texture_arb (GLITZ_GL_TEXTURE2_ARB);
-     glitz_color_range_bind (gl, surface->u.radial.color_range, feature_mask);
-     gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
-   default:
-     break;
-   }
- }
--- 218,219 ----

Index: glitz_render.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_render.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glitz_render.c	21 Jun 2004 21:26:56 -0000	1.2
--- glitz_render.c	20 Jul 2004 07:51:14 -0000	1.3
***************
*** 1,5 ****
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
!  *
   * Permission to use, copy, modify, distribute, and sell this software
   * and its documentation for any purpose is hereby granted without
--- 1,5 ----
  /*
!  * Copyright © 2004 David Reveman
!  * 
   * Permission to use, copy, modify, distribute, and sell this software
   * and its documentation for any purpose is hereby granted without
***************
*** 7,24 ****
   * and that both that copyright notice and this permission notice
   * appear in supporting documentation, and that the names of
!  * David Reveman and Peter Nilsson not be used in advertising or
!  * publicity pertaining to distribution of the software without
!  * specific, written prior permission. David Reveman and Peter Nilsson
!  * makes no representations about the suitability of this software for
!  * any purpose. It is provided "as is" without express or implied warranty.
   *
!  * DAVID REVEMAN AND PETER NILSSON DISCLAIMS ALL WARRANTIES WITH
!  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
!  * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DAVID REVEMAN AND
!  * PETER NILSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
!  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
!  * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
!  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
!  * PERFORMANCE OF THIS SOFTWARE.
   *
   * Author: David Reveman <c99drn at cs.umu.se>
--- 7,23 ----
   * and that both that copyright notice and this permission notice
   * appear in supporting documentation, and that the names of
!  * David Reveman not be used in advertising or publicity pertaining to
!  * distribution of the software without specific, written prior permission.
!  * David Reveman makes no representations about the suitability of this
!  * software for any purpose. It is provided "as is" without express or
!  * implied warranty.
   *
!  * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
!  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
!  * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
!  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
!  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
!  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
!  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * Author: David Reveman <c99drn at cs.umu.se>
***************
*** 31,197 ****
  #include "glitzint.h"
  
! glitz_render_type_t
! glitz_render_type (glitz_surface_t *src,
!                    glitz_surface_t *mask,
!                    glitz_surface_t *dst)
  {
!   int src_conv, mask_conv;
  
!   if (dst->feature_mask & GLITZ_FEATURE_CONVOLUTION_FILTER_MASK) {
!     src_conv = (src->convolution)? 1: 0;
!     mask_conv = (mask && mask->convolution)? 1: 0;
!   } else
!     src_conv = mask_conv = 0;
    
!   if (!mask) {
!     if (SURFACE_SOLID (src))
!       return GLITZ_RENDER_TYPE_SOLID;
!     else if ((!src_conv) && (!SURFACE_PROGRAMMATIC (src)))
!       return GLITZ_RENDER_TYPE_ARGB;
!     else if (SURFACE_PROGRAMMATIC (src) &&
!              (dst->feature_mask & GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK))
!       return GLITZ_RENDER_TYPE_SRC_PROGRAMMATIC;
    }
  
!   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))
!         return GLITZ_RENDER_TYPE_SOLID_A;
!       else if (!SURFACE_PROGRAMMATIC (src))
!         return GLITZ_RENDER_TYPE_ARGB_A;
!       else if (dst->feature_mask & GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
!         return GLITZ_RENDER_TYPE_SRC_PROGRAMMATIC;
!     } else if (dst->feature_mask & GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
!       if (!SURFACE_PROGRAMMATIC (src))
!         return GLITZ_RENDER_TYPE_ARGB_ARGB;
!       else
!         return GLITZ_RENDER_TYPE_SRC_PROGRAMMATIC;
!     }
    }
    
!   if (src_conv) {
!     if (mask && SURFACE_SOLID (mask)) {
!       return GLITZ_RENDER_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK;
!     } else if ((!mask) || (!SURFACE_PROGRAMMATIC (mask)))
!       return GLITZ_RENDER_TYPE_SRC_CONVOLUTION;
    }
      
!   if (mask_conv) {
!     if (SURFACE_SOLID (src)) {
!       return GLITZ_RENDER_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC;
!     } else if (!SURFACE_PROGRAMMATIC (src))
!       return GLITZ_RENDER_TYPE_MASK_CONVOLUTION;
    }
    
!   return GLITZ_RENDER_TYPE_NOT_SUPPORTED;
  }
  
! void
! glitz_render_enable (glitz_render_type_t type,
!                      glitz_surface_t *src,
!                      glitz_surface_t *mask,
!                      glitz_surface_t *dst,
!                      glitz_texture_t *src_texture,
!                      glitz_texture_t *mask_texture,
!                      unsigned short opacity)
  {
!   switch (type) {
!   case GLITZ_RENDER_TYPE_ARGB:
!     if (opacity != 0xffff) {
!       dst->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV,
!                           GLITZ_GL_TEXTURE_ENV_MODE,
!                           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:
!     glitz_program_enable_argb_argb (dst->gl, dst->programs,
!                                     src_texture, mask_texture);
!     break;
!   case GLITZ_RENDER_TYPE_SOLID_A:
!     glitz_programmatic_surface_bind (dst->gl,
!                                      (glitz_programmatic_surface_t *) src,
!                                      dst->feature_mask,
!                                      0xffff);
!     break;
!   case GLITZ_RENDER_TYPE_ARGB_A:
!     break;
!   case GLITZ_RENDER_TYPE_SOLID:
!     glitz_programmatic_surface_bind (dst->gl,
!                                      (glitz_programmatic_surface_t *) src,
!                                      dst->feature_mask,
!                                      opacity);
!     break;
!   case GLITZ_RENDER_TYPE_SRC_CONVOLUTION:
!   case GLITZ_RENDER_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK:
!     glitz_program_enable_convolution (dst->gl, dst->programs,
!                                       src, mask, src_texture, mask_texture,
!                                       GLITZ_PROGRAM_SRC_OPERATION_OFFSET, 1,
!                                       opacity);
!     break;
!   case GLITZ_RENDER_TYPE_MASK_CONVOLUTION:
!     glitz_program_enable_convolution (dst->gl, dst->programs,
!                                       src, mask, src_texture, mask_texture,
!                                       GLITZ_PROGRAM_MASK_OPERATION_OFFSET, 0,
!                                       0xffff);
!     break;
!   case GLITZ_RENDER_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC:
!     glitz_program_enable_convolution (dst->gl, dst->programs,
!                                       src, mask, src_texture, mask_texture,
!                                       GLITZ_PROGRAM_MASK_OPERATION_OFFSET, 2,
!                                       0xffff);
!     break;
!   case GLITZ_RENDER_TYPE_SRC_PROGRAMMATIC:
!     glitz_program_enable_programmatic (dst,
!                                        (glitz_programmatic_surface_t *) src,
!                                        src_texture, mask_texture,
!                                        GLITZ_PROGRAM_SRC_OPERATION_OFFSET,
!                                        opacity);
!     break;
!   case GLITZ_RENDER_TYPE_MASK_PROGRAMMATIC:
!     glitz_program_enable_programmatic (dst,
!                                        (glitz_programmatic_surface_t *) mask,
!                                        src_texture, mask_texture,
!                                        GLITZ_PROGRAM_MASK_OPERATION_OFFSET,
!                                        0xffff);
!     break;
!   case GLITZ_RENDER_TYPE_NOT_SUPPORTED:
!     break;
    }
  }
  
  void
! glitz_render_disable (glitz_render_type_t type,
!                       glitz_surface_t *dst)
  {
!   switch (type) {
!   case GLITZ_RENDER_TYPE_SRC_PROGRAMMATIC:
!   case GLITZ_RENDER_TYPE_MASK_PROGRAMMATIC:
!     dst->gl->active_texture_arb (GLITZ_GL_TEXTURE2_ARB);
!     dst->gl->bind_texture (GLITZ_GL_TEXTURE_1D, 0);
!     dst->gl->disable (GLITZ_GL_TEXTURE_1D);
!     dst->gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
!     /* fall-through */
!   case GLITZ_RENDER_TYPE_SRC_CONVOLUTION:
!   case GLITZ_RENDER_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK:
!   case GLITZ_RENDER_TYPE_MASK_CONVOLUTION:
!   case GLITZ_RENDER_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC:
!     dst->gl->bind_program_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 0);
!     dst->gl->disable (GLITZ_GL_FRAGMENT_PROGRAM_ARB);
!     dst->gl->bind_program_arb (GLITZ_GL_VERTEX_PROGRAM_ARB, 0);
!     dst->gl->disable (GLITZ_GL_VERTEX_PROGRAM_ARB);
!     break;
!   default:
!     break;
    }
  }
--- 30,696 ----
  #include "glitzint.h"
  
! #include <math.h>
! 
! static void
! _glitz_render_argb_solid (glitz_render_op_t *op)
  {
!   if (op->alpha_mask.alpha != 0xffff) {
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_MODULATE);
!     op->gl->color_4us (op->alpha_mask.alpha,
!                        op->alpha_mask.alpha,
!                        op->alpha_mask.alpha,
!                        op->alpha_mask.alpha);
!   } else {
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_REPLACE);
!     op->gl->color_4us (0x0, 0x0, 0x0, 0xffff);
!   }
! }
  
! static void
! _glitz_render_argb_argb (glitz_render_op_t *op)
! {
!   op->gl->active_texture (GLITZ_GL_TEXTURE0);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_REPLACE);  
!   op->gl->color_4us (0x0, 0x0, 0x0, 0xffff);
    
!   op->gl->active_texture (GLITZ_GL_TEXTURE1);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_COMBINE);
!   
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                      GLITZ_GL_MODULATE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                      GLITZ_GL_TEXTURE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                      GLITZ_GL_PREVIOUS);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                      GLITZ_GL_SRC_ALPHA);
!   
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                      GLITZ_GL_MODULATE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                      GLITZ_GL_TEXTURE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_ALPHA,
!                      GLITZ_GL_PREVIOUS);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                      GLITZ_GL_SRC_ALPHA);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_ALPHA,
!                      GLITZ_GL_SRC_ALPHA);
! }
! 
! static void
! _setup_x_argbc (glitz_render_op_t *op)
! {
!   op->gl->active_texture (GLITZ_GL_TEXTURE0);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_COMBINE);
!     
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                      GLITZ_GL_INTERPOLATE);
! 
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                      GLITZ_GL_TEXTURE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE2_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND2_RGB,
!                      GLITZ_GL_SRC_ALPHA);
! 
!   /* we don't care about the alpha channel, so lets do something (simple?) */
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                      GLITZ_GL_REPLACE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                      GLITZ_GL_SRC_ALPHA);
! 
!     
!   op->gl->active_texture (GLITZ_GL_TEXTURE1);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_COMBINE);
!   
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                      GLITZ_GL_DOT3_RGBA);
!     
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                      GLITZ_GL_PREVIOUS);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                      GLITZ_GL_SRC_COLOR);
! }
! 
! static void
! _glitz_render_argb_argbc (glitz_render_op_t *op)
! {
!   if (op->count == 0) {
!     _setup_x_argbc (op);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE2);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_MODULATE);
!   }
!     
!   if (op->alpha_mask.red) {
!     op->gl->color_4d (1.0, 0.5, 0.5, 0.5);
!   } else if (op->alpha_mask.green) {
!     op->gl->color_4d (0.5, 1.0, 0.5, 0.5);
!   } else if (op->alpha_mask.blue) {
!     op->gl->color_4d (0.5, 0.5, 1.0, 0.5);
!   } else {
!     op->gl->active_texture (GLITZ_GL_TEXTURE0);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_REPLACE);  
!     op->gl->color_4us (0x0, 0x0, 0x0, 0xffff);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE1);
!     glitz_texture_unbind (op->gl, op->src_texture);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE2);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_MODULATE);
    }
+ }
  
! 
! static void
! _glitz_render_solid_solid (glitz_render_op_t *op)
! {
!   op->gl->color_4us (SHORT_MULT (op->solid->red, op->alpha_mask.alpha),
!                      SHORT_MULT (op->solid->green, op->alpha_mask.alpha),
!                      SHORT_MULT (op->solid->blue, op->alpha_mask.alpha),
!                      SHORT_MULT (op->solid->alpha, op->alpha_mask.alpha));
! }
! 
! static void
! _glitz_render_solid_argb (glitz_render_op_t *op)
! { 
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_COMBINE);
!   
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                      GLITZ_GL_MODULATE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                      GLITZ_GL_TEXTURE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                      GLITZ_GL_SRC_ALPHA);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                      GLITZ_GL_SRC_COLOR);
! 
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                      GLITZ_GL_MODULATE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                      GLITZ_GL_TEXTURE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_ALPHA,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                      GLITZ_GL_SRC_ALPHA);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_ALPHA,
!                      GLITZ_GL_SRC_ALPHA);
!                        
!   op->gl->color_4us (op->solid->red,
!                      op->solid->green,
!                      op->solid->blue,
!                      op->solid->alpha);
! }
! 
! static void
! _glitz_render_solid_argbc (glitz_render_op_t *op)
! {
!   if (op->count == 0) {
!     glitz_gl_float_t color[4];
!     
!     _setup_x_argbc (op);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE2);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_COMBINE);
!   
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                        GLITZ_GL_MODULATE);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                        GLITZ_GL_PREVIOUS);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                        GLITZ_GL_CONSTANT);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                        GLITZ_GL_SRC_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                        GLITZ_GL_SRC_COLOR);
! 
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                        GLITZ_GL_MODULATE);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                        GLITZ_GL_PREVIOUS);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_ALPHA,
!                        GLITZ_GL_CONSTANT);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                        GLITZ_GL_SRC_ALPHA);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_ALPHA,
!                        GLITZ_GL_SRC_ALPHA);
! 
!     color[0] = (double) op->solid->red / 65536.0;
!     color[1] = (double) op->solid->green / 65536.0;
!     color[2] = (double) op->solid->blue / 65536.0;
!     color[3] = (double) op->solid->alpha / 65536.0;
!     
!     op->gl->tex_env_fv (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_COLOR,
!                         color);
    }
+     
+   if (op->alpha_mask.red) {
+     op->gl->color_4d (1.0, 0.5, 0.5, 0.5);
+   } else if (op->alpha_mask.green) {
+     op->gl->color_4d (0.5, 1.0, 0.5, 0.5);
+   } else if (op->alpha_mask.blue) {
+     op->gl->color_4d (0.5, 0.5, 1.0, 0.5);
+   } else {
+     op->gl->active_texture (GLITZ_GL_TEXTURE0);
+     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
+                        GLITZ_GL_MODULATE);
+     op->gl->color_4us (op->solid->red,
+                        op->solid->green,
+                        op->solid->blue,
+                        op->solid->alpha);
+     
+     op->gl->active_texture (GLITZ_GL_TEXTURE1);
+     glitz_texture_unbind (op->gl, op->src_texture);
+     
+     op->gl->active_texture (GLITZ_GL_TEXTURE2);
+     glitz_texture_unbind (op->gl, op->src_texture);
+   }
+ }
+ 
+ static void
+ _glitz_render_argbf (glitz_render_op_t *op)
+ {
+   if (op->count == 0) {
+     glitz_gl_uint_t vertex_program, fragment_program;
+ 
+     vertex_program = glitz_get_vertex_program (op);
+     fragment_program = glitz_get_fragment_program (op);
    
!     if (vertex_program && fragment_program) {
!       glitz_texture_t *texture = op->src_texture;
!       glitz_surface_t *surface = op->src;
! 
!       op->gl->enable (GLITZ_GL_VERTEX_PROGRAM);
!       op->gl->bind_program (GLITZ_GL_VERTEX_PROGRAM, vertex_program);
!       op->gl->program_local_param_4d (GLITZ_GL_VERTEX_PROGRAM, 0,
!                                       texture->texcoord_width /
!                                       (double) texture->width,
!                                       0.000, 0.0, 0.0);
!       op->gl->program_local_param_4d (GLITZ_GL_VERTEX_PROGRAM, 1,
!                                       0.000,
!                                       texture->texcoord_height /
!                                       (double) texture->height,
!                                       0.0, 0.0);
!     
!       op->gl->enable (GLITZ_GL_FRAGMENT_PROGRAM);
!       op->gl->bind_program (GLITZ_GL_FRAGMENT_PROGRAM, fragment_program);
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 0,
!                                       surface->convolution->m[0][0],
!                                       surface->convolution->m[0][1],
!                                       surface->convolution->m[0][2], 0.0);
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 1,
!                                       surface->convolution->m[1][0],
!                                       surface->convolution->m[1][1],
!                                       surface->convolution->m[1][2], 0.0);
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 2,
!                                       surface->convolution->m[2][0],
!                                       surface->convolution->m[2][1],
!                                       surface->convolution->m[2][2], 0.0);
!     }
! 
!     op->gl->color_4us (op->alpha_mask.red,
!                        op->alpha_mask.green,
!                        op->alpha_mask.blue,
!                        op->alpha_mask.alpha);
    }
+ }
+ 
+ static void
+ _glitz_end_f (glitz_render_op_t *op)
+ {
+   op->gl->bind_program (GLITZ_GL_FRAGMENT_PROGRAM, 0);
+   op->gl->disable (GLITZ_GL_FRAGMENT_PROGRAM);
+   op->gl->bind_program (GLITZ_GL_VERTEX_PROGRAM, 0);
+   op->gl->disable (GLITZ_GL_VERTEX_PROGRAM);
+ }
+ 
+ static void
+ _glitz_render_lgrad (glitz_render_op_t *op)
+ {
+   if (op->count == 0) {
+     glitz_gl_uint_t fragment_program;
+ 
+     fragment_program = glitz_get_fragment_program (op);
+   
+     if (fragment_program) {
+       glitz_programmatic_surface_t *surface =
+         (glitz_programmatic_surface_t *) op->src;
+       glitz_point_t p1, p2;
+       double length, angle, start;
      
!       op->gl->enable (GLITZ_GL_FRAGMENT_PROGRAM);
!       op->gl->bind_program (GLITZ_GL_FRAGMENT_PROGRAM, fragment_program);
! 
!       p1.x = FIXED_TO_DOUBLE (surface->u.linear.start.x);
!       p1.y = FIXED_TO_DOUBLE (surface->u.linear.start.y);
!       p2.x = FIXED_TO_DOUBLE (surface->u.linear.stop.x);
!       p2.y = FIXED_TO_DOUBLE (surface->u.linear.stop.y);
!     
!       length = sqrt ((p2.x - p1.x) * (p2.x - p1.x) +
!                      (p2.y - p1.y) * (p2.y - p1.y));
!       
!       angle = -atan2 (p2.y - p1.y, p2.x - p1.x);
!       
!       start = cos (angle) * p1.x;
!       start += -sin (angle) * p1.y;
!       
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 0, start,
!                                       (length)? 1.0 / length: INT_MAX,
!                                       cos (angle), -sin (angle));
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 1,
!                                       surface->matrix.m[0][0],
!                                       surface->matrix.m[0][1],
!                                       surface->matrix.m[1][0],
!                                       surface->matrix.m[1][1]);
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 2,
!                                       surface->matrix.m[2][0],
!                                       surface->matrix.m[2][1],
!                                       surface->base.height, 0.0);
!       
!       op->gl->active_texture (GLITZ_GL_TEXTURE2);
!       glitz_color_range_bind (op->gl, surface->u.linear.color_range,
!                               op->dst->feature_mask);
!       op->gl->active_texture (GLITZ_GL_TEXTURE0);
!     }
    }
+ 
+   op->gl->color_4us (op->alpha_mask.red,
+                      op->alpha_mask.green,
+                      op->alpha_mask.blue,
+                      op->alpha_mask.alpha);
+ }
+ 
+ static void
+ _glitz_render_rgrad (glitz_render_op_t *op)
+ {
+   if (op->count == 0) {
+     glitz_gl_uint_t fragment_program;
+ 
+     fragment_program = glitz_get_fragment_program (op);
    
!     if (fragment_program) {
!       glitz_programmatic_surface_t *surface =
!         (glitz_programmatic_surface_t *) op->src;
!       
!       op->gl->enable (GLITZ_GL_FRAGMENT_PROGRAM);
!       op->gl->bind_program (GLITZ_GL_FRAGMENT_PROGRAM, fragment_program);
! 
!       op->gl->program_local_param_4d
!         (GLITZ_GL_FRAGMENT_PROGRAM, 0,
!          FIXED_TO_DOUBLE (surface->u.radial.center.x),
!          FIXED_TO_DOUBLE (surface->u.radial.center.y),
!          1.0 / (FIXED_TO_DOUBLE (surface->u.radial.radius1) -
!                 FIXED_TO_DOUBLE (surface->u.radial.radius0)),
!          FIXED_TO_DOUBLE (surface->u.radial.radius0));
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 1,
!                                       surface->matrix.m[0][0],
!                                       surface->matrix.m[0][1],
!                                       surface->matrix.m[1][0],
!                                       surface->matrix.m[1][1]);
!       op->gl->program_local_param_4d (GLITZ_GL_FRAGMENT_PROGRAM, 2,
!                                       surface->matrix.m[2][0],
!                                       surface->matrix.m[2][1],
!                                       surface->base.height, 0.0);
!       
!       op->gl->active_texture (GLITZ_GL_TEXTURE2);
!       glitz_color_range_bind (op->gl, surface->u.radial.color_range,
!                               op->dst->feature_mask);
!       op->gl->active_texture (GLITZ_GL_TEXTURE0);
!     }
!   }
! 
!   op->gl->color_4us (op->alpha_mask.red,
!                      op->alpha_mask.green,
!                      op->alpha_mask.blue,
!                      op->alpha_mask.alpha);
  }
  
! static void
! _glitz_end_grad (glitz_render_op_t *op)
  {
!   op->gl->active_texture (GLITZ_GL_TEXTURE2);
!   op->gl->bind_texture (GLITZ_GL_TEXTURE_1D, 0);
!   op->gl->disable (GLITZ_GL_TEXTURE_1D);
!   op->gl->active_texture (GLITZ_GL_TEXTURE0);
!   op->gl->bind_program (GLITZ_GL_FRAGMENT_PROGRAM, 0);
!   op->gl->disable (GLITZ_GL_FRAGMENT_PROGRAM);
! }
! 
! static glitz_render_t
! _glitz_render_map[GLITZ_SURFACE_TYPES][GLITZ_SURFACE_TYPES] = {
!   {
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA, NULL, NULL, 0 }
!   }, {
!     { GLITZ_RENDER_TYPE_ARGB,       _glitz_render_argb_solid, NULL, 1 },
!     { GLITZ_RENDER_TYPE_ARGB_ARGB,  _glitz_render_argb_argb,  NULL, 2 },
!     { GLITZ_RENDER_TYPE_ARGB_ARGBC, _glitz_render_argb_argbc, NULL, 3 },
!     { GLITZ_RENDER_TYPE_NA,         NULL,                     NULL, 0 },
!     { GLITZ_RENDER_TYPE_ARGB_SOLID, _glitz_render_argb_solid, NULL, 1 },
!     { GLITZ_RENDER_TYPE_NA,         NULL,                     NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA,         NULL,                     NULL, 0 }
!   }, {
!     { GLITZ_RENDER_TYPE_ARGB,       _glitz_render_argb_solid, NULL, 1 },
!     { GLITZ_RENDER_TYPE_ARGB_ARGB,  _glitz_render_argb_argb,  NULL, 2 },
!     { GLITZ_RENDER_TYPE_ARGB_ARGBC, _glitz_render_argb_argbc, NULL, 3 },
!     { GLITZ_RENDER_TYPE_NA,         NULL,                     NULL, 0 },
!     { GLITZ_RENDER_TYPE_ARGB_SOLID, _glitz_render_argb_solid, NULL, 1 },
!     { GLITZ_RENDER_TYPE_NA,         NULL,                     NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA,         NULL,                     NULL, 0 }
!   }, {
!     { GLITZ_RENDER_TYPE_ARGBF,       _glitz_render_argbf, _glitz_end_f, 1 },
!     { GLITZ_RENDER_TYPE_ARGBF_ARGB,  _glitz_render_argbf, _glitz_end_f, 2 },
!     { GLITZ_RENDER_TYPE_ARGBF_ARGBC, _glitz_render_argbf, _glitz_end_f, 2 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,         0 },
!     { GLITZ_RENDER_TYPE_ARGBF_SOLID, _glitz_render_argbf, _glitz_end_f, 1 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,         0 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,         0 }
!   }, {
!     { GLITZ_RENDER_TYPE_SOLID,       _glitz_render_solid_solid, NULL, 0 },
!     { GLITZ_RENDER_TYPE_SOLID_ARGB,  _glitz_render_solid_argb,  NULL, 1 },
!     { GLITZ_RENDER_TYPE_SOLID_ARGBC, _glitz_render_solid_argbc, NULL, 3 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                      NULL, 0 },
!     { GLITZ_RENDER_TYPE_SOLID_SOLID, _glitz_render_solid_solid, NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                      NULL, 0 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                      NULL, 0 }
!   }, {
!     { GLITZ_RENDER_TYPE_LGRAD,       _glitz_render_lgrad, _glitz_end_grad, 0 },
!     { GLITZ_RENDER_TYPE_LGRAD_ARGB,  _glitz_render_lgrad, _glitz_end_grad, 2 },
!     { GLITZ_RENDER_TYPE_LGRAD_ARGBC, _glitz_render_lgrad, _glitz_end_grad, 2 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,            0 },
!     { GLITZ_RENDER_TYPE_LGRAD_SOLID, _glitz_render_lgrad, _glitz_end_grad, 1 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,            0 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,            0 }
!   }, {
!     { GLITZ_RENDER_TYPE_RGRAD,       _glitz_render_rgrad, _glitz_end_grad, 0 },
!     { GLITZ_RENDER_TYPE_RGRAD_ARGB,  _glitz_render_rgrad, _glitz_end_grad, 2 },
!     { GLITZ_RENDER_TYPE_RGRAD_ARGBC, _glitz_render_rgrad, _glitz_end_grad, 2 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,            0 },
!     { GLITZ_RENDER_TYPE_RGRAD_SOLID, _glitz_render_rgrad, _glitz_end_grad, 1 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,            0 },
!     { GLITZ_RENDER_TYPE_NA,          NULL,                NULL,            0 }
!   }
! };
!   
! #define MANUAL_REPEAT(surface) \
!   (((surface)->hint_mask & GLITZ_INT_HINT_REPEAT_MASK) && \
!    (!(surface)->texture.repeatable))
! 
! #define ROTATING_TRANSFORM(surface) \
!   ((surface)->transform && \
!    (((surface)->transform->m[0][1] != 0.0) || \
!    ((surface)->transform->m[1][0] != 0.0)))
! 
! #define SIMPLE_SURFACE(surface) \
!   ((!MANUAL_REPEAT (surface)) && (!ROTATING_TRANSFORM (surface)))
! 
! #define MULTI_TEXTURE(feature_mask, src, mask) \
!   (((feature_mask) & GLITZ_FEATURE_ARB_MULTITEXTURE_MASK) && \
!    (SIMPLE_SURFACE (src) && SIMPLE_SURFACE (mask)))
! 
! static glitz_surface_type_t
! _glitz_get_surface_type (unsigned long feature_mask,
!                          glitz_surface_t *surface)
! {
!   if (surface == NULL)
!     return GLITZ_SURFACE_TYPE_NULL;
!   
!   if (SURFACE_PROGRAMMATIC (surface)) {
!     if (SURFACE_SOLID (surface))
!       return GLITZ_SURFACE_TYPE_SOLID;
!     else if (feature_mask & GLITZ_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
!       if (SURFACE_LINEAR_GRADIENT (surface))
!         return GLITZ_SURFACE_TYPE_LGRAD;
!       else
!         return GLITZ_SURFACE_TYPE_RGRAD;
      }
!   } else {
!     if (!surface->convolution) {
!       if (SURFACE_COMPONENT_ALPHA (surface)) {
!         if (feature_mask & GLITZ_FEATURE_COMPONENT_ALPHA_MASK)
!           return GLITZ_SURFACE_TYPE_ARGBC;
!       } else
!         return GLITZ_SURFACE_TYPE_ARGB;
!       
!     } else if (feature_mask & GLITZ_FEATURE_CONVOLUTION_FILTER_MASK)
!       return GLITZ_SURFACE_TYPE_ARGBF;
    }
+   
+   return GLITZ_SURFACE_TYPE_NA;
  }
  
+ static glitz_color_t _default_alpha_mask = {
+   0x0000, 0x0000, 0x0000, 0xffff
+ };
+ 
  void
! glitz_render_op_init (glitz_render_op_t *op,
!                       glitz_surface_t **src,
!                       glitz_surface_t **mask,
!                       glitz_surface_t *dst,
!                       int *x_src,
!                       int *y_src,
!                       int *x_mask,
!                       int *y_mask)
  {
!   glitz_surface_type_t src_type;
!   glitz_surface_type_t mask_type;
!   glitz_render_t *render;
! 
!   op->type = GLITZ_RENDER_TYPE_NA;
!   op->render = NULL;
!   op->alpha_mask = _default_alpha_mask;
!   op->gl = dst->gl;
!   op->dst = dst;
!   op->src_texture = op->mask_texture = NULL;
!   op->count = 0;
!   op->src = *src;
!   op->mask = *mask;
!   op->solid = NULL;
!   op->component_alpha = GLITZ_COMPONENT_ALPHA_NONE;
!   
!   src_type = _glitz_get_surface_type (dst->feature_mask, *src);
!   if (src_type < 1)
!     return;
! 
!   mask_type = _glitz_get_surface_type (dst->feature_mask, *mask);
!   if (mask_type < 0)
!     return;
! 
!   render = &_glitz_render_map[src_type][mask_type];
!   if (render->type == GLITZ_RENDER_TYPE_NA) {
!     if (dst->feature_mask & GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK)
!       op->type = GLITZ_RENDER_TYPE_INTERMEDIATE;
!     
!     return;
!   }
! 
!   if (mask_type == GLITZ_SURFACE_TYPE_SOLID) {
!     op->alpha_mask.alpha =
!       ((glitz_programmatic_surface_t *) (op->mask))->u.solid.color.alpha;
!     *mask = NULL;
!   }
! 
!   if (src_type == GLITZ_SURFACE_TYPE_SOLID) {
!     op->solid = &((glitz_programmatic_surface_t *) (op->src))->u.solid.color;
! 
!     /* mask becomes source */
!     if (*mask) {
!       *src = *mask;
!       *mask = NULL;
!       *x_src = *x_mask;
!       *y_src = *y_mask;
!     }
    }
+   
+   if (mask_type != GLITZ_SURFACE_TYPE_NULL &&
+       mask_type != GLITZ_SURFACE_TYPE_SOLID) {
+     if (dst->feature_mask & GLITZ_FEATURE_ARB_TEXTURE_ENV_COMBINE_MASK) {
+       if (mask_type == GLITZ_SURFACE_TYPE_ARGBC) {
+         if (op->mask->format->alpha_size)
+           op->component_alpha = GLITZ_COMPONENT_ALPHA_ARGB;
+         else
+           op->component_alpha = GLITZ_COMPONENT_ALPHA_RGB;
+       }
+       
+       if (src_type != GLITZ_SURFACE_TYPE_SOLID) {
+         if (MULTI_TEXTURE (dst->feature_mask, *src, *mask))
+           op->render = render;
+         else if ((dst->feature_mask & GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK) &&
+                  (!SURFACE_COMPONENT_ALPHA (*mask)))
+           op->type = GLITZ_RENDER_TYPE_INTERMEDIATE;
+         
+       } else
+         op->render = render;
+     }
+   } else
+     op->render = render;
+ 
+   /* update source and mask */
+   op->src = *src;
+   op->mask = *mask;
+ 
+   if (op->render == render)
+     op->type = render->type;
+ }
+ 
+ void
+ glitz_render_op_set_textures (glitz_render_op_t *op,
+                               glitz_texture_t *src,
+                               glitz_texture_t *mask)
+ {
+   op->src_texture = src;
+   op->mask_texture = mask;
+ }
+ 
+ void
+ glitz_render_op_set_alpha_mask (glitz_render_op_t *op,
+                                 unsigned short red,
+                                 unsigned short green,
+                                 unsigned short blue,
+                                 unsigned short alpha)
+ {
+   op->alpha_mask.red = red;
+   op->alpha_mask.green = green;
+   op->alpha_mask.blue = blue;
+   op->alpha_mask.alpha = alpha;
+ }
+ 
+ void
+ glitz_render_op_get_alpha_mask (glitz_render_op_t *op,
+                                 unsigned short *red,
+                                 unsigned short *green,
+                                 unsigned short *blue,
+                                 unsigned short *alpha)
+ {
+   if (red) *red = op->alpha_mask.red;
+   if (green) *green = op->alpha_mask.green;
+   if (blue) *blue = op->alpha_mask.blue;
+   if (alpha) *alpha = op->alpha_mask.alpha;
+ }
+ 
+ void
+ glitz_render_enable (glitz_render_op_t *op)
+ {
+   op->render->enable (op);
+   op->count++;
+ }
+ 
+ void
+ glitz_render_disable (glitz_render_op_t *op)
+ {
+   if (op->render->disable)
+     op->render->disable (op);
  }

Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** glitz_surface.c	21 Jun 2004 21:26:56 -0000	1.14
--- glitz_surface.c	20 Jul 2004 07:51:14 -0000	1.15
***************
*** 44,58 ****
                      int width,
                      int height,
!                     glitz_programs_t *programs,
                      unsigned long texture_mask)
  {
    surface->backend = backend;
  
    surface->filter = GLITZ_FILTER_NEAREST;
    surface->polyedge = GLITZ_POLYEDGE_SMOOTH;
    surface->polyedge_smooth_hint = GLITZ_POLYEDGE_SMOOTH_HINT_GOOD;
    surface->polyopacity = 0xffff;
! 
!   surface->programs = programs;
    surface->format = format;
    surface->formats = formats;
--- 44,60 ----
                      int width,
                      int height,
!                     glitz_program_map_t *program_map,
                      unsigned long texture_mask)
  {
    surface->backend = backend;
  
+   surface->ref_count = 1;
+ 
    surface->filter = GLITZ_FILTER_NEAREST;
    surface->polyedge = GLITZ_POLYEDGE_SMOOTH;
    surface->polyedge_smooth_hint = GLITZ_POLYEDGE_SMOOTH_HINT_GOOD;
    surface->polyopacity = 0xffff;
!   
!   surface->program_map = program_map;
    surface->format = format;
    surface->formats = formats;
***************
*** 222,227 ****
--- 224,245 ----
  
  void
+ glitz_surface_reference (glitz_surface_t *surface)
+ {
+   if (surface == NULL)
+     return;
+ 
+   surface->ref_count++;
+ }
+ 
+ void
  glitz_surface_destroy (glitz_surface_t *surface)
  {
+   if (!surface)
+     return;
+ 
+   surface->ref_count--;
+   if (surface->ref_count)
+     return;
+   
    surface->backend->destroy (surface);
  }
***************
*** 386,389 ****
--- 404,422 ----
  
  void
+ glitz_surface_set_component_alpha (glitz_surface_t *surface,
+                                    glitz_bool_t component_alpha)
+ {
+   if (SURFACE_PROGRAMMATIC (surface))
+     return;
+ 
+   if (component_alpha && surface->format->red_size)
+     surface->hint_mask |= GLITZ_INT_HINT_COMPONENT_ALPHA_MASK;
+   else
+     surface->hint_mask &= ~GLITZ_INT_HINT_COMPONENT_ALPHA_MASK;
+     
+ }
+ slim_hidden_def(glitz_surface_set_component_alpha);
+ 
+ void
  glitz_surface_set_filter (glitz_surface_t *surface,
                            glitz_filter_t filter)

Index: glitz_texture.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_texture.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glitz_texture.c	21 Jun 2004 21:26:56 -0000	1.8
--- glitz_texture.c	20 Jul 2004 07:51:14 -0000	1.9
***************
*** 44,48 ****
        (!glitz_uint_is_power_of_two (height))) {
      if (target_mask & GLITZ_TEXTURE_TARGET_RECTANGLE_MASK)
!       *target = GLITZ_GL_TEXTURE_RECTANGLE_EXT;
    }
  }
--- 44,48 ----
        (!glitz_uint_is_power_of_two (height))) {
      if (target_mask & GLITZ_TEXTURE_TARGET_RECTANGLE_MASK)
!       *target = GLITZ_GL_TEXTURE_RECTANGLE;
    }
  }
***************
*** 180,184 ****
                      glitz_texture_t *texture)
  {  
!   gl->disable (GLITZ_GL_TEXTURE_RECTANGLE_EXT);
    gl->disable (GLITZ_GL_TEXTURE_2D);
  
--- 180,184 ----
                      glitz_texture_t *texture)
  {  
!   gl->disable (GLITZ_GL_TEXTURE_RECTANGLE);
    gl->disable (GLITZ_GL_TEXTURE_2D);
  

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** glitzint.h	21 Jun 2004 21:26:56 -0000	1.19
--- glitzint.h	20 Jul 2004 07:51:14 -0000	1.20
***************
*** 89,94 ****
--- 89,96 ----
    glitz_gl_vertex_2d_t vertex_2d;
    glitz_gl_tex_env_f_t tex_env_f;
+   glitz_gl_tex_env_fv_t tex_env_fv;
    glitz_gl_tex_coord_2d_t tex_coord_2d;
    glitz_gl_color_4us_t color_4us;
+   glitz_gl_color_4d_t color_4d;
    glitz_gl_scissor_t scissor;
    glitz_gl_blend_func_t blend_func;
***************
*** 139,207 ****
    glitz_gl_call_list_t call_list;
    
!   glitz_gl_active_texture_arb_t active_texture_arb;
!   glitz_gl_multi_tex_coord_2d_arb_t multi_tex_coord_2d_arb;
!   glitz_gl_gen_programs_arb_t gen_programs_arb;
!   glitz_gl_delete_programs_arb_t delete_programs_arb;
!   glitz_gl_program_string_arb_t program_string_arb;
!   glitz_gl_bind_program_arb_t bind_program_arb;
!   glitz_gl_program_local_param_4d_arb_t program_local_param_4d_arb;
!   glitz_gl_get_program_iv_arb_t get_program_iv_arb;
    glitz_bool_t need_lookup;
  } glitz_gl_proc_address_list_t;
  
! typedef enum {
!   GLITZ_PROGRAMMATIC_SURFACE_SOLID_TYPE = 0,
!   GLITZ_PROGRAMMATIC_SURFACE_LINEAR_TYPE,
!   GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE
! } glitz_programmatic_surface_type_t;
! 
! typedef enum {
!   GLITZ_RENDER_TYPE_NOT_SUPPORTED = 0,
!   GLITZ_RENDER_TYPE_SOLID,
!   GLITZ_RENDER_TYPE_SOLID_A,
!   GLITZ_RENDER_TYPE_ARGB,
!   GLITZ_RENDER_TYPE_ARGB_A,
!   GLITZ_RENDER_TYPE_ARGB_ARGB,
!   GLITZ_RENDER_TYPE_SRC_CONVOLUTION,
!   GLITZ_RENDER_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK,
!   GLITZ_RENDER_TYPE_MASK_CONVOLUTION,
!   GLITZ_RENDER_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC,
!   GLITZ_RENDER_TYPE_SRC_PROGRAMMATIC,
!   GLITZ_RENDER_TYPE_MASK_PROGRAMMATIC
! } glitz_render_type_t;
  
! #define GLITZ_PROGRAMMATIC_SURFACE_NUM \
!   (GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE + 1)
  
! #define GLITZ_PROGRAM_2DSRC_2DMASK_OFFSET     0
! #define GLITZ_PROGRAM_RECTSRC_2DMASK_OFFSET   1
! #define GLITZ_PROGRAM_2DSRC_RECTMASK_OFFSET   2
! #define GLITZ_PROGRAM_RECTSRC_RECTMASK_OFFSET 3
! #define GLITZ_PROGRAM_NOSRC_2DMASK_OFFSET     4
! #define GLITZ_PROGRAM_NOSRC_RECTMASK_OFFSET   5
! #define GLITZ_PROGRAM_2DSRC_NOMASK_OFFSET     6
! #define GLITZ_PROGRAM_RECTSRC_NOMASK_OFFSET   7
! #define GLITZ_PROGRAM_NOSRC_NOMASK_OFFSET     8
  
! #define GLITZ_PROGRAM_SRC_OPERATION_OFFSET  0
! #define GLITZ_PROGRAM_MASK_OPERATION_OFFSET 9
  
! #define GLITZ_VERTEX_PROGRAM_TYPES 2
! #define GLITZ_FRAGMENT_PROGRAM_TYPES 18
  
! #define GLITZ_CONVOLUTION_TYPES 2
! #define GLITZ_FRAGMENT_CONVOLUTION_PROGRAM_TYPES \
!   (GLITZ_FRAGMENT_PROGRAM_TYPES * GLITZ_CONVOLUTION_TYPES * 3)
! #define GLITZ_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES \
!   (GLITZ_FRAGMENT_PROGRAM_TYPES * GLITZ_PROGRAMMATIC_SURFACE_NUM)
  
! typedef struct _glitz_programs_t {
!   glitz_gl_uint_t vertex_convolution[GLITZ_VERTEX_PROGRAM_TYPES];
!   glitz_gl_uint_t fragment_simple[GLITZ_FRAGMENT_PROGRAM_TYPES];
!   glitz_gl_uint_t
!   fragment_convolution[GLITZ_FRAGMENT_CONVOLUTION_PROGRAM_TYPES];
!   glitz_gl_uint_t
!   fragment_programmatic[GLITZ_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES];
! } glitz_programs_t;
  
  typedef enum {
--- 141,212 ----
    glitz_gl_call_list_t call_list;
    
!   glitz_gl_active_texture_t active_texture;
!   glitz_gl_multi_tex_coord_2d_t multi_tex_coord_2d;
!   glitz_gl_gen_programs_t gen_programs;
!   glitz_gl_delete_programs_t delete_programs;
!   glitz_gl_program_string_t program_string;
!   glitz_gl_bind_program_t bind_program;
!   glitz_gl_program_local_param_4d_t program_local_param_4d;
!   glitz_gl_get_program_iv_t get_program_iv;
!   glitz_gl_gen_buffers_t gen_buffers;
!   glitz_gl_delete_buffers_t delete_buffers;
!   glitz_gl_bind_buffer_t bind_buffer;
!   glitz_gl_buffer_data_t buffer_data;
!   glitz_gl_map_buffer_t map_buffer;
!   glitz_gl_unmap_buffer_t unmap_buffer;
    glitz_bool_t need_lookup;
  } glitz_gl_proc_address_list_t;
  
! typedef int glitz_surface_type_t;
  
! #define GLITZ_SURFACE_TYPE_NA   -1
! #define GLITZ_SURFACE_TYPE_NULL  0
! #define GLITZ_SURFACE_TYPE_ARGB  1
! #define GLITZ_SURFACE_TYPE_ARGBC 2
! #define GLITZ_SURFACE_TYPE_ARGBF 3
! #define GLITZ_SURFACE_TYPE_SOLID 4
! #define GLITZ_SURFACE_TYPE_LGRAD 5
! #define GLITZ_SURFACE_TYPE_RGRAD 6
! #define GLITZ_SURFACE_TYPES      7
  
! typedef int glitz_render_type_t;
  
! #define GLITZ_RENDER_TYPE_NA            -1
! #define GLITZ_RENDER_TYPE_INTERMEDIATE   0
! #define GLITZ_RENDER_TYPE_ARGB           1
! #define GLITZ_RENDER_TYPE_ARGB_SOLID     2
! #define GLITZ_RENDER_TYPE_ARGB_ARGB      4
! #define GLITZ_RENDER_TYPE_ARGB_ARGBC     5
! #define GLITZ_RENDER_TYPE_ARGBF          6
! #define GLITZ_RENDER_TYPE_ARGBF_SOLID    7
! #define GLITZ_RENDER_TYPE_ARGBF_ARGB     9
! #define GLITZ_RENDER_TYPE_ARGBF_ARGBC   10
! #define GLITZ_RENDER_TYPE_SOLID         11
! #define GLITZ_RENDER_TYPE_SOLID_SOLID   12
! #define GLITZ_RENDER_TYPE_SOLID_ARGB    14
! #define GLITZ_RENDER_TYPE_SOLID_ARGBC   15
! #define GLITZ_RENDER_TYPE_LGRAD         16
! #define GLITZ_RENDER_TYPE_LGRAD_SOLID   17
! #define GLITZ_RENDER_TYPE_LGRAD_ARGB    19
! #define GLITZ_RENDER_TYPE_LGRAD_ARGBC   20
! #define GLITZ_RENDER_TYPE_RGRAD         21
! #define GLITZ_RENDER_TYPE_RGRAD_SOLID   22
! #define GLITZ_RENDER_TYPE_RGRAD_ARGB    24
! #define GLITZ_RENDER_TYPE_RGRAD_ARGBC   25
! #define GLITZ_RENDER_TYPES              26
  
! #define GLITZ_TEXTURE_NONE 0
! #define GLITZ_TEXTURE_2D   1
! #define GLITZ_TEXTURE_RECT 2
! #define GLITZ_TEXTURE_LAST 3
  
! typedef struct _glitz_program_info_t {
!   glitz_gl_uint_t vertex[GLITZ_TEXTURE_LAST][GLITZ_TEXTURE_LAST];
!   glitz_gl_uint_t fragment[GLITZ_TEXTURE_LAST][GLITZ_TEXTURE_LAST];
! } glitz_program_info_t;
  
! typedef struct _glitz_program_map_t {
!   glitz_program_info_t info[GLITZ_RENDER_TYPES];
! } glitz_program_map_t;
  
  typedef enum {
***************
*** 282,305 ****
  } glitz_surface_backend_t;
  
! #define GLITZ_INT_HINT_REPEAT_MASK         (1L << 5)
! #define GLITZ_INT_HINT_DIRTY_MASK          (1L << 6)
! #define GLITZ_INT_HINT_CLEAR_EXTERIOR_MASK (1L << 7)
  
  #define SURFACE_PROGRAMMATIC(surface) \
!   (surface->hint_mask & GLITZ_HINT_PROGRAMMATIC_MASK)
  
  #define SURFACE_SOLID(surface) \
!   ((surface->hint_mask & GLITZ_HINT_PROGRAMMATIC_MASK) && \
!    ((glitz_programmatic_surface_t *) surface)->type == \
!    GLITZ_PROGRAMMATIC_SURFACE_SOLID_TYPE)
  
  #define SURFACE_REPEAT(surface) \
!   (surface->hint_mask & GLITZ_INT_HINT_REPEAT_MASK)
  
  #define SURFACE_DIRTY(surface) \
!   (surface->hint_mask & GLITZ_INT_HINT_DIRTY_MASK)
  
  #define SURFACE_CLEAR_EXTERIOR(surface) \
!   (surface->hint_mask & GLITZ_INT_HINT_CLEAR_EXTERIOR_MASK)
  
  typedef struct _glitz_sample_offset {
--- 287,321 ----
  } glitz_surface_backend_t;
  
! #define GLITZ_INT_HINT_REPEAT_MASK          (1L << 5)
! #define GLITZ_INT_HINT_DIRTY_MASK           (1L << 6)
! #define GLITZ_INT_HINT_CLEAR_EXTERIOR_MASK  (1L << 7)
! #define GLITZ_INT_HINT_COMPONENT_ALPHA_MASK (1L << 8)
  
  #define SURFACE_PROGRAMMATIC(surface) \
!   ((surface)->hint_mask & GLITZ_HINT_PROGRAMMATIC_MASK)
  
  #define SURFACE_SOLID(surface) \
!   (((glitz_programmatic_surface_t *) (surface))->type == \
!    GLITZ_PROGRAMMATIC_SURFACE_TYPE_SOLID)
! 
! #define SURFACE_LINEAR_GRADIENT(surface) \
!   (((glitz_programmatic_surface_t *) (surface))->type == \
!    GLITZ_PROGRAMMATIC_SURFACE_TYPE_LINEAR)
! 
! #define SURFACE_RADIAL_GRADIENT(surface) \
!   (((glitz_programmatic_surface_t *) (surface))->type == \
!    GLITZ_PROGRAMMATIC_SURFACE_TYPE_RADIAL)
  
  #define SURFACE_REPEAT(surface) \
!   ((surface)->hint_mask & GLITZ_INT_HINT_REPEAT_MASK)
  
  #define SURFACE_DIRTY(surface) \
!   ((surface)->hint_mask & GLITZ_INT_HINT_DIRTY_MASK)
  
  #define SURFACE_CLEAR_EXTERIOR(surface) \
!   ((surface)->hint_mask & GLITZ_INT_HINT_CLEAR_EXTERIOR_MASK)
! 
! #define SURFACE_COMPONENT_ALPHA(surface) \
!   ((surface)->hint_mask & GLITZ_INT_HINT_COMPONENT_ALPHA_MASK)
  
  typedef struct _glitz_sample_offset {
***************
*** 320,323 ****
--- 336,340 ----
    const glitz_surface_backend_t *backend;
  
+   int ref_count;
    glitz_format_t *format;
    glitz_format_t *formats;
***************
*** 334,338 ****
    glitz_bounding_box_t dirty_box;
    glitz_gl_proc_address_list_t *gl;
!   glitz_programs_t *programs;
    glitz_matrix_t *convolution;
    unsigned int stencil_masks[GLITZ_N_STENCIL_MASKS];
--- 351,355 ----
    glitz_bounding_box_t dirty_box;
    glitz_gl_proc_address_list_t *gl;
!   glitz_program_map_t *program_map;
    glitz_matrix_t *convolution;
    unsigned int stencil_masks[GLITZ_N_STENCIL_MASKS];
***************
*** 345,363 ****
  };
  
! #define GLITZ_COLOR_RANGE_UPDATE_TEXTURE_MASK (1L << 0)
! #define GLITZ_COLOR_RANGE_UPDATE_FILTER_MASK  (1L << 1)
! #define GLITZ_COLOR_RANGE_UPDATE_EXTEND_MASK  (1L << 2)
! #define GLITZ_COLOR_RANGE_UPDATE_ALL_MASK     ((1L << 3) - 1)
! 
! struct _glitz_color_range {
!   unsigned char *data;
!   unsigned int size;
!   glitz_gl_uint_t texture;
!   glitz_filter_t filter;
!   glitz_extend_t extend;
!   unsigned long update_mask;
!   unsigned int ref_count;
!   glitz_gl_delete_textures_t delete_textures;
! };
  
  typedef struct _glitz_programmatic_surface_t {
--- 362,370 ----
  };
  
! typedef enum {
!   GLITZ_PROGRAMMATIC_SURFACE_TYPE_SOLID = 0,
!   GLITZ_PROGRAMMATIC_SURFACE_TYPE_LINEAR,
!   GLITZ_PROGRAMMATIC_SURFACE_TYPE_RADIAL
! } glitz_programmatic_surface_type_t;
  
  typedef struct _glitz_programmatic_surface_t {
***************
*** 385,388 ****
--- 392,428 ----
  } glitz_programmatic_surface_t;
  
+ 
+ typedef struct _glitz_render_op_t glitz_render_op_t;
+ 
+ typedef void (*glitz_render_function_t) (glitz_render_op_t *);
+ 
+ typedef struct _glitz_render_t {
+   glitz_render_type_t type;
+   glitz_render_function_t enable;
+   glitz_render_function_t disable;
+   int texture_units;
+ } glitz_render_t;
+ 
+ typedef enum {
+   GLITZ_COMPONENT_ALPHA_NONE = 0,
+   GLITZ_COMPONENT_ALPHA_RGB,
+   GLITZ_COMPONENT_ALPHA_ARGB
+ } glitz_component_alpha_type_t;
+ 
+ struct _glitz_render_op_t {
+   glitz_render_type_t type;
+   glitz_render_t *render;
+   glitz_gl_proc_address_list_t *gl;
+   glitz_surface_t *src;
+   glitz_surface_t *mask;
+   glitz_surface_t *dst;
+   glitz_texture_t *src_texture;
+   glitz_texture_t *mask_texture;
+   glitz_color_t *solid;
+   glitz_color_t alpha_mask;
+   glitz_component_alpha_type_t component_alpha;
+   int count;
+ };
+ 
  typedef struct _glitz_extension_map {
    char *name;
***************
*** 515,519 ****
                      int width,
                      int height,
!                     glitz_programs_t *programs,
                      unsigned long texture_mask);
  
--- 555,559 ----
                      int width,
                      int height,
!                     glitz_program_map_t *program_map,
                      unsigned long texture_mask);
  
***************
*** 528,531 ****
--- 568,574 ----
  
  extern void __internal_linkage
+ glitz_surface_reference (glitz_surface_t *surface);
+ 
+ extern void __internal_linkage
  glitz_surface_destory (glitz_surface_t *surface);
  
***************
*** 601,617 ****
  
  void
! glitz_programs_fini (glitz_gl_proc_address_list_t *gl,
!                      glitz_programs_t *programs);
  
! extern void __internal_linkage
! glitz_programmatic_surface_setup (glitz_surface_t *abstract_surface,
!                                   int width,
!                                   int height);
  
! extern void __internal_linkage
! glitz_programmatic_surface_bind (glitz_gl_proc_address_list_t *proc_address,
!                                  glitz_programmatic_surface_t *surface,
!                                  unsigned long feature_mask,
!                                  unsigned short opacity);
  
  extern glitz_surface_t *__internal_linkage
--- 644,658 ----
  
  void
! glitz_program_map_init (glitz_program_map_t *map);
!      
! void
! glitz_program_map_fini (glitz_gl_proc_address_list_t *gl,
!                         glitz_program_map_t *map);
  
! extern glitz_gl_uint_t __internal_linkage
! glitz_get_vertex_program (glitz_render_op_t *op);
  
! extern glitz_gl_uint_t __internal_linkage
! glitz_get_fragment_program (glitz_render_op_t *op);
  
  extern glitz_surface_t *__internal_linkage
***************
*** 668,694 ****
  
  extern void __internal_linkage
! glitz_program_enable_argb_argb (glitz_gl_proc_address_list_t *gl,
!                                 glitz_programs_t *programs,
!                                 glitz_texture_t *src_texture,
!                                 glitz_texture_t *mask_texture);
! 
! extern void __internal_linkage
! glitz_program_enable_convolution (glitz_gl_proc_address_list_t *gl,
!                                   glitz_programs_t *programs,
!                                   glitz_surface_t *src,
!                                   glitz_surface_t *mask,
!                                   glitz_texture_t *src_texture,
!                                   glitz_texture_t *mask_texture,
!                                   int offset,
!                                   int solid_offset,
!                                   unsigned short opacity);
  
  extern void __internal_linkage
! glitz_program_enable_programmatic (glitz_surface_t *dst,
!                                    glitz_programmatic_surface_t *surface,
!                                    glitz_texture_t *src_texture,
!                                    glitz_texture_t *mask_texture,
!                                    int offset,
!                                    unsigned short opacity);
  
  extern void __internal_linkage
--- 709,716 ----
  
  extern void __internal_linkage
! glitz_program_enable_convolution (glitz_render_op_t *op);
  
  extern void __internal_linkage
! glitz_program_enable_programmatic (glitz_render_op_t *op);
  
  extern void __internal_linkage
***************
*** 711,731 ****
                           int n_points);
  
! extern glitz_render_type_t __internal_linkage
! glitz_render_type (glitz_surface_t *dst,
!                    glitz_surface_t *src,
!                    glitz_surface_t *mask);
  
  extern void __internal_linkage
! glitz_render_enable (glitz_render_type_t type,
!                      glitz_surface_t *src,
!                      glitz_surface_t *mask,
!                      glitz_surface_t *dst,
!                      glitz_texture_t *src_texture,
!                      glitz_texture_t *mask_texture,
!                      unsigned short opacity);
  
  extern void __internal_linkage
! glitz_render_disable (glitz_render_type_t type,
!                       glitz_surface_t *dst);
  
  #define MAXSHORT SHRT_MAX
--- 733,778 ----
                           int n_points);
  
! extern void __internal_linkage
! glitz_render_op_init (glitz_render_op_t *op,
!                       glitz_surface_t **src,
!                       glitz_surface_t **mask,
!                       glitz_surface_t *dst,
!                       int *x_src,
!                       int *y_src,
!                       int *x_mask,
!                       int *y_mask);
  
  extern void __internal_linkage
! glitz_render_op_set_textures (glitz_render_op_t *op,
!                               glitz_texture_t *src,
!                               glitz_texture_t *mask);
  
  extern void __internal_linkage
! glitz_render_op_set_alpha_mask (glitz_render_op_t *op,
!                                 unsigned short red,
!                                 unsigned short green,
!                                 unsigned short blue,
!                                 unsigned short alpha);
! 
! extern void __internal_linkage
! glitz_render_op_get_alpha_mask (glitz_render_op_t *op,
!                                 unsigned short *red,
!                                 unsigned short *green,
!                                 unsigned short *blue,
!                                 unsigned short *alpha);
! 
! extern void __internal_linkage
! glitz_render_enable (glitz_render_op_t *op);
! 
! extern void __internal_linkage
! glitz_render_disable (glitz_render_op_t *op);
! 
! extern char *__internal_linkage
! glitz_pixel_buffer_bind (glitz_pixel_buffer_t *buffer,
!                          glitz_gl_enum_t target);
! 
! extern void __internal_linkage
! glitz_pixel_buffer_unbind (glitz_pixel_buffer_t *buffer);
! 
  
  #define MAXSHORT SHRT_MAX
***************
*** 794,799 ****
  #define DOUBLE_TO_FIXED(f) ((int) ((f) * 65536))
  
! #define SHORT_MODULATE(s1, s2) \
!   ((unsigned short) (((unsigned int) s1 * s2) / 0xffff))
  
  typedef void (*glitz_function_pointer_t) (void);
--- 841,847 ----
  #define DOUBLE_TO_FIXED(f) ((int) ((f) * 65536))
  
! #define SHORT_MULT(s1, s2) \
!   ((s1 == 0xffff)? s2: ((s2 == 0xffff)? s1: \
!   ((unsigned short) (((unsigned int) s1 * s2) / 0xffff))))
  
  typedef void (*glitz_function_pointer_t) (void);
***************
*** 809,812 ****
--- 857,861 ----
  slim_hidden_proto(glitz_surface_set_convolution)
  slim_hidden_proto(glitz_surface_set_repeat)
+ slim_hidden_proto(glitz_surface_set_component_alpha)
  slim_hidden_proto(glitz_surface_set_filter)
  slim_hidden_proto(glitz_surface_set_polyedge)




More information about the cairo-commit mailing list