[cairo-commit] libglc/src glc_program.c,NONE,1.1 Makefile.am,1.7,1.8 glc.c,1.14,1.15 glc.h,1.8,1.9 glc_agl_context.c,1.2,1.3 glc_agl_extension.c,1.1,1.2 glc_agl_format.c,1.4,1.5 glc_agl_info.c,1.2,1.3 glc_agl_pbuffer.c,1.3,1.4 glc_agl_surface.c,1.4,1.5 glc_format.c,1.2,1.3 glc_glx_context.c,1.7,1.8 glc_glx_extension.c,1.6,1.7 glc_glx_format.c,1.11,1.12 glc_glx_info.c,1.7,1.8 glc_glx_pbuffer.c,1.4,1.5 glc_glx_surface.c,1.10,1.11 glc_matrix.c,1.1,1.2 glc_operator.c,1.2,1.3 glc_rect.c,1.8,1.9 glc_status.c,1.1.1.1,1.2 glc_surface.c,1.12,1.13 glc_texture.c,1.6,1.7 glc_trap.c,1.9,1.10 glc_tri.c,1.9,1.10 glc_util.c,1.6,1.7 glcint.h,1.13,1.14

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-serv28503/src

Modified Files:
	Makefile.am glc.c glc.h glc_agl_context.c glc_agl_extension.c 
	glc_agl_format.c glc_agl_info.c glc_agl_pbuffer.c 
	glc_agl_surface.c glc_format.c glc_glx_context.c 
	glc_glx_extension.c glc_glx_format.c glc_glx_info.c 
	glc_glx_pbuffer.c glc_glx_surface.c glc_matrix.c 
	glc_operator.c glc_rect.c glc_status.c glc_surface.c 
	glc_texture.c glc_trap.c glc_tri.c glc_util.c glcint.h 
Added Files:
	glc_program.c 
Log Message:
Merged fragment program code

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

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/libglc/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Makefile.am	5 Feb 2004 22:22:28 -0000	1.7
--- Makefile.am	10 Feb 2004 23:38:36 -0000	1.8
***************
*** 39,42 ****
--- 39,43 ----
  	glc_util.c \
  	glc_format.c \
+ 	glc_program.c \
  	$(libglc_glx_sources) \
  	$(libglc_agl_sources) \

Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** glc.c	6 Feb 2004 14:03:39 -0000	1.14
--- glc.c	10 Feb 2004 23:38:36 -0000	1.15
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 32,35 ****
--- 32,261 ----
  #include "glcint.h"
  
+ #include <math.h>
+ 
+ #define GLC_ROUND(value) (floor (value + 0.5))
+ 
+ #define TRANSFORM(surface) \
+   (surface->transform)
+ 
+ #define REPEAT(surface) \
+   (surface->repeat)
+ 
+ #define GLREPEAT(surface, texture) \
+   (surface->repeat && texture->repeatable)
+ 
+ #define MANUALREPEAT(surface, texture) \
+   (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)
+ {
+   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 translation we can emulate this
+        by shifting destination coordinates. */
+     if ((!TRANSFORM (mask)) && TRANSLATE (src)) {
+       x_dst += GLC_ROUND (src->transform->m[2][0]);
+       y_dst += GLC_ROUND (src->transform->m[2][1]);
+     } else
+       return 0;
+   }
+   
+   src_texture = glc_surface_get_texture (src);
+   mask_texture = glc_surface_get_texture (mask);
+ 
+   if (MANUALREPEAT (src, src_texture) ||
+       MANUALREPEAT (mask, mask_texture))
+     return 0;
+ 
+   if (!glc_surface_push_current (dst, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
+     glc_surface_pop_current (dst);
+     return 0;
+   }
+ 
+   glDisable (GL_SCISSOR_TEST);
+ 
+   if (!glc_surface_enable_program (dst, src_texture, mask_texture))
+     return 0;
+ 
+   glc_set_operator (op);
+ 
+   glActiveTextureARB (GL_TEXTURE0_ARB);
+   glc_texture_bind (src_texture);
+ 
+   glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ 
+   glc_texture_ensure_filter (src_texture, src->filter);
+   glc_texture_ensure_repeat (src_texture, src->repeat);
+ 
+   glActiveTextureARB (GL_TEXTURE1_ARB);
+   glc_texture_bind (mask_texture);
+ 
+   glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ 
+   glc_texture_ensure_filter (mask_texture, mask->filter);
+   glc_texture_ensure_repeat (mask_texture, mask->repeat);
+ 
+   dst_region.x1 = x_dst;
+   dst_region.y1 = y_dst;
+   dst_region.x2 = dst_region.x1 + width;
+   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;    
+     src_region.x1 = x_src % src->width;
+     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;    
+     mask_region.x1 = x_mask % mask->width;
+     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;
+   }
+   
+   glBegin (GL_QUADS);
+   
+   glMultiTexCoord2dARB (GL_TEXTURE0_ARB, src_tl.x, src_tl.y);
+   glMultiTexCoord2dARB (GL_TEXTURE1_ARB, mask_tl.x, mask_tl.y);
+   glVertex2i (dst_region.x1, dst_region.y1);
+ 
+   glMultiTexCoord2dARB (GL_TEXTURE0_ARB, src_br.x, src_tl.y);
+   glMultiTexCoord2dARB (GL_TEXTURE1_ARB, mask_br.x, mask_tl.y);
+   glVertex2i (dst_region.x2, dst_region.y1);
+ 
+   glMultiTexCoord2dARB (GL_TEXTURE0_ARB, src_br.x, src_br.y);
+   glMultiTexCoord2dARB (GL_TEXTURE1_ARB, mask_br.x, mask_br.y);
+   glVertex2i (dst_region.x2, dst_region.y2);
+ 
+   glMultiTexCoord2dARB (GL_TEXTURE0_ARB, src_tl.x, src_br.y);
+   glMultiTexCoord2dARB (GL_TEXTURE1_ARB, mask_tl.x, mask_br.y);
+   glVertex2i (dst_region.x1, dst_region.y2);
+ 
+   glEnd ();
+ 
+   glc_texture_unbind (mask_texture);
+ 
+   glActiveTextureARB (GL_TEXTURE0_ARB);
+   glc_texture_unbind (src_texture);
+ 
+   glc_surface_disable_program (dst);
+ 
+   glc_surface_dirty (dst, &dst_region);
+     
+   glc_surface_pop_current (dst);
+ 
+   return 1;
+ }
+ 
  static void
  glc_mask_bounds (glc_surface_t *src,
***************
*** 52,56 ****
    else
      mbounds->y1 = bounds->y1;
-   
  
    if (bounds->x2 >= dst->width)
--- 278,281 ----
***************
*** 64,81 ****
      mbounds->y2 = bounds->y2;
  
!   if (!src->repeat) {
!     if ((mbounds->x2 - mbounds->x1) >= (src->width - x_src))
!       mbounds->x2 = mbounds->x1 + (src->width - x_src);
! 
!     if ((mbounds->y2 - mbounds->y1) >= (src->height - y_src))
!       mbounds->y2 = mbounds->y1 + (src->height - y_src);
!   }
! 
!   if (!mask->repeat) {
!     if ((mbounds->x2 - mbounds->x1) >= (mask->width - x_mask))
!       mbounds->x2 = mbounds->x1 + (mask->width - x_mask);
  
!     if ((mbounds->y2 - mbounds->y1) >= (mask->height - y_mask))
!       mbounds->y2 = mbounds->y1 + (mask->height - y_mask);
    }
  }
--- 289,310 ----
      mbounds->y2 = bounds->y2;
  
!   /* TODO: This can be optimized by clipping to transformed
!      surface coordinates. */
!   if ((!TRANSFORM (src)) && (!TRANSFORM (mask))) {
!     if (!src->repeat) {
!       if ((mbounds->x2 - mbounds->x1) >= (src->width - x_src))
!         mbounds->x2 = mbounds->x1 + (src->width - x_src);
!       
!       if ((mbounds->y2 - mbounds->y1) >= (src->height - y_src))
!         mbounds->y2 = mbounds->y1 + (src->height - y_src);
!     }
  
!     if (!mask->repeat) {
!       if ((mbounds->x2 - mbounds->x1) >= (mask->width - x_mask))
!         mbounds->x2 = mbounds->x1 + (mask->width - x_mask);
!       
!       if ((mbounds->y2 - mbounds->y1) >= (mask->height - y_mask))
!         mbounds->y2 = mbounds->y1 + (mask->height - y_mask);
!     }
    }
  }
***************
*** 95,99 ****
                 int height)
  {
!   glc_surface_t *intermediate = NULL, *mask_surface;
    glc_texture_t *texture;
    glc_point_t tl, bl, br, tr;
--- 324,328 ----
                 int height)
  {
!   glc_surface_t *intermediate = NULL, *src_intermediate = NULL, *mask_surface;
    glc_texture_t *texture;
    glc_point_t tl, bl, br, tr;
***************
*** 102,105 ****
--- 331,343 ----
    if (mask) {
      glc_region_box_t mask_bounds;
+     static glc_color_t clear_color = { 0x0000, 0x0000, 0x0000, 0x0000 };
+ 
+     if (_glc_program_composite (op,
+                                 src, mask, dst,
+                                 x_src, y_src,
+                                 x_mask, y_mask,
+                                 x_dst, y_dst,
+                                 width, height))
+       return;
  
      if (!mask->implicit_mask) {
***************
*** 120,127 ****
--- 358,367 ----
        mask_surface = intermediate =
          glc_surface_create_similar (dst,
+                                     GLC_STANDARD_ARGB32,
                                      mask_bounds.x2 -
                                      mask_bounds.x1,
                                      mask_bounds.y2 -
                                      mask_bounds.y1);
+       
        if (!mask_surface) {
          glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
***************
*** 129,133 ****
        }
  
!       glc_surface_disable_transform (mask);
        glc_composite (GLC_OPERATOR_SRC,
                       mask, NULL, mask_surface,
--- 369,380 ----
        }
  
!       if (TRANSFORM (mask))
!         glc_fill_rectangle (GLC_OPERATOR_SRC,
!                             mask_surface,
!                             &clear_color,
!                             0, 0,
!                             mask_surface->width,
!                             mask_surface->height);
!       
        glc_composite (GLC_OPERATOR_SRC,
                       mask, NULL, mask_surface,
***************
*** 135,146 ****
                       mask_surface->width,
                       mask_surface->height);
-       glc_surface_enable_transform (mask);
-       
      } else
        mask_surface = mask;
-     
-     width = mask_surface->width;
-     height = mask_surface->height;
  
      glc_composite (GLC_OPERATOR_IN,
                     src, NULL, mask_surface,
--- 382,406 ----
                       mask_surface->width,
                       mask_surface->height);
      } else
        mask_surface = mask;
  
+     if (TRANSFORM (src)) {
+       src_intermediate =
+         glc_surface_create_similar (dst,
+                                     GLC_STANDARD_ARGB32,
+                                     mask_surface->width,
+                                     mask_surface->height);
+       glc_fill_rectangle (GLC_OPERATOR_SRC, src_intermediate,
+                           &clear_color, 0, 0,
+                           mask_surface->width,
+                           mask_surface->height);
+       glc_composite (GLC_OPERATOR_SRC,
+                      src, NULL, src_intermediate,
+                      x_src, y_src, 0, 0, 0, 0,
+                      mask_surface->width,
+                      mask_surface->height);
+       src = src_intermediate;
+     }
+     
      glc_composite (GLC_OPERATOR_IN,
                     src, NULL, mask_surface,
***************
*** 149,152 ****
--- 409,414 ----
                     mask_surface->height);
      
+     width = mask_surface->width;
+     height = mask_surface->height;
      src = mask_surface;
      x_src = y_src = 0;
***************
*** 176,181 ****
    glc_set_operator (op);
    
!   if ((!src->transform) && (!src->disable_transform) &&
!       src->repeat && texture->repeatable) {
      /* CASE 1: Repeat, no transformation and power of two sized texture,
         GL can do repeat for us. */
--- 438,442 ----
    glc_set_operator (op);
    
!   if ((!TRANSFORM (src)) && GLREPEAT (src, texture)) {
      /* CASE 1: Repeat, no transformation and power of two sized texture,
         GL can do repeat for us. */
***************
*** 188,200 ****
      tr.x = br.x = x_dst + width;
      bl.y = br.y = y_dst + height;
! 
      /* Shift coordinates with source offset */
      if (x_src) {
!       x_src = (src->width % x_src);
        tl.x -= x_src;
        bl.x -= x_src;
      }
      if (y_src) {
!       y_src = (src->height % y_src);
        tl.y -= y_src;
        tr.y -= y_src;
--- 449,461 ----
      tr.x = br.x = x_dst + width;
      bl.y = br.y = y_dst + height;
!     
      /* Shift coordinates with source offset */
      if (x_src) {
!       x_src = (x_src % src->width);
        tl.x -= x_src;
        bl.x -= x_src;
      }
      if (y_src) {
!       y_src = (y_src % src->height);
        tl.y -= y_src;
        tr.y -= y_src;
***************
*** 210,222 ****
      glBegin (GL_QUADS);
      glTexCoord2d (0.0, repeat_factor_y);
!     glVertex2d (tl.x, tl.y);
      glTexCoord2d (repeat_factor_x, repeat_factor_y);
!     glVertex2d (tr.x, tr.y);
      glTexCoord2d (repeat_factor_x, 0.0);
!     glVertex2d (br.x, br.y);
      glTexCoord2d (0.0, 0.0);
!     glVertex2d (bl.x, bl.y);
      glEnd ();
!       
    } else {
      /* CASE 2: Either none power of two sized texture or
--- 471,483 ----
      glBegin (GL_QUADS);
      glTexCoord2d (0.0, repeat_factor_y);
!     glVertex2i (GLC_ROUND (tl.x), GLC_ROUND (tl.y));
      glTexCoord2d (repeat_factor_x, repeat_factor_y);
!     glVertex2i (GLC_ROUND (tr.x), GLC_ROUND (tr.y));
      glTexCoord2d (repeat_factor_x, 0.0);
!     glVertex2i (GLC_ROUND (br.x), GLC_ROUND (br.y));
      glTexCoord2d (0.0, 0.0);
!     glVertex2i (GLC_ROUND (bl.x), GLC_ROUND (bl.y));
      glEnd ();
!     
    } else {
      /* CASE 2: Either none power of two sized texture or
***************
*** 231,235 ****
      bl.y = br.y = src->height;
  
!     if (src->transform && (!src->disable_transform)) {
        glc_matrix_transform_point (src->transform, &tl);
        glc_matrix_transform_point (src->transform, &bl);
--- 492,496 ----
      bl.y = br.y = src->height;
  
!     if (TRANSFORM (src)) {
        glc_matrix_transform_point (src->transform, &tl);
        glc_matrix_transform_point (src->transform, &bl);
***************
*** 254,258 ****
      /* Shift all coordinates with source offset */
      if (x_src) {
!       x_src = (src->width % x_src);
        tl.x -= x_src;
        bl.x -= x_src;
--- 515,519 ----
      /* Shift all coordinates with source offset */
      if (x_src) {
!       x_src = (x_src % src->width);
        tl.x -= x_src;
        bl.x -= x_src;
***************
*** 261,265 ****
      }
      if (y_src) {
!       y_src = (src->height % y_src);
        tl.y -= y_src;
        bl.y -= y_src;
--- 522,526 ----
      }
      if (y_src) {
!       y_src = (y_src % src->height);
        tl.y -= y_src;
        bl.y -= y_src;
***************
*** 277,281 ****
          /* Clip to original source area if repeat and transform are both
             used. */
!         if ((!src->disable_transform) && src->transform && src->repeat) {
            glc_region_box_t src_clip, intersect_clip;
            
--- 538,542 ----
          /* Clip to original source area if repeat and transform are both
             used. */
!         if (TRANSFORM (src) && REPEAT (src)) {
            glc_region_box_t src_clip, intersect_clip;
            
***************
*** 295,306 ****
          
          glBegin (GL_QUADS);
!         glTexCoord2d (0.0, texture->texcoord_height);
!         glVertex2d (tl.x, tl.y);
!         glTexCoord2d (texture->texcoord_width, texture->texcoord_height);
!         glVertex2d (tr.x, tr.y);
!         glTexCoord2d (texture->texcoord_width, 0.0);
!         glVertex2d (br.x, br.y);
          glTexCoord2d (0.0, 0.0);
!         glVertex2d (bl.x, bl.y);
          glEnd ();
  
--- 556,568 ----
          
          glBegin (GL_QUADS);
!         glTexCoord2d (0.0, texture->texcoord_height - 0.0001);
!         glVertex2i (GLC_ROUND (tl.x), GLC_ROUND (tl.y));
!         glTexCoord2d (texture->texcoord_width - 0.0001,
!                       texture->texcoord_height - 0.0001);
!         glVertex2i (GLC_ROUND (tr.x), GLC_ROUND (tr.y));
!         glTexCoord2d (texture->texcoord_width - 0.0001, 0.0);
!         glVertex2i (GLC_ROUND (br.x), GLC_ROUND (br.y));
          glTexCoord2d (0.0, 0.0);
!         glVertex2i (GLC_ROUND (bl.x), GLC_ROUND (bl.y));
          glEnd ();
  
***************
*** 310,315 ****
          br.x += src->width;
          
!       } while ((!src->disable_transform) && src->repeat &&
!                (tl.x < (x_dst + width)));
        
        bl.y += src->height;
--- 572,576 ----
          br.x += src->width;
          
!       } while (REPEAT (src) && (tl.x < (x_dst + width)));
        
        bl.y += src->height;
***************
*** 323,328 ****
        br.x = save_brx;
        
!     } while ((!src->disable_transform) && src->repeat &&
!              (tl.y < (y_dst + height)));  
    }
  
--- 584,588 ----
        br.x = save_brx;
        
!     } while (REPEAT (src) && (tl.y < (y_dst + height)));  
    }
  
***************
*** 333,336 ****
--- 593,599 ----
    glc_surface_pop_current (dst);
  
+   if (src_intermediate)
+     glc_surface_destroy (src_intermediate);
+     
    if (intermediate)
      glc_surface_destroy (intermediate);

Index: glc.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glc.h	5 Feb 2004 22:22:28 -0000	1.8
--- glc.h	10 Feb 2004 23:38:36 -0000	1.9
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 130,137 ****
  } glc_operator_t;
  
! #define GLC_FEATURE_OFFSCREEN_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)
  
  typedef enum {  
--- 130,139 ----
  } glc_operator_t;
  
! #define GLC_FEATURE_OFFSCREEN_DRAWING_MASK     (1L << 0)
! #define GLC_FEATURE_EXT_TEXTURE_RECTANGLE_MASK (1L << 1)
! #define GLC_FEATURE_NV_TEXTURE_RECTANGLE_MASK  (1L << 2)
! #define GLC_FEATURE_MULTISAMPLE_MASK           (1L << 3)
! #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK (1L << 4)
! #define GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 5)
  
  typedef enum {  
***************
*** 153,157 ****
  #define GLC_FORMAT_MULTISAMPLE_MASK         (1 <<  9)
  #define GLC_FORMAT_MULTISAMPLE_SAMPLES_MASK (1 << 10)
! 
  typedef unsigned long int glc_format_id_t;
  
--- 155,159 ----
  #define GLC_FORMAT_MULTISAMPLE_MASK         (1 <<  9)
  #define GLC_FORMAT_MULTISAMPLE_SAMPLES_MASK (1 << 10)
!   
  typedef unsigned long int glc_format_id_t;
  
***************
*** 238,242 ****
  
  void
! glc_surface_show (glc_surface_t *surface);
  
  int
--- 240,248 ----
  
  void
! glc_surface_show (glc_surface_t *surface,
!                   int x,
!                   int y,
!                   unsigned int width,
!                   unsigned int height);
  
  int

Index: glc_agl_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_context.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_agl_context.c	5 Feb 2004 22:22:28 -0000	1.2
--- glc_agl_context.c	10 Feb 2004 23:38:36 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 81,85 ****
    surface->base.anti_aliasing = 0;
  
!   if (surface->format->multisample.supported) {
      if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
        glEnable (GL_MULTISAMPLE_ARB);
--- 81,85 ----
    surface->base.anti_aliasing = 0;
  
!   if (surface->base.format->multisample.supported) {
      if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
        glEnable (GL_MULTISAMPLE_ARB);

Index: glc_agl_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_extension.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glc_agl_extension.c	3 Feb 2004 15:12:11 -0000	1.1
--- glc_agl_extension.c	10 Feb 2004 23:38:36 -0000	1.2
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 36,46 ****
  
  #if GL_EXT_texture_rectangle
!   { "GL_EXT_texture_rectangle", GLC_AGL_FEATURE_TEXTURE_RECTANGLE_MASK },
! #elif GL_NV_texture_rectangle
!   { "GL_NV_texture_rectangle", GLC_AGL_FEATURE_TEXTURE_RECTANGLE_MASK },
  #endif
  
    { "GL_ARB_multisample", GLC_AGL_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK },
    { NULL, 0 }
  };
--- 36,49 ----
  
  #if GL_EXT_texture_rectangle
!   { "GL_EXT_texture_rectangle", GLC_AGL_FEATURE_EXT_TEXTURE_RECTANGLE_MASK },
! #endif
!   
! #if GL_NV_texture_rectangle
!   { "GL_NV_texture_rectangle", GLC_AGL_FEATURE_NV_TEXTURE_RECTANGLE_MASK },
  #endif
  
    { "GL_ARB_multisample", GLC_AGL_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK },
+   { "GL_ARB_fragment_program", GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK },
    { NULL, 0 }
  };
***************
*** 64,71 ****
  
    thread_info->feature_mask = 0;
!   thread_info->texture_mask = 0;
  
    if (thread_info->agl_feature_mask & GLC_AGL_FEATURE_PBUFFER_MASK)
!     thread_info->feature_mask |= GLC_FEATURE_OFFSCREEN_MASK;
  
    if (thread_info->agl_feature_mask & GLC_AGL_FEATURE_MULTISAMPLE_MASK) {
--- 67,74 ----
  
    thread_info->feature_mask = 0;
!   thread_info->texture_mask = GLC_TEXTURE_TARGET_2D_MASK;
  
    if (thread_info->agl_feature_mask & GLC_AGL_FEATURE_PBUFFER_MASK)
!     thread_info->feature_mask |= GLC_FEATURE_OFFSCREEN_DRAWING_MASK;
  
    if (thread_info->agl_feature_mask & GLC_AGL_FEATURE_MULTISAMPLE_MASK) {
***************
*** 80,86 ****
  
    if (thread_info->agl_feature_mask &
!       GLC_AGL_FEATURE_TEXTURE_RECTANGLE_MASK) {
!     thread_info->texture_mask |= GLC_TEXTURE_TARGET_RECTANGLE_MASK;
!     thread_info->feature_mask |= GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
    }
  }
--- 83,99 ----
  
    if (thread_info->agl_feature_mask &
!       GLC_AGL_FEATURE_EXT_TEXTURE_RECTANGLE_MASK) {
!     thread_info->texture_mask |= GLC_TEXTURE_TARGET_EXT_RECTANGLE_MASK;
!     thread_info->feature_mask |= GLC_FEATURE_EXT_TEXTURE_RECTANGLE_MASK;
    }
+ 
+   if (thread_info->agl_feature_mask &
+       GLC_AGL_FEATURE_NV_TEXTURE_RECTANGLE_MASK) {
+     thread_info->texture_mask |= GLC_TEXTURE_TARGET_NV_RECTANGLE_MASK;
+     thread_info->feature_mask |= GLC_FEATURE_NV_TEXTURE_RECTANGLE_MASK;
+   }
+ 
+   if (thread_info->agl_feature_mask &
+       GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
+     thread_info->feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
  }

Index: glc_agl_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_format.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_agl_format.c	6 Feb 2004 14:03:39 -0000	1.4
--- glc_agl_format.c	10 Feb 2004 23:38:36 -0000	1.5
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 170,180 ****
                   glc_format_t *format)
  {
!   int index = thread_info->n_formats++;
!   
!   thread_info->formats =
!     realloc (thread_info->formats,
!              sizeof (glc_format_t) * thread_info->n_formats);
    
!   memcpy (&thread_info->formats[index], format, sizeof (glc_format_t));
  }
  
--- 170,183 ----
                   glc_format_t *format)
  {
!   if (!glc_format_find (thread_info->formats, thread_info->n_formats,
!                         GLC_FORMAT_ALL_EXCEPT_ID_MASK, format, 0)) {
!     int index = thread_info->n_formats++;
!     
!     thread_info->formats =
!       realloc (thread_info->formats,
!                sizeof (glc_format_t) * thread_info->n_formats);
    
!     memcpy (&thread_info->formats[index], format, sizeof (glc_format_t));
!   }
  }
  
***************
*** 200,203 ****
--- 203,207 ----
    AGLPixelFormat pixel_format;
    int i = 0;
+   glc_bool_t offscreen_argb32_format = 0;
  
    for (i = 0; *(pixel_format_attrib_map[i].attrib); i++) {
***************
*** 226,230 ****
  
      format.drawable.onscreen = 1;
!     if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
        format.drawable.offscreen = 1;
      else
--- 230,234 ----
  
      format.drawable.onscreen = 1;
!     if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_DRAWING_MASK)
        format.drawable.offscreen = 1;
      else
***************
*** 257,260 ****
--- 261,268 ----
        format.multisample.samples = 0;
      }
+ 
+     if (format.drawable.offscreen &&
+         format.alpha && format.red && format.green && format.blue) 
+       offscreen_argb32_format = 1;
      
      _glc_add_format (thread_info, &format);
***************
*** 275,282 ****
           sizeof (glc_format_t), _glc_agl_format_compare);
    
!   /* Adding fake offscreen format if no real offscreen formats exists.
!      Surfaces created with this format can only be used with draw/read
       pixel functions and as source in composite functions. */
!   if (!(thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)) {
      memset (&format, 0, sizeof (glc_format_t));
      format.drawable.offscreen = 1;
--- 283,290 ----
           sizeof (glc_format_t), _glc_agl_format_compare);
    
!   /* Adding fake offscreen formats if no real argb32 offscreen formats exist.
!      Surfaces created with these formats can only be used with draw/read
       pixel functions and as source in composite functions. */
!   if (!offscreen_argb32_format) {
      memset (&format, 0, sizeof (glc_format_t));
      format.drawable.offscreen = 1;

Index: glc_agl_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_info.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_agl_info.c	5 Feb 2004 22:22:28 -0000	1.2
--- glc_agl_info.c	10 Feb 2004 23:38:36 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 74,78 ****
    0,
    0,
!   0
  };
  
--- 74,80 ----
    0,
    0,
!   0,
!   0,
!   { 0, 0, 0, 0 }
  };
  
***************
*** 102,105 ****
--- 104,111 ----
    thread_info->contexts = NULL;
    thread_info->n_contexts = 0;
+   thread_info->programs.program_2d_2d = 0;
+   thread_info->programs.program_rect_2d = 0;
+   thread_info->programs.program_2d_rect = 0;
+   thread_info->programs.program_rect_rect = 0;
    thread_info->root_context.pixel_format =
      aglChoosePixelFormat (NULL, 0, attrib);

Index: glc_agl_pbuffer.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_pbuffer.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_agl_pbuffer.c	6 Feb 2004 14:03:39 -0000	1.3
--- glc_agl_pbuffer.c	10 Feb 2004 23:38:36 -0000	1.4
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software

Index: glc_agl_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_surface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_agl_surface.c	6 Feb 2004 14:03:39 -0000	1.4
--- glc_agl_surface.c	10 Feb 2004 23:38:36 -0000	1.5
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 34,37 ****
--- 34,38 ----
  static glc_surface_t *
  _glc_agl_surface_create_similar (void *abstract_templ,
+                                  glc_format_name_t format_name,
                                   int width,
                                   int height);
***************
*** 80,83 ****
--- 81,110 ----
  }
  
+ static glc_bool_t
+ _glc_agl_surface_enable_program (void *abstract_surface,
+                                  glc_texture_t *src,
+                                  glc_texture_t *mask)
+ {
+   glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
+   glc_bool_t status = 0;
+ 
+   if (surface->thread_info->feature_mask &
+       GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
+     status = glc_program_enable_fragment_arb (&surface->thread_info->programs,
+                                               src, mask);
+ 
+   return status;
+ }
+ 
+ static void
+ _glc_agl_surface_disable_program (void *abstract_surface)
+ {
+   glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
+ 
+   if (surface->thread_info->feature_mask &
+       GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
+     glc_program_disable_fragment_arb ();
+ }
+ 
  static const struct glc_surface_backend glc_agl_surface_backend = {
    _glc_agl_surface_create_similar,
***************
*** 87,91 ****
    _glc_agl_surface_get_texture,
    _glc_agl_surface_realize,
!   _glc_agl_surface_show
  };
  
--- 114,120 ----
    _glc_agl_surface_get_texture,
    _glc_agl_surface_realize,
!   _glc_agl_surface_show,
!   _glc_agl_surface_enable_program,
!   _glc_agl_surface_disable_program
  };
  
***************
*** 97,101 ****
      
    if (!surface->pbuffer)
!     glc_texture_copy_surface (surface->texture, &surface->base,
                                &surface->base.dirty_region);
    
--- 126,130 ----
      
    if (!surface->pbuffer)
!     glc_texture_copy_surface (surface->base.texture, &surface->base,
                                &surface->base.dirty_region);
    
***************
*** 107,116 ****
    glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
  
!   if (!surface->texture->allocated)
!     glc_texture_allocate (surface->texture);
    
    _glc_agl_surface_ensure_texture (surface);
    
!   return surface->texture;
  }
  
--- 136,145 ----
    glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
  
!   if (!surface->base.texture->allocated)
!     glc_texture_allocate (surface->base.texture);
    
    _glc_agl_surface_ensure_texture (surface);
    
!   return surface->base.texture;
  }
  
***************
*** 137,140 ****
--- 166,170 ----
    glc_agl_context_t *context;
    unsigned int texture_format;
+   long int texture_target_mask;
  
    context = glc_agl_context_get (thread_info, format, 1);
***************
*** 150,154 ****
    surface->thread_info = thread_info;
    surface->context = context;
!   surface->format = format;
    
    surface->base.red = format->red;
--- 180,184 ----
    surface->thread_info = thread_info;
    surface->context = context;
!   surface->base.format = format;
    
    surface->base.red = format->red;
***************
*** 159,173 ****
    surface->base.width = width;
    surface->base.height = height;
! 
    texture_format = glc_surface_get_texture_format (&surface->base);
  
    glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
  
!   surface->texture =
      glc_texture_generate (width, height,
                            texture_format,
!                           thread_info->texture_mask);
  
!   if (!surface->texture) {
      glc_surface_pop_current (&surface->base);
      glc_surface_destroy (&surface->base);
--- 189,211 ----
    surface->base.width = width;
    surface->base.height = height;
!   
    texture_format = glc_surface_get_texture_format (&surface->base);
  
    glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
  
!   texture_target_mask = thread_info->texture_mask;
! 
!   /* Seems to be problem with binding a pbuffer to some power of two sized
!      textures. This will try to avoid the problem. */
!   if (((width > 1) && (width < 64)) ||
!       ((height > 1) && (height < 64)))
!     texture_target_mask &= ~GLC_TEXTURE_TARGET_2D_MASK;
! 
!   surface->base.texture =
      glc_texture_generate (width, height,
                            texture_format,
!                           texture_target_mask);
  
!   if (!surface->base.texture) {
      glc_surface_pop_current (&surface->base);
      glc_surface_destroy (&surface->base);
***************
*** 175,189 ****
    }
    
!   if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
!     surface->pbuffer = glc_agl_pbuffer_create (surface->texture);
  
    if (!surface->pbuffer) {
!     glc_texture_allocate (surface->texture);
    } else {
      glc_surface_push_current (&surface->base, GLC_CN_SURFACE_CONTEXT_CURRENT);
      glc_agl_pbuffer_bind (surface->pbuffer,
                            surface->context->context,
!                           surface->texture,
!                           surface->format);
      glc_surface_pop_current (&surface->base);
    }
--- 213,227 ----
    }
    
!   if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_DRAWING_MASK)
!     surface->pbuffer = glc_agl_pbuffer_create (surface->base.texture);
  
    if (!surface->pbuffer) {
!     glc_texture_allocate (surface->base.texture);
    } else {
      glc_surface_push_current (&surface->base, GLC_CN_SURFACE_CONTEXT_CURRENT);
      glc_agl_pbuffer_bind (surface->pbuffer,
                            surface->context->context,
!                           surface->base.texture,
!                           surface->base.format);
      glc_surface_pop_current (&surface->base);
    }
***************
*** 227,231 ****
    surface->thread_info = thread_info;
    surface->context = context;
!   surface->format = format;
  
    surface->base.red = format->red;
--- 265,269 ----
    surface->thread_info = thread_info;
    surface->context = context;
!   surface->base.format = format;
  
    surface->base.red = format->red;
***************
*** 246,249 ****
--- 284,288 ----
  static glc_surface_t *
  _glc_agl_surface_create_similar (void *abstract_templ,
+                                  glc_format_name_t format_name,
                                   int width,
                                   int height)
***************
*** 254,266 ****
      glc_format_t *format;
  
!     if (templ->format->drawable.offscreen && templ->format->alpha)
!       format = templ->format;
!     else
        format = glc_format_find_standard (templ->thread_info->formats,
                                           templ->thread_info->n_formats,
                                           GLC_FORMAT_OPTION_OFFSCREEN_MASK,
!                                          GLC_STANDARD_A8);
!     
!     return _glc_agl_surface_create (templ->thread_info, format, width, height);
    }
  
--- 293,308 ----
      glc_format_t *format;
  
!     format = glc_format_find_sufficient_standard
!       (templ->base.format, 1, GLC_FORMAT_OPTION_OFFSCREEN_MASK, format_name);
!     
!     if (!format)
        format = glc_format_find_standard (templ->thread_info->formats,
                                           templ->thread_info->n_formats,
                                           GLC_FORMAT_OPTION_OFFSCREEN_MASK,
!                                          format_name);
! 
!     if (format)
!       return _glc_agl_surface_create (templ->thread_info, format,
!                                       width, height);
    }
  
***************
*** 289,294 ****
    }
    
!   if (surface->texture)
!     glc_texture_destroy (surface->texture);
    
    if (surface->pbuffer)
--- 331,336 ----
    }
    
!   if (surface->base.texture)
!     glc_texture_destroy (surface->base.texture);
    
    if (surface->pbuffer)
***************
*** 328,335 ****
    glc_agl_context_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT);
    
!   if (surface->format->doublebuffer)
!     aglSwapBuffers (surface->context->context);
!   else
!     glFlush ();
    
    glc_agl_context_pop_current (surface);
--- 370,374 ----
    glc_agl_context_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT);
    
!   aglSwapBuffers (surface->context->context);
    
    glc_agl_context_pop_current (surface);

Index: glc_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_format.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_format.c	6 Feb 2004 00:50:28 -0000	1.2
--- glc_format.c	10 Feb 2004 23:38:36 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 171,172 ****
--- 171,212 ----
    return glc_format_find (formats, n_formats, mask, &templ, 0);
  }
+ 
+ glc_format_t *
+ glc_format_find_sufficient_standard (glc_format_t *formats,
+                                      int n_formats,
+                                      unsigned long options,
+                                      glc_format_name_t format_name)
+ {
+   glc_format_t templ;
+   unsigned long mask;
+ 
+   switch (format_name) {
+   case GLC_STANDARD_ARGB32:
+     mask = GLC_FORMAT_RED_MASK | GLC_FORMAT_GREEN_MASK |
+       GLC_FORMAT_BLUE_MASK | GLC_FORMAT_ALPHA_MASK;
+     templ.red = 8;
+     templ.green = 8;
+     templ.blue = 8;
+     templ.alpha = 8;
+     break;
+   case GLC_STANDARD_RGB24:
+     mask = GLC_FORMAT_RED_MASK | GLC_FORMAT_GREEN_MASK |
+       GLC_FORMAT_BLUE_MASK;
+     templ.red = 8;
+     templ.green = 8;
+     templ.blue = 8;
+     break;
+   case GLC_STANDARD_A8:
+     mask = GLC_FORMAT_ALPHA_MASK;
+     templ.alpha = 8;
+     break;
+   case GLC_STANDARD_A1:
+     mask = GLC_FORMAT_ALPHA_MASK;
+     templ.alpha = 1;
+     break;
+   }
+ 
+   _glc_format_add_options (options, &templ, &mask);
+ 
+   return glc_format_find (formats, n_formats, mask, &templ, 0);
+ }

Index: glc_glx_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_context.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glc_glx_context.c	5 Feb 2004 22:22:28 -0000	1.7
--- glc_glx_context.c	10 Feb 2004 23:38:36 -0000	1.8
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 65,85 ****
  {
    GLXFBConfig *fbconfigs;
!   int attrib[3];
!   int n_fbconfigs;
  
!   attrib[0] = GLX_FBCONFIG_ID;
!   attrib[1] = fbconfigid;
!   attrib[2] = 0;
  
!   fbconfigs = glXChooseFBConfig (screen_info->display_info->display,
!                                  screen_info->screen, attrib, &n_fbconfigs);
!   
!   context->context =
!     glXCreateNewContext (screen_info->display_info->display,
!                          *fbconfigs, GLX_RGBA_TYPE, share_list, 1);
!   context->id = fbconfigid;
!   context->fbconfig = *fbconfigs;
!   
!   XFree (fbconfigs);
  }
  
--- 65,95 ----
  {
    GLXFBConfig *fbconfigs;
!   int i, n_fbconfigs;
  
!   fbconfigs = glXGetFBConfigs (screen_info->display_info->display,
!                                screen_info->screen, &n_fbconfigs);
!   for (i = 0; i < n_fbconfigs; i++) {
!     int value;
!     
!     glXGetFBConfigAttrib (screen_info->display_info->display,
!                           fbconfigs[i], GLX_FBCONFIG_ID, &value);
!     if (value == (int) fbconfigid)
!       break;
!   }
  
!   if (i < n_fbconfigs) {
!     context->context =
!       glXCreateNewContext (screen_info->display_info->display,
!                            fbconfigs[i], GLX_RGBA_TYPE, share_list, 1);
!     context->id = fbconfigid;
!     context->fbconfig = fbconfigs[i];
!   } else {
!     context->context = NULL;
!     context->id = fbconfigid;
!     context->fbconfig = NULL;
!   }
! 
!   if (fbconfigs)
!     XFree (fbconfigs);
  }
  
***************
*** 125,140 ****
  glc_glx_context_set_surface_anti_aliasing (glc_glx_surface_t *surface)
  {
-   glc_bool_t multi_sample = 0;
- 
    surface->base.anti_aliasing = 0;
  
!   if (surface->pbuffer) {
!     if (surface->screen_info->feature_mask &
!         GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK)
!       multi_sample = 1;
!   } else if (surface->screen_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK)
!     multi_sample = 1;
!   
!   if (multi_sample) {
      if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
        glEnable (GL_MULTISAMPLE_ARB);
--- 135,141 ----
  glc_glx_context_set_surface_anti_aliasing (glc_glx_surface_t *surface)
  {
    surface->base.anti_aliasing = 0;
  
!   if (surface->base.format->multisample.supported) {
      if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
        glEnable (GL_MULTISAMPLE_ARB);

Index: glc_glx_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_extension.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_glx_extension.c	6 Feb 2004 14:03:39 -0000	1.6
--- glc_glx_extension.c	10 Feb 2004 23:38:36 -0000	1.7
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 41,51 ****
  
  #if GL_EXT_texture_rectangle
!   { "GL_EXT_texture_rectangle", GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK },
! #elif GL_NV_texture_rectangle
!   { "GL_NV_texture_rectangle", GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK },
  #endif
  
    { "GL_ARB_multisample", GLC_GLX_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK },
    { NULL, 0 }
  };
--- 41,54 ----
  
  #if GL_EXT_texture_rectangle
!   { "GL_EXT_texture_rectangle", GLC_GLX_FEATURE_EXT_TEXTURE_RECTANGLE_MASK },
! #endif
!   
! #if GL_NV_texture_rectangle
!   { "GL_NV_texture_rectangle", GLC_GLX_FEATURE_NV_TEXTURE_RECTANGLE_MASK },
  #endif
  
    { "GL_ARB_multisample", GLC_GLX_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK },
+   { "GL_ARB_fragment_program", GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK },
    { NULL, 0 }
  };
***************
*** 105,111 ****
  
    screen_info->feature_mask = 0;
  
    if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK)
!     screen_info->feature_mask |= GLC_FEATURE_OFFSCREEN_MASK;
    
    if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_MULTISAMPLE_MASK &&
--- 108,115 ----
  
    screen_info->feature_mask = 0;
+   screen_info->texture_mask = GLC_TEXTURE_TARGET_2D_MASK;
  
    if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK)
!     screen_info->feature_mask |= GLC_FEATURE_OFFSCREEN_DRAWING_MASK;
    
    if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_MULTISAMPLE_MASK &&
***************
*** 115,126 ****
  
      /* All geforce fx cards seems to support multisample with pbuffers */
!     if (strncmp ("GeForce FX", glGetString (GL_RENDERER), 10))
        screen_info->feature_mask |= GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
    }
  
    if (screen_info->glx_feature_mask &
!       GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK) {
!     screen_info->texture_mask |= GLC_TEXTURE_TARGET_RECTANGLE_MASK;
!     screen_info->feature_mask |= GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
    }
  
--- 119,136 ----
  
      /* All geforce fx cards seems to support multisample with pbuffers */
!     if (!strncmp ("GeForce FX", (char *) glGetString (GL_RENDERER), 10))
        screen_info->feature_mask |= GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
    }
  
    if (screen_info->glx_feature_mask &
!       GLC_GLX_FEATURE_EXT_TEXTURE_RECTANGLE_MASK) {
!     screen_info->texture_mask |= GLC_TEXTURE_TARGET_EXT_RECTANGLE_MASK;
!     screen_info->feature_mask |= GLC_FEATURE_EXT_TEXTURE_RECTANGLE_MASK;
!   }
! 
!   if (screen_info->glx_feature_mask &
!       GLC_GLX_FEATURE_NV_TEXTURE_RECTANGLE_MASK) {
!     screen_info->texture_mask |= GLC_TEXTURE_TARGET_NV_RECTANGLE_MASK;
!     screen_info->feature_mask |= GLC_FEATURE_NV_TEXTURE_RECTANGLE_MASK;
    }
  
***************
*** 132,140 ****
          _glc_glx_proc_address.glx_release_tex_image_ati) {
        screen_info->glx_feature_mask |= GLC_GLX_FEATURE_RENDER_TEXTURE_MASK;
!       screen_info->texture_mask &= ~GLC_TEXTURE_TARGET_RECTANGLE_MASK;
!       screen_info->feature_mask &= ~GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
      }
  #endif
      
    }
  }
--- 142,159 ----
          _glc_glx_proc_address.glx_release_tex_image_ati) {
        screen_info->glx_feature_mask |= GLC_GLX_FEATURE_RENDER_TEXTURE_MASK;
! 
!       /* ATI render texture doesn't seem to support texture rectangle */
!       screen_info->texture_mask &= ~GLC_TEXTURE_TARGET_EXT_RECTANGLE_MASK;
!       screen_info->feature_mask &= ~GLC_FEATURE_EXT_TEXTURE_RECTANGLE_MASK;
!       screen_info->texture_mask &= ~GLC_TEXTURE_TARGET_NV_RECTANGLE_MASK;
!       screen_info->feature_mask &= ~GLC_FEATURE_NV_TEXTURE_RECTANGLE_MASK;
      }
  #endif
      
    }
+ 
+   if (screen_info->glx_feature_mask &
+       GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
+     screen_info->feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
+   }
  }

Index: glc_glx_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_format.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** glc_glx_format.c	6 Feb 2004 14:03:39 -0000	1.11
--- glc_glx_format.c	10 Feb 2004 23:38:36 -0000	1.12
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 73,83 ****
                   glc_format_t *format)
  {
!   int index = screen_info->n_formats++;
!   
!   screen_info->formats =
!     realloc (screen_info->formats,
!              sizeof (glc_format_t) * screen_info->n_formats);
!   
!   memcpy (&screen_info->formats[index], format, sizeof (glc_format_t));
  }
  
--- 73,86 ----
                   glc_format_t *format)
  {
!   if (!glc_format_find (screen_info->formats, screen_info->n_formats,
!                         GLC_FORMAT_ALL_EXCEPT_ID_MASK, format, 0)) {
!     int index = screen_info->n_formats++;
! 
!     screen_info->formats =
!       realloc (screen_info->formats,
!                sizeof (glc_format_t) * screen_info->n_formats);
!     
!     memcpy (&screen_info->formats[index], format, sizeof (glc_format_t));
!   }
  }
  
***************
*** 200,204 ****
    GLXFBConfig *fbconfigs;
    int i, num_configs;
!   glc_bool_t offscreen_formats = 0;
    
    display = screen_info->display_info->display;
--- 203,207 ----
    GLXFBConfig *fbconfigs;
    int i, num_configs;
!   glc_bool_t offscreen_argb32_format = 0;
    
    display = screen_info->display_info->display;
***************
*** 229,234 ****
      format.drawable.onscreen = (value & GLX_WINDOW_BIT)? 1: 0;
      format.drawable.offscreen = (value & GLX_PBUFFER_BIT)? 1: 0;
-     if (format.drawable.offscreen)
-       offscreen_formats = 1;
      
      glXGetFBConfigAttrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value);
--- 232,235 ----
***************
*** 257,261 ****
        format.multisample.supported = 0;
        format.multisample.samples = 0;
!     }   
      
      _glc_add_format (screen_info, &format);
--- 258,266 ----
        format.multisample.supported = 0;
        format.multisample.samples = 0;
!     }
! 
!     if (format.drawable.offscreen &&
!         format.alpha && format.red && format.green && format.blue)
!       offscreen_argb32_format = 1;
      
      _glc_add_format (screen_info, &format);
***************
*** 270,274 ****
        format.red = format.green = format.blue = 0;
        _glc_add_format (screen_info, &format);
!     }
    }
  
--- 275,279 ----
        format.red = format.green = format.blue = 0;
        _glc_add_format (screen_info, &format);
!     }    
    }
  
***************
*** 276,285 ****
           sizeof (glc_format_t), _glc_glx_format_compare);
  
!   /* Adding fake offscreen formats if no real offscreen formats exists.
!      Surfaces created with this format can only be used with draw/read
       pixel functions and as source in composite functions. */
!   if (!offscreen_formats) {
      screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_PBUFFER_MASK;
!     screen_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MASK;
      memset (&format, 0, sizeof (glc_format_t));
      format.drawable.offscreen = 1;
--- 281,290 ----
           sizeof (glc_format_t), _glc_glx_format_compare);
  
!   /* Adding fake offscreen formats if no real argb32 offscreen formats exist.
!      Surfaces created with these format can only be used with draw/read
       pixel functions and as source in composite functions. */
!   if (!offscreen_argb32_format) {
      screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_PBUFFER_MASK;
!     screen_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_DRAWING_MASK;
      memset (&format, 0, sizeof (glc_format_t));
      format.drawable.offscreen = 1;
***************
*** 355,370 ****
    if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK) {
      GLXFBConfig *fbconfigs;
!     int attrib[3];
!     int n_fbconfigs;
! 
!     attrib[0] = GLX_FBCONFIG_ID;
!     attrib[1] = screen_info->format_ids[format->id];
!     attrib[2] = 0;
! 
!     fbconfigs = glXChooseFBConfig (display, screen, attrib, &n_fbconfigs);
  
!     vinfo = glXGetVisualFromFBConfig (display, *fbconfigs);
      
!     XFree (fbconfigs);
    } else {
      XVisualInfo templ;
--- 360,380 ----
    if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK) {
      GLXFBConfig *fbconfigs;
!     int i, n_fbconfigs;
!     int fbconfigid = screen_info->format_ids[format->id];
  
!     fbconfigs = glXGetFBConfigs (display, screen, &n_fbconfigs);
!     for (i = 0; i < n_fbconfigs; i++) {
!       int value;
!       
!       glXGetFBConfigAttrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value);
!       if (value == fbconfigid)
!         break;
!     }
      
!     if (i < n_fbconfigs)
!       vinfo = glXGetVisualFromFBConfig (display, fbconfigs[i]);
! 
!     if (fbconfigs)
!       XFree (fbconfigs);
    } else {
      XVisualInfo templ;

Index: glc_glx_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_info.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glc_glx_info.c	5 Feb 2004 22:22:28 -0000	1.7
--- glc_glx_info.c	10 Feb 2004 23:38:36 -0000	1.8
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 205,208 ****
--- 205,213 ----
    screen_info->n_contexts = 0;
  
+   screen_info->programs.program_2d_2d = 0;
+   screen_info->programs.program_rect_2d = 0;
+   screen_info->programs.program_2d_rect = 0;
+   screen_info->programs.program_rect_rect = 0;
+ 
    glc_glx_create_root_context (screen_info);
  

Index: glc_glx_pbuffer.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_pbuffer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_glx_pbuffer.c	3 Feb 2004 15:12:11 -0000	1.4
--- glc_glx_pbuffer.c	10 Feb 2004 23:38:36 -0000	1.5
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software

Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glc_glx_surface.c	5 Feb 2004 22:22:28 -0000	1.10
--- glc_glx_surface.c	10 Feb 2004 23:38:36 -0000	1.11
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 36,39 ****
--- 36,40 ----
  static glc_surface_t *
  _glc_glx_surface_create_similar (void *abstract_templ,
+                                  glc_format_name_t format_name,
                                   int width,
                                   int height);
***************
*** 63,67 ****
      _glc_glx_proc_address.glx_release_tex_image_ati
        (surface->screen_info->display_info->display, surface->pbuffer,
!        (surface->format->doublebuffer)? GLX_BACK_LEFT_ATI: GLX_FRONT_LEFT_ATI);
  #endif
      
--- 64,69 ----
      _glc_glx_proc_address.glx_release_tex_image_ati
        (surface->screen_info->display_info->display, surface->pbuffer,
!        (surface->base.format->doublebuffer)?
!        GLX_BACK_LEFT_ATI: GLX_FRONT_LEFT_ATI);
  #endif
      
***************
*** 92,95 ****
--- 94,124 ----
  }
  
+ static glc_bool_t
+ _glc_glx_surface_enable_program (void *abstract_surface,
+                                  glc_texture_t *src,
+                                  glc_texture_t *mask)
+ {
+   glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
+   glc_bool_t status = 0;
+ 
+   if (surface->screen_info->feature_mask &
+       GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
+     status =
+       glc_program_enable_fragment_arb (&surface->screen_info->programs,
+                                        src, mask);
+ 
+   return status;
+ }
+ 
+ static void
+ _glc_glx_surface_disable_program (void *abstract_surface)
+ {
+   glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
+ 
+   if (surface->screen_info->feature_mask &
+       GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
+     glc_program_disable_fragment_arb ();
+ }
+ 
  static const struct glc_surface_backend glc_glx_surface_backend = {
    _glc_glx_surface_create_similar,
***************
*** 99,103 ****
    _glc_glx_surface_get_texture,
    _glc_glx_surface_realize,
!   _glc_glx_surface_show
  };
  
--- 128,134 ----
    _glc_glx_surface_get_texture,
    _glc_glx_surface_realize,
!   _glc_glx_surface_show,
!   _glc_glx_surface_enable_program,
!   _glc_glx_surface_disable_program
  };
  
***************
*** 129,133 ****
  
    if (surface->render_texture) {
!     glc_texture_bind (surface->texture);
      
  #ifdef GLX_ATI_render_texture
--- 160,164 ----
  
    if (surface->render_texture) {
!     glc_texture_bind (surface->base.texture);
      
  #ifdef GLX_ATI_render_texture
***************
*** 137,144 ****
  #endif
      
!     glc_texture_unbind (surface->texture);
  
    } else
!     glc_texture_copy_surface (surface->texture, &surface->base,
                                &surface->base.dirty_region);
    
--- 168,175 ----
  #endif
      
!     glc_texture_unbind (surface->base.texture);
  
    } else
!     glc_texture_copy_surface (surface->base.texture, &surface->base,
                                &surface->base.dirty_region);
    
***************
*** 150,159 ****
    glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
  
!   if (!surface->texture->allocated)
!     glc_texture_allocate (surface->texture);
    
    _glc_glx_surface_ensure_texture (surface);
    
!   return surface->texture;
  }
  
--- 181,190 ----
    glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
  
!   if (!surface->base.texture->allocated)
!     glc_texture_allocate (surface->base.texture);
    
    _glc_glx_surface_ensure_texture (surface);
    
!   return surface->base.texture;
  }
  
***************
*** 180,184 ****
    surface->screen_info = screen_info;
    surface->context = context;
!   surface->format = format;
    
    surface->base.red = format->red;
--- 211,215 ----
    surface->screen_info = screen_info;
    surface->context = context;
!   surface->base.format = format;
    
    surface->base.red = format->red;
***************
*** 200,222 ****
    glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
  
!   surface->texture =
      glc_texture_generate (width, height,
                            texture_format,
                            screen_info->texture_mask);
  
!   if (!surface->texture) {
      glc_surface_destroy (&surface->base);
      return NULL;
    }
  
!   if (screen_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
      surface->drawable = surface->pbuffer =
        glc_glx_pbuffer_create (screen_info->display_info->display,
                                surface->context->fbconfig,
!                               surface->texture,
                                surface->render_texture);
    
    if ((!surface->render_texture) && (!surface->pbuffer))
!     glc_texture_allocate (surface->texture);
  
    glc_surface_pop_current (&surface->base);
--- 231,253 ----
    glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
  
!   surface->base.texture =
      glc_texture_generate (width, height,
                            texture_format,
                            screen_info->texture_mask);
  
!   if (!surface->base.texture) {
      glc_surface_destroy (&surface->base);
      return NULL;
    }
  
!   if (screen_info->feature_mask & GLC_FEATURE_OFFSCREEN_DRAWING_MASK)
      surface->drawable = surface->pbuffer =
        glc_glx_pbuffer_create (screen_info->display_info->display,
                                surface->context->fbconfig,
!                               surface->base.texture,
                                surface->render_texture);
    
    if ((!surface->render_texture) && (!surface->pbuffer))
!     glc_texture_allocate (surface->base.texture);
  
    glc_surface_pop_current (&surface->base);
***************
*** 267,271 ****
    surface->screen_info = screen_info;
    surface->context = context;
!   surface->format = format;
  
    surface->base.red = format->red;
--- 298,302 ----
    surface->screen_info = screen_info;
    surface->context = context;
!   surface->base.format = format;
  
    surface->base.red = format->red;
***************
*** 284,287 ****
--- 315,319 ----
  static glc_surface_t *
  _glc_glx_surface_create_similar (void *abstract_templ,
+                                  glc_format_name_t format_name,
                                   int width,
                                   int height)
***************
*** 291,304 ****
    if (templ->screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) {
      glc_format_t *format;
!     
!     if (templ->format->drawable.offscreen && templ->format->alpha)
!       format = templ->format;
!     else
        format = glc_format_find_standard (templ->screen_info->formats,
                                           templ->screen_info->n_formats,
                                           GLC_FORMAT_OPTION_OFFSCREEN_MASK,
!                                          GLC_STANDARD_A8);
!     
!     return _glc_glx_surface_create (templ->screen_info, format, width, height);
    }
    
--- 323,338 ----
    if (templ->screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) {
      glc_format_t *format;
! 
!     format = glc_format_find_sufficient_standard
!       (templ->base.format, 1, GLC_FORMAT_OPTION_OFFSCREEN_MASK, format_name);
! 
!     if (!format)
        format = glc_format_find_standard (templ->screen_info->formats,
                                           templ->screen_info->n_formats,
                                           GLC_FORMAT_OPTION_OFFSCREEN_MASK,
!                                          format_name);
!     if (format)
!       return _glc_glx_surface_create (templ->screen_info, format,
!                                       width, height);
    }
    
***************
*** 323,328 ****
      }
    
!   if (surface->texture)
!     glc_texture_destroy (surface->texture);
    
    if (surface->pbuffer)
--- 357,362 ----
      }
    
!   if (surface->base.texture)
!     glc_texture_destroy (surface->base.texture);
    
    if (surface->pbuffer)
***************
*** 363,373 ****
      return;
  
!   glc_glx_context_push_current (surface, GLC_CN_SURFACE_CONTEXT_CURRENT);
    
!   if (surface->format->doublebuffer)
!     glXSwapBuffers (surface->screen_info->display_info->display,
!                     surface->drawable);
!   else
!     glFlush ();
    
    glc_glx_context_pop_current (surface);
--- 397,404 ----
      return;
  
!   glc_glx_context_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT);
    
!   glXSwapBuffers (surface->screen_info->display_info->display,
!                   surface->drawable);
    
    glc_glx_context_pop_current (surface);

Index: glc_matrix.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_matrix.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glc_matrix.c	3 Dec 2003 16:55:50 -0000	1.1
--- glc_matrix.c	10 Feb 2004 23:38:36 -0000	1.2
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software

Index: glc_operator.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_operator.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_operator.c	4 Dec 2003 19:18:08 -0000	1.2
--- glc_operator.c	10 Feb 2004 23:38:36 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software

Index: glc_rect.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_rect.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glc_rect.c	6 Feb 2004 14:03:39 -0000	1.8
--- glc_rect.c	10 Feb 2004 23:38:36 -0000	1.9
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software

Index: glc_status.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_status.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** glc_status.c	27 Nov 2003 11:47:05 -0000	1.1.1.1
--- glc_status.c	10 Feb 2004 23:38:36 -0000	1.2
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software

Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** glc_surface.c	6 Feb 2004 14:03:39 -0000	1.12
--- glc_surface.c	10 Feb 2004 23:38:36 -0000	1.13
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 40,47 ****
  {
    surface->backend = backend;
!   
    surface->repeat = 0;
    surface->transform = NULL;
-   surface->disable_transform = 0;
    surface->anti_aliasing = 0;
    surface->filter = GLC_FILTER_NEAREST;
--- 40,48 ----
  {
    surface->backend = backend;
! 
!   surface->format = NULL;
!   surface->texture = NULL;
    surface->repeat = 0;
    surface->transform = NULL;
    surface->anti_aliasing = 0;
    surface->filter = GLC_FILTER_NEAREST;
***************
*** 62,76 ****
  glc_surface_t *
  glc_surface_create_similar (glc_surface_t *templ,
                              int width,
                              int height)
  {
    glc_surface_t *surface =
!     templ->backend->create_similar (templ, width, height);
!   
!   surface->polyedge = templ->polyedge;
! 
!   /* All channels should always be rendered to intermediate */
!   surface->red = surface->green = surface->blue = surface->alpha = 8;
  
    return surface;
  }
--- 63,76 ----
  glc_surface_t *
  glc_surface_create_similar (glc_surface_t *templ,
+                             glc_format_name_t format_name,
                              int width,
                              int height)
  {
    glc_surface_t *surface =
!     templ->backend->create_similar (templ, format_name, width, height);
  
+   if (surface)
+     surface->polyedge = templ->polyedge;
+   
    return surface;
  }
***************
*** 100,103 ****
--- 100,117 ----
  }
  
+ glc_bool_t
+ glc_surface_enable_program (glc_surface_t *surface,
+                             glc_texture_t *src,
+                             glc_texture_t *mask)
+ {
+   return surface->backend->enable_program (surface, src, mask);
+ }
+ 
+ void
+ glc_surface_disable_program (glc_surface_t *surface)
+ {
+   surface->backend->disable_program (surface);
+ }
+ 
  void
  glc_surface_set_transform (glc_surface_t *surface,
***************
*** 196,203 ****
  slim_hidden_def(glc_surface_realize);
  
  void
! glc_surface_show (glc_surface_t *surface)
  {
!   surface->backend->show (surface);
  }
  slim_hidden_def(glc_surface_show);
--- 210,268 ----
  slim_hidden_def(glc_surface_realize);
  
+ static void
+ _glc_set_raster_pos (int x, int y)
+ {
+   glPushAttrib (GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
+   glMatrixMode (GL_PROJECTION);
+   glPushMatrix ();
+   glLoadIdentity ();
+   glMatrixMode (GL_MODELVIEW);
+   glPushMatrix ();
+   glLoadIdentity ();
+   glDepthRange (0, 1);
+   glViewport (-1, -1, 2, 2);
+   
+   glRasterPos2d (0, 0);
+   glBitmap (0, 0, 1, 1, x, y, NULL);
+   
+   glPopMatrix ();
+   glMatrixMode (GL_PROJECTION);
+   glPopMatrix ();
+   glPopAttrib ();
+ }
+ 
  void
! glc_surface_show (glc_surface_t *surface,
!                   int x,
!                   int y,
!                   unsigned int width,
!                   unsigned int height)
  {
!   if (surface->format->doublebuffer &&
!       x <= 0 && y <= 0 &&
!       (x + (int) width) >= surface->width &&
!       (y + (int) height) >= surface->height) {
!     surface->backend->show (surface);
!   } else if (width > 0 && height > 0) {
!     if (x < 0) x = 0;
!     if (y < 0) y = 0;
!     if (glc_surface_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
!       if (surface->format->doublebuffer) {
!         glReadBuffer (GL_BACK);
!         glDrawBuffer (GL_FRONT);
!         glDisable (GL_SCISSOR_TEST);
!         glDisable (GL_DITHER);
!         glc_set_operator (GLC_OPERATOR_SRC);
! 
!         _glc_set_raster_pos (x, surface->height - (y + height));
!         glCopyPixels (x, surface->height - (y + height),
!                       width, height, GL_COLOR);
!         
!         glDrawBuffer (GL_BACK);
!       }
!       glFlush ();
!     }
!     glc_surface_pop_current (surface);
!   }
  }
  slim_hidden_def(glc_surface_show);
***************
*** 249,264 ****
  
  void
- glc_surface_disable_transform (glc_surface_t *surface)
- {
-   surface->disable_transform = 1;
- }
- 
- void
- glc_surface_enable_transform (glc_surface_t *surface)
- {
-   surface->disable_transform = 0;
- }
- 
- void
  glc_surface_setup_environment (glc_surface_t *surface)
  {
--- 314,317 ----
***************
*** 294,298 ****
                                         surface->alpha);
    
!   return glc_get_texture_format_from_pixelsize (pixelsize);
  }
  
--- 347,351 ----
                                         surface->alpha);
    
!   return glc_get_format_from_pixelsize (pixelsize);
  }
  
***************
*** 321,326 ****
                                         surface->blue,
                                         surface->alpha);
!   format = glc_get_texture_format_from_pixelsize (pixelsize);
!   type = glc_get_texture_data_type_from_pixelsize (pixelsize);
  
    /* We currently read the whole image to a temporary buffer and then
--- 374,379 ----
                                         surface->blue,
                                         surface->alpha);
!   format = glc_get_format_from_pixelsize (pixelsize);
!   type = glc_get_data_type_from_pixelsize (pixelsize);
  
    /* We currently read the whole image to a temporary buffer and then
***************
*** 395,400 ****
                                         surface->blue,
                                         surface->alpha);
!   format = glc_get_texture_format_from_pixelsize (pixelsize);
!   type = glc_get_texture_data_type_from_pixelsize (pixelsize);
  
  
--- 448,453 ----
                                         surface->blue,
                                         surface->alpha);
!   format = glc_get_format_from_pixelsize (pixelsize);
!   type = glc_get_data_type_from_pixelsize (pixelsize);
  
  
***************
*** 409,436 ****
      glDisable (GL_SCISSOR_TEST);
      glDisable (GL_DITHER);
- 
      glc_set_operator (GLC_OPERATOR_SRC);
  
-     glPushAttrib (GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
-     glMatrixMode (GL_PROJECTION);
-     glPushMatrix ();
-     glLoadIdentity ();
-     glMatrixMode (GL_MODELVIEW);
-     glPushMatrix ();
-     glLoadIdentity ();
-     glDepthRange (0, 1);
-     glViewport (-1, -1, 2, 2);
- 
      if (surface->requires_flipping)
        glPixelZoom (1.0, -1.0);
      
!     glRasterPos2d (0, 0);
!     glBitmap (0, 0, 1, 1, x, surface->height - y, NULL);
!     
!     glPopMatrix ();
!     glMatrixMode (GL_PROJECTION);
!     glPopMatrix ();
!     glPopAttrib ();
! 
      glDrawPixels (width, height, format, type, pixels);
  
--- 462,471 ----
      glDisable (GL_SCISSOR_TEST);
      glDisable (GL_DITHER);
      glc_set_operator (GLC_OPERATOR_SRC);
  
      if (surface->requires_flipping)
        glPixelZoom (1.0, -1.0);
      
!     _glc_set_raster_pos (x, surface->height - y);
      glDrawPixels (width, height, format, type, pixels);
  

Index: glc_texture.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_texture.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_texture.c	5 Feb 2004 22:22:28 -0000	1.6
--- glc_texture.c	10 Feb 2004 23:38:36 -0000	1.7
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 54,65 ****
    *proxy_target = GL_PROXY_TEXTURE_2D;
    
!   if ((!_glc_texture_is_power_of_two (width)) ||
        (!_glc_texture_is_power_of_two (height))) {
!     if (target_mask & GLC_TEXTURE_TARGET_RECTANGLE_MASK) {
  
  #if GL_EXT_texture_rectangle
        *target = GL_TEXTURE_RECTANGLE_EXT;
        *proxy_target = GL_PROXY_TEXTURE_RECTANGLE_EXT;
! #elif GL_NV_texture_rectangle
        *target = GL_TEXTURE_RECTANGLE_NV;
        *proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV;
--- 54,70 ----
    *proxy_target = GL_PROXY_TEXTURE_2D;
    
!   if ((!(target_mask & GLC_TEXTURE_TARGET_2D_MASK)) ||
!       (!_glc_texture_is_power_of_two (width)) ||
        (!_glc_texture_is_power_of_two (height))) {
!     if (target_mask & GLC_TEXTURE_TARGET_EXT_RECTANGLE_MASK) {
  
  #if GL_EXT_texture_rectangle
        *target = GL_TEXTURE_RECTANGLE_EXT;
        *proxy_target = GL_PROXY_TEXTURE_RECTANGLE_EXT;
! #endif
! 
!     } else if (target_mask & GLC_TEXTURE_TARGET_NV_RECTANGLE_MASK) {
!       
! #if GL_NV_texture_rectangle
        *target = GL_TEXTURE_RECTANGLE_NV;
        *proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV;
***************
*** 80,127 ****
    *value = x;
  }
-                                  
- static int
- _glc_texture_find_best_size (int width,
-                              int height,
-                              GLenum texture_format,
-                              glc_texture_t *texture)
- {
-   int test_width = width;
-   int test_height = height;
- 
-   _glc_texture_power_of_two_size (&test_width);
-   _glc_texture_power_of_two_size (&test_height);
- 
-   while (test_width <= TEXTURE_MAX_SIZE) {
-     GLint w_ok, h_ok;
- 
-     glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
-                   test_width, test_height,
-                   0, texture_format, GL_UNSIGNED_BYTE, NULL);
-       
-     w_ok = h_ok = 0;
-     glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,
-                               &w_ok);
-     glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
-                               &h_ok);
-     
-     if (w_ok != test_width || h_ok != test_height) {
-       if (test_width < test_height) {
-         test_width++;
-         _glc_texture_power_of_two_size (&test_width);
-       } else {
-         test_height++;
-         _glc_texture_power_of_two_size (&test_height);
-       }
-     } else {
-       texture->width = test_width;
-       texture->height = test_height;
-       
-       return 1;
-     }
-   }
- 
-   return 0;
- }
  
  glc_texture_t *
--- 85,88 ----
***************
*** 149,159 ****
                                   &texture->target, &proxy_target);
    
!   if (texture->target == GL_TEXTURE_2D &&
!       (!_glc_texture_find_best_size (width, height,
!                                      texture_format, texture))) {
!     free (texture);
!     return NULL;
    }
! 
    glGenTextures (1, (GLuint *) &texture->name);
    
--- 110,118 ----
                                   &texture->target, &proxy_target);
    
!   if (texture->target == GL_TEXTURE_2D) {
!     _glc_texture_power_of_two_size (&texture->width);
!     _glc_texture_power_of_two_size (&texture->height);
    }
!   
    glGenTextures (1, (GLuint *) &texture->name);
    
***************
*** 231,236 ****
        glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT);
      } else {
!       glTexParameteri (texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP);
!       glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP);
      }
      texture->repeat = repeat;
--- 190,195 ----
        glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT);
      } else {
!       glTexParameteri (texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
!       glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      }
      texture->repeat = repeat;
***************
*** 244,248 ****
  #if GL_EXT_texture_rectangle
    glDisable (GL_TEXTURE_RECTANGLE_EXT);
! #elif GL_NV_texture_rectangle
    glDisable (GL_TEXTURE_RECTANGLE_NV);
  #endif
--- 203,209 ----
  #if GL_EXT_texture_rectangle
    glDisable (GL_TEXTURE_RECTANGLE_EXT);
! #endif
!   
! #if GL_NV_texture_rectangle
    glDisable (GL_TEXTURE_RECTANGLE_NV);
  #endif

Index: glc_trap.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_trap.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glc_trap.c	6 Feb 2004 14:03:39 -0000	1.9
--- glc_trap.c	10 Feb 2004 23:38:36 -0000	1.10
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 181,184 ****
--- 181,185 ----
  
    mask = glc_surface_create_similar (dst,
+                                      GLC_STANDARD_A8,
                                       mask_bounds.x2 - mask_bounds.x1,
                                       mask_bounds.y2 - mask_bounds.y1);

Index: glc_tri.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_tri.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glc_tri.c	6 Feb 2004 14:03:39 -0000	1.9
--- glc_tri.c	10 Feb 2004 23:38:36 -0000	1.10
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 109,112 ****
--- 109,113 ----
      
    mask = glc_surface_create_similar (dst,
+                                      GLC_STANDARD_A8,
                                       mask_bounds.x2 - mask_bounds.x1,
                                       mask_bounds.y2 - mask_bounds.y1);
***************
*** 225,228 ****
--- 226,230 ----
      
    mask = glc_surface_create_similar (dst,
+                                      GLC_STANDARD_A8,
                                       mask_bounds.x2 - mask_bounds.x1,
                                       mask_bounds.y2 - mask_bounds.y1);
***************
*** 336,339 ****
--- 338,342 ----
      
    mask = glc_surface_create_similar (dst,
+                                      GLC_STANDARD_A8,
                                       mask_bounds.x2 - mask_bounds.x1,
                                       mask_bounds.y2 - mask_bounds.y1);

Index: glc_util.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_util.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_util.c	3 Feb 2004 15:12:11 -0000	1.6
--- glc_util.c	10 Feb 2004 23:38:36 -0000	1.7
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 94,98 ****
  
  unsigned int
! glc_get_texture_format_from_pixelsize (int pixelsize)
  {
    switch (pixelsize) {
--- 94,98 ----
  
  unsigned int
! glc_get_format_from_pixelsize (int pixelsize)
  {
    switch (pixelsize) {
***************
*** 113,117 ****
  
  unsigned int
! glc_get_texture_data_type_from_pixelsize (int pixelsize)
  {
    if (pixelsize == 4 && big_endian ())
--- 113,117 ----
  
  unsigned int
! glc_get_data_type_from_pixelsize (int pixelsize)
  {
    if (pixelsize == 4 && big_endian ())

Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glcint.h	6 Feb 2004 14:08:41 -0000	1.13
--- glcint.h	10 Feb 2004 23:38:36 -0000	1.14
***************
*** 1,4 ****
  /*
!  * Copyright © 2003 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
--- 1,4 ----
  /*
!  * Copyright © 2004 David Reveman, Peter Nilsson
   *
   * Permission to use, copy, modify, distribute, and sell this software
***************
*** 73,77 ****
  #define GLC_STATUS_INVALID_MATRIX_MASK     (1L << 6)
  
! #define GLC_TEXTURE_TARGET_RECTANGLE_MASK  (1L << 0)
  
  typedef enum {
--- 73,81 ----
  #define GLC_STATUS_INVALID_MATRIX_MASK     (1L << 6)
  
! #define GLC_TEXTURE_TARGET_2D_MASK            (1L << 0)
! #define GLC_TEXTURE_TARGET_EXT_RECTANGLE_MASK (1L << 1)
! #define GLC_TEXTURE_TARGET_NV_RECTANGLE_MASK  (1L << 2)
! 
! #define GLC_FORMAT_ALL_EXCEPT_ID_MASK ((1 << 11) - 2)
  
  typedef enum {
***************
*** 115,118 ****
--- 119,123 ----
    glc_surface_t *
    (*create_similar) (void *surface,
+                      glc_format_name_t format_name,
                       int width,
                       int height);
***************
*** 136,139 ****
--- 141,152 ----
    void
    (*show) (void *surface);
+ 
+   glc_bool_t
+   (*enable_program) (void *surface,
+                      glc_texture_t *src,
+                      glc_texture_t *mask);
+ 
+   void
+   (*disable_program) (void *surface);
  } glc_surface_backend_t;
  
***************
*** 141,144 ****
--- 154,159 ----
    const glc_surface_backend_t *backend;
  
+   glc_format_t *format;
+   glc_texture_t *texture;
    long int status_mask;
    glc_filter_t filter;
***************
*** 146,150 ****
    glc_polyedge_t polyedge;
    glc_matrix_t *transform;
-   glc_bool_t disable_transform;
    glc_bool_t anti_aliasing;
    int width, height;
--- 161,164 ----
***************
*** 160,163 ****
--- 174,184 ----
  } glc_extension_map;
  
+ 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;
+ 
  extern void __internal_linkage
  glc_matrix_transform_point (glc_matrix_t *matrix,
***************
*** 187,194 ****
  
  extern unsigned int __internal_linkage
! glc_get_texture_format_from_pixelsize (int pixelsize);
  
  extern unsigned int __internal_linkage
! glc_get_texture_data_type_from_pixelsize (int pixelsize);
  
  extern long int __internal_linkage
--- 208,215 ----
  
  extern unsigned int __internal_linkage
! glc_get_format_from_pixelsize (int pixelsize);
  
  extern unsigned int __internal_linkage
! glc_get_data_type_from_pixelsize (int pixelsize);
  
  extern long int __internal_linkage
***************
*** 237,240 ****
--- 258,262 ----
  extern glc_surface_t * __internal_linkage
  glc_surface_create_similar (glc_surface_t *templ,
+                             glc_format_name_t format_name,
                              int width,
                              int height);
***************
*** 253,268 ****
  glc_surface_pop_current (glc_surface_t *surface);
  
! extern void __internal_linkage
! glc_surface_dirty (glc_surface_t *surface,
!                    glc_region_box_t *region);
  
  extern void __internal_linkage
! glc_surface_status_add (glc_surface_t *surface, int flags);
  
  extern void __internal_linkage
! glc_surface_disable_transform (glc_surface_t *surface);
  
  extern void __internal_linkage
! glc_surface_enable_transform (glc_surface_t *surface);
  
  extern void __internal_linkage
--- 275,292 ----
  glc_surface_pop_current (glc_surface_t *surface);
  
! extern glc_bool_t __internal_linkage
! glc_surface_enable_program (glc_surface_t *surface,
!                             glc_texture_t *src,
!                             glc_texture_t *mask);
  
  extern void __internal_linkage
! glc_surface_disable_program (glc_surface_t *surface);
  
  extern void __internal_linkage
! glc_surface_dirty (glc_surface_t *surface,
!                    glc_region_box_t *region);
  
  extern void __internal_linkage
! glc_surface_status_add (glc_surface_t *surface, int flags);
  
  extern void __internal_linkage
***************
*** 288,291 ****
--- 312,329 ----
                            glc_format_name_t format_name);
  
+ extern glc_format_t *__internal_linkage
+ glc_format_find_sufficient_standard (glc_format_t *formats,
+                                      int n_formats,
+                                      unsigned long options,
+                                      glc_format_name_t format_name);
+ 
+ extern glc_bool_t __internal_linkage
+ glc_program_enable_fragment_arb (glc_fragment_programs_t *programs,
+                                  glc_texture_t *src_texture,
+                                  glc_texture_t *mask_texture);
+ 
+ extern void __internal_linkage
+ glc_program_disable_fragment_arb (void);
+ 
  #define MAXSHORT SHRT_MAX
  #define MINSHORT SHRT_MIN
***************
*** 372,378 ****
--- 410,420 ----
  #ifdef LIBGLC_HAS_GLX_BACKEND
  
+ #define GL_GLEXT_PROTOTYPES   1
  #define GLX_GLXEXT_PROTOTYPES 1
  
+ #include <GL/gl.h>
+ #include <GL/glext.h>     
  #include <GL/glx.h>
+ #include <GL/glxext.h>
  
  #ifdef HAVE_GL_GLXATI_H
***************
*** 380,390 ****
  #endif
  
! #define GLC_GLX_FEATURE_FBCONFIG_MASK           (1L << 0)
! #define GLC_GLX_FEATURE_PBUFFER_MASK            (1L << 1)
! #define GLC_GLX_FEATURE_RENDER_TEXTURE_MASK     (1L << 2)
! #define GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK  (1L << 3)
! #define GLC_GLX_FEATURE_MULTISAMPLE_MASK        (1L << 4)
! #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK (1L << 5)
! #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK (1L << 6)
  
  typedef struct _glc_glx_surface glc_glx_surface_t;
--- 422,434 ----
  #endif
  
! #define GLC_GLX_FEATURE_FBCONFIG_MASK              (1L << 0)
! #define GLC_GLX_FEATURE_PBUFFER_MASK               (1L << 1)
! #define GLC_GLX_FEATURE_RENDER_TEXTURE_MASK        (1L << 2)
! #define GLC_GLX_FEATURE_EXT_TEXTURE_RECTANGLE_MASK (1L << 3)
! #define GLC_GLX_FEATURE_NV_TEXTURE_RECTANGLE_MASK  (1L << 4)
! #define GLC_GLX_FEATURE_MULTISAMPLE_MASK           (1L << 5)
! #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK    (1L << 6)
! #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK    (1L << 7)
! #define GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 8)
  
  typedef struct _glc_glx_surface glc_glx_surface_t;
***************
*** 445,448 ****
--- 489,494 ----
    long int glx_feature_mask;
    long int texture_mask;
+ 
+   glc_fragment_programs_t programs;
  };
  
***************
*** 452,457 ****
    glc_glx_screen_info_t *screen_info;
    glc_glx_context_t *context;
-   glc_format_t *format;
-   glc_texture_t *texture;
    GLXDrawable drawable;
    GLXPbuffer pbuffer;
--- 498,501 ----
***************
*** 522,529 ****
  #include <AGL/agl.h>
  
! #define GLC_AGL_FEATURE_PBUFFER_MASK            (1L << 0)
! #define GLC_AGL_FEATURE_TEXTURE_RECTANGLE_MASK  (1L << 1)
! #define GLC_AGL_FEATURE_MULTISAMPLE_MASK        (1L << 2)
! #define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK (1L << 3)
  
  typedef struct _glc_agl_surface_t glc_agl_surface_t;
--- 566,575 ----
  #include <AGL/agl.h>
  
! #define GLC_AGL_FEATURE_PBUFFER_MASK               (1L << 0)
! #define GLC_AGL_FEATURE_NV_TEXTURE_RECTANGLE_MASK  (1L << 1)
! #define GLC_AGL_FEATURE_EXT_TEXTURE_RECTANGLE_MASK (1L << 2)
! #define GLC_AGL_FEATURE_MULTISAMPLE_MASK           (1L << 3)
! #define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK    (1L << 4)
! #define GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 5)
  
  typedef struct _glc_agl_surface_t glc_agl_surface_t;
***************
*** 556,559 ****
--- 602,607 ----
    long int agl_feature_mask;
    long int texture_mask;
+ 
+   glc_fragment_programs_t programs;
  } glc_agl_thread_info_t;
  
***************
*** 563,568 ****
    glc_agl_thread_info_t *thread_info;
    glc_agl_context_t *context;
-   glc_format_t *format;
-   glc_texture_t *texture;
    AGLDrawable drawable;
    AGLPbuffer pbuffer;
--- 611,614 ----





More information about the cairo-commit mailing list