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

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Nov 14 02:49:27 PST 2014


 poppler/CairoOutputDev.cc |    4 
 poppler/Gfx.cc            |   40 ++++-----
 poppler/GfxState.cc       |  197 ++++++++++++++++++++++++++++++++++------------
 poppler/GfxState.h        |   31 +++----
 poppler/Page.cc           |    4 
 5 files changed, 188 insertions(+), 88 deletions(-)

New commits:
commit b7802ff39db270dda2aa20f005fb87c22ed34137
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date:   Fri Nov 14 11:47:38 2014 +0100

    Use Default colorspaces if present instead of Device colorspaces
    
    Fixes part of #68986

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index e08fe5c..4e8abcf 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, 2012 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009, 2010 David Benjamin <davidben at mit.edu>
-// Copyright (C) 2011-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2011-2014 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2012 Patrick Pfeifer <p2000 at mailinator.com>
 // Copyright (C) 2012 Jason Crain <jason at aquaticape.us>
 //
@@ -2713,7 +2713,7 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
     return;
 
   str->getDict()->lookup("ColorSpace", &obj);
-  colorSpace = GfxColorSpace::parse(&obj, this, state);
+  colorSpace = GfxColorSpace::parse(NULL, &obj, this, state);
   obj.free();
 
   // colorspace in stream dict may be different from colorspace in jpx
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6bf7ec5..64a9d7b 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -28,7 +28,7 @@
 // Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
 // Copyright (C) 2008 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009 M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
-// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2009-2014 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 William Bader <williambader at hotmail.com>
 // Copyright (C) 2009, 2010 David Benjamin <davidben at mit.edu>
 // Copyright (C) 2010 Nils Höglund <nils.hoglund at gmail.com>
