[cairo-commit] libglc/src glc_color_range.c, NONE, 1.1 Makefile.am, 1.11, 1.12 glc.c, 1.24, 1.25 glc.h, 1.17, 1.18 glc_agl_extension.c, 1.7, 1.8 glc_glext.h, 1.1, 1.2 glc_glx_extension.c, 1.15, 1.16 glc_glx_surface.c, 1.19, 1.20 glc_program.c, 1.8, 1.9 glc_programmatic.c, 1.4, 1.5 glc_surface.c, 1.23, 1.24 glc_texture.c, 1.12, 1.13 glc_util.c, 1.9, 1.10 glcint.h, 1.26, 1.27

David Reveman commit at pdx.freedesktop.org
Sun Mar 21 05:41:05 PST 2004


Committed by: davidr

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

Modified Files:
	Makefile.am glc.c glc.h glc_agl_extension.c glc_glext.h 
	glc_glx_extension.c glc_glx_surface.c glc_program.c 
	glc_programmatic.c glc_surface.c glc_texture.c glc_util.c 
	glcint.h 
Added Files:
	glc_color_range.c 
Log Message:
Added color range interface

--- NEW FILE: glc_color_range.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.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** a/Makefile.am	14 Mar 2004 10:59:26 -0000	1.11
--- b/Makefile.am	21 Mar 2004 13:41:02 -0000	1.12
***************
*** 44,47 ****
--- 44,48 ----
  	glc_program.c \
  	glc_programmatic.c \
+ 	glc_color_range.c \
  	$(libglc_glx_sources) \
  	$(libglc_agl_sources) \

Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** a/glc.c	8 Mar 2004 00:20:28 -0000	1.24
--- b/glc.c	21 Mar 2004 13:41:02 -0000	1.25
***************
*** 260,264 ****
      (GL_TEXTURE1_ARB, mask_tl.x, mask_tl.y);
    glVertex2d (dst_region.x1, dst_region.y1);
!   
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE0_ARB, src_br.x, src_tl.y);
--- 260,264 ----
      (GL_TEXTURE1_ARB, mask_tl.x, mask_tl.y);
    glVertex2d (dst_region.x1, dst_region.y1);
! 
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE0_ARB, src_br.x, src_tl.y);
***************
*** 266,270 ****
      (GL_TEXTURE1_ARB, mask_br.x, mask_tl.y);
    glVertex2d (dst_region.x2, dst_region.y1);
!   
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE0_ARB, src_br.x, src_br.y);
--- 266,270 ----
      (GL_TEXTURE1_ARB, mask_br.x, mask_tl.y);
    glVertex2d (dst_region.x2, dst_region.y1);
! 
    dst->proc_address->gl_multi_tex_coord_2d_arb
      (GL_TEXTURE0_ARB, src_br.x, src_br.y);
***************
*** 281,291 ****
    glEnd ();
  
    glc_texture_unbind (mask_texture);
! 
    dst->proc_address->gl_active_texture_arb (GL_TEXTURE0_ARB);
- 
    glc_texture_unbind (src_texture);
  
!   glc_surface_disable_program (dst);
  
    dirty_region.x1 = floor (dst_region.x1);
--- 281,291 ----
    glEnd ();
  
+   dst->proc_address->gl_active_texture_arb (GL_TEXTURE1_ARB);
    glc_texture_unbind (mask_texture);
!   
    dst->proc_address->gl_active_texture_arb (GL_TEXTURE0_ARB);
    glc_texture_unbind (src_texture);
  
!   glc_surface_disable_program (type, dst);
  
    dirty_region.x1 = floor (dst_region.x1);
***************
*** 406,409 ****
--- 406,410 ----
    glc_point_t tl, bl, br, tr;
    glc_region_box_t clip;
+   glc_program_type_t type = 0;
  
    if (src->programmatic)
***************
*** 544,550 ****
    glc_set_operator (op);
  
!   if (src->convolution || src->programmatic)
!     glc_surface_enable_program (glc_program_type (dst, src, NULL),
!                                 dst, src, NULL, texture, NULL);
    
    if ((!TRANSFORM (src)) && GLREPEAT (src, texture)) {
--- 545,552 ----
    glc_set_operator (op);
  
!   if (src->convolution || src->programmatic) {
!     type = glc_program_type (dst, src, NULL);
!     glc_surface_enable_program (type, dst, src, NULL, texture, NULL);
!   }
    
    if ((!TRANSFORM (src)) && GLREPEAT (src, texture)) {
***************
*** 708,712 ****
  
    if (src->convolution || src->programmatic)
!     glc_surface_disable_program (dst);
    
    glc_texture_unbind (texture);
--- 710,714 ----
  
    if (src->convolution || src->programmatic)
!     glc_surface_disable_program (type, dst);
    
    glc_texture_unbind (texture);

Index: glc.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** a/glc.h	6 Mar 2004 13:58:17 -0000	1.17
--- b/glc.h	21 Mar 2004 13:41:02 -0000	1.18
***************
*** 57,60 ****
--- 57,64 ----
  } glc_point_fixed_t;
  
+ typedef struct _glc_distance_fixed_t {
+   glc_fixed16_16_t dx, dy;
+ } glc_distance_fixed_t;
+ 
  typedef struct _glc_line_fixed_t {
    glc_point_fixed_t p1, p2;
***************
*** 101,109 ****
  } glc_colorpoint_t;
  
- typedef struct _glc_colorstop_t {
-   glc_fixed16_16_t stop;
-   glc_color_t color;
- } glc_colorstop_t;
-   
  typedef struct _glc_color_trapezoid_t {
    glc_colorspan_t top, bottom;
--- 105,108 ----
***************
*** 139,152 ****
  } glc_operator_t;
  
! #define GLC_FEATURE_OFFSCREEN_DRAWING_MASK     (1L << 0)
! #define GLC_FEATURE_CONVOLUTION_FILTER_MASK    (1L << 1)
! #define GLC_FEATURE_GRADIENT_MASK              (1L << 2)
! #define GLC_FEATURE_TEXTURE_RECTANGLE_MASK     (1L << 3)
! #define GLC_FEATURE_TEXTURE_NPOT_MASK          (1L << 4)
! #define GLC_FEATURE_MULTISAMPLE_MASK           (1L << 5)
! #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK (1L << 6)
! #define GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK    (1L << 7)
! #define GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK  (1L << 8)
! #define GLC_FEATURE_ATI_RENDER_TEXTURE_MASK    (1L << 9)
  
  typedef enum {  
--- 138,151 ----
  } glc_operator_t;
  
! #define GLC_FEATURE_OFFSCREEN_DRAWING_MASK       (1L << 0)
! #define GLC_FEATURE_CONVOLUTION_FILTER_MASK      (1L << 1)
! #define GLC_FEATURE_TEXTURE_RECTANGLE_MASK       (1L << 2)
! #define GLC_FEATURE_TEXTURE_NPOT_MASK            (1L << 3)
! #define GLC_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L << 4)
! #define GLC_FEATURE_MULTISAMPLE_MASK             (1L << 5)
! #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK   (1L << 6)
! #define GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L << 7)
! #define GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 8)
! #define GLC_FEATURE_ATI_RENDER_TEXTURE_MASK      (1L << 9)
  
  typedef enum {  
***************
*** 157,176 ****
  } glc_format_name_t;
    
! #define GLC_FORMAT_ID_MASK                  (1 <<  0)
! #define GLC_FORMAT_BPP_MASK                 (1 <<  1)
! #define GLC_FORMAT_RED_MASK_MASK            (1 <<  2)
! #define GLC_FORMAT_GREEN_MASK_MASK          (1 <<  3)
! #define GLC_FORMAT_BLUE_MASK_MASK           (1 <<  4)
! #define GLC_FORMAT_ALPHA_MASK_MASK          (1 <<  5)
! #define GLC_FORMAT_RED_SIZE_MASK            (1 <<  6)
! #define GLC_FORMAT_GREEN_SIZE_MASK          (1 <<  7)
! #define GLC_FORMAT_BLUE_SIZE_MASK           (1 <<  8)
! #define GLC_FORMAT_ALPHA_SIZE_MASK          (1 <<  9)
! #define GLC_FORMAT_DEPTH_SIZE_MASK          (1 << 10)
! #define GLC_FORMAT_DOUBLEBUFFER_MASK        (1 << 11)
! #define GLC_FORMAT_ONSCREEN_MASK            (1 << 12)
! #define GLC_FORMAT_OFFSCREEN_MASK           (1 << 13)
! #define GLC_FORMAT_MULTISAMPLE_MASK         (1 << 14)
! #define GLC_FORMAT_MULTISAMPLE_SAMPLES_MASK (1 << 15)
  
  typedef unsigned long int glc_format_id_t;
--- 156,175 ----
  } glc_format_name_t;
    
