[cairo-commit] glitz/src glitz.c, 1.24, 1.25 glitz.h, 1.21, 1.22 glitz_agl_extension.c, 1.10, 1.11 glitz_agl_info.c, 1.12, 1.13 glitz_compose.c, 1.6, 1.7 glitz_gl.h, 1.9, 1.10 glitz_glx_context.c, 1.13, 1.14 glitz_glx_extension.c, 1.13, 1.14 glitz_glx_info.c, 1.18, 1.19 glitzint.h, 1.27, 1.28

David Reveman commit at pdx.freedesktop.org
Mon Sep 13 10:50:40 PDT 2004


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory gabe:/tmp/cvs-serv7227/src

Modified Files:
	glitz.c glitz.h glitz_agl_extension.c glitz_agl_info.c 
	glitz_compose.c glitz_gl.h glitz_glx_context.c 
	glitz_glx_extension.c glitz_glx_info.c glitzint.h 
Log Message:
Added support for component alpha in one single pass when using a solid color as source

Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** glitz.c	11 Sep 2004 00:16:23 -0000	1.24
--- glitz.c	13 Sep 2004 17:50:38 -0000	1.25
***************
*** 77,81 ****
      return;
    
!   glitz_composite_op_init (&comp_op, src, mask, dst);
    if (comp_op.type == GLITZ_COMBINE_TYPE_NA) {
      glitz_surface_status_add (dst, GLITZ_STATUS_NOT_SUPPORTED_MASK);
--- 77,81 ----
      return;
    
!   glitz_composite_op_init (&comp_op, op, src, mask, dst);
    if (comp_op.type == GLITZ_COMBINE_TYPE_NA) {
      glitz_surface_status_add (dst, GLITZ_STATUS_NOT_SUPPORTED_MASK);
***************
*** 133,137 ****
      x_src = y_src = 0;
  
!     glitz_composite_op_init (&comp_op, src, mask, dst);
      if (comp_op.type == GLITZ_COMBINE_TYPE_NA) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NOT_SUPPORTED_MASK);
--- 133,137 ----
      x_src = y_src = 0;
  
!     glitz_composite_op_init (&comp_op, op, src, mask, dst);
      if (comp_op.type == GLITZ_COMBINE_TYPE_NA) {
        glitz_surface_status_add (dst, GLITZ_STATUS_NOT_SUPPORTED_MASK);
***************
*** 174,178 ****
      textures[0].transform = 0;
      texture_nr = 0;
!     
      glitz_texture_bind (gl, mtexture);
  
--- 174,178 ----
      textures[0].transform = 0;
      texture_nr = 0;
! 
      glitz_texture_bind (gl, mtexture);
  
***************
*** 255,260 ****
    }
  
-   glitz_set_operator (gl, op);
- 
    gl->scissor (rect.x1,
                 dst->height - rect.y2,
--- 255,258 ----
***************
*** 273,276 ****
--- 271,275 ----
  
      gl->enable (GLITZ_GL_STENCIL_TEST);
+     gl->disable (GLITZ_GL_BLEND);
      gl->color_mask (GLITZ_GL_FALSE, GLITZ_GL_FALSE, GLITZ_GL_FALSE,
                      GLITZ_GL_FALSE);
***************
*** 300,305 ****
      passes = 1;
  
!   if (comp_op.component_alpha)
!     passes *= comp_op.component_alpha;
  
    alpha_mask = comp_op.alpha_mask;
--- 299,304 ----
      passes = 1;
  
!   if (comp_op.per_component)
!     passes *= comp_op.per_component;
  
    alpha_mask = comp_op.alpha_mask;
***************
*** 309,314 ****
      
      if (dst->indirect) {
!       if (comp_op.component_alpha)
!         sample = i / comp_op.component_alpha;
        else
          sample = i;
--- 308,313 ----
      
      if (dst->indirect) {
!       if (comp_op.per_component)
!         sample = i / comp_op.per_component;
        else
          sample = i;
***************
*** 321,326 ****
        weight = 0xffff;
      
!     if (comp_op.component_alpha) {
!       switch (i % comp_op.component_alpha) {
        case 0:
          SET_COLOR (comp_op.alpha_mask,
--- 320,325 ----
        weight = 0xffff;
      
!     if (comp_op.per_component) {
!       switch (i % comp_op.per_component) {
        case 0:
          SET_COLOR (comp_op.alpha_mask,
***************
*** 339,344 ****
                     0, SHORT_MULT (weight, alpha_mask.green), 0, 0);
          gl->color_mask (GLITZ_GL_FALSE, GLITZ_GL_TRUE, GLITZ_GL_FALSE,
!                         (comp_op.component_alpha == 4)? GLITZ_GL_FALSE:
!                         GLITZ_GL_TRUE);
          break;
        case 3:
--- 338,342 ----
                     0, SHORT_MULT (weight, alpha_mask.green), 0, 0);
          gl->color_mask (GLITZ_GL_FALSE, GLITZ_GL_TRUE, GLITZ_GL_FALSE,
!                         GLITZ_GL_FALSE);
          break;
        case 3:
***************
*** 350,357 ****
        }
      } else {
!       SET_COLOR (comp_op.alpha_mask, 0, 0, 0,
                   SHORT_MULT (weight, alpha_mask.alpha));
      }
!     
      glitz_composite_enable (&comp_op);
      
--- 348,358 ----
        }
      } else {
!       SET_COLOR (comp_op.alpha_mask,
!                  SHORT_MULT (weight, alpha_mask.red),
!                  SHORT_MULT (weight, alpha_mask.green),
!                  SHORT_MULT (weight, alpha_mask.blue),
                   SHORT_MULT (weight, alpha_mask.alpha));
      }
!   
      glitz_composite_enable (&comp_op);
      
***************
*** 366,375 ****
      gl->disable (GLITZ_GL_STENCIL_TEST);
    
!   if (comp_op.component_alpha)
      gl->color_mask (GLITZ_GL_TRUE, GLITZ_GL_TRUE, GLITZ_GL_TRUE,
                      GLITZ_GL_TRUE);
    
    glitz_composite_disable (&comp_op);
!   
    for (i = texture_nr; i >= 0; i--) {
      glitz_texture_unbind (gl, textures[i].texture);
--- 367,376 ----
      gl->disable (GLITZ_GL_STENCIL_TEST);
    
!   if (comp_op.per_component)
      gl->color_mask (GLITZ_GL_TRUE, GLITZ_GL_TRUE, GLITZ_GL_TRUE,
                      GLITZ_GL_TRUE);
    
    glitz_composite_disable (&comp_op);
! 
    for (i = texture_nr; i >= 0; i--) {
      glitz_texture_unbind (gl, textures[i].texture);

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** glitz.h	11 Sep 2004 14:52:49 -0000	1.21
--- glitz.h	13 Sep 2004 17:50:38 -0000	1.22
***************
*** 108,112 ****
  #define GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK     (1L << 11)
  #define GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK      (1L << 12)
! #define GLITZ_FEATURE_COMPONENT_ALPHA_MASK          (1L << 13)
  
  typedef enum {
--- 108,112 ----
  #define GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK     (1L << 11)
  #define GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK      (1L << 12)
! #define GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK  (1L << 13)
  
  typedef enum {

Index: glitz_agl_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_extension.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glitz_agl_extension.c	9 Sep 2004 09:50:26 -0000	1.10
--- glitz_agl_extension.c	13 Sep 2004 17:50:38 -0000	1.11
***************
*** 142,146 ****
        glGetIntegerv (GLITZ_GL_MAX_TEXTURE_UNITS, &max_texture_units);
        if (max_texture_units >= 3)
!         thread_info->feature_mask |= GLITZ_FEATURE_COMPONENT_ALPHA_MASK;
      }
      
--- 142,147 ----
        glGetIntegerv (GLITZ_GL_MAX_TEXTURE_UNITS, &max_texture_units);
        if (max_texture_units >= 3)
!         thread_info->feature_mask |=
!           GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
      }
      

Index: glitz_agl_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_info.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** glitz_agl_info.c	9 Sep 2004 09:50:26 -0000	1.12
--- glitz_agl_info.c	13 Sep 2004 17:50:38 -0000	1.13
***************
*** 50,53 ****
--- 50,54 ----
    (glitz_gl_scissor_t) glScissor,
    (glitz_gl_blend_func_t) glBlendFunc,
+   (glitz_gl_blend_color_t) glBlendColor,
    (glitz_gl_clear_t) glClear,
    (glitz_gl_clear_color_t) glClearColor,

Index: glitz_compose.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_compose.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glitz_compose.c	9 Sep 2004 23:09:03 -0000	1.6
--- glitz_compose.c	13 Sep 2004 17:50:38 -0000	1.7
***************
*** 33,36 ****
--- 33,38 ----
  _glitz_combine_argb_argb (glitz_composite_op_t *op)
  {
+   glitz_set_operator (op->gl, op->render_op);
+   
    op->gl->active_texture (GLITZ_GL_TEXTURE0);
    op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
***************
*** 66,122 ****
  
  static void
! _glitz_combine_x_argbc (glitz_composite_op_t *op)
  {
!   op->gl->active_texture (GLITZ_GL_TEXTURE0);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_COMBINE);
      
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                      GLITZ_GL_INTERPOLATE);
  
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                      GLITZ_GL_TEXTURE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE2_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND2_RGB,
!                      GLITZ_GL_SRC_ALPHA);
  
!   /* we don't care about the alpha channel, so lets do something (simple?) */
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                      GLITZ_GL_REPLACE);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                      GLITZ_GL_SRC_ALPHA);
  
      
!   op->gl->active_texture (GLITZ_GL_TEXTURE1);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_COMBINE);
    
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                      GLITZ_GL_DOT3_RGBA);
      
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                      GLITZ_GL_PREVIOUS);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                      GLITZ_GL_PRIMARY_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                      GLITZ_GL_SRC_COLOR);
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                      GLITZ_GL_SRC_COLOR);
! }
! 
! static void
! _glitz_combine_argb_argbc (glitz_composite_op_t *op)
! {
!   if (op->count == 0) {
!     _glitz_combine_x_argbc (op);
      
      op->gl->active_texture (GLITZ_GL_TEXTURE2);
--- 68,120 ----
  
  static void
! _glitz_combine_argb_argbc (glitz_composite_op_t *op)
  {
!   if (op->count == 0) {
!     glitz_set_operator (op->gl, op->render_op);
      
!     op->gl->active_texture (GLITZ_GL_TEXTURE0);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_COMBINE);
!     
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                        GLITZ_GL_INTERPOLATE);
  
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                        GLITZ_GL_TEXTURE);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                        GLITZ_GL_PRIMARY_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE2_RGB,
!                        GLITZ_GL_PRIMARY_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                        GLITZ_GL_SRC_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                        GLITZ_GL_SRC_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND2_RGB,
!                        GLITZ_GL_SRC_ALPHA);
  
