[cairo-commit] src/cairo-xcb-private.h src/cairo-xcb-surface-render.c

Uli Schlachter psychon at kemper.freedesktop.org
Sat Jun 11 12:36:55 PDT 2011


 src/cairo-xcb-private.h        |    4 +++
 src/cairo-xcb-surface-render.c |   43 +++++++++++++++++++++++++----------------
 2 files changed, 31 insertions(+), 16 deletions(-)

New commits:
commit fb0a40fc10849eb6e972be27c98685f6ab7bc344
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Jun 11 21:32:29 2011 +0200

    XCB: Implement PDF blend operators natively
    
    The PDF blend operators, as offered by cairo, where added in RENDER 0.11. This
    commit makes the XCB backend use them, if they are available.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index ae6027e..4704a25 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -55,6 +55,10 @@
 #include <xcb/xcbext.h>
 #include <pixman.h>
 
+#define CAIRO_XCB_RENDER_AT_LEAST(major, minor)	\
+	((XCB_RENDER_MAJOR_VERSION > major) ||	\
+	((XCB_RENDER_MAJOR_VERSION == major) && (XCB_RENDER_MINOR_VERSION >= minor)))
+
 typedef struct _cairo_xcb_connection cairo_xcb_connection_t;
 typedef struct _cairo_xcb_font cairo_xcb_font_t;
 typedef struct _cairo_xcb_screen cairo_xcb_screen_t;
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 4d5a88f..bc8f2a6 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -168,7 +168,12 @@ _operator_is_supported (uint32_t flags, cairo_operator_t op)
     if (op <= CAIRO_OPERATOR_SATURATE)
 	return TRUE;
 
-    /* TODO Support pdf operators via CAIRO_XCB_RENDER_HAS_PDF_OPERATORS */
+    /* Can we use PDF operators? */
+#if CAIRO_XCB_RENDER_AT_LEAST(0, 11)
+    if (op <= CAIRO_OPERATOR_HSL_LUMINOSITY)
+	return flags & CAIRO_XCB_RENDER_HAS_PDF_OPERATORS;
+#endif
+
     return FALSE;
 }
 
@@ -195,21 +200,27 @@ _render_operator (cairo_operator_t op)
     C(ADD, ADD);
     C(SATURATE, SATURATE);
 
-    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:
+#if CAIRO_XCB_RENDER_AT_LEAST(0, 11)
+#define BLEND(x,y) C(x,y)
+#else
+#define BLEND(x,y) case CAIRO_OPERATOR_##x: ASSERT_NOT_REACHED; return XCB_RENDER_PICT_OP_OVER
+#endif
+    BLEND(MULTIPLY, MULTIPLY);
+    BLEND(SCREEN, SCREEN);
+    BLEND(OVERLAY, OVERLAY);
+    BLEND(DARKEN, DARKEN);
+    BLEND(LIGHTEN, LIGHTEN);
+    BLEND(COLOR_DODGE, COLOR_DODGE);
+    BLEND(COLOR_BURN, COLOR_BURN);
+    BLEND(HARD_LIGHT, HARD_LIGHT);
+    BLEND(SOFT_LIGHT, SOFT_LIGHT);
+    BLEND(DIFFERENCE, DIFFERENCE);
+    BLEND(EXCLUSION, EXCLUSION);
+    BLEND(HSL_HUE, HSL_HUE);
+    BLEND(HSL_SATURATION, HSL_SATURATION);
+    BLEND(HSL_COLOR, HSL_COLOR);
+    BLEND(HSL_LUMINOSITY, HSL_LUMINOSITY);
+
     default:
 	ASSERT_NOT_REACHED;
 	return XCB_RENDER_PICT_OP_OVER;


More information about the cairo-commit mailing list