! #define GLC_FORMAT_ID_MASK                  (1L <<  0)
! #define GLC_FORMAT_BPP_MASK                 (1L <<  1)
! #define GLC_FORMAT_RED_MASK_MASK            (1L <<  2)
! #define GLC_FORMAT_GREEN_MASK_MASK          (1L <<  3)
! #define GLC_FORMAT_BLUE_MASK_MASK           (1L <<  4)
! #define GLC_FORMAT_ALPHA_MASK_MASK          (1L <<  5)
! #define GLC_FORMAT_RED_SIZE_MASK            (1L <<  6)
! #define GLC_FORMAT_GREEN_SIZE_MASK          (1L <<  7)
! #define GLC_FORMAT_BLUE_SIZE_MASK           (1L <<  8)
! #define GLC_FORMAT_ALPHA_SIZE_MASK          (1L <<  9)
! #define GLC_FORMAT_DEPTH_SIZE_MASK          (1L << 10)
! #define GLC_FORMAT_DOUBLEBUFFER_MASK        (1L << 11)
! #define GLC_FORMAT_ONSCREEN_MASK            (1L << 12)
! #define GLC_FORMAT_OFFSCREEN_MASK           (1L << 13)
! #define GLC_FORMAT_MULTISAMPLE_MASK         (1L << 14)
! #define GLC_FORMAT_MULTISAMPLE_SAMPLES_MASK (1L << 15)
  
  typedef unsigned long int glc_format_id_t;
***************
*** 207,216 ****
  } glc_format_t;
  
! #define GLC_FORMAT_OPTION_DOUBLEBUFFER_MASK   (1 << 0)
! #define GLC_FORMAT_OPTION_SINGLEBUFFER_MASK   (1 << 1)
! #define GLC_FORMAT_OPTION_ONSCREEN_MASK       (1 << 2)
! #define GLC_FORMAT_OPTION_OFFSCREEN_MASK      (1 << 3)
! #define GLC_FORMAT_OPTION_MULTISAMPLE_MASK    (1 << 4)
! #define GLC_FORMAT_OPTION_NO_MULTISAMPLE_MASK (1 << 5)
  
  /* glc_status.c */
--- 206,215 ----
  } glc_format_t;
  
! #define GLC_FORMAT_OPTION_DOUBLEBUFFER_MASK   (1L << 0)
! #define GLC_FORMAT_OPTION_SINGLEBUFFER_MASK   (1L << 1)
! #define GLC_FORMAT_OPTION_ONSCREEN_MASK       (1L << 2)
! #define GLC_FORMAT_OPTION_OFFSCREEN_MASK      (1L << 3)
! #define GLC_FORMAT_OPTION_MULTISAMPLE_MASK    (1L << 4)
! #define GLC_FORMAT_OPTION_NO_MULTISAMPLE_MASK (1L << 5)
  
  /* glc_status.c */
***************
*** 228,231 ****
--- 227,260 ----
  glc_status_string (glc_status_t status);
  
+ /* glc_color_range.c */
+ 
+ typedef struct _glc_color_range glc_color_range_t;
+ 
+ typedef enum {
+   GLC_EXTEND_PAD,
+   GLC_EXTEND_REPEAT,
+   GLC_EXTEND_REFLECT
+ } glc_extend_t;
+   
+ glc_color_range_t *
+ glc_color_range_create (unsigned int size);
+ 
+ void
+ glc_color_range_destroy (glc_color_range_t *color_range);
+ 
+ unsigned char *
+ glc_color_range_get_data (glc_color_range_t *color_range);
+ 
+ void
+ glc_color_range_put_back_data (glc_color_range_t *color_range);
+ 
+ void
+ glc_color_range_set_filter (glc_color_range_t *color_range,
+                             glc_filter_t filter);
+   
+ void
+ glc_color_range_set_extend (glc_color_range_t *color_range,
+                             glc_extend_t extend);
+ 
    
  /* glc_surface.c */
***************
*** 237,240 ****
--- 266,282 ----
    GLC_POLYEDGE_SMOOTH
  } glc_polyedge_t;
+ 
+ glc_surface_t *
+ glc_surface_create_solid (glc_color_t *color);
+   
+ glc_surface_t *
+ glc_surface_create_linear (glc_point_fixed_t *start,
+                            glc_point_fixed_t *end,
+                            glc_color_range_t *color_range);
+ 
+ glc_surface_t *
+ glc_surface_create_radial (glc_point_fixed_t *center,
+                            glc_distance_fixed_t *radius,
+                            glc_color_range_t *color_range);
    
  void
***************
*** 312,332 ****
  unsigned long
  glc_surface_features (glc_surface_t *surface);
