[cairo-commit] cairo/src cairo-pattern.c, 1.33, 1.34 cairo.c, 1.86, 1.87 cairo.h, 1.109, 1.110

Owen Taylor commit at pdx.freedesktop.org
Fri May 6 12:00:24 PDT 2005


Committed by: otaylor

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

Modified Files:
	cairo-pattern.c cairo.c cairo.h 
Log Message:
2005-05-05  Owen Taylor  <otaylor at redhat.com>

        * src/cairo.[ch] doc/public/cairo-sections.txt: Add
        cairo_paint_with_alpha().

        * src/cairo-pattern.c (_cairo_pattern_acquire_surfaces): Fix
        segfault when mask == NULL.

        * test/mask.c test/mask-ref.png: Add testing of cairo_paint_with_alpha().

        * test/coverage.c test/coverage-ref.png: Remove ... it's not testing
        anything that mask doesn't test better.


Index: cairo-pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pattern.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- cairo-pattern.c	2 May 2005 20:39:33 -0000	1.33
+++ cairo-pattern.c	6 May 2005 19:00:22 -0000	1.34
@@ -1238,8 +1238,8 @@
      * information in mask, so this will need to change when we
      * support RENDER-style 4-channel masks. */
     if (src->type == CAIRO_PATTERN_SOLID &&
-	mask->type == CAIRO_PATTERN_SOLID)
-    {
+	mask && mask->type == CAIRO_PATTERN_SOLID)
+      {
 	cairo_color_t combined;
 	cairo_solid_pattern_t *src_solid = (cairo_solid_pattern_t *) src;
 	cairo_solid_pattern_t *mask_solid = (cairo_solid_pattern_t *) mask;

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- cairo.c	3 May 2005 15:33:32 -0000	1.86
+++ cairo.c	6 May 2005 19:00:22 -0000	1.87
@@ -1531,6 +1531,37 @@
 }
 
 /**
+ * cairo_paint_with_alpha:
+ * @cr: a cairo context
+ * @alpha: alpha value, between 0 (transparent) and 1 (opaque)
+ * 
+ * A drawing operator that paints the current source everywhere within
+ * the current clip region using a mask of constant alpha value
+ * @alpha. The effect is similar to cairo_paint(), but the drawing
+ * is faded out using the alpha value.
+ **/
+void
+cairo_paint_with_alpha (cairo_t *cr,
+			double   alpha)
+{
+    cairo_color_t color;
+    cairo_pattern_union_t pattern;
+  
+    CAIRO_CHECK_SANITY (cr);
+    if (cr->status)
+	return;
+
+    _cairo_color_init_rgba (&color, 1., 1., 1., alpha);
+    _cairo_pattern_init_solid (&pattern.solid, &color);
+
+    cr->status = _cairo_gstate_mask (cr->gstate, &pattern.base);
+
+    _cairo_pattern_fini (&pattern.base);
+
+    CAIRO_CHECK_SANITY (cr);
+}
+
+/**
  * cairo_mask:
  * @cr: a cairo context
  * @pattern: a #cairo_pattern_t

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- cairo.h	3 May 2005 15:33:32 -0000	1.109
+++ cairo.h	6 May 2005 19:00:22 -0000	1.110
@@ -491,6 +491,10 @@
 cairo_paint (cairo_t *cr);
 
 void
+cairo_paint_with_alpha (cairo_t *cr,
+			double   alpha);
+
+void
 cairo_mask (cairo_t         *cr,
 	    cairo_pattern_t *pattern);
 




More information about the cairo-commit mailing list