[poppler] 2 commits - poppler/Gfx.cc poppler/Gfx.h poppler/GfxState.cc poppler/GfxState.h poppler/OutputDev.cc poppler/OutputDev.h poppler/SplashOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Jun 5 16:02:36 PDT 2013


 poppler/Gfx.cc             |   61 +++++++++++------------------
 poppler/Gfx.h              |   12 -----
 poppler/GfxState.cc        |   93 ++++++++++++++++++++++-----------------------
 poppler/GfxState.h         |   33 ++++++++-------
 poppler/OutputDev.cc       |    8 +++
 poppler/OutputDev.h        |   19 ++++++++-
 poppler/SplashOutputDev.cc |    2 
 7 files changed, 116 insertions(+), 112 deletions(-)

New commits:
commit 342cc0d8a101e99199d447d632a1cd5ba7beb5b2
Author: Li Junling <lijunling at sina.com>
Date:   Tue Jun 4 22:39:35 2013 +0200

    Fix memory leak

diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 171825f..765b892 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -31,6 +31,7 @@
 // Copyright (C) 2011 Andrea Canciani <ranma42 at gmail.com>
 // Copyright (C) 2011, 2012 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2013 Lu Wang <coolwanglu at gmail.com>
+// Copyright (C) 2013 Li Junling <lijunling at sina.com>
 //
 // 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
@@ -4237,6 +4238,7 @@ GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *ca
   gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
   updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
   gfx->display(str);
+  delete splash;
   splash = formerSplash;
   TilingSplashOutBitmap imgData;
   imgData.bitmap = bitmap;
commit 52945a072b6f864e80485cc4321a27530a76c452
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Jun 4 22:35:32 2013 +0200

    Move the iccColorSpaceCache from Gfx to OutputDev
    
    This way it's shared when doing tiling. Page 35 of bug-poppler64963.pdf
    goes down from 150 to 133 seconds

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 775a2c9..c609292 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -459,7 +459,7 @@ void GfxResources::lookupColorSpace(const char *name, Object *obj) {
   obj->initNull();
 }
 
-GfxPattern *GfxResources::lookupPattern(char *name, Gfx *gfx) {
+GfxPattern *GfxResources::lookupPattern(char *name, OutputDev *out) {
   GfxResources *resPtr;
   GfxPattern *pattern;
   Object obj;
@@ -467,7 +467,7 @@ GfxPattern *GfxResources::lookupPattern(char *name, Gfx *gfx) {
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
     if (resPtr->patternDict.isDict()) {
       if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) {
-	pattern = GfxPattern::parse(&obj, gfx);
+	pattern = GfxPattern::parse(&obj, out);
 	obj.free();
 	return pattern;
       }
@@ -478,7 +478,7 @@ GfxPattern *GfxResources::lookupPattern(char *name, Gfx *gfx) {
   return NULL;
 }
 
-GfxShading *GfxResources::lookupShading(char *name, Gfx *gfx) {
+GfxShading *GfxResources::lookupShading(char *name, OutputDev *out) {
   GfxResources *resPtr;
   GfxShading *shading;
   Object obj;
@@ -486,7 +486,7 @@ GfxShading *GfxResources::lookupShading(char *name, Gfx *gfx) {
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
     if (resPtr->shadingDict.isDict()) {
       if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) {
-	shading = GfxShading::parse(&obj, gfx);
+	shading = GfxShading::parse(&obj, out);
 	obj.free();
 	return shading;
       }
@@ -537,9 +537,6 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, int pageNum, Dict *resDict,
 	 PDFRectangle *cropBox, int rotate,
 	 GBool (*abortCheckCbkA)(void *data),
 	 void *abortCheckCbkDataA, XRef *xrefA)
-#ifdef USE_CMS
- : iccColorSpaceCache(5)
-#endif
 {
   int i;
 
@@ -592,9 +589,6 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, Dict *resDict,
 	 PDFRectangle *box, PDFRectangle *cropBox,
 	 GBool (*abortCheckCbkA)(void *data),
 	 void *abortCheckCbkDataA, XRef *xrefA)
- #ifdef USE_CMS
- : iccColorSpaceCache(5)
-#endif
 {
   int i;
 
@@ -1188,7 +1182,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
 	  blendingColorSpace = NULL;
 	  isolated = knockout = gFalse;
 	  if (!obj4.dictLookup("CS", &obj5)->isNull()) {
-	    blendingColorSpace = GfxColorSpace::parse(&obj5, this);
+	    blendingColorSpace = GfxColorSpace::parse(&obj5, out);
 	  }
 	  obj5.free();
 	  if (obj4.dictLookup("I", &obj5)->isBool()) {
@@ -1390,7 +1384,7 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
   state->setFillPattern(NULL);
   res->lookupColorSpace("DefaultGray", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceGrayColorSpace();
@@ -1411,7 +1405,7 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultGray", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceGrayColorSpace();
@@ -1432,7 +1426,7 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
 
   res->lookupColorSpace("DefaultCMYK", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceCMYKColorSpace();
@@ -1457,7 +1451,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultCMYK", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceCMYKColorSpace();
@@ -1481,7 +1475,7 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   state->setFillPattern(NULL);
   res->lookupColorSpace("DefaultRGB", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceRGBColorSpace();
@@ -1505,7 +1499,7 @@ void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultRGB", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceRGBColorSpace();
@@ -1527,9 +1521,9 @@ void Gfx::opSetFillColorSpace(Object args[], int numArgs) {
 
   res->lookupColorSpace(args[0].getName(), &obj);
   if (obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&args[0], this);
+    colorSpace = GfxColorSpace::parse(&args[0], out);
   } else {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   obj.free();
   if (colorSpace) {
@@ -1552,9 +1546,9 @@ void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace(args[0].getName(), &obj);
   if (obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&args[0], this);
+    colorSpace = GfxColorSpace::parse(&args[0], out);
   } else {
-    colorSpace = GfxColorSpace::parse(&obj, this);
+    colorSpace = GfxColorSpace::parse(&obj, out);
   }
   obj.free();
   if (colorSpace) {
@@ -1625,7 +1619,7 @@ void Gfx::opSetFillColorN(Object args[], int numArgs) {
     }
     if (numArgs > 0) {
       if (args[numArgs-1].isName() &&
-	  (pattern = res->lookupPattern(args[numArgs-1].getName(), this))) {
+	  (pattern = res->lookupPattern(args[numArgs-1].getName(), out))) {
         state->setFillPattern(pattern);
       }
     }
@@ -1677,7 +1671,7 @@ void Gfx::opSetStrokeColorN(Object args[], int numArgs) {
       return;
     }
     if (args[numArgs-1].isName() &&
-	(pattern = res->lookupPattern(args[numArgs-1].getName(), this))) {
+	(pattern = res->lookupPattern(args[numArgs-1].getName(), out))) {
       state->setStrokePattern(pattern);
     }
 
@@ -2387,7 +2381,7 @@ void Gfx::opShFill(Object args[], int numArgs) {
     return;
   }
 
-  if (!(shading = res->lookupShading(args[0].getName(), this))) {
+  if (!(shading = res->lookupShading(args[0].getName(), out))) {
     return;
   }
 
@@ -4344,14 +4338,14 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       }
     }
     if (!obj1.isNull()) {
-      colorSpace = GfxColorSpace::parse(&obj1, this);
+      colorSpace = GfxColorSpace::parse(&obj1, out);
     } else if (csMode == streamCSDeviceGray) {
       Object objCS;
       res->lookupColorSpace("DefaultGray", &objCS);
       if (objCS.isNull()) {
         colorSpace = new GfxDeviceGrayColorSpace();
       } else {
-        colorSpace = GfxColorSpace::parse(&objCS, this);
+        colorSpace = GfxColorSpace::parse(&objCS, out);
       }
       objCS.free();
     } else if (csMode == streamCSDeviceRGB) {
@@ -4360,7 +4354,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       if (objCS.isNull()) {
         colorSpace = new GfxDeviceRGBColorSpace();
       } else {
-        colorSpace = GfxColorSpace::parse(&objCS, this);
+        colorSpace = GfxColorSpace::parse(&objCS, out);
       }
       objCS.free();
     } else if (csMode == streamCSDeviceCMYK) {
@@ -4369,7 +4363,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       if (objCS.isNull()) {
         colorSpace = new GfxDeviceCMYKColorSpace();
       } else {
-        colorSpace = GfxColorSpace::parse(&objCS, this);
+        colorSpace = GfxColorSpace::parse(&objCS, out);
       }
       objCS.free();
     } else {
@@ -4464,7 +4458,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
 	  obj2.free();
 	}
       }
-      maskColorSpace = GfxColorSpace::parse(&obj1, this);
+      maskColorSpace = GfxColorSpace::parse(&obj1, out);
       obj1.free();
       if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
 	goto err1;
@@ -4760,7 +4754,7 @@ void Gfx::doForm(Object *str) {
   if (dict->lookup("Group", &obj1)->isDict()) {
     if (obj1.dictLookup("S", &obj2)->isName("Transparency")) {
       if (!obj1.dictLookup("CS", &obj3)->isNull()) {
-	blendingColorSpace = GfxColorSpace::parse(&obj3, this);
+	blendingColorSpace = GfxColorSpace::parse(&obj3, out);
       }
       obj3.free();
       if (obj1.dictLookup("I", &obj3)->isBool()) {
@@ -5388,10 +5382,3 @@ void Gfx::popResources() {
   delete res;
   res = resPtr;
 }
-
-#ifdef USE_CMS
-PopplerCache *Gfx::getIccColorSpaceCache()
-{
-  return &iccColorSpaceCache;
-}
-#endif
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index aa81e56..4107e8a 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -116,8 +116,8 @@ public:
   GBool lookupXObjectNF(char *name, Object *obj);
   GBool lookupMarkedContentNF(char *name, Object *obj);
   void lookupColorSpace(const char *name, Object *obj);
-  GfxPattern *lookupPattern(char *name, Gfx *gfx);
-  GfxShading *lookupShading(char *name, Gfx *gfx);
+  GfxPattern *lookupPattern(char *name, OutputDev *out);
+  GfxShading *lookupShading(char *name, OutputDev *out);
   GBool lookupGState(char *name, Object *obj);
   GBool lookupGStateNF(char *name, Object *obj);
 
@@ -194,10 +194,6 @@ public:
 
   void pushResources(Dict *resDict);
   void popResources();
- 
-#ifdef USE_CMS
-  PopplerCache *getIccColorSpaceCache();
-#endif
 
 private:
 
@@ -230,10 +226,6 @@ private:
   
   std::set<int> formsDrawing;	// the forms that are being drawn
 
-#ifdef USE_CMS
-  PopplerCache iccColorSpaceCache;
-#endif
-
   GBool				// callback to check for an abort
     (*abortCheckCbk)(void *data);
   void *abortCheckCbkData;
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 3e5e053..ea79465 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -16,7 +16,7 @@
 // Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc at gnome.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) 2009, 2012 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2009, 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 Christian Persch <chpe at gnome.org>
@@ -52,6 +52,7 @@
 #include "GfxFont.h"
 #include "GlobalParams.h"
 #include "PopplerCache.h"
+#include "OutputDev.h"
 
 //------------------------------------------------------------------------
 
@@ -255,7 +256,7 @@ GfxColorSpace::GfxColorSpace() {
 GfxColorSpace::~GfxColorSpace() {
 }
 
-GfxColorSpace *GfxColorSpace::parse(Object *csObj, Gfx *gfx, int recursion) {
+GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, int recursion) {
   GfxColorSpace *cs;
   Object obj1;
 
@@ -292,15 +293,15 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, Gfx *gfx, int recursion) {
     } else if (obj1.isName("Lab")) {
       cs = GfxLabColorSpace::parse(csObj->getArray());
     } else if (obj1.isName("ICCBased")) {
-      cs = GfxICCBasedColorSpace::parse(csObj->getArray(), gfx, recursion);
+      cs = GfxICCBasedColorSpace::parse(csObj->getArray(), out, recursion);
     } else if (obj1.isName("Indexed") || obj1.isName("I")) {
-      cs = GfxIndexedColorSpace::parse(csObj->getArray(), gfx, recursion);
+      cs = GfxIndexedColorSpace::parse(csObj->getArray(), out, recursion);
     } else if (obj1.isName("Separation")) {
-      cs = GfxSeparationColorSpace::parse(csObj->getArray(), gfx, recursion);
+      cs = GfxSeparationColorSpace::parse(csObj->getArray(), out, recursion);
     } else if (obj1.isName("DeviceN")) {
-      cs = GfxDeviceNColorSpace::parse(csObj->getArray(), gfx, recursion);
+      cs = GfxDeviceNColorSpace::parse(csObj->getArray(), out, recursion);
     } else if (obj1.isName("Pattern")) {
-      cs = GfxPatternColorSpace::parse(csObj->getArray(), gfx, recursion);
+      cs = GfxPatternColorSpace::parse(csObj->getArray(), out, recursion);
     } else {
       error(errSyntaxWarning, -1, "Bad color space");
     }
@@ -1625,7 +1626,7 @@ GfxColorSpace *GfxICCBasedColorSpace::copy() {
   return cs;
 }
 
-GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx, int recursion) {
+GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, int recursion) {
   GfxICCBasedColorSpace *cs;
   Ref iccProfileStreamA;
   int nCompsA;
@@ -1648,9 +1649,9 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
   obj1.free();
 #ifdef USE_CMS
   // check cache
-  if (gfx && iccProfileStreamA.num > 0) {
+  if (out && iccProfileStreamA.num > 0) {
     GfxICCBasedColorSpaceKey k(iccProfileStreamA.num, iccProfileStreamA.gen);
-    GfxICCBasedColorSpaceItem *item = static_cast<GfxICCBasedColorSpaceItem *>(gfx->getIccColorSpaceCache()->lookup(k));
+    GfxICCBasedColorSpaceItem *item = static_cast<GfxICCBasedColorSpaceItem *>(out->getIccColorSpaceCache()->lookup(k));
     if (item != NULL)
     {
       cs = static_cast<GfxICCBasedColorSpace*>(item->cs->copy());
@@ -1680,7 +1681,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
     nCompsA = 4;
   }
   if (dict->lookup("Alternate", &obj2)->isNull() ||
-      !(altA = GfxColorSpace::parse(&obj2, gfx, recursion + 1))) {
+      !(altA = GfxColorSpace::parse(&obj2, out, recursion + 1))) {
     switch (nCompsA) {
     case 1:
       altA = new GfxDeviceGrayColorSpace();
@@ -1762,10 +1763,10 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
   }
   obj1.free();
   // put this colorSpace into cache
-  if (gfx && iccProfileStreamA.num > 0) {
+  if (out && iccProfileStreamA.num > 0) {
     GfxICCBasedColorSpaceKey *k = new GfxICCBasedColorSpaceKey(iccProfileStreamA.num, iccProfileStreamA.gen);
     GfxICCBasedColorSpaceItem *item = new GfxICCBasedColorSpaceItem(cs);
-    gfx->getIccColorSpaceCache()->put(k, item);
+    out->getIccColorSpaceCache()->put(k, item);
   }
 #endif
   return cs;
@@ -1992,7 +1993,7 @@ GfxColorSpace *GfxIndexedColorSpace::copy() {
   return cs;
 }
 
-GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, Gfx *gfx, int recursion) {
+GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, OutputDev *out, int recursion) {
   GfxIndexedColorSpace *cs;
   GfxColorSpace *baseA;
   int indexHighA;
@@ -2005,7 +2006,7 @@ GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
     goto err1;
   }
   arr->get(1, &obj1);
-  if (!(baseA = GfxColorSpace::parse(&obj1, gfx, recursion + 1))) {
+  if (!(baseA = GfxColorSpace::parse(&obj1, out, recursion + 1))) {
     error(errSyntaxWarning, -1, "Bad Indexed color space (base color space)");
     goto err2;
   }
@@ -2227,7 +2228,7 @@ GfxColorSpace *GfxSeparationColorSpace::copy() {
 }
 
 //~ handle the 'All' and 'None' colorants
-GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, Gfx *gfx, int recursion) {
+GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, OutputDev *out, int recursion) {
   GfxSeparationColorSpace *cs;
   GooString *nameA;
   GfxColorSpace *altA;
@@ -2245,7 +2246,7 @@ GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, Gfx *gfx, int recursio
   nameA = new GooString(obj1.getName());
   obj1.free();
   arr->get(2, &obj1);
-  if (!(altA = GfxColorSpace::parse(&obj1, gfx, recursion + 1))) {
+  if (!(altA = GfxColorSpace::parse(&obj1, out, recursion + 1))) {
     error(errSyntaxWarning, -1, "Bad Separation color space (alternate color space)");
     goto err3;
   }
@@ -2476,7 +2477,7 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
 }
 
 //~ handle the 'None' colorant
-GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, Gfx *gfx, int recursion) {
+GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, int recursion) {
   GfxDeviceNColorSpace *cs;
   int nCompsA;
   GooString *namesA[gfxColorMaxComps];
@@ -2511,7 +2512,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
   }
   obj1.free();
   arr->get(2, &obj1);
-  if (!(altA = GfxColorSpace::parse(&obj1, gfx, recursion + 1))) {
+  if (!(altA = GfxColorSpace::parse(&obj1, out, recursion + 1))) {
     error(errSyntaxWarning, -1, "Bad DeviceN color space (alternate color space)");
     goto err3;
   }
@@ -2533,7 +2534,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
       for (i = 0; i < colorants->getLength(); i++) {
         Object obj3;
         colorants->getVal(i, &obj3);
-        separationList->append(GfxSeparationColorSpace::parse(obj3.getArray(), gfx, recursion));
+        separationList->append(GfxSeparationColorSpace::parse(obj3.getArray(), out, recursion));
         obj3.free();
       }
     }
@@ -2735,7 +2736,7 @@ GfxColorSpace *GfxPatternColorSpace::copy() {
 				          (GfxColorSpace *)NULL);
 }
 
-GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, Gfx *gfx, int recursion) {
+GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, OutputDev *out, int recursion) {
   GfxPatternColorSpace *cs;
   GfxColorSpace *underA;
   Object obj1;
@@ -2747,7 +2748,7 @@ GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
   underA = NULL;
   if (arr->getLength() == 2) {
     arr->get(1, &obj1);
-    if (!(underA = GfxColorSpace::parse(&obj1, gfx, recursion + 1))) {
+    if (!(underA = GfxColorSpace::parse(&obj1, out, recursion + 1))) {
       error(errSyntaxWarning, -1, "Bad Pattern color space (underlying color space)");
       obj1.free();
       return NULL;
@@ -2792,7 +2793,7 @@ GfxPattern::GfxPattern(int typeA) {
 GfxPattern::~GfxPattern() {
 }
 
-GfxPattern *GfxPattern::parse(Object *obj, Gfx *gfx) {
+GfxPattern *GfxPattern::parse(Object *obj, OutputDev *out) {
   GfxPattern *pattern;
   Object obj1;
 
@@ -2807,7 +2808,7 @@ GfxPattern *GfxPattern::parse(Object *obj, Gfx *gfx) {
   if (obj1.isInt() && obj1.getInt() == 1) {
     pattern = GfxTilingPattern::parse(obj);
   } else if (obj1.isInt() && obj1.getInt() == 2) {
-    pattern = GfxShadingPattern::parse(obj, gfx);
+    pattern = GfxShadingPattern::parse(obj, out);
   }
   obj1.free();
   return pattern;
@@ -2935,7 +2936,7 @@ GfxPattern *GfxTilingPattern::copy() {
 // GfxShadingPattern
 //------------------------------------------------------------------------
 
-GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, Gfx *gfx) {
+GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, OutputDev *out) {
   Dict *dict;
   GfxShading *shadingA;
   double matrixA[6];
@@ -2948,7 +2949,7 @@ GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, Gfx *gfx) {
   dict = patObj->getDict();
 
   dict->lookup("Shading", &obj1);
-  shadingA = GfxShading::parse(&obj1, gfx);
+  shadingA = GfxShading::parse(&obj1, out);
   obj1.free();
   if (!shadingA) {
     return NULL;
@@ -3021,7 +3022,7 @@ GfxShading::~GfxShading() {
   }
 }
 
-GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
+GfxShading *GfxShading::parse(Object *obj, OutputDev *out) {
   GfxShading *shading;
   Dict *dict;
   int typeA;
@@ -3045,17 +3046,17 @@ GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
 
   switch (typeA) {
   case 1:
-    shading = GfxFunctionShading::parse(dict, gfx);
+    shading = GfxFunctionShading::parse(dict, out);
     break;
   case 2:
-    shading = GfxAxialShading::parse(dict, gfx);
+    shading = GfxAxialShading::parse(dict, out);
     break;
   case 3:
-    shading = GfxRadialShading::parse(dict, gfx);
+    shading = GfxRadialShading::parse(dict, out);
     break;
   case 4:
     if (obj->isStream()) {
-      shading = GfxGouraudTriangleShading::parse(4, dict, obj->getStream(), gfx);
+      shading = GfxGouraudTriangleShading::parse(4, dict, obj->getStream(), out);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 4 shading object");
       goto err1;
@@ -3063,7 +3064,7 @@ GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
     break;
   case 5:
     if (obj->isStream()) {
-      shading = GfxGouraudTriangleShading::parse(5, dict, obj->getStream(), gfx);
+      shading = GfxGouraudTriangleShading::parse(5, dict, obj->getStream(), out);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 5 shading object");
       goto err1;
@@ -3071,7 +3072,7 @@ GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
     break;
   case 6:
     if (obj->isStream()) {
-      shading = GfxPatchMeshShading::parse(6, dict, obj->getStream(), gfx);
+      shading = GfxPatchMeshShading::parse(6, dict, obj->getStream(), out);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 6 shading object");
       goto err1;
@@ -3079,7 +3080,7 @@ GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
     break;
   case 7:
     if (obj->isStream()) {
-      shading = GfxPatchMeshShading::parse(7, dict, obj->getStream(), gfx);
+      shading = GfxPatchMeshShading::parse(7, dict, obj->getStream(), out);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 7 shading object");
       goto err1;
@@ -3096,12 +3097,12 @@ GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
   return NULL;
 }
 
-GBool GfxShading::init(Dict *dict, Gfx *gfx) {
+GBool GfxShading::init(Dict *dict, OutputDev *out) {
   Object obj1, obj2;
   int i;
 
   dict->lookup("ColorSpace", &obj1);
-  if (!(colorSpace = GfxColorSpace::parse(&obj1, gfx))) {
+  if (!(colorSpace = GfxColorSpace::parse(&obj1, out))) {
     error(errSyntaxWarning, -1, "Bad color space in shading dictionary");
     obj1.free();
     return gFalse;
@@ -3208,7 +3209,7 @@ GfxFunctionShading::~GfxFunctionShading() {
   }
 }
 
-GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, Gfx *gfx) {
+GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, OutputDev *out) {
   GfxFunctionShading *shading;
   double x0A, y0A, x1A, y1A;
   double matrixA[6];
@@ -3276,7 +3277,7 @@ GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, Gfx *gfx) {
 
   shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA,
 				   funcsA, nFuncsA);
-  if (!shading->init(dict, gfx)) {
+  if (!shading->init(dict, out)) {
     delete shading;
     return NULL;
   }
@@ -3527,7 +3528,7 @@ GfxAxialShading::GfxAxialShading(GfxAxialShading *shading):
 GfxAxialShading::~GfxAxialShading() {
 }
 
-GfxAxialShading *GfxAxialShading::parse(Dict *dict, Gfx *gfx) {
+GfxAxialShading *GfxAxialShading::parse(Dict *dict, OutputDev *out) {
   GfxAxialShading *shading;
   double x0A, y0A, x1A, y1A;
   double t0A, t1A;
@@ -3624,7 +3625,7 @@ GfxAxialShading *GfxAxialShading::parse(Dict *dict, Gfx *gfx) {
 
   shading = new GfxAxialShading(x0A, y0A, x1A, y1A, t0A, t1A,
 				funcsA, nFuncsA, extend0A, extend1A);
-  if (!shading->init(dict, gfx)) {
+  if (!shading->init(dict, out)) {
     delete shading;
     return NULL;
   }
@@ -3735,7 +3736,7 @@ GfxRadialShading::GfxRadialShading(GfxRadialShading *shading):
 GfxRadialShading::~GfxRadialShading() {
 }
 
-GfxRadialShading *GfxRadialShading::parse(Dict *dict, Gfx *gfx) {
+GfxRadialShading *GfxRadialShading::parse(Dict *dict, OutputDev *out) {
   GfxRadialShading *shading;
   double x0A, y0A, r0A, x1A, y1A, r1A;
   double t0A, t1A;
@@ -3814,7 +3815,7 @@ GfxRadialShading *GfxRadialShading::parse(Dict *dict, Gfx *gfx) {
 
   shading = new GfxRadialShading(x0A, y0A, r0A, x1A, y1A, r1A, t0A, t1A,
 				 funcsA, nFuncsA, extend0A, extend1A);
-  if (!shading->init(dict, gfx)) {
+  if (!shading->init(dict, out)) {
     delete shading;
     return NULL;
   }
@@ -4258,7 +4259,7 @@ GfxGouraudTriangleShading::~GfxGouraudTriangleShading() {
 GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
 							    Dict *dict,
 							    Stream *str,
-							    Gfx *gfx) {
+							    OutputDev *out) {
   GfxGouraudTriangleShading *shading;
   Function *funcsA[gfxColorMaxComps];
   int nFuncsA;
@@ -4454,7 +4455,7 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
   shading = new GfxGouraudTriangleShading(typeA, verticesA, nVerticesA,
 					  trianglesA, nTrianglesA,
 					  funcsA, nFuncsA);
-  if (!shading->init(dict, gfx)) {
+  if (!shading->init(dict, out)) {
     delete shading;
     return NULL;
   }
@@ -4601,7 +4602,7 @@ GfxPatchMeshShading::~GfxPatchMeshShading() {
 }
 
 GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
-						Stream *str, Gfx *gfx) {
+						Stream *str, OutputDev *out) {
   GfxPatchMeshShading *shading;
   Function *funcsA[gfxColorMaxComps];
   int nFuncsA;
@@ -5125,7 +5126,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
 
   shading = new GfxPatchMeshShading(typeA, patchesA, nPatchesA,
 				    funcsA, nFuncsA);
-  if (!shading->init(dict, gfx)) {
+  if (!shading->init(dict, out)) {
     delete shading;
     return NULL;
   }
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index aa15a75..2f3efcf 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2006 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2009-2011 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009-2011, 2013 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
 // Copyright (C) 2011 Andrea Canciani <ranma42 at gmail.com>
 // Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
@@ -50,6 +50,7 @@ class PDFRectangle;
 class GfxShading;
 class PopplerCache;
 class GooList;
+class OutputDev;
 
 class Matrix {
 public:
@@ -198,7 +199,7 @@ public:
   virtual GfxColorSpaceMode getMode() = 0;
 
   // Construct a color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Object *csObj, Gfx *gfx, int recursion = 0);
+  static GfxColorSpace *parse(Object *csObj, OutputDev *out, int recursion = 0);
 
   // Convert to gray, RGB, or CMYK.
   virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
@@ -492,7 +493,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csICCBased; }
 
   // Construct an ICCBased color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, Gfx *gfx, int recursion);
+  static GfxColorSpace *parse(Array *arr, OutputDev *out, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -538,7 +539,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csIndexed; }
 
   // Construct an Indexed color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, Gfx *gfx, int recursion);
+  static GfxColorSpace *parse(Array *arr, OutputDev *out, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -587,7 +588,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csSeparation; }
 
   // Construct a Separation color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, Gfx *gfx, int recursion);
+  static GfxColorSpace *parse(Array *arr, OutputDev *out, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -632,7 +633,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csDeviceN; }
 
   // Construct a DeviceN color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, Gfx *gfx, int recursion);
+  static GfxColorSpace *parse(Array *arr, OutputDev *out, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -679,7 +680,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csPattern; }
 
   // Construct a Pattern color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, Gfx *gfx, int recursion);
+  static GfxColorSpace *parse(Array *arr, OutputDev *out, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -708,7 +709,7 @@ public:
   GfxPattern(int typeA);
   virtual ~GfxPattern();
 
-  static GfxPattern *parse(Object *obj, Gfx *gfx);
+  static GfxPattern *parse(Object *obj, OutputDev *out);
 
   virtual GfxPattern *copy() = 0;
 
@@ -764,7 +765,7 @@ private:
 class GfxShadingPattern: public GfxPattern {
 public:
 
-  static GfxShadingPattern *parse(Object *patObj, Gfx *gfx);
+  static GfxShadingPattern *parse(Object *patObj, OutputDev *out);
   virtual ~GfxShadingPattern();
 
   virtual GfxPattern *copy();
@@ -791,7 +792,7 @@ public:
   GfxShading(GfxShading *shading);
   virtual ~GfxShading();
 
-  static GfxShading *parse(Object *obj, Gfx *gfx);
+  static GfxShading *parse(Object *obj, OutputDev *out);
 
   virtual GfxShading *copy() = 0;
 
@@ -805,7 +806,7 @@ public:
 
 protected:
 
-  GBool init(Dict *dict, Gfx *gfx);
+  GBool init(Dict *dict, OutputDev *out);
 
   int type;
   GfxColorSpace *colorSpace;
@@ -874,7 +875,7 @@ public:
   GfxFunctionShading(GfxFunctionShading *shading);
   virtual ~GfxFunctionShading();
 
-  static GfxFunctionShading *parse(Dict *dict, Gfx *gfx);
+  static GfxFunctionShading *parse(Dict *dict, OutputDev *out);
 
   virtual GfxShading *copy();
 
@@ -908,7 +909,7 @@ public:
   GfxAxialShading(GfxAxialShading *shading);
   virtual ~GfxAxialShading();
 
-  static GfxAxialShading *parse(Dict *dict, Gfx *gfx);
+  static GfxAxialShading *parse(Dict *dict, OutputDev *out);
 
   virtual GfxShading *copy();
 
@@ -941,7 +942,7 @@ public:
   GfxRadialShading(GfxRadialShading *shading);
   virtual ~GfxRadialShading();
 
-  static GfxRadialShading *parse(Dict *dict, Gfx *gfx);
+  static GfxRadialShading *parse(Dict *dict, OutputDev *out);
 
   virtual GfxShading *copy();
 
@@ -979,7 +980,7 @@ public:
   GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading);
   virtual ~GfxGouraudTriangleShading();
 
-  static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str, Gfx *gfx);
+  static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str, OutputDev *out);
 
   virtual GfxShading *copy();
 
@@ -1065,7 +1066,7 @@ public:
   GfxPatchMeshShading(GfxPatchMeshShading *shading);
   virtual ~GfxPatchMeshShading();
 
-  static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str, Gfx *gfx);
+  static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str, OutputDev *out);
 
   virtual GfxShading *copy();
 
diff --git a/poppler/OutputDev.cc b/poppler/OutputDev.cc
index 54580d0..ee3cf5a 100644
--- a/poppler/OutputDev.cc
+++ b/poppler/OutputDev.cc
@@ -17,7 +17,7 @@
 // Copyright (C) 2006 Thorkild Stray <thorkild at ifi.uio.no>
 // Copyright (C) 2007 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright (C) 2009, 2012 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009, 2012, 2013 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
@@ -193,3 +193,9 @@ GooHash *OutputDev::endProfile() {
   return profile;
 }
 
+#ifdef USE_CMS
+PopplerCache *OutputDev::getIccColorSpaceCache()
+{
+  return &iccColorSpaceCache;
+}
+#endif
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index abccffe..e8a7a47 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -19,7 +19,7 @@
 // Copyright (C) 2007, 2011 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009, 2011 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright (C) 2009, 2012 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009, 2012, 2013 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
 // Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
 // Copyright (C) 2012 William Bader <williambader at hotmail.com>
@@ -40,6 +40,7 @@
 #include "goo/gtypes.h"
 #include "CharTypes.h"
 #include "Object.h"
+#include "PopplerCache.h"
 
 class Annot;
 class Dict;
@@ -72,7 +73,13 @@ class OutputDev {
 public:
 
   // Constructor.
-  OutputDev() { profileHash = NULL; }
+  OutputDev() 
+#ifdef USE_CMS
+ : iccColorSpaceCache(5)
+#endif
+  {
+      profileHash = NULL;
+  }
 
   // Destructor.
   virtual ~OutputDev() {}
@@ -325,11 +332,19 @@ public:
   virtual void setVectorAntialias(GBool /*vaa*/) {}
 #endif
 
+#ifdef USE_CMS
+  PopplerCache *getIccColorSpaceCache();
+#endif
+
 private:
 
   double defCTM[6];		// default coordinate transform matrix
   double defICTM[6];		// inverse of default CTM
   GooHash *profileHash;
+
+#ifdef USE_CMS
+  PopplerCache iccColorSpaceCache;
+#endif
 };
 
 #endif


More information about the poppler mailing list