- 
-   
- /* glc_programmatic.c */
- 
- glc_surface_t *
- glc_solid_create (glc_color_t *color);
-   
- glc_surface_t *
- glc_linear_gradient_create (glc_colorpoint_t *start,
-                             glc_colorpoint_t *end,
-                             glc_colorstop_t *stops,
-                             int n_stops);
- 
- glc_surface_t *
- glc_radial_gradient_create (glc_colorpoint_t *start,
-                             glc_colorstop_t *stops,
-                             int n_stops);
    
    
--- 354,357 ----

Index: glc_agl_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_extension.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/glc_agl_extension.c	5 Mar 2004 07:48:22 -0000	1.7
--- b/glc_agl_extension.c	21 Mar 2004 13:41:02 -0000	1.8
***************
*** 37,40 ****
--- 37,42 ----
    { "GL_NV_texture_rectangle", GLC_AGL_FEATURE_TEXTURE_RECTANGLE_MASK },
    { "GL_ARB_texture_non_power_of_two", GLC_AGL_FEATURE_TEXTURE_NPOT_MASK },
+   { "GL_ARB_texture_mirrored_repeat",
+     GLC_AGL_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK },
    { "GL_ARB_multisample", GLC_AGL_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK },
***************
*** 88,99 ****
  
    if (thread_info->agl_feature_mask &
        GLC_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK)
      thread_info->feature_mask |= GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK;
    
    if (thread_info->agl_feature_mask &
!       GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
      thread_info->feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
-     thread_info->feature_mask |= GLC_FEATURE_GRADIENT_MASK;
-   }
  
    if ((thread_info->feature_mask & GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&
--- 90,103 ----
  
    if (thread_info->agl_feature_mask &
+       GLC_AGL_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK)
+     thread_info->feature_mask |= GLC_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK;
+ 
+   if (thread_info->agl_feature_mask &
        GLC_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK)
      thread_info->feature_mask |= GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK;
    
    if (thread_info->agl_feature_mask &
!       GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
      thread_info->feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
  
    if ((thread_info->feature_mask & GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK) &&

Index: glc_glext.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glext.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/glc_glext.h	6 Mar 2004 13:58:17 -0000	1.1
--- b/glc_glext.h	21 Mar 2004 13:41:02 -0000	1.2
***************
*** 36,39 ****
--- 36,43 ----
  #endif
  
+ #ifndef GL_ARB_texture_mirrored_repeat
+ #define GL_MIRRORED_REPEAT_ARB            0x8370
+ #endif
+ 
  #ifndef GL_ARB_multitexture
  #define GL_TEXTURE0_ARB                   0x84C0

Index: glc_glx_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_extension.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** a/glc_glx_extension.c	6 Mar 2004 13:58:17 -0000	1.15
--- b/glc_glx_extension.c	21 Mar 2004 13:41:02 -0000	1.16
***************
*** 42,45 ****
--- 42,47 ----
    { "GL_NV_texture_rectangle", GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK },
    { "GL_ARB_texture_non_power_of_two", GLC_GLX_FEATURE_TEXTURE_NPOT_MASK },
+   { "GL_ARB_texture_mirrored_repeat",
+     GLC_GLX_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK },
    { "GL_ARB_multisample", GLC_GLX_FEATURE_MULTISAMPLE_MASK },
    { "GL_NV_multisample_filter_hint", GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK },
***************
*** 113,116 ****
--- 115,122 ----
  
    if (screen_info->glx_feature_mask &
+       GLC_GLX_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK)
+     screen_info->feature_mask |= GLC_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK;
+ 
+   if (screen_info->glx_feature_mask &
        GLC_GLX_FEATURE_ATI_RENDER_TEXTURE_MASK) {
      screen_info->glx_feature_mask |= GLC_GLX_FEATURE_ATI_RENDER_TEXTURE_MASK;
***************
*** 132,136 ****
      screen_info->glx_feature_mask |= GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
      screen_info->feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
-     screen_info->feature_mask |= GLC_FEATURE_GRADIENT_MASK;
    }
  
--- 138,141 ----

Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** a/glc_glx_surface.c	6 Mar 2004 13:58:17 -0000	1.19
--- b/glc_glx_surface.c	21 Mar 2004 13:41:02 -0000	1.20
***************
*** 162,166 ****
    surface->base.feature_mask &= ~GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
    surface->base.feature_mask &= ~GLC_FEATURE_CONVOLUTION_FILTER_MASK;
-   surface->base.feature_mask &= ~GLC_FEATURE_GRADIENT_MASK;
    surface->base.feature_mask &= ~GLC_FEATURE_MULTISAMPLE_MASK;
    surface->base.feature_mask &= ~GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
--- 162,165 ----
***************
*** 184,192 ****
        surface->context->gl_proc_address.gl_bind_program_arb) {
      if (surface->screen_info->feature_mask &
!         GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
        surface->base.feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
!       surface->base.feature_mask |= GLC_FEATURE_GRADIENT_MASK;
!     }
!     
      if (surface->screen_info->feature_mask &
          GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK)
--- 183,189 ----
        surface->context->gl_proc_address.gl_bind_program_arb) {
      if (surface->screen_info->feature_mask &
!         GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK)
        surface->base.feature_mask |= GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK;
!   
      if (surface->screen_info->feature_mask &
          GLC_FEATURE_ARB_VERTEX_PROGRAM_MASK)

Index: glc_program.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_program.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** a/glc_program.c	8 Mar 2004 00:20:28 -0000	1.8
--- b/glc_program.c	21 Mar 2004 13:41:02 -0000	1.9
***************
*** 260,299 ****
    
    /*
!    * Linear gradient.
     *
!    * program.local[0]: start color
!    * program.local[1]: end color
!    * program.local[2].x = start offset
!    * program.local[2].y = stop offset
!    * program.local[2].z = 1 / length
!    * program.local[3].x = sin (angle)
!    * program.local[3].y = cos (angle)
     *
     * Author: David Reveman <c99drn at cs.umu.se>
     */
    "!!ARBfp1.0\n"
!   "PARAM start_color = program.local[0];\n"
!   "PARAM end_color = program.local[1];\n"
!   "PARAM gradient = program.local[2];\n"
!   "PARAM angle = program.local[3];\n"
    "ATTRIB pos = fragment.texcoord[%d];\n"
    "TEMP color, distance, position;\n"
! 
    /* temporary */
    "%s"
! 
    "MUL position.x, angle.x, pos.x;\n"
    "MAD position.x, angle.y, pos.y, position.x;\n"
! 
!   "SUB distance, position.x, gradient.x;\n"
!   "MUL distance, distance, gradient.z;\n"
! 
!   "MUL color, distance, end_color;\n"
! 
!   "SUB distance, gradient.y, position.x;\n"
!   "MUL distance, distance, gradient.z;\n"
! 
!   "MAD color, distance, start_color, color;\n"
! 
    /* pd operation */
    "%s"
--- 260,292 ----
    
    /*
!    * Linear gradient using 1D texture as color range.
!    * Texture unit 2 is color range.
     *
!    * program.local[0].x = start offset
!    * program.local[0].y = stop offset
!    * program.local[0].z = 1 / length
!    * program.local[1].x = sin (angle)
!    * program.local[1].y = cos (angle)
     *
     * Author: David Reveman <c99drn at cs.umu.se>
     */
+ 
    "!!ARBfp1.0\n"
!   "PARAM gradient = program.local[0];\n"
!   "PARAM angle = program.local[1];\n"
    "ATTRIB pos = fragment.texcoord[%d];\n"
    "TEMP color, distance, position;\n"
!   
    /* temporary */
    "%s"
!   
    "MUL position.x, angle.x, pos.x;\n"
    "MAD position.x, angle.y, pos.y, position.x;\n"
!   
!   "SUB distance.x, position.x, gradient.x;\n"
!   "MUL distance.x, distance.x, gradient.z;\n"
!   
!   "TEX color, distance, texture[2], 1D;\n"
!   
    /* pd operation */
    "%s"
***************
*** 302,312 ****
  
    /*
!    * Radial gradient.
     *
!    * program.local[0]: start color
!    * program.local[1]: end color
!    * program.local[2].x = center point X coordinate
!    * program.local[2].y = center point Y coordinate
!    * program.local[2].z = 1 / (length * length)
     *
     * Author: David Reveman <c99drn at cs.umu.se>
--- 295,307 ----
  
    /*
!    * Radial gradient using 1D texture as color range.
!    * Texture unit 2 is color range.
     *
!    * param[0].x = center point X coordinate
!    * param[0].y = center point Y coordinate
!    * param[1].x = MIN (radius_x, radius_y) / radius_x
!    * param[1].y = MIN (radius_x, radius_y) / radius_y
!    * param[1].z = 0
!    * param[1].x = 1 / MIN (radius_x, radius_y)
     *
     * Author: David Reveman <c99drn at cs.umu.se>
***************
*** 314,320 ****
  
    "!!ARBfp1.0\n"
!   "PARAM start_color = program.local[0];\n"
!   "PARAM end_color = program.local[1];\n"
!   "PARAM gradient = program.local[2];\n"
    "ATTRIB position = fragment.texcoord[%d];\n"
    "TEMP color, distance;\n"
--- 309,314 ----
  
    "!!ARBfp1.0\n"
!   "PARAM gradient = program.local[0];\n"
!   "PARAM length = program.local[1];\n"
    "ATTRIB position = fragment.texcoord[%d];\n"
    "TEMP color, distance;\n"
***************
*** 322,336 ****
    /* temporary */
    "%s"
  
!   "MOV distance, 0.0;\n"
!   "SUB distance.x, position.x, gradient.x;\n"
!   "SUB distance.y, position.y, gradient.y;\n"
    
!   "DP3 distance, distance, distance;\n"
!   "MUL distance.xyzw, distance, gradient.z;\n"
    
!   "MUL color, distance, end_color;\n"
!   "SUB distance, 1.0, distance;\n"
!   "MAD color, distance, start_color, color;\n"
  
    /* pd operation */
--- 316,333 ----
    /* temporary */
    "%s"
+   
+   "SUB distance, position, gradient;\n"
+   "MUL distance, distance, length;\n"
  
!   "DP3 distance.x, distance, distance;\n"
!   "RSQ distance.w, distance.x;\n"
    
!   "RCP distance.x, distance.w;\n"
!   "MUL distance.x, distance.x, distance.x;\n"
!   "MUL distance.x, distance.x, distance.w;\n"
    
!   "MUL distance.x, distance.x, length.w;\n"
!   
!   "TEX color, distance, texture[2], 1D;\n"
  
    /* pd operation */
***************
*** 504,509 ****
               expand->operation);
      break;
!   case GLC_PROGRAMMATIC_SURFACE_LINEAR_GRADIENT_TYPE:
!   case GLC_PROGRAMMATIC_SURFACE_RADIAL_GRADIENT_TYPE:
      sprintf (program_buffer,
               _glc_fragment_program_programmatic[type],
--- 501,506 ----
               expand->operation);
      break;
!   case GLC_PROGRAMMATIC_SURFACE_LINEAR_TYPE:
!   case GLC_PROGRAMMATIC_SURFACE_RADIAL_TYPE:
      sprintf (program_buffer,
               _glc_fragment_program_programmatic[type],
***************
*** 607,623 ****
  
      if (solid_offset) {
!       glc_solid_t *solid;
        
        if (solid_offset == 1)
!         solid = &((glc_programmatic_surface_t *) mask)->attributes.solid;
        else
!         solid = &((glc_programmatic_surface_t *) src)->attributes.solid;
        
        proc_address->gl_program_local_param_4d_arb
          (GL_FRAGMENT_PROGRAM_ARB, 3,
!          (double) solid->color.red / 65536.0,
!          (double) solid->color.green / 65536.0,
!          (double) solid->color.blue / 65536.0,
!          (double) solid->color.alpha / 65536.0);
      }
    }
--- 604,620 ----
  
      if (solid_offset) {
!       glc_color_t *color;
        
        if (solid_offset == 1)
!         color = &((glc_programmatic_surface_t *) mask)->u.solid.color;
        else
!         color = &((glc_programmatic_surface_t *) src)->u.solid.color;
        
        proc_address->gl_program_local_param_4d_arb
          (GL_FRAGMENT_PROGRAM_ARB, 3,
!          (double) color->red / 65536.0,
!          (double) color->green / 65536.0,
!          (double) color->blue / 65536.0,
!          (double) color->alpha / 65536.0);
      }
    }
***************
*** 647,651 ****
    if ((surface->type == GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE) &&
        (add_offset == GLC_PROGRAM_NOSRC_NOMASK_OFFSET)) {
!     glc_programmatic_surface_set_parameters (proc_address, surface);
      
      return;
--- 644,648 ----
    if ((surface->type == GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE) &&
        (add_offset == GLC_PROGRAM_NOSRC_NOMASK_OFFSET)) {
!     glc_programmatic_surface_bind (proc_address, surface, dst->feature_mask);
      
      return;
***************
*** 663,667 ****
           programs->fragment_programmatic[type_offset]);
      
!       glc_programmatic_surface_set_parameters (proc_address, surface);
      }
    }
--- 660,664 ----
           programs->fragment_programmatic[type_offset]);
      
