[cairo-commit] 5 commits - src/cairo-directfb-surface.c src/cairo-glitz-surface.c src/cairo.h src/cairo-pdf-surface.c src/cairo-script-surface.c util/cairo-script util/cairo-trace

Chris Wilson ickle at kemper.freedesktop.org
Tue Jul 14 11:09:28 PDT 2009


 src/cairo-directfb-surface.c               |   15 ++++
 src/cairo-glitz-surface.c                  |   80 ++++++++++++++++++------
 src/cairo-pdf-surface.c                    |   95 ++++++++++++++---------------
 src/cairo-script-surface.c                 |   18 +++++
 src/cairo.h                                |   22 +++---
 util/cairo-script/cairo-script-operators.c |   15 ++++
 util/cairo-trace/trace.c                   |   18 +++++
 7 files changed, 183 insertions(+), 80 deletions(-)

New commits:
commit 8c55ca9ebce487c5ca8b1712f8358a6361032d43
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jul 14 16:54:51 2009 +0100

    [directfb] Silence compiler warnings.
    
    Add extended blend mode to operator switch.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 1747117..f7de84c 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -287,6 +287,21 @@ _directfb_get_operator (cairo_operator_t         operator,
 	dstblend = DSBF_ONE;
 	break;
 #endif
+    case CAIRO_OPERATOR_MULTIPLY:
+    case CAIRO_OPERATOR_SCREEN:
+    case CAIRO_OPERATOR_OVERLAY:
+    case CAIRO_OPERATOR_DARKEN:
+    case CAIRO_OPERATOR_LIGHTEN:
+    case CAIRO_OPERATOR_COLOR_DODGE:
+    case CAIRO_OPERATOR_COLOR_BURN:
+    case CAIRO_OPERATOR_HARD_LIGHT:
+    case CAIRO_OPERATOR_SOFT_LIGHT:
+    case CAIRO_OPERATOR_DIFFERENCE:
+    case CAIRO_OPERATOR_EXCLUSION:
+    case CAIRO_OPERATOR_HSL_HUE:
+    case CAIRO_OPERATOR_HSL_SATURATION:
+    case CAIRO_OPERATOR_HSL_COLOR:
+    case CAIRO_OPERATOR_HSL_LUMINOSITY:
     default:
 	return FALSE;
     }
commit 8ad3fca2109f18b5125e7087b3059eb4225eec3e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jul 14 16:51:31 2009 +0100

    [glitz] Extended blend mode support
    
    Ensure that we fallback given an extended operator.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index cd0d254..8188129 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -441,10 +441,54 @@ _cairo_glitz_surface_set_matrix (cairo_glitz_surface_t *surface,
     glitz_surface_set_transform (surface->surface, &transform);
 }
 
+static cairo_bool_t
+_is_supported_operator (cairo_operator_t op)
+{
+    /* This is really just a if (op < SATURATE), but we use a switch
+     * so the compiler will warn if we ever add more operators.
+     */
+    switch (op) {
+    case CAIRO_OPERATOR_CLEAR:
+    case CAIRO_OPERATOR_SOURCE:
+    case CAIRO_OPERATOR_OVER:
+    case CAIRO_OPERATOR_IN:
+    case CAIRO_OPERATOR_OUT:
+    case CAIRO_OPERATOR_ATOP:
+    case CAIRO_OPERATOR_DEST:
+    case CAIRO_OPERATOR_DEST_OVER:
+    case CAIRO_OPERATOR_DEST_IN:
+    case CAIRO_OPERATOR_DEST_OUT:
+    case CAIRO_OPERATOR_DEST_ATOP:
+    case CAIRO_OPERATOR_XOR:
+    case CAIRO_OPERATOR_ADD:
+	return TRUE;
+
+    case CAIRO_OPERATOR_SATURATE:
+	/* nobody likes saturate, expect that it's required to do
+	 * seamless polygons!
+	 */
+    case CAIRO_OPERATOR_MULTIPLY:
+    case CAIRO_OPERATOR_SCREEN:
+    case CAIRO_OPERATOR_OVERLAY:
+    case CAIRO_OPERATOR_DARKEN:
+    case CAIRO_OPERATOR_LIGHTEN:
+    case CAIRO_OPERATOR_COLOR_DODGE:
+    case CAIRO_OPERATOR_COLOR_BURN:
+    case CAIRO_OPERATOR_HARD_LIGHT:
+    case CAIRO_OPERATOR_SOFT_LIGHT:
+    case CAIRO_OPERATOR_DIFFERENCE:
+    case CAIRO_OPERATOR_EXCLUSION:
+    case CAIRO_OPERATOR_HSL_HUE:
+    case CAIRO_OPERATOR_HSL_SATURATION:
+    case CAIRO_OPERATOR_HSL_COLOR:
+    case CAIRO_OPERATOR_HSL_LUMINOSITY:
+	return FALSE;
+    }
+}
 static glitz_operator_t
 _glitz_operator (cairo_operator_t op)
 {
-    switch (op) {
+    switch ((int) op) {
     case CAIRO_OPERATOR_CLEAR:
 	return GLITZ_OPERATOR_CLEAR;
 
@@ -474,24 +518,17 @@ _glitz_operator (cairo_operator_t op)
 	return GLITZ_OPERATOR_XOR;
     case CAIRO_OPERATOR_ADD:
 	return GLITZ_OPERATOR_ADD;
-    case CAIRO_OPERATOR_SATURATE:
-	/* XXX: This line should never be reached. Glitz backend should bail
-	   out earlier if saturate operator is used. OpenGL can't do saturate
-	   with pre-multiplied colors. Solid colors can still be done as we
-	   can just un-pre-multiply them. However, support for that will have
-	   to be added to glitz. */
 
-	/* fall-through */
-	break;
-    }
-
-    ASSERT_NOT_REACHED;
+    default:
+	ASSERT_NOT_REACHED;
 
-    /* Something's very broken if this line of code can be reached, so
-       we want to return something that would give a noticeably
-       incorrect result. The XOR operator seems so rearely desired
-       that it should fit the bill here. */
-    return CAIRO_OPERATOR_XOR;
+	/* Something's very broken if this line of code can be reached, so
+	 * we want to return something that would give a noticeably
+	 * incorrect result. The XOR operator seems so rearely desired
+	 * that it should fit the bill here.
+	 */
+	return CAIRO_OPERATOR_XOR;
+    }
 }
 
 #define CAIRO_GLITZ_FEATURE_OK(surface, name)				  \
@@ -897,7 +934,7 @@ _cairo_glitz_surface_composite (cairo_operator_t op,
     cairo_glitz_surface_t		*mask;
     cairo_int_status_t			status;
 
-    if (op == CAIRO_OPERATOR_SATURATE)
+    if (! _is_supported_operator (op))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     if (_glitz_ensure_target (dst->surface))
@@ -1002,6 +1039,9 @@ _cairo_glitz_surface_fill_rectangles (void		      *abstract_dst,
     glitz_rectangle_t *current_rect;
     int i;
 
+    if (! _is_supported_operator (op))
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (n_rects > ARRAY_LENGTH (stack_rects)) {
         glitz_rects = _cairo_malloc_ab (n_rects, sizeof (glitz_rectangle_t));
         if (glitz_rects == NULL)
@@ -1133,7 +1173,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t  op,
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
-    if (op == CAIRO_OPERATOR_SATURATE)
+    if (! _is_supported_operator (op))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     if (_glitz_ensure_target (dst->surface))
@@ -2028,7 +2068,7 @@ _cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
 	scaled_font->surface_backend != _cairo_glitz_surface_get_backend ())
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if (op == CAIRO_OPERATOR_SATURATE)
+    if (! _is_supported_operator (op))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     /* XXX Unbounded operators are not handled correctly */
commit 333d37a60fa80f325612ea94b19ec9892dff8cfb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jul 14 16:41:00 2009 +0100

    [pdf] Silence copmiler.
    
    Fill in missing case values to silence the compiler, and remind us should
    we every add more operators in future.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 0108572..0e5c840 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -771,52 +771,39 @@ static const char *
 _cairo_operator_to_pdf_blend_mode (cairo_operator_t op)
 {
     switch (op) {
-    case CAIRO_OPERATOR_MULTIPLY:
-	return "Multiply";
-
-    case CAIRO_OPERATOR_SCREEN:
-	return "Screen";
-
-    case CAIRO_OPERATOR_OVERLAY:
-	return "Overlay";
-
-    case CAIRO_OPERATOR_DARKEN:
-	return "Darken";
-
-    case  CAIRO_OPERATOR_LIGHTEN:
-	return "Lighten";
-
-    case CAIRO_OPERATOR_COLOR_DODGE:
-	return "ColorDodge";
-
-    case CAIRO_OPERATOR_COLOR_BURN:
-	return "ColorBurn";
-
-    case CAIRO_OPERATOR_HARD_LIGHT:
-	return "HardLight";
-
-    case CAIRO_OPERATOR_SOFT_LIGHT:
-	return "SoftLight";
-
-    case CAIRO_OPERATOR_DIFFERENCE:
-	return "Difference";
-
-    case CAIRO_OPERATOR_EXCLUSION:
-	return "Exclusion";
-
-    case CAIRO_OPERATOR_HSL_HUE:
-	return "Hue";
-
-    case CAIRO_OPERATOR_HSL_SATURATION:
-	return "Saturation";
-
-    case CAIRO_OPERATOR_HSL_COLOR:
-	return "Color";
-
-    case CAIRO_OPERATOR_HSL_LUMINOSITY:
-	return "Luminosity";
+    /* The extend blend mode operators */
+    case CAIRO_OPERATOR_MULTIPLY:       return "Multiply";
+    case CAIRO_OPERATOR_SCREEN:         return "Screen";
+    case CAIRO_OPERATOR_OVERLAY:        return "Overlay";
+    case CAIRO_OPERATOR_DARKEN:         return "Darken";
+    case CAIRO_OPERATOR_LIGHTEN:        return "Lighten";
+    case CAIRO_OPERATOR_COLOR_DODGE:    return "ColorDodge";
+    case CAIRO_OPERATOR_COLOR_BURN:     return "ColorBurn";
+    case CAIRO_OPERATOR_HARD_LIGHT:     return "HardLight";
+    case CAIRO_OPERATOR_SOFT_LIGHT:     return "SoftLight";
+    case CAIRO_OPERATOR_DIFFERENCE:     return "Difference";
+    case CAIRO_OPERATOR_EXCLUSION:      return "Exclusion";
+    case CAIRO_OPERATOR_HSL_HUE:        return "Hue";
+    case CAIRO_OPERATOR_HSL_SATURATION: return "Saturation";
+    case CAIRO_OPERATOR_HSL_COLOR:      return "Color";
+    case CAIRO_OPERATOR_HSL_LUMINOSITY: return "Luminosity";
 
     default:
+    /* The original Porter-Duff set */
+    case CAIRO_OPERATOR_CLEAR:
+    case CAIRO_OPERATOR_SOURCE:
+    case CAIRO_OPERATOR_OVER:
+    case CAIRO_OPERATOR_IN:
+    case CAIRO_OPERATOR_OUT:
+    case CAIRO_OPERATOR_ATOP:
+    case CAIRO_OPERATOR_DEST:
+    case CAIRO_OPERATOR_DEST_OVER:
+    case CAIRO_OPERATOR_DEST_IN:
+    case CAIRO_OPERATOR_DEST_OUT:
+    case CAIRO_OPERATOR_DEST_ATOP:
+    case CAIRO_OPERATOR_XOR:
+    case CAIRO_OPERATOR_ADD:
+    case CAIRO_OPERATOR_SATURATE:
 	return "Normal";
     }
 }
@@ -839,10 +826,11 @@ _cairo_pdf_surface_emit_group_resources (cairo_pdf_surface_t         *surface,
 				     "   /ExtGState <<\n");
 
 	for (i = 0; i < CAIRO_NUM_OPERATORS; i++) {
-	    if (res->operators[i])
+	    if (res->operators[i]) {
 		_cairo_output_stream_printf (surface->output,
 					     "      /b%d << /BM /%s >>\n",
 					     i, _cairo_operator_to_pdf_blend_mode(i));
+	    }
 	}
 
 	for (i = 0; i < num_alphas; i++) {
@@ -5125,6 +5113,19 @@ _pdf_operator_supported (cairo_operator_t op)
 	return TRUE;
 
     default:
+    case CAIRO_OPERATOR_CLEAR:
+    case CAIRO_OPERATOR_SOURCE:
+    case CAIRO_OPERATOR_IN:
+    case CAIRO_OPERATOR_OUT:
+    case CAIRO_OPERATOR_ATOP:
+    case CAIRO_OPERATOR_DEST:
+    case CAIRO_OPERATOR_DEST_OVER:
+    case CAIRO_OPERATOR_DEST_IN:
+    case CAIRO_OPERATOR_DEST_OUT:
+    case CAIRO_OPERATOR_DEST_ATOP:
+    case CAIRO_OPERATOR_XOR:
+    case CAIRO_OPERATOR_ADD:
+    case CAIRO_OPERATOR_SATURATE:
 	return FALSE;
     }
 }
@@ -5154,10 +5155,10 @@ _cairo_pdf_surface_analyze_operation (cairo_pdf_surface_t  *surface,
 		    return CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN;
 	    }
 	}