!     /* we don't care about the alpha channel, so lets do something (simple?) */
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                        GLITZ_GL_REPLACE);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                        GLITZ_GL_PRIMARY_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                        GLITZ_GL_SRC_ALPHA);
  
      
!     op->gl->active_texture (GLITZ_GL_TEXTURE1);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_COMBINE);
    
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                        GLITZ_GL_DOT3_RGBA);
      
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                        GLITZ_GL_PREVIOUS);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                        GLITZ_GL_PRIMARY_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                        GLITZ_GL_SRC_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                        GLITZ_GL_SRC_COLOR);
      
      op->gl->active_texture (GLITZ_GL_TEXTURE2);
***************
*** 149,152 ****
--- 147,152 ----
  _glitz_combine_argb_solid (glitz_composite_op_t *op)
  {
+   glitz_set_operator (op->gl, op->render_op);
+   
    if (op->alpha_mask.alpha != 0xffff) {
      op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
***************
*** 167,170 ****
--- 167,173 ----
  {
    unsigned short alpha;
+ 
+   if (op->count == 0)
+     glitz_set_operator (op->gl, op->render_op);
    
    if (op->alpha_mask.red)
***************
*** 191,196 ****
  _glitz_combine_argbf_solid (glitz_composite_op_t *op)
  {
!   if (op->count == 0)
      glitz_filter_enable (op->src, op);
  
    op->gl->color_4us (0x0, 0x0, 0x0, op->alpha_mask.alpha);
--- 194,201 ----
  _glitz_combine_argbf_solid (glitz_composite_op_t *op)
  {
!   if (op->count == 0) {
!     glitz_set_operator (op->gl, op->render_op);
      glitz_filter_enable (op->src, op);
+   }
  
    op->gl->color_4us (0x0, 0x0, 0x0, op->alpha_mask.alpha);
***************
*** 200,205 ****
  _glitz_combine_argbf_argbc (glitz_composite_op_t *op)
  {
!   if (op->count == 0)
      glitz_filter_enable (op->src, op);
    
    op->gl->color_4us (op->alpha_mask.red,
--- 205,212 ----
  _glitz_combine_argbf_argbc (glitz_composite_op_t *op)
  {
!   if (op->count == 0) {
!     glitz_set_operator (op->gl, op->render_op);
      glitz_filter_enable (op->src, op);
+   }
    
    op->gl->color_4us (op->alpha_mask.red,
***************
*** 214,219 ****
    unsigned short alpha;
    
!   if (op->count == 0)
      glitz_filter_enable (op->src, op);
    
    if (op->alpha_mask.red)
--- 221,228 ----
    unsigned short alpha;
    
!   if (op->count == 0) {
!     glitz_set_operator (op->gl, op->render_op);
      glitz_filter_enable (op->src, op);
+   }
    
    if (op->alpha_mask.red)
***************
*** 232,235 ****
--- 241,246 ----
  _glitz_combine_solid_solid (glitz_composite_op_t *op)
  {
+   glitz_set_operator (op->gl, op->render_op);
+   
    op->gl->color_4us (SHORT_MULT (op->solid->red, op->alpha_mask.alpha),
                       SHORT_MULT (op->solid->green, op->alpha_mask.alpha),
***************
*** 240,244 ****
  static void
  _glitz_combine_solid_argb (glitz_composite_op_t *op)
! { 
    op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
                       GLITZ_GL_COMBINE);
--- 251,257 ----
  static void
  _glitz_combine_solid_argb (glitz_composite_op_t *op)
! {
!   glitz_set_operator (op->gl, op->render_op);
!   
    op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
                       GLITZ_GL_COMBINE);
***************
*** 265,363 ****
    op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_ALPHA,
                       GLITZ_GL_SRC_ALPHA);
!                        
!   op->gl->color_4us (op->solid->red,
!                      op->solid->green,
!                      op->solid->blue,
!                      op->solid->alpha);
  }
  
  static void
  _glitz_combine_solid_argbc (glitz_composite_op_t *op)
  {
!   if (op->count == 0) {
!     glitz_gl_float_t color[4];
!     
!     _glitz_combine_x_argbc (op);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE2);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_COMBINE);
!   
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_RGB,
!                        GLITZ_GL_MODULATE);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_RGB,
!                        GLITZ_GL_PREVIOUS);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_RGB,
!                        GLITZ_GL_CONSTANT);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_RGB,
!                        GLITZ_GL_SRC_COLOR);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_RGB,
!                        GLITZ_GL_SRC_COLOR);
  
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_COMBINE_ALPHA,
!                        GLITZ_GL_MODULATE);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE0_ALPHA,
!                        GLITZ_GL_PREVIOUS);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_SOURCE1_ALPHA,
!                        GLITZ_GL_CONSTANT);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND0_ALPHA,
!                        GLITZ_GL_SRC_ALPHA);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_ALPHA,
!                        GLITZ_GL_SRC_ALPHA);
  