!       glc_programmatic_surface_bind (proc_address, surface, dst->feature_mask);
      }
    }
***************
*** 798,804 ****
  
  void
! glc_program_disable (glc_surface_t *dst)
  {
    if (dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
      dst->proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB, 0);
      glDisable (GL_FRAGMENT_PROGRAM_ARB);
--- 795,811 ----
  
  void
! glc_program_disable (glc_program_type_t type,
!                      glc_surface_t *dst)
  {
    if (dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
+ 
+     if (type == GLC_PROGRAM_TYPE_SRC_PROGRAMMATIC ||
+         type == GLC_PROGRAM_TYPE_MASK_PROGRAMMATIC) {
+       dst->proc_address->gl_active_texture_arb (GL_TEXTURE2_ARB);
+       glBindTexture (GL_TEXTURE_1D, 0);
+       glDisable (GL_TEXTURE_1D);
+       dst->proc_address->gl_active_texture_arb (GL_TEXTURE0_ARB);
+     }
+     
      dst->proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB, 0);
      glDisable (GL_FRAGMENT_PROGRAM_ARB);

Index: glc_programmatic.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_programmatic.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** a/glc_programmatic.c	15 Mar 2004 11:27:13 -0000	1.4
--- b/glc_programmatic.c	21 Mar 2004 13:41:03 -0000	1.5
***************
*** 48,51 ****
--- 48,61 ----
    glc_programmatic_surface_t *surface =
      (glc_programmatic_surface_t *) abstract_surface;
+ 
+   switch (surface->type) {
+   case GLC_PROGRAMMATIC_SURFACE_LINEAR_TYPE:
+     glc_color_range_destroy (surface->u.linear.color_range);
+     break;
+   case GLC_PROGRAMMATIC_SURFACE_RADIAL_TYPE:
+     glc_color_range_destroy (surface->u.radial.color_range);
+   default:
+     break;
+   }
    
    glc_surface_deinit (&surface->base);
***************
*** 125,140 ****
                                  int height)
  {
!  glc_programmatic_surface_t *surface =
      (glc_programmatic_surface_t *) abstract_surface;
!  
   surface->texture.texcoord_width = surface->base.width =
     surface->texture.width = width;
   surface->texture.texcoord_height = surface->base.height =
     surface->texture.height = height;
-  surface->base.repeat = 0;
  }
  
  glc_surface_t *
! glc_solid_create (glc_color_t *color)
  {
    glc_programmatic_surface_t *surface;
--- 135,149 ----
                                  int height)
  {
!   glc_programmatic_surface_t *surface =
      (glc_programmatic_surface_t *) abstract_surface;
!   
   surface->texture.texcoord_width = surface->base.width =
     surface->texture.width = width;
   surface->texture.texcoord_height = surface->base.height =
     surface->texture.height = height;
  }
  
  glc_surface_t *
! glc_programmatic_surface_create_solid (glc_color_t *color)
  {
    glc_programmatic_surface_t *surface;
***************
*** 145,164 ****
  
    surface->type = GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE;
!   surface->attributes.solid.color = *color;
!   surface->texture.target = 0;
    
    return &surface->base;
  }
- slim_hidden_def(glc_solid_create);
  
- /* TODO: support color stops */
  glc_surface_t *
! glc_linear_gradient_create (glc_colorpoint_t *start,
!                             glc_colorpoint_t *end,
!                             glc_colorstop_t *stops,
!                             int n_stops)
  {
    glc_programmatic_surface_t *surface;
-   glc_linear_gradient_t *gradient;
  
    surface = _glc_programmatic_surface_create ();
--- 154,168 ----
  
    surface->type = GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE;
!   surface->u.solid.color = *color;
    
    return &surface->base;
  }
  
  glc_surface_t *
! glc_programmatic_surface_create_linear (glc_point_fixed_t *start,
!                                         glc_point_fixed_t *stop,
!                                         glc_color_range_t *color_range)
  {
    glc_programmatic_surface_t *surface;
  
    surface = _glc_programmatic_surface_create ();
***************
*** 166,187 ****
      return NULL;
  
!   surface->type = GLC_PROGRAMMATIC_SURFACE_LINEAR_GRADIENT_TYPE;
!   gradient = &surface->attributes.linear_gradient;
! 
!   gradient->start = *start;
!   gradient->end = *end;    
    
    return &surface->base;
  }
- slim_hidden_def(glc_linear_gradient_create);
  
- /* TODO: support more than one color stop and adjustable focus point */
  glc_surface_t *
! glc_radial_gradient_create (glc_colorpoint_t *start,
!                             glc_colorstop_t *stops,
!                             int n_stops)
  {
    glc_programmatic_surface_t *surface;
-   glc_radial_gradient_t *gradient;
  
    surface = _glc_programmatic_surface_create ();
--- 170,188 ----
      return NULL;
  
!   surface->type = GLC_PROGRAMMATIC_SURFACE_LINEAR_TYPE;
!   surface->u.linear.start = *start;
!   surface->u.linear.stop = *stop;
!   surface->u.linear.color_range = color_range;
!   glc_color_range_reference (color_range);
    
    return &surface->base;
  }
  
  glc_surface_t *
! glc_programmatic_surface_create_radial (glc_point_fixed_t *start,
!                                         glc_distance_fixed_t *radius,
!                                         glc_color_range_t *color_range)
  {
    glc_programmatic_surface_t *surface;
  
    surface = _glc_programmatic_surface_create ();
***************
*** 189,231 ****
      return NULL;
  
!   surface->type = GLC_PROGRAMMATIC_SURFACE_RADIAL_GRADIENT_TYPE;
!   gradient = &surface->attributes.radial_gradient;
! 
!   gradient->start = *start;
! 
!   if (n_stops) {
!     gradient->stop = *stops;
!   } else {
!     gradient->stop.stop = 0;
!     gradient->stop.color = gradient->start.color;
!   }
    
    return &surface->base;
  }
- slim_hidden_def(glc_radial_gradient_create);
  
  void
! glc_programmatic_surface_set_parameters (glc_gl_proc_address_list_t
!                                          *proc_address,
!                                          glc_programmatic_surface_t *surface)
  {
    switch (surface->type) {
    case GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE: {
!     glc_solid_t *solid = &surface->attributes.solid;
!     
!     glColor4us (solid->color.red, solid->color.green, solid->color.blue,
!                 solid->color.alpha);
    } break;
!   case GLC_PROGRAMMATIC_SURFACE_LINEAR_GRADIENT_TYPE: {
!     glc_linear_gradient_t *gradient = &surface->attributes.linear_gradient;
      glc_point_t p1, p2;
!     double length, angle, start, end;
! 
!     p1.x = FIXED_TO_DOUBLE (gradient->start.point.x);
!     p1.y = surface->base.height - FIXED_TO_DOUBLE (gradient->start.point.y);
      
-     p2.x = FIXED_TO_DOUBLE (gradient->end.point.x);
-     p2.y = surface->base.height - FIXED_TO_DOUBLE (gradient->end.point.y);
- 
      length = sqrt ((p2.x - p1.x) * (p2.x - p1.x) +
                     (p2.y - p1.y) * (p2.y - p1.y));
--- 190,226 ----
      return NULL;
  
!   surface->type = GLC_PROGRAMMATIC_SURFACE_RADIAL_TYPE;
!   surface->u.radial.center = *start;
!   surface->u.radial.radius = *radius;
!   surface->u.radial.color_range = color_range;
!   glc_color_range_reference (color_range);
    
    return &surface->base;
  }
  
  void
! glc_programmatic_surface_bind (glc_gl_proc_address_list_t *proc_address,
!                                glc_programmatic_surface_t *surface,
!                                unsigned long feature_mask)
  {
    switch (surface->type) {
    case GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE: {
!     glColor4us (surface->u.solid.color.red,
!                 surface->u.solid.color.green,
!                 surface->u.solid.color.blue,
!                 surface->u.solid.color.alpha);
    } break;
!   case GLC_PROGRAMMATIC_SURFACE_LINEAR_TYPE: {
      glc_point_t p1, p2;
!     double length, angle, start, stop;
!     
!     p1.x = FIXED_TO_DOUBLE (surface->u.linear.start.x);
!     p1.y = surface->base.height -
!       FIXED_TO_DOUBLE (surface->u.linear.start.y);
!     
!     p2.x = FIXED_TO_DOUBLE (surface->u.linear.stop.x);
!     p2.y = surface->base.height -
!       FIXED_TO_DOUBLE (surface->u.linear.stop.y);
      
      length = sqrt ((p2.x - p1.x) * (p2.x - p1.x) +
                     (p2.y - p1.y) * (p2.y - p1.y));
***************
*** 236,289 ****
      start += -sin (angle) * p1.y;
  
!     end = cos (angle) * p2.x;
!     end += -sin (angle) * p2.y;
  
      proc_address->gl_program_local_param_4d_arb
        (GL_FRAGMENT_PROGRAM_ARB, 0,
-        FIXED_TO_DOUBLE (gradient->start.color.red),
-        FIXED_TO_DOUBLE (gradient->start.color.green),
-        FIXED_TO_DOUBLE (gradient->start.color.blue),
-        FIXED_TO_DOUBLE (gradient->start.color.alpha));
-     proc_address->gl_program_local_param_4d_arb
-       (GL_FRAGMENT_PROGRAM_ARB, 1,
-        FIXED_TO_DOUBLE (gradient->end.color.red),
-        FIXED_TO_DOUBLE (gradient->end.color.green),
-        FIXED_TO_DOUBLE (gradient->end.color.blue),
-        FIXED_TO_DOUBLE (gradient->end.color.alpha));
-     proc_address->gl_program_local_param_4d_arb
-       (GL_FRAGMENT_PROGRAM_ARB, 2,
         start,
!        end,
         (length)? 1.0 / length: INT_MAX,
         0.0);
      proc_address->gl_program_local_param_4d_arb
!       (GL_FRAGMENT_PROGRAM_ARB, 3,
         cos (angle),
         -sin (angle),
         0.0, 0.0);
    } break;
!   case GLC_PROGRAMMATIC_SURFACE_RADIAL_GRADIENT_TYPE: {
!     glc_radial_gradient_t *gradient = &surface->attributes.radial_gradient;
!     double length = FIXED_TO_DOUBLE (gradient->stop.stop);
  
      proc_address->gl_program_local_param_4d_arb
        (GL_FRAGMENT_PROGRAM_ARB, 0,
!        FIXED_TO_DOUBLE (gradient->start.color.red),
!        FIXED_TO_DOUBLE (gradient->start.color.green),
!        FIXED_TO_DOUBLE (gradient->start.color.blue),
!        FIXED_TO_DOUBLE (gradient->start.color.alpha));
      proc_address->gl_program_local_param_4d_arb
        (GL_FRAGMENT_PROGRAM_ARB, 1,
!        FIXED_TO_DOUBLE (gradient->stop.color.red),
!        FIXED_TO_DOUBLE (gradient->stop.color.green),
!        FIXED_TO_DOUBLE (gradient->stop.color.blue),
!        FIXED_TO_DOUBLE (gradient->stop.color.alpha));
!     proc_address->gl_program_local_param_4d_arb
!       (GL_FRAGMENT_PROGRAM_ARB, 2,
!        FIXED_TO_DOUBLE (gradient->start.point.x),
!        surface->base.height - FIXED_TO_DOUBLE (gradient->start.point.y),
!        (length)? 1.0 / (length * length): INT_MAX,
!        0.0);
!   } break;
    default:
      break;
--- 231,285 ----
      start += -sin (angle) * p1.y;
  
!     stop = cos (angle) * p2.x;
!     stop += -sin (angle) * p2.y;
  
      proc_address->gl_program_local_param_4d_arb
        (GL_FRAGMENT_PROGRAM_ARB, 0,
         start,
!        stop,
         (length)? 1.0 / length: INT_MAX,
         0.0);
      proc_address->gl_program_local_param_4d_arb
!       (GL_FRAGMENT_PROGRAM_ARB, 1,
         cos (angle),
         -sin (angle),
         0.0, 0.0);
+ 
+     proc_address->gl_active_texture_arb (GL_TEXTURE2_ARB);
+     glc_color_range_bind (surface->u.linear.color_range, feature_mask);
+     proc_address->gl_active_texture_arb (GL_TEXTURE0_ARB);
+     
    } break;
!   case GLC_PROGRAMMATIC_SURFACE_RADIAL_TYPE: {
!     double radius_x, radius_y;
!     double length;
!     
!     radius_x = FIXED_TO_DOUBLE (surface->u.radial.radius.dx);
!     radius_y = FIXED_TO_DOUBLE (surface->u.radial.radius.dy);
! 
!     length = fabs (MIN (radius_x, radius_y));
  
+     /* ugly */
+     if (length == 0.0)
+       length = 0.000001;
+     
      proc_address->gl_program_local_param_4d_arb
        (GL_FRAGMENT_PROGRAM_ARB, 0,
!        FIXED_TO_DOUBLE (surface->u.radial.center.x),
!        surface->base.height -
!        FIXED_TO_DOUBLE (surface->u.radial.center.y),
!        0.0, 0.0);
      proc_address->gl_program_local_param_4d_arb
        (GL_FRAGMENT_PROGRAM_ARB, 1,
!        length / radius_x,
!        length / radius_y,
!        0.0,
!        1.0 / length);
! 
!     proc_address->gl_active_texture_arb (GL_TEXTURE2_ARB);
!     glc_color_range_bind (surface->u.radial.color_range, feature_mask);
!     proc_address->gl_active_texture_arb (GL_TEXTURE0_ARB);
!     
!   }
    default:
      break;

Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** a/glc_surface.c	13 Mar 2004 23:44:29 -0000	1.23
--- b/glc_surface.c	21 Mar 2004 13:41:03 -0000	1.24
***************
*** 85,88 ****
--- 85,113 ----
  }
  
+ glc_surface_t *
+ glc_surface_create_solid (glc_color_t *color)
+ {
+   return glc_programmatic_surface_create_solid (color);
+ }
+ slim_hidden_def(glc_surface_create_solid);
+   
+ glc_surface_t *
+ glc_surface_create_linear (glc_point_fixed_t *start,
+                            glc_point_fixed_t *end,
+                            glc_color_range_t *color_range)
+ {
+   return glc_programmatic_surface_create_linear (start, end, color_range);
+ }
+ slim_hidden_def(glc_surface_create_linear);
+ 
+ glc_surface_t *
+ glc_surface_create_radial (glc_point_fixed_t *center,
+                            glc_distance_fixed_t *radius,
+                            glc_color_range_t *color_range)
+ {
+   return glc_programmatic_surface_create_radial (center, radius, color_range);
+ }
+ slim_hidden_def(glc_surface_create_radial);
+ 
  void
  glc_surface_destroy (glc_surface_t *surface)
***************
*** 122,128 ****
  
  void
! glc_surface_disable_program (glc_surface_t *surface)
  {
!   glc_program_disable (surface);
  }
  
--- 147,154 ----
  
  void
! glc_surface_disable_program (glc_program_type_t type,
!                              glc_surface_t *surface)
  {
!   glc_program_disable (type, surface);
  }
  

Index: glc_texture.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_texture.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** a/glc_texture.c	6 Mar 2004 13:58:17 -0000	1.12
--- b/glc_texture.c	21 Mar 2004 13:41:03 -0000	1.13
***************
*** 32,46 ****
  #include "glcint.h"
  
- static glc_bool_t
- _glc_texture_is_power_of_two (int value)
- {
-   int x = 1;
-   
-   while (x < value)
-     x <<= 1;
- 
-   return (x == value);
- }
- 
  static void
  _glc_texture_find_best_target (int width, int height,
--- 32,35 ----
***************
*** 51,56 ****
  
    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_RECTANGLE_MASK)
        *target = GL_TEXTURE_RECTANGLE_EXT;
--- 40,45 ----
  
    if ((!(target_mask & GLC_TEXTURE_TARGET_2D_MASK)) ||
!       (!glc_int_is_power_of_two (width)) ||
!       (!glc_int_is_power_of_two (height))) {
      if (target_mask & GLC_TEXTURE_TARGET_RECTANGLE_MASK)
        *target = GL_TEXTURE_RECTANGLE_EXT;
***************
*** 58,72 ****
  }
  
- static void
- _glc_texture_power_of_two_size (int *value)
- {
-   int x = 1;
-   
-   while (x < *value)
-     x <<= 1;
- 
-   *value = x;
- }
- 
  glc_texture_t *
  glc_texture_generate (int width,
--- 47,50 ----
***************
*** 93,98 ****
      
      if (texture->target == GL_TEXTURE_2D) {
!       _glc_texture_power_of_two_size (&texture->width);
!       _glc_texture_power_of_two_size (&texture->height);
      }
    } else
--- 71,76 ----
      
      if (texture->target == GL_TEXTURE_2D) {
!       glc_int_to_power_of_two (&texture->width);
!       glc_int_to_power_of_two (&texture->height);
      }
    } else

Index: glc_util.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_util.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** a/glc_util.c	20 Feb 2004 17:40:57 -0000	1.9
--- b/glc_util.c	21 Mar 2004 13:41:03 -0000	1.10
***************
*** 169,170 ****
--- 169,193 ----
    return mask;
  }
+ 
+ glc_bool_t
+ glc_int_is_power_of_two (int value)
+ {
+   int x = 1;
+   
+   while (x < value)
+     x <<= 1;
+ 
+   return (x == value);
+ }
+ 
+ void
+ glc_int_to_power_of_two (int *value)
+ {
+   int x = 1;
+   
+   while (x < *value)
+     x <<= 1;
+ 
+   *value = x;
+ }
+ 

Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** a/glcint.h	13 Mar 2004 23:44:29 -0000	1.26
--- b/glcint.h	21 Mar 2004 13:41:03 -0000	1.27
***************
*** 101,106 ****
  typedef enum {
    GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE = 0,
!   GLC_PROGRAMMATIC_SURFACE_LINEAR_GRADIENT_TYPE,
!   GLC_PROGRAMMATIC_SURFACE_RADIAL_GRADIENT_TYPE
  } glc_programmatic_surface_type_t;
  
--- 101,106 ----
  typedef enum {
    GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE = 0,
!   GLC_PROGRAMMATIC_SURFACE_LINEAR_TYPE,
!   GLC_PROGRAMMATIC_SURFACE_RADIAL_TYPE
  } glc_programmatic_surface_type_t;
  
***************
*** 118,122 ****
  
  #define GLC_PROGRAMMATIC_SURFACE_NUM \
!   (GLC_PROGRAMMATIC_SURFACE_RADIAL_GRADIENT_TYPE + 1)
  
  #define GLC_PROGRAM_2DSRC_2DMASK_OFFSET     0
--- 118,122 ----
  
  #define GLC_PROGRAMMATIC_SURFACE_NUM \
!   (GLC_PROGRAMMATIC_SURFACE_RADIAL_TYPE + 1)
  
  #define GLC_PROGRAM_2DSRC_2DMASK_OFFSET     0
***************
*** 239,268 ****
  };
  