-    }
 
-    if (_pdf_operator_supported (op))
 	return CAIRO_STATUS_SUCCESS;
+    }
+
 
     /* The SOURCE operator is supported if the pattern is opaque or if
      * there is nothing painted underneath. */
commit 710308c64e298ae35988fb0881a33cbe92af48ab
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jul 14 16:31:41 2009 +0100

    [script] Extended blend mode support.

diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index d232767..059ef95 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -242,7 +242,23 @@ _operator_to_string (cairo_operator_t op)
 
 	"XOR",		/* CAIRO_OPERATOR_XOR */
 	"ADD",		/* CAIRO_OPERATOR_ADD */
-	"SATURATE"	/* CAIRO_OPERATOR_SATURATE */
+	"SATURATE",	/* CAIRO_OPERATOR_SATURATE */
+
+	"MULTIPLY",	/* CAIRO_OPERATOR_MULTIPLY */
+	"SCREEN",	/* CAIRO_OPERATOR_SCREEN */
+	"OVERLAY",	/* CAIRO_OPERATOR_OVERLAY */
+	"DARKEN",	/* CAIRO_OPERATOR_DARKEN */
+	"LIGHTEN",	/* CAIRO_OPERATOR_LIGHTEN */
+	"DODGE",	/* CAIRO_OPERATOR_COLOR_DODGE */
+	"BURN",		/* CAIRO_OPERATOR_COLOR_BURN */
+	"HARD_LIGHT",	/* CAIRO_OPERATOR_HARD_LIGHT */
+	"SOFT_LIGHT",	/* CAIRO_OPERATOR_SOFT_LIGHT */
+	"DIFFERENCE",	/* CAIRO_OPERATOR_DIFFERENCE */
+	"EXCLUSION",	/* CAIRO_OPERATOR_EXCLUSION */
+	"HSL_HUE",	/* CAIRO_OPERATOR_HSL_HUE */
+	"HSL_SATURATION", /* CAIRO_OPERATOR_HSL_SATURATION */
+	"HSL_COLOR",	/* CAIRO_OPERATOR_HSL_COLOR */
+	"HSL_LUMINOSITY" /* CAIRO_OPERATOR_HSL_LUMINOSITY */
     };
     assert (op < ARRAY_LENGTH (names));
     return names[op];
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index da68b1b..c447b94 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -5635,6 +5635,21 @@ _integer_constants[] = {
     { "XOR",		CAIRO_OPERATOR_XOR },
     { "ADD",		CAIRO_OPERATOR_ADD },
     { "SATURATE",	CAIRO_OPERATOR_SATURATE },
+    { "MULTIPLY",	CAIRO_OPERATOR_MULTIPLY },
+    { "SCREEN",		CAIRO_OPERATOR_SCREEN },
+    { "OVERLAY",	CAIRO_OPERATOR_OVERLAY },
+    { "DARKEN",		CAIRO_OPERATOR_DARKEN },
+    { "LIGHTEN",	CAIRO_OPERATOR_LIGHTEN },
+    { "DODGE",		CAIRO_OPERATOR_COLOR_DODGE },
+    { "BURN",		CAIRO_OPERATOR_COLOR_BURN },
+    { "HARD_LIGHT",	CAIRO_OPERATOR_HARD_LIGHT },
+    { "SOFT_LIGHT",	CAIRO_OPERATOR_SOFT_LIGHT },
+    { "DIFFERENCE",	CAIRO_OPERATOR_DIFFERENCE },
+    { "EXCLUSION",	CAIRO_OPERATOR_EXCLUSION },
+    { "HSL_HUE",	CAIRO_OPERATOR_HSL_HUE },
+    { "HSL_SATURATION", CAIRO_OPERATOR_HSL_SATURATION },
+    { "HSL_COLOR",	CAIRO_OPERATOR_HSL_COLOR },
+    { "HSL_LUMINOSITY", CAIRO_OPERATOR_HSL_LUMINOSITY },
 
     { "WINDING",	CAIRO_FILL_RULE_WINDING },
     { "EVEN_ODD",	CAIRO_FILL_RULE_EVEN_ODD },
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index b29b57f..26e0d02 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -1857,7 +1857,23 @@ _operator_to_string (cairo_operator_t op)
 
 	"XOR",		/* CAIRO_OPERATOR_XOR */
 	"ADD",		/* CAIRO_OPERATOR_ADD */
-	"SATURATE"	/* CAIRO_OPERATOR_SATURATE */
+	"SATURATE",	/* CAIRO_OPERATOR_SATURATE */
+
+	"MULTIPLY",	/* CAIRO_OPERATOR_MULTIPLY */
+	"SCREEN",	/* CAIRO_OPERATOR_SCREEN */
+	"OVERLAY",	/* CAIRO_OPERATOR_OVERLAY */
+	"DARKEN",	/* CAIRO_OPERATOR_DARKEN */
+	"LIGHTEN",	/* CAIRO_OPERATOR_LIGHTEN */
+	"DODGE",	/* CAIRO_OPERATOR_COLOR_DODGE */
+	"BURN",		/* CAIRO_OPERATOR_COLOR_BURN */
+	"HARD_LIGHT",	/* CAIRO_OPERATOR_HARD_LIGHT */
+	"SOFT_LIGHT",	/* CAIRO_OPERATOR_SOFT_LIGHT */
+	"DIFFERENCE",	/* CAIRO_OPERATOR_DIFFERENCE */
+	"EXCLUSION",	/* CAIRO_OPERATOR_EXCLUSION */
+	"HSL_HUE",	/* CAIRO_OPERATOR_HSL_HUE */
+	"HSL_SATURATION", /* CAIRO_OPERATOR_HSL_SATURATION */
+	"HSL_COLOR",	/* CAIRO_OPERATOR_HSL_COLOR */
+	"HSL_LUMINOSITY" /* CAIRO_OPERATOR_HSL_LUMINOSITY */
     };
     return names[op];
 }
