From 1b47b1a78da9c395dc7731006e8e5e59ba898022 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Thu, 19 Mar 2009 22:34:23 +1030 Subject: [PATCH] Fix bug in cairo backend with nested masks The previous smask was not restored after a q/Q pair or form xobject. --- poppler/CairoOutputDev.cc | 18 +++++++++++++++++- poppler/CairoOutputDev.h | 5 +++++ 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 822d66d..fd93e05 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -132,6 +132,7 @@ CairoOutputDev::CairoOutputDev() { t3_glyph_has_bbox = gFalse; groupColorSpaceStack = NULL; + maskStack = NULL; group = NULL; mask = NULL; shape = NULL; @@ -242,6 +243,11 @@ void CairoOutputDev::saveState(GfxState *state) { cairo_save (cairo); if (cairo_shape) cairo_save (cairo_shape); + + MaskStack *ms = new MaskStack; + ms->mask = cairo_pattern_reference(mask); + ms->next = maskStack; + maskStack = ms; } void CairoOutputDev::restoreState(GfxState *state) { @@ -256,6 +262,14 @@ void CairoOutputDev::restoreState(GfxState *state) { updateStrokeColor(state); updateFillOpacity(state); updateStrokeOpacity(state); + + MaskStack* ms = maskStack; + if (mask) + cairo_pattern_destroy(mask); + + mask = ms->mask; + maskStack = ms->next; + delete ms; } void CairoOutputDev::updateAll(GfxState *state) { @@ -1024,7 +1038,9 @@ void CairoOutputDev::popTransparencyGroup() { void CairoOutputDev::clearSoftMask(GfxState * /*state*/) { - //XXX: should we be doing anything here? + if (mask) + cairo_pattern_destroy(mask); + mask = NULL; } void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index 1e410c1..5ec2bf0 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -271,6 +271,11 @@ protected: GfxColorSpace *cs; struct ColorSpaceStack *next; } * groupColorSpaceStack; + + struct MaskStack { + cairo_pattern_t *mask; + struct MaskStack *next; + } *maskStack; }; //------------------------------------------------------------------------ -- 1.5.6.3