! typedef struct _glc_solid_t {
!   glc_color_t color;
! } glc_solid_t;
! 
! typedef struct _glc_linear_gradient_t {
!   glc_colorpoint_t start;
!   glc_colorpoint_t end;
! } glc_linear_gradient_t;
! 
! typedef struct _glc_radial_gradient_t {
!   glc_colorpoint_t start;
!   glc_colorstop_t stop;
! } glc_radial_gradient_t;
  
! typedef union _glc_programmatic_attributes_t {
!   glc_solid_t solid;
!   glc_linear_gradient_t linear_gradient;
!   glc_radial_gradient_t radial_gradient;
! } glc_programmatic_attributes_t;
  
  typedef struct _glc_programmatic_surface_t {
    glc_surface_t base;
    
-   glc_programmatic_surface_type_t type;
-   glc_programmatic_attributes_t attributes;
    glc_texture_t texture;
  } glc_programmatic_surface_t;
  
--- 239,278 ----
  };
  
! #define GLC_COLOR_RANGE_UPDATE_TEXTURE_MASK (1L << 0)
! #define GLC_COLOR_RANGE_UPDATE_FILTER_MASK  (1L << 1)
! #define GLC_COLOR_RANGE_UPDATE_EXTEND_MASK  (1L << 2)
! #define GLC_COLOR_RANGE_UPDATE_ALL_MASK     ((1L << 3) - 1)
  