@@ -468,7 +468,7 @@ GfxPattern *GfxResources::lookupPattern(char *name, OutputDev *out, GfxState *st
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
     if (resPtr->patternDict.isDict()) {
       if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) {
-	pattern = GfxPattern::parse(&obj, out, state);
+	pattern = GfxPattern::parse(resPtr, &obj, out, state);
 	obj.free();
 	return pattern;
       }
@@ -487,7 +487,7 @@ GfxShading *GfxResources::lookupShading(char *name, OutputDev *out, GfxState *st
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
     if (resPtr->shadingDict.isDict()) {
       if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) {
-	shading = GfxShading::parse(&obj, out, state);
+	shading = GfxShading::parse(resPtr, &obj, out, state);
 	obj.free();
 	return shading;
       }
@@ -1236,7 +1236,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
 	  blendingColorSpace = NULL;
 	  isolated = knockout = gFalse;
 	  if (!obj4.dictLookup("CS", &obj5)->isNull()) {
-	    blendingColorSpace = GfxColorSpace::parse(&obj5, out, state);
+	    blendingColorSpace = GfxColorSpace::parse(res, &obj5, out, state);
 	  }
 	  obj5.free();
 	  if (obj4.dictLookup("I", &obj5)->isBool()) {
@@ -1439,7 +1439,7 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
   state->setFillPattern(NULL);
   res->lookupColorSpace("DefaultGray", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceGrayColorSpace();
@@ -1460,7 +1460,7 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultGray", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceGrayColorSpace();
@@ -1481,7 +1481,7 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
 
   res->lookupColorSpace("DefaultCMYK", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceCMYKColorSpace();
@@ -1506,7 +1506,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultCMYK", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceCMYKColorSpace();
@@ -1530,7 +1530,7 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   state->setFillPattern(NULL);
   res->lookupColorSpace("DefaultRGB", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceRGBColorSpace();
@@ -1554,7 +1554,7 @@ void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) {
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultRGB", &obj);
   if (!obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   if (colorSpace == NULL) {
     colorSpace = new GfxDeviceRGBColorSpace();
@@ -1576,9 +1576,9 @@ void Gfx::opSetFillColorSpace(Object args[], int numArgs) {
 
   res->lookupColorSpace(args[0].getName(), &obj);
   if (obj.isNull()) {
-    colorSpace = GfxColorSpace::parse(&args[0], out, state);
+    colorSpace = GfxColorSpace::parse(res, &args[0], out, state);
   } else {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   obj.free();
   if (colorSpace) {
@@ -1601,9 +1601,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], out, state);
+    colorSpace = GfxColorSpace::parse(res, &args[0], out, state);
   } else {
-    colorSpace = GfxColorSpace::parse(&obj, out, state);
+    colorSpace = GfxColorSpace::parse(res, &obj, out, state);
   }
   obj.free();
   if (colorSpace) {
@@ -4403,7 +4403,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
         }
         state->setRenderingIntent(objIntent.getName());
       }
-      colorSpace = GfxColorSpace::parse(&obj1, out, state);
+      colorSpace = GfxColorSpace::parse(res, &obj1, out, state);
       if (objIntent.isName()) {
         state->setRenderingIntent(tempIntent);
         free(tempIntent);
@@ -4415,7 +4415,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       if (objCS.isNull()) {
         colorSpace = new GfxDeviceGrayColorSpace();
       } else {
-        colorSpace = GfxColorSpace::parse(&objCS, out, state);
+        colorSpace = GfxColorSpace::parse(res, &objCS, out, state);
       }
       objCS.free();
     } else if (csMode == streamCSDeviceRGB) {
@@ -4424,7 +4424,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       if (objCS.isNull()) {
         colorSpace = new GfxDeviceRGBColorSpace();
       } else {
-        colorSpace = GfxColorSpace::parse(&objCS, out, state);
+        colorSpace = GfxColorSpace::parse(res, &objCS, out, state);
       }
       objCS.free();
     } else if (csMode == streamCSDeviceCMYK) {
@@ -4433,7 +4433,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
       if (objCS.isNull()) {
         colorSpace = new GfxDeviceCMYKColorSpace();
       } else {
-        colorSpace = GfxColorSpace::parse(&objCS, out, state);
+        colorSpace = GfxColorSpace::parse(res, &objCS, out, state);
       }
       objCS.free();
     } else {
@@ -4528,7 +4528,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
 	  obj2.free();
 	}
       }
-      maskColorSpace = GfxColorSpace::parse(&obj1, out, state);
+      maskColorSpace = GfxColorSpace::parse(NULL, &obj1, out, state);
       obj1.free();
       if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
 	goto err1;
@@ -4824,7 +4824,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, out, state);
+	blendingColorSpace = GfxColorSpace::parse(res, &obj3, out, state);
       }
       obj3.free();
       if (obj1.dictLookup("I", &obj3)->isBool()) {
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index eae85dc..a303529 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -192,7 +192,7 @@ static const std::map<unsigned int, unsigned int>::size_type CMSCACHE_LIMIT = 20
 #define LCMS_FLAGS 0
 #else
 #include <lcms2.h>
-#define LCMS_FLAGS cmsFLAGS_NOOPTIMIZE
+#define LCMS_FLAGS cmsFLAGS_NOOPTIMIZE | cmsFLAGS_BLACKPOINTCOMPENSATION
 #endif
 
 #define COLOR_PROFILE_DIR "/ColorProfiles/"
@@ -282,7 +282,7 @@ GfxColorSpace::GfxColorSpace() {
 GfxColorSpace::~GfxColorSpace() {
 }
 
-GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *state, int recursion) {
+GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion) {
   GfxColorSpace *cs;
   Object obj1;
 
@@ -294,11 +294,44 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta
   cs = NULL;
   if (csObj->isName()) {
     if (csObj->isName("DeviceGray") || csObj->isName("G")) {
-      cs = new GfxDeviceGrayColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultGray", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceGrayColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceGrayColorSpace();
+      }
     } else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) {
-      cs = new GfxDeviceRGBColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultRGB", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceRGBColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceRGBColorSpace();
+      }
     } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) {
-      cs = new GfxDeviceCMYKColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultCMYK", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceCMYKColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceCMYKColorSpace();
+      }
     } else if (csObj->isName("Pattern")) {
       cs = new GfxPatternColorSpace(NULL);
     } else {
@@ -307,11 +340,44 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta
   } else if (csObj->isArray() && csObj->arrayGetLength() > 0) {
     csObj->arrayGet(0, &obj1);
     if (obj1.isName("DeviceGray") || obj1.isName("G")) {
-      cs = new GfxDeviceGrayColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultGray", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceGrayColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceGrayColorSpace();
+      }
     } else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) {
-      cs = new GfxDeviceRGBColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultRGB", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceRGBColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceRGBColorSpace();
+      }
     } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) {
-      cs = new GfxDeviceCMYKColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultCMYK", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceCMYKColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceCMYKColorSpace();
+      }
     } else if (obj1.isName("CalGray")) {
       cs = GfxCalGrayColorSpace::parse(csObj->getArray(), state);
     } else if (obj1.isName("CalRGB")) {
@@ -321,13 +387,13 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta
     } else if (obj1.isName("ICCBased")) {
       cs = GfxICCBasedColorSpace::parse(csObj->getArray(), out, state, recursion);
     } else if (obj1.isName("Indexed") || obj1.isName("I")) {
-      cs = GfxIndexedColorSpace::parse(csObj->getArray(), out, state, recursion);
+      cs = GfxIndexedColorSpace::parse(res, csObj->getArray(), out, state, recursion);
     } else if (obj1.isName("Separation")) {
-      cs = GfxSeparationColorSpace::parse(csObj->getArray(), out, state, recursion);
+      cs = GfxSeparationColorSpace::parse(res, csObj->getArray(), out, state, recursion);
     } else if (obj1.isName("DeviceN")) {
-      cs = GfxDeviceNColorSpace::parse(csObj->getArray(), out, state, recursion);
+      cs = GfxDeviceNColorSpace::parse(res, csObj->getArray(), out, state, recursion);
     } else if (obj1.isName("Pattern")) {
-      cs = GfxPatternColorSpace::parse(csObj->getArray(), out, state, recursion);
+      cs = GfxPatternColorSpace::parse(res, csObj->getArray(), out, state, recursion);
     } else {
       error(errSyntaxWarning, -1, "Bad color space");
     }
@@ -335,11 +401,44 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta
   } else if (csObj->isDict()) {
     csObj->dictLookup("ColorSpace", &obj1);
     if (obj1.isName("DeviceGray")) {
-      cs = new GfxDeviceGrayColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultGray", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceGrayColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceGrayColorSpace();
+      }
     } else if (obj1.isName("DeviceRGB")) {
-      cs = new GfxDeviceRGBColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultRGB", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceRGBColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceRGBColorSpace();
+      }
     } else if (obj1.isName("DeviceCMYK")) {
-      cs = new GfxDeviceCMYKColorSpace();
+      if (res != NULL) {
+        Object objCS;
+        res->lookupColorSpace("DefaultCMYK", &objCS);
+        if (objCS.isNull()) {
+          cs = new GfxDeviceCMYKColorSpace();
+        } else {
+          cs = GfxColorSpace::parse(NULL, &objCS, out, state);
+        }
+        objCS.free();
+      } else {
+        cs = new GfxDeviceCMYKColorSpace();
+      }
     } else {
       error(errSyntaxWarning, -1, "Bad color space dict'");
     }
@@ -1871,7 +1970,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState
     nCompsA = 4;
   }
   if (dict->lookup("Alternate", &obj2)->isNull() ||
-      !(altA = GfxColorSpace::parse(&obj2, out, state, recursion + 1))) {
+      !(altA = GfxColorSpace::parse(NULL, &obj2, out, state, recursion + 1))) {
     switch (nCompsA) {
     case 1:
       altA = new GfxDeviceGrayColorSpace();
@@ -2422,7 +2521,7 @@ GfxColorSpace *GfxIndexedColorSpace::copy() {
   return cs;
 }
 
-GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) {
+GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
   GfxIndexedColorSpace *cs;
   GfxColorSpace *baseA;
   int indexHighA;
@@ -2435,7 +2534,7 @@ GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, OutputDev *out, GfxState
     goto err1;
   }
   arr->get(1, &obj1);
-  if (!(baseA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) {
+  if (!(baseA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
     error(errSyntaxWarning, -1, "Bad Indexed color space (base color space)");
     goto err2;
   }
@@ -2687,7 +2786,7 @@ GfxColorSpace *GfxSeparationColorSpace::copy() {
 }
 
 //~ handle the 'All' and 'None' colorants
-GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) {
+GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
   GfxSeparationColorSpace *cs;
   GooString *nameA;
   GfxColorSpace *altA;
@@ -2705,7 +2804,7 @@ GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, OutputDev *out, GfxSta
   nameA = new GooString(obj1.getName());
   obj1.free();
   arr->get(2, &obj1);
-  if (!(altA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) {
+  if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
     error(errSyntaxWarning, -1, "Bad Separation color space (alternate color space)");
     goto err3;
   }
@@ -2936,7 +3035,7 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
 }
 
 //~ handle the 'None' colorant
-GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) {
+GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
   GfxDeviceNColorSpace *cs;
   int nCompsA;
   GooString *namesA[gfxColorMaxComps];
@@ -2971,7 +3070,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, GfxState
   }
   obj1.free();
   arr->get(2, &obj1);
-  if (!(altA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) {
+  if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
     error(errSyntaxWarning, -1, "Bad DeviceN color space (alternate color space)");
     goto err3;
   }
@@ -2994,7 +3093,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, GfxState
         Object obj3;
         colorants->getVal(i, &obj3);
         if (obj3.isArray()) {
-          separationList->append(GfxSeparationColorSpace::parse(obj3.getArray(), out, state, recursion));
+          separationList->append(GfxSeparationColorSpace::parse(res, obj3.getArray(), out, state, recursion));
         } else {
           obj3.free();
           obj2.free();
@@ -3202,7 +3301,7 @@ GfxColorSpace *GfxPatternColorSpace::copy() {
 				          (GfxColorSpace *)NULL);
 }
 
-GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) {
+GfxColorSpace *GfxPatternColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
   GfxPatternColorSpace *cs;
   GfxColorSpace *underA;
   Object obj1;
@@ -3214,7 +3313,7 @@ GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, OutputDev *out, GfxState
   underA = NULL;
   if (arr->getLength() == 2) {
     arr->get(1, &obj1);
-    if (!(underA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) {
+    if (!(underA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
       error(errSyntaxWarning, -1, "Bad Pattern color space (underlying color space)");
       obj1.free();
       return NULL;
@@ -3259,7 +3358,7 @@ GfxPattern::GfxPattern(int typeA) {
 GfxPattern::~GfxPattern() {
 }
 
-GfxPattern *GfxPattern::parse(Object *obj, OutputDev *out, GfxState *state) {
+GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) {
   GfxPattern *pattern;
   Object obj1;
 
@@ -3274,7 +3373,7 @@ GfxPattern *GfxPattern::parse(Object *obj, OutputDev *out, GfxState *state) {
   if (obj1.isInt() && obj1.getInt() == 1) {
     pattern = GfxTilingPattern::parse(obj);
   } else if (obj1.isInt() && obj1.getInt() == 2) {
-    pattern = GfxShadingPattern::parse(obj, out, state);
+    pattern = GfxShadingPattern::parse(res, obj, out, state);
   }
   obj1.free();
   return pattern;
@@ -3402,7 +3501,7 @@ GfxPattern *GfxTilingPattern::copy() {
 // GfxShadingPattern
 //------------------------------------------------------------------------
 
-GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, OutputDev *out, GfxState *state) {
+GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state) {
   Dict *dict;
   GfxShading *shadingA;
   double matrixA[6];
@@ -3415,7 +3514,7 @@ GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, OutputDev *out, GfxS
   dict = patObj->getDict();
 
   dict->lookup("Shading", &obj1);
-  shadingA = GfxShading::parse(&obj1, out, state);
+  shadingA = GfxShading::parse(res, &obj1, out, state);
   obj1.free();
   if (!shadingA) {
     return NULL;
@@ -3488,7 +3587,7 @@ GfxShading::~GfxShading() {
   }
 }
 
-GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) {
+GfxShading *GfxShading::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) {
   GfxShading *shading;
   Dict *dict;
   int typeA;
@@ -3512,17 +3611,17 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) {
 
   switch (typeA) {
   case 1:
-    shading = GfxFunctionShading::parse(dict, out, state);
+    shading = GfxFunctionShading::parse(res, dict, out, state);
     break;
   case 2:
-    shading = GfxAxialShading::parse(dict, out, state);
+    shading = GfxAxialShading::parse(res, dict, out, state);
     break;
   case 3:
-    shading = GfxRadialShading::parse(dict, out, state);
+    shading = GfxRadialShading::parse(res, dict, out, state);
     break;
   case 4:
     if (obj->isStream()) {
-      shading = GfxGouraudTriangleShading::parse(4, dict, obj->getStream(), out, state);
+      shading = GfxGouraudTriangleShading::parse(res, 4, dict, obj->getStream(), out, state);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 4 shading object");
       goto err1;
@@ -3530,7 +3629,7 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) {
     break;
   case 5:
     if (obj->isStream()) {
-      shading = GfxGouraudTriangleShading::parse(5, dict, obj->getStream(), out, state);
+      shading = GfxGouraudTriangleShading::parse(res, 5, dict, obj->getStream(), out, state);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 5 shading object");
       goto err1;
@@ -3538,7 +3637,7 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) {
     break;
   case 6:
     if (obj->isStream()) {
-      shading = GfxPatchMeshShading::parse(6, dict, obj->getStream(), out, state);
+      shading = GfxPatchMeshShading::parse(res, 6, dict, obj->getStream(), out, state);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 6 shading object");
       goto err1;
@@ -3546,7 +3645,7 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) {
     break;
   case 7:
     if (obj->isStream()) {
-      shading = GfxPatchMeshShading::parse(7, dict, obj->getStream(), out, state);
+      shading = GfxPatchMeshShading::parse(res, 7, dict, obj->getStream(), out, state);
     } else {
       error(errSyntaxWarning, -1, "Invalid Type 7 shading object");
       goto err1;
@@ -3563,12 +3662,12 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) {
   return NULL;
 }
 
-GBool GfxShading::init(Dict *dict, OutputDev *out, GfxState *state) {
+GBool GfxShading::init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) {
   Object obj1, obj2;
   int i;
 
   dict->lookup("ColorSpace", &obj1);
-  if (!(colorSpace = GfxColorSpace::parse(&obj1, out, state))) {
+  if (!(colorSpace = GfxColorSpace::parse(res, &obj1, out, state))) {
     error(errSyntaxWarning, -1, "Bad color space in shading dictionary");
     obj1.free();
     return gFalse;
@@ -3675,7 +3774,7 @@ GfxFunctionShading::~GfxFunctionShading() {
   }
 }
 
-GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, OutputDev *out, GfxState *state) {
+GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) {
   GfxFunctionShading *shading;
   double x0A, y0A, x1A, y1A;
   double matrixA[6];
@@ -3743,7 +3842,7 @@ GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, OutputDev *out, GfxSta
 
   shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA,
 				   funcsA, nFuncsA);
-  if (!shading->init(dict, out, state)) {
+  if (!shading->init(res, dict, out, state)) {
     delete shading;
     return NULL;
   }
@@ -3994,7 +4093,7 @@ GfxAxialShading::GfxAxialShading(GfxAxialShading *shading):
 GfxAxialShading::~GfxAxialShading() {
 }
 
-GfxAxialShading *GfxAxialShading::parse(Dict *dict, OutputDev *out, GfxState *state) {
+GfxAxialShading *GfxAxialShading::parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) {
   GfxAxialShading *shading;
   double x0A, y0A, x1A, y1A;
   double t0A, t1A;
@@ -4091,7 +4190,7 @@ GfxAxialShading *GfxAxialShading::parse(Dict *dict, OutputDev *out, GfxState *st
 
   shading = new GfxAxialShading(x0A, y0A, x1A, y1A, t0A, t1A,
 				funcsA, nFuncsA, extend0A, extend1A);
-  if (!shading->init(dict, out, state)) {
+  if (!shading->init(res, dict, out, state)) {
     delete shading;
     return NULL;
   }
@@ -4202,7 +4301,7 @@ GfxRadialShading::GfxRadialShading(GfxRadialShading *shading):
 GfxRadialShading::~GfxRadialShading() {
 }
 
-GfxRadialShading *GfxRadialShading::parse(Dict *dict, OutputDev *out, GfxState *state) {
+GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) {
   GfxRadialShading *shading;
   double x0A, y0A, r0A, x1A, y1A, r1A;
   double t0A, t1A;
@@ -4281,7 +4380,7 @@ GfxRadialShading *GfxRadialShading::parse(Dict *dict, OutputDev *out, GfxState *
 
   shading = new GfxRadialShading(x0A, y0A, r0A, x1A, y1A, r1A, t0A, t1A,
 				 funcsA, nFuncsA, extend0A, extend1A);
-  if (!shading->init(dict, out, state)) {
+  if (!shading->init(res, dict, out, state)) {
     delete shading;
     return NULL;
   }
@@ -4722,7 +4821,7 @@ GfxGouraudTriangleShading::~GfxGouraudTriangleShading() {
   }
 }
 
-GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
+GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, int typeA,
 							    Dict *dict,
 							    Stream *str,
 							    OutputDev *out, GfxState *gfxState) {
@@ -4921,7 +5020,7 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
   shading = new GfxGouraudTriangleShading(typeA, verticesA, nVerticesA,
 					  trianglesA, nTrianglesA,
 					  funcsA, nFuncsA);
-  if (!shading->init(dict, out, gfxState)) {
+  if (!shading->init(res, dict, out, gfxState)) {
     delete shading;
     return NULL;
   }
@@ -5067,7 +5166,7 @@ GfxPatchMeshShading::~GfxPatchMeshShading() {
   }
 }
 
-GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
+GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Dict *dict,
 						Stream *str, OutputDev *out, GfxState *state) {
   GfxPatchMeshShading *shading;
   Function *funcsA[gfxColorMaxComps];
@@ -5592,7 +5691,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
 
   shading = new GfxPatchMeshShading(typeA, patchesA, nPatchesA,
 				    funcsA, nFuncsA);
-  if (!shading->init(dict, out, state)) {
+  if (!shading->init(res, dict, out, state)) {
     delete shading;
     return NULL;
   }
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 106b2c0..d5853e3 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -20,7 +20,7 @@
 // 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-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2011-2014 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2013 Lu Wang <coolwanglu at gmail.com>
 //
 // To see a description of the changes please see the Changelog file that
@@ -53,6 +53,7 @@ class PopplerCache;
 class GooList;
 class OutputDev;
 class GfxState;
+class GfxResources;
 
 class Matrix {
 public:
@@ -205,7 +206,7 @@ public:
   virtual GfxColorSpaceMode getMode() = 0;
 
   // Construct a color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Object *csObj, OutputDev *out, GfxState *state, int recursion = 0);
+  static GfxColorSpace *parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion = 0);
 
   // Convert to gray, RGB, or CMYK.
   virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
@@ -578,7 +579,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csIndexed; }
 
   // Construct an Indexed color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
+  static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -631,7 +632,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csSeparation; }
 
   // Construct a Separation color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
+  static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -676,7 +677,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csDeviceN; }
 
   // Construct a DeviceN color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
+  static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -723,7 +724,7 @@ public:
   virtual GfxColorSpaceMode getMode() { return csPattern; }
 
   // Construct a Pattern color space.  Returns NULL if unsuccessful.
-  static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
+  static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
 
   virtual void getGray(GfxColor *color, GfxGray *gray);
   virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -752,7 +753,7 @@ public:
   GfxPattern(int typeA);
   virtual ~GfxPattern();
 
-  static GfxPattern *parse(Object *obj, OutputDev *out, GfxState *state);
+  static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state);
 
   virtual GfxPattern *copy() = 0;
 
@@ -808,7 +809,7 @@ private:
 class GfxShadingPattern: public GfxPattern {
 public:
 
-  static GfxShadingPattern *parse(Object *patObj, OutputDev *out, GfxState *state);
+  static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state);
   virtual ~GfxShadingPattern();
 
   virtual GfxPattern *copy();
@@ -835,7 +836,7 @@ public:
   GfxShading(GfxShading *shading);
   virtual ~GfxShading();
 
-  static GfxShading *parse(Object *obj, OutputDev *out, GfxState *state);
+  static GfxShading *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state);
 
   virtual GfxShading *copy() = 0;
 
@@ -849,7 +850,7 @@ public:
 
 protected:
 
-  GBool init(Dict *dict, OutputDev *out, GfxState *state);
+  GBool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
   int type;
   GfxColorSpace *colorSpace;
@@ -918,7 +919,7 @@ public:
   GfxFunctionShading(GfxFunctionShading *shading);
   virtual ~GfxFunctionShading();
 
-  static GfxFunctionShading *parse(Dict *dict, OutputDev *out, GfxState *state);
+  static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
   virtual GfxShading *copy();
 
@@ -952,7 +953,7 @@ public:
   GfxAxialShading(GfxAxialShading *shading);
   virtual ~GfxAxialShading();
 
-  static GfxAxialShading *parse(Dict *dict, OutputDev *out, GfxState *state);
+  static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
   virtual GfxShading *copy();
 
@@ -985,7 +986,7 @@ public:
   GfxRadialShading(GfxRadialShading *shading);
   virtual ~GfxRadialShading();
 
-  static GfxRadialShading *parse(Dict *dict, OutputDev *out, GfxState *state);
+  static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
   virtual GfxShading *copy();
 
@@ -1023,7 +1024,7 @@ public:
   GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading);
   virtual ~GfxGouraudTriangleShading();
 
-  static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
+  static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
 
   virtual GfxShading *copy();
 
@@ -1109,7 +1110,7 @@ public:
   GfxPatchMeshShading(GfxPatchMeshShading *shading);
   virtual ~GfxPatchMeshShading();
 
-  static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
+  static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
 
   virtual GfxShading *copy();
 
diff --git a/poppler/Page.cc b/poppler/Page.cc
index ecdff32..98c13c1 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -25,7 +25,7 @@
 // Copyright (C) 2008 Brad Hards <bradh at kde.org>
 // Copyright (C) 2008 Ilya Gorenbein <igorenbein at finjan.com>
 // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso at hotmail.it>
-// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2013 Jason Crain <jason at aquaticape.us>
 // Copyright (C) 2013 Adrian Johnson <ajohnson at redneon.com>
 //
@@ -672,7 +672,7 @@ GBool Page::loadThumb(unsigned char **data_out,
     obj1.free ();
     dict->lookup ("CS", &obj1);
   }
-  colorSpace = GfxColorSpace::parse(&obj1, NULL, NULL);
+  colorSpace = GfxColorSpace::parse(NULL, &obj1, NULL, NULL);
   obj1.free();
   if (!colorSpace) {
     fprintf (stderr, "Error: Cannot parse color space\n");


More information about the poppler mailing list