!     color[0] = op->solid->red / 65536.0f;
!     color[1] = op->solid->green / 65536.0f;
!     color[2] = op->solid->blue / 65536.0f;
!     color[3] = op->solid->alpha / 65536.0f;
!     
!     op->gl->tex_env_fv (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_COLOR,
!                         color);
!   }
!     
!   if (op->alpha_mask.red) {
!     op->gl->color_4f (1.0f, 0.5f, 0.5f, 0.5f);
!   } else if (op->alpha_mask.green) {
!     op->gl->color_4f (0.5f, 1.0f, 0.5f, 0.5f);
!   } else if (op->alpha_mask.blue) {
!     op->gl->color_4f (0.5f, 0.5f, 1.0f, 0.5f);
!   } else {
!     static glitz_gl_float_t color[] = { 0.0f, 0.0f, 0.0f, 0.0f };
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE0);
!     op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                        GLITZ_GL_MODULATE);
!     op->gl->color_4us (op->solid->red,
!                        op->solid->green,
!                        op->solid->blue,
!                        op->solid->alpha);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE1);
!     glitz_texture_unbind (op->gl, &op->src->texture);
!     
!     op->gl->active_texture (GLITZ_GL_TEXTURE2);
!     op->gl->tex_env_fv (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_COLOR,
!                         color);
!     glitz_texture_unbind (op->gl, &op->src->texture);
!   }
  }
  
  static void
  _glitz_combine_solid_solidc (glitz_composite_op_t *op)
  {
!   unsigned short alpha;
!   
!   if (op->alpha_mask.red)
!     alpha = op->alpha_mask.red;
!   else if (op->alpha_mask.green)
!     alpha = op->alpha_mask.green;
!   else if (op->alpha_mask.blue)
!     alpha = op->alpha_mask.blue;
!   else
!     alpha = op->alpha_mask.alpha;
!   
!   op->gl->color_4us (SHORT_MULT (op->solid->red, alpha),
!                      SHORT_MULT (op->solid->green, alpha),
!                      SHORT_MULT (op->solid->blue, alpha),
!                      SHORT_MULT (op->solid->alpha, alpha));
  }
  