! struct _glc_color_range {
!   unsigned char *data;
!   unsigned int size;
!   unsigned int texture;
!   glc_filter_t filter;
!   glc_extend_t extend;
!   unsigned long update_mask;
!   unsigned int ref_count;
! };
  
  typedef struct _glc_programmatic_surface_t {
    glc_surface_t base;
    
    glc_texture_t texture;
+   
+   glc_programmatic_surface_type_t type;
+   union {
+     struct {
+       glc_color_t color;
+     } solid;
+     struct {
+       glc_point_fixed_t start;
+       glc_point_fixed_t stop;
+       glc_color_range_t *color_range;
+     } linear;
+     struct {
+       glc_point_fixed_t center;
+       glc_distance_fixed_t radius;
+       glc_color_range_t *color_range;
+     } radial;
+   } u;
  } glc_programmatic_surface_t;
  
***************
*** 328,331 ****
--- 338,347 ----
                        glc_extension_map *extensions_map);
  
+ extern glc_bool_t __internal_linkage
+ glc_int_is_power_of_two (int value);
+ 
+ extern void __internal_linkage
+ glc_int_to_power_of_two (int *value);
+ 
  extern glc_texture_t *__internal_linkage
  glc_texture_generate (int width,
***************
*** 405,409 ****
  
  extern void __internal_linkage
! glc_surface_disable_program (glc_surface_t *surface);
  
  extern void __internal_linkage
--- 421,426 ----
  
  extern void __internal_linkage
! glc_surface_disable_program (glc_program_type_t type,
!                              glc_surface_t *surface);
  
  extern void __internal_linkage
***************
*** 456,460 ****
  
  extern void __internal_linkage
! glc_program_disable (glc_surface_t *dst);
  
  extern void __internal_linkage
--- 473,478 ----
  
  extern void __internal_linkage
! glc_program_disable (glc_program_type_t type,
!                      glc_surface_t *dst);
  
  extern void __internal_linkage
***************
*** 464,470 ****
  
  extern void __internal_linkage
! glc_programmatic_surface_set_parameters (glc_gl_proc_address_list_t
!                                          *proc_address,
!                                          glc_programmatic_surface_t *surface);
  
  #define MAXSHORT SHRT_MAX
--- 482,508 ----
  
  extern void __internal_linkage
! glc_programmatic_surface_bind (glc_gl_proc_address_list_t *proc_address,
!                                glc_programmatic_surface_t *surface,
!                                unsigned long feature_mask);
! 
! extern glc_surface_t *__internal_linkage
! glc_programmatic_surface_create_solid (glc_color_t *color);
! 
! extern glc_surface_t *__internal_linkage
! glc_programmatic_surface_create_linear (glc_point_fixed_t *start,
!                                         glc_point_fixed_t *stop,
!                                         glc_color_range_t *color_range);
! 
! extern glc_surface_t *__internal_linkage
! glc_programmatic_surface_create_radial (glc_point_fixed_t *start,
!                                         glc_distance_fixed_t *radius,
!                                         glc_color_range_t *color_range);
! 
! extern void __internal_linkage
! glc_color_range_bind (glc_color_range_t *color_range,
!                       unsigned long feature_mask);
! 
! extern void __internal_linkage
! glc_color_range_reference (glc_color_range_t *color_range);
  
  #define MAXSHORT SHRT_MAX
***************
*** 525,528 ****
--- 563,569 ----
  /* Avoid unnecessary PLT entries.  */
  
+ slim_hidden_proto(glc_surface_create_solid)
+ slim_hidden_proto(glc_surface_create_linear)
+ slim_hidden_proto(glc_surface_create_radial)
  slim_hidden_proto(glc_surface_set_transform)
  slim_hidden_proto(glc_surface_set_convolution)
***************
*** 549,556 ****
  slim_hidden_proto(glc_composite_tri_fan)
  slim_hidden_proto(glc_color_triangles)
! slim_hidden_proto(glc_solid_create)
! slim_hidden_proto(glc_linear_gradient_create)
! slim_hidden_proto(glc_radial_gradient_create)
!      
       
  #ifdef LIBGLC_HAS_GLX_BACKEND
--- 590,598 ----
  slim_hidden_proto(glc_composite_tri_fan)
  slim_hidden_proto(glc_color_triangles)
! slim_hidden_proto(glc_color_range_create)
! slim_hidden_proto(glc_color_range_get_data)
! slim_hidden_proto(glc_color_range_put_back_data)
! slim_hidden_proto(glc_color_range_set_filter)
! slim_hidden_proto(glc_color_range_set_extend)
       
  #ifdef LIBGLC_HAS_GLX_BACKEND
***************
*** 560,572 ****
  #include "glc_glxext.h"
  
! #define GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK    (1L << 0)
! #define GLC_GLX_FEATURE_TEXTURE_NPOT_MASK         (1L << 1)
! #define GLC_GLX_FEATURE_MULTISAMPLE_MASK          (1L << 2)
! #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK   (1L << 3)
! #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK   (1L << 4)
! #define GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK   (1L << 5)
! #define GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK (1L << 6)
! #define GLC_GLX_FEATURE_ATI_RENDER_TEXTURE_MASK   (1L << 7)
! #define GLC_GLX_FEATURE_GLX13_MASK                (1L << 8)
  
  typedef struct _glc_glx_surface glc_glx_surface_t;
--- 602,615 ----
  #include "glc_glxext.h"
  
! #define GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK       (1L << 0)
! #define GLC_GLX_FEATURE_TEXTURE_NPOT_MASK            (1L << 1)
! #define GLC_GLX_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L << 2)
! #define GLC_GLX_FEATURE_MULTISAMPLE_MASK             (1L << 3)
! #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK      (1L << 4)
! #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK      (1L << 5)
! #define GLC_GLX_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L << 6)
! #define GLC_GLX_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 7)
! #define GLC_GLX_FEATURE_ATI_RENDER_TEXTURE_MASK      (1L << 8)
! #define GLC_GLX_FEATURE_GLX13_MASK                   (1L << 9)
  
  typedef struct _glc_glx_surface glc_glx_surface_t;
***************
*** 715,725 ****
  #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_TEXTURE_NPOT_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_VERTEX_PROGRAM_MASK   (1L << 5)
! #define GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK (1L << 6)
  
  typedef struct _glc_agl_surface_t glc_agl_surface_t;
--- 758,769 ----
  #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_TEXTURE_NPOT_MASK            (1L << 2)
! #define GLC_AGL_FEATURE_TEXTURE_MIRRORED_REPEAT_MASK (1L << 3)
! #define GLC_AGL_FEATURE_MULTISAMPLE_MASK             (1L << 4)
! #define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK      (1L << 5)
! #define GLC_AGL_FEATURE_ARB_VERTEX_PROGRAM_MASK      (1L << 6)
! #define GLC_AGL_FEATURE_ARB_FRAGMENT_PROGRAM_MASK    (1L << 7)
  
  typedef struct _glc_agl_surface_t glc_agl_surface_t;





More information about the cairo-commit mailing list