diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2009-06-17 11:10:15 +0200 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2009-07-31 17:41:11 +0200 |
commit | b054756113f0df6b59935823882f412486e96db5 (patch) | |
tree | 65325c172da40a9f2ed9b5afbfee4523101de38d | |
parent | bf8964726c9311e7e82b1faf49cc2272e5c1e339 (diff) |
[cairo] Implement blend mdoes in cairo backend
It requires cairo from git master to work at the moment. Fixes bugs
#22384, #12979, #13603, #17919, #22255
-rw-r--r-- | configure.ac | 27 | ||||
-rw-r--r-- | poppler/CairoOutputDev.cc | 59 | ||||
-rw-r--r-- | poppler/CairoOutputDev.h | 1 |
3 files changed, 87 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 0494c926..1942393b 100644 --- a/configure.ac +++ b/configure.ac @@ -259,6 +259,9 @@ elif test x$enable_cairo_output = xtry; then [enable_cairo_output="no"]) fi +AC_SUBST(CAIRO_CFLAGS) +AC_SUBST(CAIRO_LIBS) + AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes) AH_TEMPLATE([HAVE_CAIRO], [Use cairo for rendering.]) if test x$enable_cairo_output = xyes; then @@ -266,6 +269,30 @@ if test x$enable_cairo_output = xyes; then CAIRO_FEATURE="#define POPPLER_HAS_CAIRO 1" CAIRO_REQ="cairo" AC_CHECK_HEADERS(fcntl.h sys/mman.h sys/stat.h) + AC_LANG_PUSH([C]) + _SAVE_CFLAGS=$CFLAGS + _SAVE_LIBS=$LIBS + CFLAGS="$CFLAGS $CAIRO_CFLAGS" + LIBS="$LIBS $CAIRO_LIBS" + AC_CACHE_CHECK([for cairo blend modes support], + ac_cv_cairo_has_blend_modes, + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[ +#include <cairo.h> +int main() { + cairo_t *cr; + cairo_set_operator(cr, CAIRO_OPERATOR_MULTIPLY); + return 0; +} + ]])], + [ac_cv_cairo_has_blend_modes="yes"], + [ac_cv_cairo_has_blend_modes="no"])]) + CFLAGS=$_SAVE_CFLAGS + LIBS=$_SAVE_LIBS + AC_LANG_POP([C]) + if test "$ac_cv_cairo_has_blend_modes" = "yes"; then + AC_DEFINE(CAIRO_HAS_BLEND_MODES, [1], [Whether cairo has blend modes support]) + fi else CAIRO_FEATURE="#undef POPPLER_HAS_CAIRO" CAIRO_REQ="" diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 670ae402..d1f5f3cd 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -263,6 +263,7 @@ void CairoOutputDev::restoreState(GfxState *state) { updateStrokeColor(state); updateFillOpacity(state); updateStrokeOpacity(state); + updateBlendMode(state); MaskStack* ms = maskStack; if (mask) @@ -284,6 +285,7 @@ void CairoOutputDev::updateAll(GfxState *state) { updateStrokeColor(state); updateFillOpacity(state); updateStrokeOpacity(state); + updateBlendMode(state); needFontUpdate = gTrue; } @@ -470,6 +472,63 @@ void CairoOutputDev::updateFillColorStop(GfxState *state, double offset) { offset, fill_color.r, fill_color.g, fill_color.b)); } +void CairoOutputDev::updateBlendMode(GfxState *state) { +#ifdef CAIRO_HAS_BLEND_MODES + switch (state->getBlendMode()) { + default: + case gfxBlendNormal: + cairo_set_operator (cairo, CAIRO_OPERATOR_OVER); + break; + case gfxBlendMultiply: + cairo_set_operator (cairo, CAIRO_OPERATOR_MULTIPLY); + break; + case gfxBlendScreen: + cairo_set_operator (cairo, CAIRO_OPERATOR_SCREEN); + break; + case gfxBlendOverlay: + cairo_set_operator (cairo, CAIRO_OPERATOR_OVERLAY); + break; + case gfxBlendDarken: + cairo_set_operator (cairo, CAIRO_OPERATOR_DARKEN); + break; + case gfxBlendLighten: + cairo_set_operator (cairo, CAIRO_OPERATOR_LIGHTEN); + break; + case gfxBlendColorDodge: + cairo_set_operator (cairo, CAIRO_OPERATOR_COLOR_DODGE); + break; + case gfxBlendColorBurn: + cairo_set_operator (cairo, CAIRO_OPERATOR_COLOR_BURN); + break; + case gfxBlendHardLight: + cairo_set_operator (cairo, CAIRO_OPERATOR_HARD_LIGHT); + break; + case gfxBlendSoftLight: + cairo_set_operator (cairo, CAIRO_OPERATOR_SOFT_LIGHT); + break; + case gfxBlendDifference: + cairo_set_operator (cairo, CAIRO_OPERATOR_DIFFERENCE); + break; + case gfxBlendExclusion: + cairo_set_operator (cairo, CAIRO_OPERATOR_EXCLUSION); + break; + case gfxBlendHue: + cairo_set_operator (cairo, CAIRO_OPERATOR_HSL_HUE); + break; + case gfxBlendSaturation: + cairo_set_operator (cairo, CAIRO_OPERATOR_HSL_SATURATION); + break; + case gfxBlendColor: + cairo_set_operator (cairo, CAIRO_OPERATOR_HSL_COLOR); + break; + case gfxBlendLuminosity: + cairo_set_operator (cairo, CAIRO_OPERATOR_HSL_LUMINOSITY); + break; + } + LOG(printf ("blend mode: %d\n", (int)state->getBlendMode())); +#endif /* CAIRO_HAS_BLEND_MODES */ +} + void CairoOutputDev::updateFont(GfxState *state) { cairo_font_face_t *font_face; cairo_matrix_t matrix, invert_matrix; diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index cd66cb78..f25e4028 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -141,6 +141,7 @@ public: virtual void updateFillOpacity(GfxState *state); virtual void updateStrokeOpacity(GfxState *state); virtual void updateFillColorStop(GfxState *state, double offset); + virtual void updateBlendMode(GfxState *state); //----- update text state virtual void updateFont(GfxState *state); |