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 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..cb1ad05 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc @@ -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(gfx->getIccColorSpaceCache()->lookup(k)); + GfxICCBasedColorSpaceItem *item = static_cast(out->getIccColorSpaceCache()->lookup(k)); if (item != NULL) { cs = static_cast(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..1c42236 100644 --- a/poppler/GfxState.h +++ b/poppler/GfxState.h @@ -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..4e95986 100644 --- a/poppler/OutputDev.cc +++ b/poppler/OutputDev.cc @@ -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..4b8e766 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -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