[poppler] configure.ac poppler/CairoOutputDev.cc poppler/CairoOutputDev.h
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Fri Jul 31 08:41:28 PDT 2009
configure.ac | 27 +++++++++++++++++++++
poppler/CairoOutputDev.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++
poppler/CairoOutputDev.h | 1
3 files changed, 87 insertions(+)
New commits:
commit b054756113f0df6b59935823882f412486e96db5
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Wed Jun 17 11:10:15 2009 +0200
[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
diff --git a/configure.ac b/configure.ac
index 0494c92..1942393 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 670ae40..d1f5f3c 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 cd66cb7..f25e402 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);
More information about the poppler
mailing list