From 36b7fd4b7ff4e9ea0bea7456f364274a7d41b50d Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 30 Sep 2011 18:50:30 +0930 Subject: [PATCH 2/2] cairo: fix softmask bug due to wrong ctm The ctm when calling cairo_mask() needs to be the same as the ctm when the mask was created. --- poppler/CairoOutputDev.cc | 7 +++++++ poppler/CairoOutputDev.h | 1 + 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 6cb69a2..d3f4026 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -728,7 +728,10 @@ void CairoOutputDev::fill(GfxState *state) { //XXX: how do we get the path if (mask) { cairo_clip (cairo); + cairo_save (cairo); + cairo_set_matrix (cairo, &mask_matrix); cairo_mask (cairo, mask); + cairo_restore (cairo); } else if (strokePathClip) { fillToStrokePathClip(); } else { @@ -1480,7 +1483,10 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo if (status) printf("BAD status: %s\n", cairo_status_to_string(status)); } else { + cairo_save(cairo); + cairo_set_matrix(cairo, &mask_matrix); cairo_mask(cairo, mask); + cairo_restore(cairo); cairo_pattern_destroy(mask); mask = NULL; @@ -1602,6 +1608,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, /* setup the new mask pattern */ mask = cairo_pattern_create_for_surface(source); + cairo_get_matrix(cairo, &mask_matrix); if (cairo_get_group_target(cairo) == cairo_get_target(cairo)) { cairo_pattern_set_matrix(mask, &mat); diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index effa9dd..9dadbd1 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -341,6 +341,7 @@ protected: cairo_pattern_t *group; cairo_pattern_t *shape; cairo_pattern_t *mask; + cairo_matrix_t mask_matrix; cairo_surface_t *cairo_shape_surface; cairo_t *cairo_shape; int knockoutCount; -- 1.7.4.1