--- 278,329 ----
    op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_OPERAND1_ALPHA,
                       GLITZ_GL_SRC_ALPHA);
! 
!   op->gl->color_4us (SHORT_MULT (op->solid->red, op->alpha_mask.alpha),
!                      SHORT_MULT (op->solid->green, op->alpha_mask.alpha),
!                      SHORT_MULT (op->solid->blue, op->alpha_mask.alpha),
!                      SHORT_MULT (op->solid->alpha, op->alpha_mask.alpha));
  }
  
+ /* This only works with the OVER operator. */
  static void
  _glitz_combine_solid_argbc (glitz_composite_op_t *op)
  {
!   glitz_color_t solid;
  
!   solid.red = SHORT_MULT (op->solid->red, op->alpha_mask.alpha);
!   solid.green = SHORT_MULT (op->solid->green, op->alpha_mask.alpha);
!   solid.blue = SHORT_MULT (op->solid->blue, op->alpha_mask.alpha);
!   solid.alpha = SHORT_MULT (op->solid->alpha, op->alpha_mask.alpha);
  
!   op->gl->enable (GLITZ_GL_BLEND);
!   op->gl->blend_func (GLITZ_GL_CONSTANT_COLOR, GLITZ_GL_ONE_MINUS_SRC_COLOR);
!   op->gl->blend_color ((glitz_gl_clampf_t) solid.red / solid.alpha,
!                        (glitz_gl_clampf_t) solid.green / solid.alpha,
!                        (glitz_gl_clampf_t) solid.blue / solid.alpha,
!                        1.0f);
!   
!   op->gl->tex_env_f (GLITZ_GL_TEXTURE_ENV, GLITZ_GL_TEXTURE_ENV_MODE,
!                      GLITZ_GL_MODULATE);
!   op->gl->color_4us (solid.alpha,
!                      solid.alpha,
!                      solid.alpha,
!                      solid.alpha);
  }
  
+ /* This only works with the OVER operator. */
  static void
  _glitz_combine_solid_solidc (glitz_composite_op_t *op)
  {
!   op->gl->enable (GLITZ_GL_BLEND);
!   op->gl->blend_func (GLITZ_GL_CONSTANT_COLOR, GLITZ_GL_ONE_MINUS_SRC_COLOR);
!   op->gl->blend_color ((glitz_gl_clampf_t) op->solid->red / op->solid->alpha,
!                        (glitz_gl_clampf_t) op->solid->green / op->solid->alpha,
!                        (glitz_gl_clampf_t) op->solid->blue / op->solid->alpha,
!                        1.0f);
! 
!   op->gl->color_4us (SHORT_MULT (op->alpha_mask.red, op->solid->alpha),
!                      SHORT_MULT (op->alpha_mask.green, op->solid->alpha),
!                      SHORT_MULT (op->alpha_mask.blue, op->solid->alpha),
!                      SHORT_MULT (op->alpha_mask.alpha, op->solid->alpha));
  }
  
***************
*** 395,409 ****
      { GLITZ_COMBINE_TYPE_SOLID,        _glitz_combine_solid_solid,  0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_ARGB,   _glitz_combine_solid_argb,   1, 0 },
!     { GLITZ_COMBINE_TYPE_SOLID_ARGBC,  _glitz_combine_solid_argbc,  3, 0 },
      { GLITZ_COMBINE_TYPE_NA,           NULL,                        0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_SOLID,  _glitz_combine_solid_solid,  0, 0 },
!     { GLITZ_COMBINE_TYPE_ARGBF_SOLIDC, _glitz_combine_solid_solidc, 1, 0 }
    }, {
      { GLITZ_COMBINE_TYPE_SOLID,        _glitz_combine_solid_solid,  0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_ARGB,   _glitz_combine_solid_argb,   1, 0 },
!     { GLITZ_COMBINE_TYPE_SOLID_ARGBC,  _glitz_combine_solid_argbc,  3, 0 },
      { GLITZ_COMBINE_TYPE_NA,           NULL,                        0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_SOLID,  _glitz_combine_solid_solid,  0, 0 },
!     { GLITZ_COMBINE_TYPE_ARGBF_SOLIDC, _glitz_combine_solid_solidc, 1, 0 }
    }
  };
--- 361,375 ----
      { GLITZ_COMBINE_TYPE_SOLID,        _glitz_combine_solid_solid,  0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_ARGB,   _glitz_combine_solid_argb,   1, 0 },
