[cairo-commit] libglc/src glc.c,1.17,1.18 glc.h,1.12,1.13 glc_agl_extension.c,1.3,1.4 glc_agl_info.c,1.5,1.6 glc_agl_surface.c,1.7,1.8 glc_glx_context.c,1.10,1.11 glc_glx_extension.c,1.9,1.10 glc_glx_info.c,1.10,1.11 glc_glx_surface.c,1.15,1.16 glc_matrix.c,1.2,1.3 glc_program.c,1.2,1.3 glc_surface.c,1.16,1.17 glc_util.c,1.8,1.9 glcint.h,1.17,1.18

David Reveman commit at pdx.freedesktop.org
Mon Aug 15 11:12:59 PDT 2005


Committed by: davidr

Update of /cvs/cairo/libglc/src
In directory pdx:/tmp/cvs-serv11289/src

Modified Files:
	glc.c glc.h glc_agl_extension.c glc_agl_info.c 
	glc_agl_surface.c glc_glx_context.c glc_glx_extension.c 
	glc_glx_info.c glc_glx_surface.c glc_matrix.c glc_program.c 
	glc_surface.c glc_util.c glcint.h 
Log Message:
Added convolution filter support

Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** a/glc.c	16 Feb 2004 22:02:40 -0000	1.17
--- b/glc.c	20 Feb 2004 17:40:57 -0000	1.18
***************
*** 46,76 ****
    (surface->repeat && (!texture->repeatable))
  
! #define TRANSLATE(surface) \
    (surface->transform && \
!    (surface->transform->m[0][0] == 1.0) && \
!    (surface->transform->m[0][1] == 0.0) && \
!    (surface->transform->m[1][0] == 0.0) && \
!    (surface->transform->m[1][1] == 1.0))
  
  /* This version of composite uses fragment programs for direct
!    Porter-Duff compositing. It can not handle other transformations
!    than translation and will fall back to regular composite function
!    if this is the case.
  
!    TODO: Add support for manual repeat to this function.
  */
  static glc_bool_t
! _glc_program_composite (glc_operator_t op,
!                         glc_surface_t *src,
!                         glc_surface_t *mask,
!                         glc_surface_t *dst,
!                         int x_src,
!                         int y_src,
!                         int x_mask,
!                         int y_mask,
!                         int x_dst,
!                         int y_dst,
!                         int width,
!                         int height)
  {
    
--- 46,75 ----
    (surface->repeat && (!texture->repeatable))
  
! #define ROTATE(surface) \
    (surface->transform && \
!    ((surface->transform->m[0][1] != 0.0) || \
!    (surface->transform->m[1][0] != 0.0)))
  
  /* This version of composite uses fragment programs for direct
!    Porter-Duff compositing. It cannot handle rotating transformations
!    and only one of source and mask can be a transformed the other
!    surface must be repeating. Function will fall back to regular composite
!    function if this isn't the case.
  
!    TODO: Add manual repeat support.
  */
  static glc_bool_t
! _glc_composite_direct (glc_operator_t op,
!                        glc_surface_t *src,
!                        glc_surface_t *mask,
!                        glc_surface_t *dst,
!                        int x_src,
!                        int y_src,
!                        int x_mask,
!                        int y_mask,
!                        int x_dst,
!                        int y_dst,
!                        int width,
!                        int height)
  {
    
***************
*** 78,96 ****
    glc_texture_t *src_texture;
    glc_texture_t *mask_texture;
!   glc_region_box_t src_region, mask_region, dst_region;
!   glc_point_t src_tl, src_br, mask_tl, mask_br;
  
    if (TRANSFORM (src) || TRANSFORM (mask)) {
! 
!     /* If transform is a simple integer translation we can emulate this
!        by shifting destination coordinates. */
!     if ((!TRANSFORM (mask)) && TRANSLATE (src) &&
!         (((double) ((int) src->transform->m[2][0])) ==
!          src->transform->m[2][0]) &&
!         (((double) ((int) src->transform->m[2][1])) ==
!          src->transform->m[2][1])) {
!       x_dst += (int) src->transform->m[2][0];
!       y_dst += (int) src->transform->m[2][1];
!     } else
        return 0;
    }
--- 77,95 ----
    glc_texture_t *src_texture;
    glc_texture_t *mask_texture;
!   glc_sub_pixel_region_box_t src_region, mask_region, dst_region;
!   glc_region_box_t dirty_region;
!   glc_point_t src_tl, src_br, mask_tl, mask_br, translate_src,
!     translate_mask;
!   double src_width, src_height, mask_width, mask_height;
  
+   /* We cannot continue if we have a rotating transformation or
+      if both surfaces have transformations or the surface not being
+      transformed isn't repeating. */
    if (TRANSFORM (src) || TRANSFORM (mask)) {
!     if (ROTATE (src) || ROTATE (mask))
!       return 0;
!     
!     if ((TRANSFORM (src) && (TRANSFORM (mask) || (!REPEAT (mask)))) ||
!         (TRANSFORM (mask) && (TRANSFORM (src) || (!REPEAT (src)))))
        return 0;
    }
***************
*** 99,104 ****
    mask_texture = glc_surface_get_texture (mask);
  
!   if (MANUALREPEAT (src, src_texture) ||
!       MANUALREPEAT (mask, mask_texture))
      return 0;
  
--- 98,102 ----
    mask_texture = glc_surface_get_texture (mask);
  
!   if (MANUALREPEAT (src, src_texture) || MANUALREPEAT (mask, mask_texture))
      return 0;
  
***************
*** 110,115 ****
    glDisable (GL_SCISSOR_TEST);
  
!   if (!glc_surface_enable_program (dst, src_texture, mask_texture))
      return 0;
  
    glc_set_operator (op);
--- 108,115 ----
    glDisable (GL_SCISSOR_TEST);
  
!   if (!glc_surface_enable_program (src, src_texture, mask_texture)) {
!     glc_surface_pop_current (dst);
      return 0;
+   }
  
    glc_set_operator (op);
***************
*** 120,124 ****
    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
!   glc_texture_ensure_filter (src_texture, GLC_FILTER_NEAREST);
    glc_texture_ensure_repeat (src_texture, src->repeat);
  
--- 120,128 ----
    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
!   if (TRANSFORM (src))
!     glc_texture_ensure_filter (src_texture, src->filter);
!   else
!     glc_texture_ensure_filter (src_texture, GLC_FILTER_NEAREST);
!     
    glc_texture_ensure_repeat (src_texture, src->repeat);
  
***************
*** 128,134 ****
    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
!   glc_texture_ensure_filter (mask_texture, GLC_FILTER_NEAREST);
!   glc_texture_ensure_repeat (mask_texture, mask->repeat);
  
    dst_region.x1 = x_dst;
    dst_region.y1 = y_dst;
--- 132,180 ----
    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
!   if (TRANSFORM (mask))
!     glc_texture_ensure_filter (mask_texture, mask->filter);
!   else
!     glc_texture_ensure_filter (mask_texture, GLC_FILTER_NEAREST);
! 
! 
!   /* calculate source area */
!   src_region.x1 = src_region.y1 = 0.0;
!   src_region.x2 = src->width;
!   src_region.y2 = src->height;
!   
!   if (TRANSFORM (src))
!     glc_matrix_transform_sub_pixel_region (src->transform, &src_region);
  
+   src_width = src_region.x2 - src_region.x1;
+   src_height = src_region.y2 - src_region.y1;
+ 
+   translate_src.x = (src_region.x1 < 0.0)? src_region.x1: 0.0;
+   translate_src.y = (src_region.y1 < 0.0)? src_region.y1: 0.0;
+   src_region.x1 += x_dst;
+   src_region.y1 += y_dst;
+   src_region.x2 += (x_dst - x_src);
+   src_region.y2 += (y_dst - y_src);
+   
+ 
+   /* calculate mask area */
+   mask_region.x1 = mask_region.y1 = 0.0;
+   mask_region.x2 = mask->width;
+   mask_region.y2 = mask->height;
+ 
+   if (TRANSFORM (mask))
+     glc_matrix_transform_sub_pixel_region (mask->transform, &mask_region);
+ 
+   mask_width = mask_region.x2 - mask_region.x1;
+   mask_height = mask_region.y2 - mask_region.y1;
+ 
+   translate_mask.x = (mask_region.x1 < 0.0)? mask_region.x1: 0.0;
+   translate_mask.y = (mask_region.y1 < 0.0)? mask_region.y1: 0.0;
+   mask_region.x1 += x_dst;
+   mask_region.y1 += y_dst;
+   mask_region.x2 += (x_dst - x_mask);
+   mask_region.y2 += (y_dst - y_mask);
+ 
+ 
+   /* calculate destination area */
    dst_region.x1 = x_dst;
    dst_region.y1 = y_dst;
***************
*** 136,168 ****
    dst_region.y2 = dst_region.y1 + height;
    
!   src_region.x1 = x_dst;
!   src_region.y1 = y_dst;
!   if (src->repeat) {
!     src_region.x2 = src_region.x1 + width;
!     src_region.y2 = src_region.y1 + height;
!   } else {
!     src_region.x2 = src_region.x1 + src->width - x_src;
!     src_region.y2 = src_region.y1 + src->height - y_src;
!   }
! 
!   mask_region.x1 = x_dst;
!   mask_region.y1 = y_dst;
!   if (mask->repeat) {
!     mask_region.x2 = mask_region.x1 + width;
!     mask_region.y2 = mask_region.y1 + height;
!   } else {
!     mask_region.x2 = mask_region.x1 + mask->width - x_mask;
!     mask_region.y2 = mask_region.y1 + mask->height - y_mask;
!   }
! 
!   glc_intersect_region (&dst_region, &src_region, &dst_region);
!   glc_intersect_region (&dst_region, &mask_region, &dst_region);
  
!   glc_intersect_region (&src_region, &dst_region, &src_region);
!   glc_intersect_region (&mask_region, &dst_region, &mask_region);
  
!   if (src->repeat) {
      src_region.y2 = src->height -
!       (((y_src % src->height) + (dst_region.y2 - dst_region.y1)) %
         src->height);
      src_region.y1 = (dst_region.y2 - dst_region.y1) + src_region.y2;    
--- 182,196 ----
    dst_region.y2 = dst_region.y1 + height;
    
!   if (!REPEAT (src))
!     glc_intersect_sub_pixel_region (&dst_region, &src_region, &dst_region);
  
!   if (!REPEAT (mask))
!     glc_intersect_sub_pixel_region (&dst_region, &mask_region, &dst_region);
!   
  
!   /* re-calculate source area */
!   if (REPEAT (src)) {
      src_region.y2 = src->height -
!       (((y_src % src->height) + (int) (dst_region.y2 - dst_region.y1)) %
         src->height);
      src_region.y1 = (dst_region.y2 - dst_region.y1) + src_region.y2;    
***************
*** 170,186 ****
      src_region.x2 = (dst_region.x2 - dst_region.x1) + src_region.x1;
    } else {
!     src_region.x1 -= x_dst;
!     src_region.y1 -= y_dst;
!     src_region.x2 -= x_dst;
!     src_region.y2 -= y_dst;
!     src_region.x1 = x_src;
!     src_region.y1 = y_src;
!     src_region.x2 += src_region.x1;
!     src_region.y2 += src_region.y1;
    }
  
!   if (mask->repeat) {
      mask_region.y2 = mask->height -
!       (((y_mask % mask->height) + (dst_region.y2 - dst_region.y1)) %
         mask->height);
      mask_region.y1 = (dst_region.y2 - dst_region.y1) + mask_region.y2;    
--- 198,213 ----
      src_region.x2 = (dst_region.x2 - dst_region.x1) + src_region.x1;
    } else {
!     glc_intersect_sub_pixel_region (&src_region, &dst_region, &src_region);
! 
!     src_region.x2 = (src_region.x2 - src_region.x1) - translate_src.x;
!     src_region.y2 = (src_region.y2 - src_region.y1) - translate_src.y;
!     src_region.x1 = x_src - translate_src.x;
!     src_region.y1 = y_src - translate_src.y;
    }
  
!   /* re-calculate mask area */
!   if (REPEAT (mask)) {
      mask_region.y2 = mask->height -
!       (((y_mask % mask->height) + (int) (dst_region.y2 - dst_region.y1)) %
         mask->height);
      mask_region.y1 = (dst_region.y2 - dst_region.y1) + mask_region.y2;    
***************
*** 188,227 ****
      mask_region.x2 = (dst_region.x2 - dst_region.x1) + mask_region.x1;
    } else {
!     mask_region.x1 -= x_dst;
!     mask_region.y1 -= y_dst;
!     mask_region.x2 -= x_dst;
!     mask_region.y2 -= y_dst;
!     mask_region.x1 = x_mask;
!     mask_region.y1 = y_mask;
!     mask_region.x2 += mask_region.x1;
!     mask_region.y2 += mask_region.y1;
    }
  
!   src_tl.x = ((double) src_region.x1 / (double) src->width) *
!     src_texture->texcoord_width;
!   src_tl.y = ((double) src_region.y1 / (double) src->height) *
!     src_texture->texcoord_height;
  
!   src_br.x = ((double) src_region.x2 / (double) src->width) *
!     src_texture->texcoord_width;
!   src_br.y = ((double) src_region.y2 / (double) src->height) *
!     src_texture->texcoord_height;
  
!   mask_tl.x = ((double) mask_region.x1 / (double) mask->width) *
!     mask_texture->texcoord_width;
!   mask_tl.y = ((double) mask_region.y1 / (double) mask->height) *
!     mask_texture->texcoord_height;
  
!   mask_br.x = ((double) mask_region.x2 / (double) mask->width) *
!     mask_texture->texcoord_width;
!   mask_br.y = ((double) mask_region.y2 / (double) mask->height) *
!     mask_texture->texcoord_height;
  
!   if (!src->repeat) {
      src_tl.y = src_texture->texcoord_height - src_tl.y;
      src_br.y = src_texture->texcoord_height - src_br.y;
    }
      
!   if (!mask->repeat) {
      mask_tl.y = mask_texture->texcoord_height - mask_tl.y;
      mask_br.y = mask_texture->texcoord_height - mask_br.y;
--- 215,245 ----
      mask_region.x2 = (dst_region.x2 - dst_region.x1) + mask_region.x1;
    } else {
!     glc_intersect_sub_pixel_region (&mask_region, &dst_region, &mask_region);
!     
!     mask_region.x2 = (mask_region.x2 - mask_region.x1) - translate_mask.x;
!     mask_region.y2 = (mask_region.y2 - mask_region.y1) - translate_mask.y;
!     mask_region.x1 = x_mask - translate_mask.x;
!     mask_region.y1 = y_mask - translate_mask.y;
    }
  
!   /* normalize texture coordinates */
!   src_tl.x = (src_region.x1 / src_width) * src_texture->texcoord_width;
!   src_tl.y = (src_region.y1 / src_height) * src_texture->texcoord_height;
  
!   src_br.x = (src_region.x2 / src_width) * src_texture->texcoord_width;
!   src_br.y = (src_region.y2 / src_height) * src_texture->texcoord_height;
  
!   mask_tl.x = (mask_region.x1 / mask_width) * mask_texture->texcoord_width;
!   mask_tl.y = (mask_region.y1 / mask_height) * mask_texture->texcoord_height;
  
!   mask_br.x = (mask_region.x2 / mask_width) * mask_texture->texcoord_width;
!   mask_br.y = (mask_region.y2 / mask_height) * mask_texture->texcoord_height;
  
!   if (!REPEAT(src)) {
      src_tl.y = src_texture->texcoord_height - src_tl.y;
      src_br.y = src_texture->texcoord_height - src_br.y;
    }
      
!   if (!REPEAT(mask)) {
      mask_tl.y = mask_texture->texcoord_height - mask_tl.y;
      mask_br.y = mask_texture->texcoord_height - mask_br.y;
***************
*** 234,238 ****
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_tl.x, mask_tl.y);
!   glVertex2i (dst_region.x1, dst_region.y1);
  
    dst->proc_address->gl_multi_tex_coord_2d_arb
--- 252,256 ----
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_tl.x, mask_tl.y);
!   glVertex2d (dst_region.x1, dst_region.y1);
  
    dst->proc_address->gl_multi_tex_coord_2d_arb
***************
*** 240,244 ****
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_br.x, mask_tl.y);
!   glVertex2i (dst_region.x2, dst_region.y1);
  
    dst->proc_address->gl_multi_tex_coord_2d_arb
--- 258,262 ----
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_br.x, mask_tl.y);
!   glVertex2d (dst_region.x2, dst_region.y1);
  
    dst->proc_address->gl_multi_tex_coord_2d_arb
***************
*** 246,250 ****
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_br.x, mask_br.y);
!   glVertex2i (dst_region.x2, dst_region.y2);
  
    dst->proc_address->gl_multi_tex_coord_2d_arb
--- 264,268 ----
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_br.x, mask_br.y);
!   glVertex2d (dst_region.x2, dst_region.y2);
  
    dst->proc_address->gl_multi_tex_coord_2d_arb
***************
*** 252,256 ****
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_tl.x, mask_br.y);
!   glVertex2i (dst_region.x1, dst_region.y2);
  
    glEnd ();
--- 270,274 ----
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE1_ARB, mask_tl.x, mask_br.y);
!   glVertex2d (dst_region.x1, dst_region.y2);
  
    glEnd ();
***************
*** 263,267 ****
    glc_surface_disable_program (dst);
  
!   glc_surface_dirty (dst, &dst_region);
      
    glc_surface_pop_current (dst);
--- 281,289 ----
    glc_surface_disable_program (dst);
  
!   dirty_region.x1 = floor (dst_region.x1);
!   dirty_region.x1 = floor (dst_region.y1);
!   dirty_region.x2 = ceil (dst_region.x2);
!   dirty_region.x2 = ceil (dst_region.y2);
!   glc_surface_dirty (dst, &dirty_region);
      
    glc_surface_pop_current (dst);
***************
*** 349,358 ****
  
      if ((dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
!         _glc_program_composite (op,
!                                 src, mask, dst,
!                                 x_src, y_src,
!                                 x_mask, y_mask,
!                                 x_dst, y_dst,
!                                 width, height))
        return;
      
--- 371,380 ----
  
      if ((dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
!         _glc_composite_direct (op,
!                                src, mask, dst,
!                                x_src, y_src,
!                                x_mask, y_mask,
!                                x_dst, y_dst,
!                                width, height))
        return;
      
***************
*** 451,454 ****
--- 473,479 ----
    
    glc_set_operator (op);
+ 
+   if (src->convolution)
+     glc_surface_enable_program (src, texture, NULL);
    
    if ((!TRANSFORM (src)) && GLREPEAT (src, texture)) {
***************
*** 604,607 ****
--- 629,635 ----
    }
  
+   if (src->convolution)
+     glc_surface_disable_program (src);
+   
    glc_texture_unbind (texture);
  

Index: glc.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** a/glc.h	18 Feb 2004 14:52:45 -0000	1.12
--- b/glc.h	20 Feb 2004 17:40:57 -0000	1.13
***************
*** 79,82 ****
--- 79,86 ----
  } glc_transform_t;
  
+ typedef struct _glc_convolution_t {
+   glc_fixed16_16_t matrix[3][3];
+ } glc_convolution_t;
+ 
  typedef struct {
    unsigned short red;
***************
*** 131,139 ****
  
  #define GLC_FEATURE_OFFSCREEN_DRAWING_MASK     (1L << 0)
! #define GLC_FEATURE_TEXTURE_RECTANGLE_MASK     (1L << 1)
! #define GLC_FEATURE_MULTISAMPLE_MASK           (1L << 2)
! #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK (1L << 3)
! #define GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 4)
! #define GLC_FEATURE_ATI_RENDER_TEXTURE_MASK    (1L << 5)
  
  typedef enum {  
--- 135,145 ----
  
  #define GLC_FEATURE_OFFSCREEN_DRAWING_MASK     (1L << 0)
! #define GLC_FEATURE_CONVOLUTION_FILTER_MASK    (1L << 1)
! #define GLC_FEATURE_TEXTURE_RECTANGLE_MASK     (1L << 2)
! #define GLC_FEATURE_MULTISAMPLE_MASK           (1L << 3)
! #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK (1L << 4)
! #define GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK    (1L << 5)
! #define GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 6)
! #define GLC_FEATURE_ATI_RENDER_TEXTURE_MASK    (1L << 7)
  
  typedef enum {  
***************
*** 233,236 ****
--- 239,246 ----
  
  void
+ glc_surface_set_convolution (glc_surface_t *surface,
+                              glc_convolution_t *convolution);
+ 
+ void
  glc_surface_set_repeat (glc_surface_t *surface,
                          glc_bool_t repeat);

Index: glc_agl_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_extension.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/glc_agl_extension.c	18 Feb 2004 14:52:45 -0000	1.3
--- b/glc_agl_extension.c	20 Feb 2004 17:40:57 -0000	1.4
***************
*** 38,41 ****
--- 38,42 ----
    { "GL_ARB_multisample", GLC_AGL_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK },
+   { "GL_ARB_vertex_program", GLC_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK },
    { "GL_ARB_fragment_program", GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK },
    { NULL, 0 }
***************
*** 81,85 ****
--- 82,94 ----
  
    if (thread_info->agl_feature_mask &
+       GLC_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK)
+     thread_info->feature_mask |= GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK;
+   
+   if (thread_info->agl_feature_mask &
        GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
      thread_info->feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
+ 
+   if ((thread_info->feature_mask & GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&
+       (thread_info->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK))
+     thread_info->feature_mask |= GLC_FEATURE_CONVOLUTION_FILTER_MASK;
  }

Index: glc_agl_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_info.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/glc_agl_info.c	18 Feb 2004 14:52:45 -0000	1.5
--- b/glc_agl_info.c	20 Feb 2004 17:40:57 -0000	1.6
***************
*** 39,42 ****
--- 39,44 ----
    glProgramStringARB,
    glBindProgramARB,
+   glProgramLocalParameter4dARB,
+   glGetProgramivARB,
    0
  };
***************
*** 115,119 ****
    thread_info->n_contexts = 0;
  
!   memset (&thread_info->programs, 0, sizeof (glc_fragment_programs_t));
    
    thread_info->root_context.pixel_format =
--- 117,121 ----
    thread_info->n_contexts = 0;
  
!   memset (&thread_info->programs, 0, sizeof (glc_programs_t));
    
    thread_info->root_context.pixel_format =
***************
*** 161,165 ****
--- 163,169 ----
            
  #if defined(GL_ARB_multitexture) && defined(GL_ARB_fragment_program)
+           | GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK
            | GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK
+           | GLC_FEATURE_CONVOLUTION_FILTER_MASK
  #endif          
            

Index: glc_agl_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_surface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/glc_agl_surface.c	16 Feb 2004 22:02:40 -0000	1.7
--- b/glc_agl_surface.c	20 Feb 2004 17:40:57 -0000	1.8
***************
*** 131,134 ****
--- 131,167 ----
  }
  
+ static void
+ _glc_agl_set_features (glc_agl_surface_t *surface)
+ {
+   surface->base.feature_mask = surface->thread_info->feature_mask;
+ 
+   surface->base.feature_mask &= ~GLC_FEATURE_CONVOLUTION_FILTER_MASK;
+   surface->base.feature_mask &= ~GLC_FEATURE_MULTISAMPLE_MASK;
+   surface->base.feature_mask &= ~GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
+ 
+ #if defined(GL_ARB_multitexture) && defined(GL_ARB_fragment_program)
+   if (surface->thread_info->feature_mask &
+       GLC_FEATURE_CONVOLUTION_FILTER_MASK) {
+     GLuint texture_indirections;
+ 
+     surface->base.proc_address->gl_get_program_iv_arb
+       (GL_FRAGMENT_PROGRAM_ARB,
+        GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB,
+        &texture_indirections);
+ 
+     /* Convolution filter programs require support for at least six
+        texture indirections. */
+     if (texture_indirections >= 5)
+       surface->base.feature_mask |= GLC_FEATURE_CONVOLUTION_FILTER_MASK;
+   }
+ #endif
+ 
+   if (surface->base.format->multisample.supported) {
+     surface->base.feature_mask |= GLC_FEATURE_MULTISAMPLE_MASK;
+     if (surface->pbuffer)
+       surface->base.feature_mask |= GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
+   }
+ }
+ 
  static glc_surface_t *
  _glc_agl_surface_create (glc_agl_thread_info_t *thread_info,
***************
*** 157,161 ****
    surface->base.proc_address = &_glc_agl_gl_proc_address;
    surface->base.programs = &thread_info->programs;
!   surface->base.feature_mask = thread_info->feature_mask;
    surface->base.format = format;
    surface->base.width = width;
--- 190,194 ----
    surface->base.proc_address = &_glc_agl_gl_proc_address;
    surface->base.programs = &thread_info->programs;
!   surface->base.feature_mask = 0;
    surface->base.format = format;
    surface->base.width = width;
***************
*** 187,190 ****
--- 220,225 ----
    if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_DRAWING_MASK)
      surface->pbuffer = glc_agl_pbuffer_create (surface->base.texture);
+   
+   _glc_agl_set_features (surface);
  
    if (!surface->pbuffer) {
***************
*** 240,248 ****
    surface->base.proc_address = &_glc_agl_gl_proc_address;
    surface->base.programs = &thread_info->programs;
-   surface->base.feature_mask = thread_info->feature_mask;
    surface->base.format = format;
    surface->base.width = width;
    surface->base.height = height;
  
    surface->window = window;
    surface->drawable = GetWindowPort (window);
--- 275,284 ----
    surface->base.proc_address = &_glc_agl_gl_proc_address;
    surface->base.programs = &thread_info->programs;
    surface->base.format = format;
    surface->base.width = width;
    surface->base.height = height;
  
+   _glc_agl_set_features (surface);
+ 
    surface->window = window;
    surface->drawable = GetWindowPort (window);

Index: glc_glx_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_context.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** a/glc_glx_context.c	18 Feb 2004 14:52:45 -0000	1.10
--- b/glc_glx_context.c	20 Feb 2004 17:40:57 -0000	1.11
***************
*** 190,193 ****
--- 190,199 ----
      (glc_proc_ptr_gl_bind_program_arb_t)
      glc_glx_get_proc_address ("glBindProgramARB");
+   context->gl_proc_address.gl_program_local_param_4d_arb =
+     (glc_proc_ptr_gl_program_local_param_4d_arb_t)
+     glc_glx_get_proc_address ("glProgramLocalParameter4dARB");
+   context->gl_proc_address.gl_get_program_iv_arb =
+     (glc_proc_ptr_gl_get_program_iv_arb_t)
+     glc_glx_get_proc_address ("glGetProgramivARB");
  #endif
  

Index: glc_glx_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_extension.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** a/glc_glx_extension.c	18 Feb 2004 14:52:45 -0000	1.9
--- b/glc_glx_extension.c	20 Feb 2004 17:40:57 -0000	1.10
***************
*** 43,46 ****
--- 43,47 ----
    { "GL_ARB_multisample", GLC_GLX_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK },
+   { "GL_ARB_vertex_program", GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK },
    { "GL_ARB_fragment_program", GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK },
    { NULL, 0 }
***************
*** 125,128 ****
--- 126,142 ----
  
    if (screen_info->glx_feature_mask &
+       GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK) {
+     screen_info->glx_feature_mask &=
+       ~GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK;
+     
+ #if defined(GL_ARB_multitexture) && defined(GL_ARB_vertex_program)
+     screen_info->glx_feature_mask |=
+       GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK;
+     screen_info->feature_mask |= GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK;
+ #endif
+     
+   }
+ 
+   if (screen_info->glx_feature_mask &
        GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
      screen_info->glx_feature_mask &=
***************
*** 136,138 ****
--- 150,156 ----
      
    }
+ 
+   if ((screen_info->feature_mask & GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&
+       (screen_info->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK))
+     screen_info->feature_mask |= GLC_FEATURE_CONVOLUTION_FILTER_MASK;
  }

Index: glc_glx_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_info.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** a/glc_glx_info.c	18 Feb 2004 14:52:45 -0000	1.10
--- b/glc_glx_info.c	20 Feb 2004 17:40:57 -0000	1.11
***************
*** 256,260 ****
    screen_info->n_contexts = 0;
  
!   memset (&screen_info->programs, 0, sizeof (glc_fragment_programs_t));
  
    glc_glx_create_root_context (screen_info);
--- 256,260 ----
    screen_info->n_contexts = 0;
  
!   memset (&screen_info->programs, 0, sizeof (glc_programs_t));
  
    glc_glx_create_root_context (screen_info);
***************
*** 315,319 ****
--- 315,321 ----
            
  #if defined(GL_ARB_multitexture) && defined(GL_ARB_fragment_program)
+           | GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK
            | GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK
+           | GLC_FEATURE_CONVOLUTION_FILTER_MASK
  #endif
            

Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** a/glc_glx_surface.c	18 Feb 2004 14:52:45 -0000	1.15
--- b/glc_glx_surface.c	20 Feb 2004 17:40:57 -0000	1.16
***************
*** 166,170 ****
--- 166,174 ----
  
    surface->base.feature_mask &= ~GLC_FEATURE_ATI_RENDER_TEXTURE_MASK;
+   surface->base.feature_mask &= ~GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK;
    surface->base.feature_mask &= ~GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
+   surface->base.feature_mask &= ~GLC_FEATURE_CONVOLUTION_FILTER_MASK;
+   surface->base.feature_mask &= ~GLC_FEATURE_MULTISAMPLE_MASK;
+   surface->base.feature_mask &= ~GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
  
    if (surface->context->glx_proc_address.supported) {
***************
*** 182,196 ****
  
  #if defined(GL_ARB_multitexture) && defined(GL_ARB_fragment_program)
!   if ((surface->screen_info->feature_mask &
!        GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
!       surface->context->gl_proc_address.gl_active_texture_arb &&
        surface->context->gl_proc_address.gl_multi_tex_coord_2d_arb &&
        surface->context->gl_proc_address.gl_gen_programs_arb &&
        surface->context->gl_proc_address.gl_delete_programs_arb &&
        surface->context->gl_proc_address.gl_program_string_arb &&
!       surface->context->gl_proc_address.gl_bind_program_arb)
!     surface->base.feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
  #endif
!   
  }
  
--- 186,227 ----
  
  #if defined(GL_ARB_multitexture) && defined(GL_ARB_fragment_program)
!   if (surface->context->gl_proc_address.gl_active_texture_arb &&
        surface->context->gl_proc_address.gl_multi_tex_coord_2d_arb &&
        surface->context->gl_proc_address.gl_gen_programs_arb &&
        surface->context->gl_proc_address.gl_delete_programs_arb &&
        surface->context->gl_proc_address.gl_program_string_arb &&
!       surface->context->gl_proc_address.gl_bind_program_arb) {
!     if (surface->screen_info->feature_mask &
!         GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
!       surface->base.feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
!     
!     if (surface->screen_info->feature_mask &
!         GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK)
!       surface->base.feature_mask |= GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK;
!     
!     if ((surface->base.feature_mask & GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&
!         (surface->base.feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
!         surface->context->gl_proc_address.gl_program_local_param_4d_arb &&
!         surface->context->gl_proc_address.gl_get_program_iv_arb) {
!       GLuint texture_indirections;
! 
!       surface->context->gl_proc_address.gl_get_program_iv_arb
!         (GL_FRAGMENT_PROGRAM_ARB,
!          GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB,
!          &texture_indirections);
! 
!       /* Convolution filter programs require support for at least six
!          texture indirections. */
!       if (texture_indirections >= 5)
!         surface->base.feature_mask |= GLC_FEATURE_CONVOLUTION_FILTER_MASK;
!     }
!   }
  #endif
! 
!   if (surface->base.format->multisample.supported) {
!     surface->base.feature_mask |= GLC_FEATURE_MULTISAMPLE_MASK;
!     if (surface->pbuffer)
!       surface->base.feature_mask |= GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
!   }
  }
  

Index: glc_matrix.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_matrix.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/glc_matrix.c	10 Feb 2004 23:38:36 -0000	1.2
--- b/glc_matrix.c	20 Feb 2004 17:40:57 -0000	1.3
***************
*** 32,35 ****
--- 32,37 ----
  #include "glcint.h"
  
+ #include <math.h>
+ 
  static void
  _glc_matrix_transform_distance (glc_matrix_t *matrix,
***************
*** 47,51 ****
  
  void
! glc_matrix_transform_point (glc_matrix_t *matrix, glc_point_t *point)
  {
    _glc_matrix_transform_distance (matrix, &point->x, &point->y);
--- 49,54 ----
  
  void
! glc_matrix_transform_point (glc_matrix_t *matrix,
!                             glc_point_t *point)
  {
    _glc_matrix_transform_distance (matrix, &point->x, &point->y);
***************
*** 55,58 ****
--- 58,74 ----
  }
  
+ void
+ glc_matrix_transform_sub_pixel_region (glc_matrix_t *matrix,
+                                        glc_sub_pixel_region_box_t *region)
+ {
+   _glc_matrix_transform_distance (matrix, &region->x1, &region->y1);
+   _glc_matrix_transform_distance (matrix, &region->x2, &region->y2);
+   
+   region->x1 += matrix->m[2][0];
+   region->y1 += matrix->m[2][1];
+   region->x2 += matrix->m[2][0];
+   region->y2 += matrix->m[2][1];
+ }
+ 
  static void
  _glc_matrix_set_affine (glc_matrix_t *matrix,
***************
*** 67,71 ****
  
  static void
! _glc_matrix_scalar_multiply (glc_matrix_t *matrix, double scalar)
  {
    int row, col;
--- 83,88 ----
  
  static void
! _glc_matrix_scalar_multiply (glc_matrix_t *matrix,
!                              double scalar)
  {
    int row, col;
***************
*** 124,125 ****
--- 141,166 ----
    return GLC_STATUS_SUCCESS;
  }
+ 
+ /* This function is only used for convolution kernel normalization.
+    I'm not sure that it does the right thing when kernel contains negative
+    values or when the sum equals zero. */
+ glc_status_t
+ glc_matrix_normalize (glc_matrix_t *matrix)
+ {
+   int row, col;
+   double sum = 0.0;
+ 
+   for (row = 0; row < 3; row++)
+     for (col = 0; col < 3; col++)
+       sum += matrix->m[row][col];
+ 
+   if (sum != 0.0) {
+     sum = 1.0 / sum;
+ 
+     for (row = 0; row < 3; row++)
+       for (col = 0; col < 3; col++)
+         matrix->m[row][col] *= sum;
+   }
+   
+   return GLC_STATUS_SUCCESS;
+ }

Index: glc_program.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_program.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/glc_program.c	16 Feb 2004 22:02:40 -0000	1.2
--- b/glc_program.c	20 Feb 2004 17:40:57 -0000	1.3
***************
*** 33,80 ****
  
  #ifdef GL_ARB_fragment_program
! /*
!  * ARB_fragment_program
!  *
!  * Porter-Duff compositing (SRC in MASK).
!  * Texture unit 0 is SRC.
!  * Texture unit 1 is MASK.
!  *
!  * Author: David Reveman <c99drn at cs.umu.se>
!  */
! #define GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_2D_2D \
!   "!!ARBfp1.0\n" \
!   "TEMP src, mask;\n" \
!   "TEX src, fragment.texcoord[0], texture[0], 2D;\n" \
!   "TEX mask, fragment.texcoord[1], texture[1], 2D;\n" \
!   "MUL result.color, src, mask.a;\n" \
!   "END"
! #define GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_RECT_2D \
!   "!!ARBfp1.0\n" \
!   "TEMP src, mask;\n" \
!   "TEX src, fragment.texcoord[0], texture[0], RECT;\n" \
!   "TEX mask, fragment.texcoord[1], texture[1], 2D;\n" \
!   "MUL result.color, src, mask.a;\n" \
!   "END"
! #define GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_2D_RECT \
!   "!!ARBfp1.0\n" \
!   "TEMP src, mask;\n" \
!   "TEX src, fragment.texcoord[0], texture[0], 2D;\n" \
!   "TEX mask, fragment.texcoord[1], texture[1], RECT;\n" \
!   "MUL result.color, src, mask.a;\n" \
!   "END"
! #define GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_RECT_RECT \
!   "!!ARBfp1.0\n" \
!   "TEMP src, mask;\n" \
!   "TEX src, fragment.texcoord[0], texture[0], RECT;\n" \
!   "TEX mask, fragment.texcoord[1], texture[1], RECT;\n" \
!   "MUL result.color, src, mask.a;\n" \
!   "END"
  
  static unsigned int
  glc_program_compile_fragment_arb (glc_gl_proc_address_list_t *proc_address,
!                                   const char *program_string)
  {
    GLint error;
    GLuint program;
      
    proc_address->gl_gen_programs_arb (1, (GLuint *) &program);
--- 33,493 ----
  
  #ifdef GL_ARB_fragment_program
! 
! static char *_glc_vertex_programs[] =
!   {
!     /*
!      * Passes texture coordinates to convolution filter
!      * fragment programs. Texture unit 1 is reserved for MASK
!      * in Porter-Duff compositing.
!      *
!      * program.local[0]: Vertical pixel offset in texture coordinates
!      * program.local[1]: Horizontal pixel offset in texture coordinates
!      *
!      * Author: David Reveman <c99drn at cs.umu.se>
!      */
!     "!!ARBvp1.0\n"
!     "OPTION ARB_position_invariant;\n"
!     "ATTRIB coord = vertex.texcoord[0];\n"
!     "PARAM vertical_offset   = program.local[0];\n"
!     "PARAM horizontal_offset = program.local[1];\n"
!     "MOV result.texcoord[0], coord;\n"
!     "ADD result.texcoord[2], coord, vertical_offset;\n"
!     "SUB result.texcoord[3], coord, vertical_offset;\n"
!     "ADD result.texcoord[4], coord, horizontal_offset;\n"
!     "SUB result.texcoord[5], coord, horizontal_offset;\n"
!     "MOV result.texcoord[1], vertex.texcoord[1];\n"
!     "END"
!   };
! 
! static char *_glc_fragment_programs[] =
!   {
!     /*
!      * Porter-Duff compositing (SRC in MASK).
!      * Texture unit 0 is SRC.
!      * Texture unit 1 is MASK.
!      *
!      * Author: David Reveman <c99drn at cs.umu.se>
!      */
! 
!     /* SRC == TEXTURE_2D, MASK == TEXTURE_2D */
!     "!!ARBfp1.0\n"
!     "TEMP src, mask;\n"
!     "TEX src, fragment.texcoord[0], texture[0], 2D;\n"
!     "TEX mask, fragment.texcoord[1], texture[1], 2D;\n"
!     "MUL result.color, src, mask.a;\n"
!     "END",
!     
!     /* SRC == TEXTURE_RECTANGLE, MASK == TEXTURE_2D */
!     "!!ARBfp1.0\n"
!     "TEMP src, mask;\n"
!     "TEX src, fragment.texcoord[0], texture[0], RECT;\n"
!     "TEX mask, fragment.texcoord[1], texture[1], 2D;\n"
!     "MUL result.color, src, mask.a;\n"
!     "END",
! 
!     /* SRC == TEXTURE_2D, MASK == TEXTURE_RECTANGLE */
!     "!!ARBfp1.0\n"
!     "TEMP src, mask;\n"
!     "TEX src, fragment.texcoord[0], texture[0], 2D;\n"
!     "TEX mask, fragment.texcoord[1], texture[1], RECT;\n"
!     "MUL result.color, src, mask.a;\n"
!     "END",
! 
!     /* SRC == TEXTURE_RECTANGLE, MASK == TEXTURE_RECTANGLE */
!     "!!ARBfp1.0\n"
!     "TEMP src, mask;\n"
!     "TEX src, fragment.texcoord[0], texture[0], RECT;\n"
!     "TEX mask, fragment.texcoord[1], texture[1], RECT;\n"
!     "MUL result.color, src, mask.a;\n"
!     "END",
! 
!     /*
!      * Combined 3x3 convolution filter and Porter-Duff compositing.
!      * Convolution kernel must be normalized.
!      *
!      * program.local[0]: Top convolution kernel row
!      * program.local[1]: Middle convolution kernel row
!      * program.local[2]: Bottom convolution kernel row
!      *
!      * Author: David Reveman <c99drn at cs.umu.se>
!      */
! 
!     /* SRC == TEXTURE_2D, MASK == TEXTURE_2D */
!     "!!ARBfp1.0\n"
!     "ATTRIB east  = fragment.texcoord[2];\n"
!     "ATTRIB west  = fragment.texcoord[3];\n"
!     "ATTRIB south = fragment.texcoord[4];\n"
!     "ATTRIB north = fragment.texcoord[5];\n"
!     "PARAM k0 = program.local[0];\n"
!     "PARAM k1 = program.local[1];\n"
!     "PARAM k2 = program.local[2];\n"
!     "TEMP out, in, coord, mask;\n"
! 
!     /* center */
!     "TEX in, fragment.texcoord[0], texture[0], 2D;\n"
!     "MUL out, in, k1.y;\n"
! 
!     /* north west */
!     "MOV coord.x, west.x;\n"
!     "MOV coord.y, north.y;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k0.x, out;\n"
! 
!     /* north */
!     "TEX in, north, texture[0], 2D;\n"
!     "MAD out, in, k0.y, out;\n"
! 
!     /* north east */
!     "MOV coord.x, east.x;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k0.z, out;\n"
! 
!     /* east */
!     "TEX in, east, texture[0], 2D;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     /* south east */
!     "MOV coord.y, south.y;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k2.z, out;\n"
! 
!     /* south */
!     "TEX in, south, texture[0], 2D;\n"
!     "MAD out, in, k2.y, out;\n"
! 
!     /* south west */
!     "MOV coord.x, west.x;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k2.x, out;\n"
! 
!     /* west */
!     "TEX in, west, texture[0], 2D;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     "TEX mask, fragment.texcoord[1], texture[1], 2D;\n"
!     "MUL result.color, out, mask.a;\n"
!     "END",
! 
!     /* SRC == TEXTURE_RECTANGLE, MASK == TEXTURE_2D */
!     "!!ARBfp1.0\n"
!     "ATTRIB east  = fragment.texcoord[2];\n"
!     "ATTRIB west  = fragment.texcoord[3];\n"
!     "ATTRIB south = fragment.texcoord[4];\n"
!     "ATTRIB north = fragment.texcoord[5];\n"
!     "PARAM k0 = program.local[0];\n"
!     "PARAM k1 = program.local[1];\n"
!     "PARAM k2 = program.local[2];\n"
!     "TEMP out, in, coord, mask;\n"
! 
!     /* center */
!     "TEX in, fragment.texcoord[0], texture[0], RECT;\n"
!     "MUL out, in, k1.y;\n"
! 
!     /* north west */
!     "MOV coord.x, west.x;\n"
!     "MOV coord.y, north.y;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k0.x, out;\n"
! 
!     /* north */
!     "TEX in, north, texture[0], RECT;\n"
!     "MAD out, in, k0.y, out;\n"
! 
!     /* north east */
!     "MOV coord.x, east.x;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k0.z, out;\n"
! 
!     /* east */
!     "TEX in, east, texture[0], RECT;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     /* south east */
!     "MOV coord.y, south.y;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k2.z, out;\n"
! 
!     /* south */
!     "TEX in, south, texture[0], RECT;\n"
!     "MAD out, in, k2.y, out;\n"
! 
!     /* south west */
!     "MOV coord.x, west.x;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k2.x, out;\n"
! 
!     /* west */
!     "TEX in, west, texture[0], RECT;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     "TEX mask, fragment.texcoord[1], texture[1], 2D;\n"
!     "MUL result.color, out, mask.a;\n"
!     "END",
! 
!     /* SRC == TEXTURE_2D, MASK == TEXTURE_RECTANGLE */
!     "!!ARBfp1.0\n"
!     "ATTRIB east  = fragment.texcoord[2];\n"
!     "ATTRIB west  = fragment.texcoord[3];\n"
!     "ATTRIB south = fragment.texcoord[4];\n"
!     "ATTRIB north = fragment.texcoord[5];\n"
!     "PARAM k0 = program.local[0];\n"
!     "PARAM k1 = program.local[1];\n"
!     "PARAM k2 = program.local[2];\n"
!     "TEMP out, in, coord, mask;\n"
! 
!     /* center */
!     "TEX in, fragment.texcoord[0], texture[0], 2D;\n"
!     "MUL out, in, k1.y;\n"
! 
!     /* north west */
!     "MOV coord.x, west.x;\n"
!     "MOV coord.y, north.y;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k0.x, out;\n"
! 
!     /* north */
!     "TEX in, north, texture[0], 2D;\n"
!     "MAD out, in, k0.y, out;\n"
! 
!     /* north east */
!     "MOV coord.x, east.x;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k0.z, out;\n"
! 
!     /* east */
!     "TEX in, east, texture[0], 2D;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     /* south east */
!     "MOV coord.y, south.y;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k2.z, out;\n"
! 
!     /* south */
!     "TEX in, south, texture[0], 2D;\n"
!     "MAD out, in, k2.y, out;\n"
! 
!     /* south west */
!     "MOV coord.x, west.x;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k2.x, out;\n"
! 
!     /* west */
!     "TEX in, west, texture[0], 2D;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     "TEX mask, fragment.texcoord[1], texture[1], RECT;\n"
!     "MUL result.color, out, mask.a;\n"
!     "END",
! 
!     /* SRC == TEXTURE_RECTANGLE, MASK == TEXTURE_RECTANGLE */
!     "!!ARBfp1.0\n"
!     "ATTRIB east  = fragment.texcoord[2];\n"
!     "ATTRIB west  = fragment.texcoord[3];\n"
!     "ATTRIB south = fragment.texcoord[4];\n"
!     "ATTRIB north = fragment.texcoord[5];\n"
!     "PARAM k0 = program.local[0];\n"
!     "PARAM k1 = program.local[1];\n"
!     "PARAM k2 = program.local[2];\n"
!     "TEMP out, in, coord, mask;\n"
! 
!     /* center */
!     "TEX in, fragment.texcoord[0], texture[0], RECT;\n"
!     "MUL out, in, k1.y;\n"
! 
!     /* north west */
!     "MOV coord.x, west.x;\n"
!     "MOV coord.y, north.y;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k0.x, out;\n"
! 
!     /* north */
!     "TEX in, north, texture[0], RECT;\n"
!     "MAD out, in, k0.y, out;\n"
! 
!     /* north east */
!     "MOV coord.x, east.x;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k0.z, out;\n"
! 
!     /* east */
!     "TEX in, east, texture[0], RECT;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     /* south east */
!     "MOV coord.y, south.y;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k2.z, out;\n"
! 
!     /* south */
!     "TEX in, south, texture[0], RECT;\n"
!     "MAD out, in, k2.y, out;\n"
! 
!     /* south west */
!     "MOV coord.x, west.x;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k2.x, out;\n"
! 
!     /* west */
!     "TEX in, west, texture[0], RECT;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     "TEX mask, fragment.texcoord[1], texture[1], RECT;\n"
!     "MUL result.color, out, mask.a;\n"
!     "END",
! 
!     /*
!      * 3x3 convolution filter.
!      * Convolution kernel must be normalized.
!      *
!      * program.local[0]: Top convolution kernel row
!      * program.local[1]: Middle convolution kernel row
!      * program.local[2]: Bottom convolution kernel row
!      *
!      * Author: David Reveman <c99drn at cs.umu.se>
!      */
! 
!     /* SRC == TEXTURE_2D */
!     "!!ARBfp1.0\n"
!     "ATTRIB east  = fragment.texcoord[2];\n"
!     "ATTRIB west  = fragment.texcoord[3];\n"
!     "ATTRIB south = fragment.texcoord[4];\n"
!     "ATTRIB north = fragment.texcoord[5];\n"
!     "PARAM k0 = program.local[0];\n"
!     "PARAM k1 = program.local[1];\n"
!     "PARAM k2 = program.local[2];\n"
!     "TEMP out, in, coord;\n"
! 
!     /* center */
!     "TEX in, fragment.texcoord[0], texture[0], 2D;\n"
!     "MUL out, in, k1.y;\n"
! 
!     /* north west */
!     "MOV coord.x, west.x;\n"
!     "MOV coord.y, north.y;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k0.x, out;\n"
! 
!     /* north */
!     "TEX in, north, texture[0], 2D;\n"
!     "MAD out, in, k0.y, out;\n"
! 
!     /* north east */
!     "MOV coord.x, east.x;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k0.z, out;\n"
! 
!     /* east */
!     "TEX in, east, texture[0], 2D;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     /* south east */
!     "MOV coord.y, south.y;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k2.z, out;\n"
! 
!     /* south */
!     "TEX in, south, texture[0], 2D;\n"
!     "MAD out, in, k2.y, out;\n"
! 
!     /* south west */
!     "MOV coord.x, west.x;\n"
!     "TEX in, coord, texture[0], 2D;\n"
!     "MAD out, in, k2.x, out;\n"
! 
!     /* west */
!     "TEX in, west, texture[0], 2D;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     "MOV result.color, out;\n"
!     "END",
!     
!     /* SRC == TEXTURE_RECTANGLE */
!     "!!ARBfp1.0\n"
!     "ATTRIB east  = fragment.texcoord[2];\n"
!     "ATTRIB west  = fragment.texcoord[3];\n"
!     "ATTRIB south = fragment.texcoord[4];\n"
!     "ATTRIB north = fragment.texcoord[5];\n"
!     "PARAM k0 = program.local[0];\n"
!     "PARAM k1 = program.local[1];\n"
!     "PARAM k2 = program.local[2];\n"
!     "TEMP out, in, coord;\n"
! 
!     /* center */
!     "TEX in, fragment.texcoord[0], texture[0], RECT;\n"
!     "MUL out, in, k1.y;\n"
! 
!     /* north west */
!     "MOV coord.x, west.x;\n"
!     "MOV coord.y, north.y;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k0.x, out;\n"
! 
!     /* north */
!     "TEX in, north, texture[0], RECT;\n"
!     "MAD out, in, k0.y, out;\n"
! 
!     /* north east */
!     "MOV coord.x, east.x;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k0.z, out;\n"
! 
!     /* east */
!     "TEX in, east, texture[0], RECT;\n"
!     "MAD out, in, k1.x, out;\n"
! 
!     /* south east */
!     "MOV coord.y, south.y;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k2.z, out;\n"
! 
!     /* south */
!     "TEX in, south, texture[0], RECT;\n"
!     "MAD out, in, k2.y, out;\n"
! 
!     /* south west */
!     "MOV coord.x, west.x;\n"
!     "TEX in, coord, texture[0], RECT;\n"
!     "MAD out, in, k2.x, out;\n"
! 
!     /* west */
!     "TEX in, west, texture[0], RECT;\n"
!     "MAD out, in, k1.x, out;\n"
!   
!     "MOV result.color, out;\n"
!     "END"
!   }; 
! 
! static unsigned int
! glc_program_compile_vertex_arb (glc_gl_proc_address_list_t *proc_address,
!                                 int offset)
! {
!   GLint error;
!   GLuint program;
!   char *program_string = _glc_vertex_programs[offset];
!     
!   proc_address->gl_gen_programs_arb (1, (GLuint *) &program);
!   proc_address->gl_bind_program_arb (GL_VERTEX_PROGRAM_ARB, program);
!   proc_address->gl_program_string_arb (GL_VERTEX_PROGRAM_ARB,
!                                        GL_PROGRAM_FORMAT_ASCII_ARB,
!                                        strlen (program_string),
!                                        program_string);
!   
!   glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &error);
!   if (error != -1) {
!     proc_address->gl_delete_programs_arb (1, &program);
!     program = 0;
!   }
!   
!   return (unsigned int) program;
! }
  
  static unsigned int
  glc_program_compile_fragment_arb (glc_gl_proc_address_list_t *proc_address,
!                                   int offset)
  {
    GLint error;
    GLuint program;
+   char *program_string = _glc_fragment_programs[offset];
      
    proc_address->gl_gen_programs_arb (1, (GLuint *) &program);
***************
*** 93,156 ****
    return (unsigned int) program;
  }
- #endif
  
! glc_bool_t
! glc_program_enable_fragment_arb (glc_gl_proc_address_list_t *proc_address,
!                                  glc_fragment_programs_t *programs,
!                                  glc_texture_t *src_texture,
!                                  glc_texture_t *mask_texture)
  {
! 
! #ifdef GL_ARB_fragment_program
!   GLuint program;
    
    if (src_texture->target == GL_TEXTURE_2D) {
!     if (mask_texture->target == GL_TEXTURE_2D) {
!       if (!programs->program_2d_2d)
!         programs->program_2d_2d = glc_program_compile_fragment_arb
!           (proc_address, GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_2D_2D);
!       
!       program = programs->program_2d_2d;
!     } else {
!       if (!programs->program_2d_rect)
!         programs->program_2d_rect = glc_program_compile_fragment_arb
!           (proc_address, GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_2D_RECT);
!       
!       program = programs->program_2d_rect;
!     }
    } else {
!     if (mask_texture->target == GL_TEXTURE_2D) {
!       if (!programs->program_rect_2d)
!         programs->program_rect_2d = glc_program_compile_fragment_arb
!           (proc_address, GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_RECT_2D);
!       
!       program = programs->program_rect_2d;
!     } else {
!       if (!programs->program_rect_rect)
!         programs->program_rect_rect = glc_program_compile_fragment_arb
!           (proc_address, GLC_PROGRAM_FRAGMENT_ARB_SRC_IN_MASK_RECT_RECT);
!       
!       program = programs->program_rect_rect;
!     }
    }
  
!   if (program) {
      glEnable (GL_FRAGMENT_PROGRAM_ARB);
!     proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB, program);
      
      return 1;
    }
  #endif
  
    return 0;
  }
  
  void
! glc_program_disable_fragment_arb (glc_gl_proc_address_list_t *proc_address)
  {
    
  #ifdef GL_ARB_fragment_program
!   proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB, 0);
    glDisable (GL_FRAGMENT_PROGRAM_ARB);
  #endif
    
--- 506,658 ----
    return (unsigned int) program;
  }
  
! static int
! _glc_program_offset (glc_texture_t *src_texture,
!                      glc_texture_t *mask_texture)
  {
!   int offset;
    
    if (src_texture->target == GL_TEXTURE_2D) {
!     offset = GLC_FRAGMENT_PROGRAM_2D_OFFSET;
! 
!     if (mask_texture)
!       offset = (mask_texture->target == GL_TEXTURE_2D)?
!         GLC_FRAGMENT_PROGRAM_2D_2D_OFFSET:
!     GLC_FRAGMENT_PROGRAM_2D_RECT_OFFSET;
    } else {
!     offset = GLC_FRAGMENT_PROGRAM_RECT_OFFSET;
! 
!     if (mask_texture)
!       offset = (mask_texture->target == GL_TEXTURE_2D)?
!         GLC_FRAGMENT_PROGRAM_RECT_2D_OFFSET:
!     GLC_FRAGMENT_PROGRAM_RECT_RECT_OFFSET;
    }
+   
+   return offset;
+ }
  
! static glc_bool_t
! glc_program_enable_comp (glc_gl_proc_address_list_t *proc_address,
!                          glc_programs_t *programs,
!                          glc_texture_t *src_texture,
!                          glc_texture_t *mask_texture)
! {
!   int fragment_offset = GLC_FRAGMENT_PROGRAM_COMP_BASE;
!   
!   fragment_offset += _glc_program_offset (src_texture, mask_texture);
!   
!   if (!programs->fragment[fragment_offset])
!     programs->fragment[fragment_offset] = glc_program_compile_fragment_arb
!       (proc_address, fragment_offset);
! 
!   if (programs->fragment[fragment_offset]) {
      glEnable (GL_FRAGMENT_PROGRAM_ARB);
!     proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB,
!                                        programs->fragment[fragment_offset]);
!     
!     return 1;
!   }
!   
!   return 0;
! }
! 
! static glc_bool_t
! glc_program_enable_comp_conv (glc_gl_proc_address_list_t *proc_address,
!                               glc_programs_t *programs,
!                               glc_surface_t *src,
!                               glc_texture_t *src_texture,
!                               glc_texture_t *mask_texture)
! {
!   int vertex_offset = GLC_VERTEX_PROGRAM_COMP_CONV_BASE;
!   int fragment_offset = GLC_FRAGMENT_PROGRAM_COMP_CONV_BASE;
! 
!   if (!(src->feature_mask & GLC_FEATURE_CONVOLUTION_FILTER_MASK))
!     return 0;
! 
!   if (!programs->vertex[vertex_offset])
!     programs->vertex[vertex_offset] = glc_program_compile_vertex_arb
!       (proc_address, vertex_offset);
! 
!   fragment_offset += _glc_program_offset (src_texture, mask_texture);
!   
!   if (!programs->fragment[fragment_offset])
!     programs->fragment[fragment_offset] = glc_program_compile_fragment_arb
!       (proc_address, fragment_offset);
!   
!   if (programs->fragment[fragment_offset] && programs->vertex[vertex_offset]) {
! 
!     glEnable (GL_VERTEX_PROGRAM_ARB);
!     proc_address->gl_bind_program_arb (GL_VERTEX_PROGRAM_ARB,
!                                        programs->vertex[vertex_offset]);
!     proc_address->gl_program_local_param_4d_arb (GL_VERTEX_PROGRAM_ARB, 0,
!                                                  src_texture->texcoord_width /
!                                                  (double) src_texture->width,
!                                                  0.000, 0.0, 0.0);
!     proc_address->gl_program_local_param_4d_arb (GL_VERTEX_PROGRAM_ARB, 1,
!                                                  0.000,
!                                                  src_texture->texcoord_height /
!                                                  (double) src_texture->height,
!                                                  0.0, 0.0);
      
+     glEnable (GL_FRAGMENT_PROGRAM_ARB);
+     proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB,
+                                        programs->fragment[fragment_offset]);
+     proc_address->gl_program_local_param_4d_arb (GL_FRAGMENT_PROGRAM_ARB, 0,
+                                                  src->convolution->m[0][0],
+                                                  src->convolution->m[0][1],
+                                                  src->convolution->m[0][2],
+                                                  0.0);
+     proc_address->gl_program_local_param_4d_arb (GL_FRAGMENT_PROGRAM_ARB, 1,
+                                                  src->convolution->m[1][0],
+                                                  src->convolution->m[1][1],
+                                                  src->convolution->m[1][2],
+                                                  0.0);
+     proc_address->gl_program_local_param_4d_arb (GL_FRAGMENT_PROGRAM_ARB, 2,
+                                                  src->convolution->m[2][0],
+                                                  src->convolution->m[2][1],
+                                                  src->convolution->m[2][2],
+                                                  0.0);
      return 1;
    }
+   
+   return 0;
+ }
  #endif
  
+ glc_bool_t
+ glc_program_enable (glc_surface_t *surface,
+                     glc_texture_t *src_texture,
+                     glc_texture_t *mask_texture)
+ {
+   
+ #ifdef GL_ARB_fragment_program
+   if ((!mask_texture) && (!surface->convolution))
+     return 1;
+   
+   if (surface->convolution)
+     return glc_program_enable_comp_conv (surface->proc_address,
+                                          surface->programs,
+                                          surface,
+                                          src_texture,
+                                          mask_texture);
+   else
+     return glc_program_enable_comp (surface->proc_address,
+                                     surface->programs,
+                                     src_texture,
+                                     mask_texture);
+ #endif
+   
    return 0;
  }
  
  void
! glc_program_disable (glc_surface_t *surface)
  {
    
  #ifdef GL_ARB_fragment_program
!   surface->proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB, 0);
    glDisable (GL_FRAGMENT_PROGRAM_ARB);
+   surface->proc_address->gl_bind_program_arb (GL_VERTEX_PROGRAM_ARB, 0);
+   glDisable (GL_VERTEX_PROGRAM_ARB);
  #endif
    

Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** a/glc_surface.c	18 Feb 2004 14:52:45 -0000	1.16
--- b/glc_surface.c	20 Feb 2004 17:40:57 -0000	1.17
***************
*** 53,56 ****
--- 53,57 ----
    surface->dirty = 0;
    surface->requires_flipping = 1;
+   surface->convolution = NULL;
  }
  
***************
*** 60,63 ****
--- 61,67 ----
    if (surface->transform)
      free (surface->transform);
+ 
+   if (surface->convolution)
+     free (surface->convolution);
  }
  
***************
*** 108,114 ****
    if (surface->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
      return
!       glc_program_enable_fragment_arb (surface->proc_address,
!                                        surface->programs,
!                                        src, mask);
    
    return 0;
--- 112,116 ----
    if (surface->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
      return
!       glc_program_enable (surface, src, mask);
    
    return 0;
***************
*** 119,123 ****
  {
    if (surface->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
!     glc_program_disable_fragment_arb (surface->proc_address);
  }
  
--- 121,125 ----
  {
    if (surface->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
!     glc_program_disable (surface);
  }
  
***************
*** 130,134 ****
        { FIXED1, 0x00000, 0x00000 },
        { 0x00000, FIXED1, 0x00000 },
!       { 0x00000, 0x00000, FIXED1 },
      }
    };
--- 132,136 ----
        { FIXED1, 0x00000, 0x00000 },
        { 0x00000, FIXED1, 0x00000 },
!       { 0x00000, 0x00000, FIXED1 }
      }
    };
***************
*** 168,171 ****
--- 170,216 ----
  
  void
+ glc_surface_set_convolution (glc_surface_t *surface,
+                              glc_convolution_t *convolution)
+ {
+   if (convolution &&
+       convolution->matrix[0][0] == 0x00000 &&
+       convolution->matrix[0][1] == 0x00000 &&
+       convolution->matrix[0][2] == 0x00000 &&
+       convolution->matrix[1][0] == 0x00000 &&
+       convolution->matrix[1][2] == 0x00000 &&
+       convolution->matrix[2][0] == 0x00000 &&
+       convolution->matrix[2][1] == 0x00000 &&
+       convolution->matrix[2][2] == 0x00000)
+     convolution = NULL;
+   
+   if (convolution) {
+     int row, col;
+     
+     if (!surface->convolution) {
+       surface->convolution = malloc (sizeof (glc_matrix_t));
+       if (!surface->convolution)
+ 		return;
+ 	}
+ 
+     for (row = 0; row < 3; row++)
+       for (col = 0; col < 3; col++)
+         surface->convolution->m[row][col] =
+           FIXED_TO_DOUBLE (convolution->matrix[row][col]);
+     
+     if (glc_matrix_normalize (surface->convolution)) {
+       free (surface->convolution);
+       surface->convolution = NULL;
+       glc_surface_status_add (surface, GLC_STATUS_INVALID_MATRIX_MASK);
+     }
+   } else {
+     if (surface->convolution) {
+       free (surface->convolution);
+       surface->convolution = NULL;
+     }
+   }
+ }
+ slim_hidden_def(glc_surface_set_convolution);
+ 
+ void
  glc_surface_set_repeat (glc_surface_t *surface,
                          glc_bool_t repeat)

Index: glc_util.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** a/glc_util.c	12 Feb 2004 12:49:39 -0000	1.8
--- b/glc_util.c	20 Feb 2004 17:40:57 -0000	1.9
***************
*** 63,66 ****
--- 63,94 ----
  }
  
+ void
+ glc_intersect_sub_pixel_region (glc_sub_pixel_region_box_t *box1,
+                                 glc_sub_pixel_region_box_t *box2,
+                                 glc_sub_pixel_region_box_t *return_box)
+ {
+   return_box->x1 = (box1->x1 >= box2->x1)? box1->x1: box2->x1;
+   return_box->x2 = (box1->x2 <= box2->x2)? box1->x2: box2->x2;
+   return_box->y1 = (box1->y1 >= box2->y1)? box1->y1: box2->y1;
+   return_box->y2 = (box1->y2 <= box2->y2)? box1->y2: box2->y2;
+ 
+   if (return_box->x1 >= return_box->x2)
+     return_box->x1 = return_box->x2 = 0.0;
+   
+   if (return_box->y1 >= return_box->y2)
+     return_box->y1 = return_box->y2 = 0.0;
+ }
+ 
+ void
+ glc_union_sub_pixel_region (glc_sub_pixel_region_box_t *box1,
+                             glc_sub_pixel_region_box_t *box2,
+                             glc_sub_pixel_region_box_t *return_box)
+ {
+   return_box->x1 = (box1->x1 <= box2->x1)? box1->x1: box2->x1;
+   return_box->x2 = (box1->x2 >= box2->x2)? box1->x2: box2->x2;
+   return_box->y1 = (box1->y1 <= box2->y1)? box1->y1: box2->y1;
+   return_box->y2 = (box1->y2 >= box2->y2)? box1->y2: box2->y2;
+ }
+ 
  static int
  big_endian (void)

Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** a/glcint.h	18 Feb 2004 14:52:45 -0000	1.17
--- b/glcint.h	20 Feb 2004 17:40:57 -0000	1.18
***************
*** 97,101 ****
       (GLenum, GLenum, GLsizei, const GLvoid *);
  typedef void (* glc_proc_ptr_gl_bind_program_arb_t)
!       (GLenum, GLuint);
  
  typedef struct _glc_gl_proc_address_list_t {
--- 97,105 ----
       (GLenum, GLenum, GLsizei, const GLvoid *);
  typedef void (* glc_proc_ptr_gl_bind_program_arb_t)
!      (GLenum, GLuint);
! typedef void (* glc_proc_ptr_gl_program_local_param_4d_arb_t)
!      (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
! typedef void (* glc_proc_ptr_gl_get_program_iv_arb_t)
!      (GLenum, GLenum, GLuint *);
  
  typedef struct _glc_gl_proc_address_list_t {
***************
*** 111,114 ****
--- 115,120 ----
    glc_proc_ptr_gl_program_string_arb_t gl_program_string_arb;
    glc_proc_ptr_gl_bind_program_arb_t gl_bind_program_arb;
+   glc_proc_ptr_gl_program_local_param_4d_arb_t gl_program_local_param_4d_arb;
+   glc_proc_ptr_gl_get_program_iv_arb_t gl_get_program_iv_arb;
  #endif
  
***************
*** 116,125 ****
  } glc_gl_proc_address_list_t;
  
! typedef struct _glc_fragment_programs_t {
!   unsigned int program_2d_2d;
!   unsigned int program_rect_2d;
!   unsigned int program_2d_rect;
!   unsigned int program_rect_rect;
! } glc_fragment_programs_t;
  
  typedef enum {
--- 122,144 ----
  } glc_gl_proc_address_list_t;
  
! #define GLC_VERTEX_PROGRAMS   1
! #define GLC_FRAGMENT_PROGRAMS 10
! 
! #define GLC_VERTEX_PROGRAM_COMP_CONV_BASE 0
! 
! #define GLC_FRAGMENT_PROGRAM_COMP_BASE      0
! #define GLC_FRAGMENT_PROGRAM_COMP_CONV_BASE 4
! 
! #define GLC_FRAGMENT_PROGRAM_2D_2D_OFFSET     0
! #define GLC_FRAGMENT_PROGRAM_RECT_2D_OFFSET   1
! #define GLC_FRAGMENT_PROGRAM_2D_RECT_OFFSET   2
! #define GLC_FRAGMENT_PROGRAM_RECT_RECT_OFFSET 3
! #define GLC_FRAGMENT_PROGRAM_2D_OFFSET        4
! #define GLC_FRAGMENT_PROGRAM_RECT_OFFSET      5
! 
! typedef struct _glc_programs_t {
!   unsigned long vertex[GLC_VERTEX_PROGRAMS];
!   unsigned long fragment[GLC_FRAGMENT_PROGRAMS];
! } glc_programs_t;
  
  typedef enum {
***************
*** 134,137 ****
--- 153,160 ----
  } glc_region_box_t;
  
+ typedef struct _glc_sub_pixel_region_box_t {
+   double x1, x2, y1, y2;
+ } glc_sub_pixel_region_box_t;
+ 
  typedef struct _glc_point_t {
    double x, y;
***************
*** 139,143 ****
  
  typedef struct _glc_matrix_t {
!   double m[3][2];
  } glc_matrix_t;
  
--- 162,166 ----
  
  typedef struct _glc_matrix_t {
!   double m[3][3];
  } glc_matrix_t;
  
***************
*** 205,209 ****
    glc_bool_t requires_flipping;
    glc_gl_proc_address_list_t *proc_address;
!   glc_fragment_programs_t *programs;
  };
  
--- 228,233 ----
    glc_bool_t requires_flipping;
    glc_gl_proc_address_list_t *proc_address;
!   glc_programs_t *programs;
!   glc_matrix_t *convolution;
  };
  
***************
*** 217,223 ****
--- 241,254 ----
                              glc_point_t *point);
  
+ extern void __internal_linkage
+ glc_matrix_transform_sub_pixel_region (glc_matrix_t *matrix,
+                                        glc_sub_pixel_region_box_t *region);
+ 
  extern glc_status_t __internal_linkage
  glc_matrix_invert (glc_matrix_t *matrix);
  
+ extern glc_status_t __internal_linkage
+ glc_matrix_normalize (glc_matrix_t *matrix);
+ 
  extern void __internal_linkage
  glc_set_operator (glc_operator_t op);
***************
*** 233,236 ****
--- 264,277 ----
                    glc_region_box_t *return_box);
  
+ extern void __internal_linkage
+ glc_intersect_sub_pixel_region (glc_sub_pixel_region_box_t *box1,
+                                 glc_sub_pixel_region_box_t *box2,
+                                 glc_sub_pixel_region_box_t *return_box);
+ 
+ extern void __internal_linkage
+ glc_union_sub_pixel_region (glc_sub_pixel_region_box_t *box1,
+                             glc_sub_pixel_region_box_t *box2,
+                             glc_sub_pixel_region_box_t *return_box);
+ 
  extern unsigned int __internal_linkage
  glc_get_gl_format_from_bpp (unsigned short bpp);
***************
*** 345,355 ****
  
  extern glc_bool_t __internal_linkage
! glc_program_enable_fragment_arb (glc_gl_proc_address_list_t *proc_address,
!                                  glc_fragment_programs_t *programs,
!                                  glc_texture_t *src_texture,
!                                  glc_texture_t *mask_texture);
  
  extern void __internal_linkage
! glc_program_disable_fragment_arb (glc_gl_proc_address_list_t *proc_address);
  
  #define MAXSHORT SHRT_MAX
--- 386,395 ----
  
  extern glc_bool_t __internal_linkage
! glc_program_enable (glc_surface_t *surface,
!                     glc_texture_t *src_texture,
!                     glc_texture_t *mask_texture);
  
  extern void __internal_linkage
! glc_program_disable (glc_surface_t *surface);
  
  #define MAXSHORT SHRT_MAX
***************
*** 411,414 ****
--- 451,455 ----
  
  slim_hidden_proto(glc_surface_set_transform)
+ slim_hidden_proto(glc_surface_set_convolution)
  slim_hidden_proto(glc_surface_set_repeat)
  slim_hidden_proto(glc_surface_set_filter)
***************
*** 444,453 ****
  #endif
  
! #define GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK     (1L << 0)
! #define GLC_GLX_FEATURE_MULTISAMPLE_MASK           (1L << 1)
! #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK    (1L << 2)
! #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK    (1L << 3)
! #define GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 4)
! #define GLC_GLX_FEATURE_ATI_RENDER_TEXTURE_MASK    (1L << 5)
  
  typedef struct _glc_glx_surface glc_glx_surface_t;
--- 485,495 ----
  #endif
  
! #define GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK    (1L << 0)
! #define GLC_GLX_FEATURE_MULTISAMPLE_MASK          (1L << 1)
! #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK   (1L << 2)
! #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK   (1L << 3)
! #define GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK   (1L << 4)
! #define GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK (1L << 5)
! #define GLC_GLX_FEATURE_ATI_RENDER_TEXTURE_MASK   (1L << 6)
  
  typedef struct _glc_glx_surface glc_glx_surface_t;
***************
*** 548,552 ****
    long int texture_mask;
  
!   glc_fragment_programs_t programs;
  };
  
--- 590,594 ----
    long int texture_mask;
  
!   glc_programs_t programs;
  };
  
***************
*** 635,639 ****
  #define GLC_AGL_FEATURE_MULTISAMPLE_MASK          (1L << 2)
  #define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK   (1L << 3)
! #define GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK (1L << 4)
  
  typedef struct _glc_agl_surface_t glc_agl_surface_t;
--- 677,682 ----
  #define GLC_AGL_FEATURE_MULTISAMPLE_MASK          (1L << 2)
  #define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK   (1L << 3)
! #define GLC_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK   (1L << 4)
! #define GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK (1L << 5)
  
  typedef struct _glc_agl_surface_t glc_agl_surface_t;
***************
*** 667,671 ****
    long int texture_mask;
  
!   glc_fragment_programs_t programs;
  } glc_agl_thread_info_t;
  
--- 710,714 ----
    long int texture_mask;
  
!   glc_programs_t programs;
  } glc_agl_thread_info_t;
  





More information about the cairo-commit mailing list