[cairo-commit] cairo/src cairo_gstate.c, 1.52, 1.53 cairo_pattern.c, 1.9, 1.10 cairoint.h, 1.65, 1.66

David Reveman commit at pdx.freedesktop.org
Fri Jun 11 06:20:20 PDT 2004


Committed by: davidr

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

Modified Files:
	cairo_gstate.c cairo_pattern.c cairoint.h 
Log Message:
Pre-multiply gradients after color interpolation

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** cairo_gstate.c	24 May 2004 09:28:05 -0000	1.52
--- cairo_gstate.c	11 Jun 2004 13:20:17 -0000	1.53
***************
*** 1265,1270 ****
  	    pattern->type = CAIRO_PATTERN_SOLID;
        
! 	    if (pattern->n_stops)
! 		pattern->color = pattern->stops->color;
  	}
      }
--- 1265,1278 ----
  	    pattern->type = CAIRO_PATTERN_SOLID;
        
! 	    if (pattern->n_stops) {
! 		cairo_color_stop_t *stop = pattern->stops;
! 		
! 		_cairo_color_set_rgb (&pattern->color,
! 				      (double) stop->color_char[0] / 0xff,
! 				      (double) stop->color_char[1] / 0xff,
! 				      (double) stop->color_char[2] / 0xff);
! 		_cairo_color_set_alpha (&pattern->color,
! 					(double) stop->color_char[3] / 0xff);
! 	    }
  	}
      }

Index: cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pattern.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** cairo_pattern.c	28 May 2004 19:37:15 -0000	1.9
--- cairo_pattern.c	11 Jun 2004 13:20:17 -0000	1.10
***************
*** 28,31 ****
--- 28,35 ----
  #include "cairoint.h"
  
+ #define MULTIPLY_COLORCOMP(c1, c2) \
+     ((unsigned char) \
+      ((((unsigned char) (c1)) * (int) ((unsigned char) (c2))) / 0xff))
+ 
  void
  _cairo_pattern_init (cairo_pattern_t *pattern)
***************
*** 248,258 ****
      stop->offset = _cairo_fixed_from_double (offset);
      stop->id = pattern->n_stops;
!     _cairo_color_init (&stop->color);
!     _cairo_color_set_rgb (&stop->color, red, green, blue);
!     _cairo_color_set_alpha (&stop->color, alpha);
!     stop->color_char[0] = stop->color.red_short / 256;
!     stop->color_char[1] = stop->color.green_short / 256;
!     stop->color_char[2] = stop->color.blue_short / 256;
!     stop->color_char[3] = stop->color.alpha_short / 256;
  
      /* sort stops in ascending order */
--- 252,260 ----
      stop->offset = _cairo_fixed_from_double (offset);
      stop->id = pattern->n_stops;
! 
!     stop->color_char[0] = red * 0xff;
!     stop->color_char[1] = green * 0xff;
!     stop->color_char[2] = blue * 0xff;
!     stop->color_char[3] = alpha * 0xff;
  
      /* sort stops in ascending order */
***************
*** 330,343 ****
      _cairo_color_set_alpha (&pattern->color, alpha);
  
!     for (i = 0; i < pattern->n_stops; i++) {
! 	cairo_color_stop_t *stop = &pattern->stops[i];
!     
! 	_cairo_color_set_alpha (&stop->color, stop->color.alpha * alpha);
! 
! 	stop->color_char[0] = stop->color.red_short / 256;
! 	stop->color_char[1] = stop->color.green_short / 256;
! 	stop->color_char[2] = stop->color.blue_short / 256;
! 	stop->color_char[3] = stop->color.alpha_short / 256;
!     }
  }
  
--- 332,338 ----
      _cairo_color_set_alpha (&pattern->color, alpha);
  
!     for (i = 0; i < pattern->n_stops; i++)
! 	pattern->stops[i].color_char[3] =
! 	    MULTIPLY_COLORCOMP (pattern->stops[i].color_char[3], alpha * 0xff);
  }
  
***************
*** 511,514 ****
--- 506,517 ----
  				 op->stops[i + 1].color_char,
  				 factor, pixel);
+ 	    
+ 	    /* multiply alpha */
+ 	    if (((unsigned char) (*pixel >> 24)) != 0xff) {
+ 		*pixel = (*pixel & 0xff000000) |
+ 		    (MULTIPLY_COLORCOMP (*pixel >> 16, *pixel >> 24) << 16) |
+ 		    (MULTIPLY_COLORCOMP (*pixel >> 8, *pixel >> 24) << 8) |
+ 		    (MULTIPLY_COLORCOMP (*pixel >> 0, *pixel >> 24) << 0);
+ 	    }
  	    break;
  	}

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** cairoint.h	28 May 2004 19:37:15 -0000	1.65
--- cairoint.h	11 Jun 2004 13:20:17 -0000	1.66
***************
*** 473,477 ****
      cairo_fixed_48_16_t scale;
      int id;
-     cairo_color_t color;
      unsigned char color_char[4];
  } cairo_color_stop_t;
--- 473,476 ----





More information about the cairo-commit mailing list