!     { GLITZ_COMBINE_TYPE_SOLID_ARGBC,  _glitz_combine_solid_argbc,  1, 0 },
      { GLITZ_COMBINE_TYPE_NA,           NULL,                        0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_SOLID,  _glitz_combine_solid_solid,  0, 0 },
!     { GLITZ_COMBINE_TYPE_SOLID_SOLIDC, _glitz_combine_solid_solidc, 1, 0 }
    }, {
      { GLITZ_COMBINE_TYPE_SOLID,        _glitz_combine_solid_solid,  0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_ARGB,   _glitz_combine_solid_argb,   1, 0 },
!     { GLITZ_COMBINE_TYPE_SOLID_ARGBC,  _glitz_combine_solid_argbc,  1, 0 },
      { GLITZ_COMBINE_TYPE_NA,           NULL,                        0, 0 },
      { GLITZ_COMBINE_TYPE_SOLID_SOLID,  _glitz_combine_solid_solid,  0, 0 },
!     { GLITZ_COMBINE_TYPE_SOLID_SOLIDC, _glitz_combine_solid_solidc, 1, 0 }
    }
  };
***************
*** 452,457 ****
      
      } else if (SURFACE_COMPONENT_ALPHA (surface)) {
!       if (feature_mask & GLITZ_FEATURE_COMPONENT_ALPHA_MASK)
!         return GLITZ_SURFACE_TYPE_ARGBC;
      } else
        return GLITZ_SURFACE_TYPE_ARGB;
--- 418,422 ----
      
      } else if (SURFACE_COMPONENT_ALPHA (surface)) {
!       return GLITZ_SURFACE_TYPE_ARGBC;
      } else
        return GLITZ_SURFACE_TYPE_ARGB;
***************
*** 467,470 ****
--- 432,436 ----
  void
  glitz_composite_op_init (glitz_composite_op_t *op,
+                          glitz_operator_t render_op,
                           glitz_surface_t *src,
                           glitz_surface_t *mask,
***************
*** 475,478 ****
--- 441,445 ----
    glitz_combine_t *combine;
  
+   op->render_op = render_op;
    op->type = GLITZ_COMBINE_TYPE_NA;
    op->combine = NULL;
***************
*** 484,488 ****
    op->count = 0;
    op->solid = NULL;
!   op->component_alpha = GLITZ_COMPONENT_ALPHA_NONE;
    op->fp = 0;
  
--- 451,455 ----
    op->count = 0;
    op->solid = NULL;
!   op->per_component = 0;
    op->fp = 0;
  
***************
*** 498,501 ****
--- 465,481 ----
      return;
  
+   if (src_type == GLITZ_SURFACE_TYPE_SOLIDC)
+     src_type = GLITZ_SURFACE_TYPE_SOLID;
+ 
+   /* We can't do solid IN argbc OP dest, unless OP is OVER.
+      But we can do argb IN argbc OP dest, so lets just not use the
+      source as a solid color if this is the case. I need to figure out
+      a better way to handle special cases like this. */
+   if (src_type == GLITZ_SURFACE_TYPE_SOLID &&
+       (mask_type == GLITZ_SURFACE_TYPE_SOLIDC ||
+        mask_type == GLITZ_SURFACE_TYPE_ARGBC) &&
+       render_op != GLITZ_OPERATOR_OVER)
+     src_type = GLITZ_SURFACE_TYPE_ARGB;
+     
    combine = &_glitz_combine_map[src_type][mask_type];
    if (combine->type == GLITZ_COMBINE_TYPE_NA) {
***************
*** 503,508 ****
      
      return;
!   }
! 
    if (src_type == GLITZ_SURFACE_TYPE_SOLID) {
      glitz_surface_ensure_solid (src);
--- 483,488 ----
      
      return;
!   } 
!   
    if (src_type == GLITZ_SURFACE_TYPE_SOLID) {
      glitz_surface_ensure_solid (src);
***************
*** 511,516 ****
    }
    
!   if (mask_type == GLITZ_SURFACE_TYPE_SOLID ||
!       mask_type == GLITZ_SURFACE_TYPE_SOLIDC) {
      glitz_surface_ensure_solid (mask);
      op->alpha_mask = mask->solid;
--- 491,500 ----
    }
    
!   if (mask_type == GLITZ_SURFACE_TYPE_SOLID) {
!     glitz_surface_ensure_solid (mask);
!     op->alpha_mask = mask->solid;
!     op->mask = NULL;
!     op->combine = combine;
!   } else if (mask_type == GLITZ_SURFACE_TYPE_SOLIDC) {
      glitz_surface_ensure_solid (mask);
      op->alpha_mask = mask->solid;
***************
*** 518,546 ****
      op->combine = combine;
      
!     if (mask_type == GLITZ_SURFACE_TYPE_SOLIDC) {
!       if (mask->format->alpha_size)
!         op->component_alpha = GLITZ_COMPONENT_ALPHA_ARGB;
!       else
!         op->component_alpha = GLITZ_COMPONENT_ALPHA_RGB;
!     }
    } else if (mask_type != GLITZ_SURFACE_TYPE_NULL) {
!     if (dst->backend->feature_mask & GLITZ_FEATURE_TEXTURE_ENV_COMBINE_MASK) {
!       if (mask_type == GLITZ_SURFACE_TYPE_ARGBC) {
!         if (mask->format->alpha_size)
!           op->component_alpha = GLITZ_COMPONENT_ALPHA_ARGB;
!         else
!           op->component_alpha = GLITZ_COMPONENT_ALPHA_RGB;
!       }
!       
!       if (op->src) {
!         if (dst->backend->feature_mask & GLITZ_FEATURE_MULTITEXTURE_MASK) {
!           op->combine = combine;
!         } else if (!op->component_alpha)
!           op->type = GLITZ_COMBINE_TYPE_INTERMEDIATE; 
!       } else
          op->combine = combine;
      }
    } else
      op->combine = combine;
    
    if (op->combine == combine) {
--- 502,535 ----
      op->combine = combine;
      
!     if (op->src)
!       op->per_component = 4;
!     
    } else if (mask_type != GLITZ_SURFACE_TYPE_NULL) {
!     if (mask_type == GLITZ_SURFACE_TYPE_ARGBC) {
!       if (op->src)
!         op->per_component = 4;
!       else
          op->combine = combine;
      }
+ 
+     if (dst->backend->feature_mask & GLITZ_FEATURE_TEXTURE_ENV_COMBINE_MASK)
+       op->combine = combine;
    } else
      op->combine = combine;
+ 
+   if (!(dst->backend->feature_mask & GLITZ_FEATURE_MULTITEXTURE_MASK)) {
+     if (op->src && op->mask) {
+       if (!op->per_component) {
+         op->type = GLITZ_COMBINE_TYPE_INTERMEDIATE;
+         return;
+       } else
+         op->combine = NULL;
+     }
+   }
+ 
+   if (op->per_component &&
+       (!(dst->backend->feature_mask &
+          GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK)))
+     op->combine = NULL;
    
    if (op->combine == combine) {

Index: glitz_gl.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_gl.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glitz_gl.h	9 Sep 2004 09:50:26 -0000	1.9
--- glitz_gl.h	13 Sep 2004 17:50:38 -0000	1.10
***************
*** 202,205 ****
--- 202,206 ----
  #define GLITZ_GL_ZERO                0x0000
  #define GLITZ_GL_ONE                 0x0001
+ #define GLITZ_GL_ONE_MINUS_SRC_COLOR 0x0301
  #define GLITZ_GL_SRC_ALPHA           0x0302
  #define GLITZ_GL_ONE_MINUS_SRC_ALPHA 0x0303
***************
*** 207,210 ****
--- 208,212 ----
  #define GLITZ_GL_ONE_MINUS_DST_ALPHA 0x0305
  #define GLITZ_GL_SRC_ALPHA_SATURATE  0x0308
+ #define GLITZ_GL_CONSTANT_COLOR      0x8001
  
  #define GLITZ_GL_PACK_ALIGNMENT      0x0D05
***************
*** 300,303 ****
--- 302,308 ----
  typedef glitz_gl_void_t (* glitz_gl_blend_func_t)
       (glitz_gl_enum_t sfactor, glitz_gl_enum_t dfactor);
+ typedef glitz_gl_void_t (* glitz_gl_blend_color_t)
+      (glitz_gl_clampf_t red, glitz_gl_clampf_t green, glitz_gl_clampf_t blue,
+       glitz_gl_clampf_t alpha);
  typedef glitz_gl_void_t (* glitz_gl_clear_t)
       (glitz_gl_bitfield_t mask);

Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_context.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz_glx_context.c	7 Sep 2004 14:28:21 -0000	1.13
--- glitz_glx_context.c	13 Sep 2004 17:50:38 -0000	1.14
***************
*** 296,300 ****
  
    context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_COMPONENT_ALPHA_MASK;
    context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
    context->backend.feature_mask &= ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
--- 296,300 ----
  
    context->backend.feature_mask &= ~GLITZ_FEATURE_MULTITEXTURE_MASK;
!   context->backend.feature_mask &= ~GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
    context->backend.feature_mask &= ~GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK;
    context->backend.feature_mask &= ~GLITZ_FEATURE_VERTEX_BUFFER_OBJECT_MASK;
***************
*** 304,309 ****
      context->backend.feature_mask |= GLITZ_FEATURE_MULTITEXTURE_MASK;
  
!     if (screen_info->feature_mask & GLITZ_FEATURE_COMPONENT_ALPHA_MASK)
!       context->backend.feature_mask |= GLITZ_FEATURE_COMPONENT_ALPHA_MASK;
      
      if (context->backend.gl.gen_programs &&
--- 304,310 ----
      context->backend.feature_mask |= GLITZ_FEATURE_MULTITEXTURE_MASK;
  
!     if (screen_info->feature_mask & GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK)
!       context->backend.feature_mask |=
!         GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
      
      if (context->backend.gl.gen_programs &&

Index: glitz_glx_extension.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_extension.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** glitz_glx_extension.c	9 Sep 2004 09:50:26 -0000	1.13
--- glitz_glx_extension.c	13 Sep 2004 17:50:38 -0000	1.14
***************
*** 165,169 ****
        glGetIntegerv (GLITZ_GL_MAX_TEXTURE_UNITS, &max_texture_units);
        if (max_texture_units >= 3)
!         screen_info->feature_mask |= GLITZ_FEATURE_COMPONENT_ALPHA_MASK;
      }
          
--- 165,170 ----
        glGetIntegerv (GLITZ_GL_MAX_TEXTURE_UNITS, &max_texture_units);
        if (max_texture_units >= 3)
!         screen_info->feature_mask |=
!           GLITZ_FEATURE_PER_COMPONENT_RENDERING_MASK;
      }
          

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_info.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** glitz_glx_info.c	9 Sep 2004 09:50:26 -0000	1.18
--- glitz_glx_info.c	13 Sep 2004 17:50:38 -0000	1.19
***************
*** 51,54 ****
--- 51,55 ----
    (glitz_gl_scissor_t) glScissor,
    (glitz_gl_blend_func_t) glBlendFunc,
+   (glitz_gl_blend_color_t) glBlendColor,
    (glitz_gl_clear_t) glClear,
    (glitz_gl_clear_color_t) glClearColor,

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** glitzint.h	9 Sep 2004 23:09:03 -0000	1.27
--- glitzint.h	13 Sep 2004 17:50:38 -0000	1.28
***************
*** 90,93 ****
--- 90,94 ----
    glitz_gl_scissor_t scissor;
    glitz_gl_blend_func_t blend_func;
+   glitz_gl_blend_color_t blend_color;
    glitz_gl_clear_t clear;
    glitz_gl_clear_color_t clear_color;
***************
*** 446,459 ****
  } glitz_combine_t;
  
- typedef enum {
-   GLITZ_COMPONENT_ALPHA_NONE = 0,
-   GLITZ_COMPONENT_ALPHA_RGB = 3,
-   GLITZ_COMPONENT_ALPHA_ARGB = 4
- } glitz_component_alpha_type_t;
- 
  struct _glitz_composite_op_t {
    glitz_combine_type_t type;
    glitz_combine_t *combine;
    glitz_gl_proc_address_list_t *gl;
    glitz_surface_t *src;
    glitz_surface_t *mask;
--- 447,455 ----
  } glitz_combine_t;
  
  struct _glitz_composite_op_t {
    glitz_combine_type_t type;
    glitz_combine_t *combine;
    glitz_gl_proc_address_list_t *gl;
+   glitz_operator_t render_op;
    glitz_surface_t *src;
    glitz_surface_t *mask;
***************
*** 461,465 ****
    glitz_color_t *solid;
    glitz_color_t alpha_mask;
!   glitz_component_alpha_type_t component_alpha;
    glitz_gl_uint_t fp;
    int count;
--- 457,461 ----
    glitz_color_t *solid;
    glitz_color_t alpha_mask;
!   int per_component;
    glitz_gl_uint_t fp;
    int count;
***************
*** 633,636 ****
--- 629,633 ----
  extern void __internal_linkage
  glitz_composite_op_init (glitz_composite_op_t *op,
+                          glitz_operator_t render_op,
                           glitz_surface_t *src,
                           glitz_surface_t *mask,




More information about the cairo-commit mailing list