Commit b0547561 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[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
parent bf896472
......@@ -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=""
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment