[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/OutputDev.cc poppler/OutputDev.h poppler/PSOutputDev.cc poppler/PSOutputDev.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Apr 25 11:12:45 PDT 2012


 poppler/CairoOutputDev.cc  |    6 +++---
 poppler/CairoOutputDev.h   |    6 +++---
 poppler/Gfx.cc             |    4 ++--
 poppler/OutputDev.cc       |    5 +++--
 poppler/OutputDev.h        |    6 +++---
 poppler/PSOutputDev.cc     |    4 ++--
 poppler/PSOutputDev.h      |    4 ++--
 poppler/SplashOutputDev.cc |   35 +++++++++++------------------------
 poppler/SplashOutputDev.h  |    4 ++--
 9 files changed, 31 insertions(+), 43 deletions(-)

New commits:
commit cf7a20adbd15f901d414ce06825459c33eeef3f5
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date:   Wed Apr 25 18:51:23 2012 +0200

    Fix slow rendering of pdf with a lot of image masks in pattern colorspace
    
    Makes it around 8 times faster

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 32f01d3..b70183e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -25,7 +25,7 @@
 // Copyright (C) 2008, 2009 Chris Wilson <chris at chris-wilson.co.uk>
 // Copyright (C) 2008 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009, 2010 David Benjamin <davidben at mit.edu>
-// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2012 Patrick Pfeifer <p2000 at mailinator.com>
 //
 // To see a description of the changes please see the Changelog file that
@@ -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..df76975 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -20,7 +20,7 @@
 // Copyright (C) 2006-2011 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2008, 2009, 2011, 2012 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
-// Copyright (C) 2010, 2011 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2010-2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -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..c52f611 100644
--- a/poppler/OutputDev.cc
+++ b/poppler/OutputDev.cc
@@ -18,6 +18,7 @@
 // Copyright (C) 2007 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -111,11 +112,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..803d922 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2006 Thorkild Stray <thorkild at ifi.uio.no>
 // Copyright (C) 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2007, 2011 Adrian Johnson <ajohnson at redneon.com>
-// Copyright (C) 2009-2011 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2009-2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009, 2011 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
@@ -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..0e956c7 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -2590,12 +2590,13 @@ 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;
@@ -2605,6 +2606,12 @@ void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state,
   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 +2625,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 +2637,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 +2651,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);


More information about the poppler mailing list