[poppler] poppler/Gfx.cc poppler/Gfx.h poppler/GfxState.cc poppler/GfxState.h poppler/Page.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Oct 23 13:01:48 PDT 2009


 poppler/Gfx.cc      |   49 +++++++++++++++++----------
 poppler/Gfx.h       |   13 ++++++-
 poppler/GfxState.cc |   94 +++++++++++++++++++++++++---------------------------
 poppler/GfxState.h  |   33 ++++++++----------
 poppler/Page.cc     |    4 +-
 5 files changed, 107 insertions(+), 86 deletions(-)

New commits:
commit b174ebd6b323c7a58a19d59c1a9e4ac4e6cba7d9
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Oct 23 21:57:42 2009 +0200

    Move the iccColorSpaceCache from a static in GfxState to a member of Gfx
    
    Fixes the problem that the keys are per document but we had a static
    that lived as much as the library. Now the cache only lives the rendering
    of a page so it's a bit slower but at least it's correct. Fixes bug 24686

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index ca9b513..eeabd87 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -440,7 +440,7 @@ void GfxResources::lookupColorSpace(char *name, Object *obj) {
   obj->initNull();
 }
 
-GfxPattern *GfxResources::lookupPattern(char *name) {
+GfxPattern *GfxResources::lookupPattern(char *name, Gfx *gfx) {
   GfxResources *resPtr;
   GfxPattern *pattern;
   Object obj;
@@ -448,7 +448,7 @@ GfxPattern *GfxResources::lookupPattern(char *name) {
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
     if (resPtr->patternDict.isDict()) {
       if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) {
-	pattern = GfxPattern::parse(&obj);
+	pattern = GfxPattern::parse(&obj, gfx);
 	obj.free();
 	return pattern;
       }
@@ -459,7 +459,7 @@ GfxPattern *GfxResources::lookupPattern(char *name) {
   return NULL;
 }
 
-GfxShading *GfxResources::lookupShading(char *name) {
+GfxShading *GfxResources::lookupShading(char *name, Gfx *gfx) {
   GfxResources *resPtr;
   GfxShading *shading;
   Object obj;
@@ -467,7 +467,7 @@ GfxShading *GfxResources::lookupShading(char *name) {
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
     if (resPtr->shadingDict.isDict()) {
       if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) {
-	shading = GfxShading::parse(&obj);
+	shading = GfxShading::parse(&obj, gfx);
 	obj.free();
 	return shading;
       }
@@ -501,7 +501,11 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata
 	 double hDPI, double vDPI, PDFRectangle *box,
 	 PDFRectangle *cropBox, int rotate,
 	 GBool (*abortCheckCbkA)(void *data),
-	 void *abortCheckCbkDataA) {
+	 void *abortCheckCbkDataA)
+#ifdef USE_CMS
+ : iccColorSpaceCache(5)
+#endif
+{
   int i;
 
   xref = xrefA;
@@ -549,7 +553,11 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata
 Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA,
 	 PDFRectangle *box, PDFRectangle *cropBox,
 	 GBool (*abortCheckCbkA)(void *data),
-	 void *abortCheckCbkDataA) {
+	 void *abortCheckCbkDataA)
+ #ifdef USE_CMS
+ : iccColorSpaceCache(5)
+#endif
+{
   int i;
 
   xref = xrefA;
@@ -1057,7 +1065,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
 	  blendingColorSpace = NULL;
 	  isolated = knockout = gFalse;
 	  if (!obj4.dictLookup("CS", &obj5)->isNull()) {
-	    blendingColorSpace = GfxColorSpace::parse(&obj5);
+	    blendingColorSpace = GfxColorSpace::parse(&obj5, this);
 	  }
 	  obj5.free();
 	  if (obj4.dictLookup("I", &obj5)->isBool()) {
@@ -1364,9 +1372,9 @@ void Gfx::opSetFillColorSpace(Object args[], int numArgs) {
   state->setFillPattern(NULL);
   res->lookupColorSpace(args[0].getName(), &obj);
   if (obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&args[0]);
+    colorSpace = GfxColorSpace::parse(&args[0], this);
   } else {
-    colorSpace = GfxColorSpace::parse(&obj);
+    colorSpace = GfxColorSpace::parse(&obj, this);
   }
   obj.free();
   if (colorSpace) {
@@ -1406,9 +1414,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]);
+    colorSpace = GfxColorSpace::parse(&args[0], this);
   } else {
-    colorSpace = GfxColorSpace::parse(&obj);
+    colorSpace = GfxColorSpace::parse(&obj, this);
   }
   obj.free();
   if (colorSpace) {
@@ -1476,7 +1484,7 @@ void Gfx::opSetFillColorN(Object args[], int numArgs) {
       out->updateFillColor(state);
     }
     if (args[numArgs-1].isName() &&
-	(pattern = res->lookupPattern(args[numArgs-1].getName()))) {
+	(pattern = res->lookupPattern(args[numArgs-1].getName(), this))) {
       state->setFillPattern(pattern);
     }
 
@@ -1519,7 +1527,7 @@ void Gfx::opSetStrokeColorN(Object args[], int numArgs) {
       out->updateStrokeColor(state);
     }
     if (args[numArgs-1].isName() &&
-	(pattern = res->lookupPattern(args[numArgs-1].getName()))) {
+	(pattern = res->lookupPattern(args[numArgs-1].getName(), this))) {
       state->setStrokePattern(pattern);
     }
 
@@ -2149,7 +2157,7 @@ void Gfx::opShFill(Object args[], int numArgs) {
   GfxPath *savedPath;
   double xMin, yMin, xMax, yMax;
 
-  if (!(shading = res->lookupShading(args[0].getName()))) {
+  if (!(shading = res->lookupShading(args[0].getName(), this))) {
     return;
   }
 
@@ -3903,7 +3911,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       }
     }
     if (!obj1.isNull()) {
-      colorSpace = GfxColorSpace::parse(&obj1);
+      colorSpace = GfxColorSpace::parse(&obj1, this);
     } else if (csMode == streamCSDeviceGray) {
       colorSpace = new GfxDeviceGrayColorSpace();
     } else if (csMode == streamCSDeviceRGB) {
@@ -3998,7 +4006,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
 	  obj2.free();
 	}
       }
-      maskColorSpace = GfxColorSpace::parse(&obj1);
+      maskColorSpace = GfxColorSpace::parse(&obj1, this);
       obj1.free();
       if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
 	goto err1;
@@ -4199,7 +4207,7 @@ void Gfx::doForm(Object *str) {
     if (obj1.dictLookup("S", &obj2)->isName("Transparency")) {
       transpGroup = gTrue;
       if (!obj1.dictLookup("CS", &obj3)->isNull()) {
-	blendingColorSpace = GfxColorSpace::parse(&obj3);
+	blendingColorSpace = GfxColorSpace::parse(&obj3, this);
       }
       obj3.free();
       if (obj1.dictLookup("I", &obj3)->isBool()) {
@@ -4727,3 +4735,10 @@ 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 e03d025..bb76260 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -36,6 +36,7 @@
 #include "goo/GooList.h"
 #include "GfxState.h"
 #include "Object.h"
+#include "PopplerCache.h"
 
 class GooString;
 class XRef;
@@ -109,8 +110,8 @@ public:
   GBool lookupXObjectNF(char *name, Object *obj);
   GBool lookupMarkedContentNF(char *name, Object *obj);
   void lookupColorSpace(char *name, Object *obj);
-  GfxPattern *lookupPattern(char *name);
-  GfxShading *lookupShading(char *name);
+  GfxPattern *lookupPattern(char *name, Gfx *gfx);
+  GfxShading *lookupShading(char *name, Gfx *gfx);
   GBool lookupGState(char *name, Object *obj);
 
   GfxResources *getNext() { return next; }
@@ -168,6 +169,10 @@ public:
 
   void pushResources(Dict *resDict);
   void popResources();
+  
+#ifdef USE_CMS
+  PopplerCache *getIccColorSpaceCache();
+#endif
 
 private:
 
@@ -196,6 +201,10 @@ private:
   MarkedContentStack *mcStack;	// current BMC/EMC stack
 
   Parser *parser;		// parser for page content stream(s)
+ 
+#ifdef USE_CMS
+  PopplerCache iccColorSpaceCache;
+#endif
 
   GBool				// callback to check for an abort
     (*abortCheckCbk)(void *data);
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 8595455..0dc02b4 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -40,6 +40,7 @@
 #include "Object.h"
 #include "Array.h"
 #include "Page.h"
+#include "Gfx.h"
 #include "GfxState.h"
 #include "GfxState_helpers.h"
 #include "GfxFont.h"
@@ -192,7 +193,7 @@ GfxColorSpace::GfxColorSpace() {
 GfxColorSpace::~GfxColorSpace() {
 }
 
-GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
+GfxColorSpace *GfxColorSpace::parse(Object *csObj, Gfx *gfx) {
   GfxColorSpace *cs;
   Object obj1;
 
@@ -224,15 +225,15 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
     } else if (obj1.isName("Lab")) {
       cs = GfxLabColorSpace::parse(csObj->getArray());
     } else if (obj1.isName("ICCBased")) {
-      cs = GfxICCBasedColorSpace::parse(csObj->getArray());
+      cs = GfxICCBasedColorSpace::parse(csObj->getArray(), gfx);
     } else if (obj1.isName("Indexed") || obj1.isName("I")) {
-      cs = GfxIndexedColorSpace::parse(csObj->getArray());
+      cs = GfxIndexedColorSpace::parse(csObj->getArray(), gfx);
     } else if (obj1.isName("Separation")) {
-      cs = GfxSeparationColorSpace::parse(csObj->getArray());
+      cs = GfxSeparationColorSpace::parse(csObj->getArray(), gfx);
     } else if (obj1.isName("DeviceN")) {
-      cs = GfxDeviceNColorSpace::parse(csObj->getArray());
+      cs = GfxDeviceNColorSpace::parse(csObj->getArray(), gfx);
     } else if (obj1.isName("Pattern")) {
-      cs = GfxPatternColorSpace::parse(csObj->getArray());
+      cs = GfxPatternColorSpace::parse(csObj->getArray(), gfx);
     } else {
       error(-1, "Bad color space");
     }
@@ -1392,7 +1393,7 @@ GfxColorSpace *GfxICCBasedColorSpace::copy() {
   return cs;
 }
 
-GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
+GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx) {
   GfxICCBasedColorSpace *cs;
   Ref iccProfileStreamA;
   int nCompsA;
@@ -1411,9 +1412,9 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
   obj1.free();
 #ifdef USE_CMS
   // check cache
-  if (iccProfileStreamA.num > 0) {
+  if (gfx && iccProfileStreamA.num > 0) {
     GfxICCBasedColorSpaceKey k(iccProfileStreamA.num, iccProfileStreamA.gen);
-    GfxICCBasedColorSpaceItem *item = static_cast<GfxICCBasedColorSpaceItem *>(cache->lookup(k));
+    GfxICCBasedColorSpaceItem *item = static_cast<GfxICCBasedColorSpaceItem *>(gfx->getIccColorSpaceCache()->lookup(k));
     if (item != NULL)
     {
       cs = static_cast<GfxICCBasedColorSpace*>(item->cs->copy());
@@ -1442,7 +1443,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
     nCompsA = gfxColorMaxComps;
   }
   if (dict->lookup("Alternate", &obj2)->isNull() ||
-      !(altA = GfxColorSpace::parse(&obj2))) {
+      !(altA = GfxColorSpace::parse(&obj2, gfx))) {
     switch (nCompsA) {
     case 1:
       altA = new GfxDeviceGrayColorSpace();
@@ -1532,10 +1533,10 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
   }
   obj1.free();
   // put this colorSpace into cache
-  if (iccProfileStreamA.num > 0) {
+  if (gfx && iccProfileStreamA.num > 0) {
     GfxICCBasedColorSpaceKey *k = new GfxICCBasedColorSpaceKey(iccProfileStreamA.num, iccProfileStreamA.gen);
     GfxICCBasedColorSpaceItem *item = new GfxICCBasedColorSpaceItem(cs);
-    cache->put(k, item);
+    gfx->getIccColorSpaceCache()->put(k, item);
   }
 #endif
   return cs;
@@ -1683,10 +1684,6 @@ void GfxICCBasedColorSpace::getDefaultRanges(double *decodeLow,
 #endif
 }
 
-#ifdef USE_CMS
-PopplerCache *GfxICCBasedColorSpace::cache = new PopplerCache(5);
-#endif
-
 //------------------------------------------------------------------------
 // GfxIndexedColorSpace
 //------------------------------------------------------------------------
@@ -1713,7 +1710,7 @@ GfxColorSpace *GfxIndexedColorSpace::copy() {
   return cs;
 }
 
-GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr) {
+GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, Gfx *gfx) {
   GfxIndexedColorSpace *cs;
   GfxColorSpace *baseA;
   int indexHighA;
@@ -1727,7 +1724,7 @@ GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr) {
     goto err1;
   }
   arr->get(1, &obj1);
-  if (!(baseA = GfxColorSpace::parse(&obj1))) {
+  if (!(baseA = GfxColorSpace::parse(&obj1, gfx))) {
     error(-1, "Bad Indexed color space (base color space)");
     goto err2;
   }
@@ -1873,7 +1870,7 @@ GfxColorSpace *GfxSeparationColorSpace::copy() {
 }
 
 //~ handle the 'All' and 'None' colorants
-GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr) {
+GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, Gfx *gfx) {
   GfxSeparationColorSpace *cs;
   GooString *nameA;
   GfxColorSpace *altA;
@@ -1891,7 +1888,7 @@ GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr) {
   nameA = new GooString(obj1.getName());
   obj1.free();
   arr->get(2, &obj1);
-  if (!(altA = GfxColorSpace::parse(&obj1))) {
+  if (!(altA = GfxColorSpace::parse(&obj1, gfx))) {
     error(-1, "Bad Separation color space (alternate color space)");
     goto err3;
   }
@@ -1996,7 +1993,7 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
 }
 
 //~ handle the 'None' colorant
-GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr) {
+GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, Gfx *gfx) {
   GfxDeviceNColorSpace *cs;
   int nCompsA;
   GooString *namesA[gfxColorMaxComps];
@@ -2030,7 +2027,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr) {
   }
   obj1.free();
   arr->get(2, &obj1);
-  if (!(altA = GfxColorSpace::parse(&obj1))) {
+  if (!(altA = GfxColorSpace::parse(&obj1, gfx))) {
     error(-1, "Bad DeviceN color space (alternate color space)");
     goto err3;
   }
@@ -2134,7 +2131,7 @@ GfxColorSpace *GfxPatternColorSpace::copy() {
 				          (GfxColorSpace *)NULL);
 }
 
-GfxColorSpace *GfxPatternColorSpace::parse(Array *arr) {
+GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, Gfx *gfx) {
   GfxPatternColorSpace *cs;
   GfxColorSpace *underA;
   Object obj1;
@@ -2146,7 +2143,7 @@ GfxColorSpace *GfxPatternColorSpace::parse(Array *arr) {
   underA = NULL;
   if (arr->getLength() == 2) {
     arr->get(1, &obj1);
-    if (!(underA = GfxColorSpace::parse(&obj1))) {
+    if (!(underA = GfxColorSpace::parse(&obj1, gfx))) {
       error(-1, "Bad Pattern color space (underlying color space)");
       obj1.free();
       return NULL;
@@ -2185,7 +2182,7 @@ GfxPattern::GfxPattern(int typeA) {
 GfxPattern::~GfxPattern() {
 }
 
-GfxPattern *GfxPattern::parse(Object *obj) {
+GfxPattern *GfxPattern::parse(Object *obj, Gfx *gfx) {
   GfxPattern *pattern;
   Object obj1;
 
@@ -2200,7 +2197,7 @@ GfxPattern *GfxPattern::parse(Object *obj) {
   if (obj1.isInt() && obj1.getInt() == 1) {
     pattern = GfxTilingPattern::parse(obj);
   } else if (obj1.isInt() && obj1.getInt() == 2) {
-    pattern = GfxShadingPattern::parse(obj);
+    pattern = GfxShadingPattern::parse(obj, gfx);
   }
   obj1.free();
   return pattern;
@@ -2328,7 +2325,7 @@ GfxPattern *GfxTilingPattern::copy() {
 // GfxShadingPattern
 //------------------------------------------------------------------------
 
-GfxShadingPattern *GfxShadingPattern::parse(Object *patObj) {
+GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, Gfx *gfx) {
   Dict *dict;
   GfxShading *shadingA;
   double matrixA[6];
@@ -2341,7 +2338,7 @@ GfxShadingPattern *GfxShadingPattern::parse(Object *patObj) {
   dict = patObj->getDict();
 
   dict->lookup("Shading", &obj1);
-  shadingA = GfxShading::parse(&obj1);
+  shadingA = GfxShading::parse(&obj1, gfx);
   obj1.free();
   if (!shadingA) {
     return NULL;
@@ -2414,7 +2411,7 @@ GfxShading::~GfxShading() {
   }
 }
 
-GfxShading *GfxShading::parse(Object *obj) {
+GfxShading *GfxShading::parse(Object *obj, Gfx *gfx) {
   GfxShading *shading;
   Dict *dict;
   int typeA;
@@ -2438,17 +2435,17 @@ GfxShading *GfxShading::parse(Object *obj) {
 
   switch (typeA) {
   case 1:
-    shading = GfxFunctionShading::parse(dict);
+    shading = GfxFunctionShading::parse(dict, gfx);
     break;
   case 2:
-    shading = GfxAxialShading::parse(dict);
+    shading = GfxAxialShading::parse(dict, gfx);
     break;
   case 3:
-    shading = GfxRadialShading::parse(dict);
+    shading = GfxRadialShading::parse(dict, gfx);
     break;
   case 4:
     if (obj->isStream()) {
-      shading = GfxGouraudTriangleShading::parse(4, dict, obj->getStream());
+      shading = GfxGouraudTriangleShading::parse(4, dict, obj->getStream(), gfx);
     } else {
       error(-1, "Invalid Type 4 shading object");
       goto err1;
@@ -2456,7 +2453,7 @@ GfxShading *GfxShading::parse(Object *obj) {
     break;
   case 5:
     if (obj->isStream()) {
-      shading = GfxGouraudTriangleShading::parse(5, dict, obj->getStream());
+      shading = GfxGouraudTriangleShading::parse(5, dict, obj->getStream(), gfx);
     } else {
       error(-1, "Invalid Type 5 shading object");
       goto err1;
@@ -2464,7 +2461,7 @@ GfxShading *GfxShading::parse(Object *obj) {
     break;
   case 6:
     if (obj->isStream()) {
-      shading = GfxPatchMeshShading::parse(6, dict, obj->getStream());
+      shading = GfxPatchMeshShading::parse(6, dict, obj->getStream(), gfx);
     } else {
       error(-1, "Invalid Type 6 shading object");
       goto err1;
@@ -2472,7 +2469,7 @@ GfxShading *GfxShading::parse(Object *obj) {
     break;
   case 7:
     if (obj->isStream()) {
-      shading = GfxPatchMeshShading::parse(7, dict, obj->getStream());
+      shading = GfxPatchMeshShading::parse(7, dict, obj->getStream(), gfx);
     } else {
       error(-1, "Invalid Type 7 shading object");
       goto err1;
@@ -2489,12 +2486,12 @@ GfxShading *GfxShading::parse(Object *obj) {
   return NULL;
 }
 
-GBool GfxShading::init(Dict *dict) {
+GBool GfxShading::init(Dict *dict, Gfx *gfx) {
   Object obj1, obj2;
   int i;
 
   dict->lookup("ColorSpace", &obj1);
-  if (!(colorSpace = GfxColorSpace::parse(&obj1))) {
+  if (!(colorSpace = GfxColorSpace::parse(&obj1, gfx))) {
     error(-1, "Bad color space in shading dictionary");
     obj1.free();
     return gFalse;
@@ -2591,7 +2588,7 @@ GfxFunctionShading::~GfxFunctionShading() {
   }
 }
 
-GfxFunctionShading *GfxFunctionShading::parse(Dict *dict) {
+GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, Gfx *gfx) {
   GfxFunctionShading *shading;
   double x0A, y0A, x1A, y1A;
   double matrixA[6];
@@ -2659,7 +2656,7 @@ GfxFunctionShading *GfxFunctionShading::parse(Dict *dict) {
 
   shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA,
 				   funcsA, nFuncsA);
-  if (!shading->init(dict)) {
+  if (!shading->init(dict, gfx)) {
     delete shading;
     return NULL;
   }
@@ -2749,7 +2746,7 @@ GfxAxialShading::~GfxAxialShading() {
   }
 }
 
-GfxAxialShading *GfxAxialShading::parse(Dict *dict) {
+GfxAxialShading *GfxAxialShading::parse(Dict *dict, Gfx *gfx) {
   GfxAxialShading *shading;
   double x0A, y0A, x1A, y1A;
   double t0A, t1A;
@@ -2824,7 +2821,7 @@ GfxAxialShading *GfxAxialShading::parse(Dict *dict) {
 
   shading = new GfxAxialShading(x0A, y0A, x1A, y1A, t0A, t1A,
 				funcsA, nFuncsA, extend0A, extend1A);
-  if (!shading->init(dict)) {
+  if (!shading->init(dict, gfx)) {
     delete shading;
     return NULL;
   }
@@ -2913,7 +2910,7 @@ GfxRadialShading::~GfxRadialShading() {
   }
 }
 
-GfxRadialShading *GfxRadialShading::parse(Dict *dict) {
+GfxRadialShading *GfxRadialShading::parse(Dict *dict, Gfx *gfx) {
   GfxRadialShading *shading;
   double x0A, y0A, r0A, x1A, y1A, r1A;
   double t0A, t1A;
@@ -2992,7 +2989,7 @@ GfxRadialShading *GfxRadialShading::parse(Dict *dict) {
 
   shading = new GfxRadialShading(x0A, y0A, r0A, x1A, y1A, r1A, t0A, t1A,
 				 funcsA, nFuncsA, extend0A, extend1A);
-  if (!shading->init(dict)) {
+  if (!shading->init(dict, gfx)) {
     delete shading;
     return NULL;
   }
@@ -3143,7 +3140,8 @@ GfxGouraudTriangleShading::~GfxGouraudTriangleShading() {
 
 GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
 							    Dict *dict,
-							    Stream *str) {
+							    Stream *str,
+							    Gfx *gfx) {
   GfxGouraudTriangleShading *shading;
   Function *funcsA[gfxColorMaxComps];
   int nFuncsA;
@@ -3339,7 +3337,7 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
   shading = new GfxGouraudTriangleShading(typeA, verticesA, nVerticesA,
 					  trianglesA, nTrianglesA,
 					  funcsA, nFuncsA);
-  if (!shading->init(dict)) {
+  if (!shading->init(dict, gfx)) {
     delete shading;
     return NULL;
   }
@@ -3451,7 +3449,7 @@ GfxPatchMeshShading::~GfxPatchMeshShading() {
 }
 
 GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
-						Stream *str) {
+						Stream *str, Gfx *gfx) {
   GfxPatchMeshShading *shading;
   Function *funcsA[gfxColorMaxComps];
   int nFuncsA;
@@ -3952,7 +3950,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
 
   shading = new GfxPatchMeshShading(typeA, patchesA, nPatchesA,
 				    funcsA, nFuncsA);
-  if (!shading->init(dict)) {
+  if (!shading->init(dict, gfx)) {
     delete shading;
     return NULL;
   }
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 458db60..7dccfd5 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -36,6 +36,7 @@
 #include "Function.h"
 
 class Array;
+class Gfx;
 class GfxFont;
 class PDFRectangle;
 class GfxShading;
@@ -178,7 +179,7 @@ public:
   virtual GfxColorSpaceMode getMode() = 0;
 
   // Construct a color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Object *csObj);
+  static GfxColorSpace *parse(Object *csObj, Gfx *gfx);
 
   // Convert to gray, RGB, or CMYK.
   virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
@@ -445,7 +446,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csICCBased; }
 
   // Construct an ICCBased color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr);
+  static GfxColorSpace *parse(Array *arr, Gfx *gfx);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -473,8 +474,6 @@ private:
 #ifdef USE_CMS
   GfxColorTransform *transform;
   GfxColorTransform *lineTransform; // color transform for line
-
-  static PopplerCache *cache;
 #endif
 };
 //------------------------------------------------------------------------
@@ -490,7 +489,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csIndexed; }
 
   // Construct a Lab color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr);
+  static GfxColorSpace *parse(Array *arr, Gfx *gfx);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -532,7 +531,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csSeparation; }
 
   // Construct a Separation color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr);
+  static GfxColorSpace *parse(Array *arr, Gfx *gfx);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -569,7 +568,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csDeviceN; }
 
   // Construct a DeviceN color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr);
+  static GfxColorSpace *parse(Array *arr, Gfx *gfx);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -608,7 +607,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csPattern; }
 
   // Construct a Pattern color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr);
+  static GfxColorSpace *parse(Array *arr, Gfx *gfx);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -636,7 +635,7 @@ public:
   GfxPattern(int typeA);
   virtual ~GfxPattern();
 
-  static GfxPattern *parse(Object *obj);
+  static GfxPattern *parse(Object *obj, Gfx *gfx);
 
   virtual GfxPattern *copy() = 0;
 
@@ -692,7 +691,7 @@ private:
 class GfxShadingPattern: public GfxPattern {
 public:
 
-  static GfxShadingPattern *parse(Object *patObj);
+  static GfxShadingPattern *parse(Object *patObj, Gfx *gfx);
   virtual ~GfxShadingPattern();
 
   virtual GfxPattern *copy();
@@ -719,7 +718,7 @@ public:
   GfxShading(GfxShading *shading);
   virtual ~GfxShading();
 
-  static GfxShading *parse(Object *obj);
+  static GfxShading *parse(Object *obj, Gfx *gfx);
 
   virtual GfxShading *copy() = 0;
 
@@ -733,7 +732,7 @@ public:
 
 protected:
 
-  GBool init(Dict *dict);
+  GBool init(Dict *dict, Gfx *gfx);
 
   int type;
   GfxColorSpace *colorSpace;
@@ -757,7 +756,7 @@ public:
   GfxFunctionShading(GfxFunctionShading *shading);
   virtual ~GfxFunctionShading();
 
-  static GfxFunctionShading *parse(Dict *dict);
+  static GfxFunctionShading *parse(Dict *dict, Gfx *gfx);
 
   virtual GfxShading *copy();
 
@@ -791,7 +790,7 @@ public:
   GfxAxialShading(GfxAxialShading *shading);
   virtual ~GfxAxialShading();
 
-  static GfxAxialShading *parse(Dict *dict);
+  static GfxAxialShading *parse(Dict *dict, Gfx *gfx);
 
   virtual GfxShading *copy();
 
@@ -829,7 +828,7 @@ public:
   GfxRadialShading(GfxRadialShading *shading);
   virtual ~GfxRadialShading();
 
-  static GfxRadialShading *parse(Dict *dict);
+  static GfxRadialShading *parse(Dict *dict, Gfx *gfx);
 
   virtual GfxShading *copy();
 
@@ -872,7 +871,7 @@ public:
   GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading);
   virtual ~GfxGouraudTriangleShading();
 
-  static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str);
+  static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str, Gfx *gfx);
 
   virtual GfxShading *copy();
 
@@ -909,7 +908,7 @@ public:
   GfxPatchMeshShading(GfxPatchMeshShading *shading);
   virtual ~GfxPatchMeshShading();
 
-  static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str);
+  static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str, Gfx *gfx);
 
   virtual GfxShading *copy();
 
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 3bbfdde..67dc632 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
 // Copyright (C) 2005 Jeff Muizelaar <jeff at infidigm.net>
-// Copyright (C) 2005-2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005-2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006-2008 Pino Toscano <pino at kde.org>
 // Copyright (C) 2006 Nickolay V. Shmyrev <nshmyrev at yandex.ru>
 // Copyright (C) 2006 Scott Turner <scotty1024 at mac.com>
@@ -554,7 +554,7 @@ GBool Page::loadThumb(unsigned char **data_out,
     obj1.free ();
     dict->lookup ("CS", &obj1);
   }
-  colorSpace = GfxColorSpace::parse(&obj1);
+  colorSpace = GfxColorSpace::parse(&obj1, NULL);
   obj1.free();
   if (!colorSpace) {
     fprintf (stderr, "Error: Cannot parse color space\n");


More information about the poppler mailing list