Commit b7802ff3 authored by Thomas Freitag's avatar Thomas Freitag Committed by Albert Astals Cid

Use Default colorspaces if present instead of Device colorspaces

Fixes part of #68986
parent 07aa6f40
......@@ -25,7 +25,7 @@
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
// Copyright (C) 2008, 2012 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2009, 2010 David Benjamin <davidben@mit.edu>
// Copyright (C) 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2011-2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2012 Patrick Pfeifer <p2000@mailinator.com>
// Copyright (C) 2012 Jason Crain <jason@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
......
......@@ -28,7 +28,7 @@
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
// Copyright (C) 2008 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2009 M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009-2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 William Bader <williambader@hotmail.com>
// Copyright (C) 2009, 2010 David Benjamin <davidben@mit.edu>
// Copyright (C) 2010 Nils Höglund <nils.hoglund@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()) {
......
This diff is collapsed.
......@@ -20,7 +20,7 @@
// Copyright (C) 2009-2011, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
// Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com>
// Copyright (C) 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2011-2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Lu Wang <coolwanglu@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();
......
......@@ -25,7 +25,7 @@
// Copyright (C) 2008 Brad Hards <bradh@kde.org>
// Copyright (C) 2008 Ilya Gorenbein <igorenbein@finjan.com>
// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2013 Adrian Johnson <ajohnson@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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment