[poppler] 3 commits - poppler/PSOutputDev.cc poppler/PSOutputDev.h poppler/SplashOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Jul 28 16:13:09 PDT 2013


 poppler/PSOutputDev.cc     |   43 +++++++++++--------------------------------
 poppler/PSOutputDev.h      |    6 +++---
 poppler/SplashOutputDev.cc |    8 +++++++-
 3 files changed, 21 insertions(+), 36 deletions(-)

New commits:
commit 4637b1581286381c3d1c6963828d9cd8afc5b9e0
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Jul 29 01:08:06 2013 +0200

    Make some pdftops conversions *much* faster
    
    For example: http://ev.kde.org/resources/expense_report.pdf
    
    Without this patch it seems "infinite", which this patch it's a few seconds
    
    The change: Instead of just remembering in xobjStack the set of XObjects (and Patterns,
    the variable name was 'wrong') we are currently setting up (i.e. the current chain), we
    remember all of them.
    
    This has passed the pdf->ps regression test without a single issue

diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 11add87..4fe5d7b 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1075,7 +1075,6 @@ PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *doc,
   font16Enc = NULL;
   imgIDs = NULL;
   formIDs = NULL;
-  xobjStack = NULL;
   paperSizes = NULL;
   embFontList = NULL;
   customColors = NULL;
@@ -1142,7 +1141,6 @@ PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
   font16Enc = NULL;
   imgIDs = NULL;
   formIDs = NULL;
-  xobjStack = NULL;
   paperSizes = NULL;
   embFontList = NULL;
   customColors = NULL;
@@ -1276,7 +1274,6 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
   formIDLen = 0;
   formIDSize = 0;
 
-  xobjStack = new GooList();
   numSaves = 0;
   numTilingPatterns = 0;
   nextFunc = 0;
@@ -1376,9 +1373,6 @@ PSOutputDev::~PSOutputDev() {
   }
   gfree(imgIDs);
   gfree(formIDs);
-  if (xobjStack) {
-    delete xobjStack;
-  }
   while (customColors) {
     cc = customColors;
     customColors = cc->next;
@@ -1658,9 +1652,9 @@ void PSOutputDev::writeTrailer() {
 
 void PSOutputDev::setupResources(Dict *resDict) {
   Object xObjDict, xObjRef, xObj, patDict, patRef, pat, resObj;
-  Ref ref0, ref1;
+  Ref ref0;
   GBool skip;
-  int i, j;
+  int i;
 
   setupFonts(resDict);
   setupImages(resDict);
@@ -1675,15 +1669,10 @@ void PSOutputDev::setupResources(Dict *resDict) {
       skip = gFalse;
       if ((xObjDict.dictGetValNF(i, &xObjRef)->isRef())) {
 	ref0 = xObjRef.getRef();
-	for (j = 0; j < xobjStack->getLength(); ++j) {
-	  ref1 = *(Ref *)xobjStack->get(j);
-	  if (ref1.num == ref0.num && ref1.gen == ref0.gen) {
-	    skip = gTrue;
-	    break;
-	  }
-	}
-	if (!skip) {
-	  xobjStack->append(&ref0);
+	if (resourceIDs.find(ref0.num) != resourceIDs.end()) {
+	  skip = gTrue;
+	} else {
+	  resourceIDs.insert(ref0.num);
 	}
       }
       if (!skip) {
@@ -1700,9 +1689,6 @@ void PSOutputDev::setupResources(Dict *resDict) {
 	xObj.free();
       }
 
-      if (xObjRef.isRef() && !skip) {
-	xobjStack->del(xobjStack->getLength() - 1);
-      }
       xObjRef.free();
     }
   }
@@ -1718,15 +1704,10 @@ void PSOutputDev::setupResources(Dict *resDict) {
       skip = gFalse;
       if ((patDict.dictGetValNF(i, &patRef)->isRef())) {
 	ref0 = patRef.getRef();
-	for (j = 0; j < xobjStack->getLength(); ++j) {
-	  ref1 = *(Ref *)xobjStack->get(j);
-	  if (ref1.num == ref0.num && ref1.gen == ref0.gen) {
-	    skip = gTrue;
-	    break;
-	  }
-	}
-	if (!skip) {
-	  xobjStack->append(&ref0);
+	if (resourceIDs.find(ref0.num) != resourceIDs.end()) {
+	  skip = gTrue;
+	} else {
+	  resourceIDs.insert(ref0.num);
 	}
       }
       if (!skip) {
@@ -1743,9 +1724,6 @@ void PSOutputDev::setupResources(Dict *resDict) {
 	pat.free();
       }
 
-      if (patRef.isRef() && !skip) {
-	xobjStack->del(xobjStack->getLength() - 1);
-      }
       patRef.free();
     }
     inType3Char = gFalse;
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index f9dc63c..92b007e 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Martin Kretzschmar <martink at gnome.org>
 // Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
-// Copyright (C) 2006-2008, 2012 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2008, 2012, 2013 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2007 Brad Hards <bradh at kde.org>
 // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
@@ -43,6 +43,7 @@
 #include "GfxState.h"
 #include "GlobalParams.h"
 #include "OutputDev.h"
+#include <set>
 
 class GHooash;
 class PDFDoc;
@@ -428,6 +429,7 @@ private:
   Ref *fontIDs;			// list of object IDs of all used fonts
   int fontIDLen;		// number of entries in fontIDs array
   int fontIDSize;		// size of fontIDs array
+  std::set<int> resourceIDs;	// list of object IDs of objects containing Resources we've already set up
   GooHash *fontNames;		// all used font names
   PST1FontName *t1FontNames;	// font names for Type 1/1C fonts
   int t1FontNameLen;		// number of entries in t1FontNames array
@@ -444,8 +446,6 @@ private:
   Ref *formIDs;			// list of IDs for predefined forms
   int formIDLen;		// number of entries in formIDs array
   int formIDSize;		// size of formIDs array
-  GooList *xobjStack;		// stack of XObject dicts currently being
-				//   processed
   int numSaves;			// current number of gsaves
   int numTilingPatterns;	// current number of nested tiling patterns
   int nextFunc;			// next unique number to use for a function
commit e04287f2682e46831c04e0ef8d60411f521a2572
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Jul 29 00:55:43 2013 +0200

    Fallback to 1x1 bitmap If we fail to create the corrent one

diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index b11b695..4d4e945 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2006 Stefan Schweizer <genstef at gentoo.org>
-// Copyright (C) 2006-2012 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2013 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
 // Copyright (C) 2006 Scott Turner <scotty1024 at mac.com>
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
@@ -1385,6 +1385,12 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
     }
     bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode,
 			      colorMode != splashModeMono1, bitmapTopDown);
+    if (!bitmap->getDataPtr()) {
+      delete bitmap;
+      w = h = 1;
+      bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode,
+                              colorMode != splashModeMono1, bitmapTopDown);
+    }
   }
   splash = new Splash(bitmap, vectorAntialias, &screenParams);
   splash->setThinLineMode(thinLineMode);
commit fe5ff20cb93a70fa1650ef5e00b67e35de20f0ca
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Jul 29 00:54:07 2013 +0200

    Initialize t3FillColorOnly

diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 41c763d..11add87 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1238,6 +1238,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
   processColors = 0;
   inType3Char = gFalse;
   inUncoloredPattern = gFalse;
+  t3FillColorOnly = gFalse;
 
 #if OPI_SUPPORT
   // initialize OPI nesting levels


More information about the poppler mailing list