commit 100f0d94eebcec05372263b2e68c27b91b52a1c8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jul 14 16:30:36 2009 +0100

    [cairo] Remove trailing spaces in comments.
    
    vim highlights these errors making my screen go red and upsets me.
    So they must die.

diff --git a/src/cairo.h b/src/cairo.h
index c2f209c..8cfcf5f 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -427,35 +427,35 @@ cairo_pop_group_to_source (cairo_t *cr);
  * @CAIRO_OPERATOR_SCREEN: source and destination are complemented and
  * multiplied. This causes the result to be at least as light as the lighter
  * inputs.
- * @CAIRO_OPERATOR_OVERLAY: multiplies or screens, depending on the 
+ * @CAIRO_OPERATOR_OVERLAY: multiplies or screens, depending on the
  * lightness of the destination color.
  * @CAIRO_OPERATOR_DARKEN: replaces the destination with the source if it
  * is darker, otherwise keeps the source.
  * @CAIRO_OPERATOR_LIGHTEN: replaces the destination with the source if it
  * is lighter, otherwise keeps the source.
- * @CAIRO_OPERATOR_COLOR_DODGE: brightens the destination color to reflect 
+ * @CAIRO_OPERATOR_COLOR_DODGE: brightens the destination color to reflect
  * the source color.
  * @CAIRO_OPERATOR_COLOR_BURN: darkens the destination color to reflect
  * the source color.
- * @CAIRO_OPERATOR_HARD_LIGHT: Multiplies or screens, dependant on source 
+ * @CAIRO_OPERATOR_HARD_LIGHT: Multiplies or screens, dependant on source
  * color.
- * @CAIRO_OPERATOR_SOFT_LIGHT: Darkens or lightens, dependant on source 
+ * @CAIRO_OPERATOR_SOFT_LIGHT: Darkens or lightens, dependant on source
  * color.
- * @CAIRO_OPERATOR_DIFFERENCE: Takes the difference of the source and 
+ * @CAIRO_OPERATOR_DIFFERENCE: Takes the difference of the source and
  * destination color.
  * @CAIRO_OPERATOR_EXCLUSION: Produces an effect similar to difference, but
  * with lower contrast.
- * @CAIRO_OPERATOR_HSL_HUE: Creates a color with the hue of the source 
+ * @CAIRO_OPERATOR_HSL_HUE: Creates a color with the hue of the source
  * and the saturation and luminosity of the target.
  * @CAIRO_OPERATOR_HSL_SATURATION: Creates a color with the saturation
- * of the source and the hue and luminosity of the target. Painting with 
+ * of the source and the hue and luminosity of the target. Painting with
  * this mode onto a gray area prduces no change.
- * @CAIRO_OPERATOR_HSL_COLOR: Creates a color with the hue and saturation 
- * of the source and the luminosity of the target. This preserves the gray 
+ * @CAIRO_OPERATOR_HSL_COLOR: Creates a color with the hue and saturation
+ * of the source and the luminosity of the target. This preserves the gray
  * levels of the target and is useful for coloring monochrome images or
  * tinting color images.
- * @CAIRO_OPERATOR_HSL_LUMINOSITY: Creates a color with the luminosity of 
- * the source and the hue and saturation of the target. This produces an 
+ * @CAIRO_OPERATOR_HSL_LUMINOSITY: Creates a color with the luminosity of
+ * the source and the hue and saturation of the target. This produces an
  * inverse effect to @CAIRO_OPERATOR_HSL_COLOR.
  *
  * #cairo_operator_t is used to set the compositing operator for all cairo


More information about the cairo-commit mailing list