diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 32f01d3..d01d57d 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -1858,7 +1858,7 @@ void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg) { + GBool inlineImg, double *baseMatrix) { /* FIXME: Doesn't the image mask support any colorspace? */ cairo_set_source (cairo, fill_pattern); @@ -1922,7 +1922,7 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stre gTrue, gFalse, gFalse); } -void CairoOutputDev::unsetSoftMaskFromImageMask(GfxState *state) { +void CairoOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) { double bbox[4] = {0,0,1,1}; // dummy endTransparencyGroup(state); diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index ae85433..4149a1b 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -202,8 +202,8 @@ public: virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg); - virtual void unsetSoftMaskFromImageMask(GfxState *state); + GBool inlineImg, double *baseMatrix); + virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool interpolate, GBool inlineImg); diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index e9d6ac3..7c0c88b 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -2030,7 +2030,7 @@ void Gfx::doPatternImageMask(Object *ref, Stream *str, int width, int height, saveState(); out->setSoftMaskFromImageMask(state, ref, str, - width, height, invert, inlineImg); + width, height, invert, inlineImg, baseMatrix); state->clearPath(); state->moveTo(0, 0); @@ -2040,7 +2040,7 @@ void Gfx::doPatternImageMask(Object *ref, Stream *str, int width, int height, state->closePath(); doPatternText(); - out->unsetSoftMaskFromImageMask(state); + out->unsetSoftMaskFromImageMask(state, baseMatrix); restoreState(); } diff --git a/poppler/OutputDev.cc b/poppler/OutputDev.cc index 43b7f5b..32062b5 100644 --- a/poppler/OutputDev.cc +++ b/poppler/OutputDev.cc @@ -111,11 +111,11 @@ void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, void OutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg) { + GBool inlineImg, double *baseMatrix) { drawImageMask(state, ref, str, width, height, invert, gFalse, inlineImg); } -void OutputDev::unsetSoftMaskFromImageMask(GfxState *state) { +void OutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) { return; } diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h index d739625..bd2ea2a 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -251,8 +251,8 @@ public: virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg); - virtual void unsetSoftMaskFromImageMask(GfxState *state); + GBool inlineImg, double *baseMatrix); + virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg); diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 157b4b7..dac10d0 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -4946,13 +4946,13 @@ void PSOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, void PSOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg) { + GBool inlineImg, double *baseMatrix) { if (level != psLevel1 && level != psLevel1Sep) { maskToClippingPath(str, width, height, invert); } } -void PSOutputDev::unsetSoftMaskFromImageMask(GfxState * state) { +void PSOutputDev::unsetSoftMaskFromImageMask(GfxState * state, double *baseMatrix) { if (level != psLevel1 && level != psLevel1Sep) { writePS("pdfImClipEnd\n"); } diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 751ad8e..70aef9f 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -256,8 +256,8 @@ public: virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg); - virtual void unsetSoftMaskFromImageMask(GfxState *state); + GBool inlineImg, double *baseMatrix); + virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg); diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 807e23a..96b928a 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -2590,21 +2590,27 @@ void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg) { + GBool inlineImg, double *baseMatrix) { double *ctm; SplashCoord mat[6]; SplashOutImageMaskData imgMaskData; Splash *maskSplash; SplashColor maskColor; + double bbox[4] = {0,0,1,1}; // default; if (state->getFillColorSpace()->isNonMarking()) { return; } - ctm = state->getCTM(); for (int i = 0; i < 6; ++i) { if (!isfinite(ctm[i])) return; } + + beginTransparencyGroup(state, bbox, NULL, gFalse, gFalse, gFalse); + baseMatrix[4] -= transpGroupStack->tx; + baseMatrix[5] -= transpGroupStack->ty; + + ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; @@ -2618,28 +2624,6 @@ void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, imgMaskData.height = height; imgMaskData.y = 0; - /* from beginTransparencyGroup: */ - // push a new stack entry - SplashTransparencyGroup *transpGroup = new SplashTransparencyGroup(); - transpGroup->tx = 0; - transpGroup->ty = 0; - transpGroup->blendingColorSpace = NULL; - transpGroup->isolated = gFalse; - transpGroup->next = transpGroupStack; - transpGroupStack = transpGroup; - // save state - transpGroup->origBitmap = bitmap; - transpGroup->origSplash = splash; - //~ this ignores the blendingColorSpace arg - // create the temporary bitmap - bitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), bitmapRowPad, colorMode, gTrue, - bitmapTopDown); - splash = new Splash(bitmap, vectorAntialias, - transpGroup->origSplash->getScreen()); - splash->blitTransparent(transpGroup->origBitmap, 0, 0, 0, 0, bitmap->getWidth(), bitmap->getHeight()); - splash->setInNonIsolatedGroup(transpGroup->origBitmap, 0, 0); - transpGroup->tBitmap = bitmap; - maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), 1, splashModeMono8, gFalse); maskSplash = new Splash(maskBitmap, vectorAntialias); maskColor[0] = 0; @@ -2652,7 +2636,7 @@ void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, str->close(); } -void SplashOutputDev::unsetSoftMaskFromImageMask(GfxState *state) { +void SplashOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) { double bbox[4] = {0,0,1,1}; // dummy /* transfer mask to alpha channel! */ @@ -2666,6 +2650,8 @@ void SplashOutputDev::unsetSoftMaskFromImageMask(GfxState *state) { delete maskBitmap; maskBitmap = NULL; endTransparencyGroup(state); + baseMatrix[4] += transpGroupStack->tx; + baseMatrix[5] += transpGroupStack->ty; paintTransparencyGroup(state, bbox); } diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index 95a7f65..b70ec38 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -266,8 +266,8 @@ public: virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg); - virtual void unsetSoftMaskFromImageMask(GfxState *state); + GBool inlineImg, double *baseMatrix); + virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg);