summaryrefslogtreecommitdiff
path: root/splash
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2019-08-23 00:11:45 +0200
committerAlbert Astals Cid <aacid@kde.org>2019-08-24 12:07:20 +0200
commit2e32545b1d2e31359775a65ef34e0385c9079126 (patch)
tree342c5c249434d74ab9a66d39b8bb553dd3923d07 /splash
parent9d5af77a9538be2cb4fce2fc4601359bb41d3976 (diff)
Always enable SPLASH_CMYK
Doesn't seem to cause any speed regression and one ifdef less is code easier to maintain
Diffstat (limited to 'splash')
-rw-r--r--splash/Splash.cc75
-rw-r--r--splash/Splash.h13
-rw-r--r--splash/SplashBitmap.cc20
-rw-r--r--splash/SplashBitmap.h2
-rw-r--r--splash/SplashState.cc19
-rw-r--r--splash/SplashState.h2
-rw-r--r--splash/SplashTypes.h21
7 files changed, 11 insertions, 141 deletions
diff --git a/splash/Splash.cc b/splash/Splash.cc
index 074dfe6e..c3e54b84 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -169,12 +169,9 @@ SplashPipeResultColorCtrl Splash::pipeResultColorNoAlphaBlend[] = {
splashPipeResultColorNoAlphaBlendMono,
splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorNoAlphaBlendRGB,
- splashPipeResultColorNoAlphaBlendRGB
-#ifdef SPLASH_CMYK
- ,
+ splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorNoAlphaBlendCMYK,
splashPipeResultColorNoAlphaBlendDeviceN
-#endif
};
SplashPipeResultColorCtrl Splash::pipeResultColorAlphaNoBlend[] = {
@@ -182,12 +179,9 @@ SplashPipeResultColorCtrl Splash::pipeResultColorAlphaNoBlend[] = {
splashPipeResultColorAlphaNoBlendMono,
splashPipeResultColorAlphaNoBlendRGB,
splashPipeResultColorAlphaNoBlendRGB,
- splashPipeResultColorAlphaNoBlendRGB
-#ifdef SPLASH_CMYK
- ,
+ splashPipeResultColorAlphaNoBlendRGB,
splashPipeResultColorAlphaNoBlendCMYK,
splashPipeResultColorAlphaNoBlendDeviceN
-#endif
};
SplashPipeResultColorCtrl Splash::pipeResultColorAlphaBlend[] = {
@@ -195,12 +189,9 @@ SplashPipeResultColorCtrl Splash::pipeResultColorAlphaBlend[] = {
splashPipeResultColorAlphaBlendMono,
splashPipeResultColorAlphaBlendRGB,
splashPipeResultColorAlphaBlendRGB,
- splashPipeResultColorAlphaBlendRGB
-#ifdef SPLASH_CMYK
- ,
+ splashPipeResultColorAlphaBlendRGB,
splashPipeResultColorAlphaBlendCMYK,
splashPipeResultColorAlphaBlendDeviceN
-#endif
};
//------------------------------------------------------------------------
@@ -310,12 +301,10 @@ inline void Splash::pipeInit(SplashPipe *pipe, int x, int y,
pipe->run = &Splash::pipeRunSimpleXBGR8;
} else if (bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) {
pipe->run = &Splash::pipeRunSimpleBGR8;
-#ifdef SPLASH_CMYK
} else if (bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) {
pipe->run = &Splash::pipeRunSimpleCMYK8;
} else if (bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) {
pipe->run = &Splash::pipeRunSimpleDeviceN8;
-#endif
}
} else if (!pipe->pattern && !pipe->noTransparency && !state->softMask &&
pipe->usesShape &&
@@ -331,12 +320,10 @@ inline void Splash::pipeInit(SplashPipe *pipe, int x, int y,
pipe->run = &Splash::pipeRunAAXBGR8;
} else if (bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) {
pipe->run = &Splash::pipeRunAABGR8;
-#ifdef SPLASH_CMYK
} else if (bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) {
pipe->run = &Splash::pipeRunAACMYK8;
} else if (bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) {
pipe->run = &Splash::pipeRunAADeviceN8;
-#endif
}
}
}
@@ -348,10 +335,8 @@ void Splash::pipeRun(SplashPipe *pipe) {
SplashColorPtr cSrc;
unsigned char cResult0, cResult1, cResult2, cResult3;
int t;
-#ifdef SPLASH_CMYK
int cp, mask;
unsigned char cResult[SPOT_NCOMPS+4];
-#endif
//----- source color
@@ -364,7 +349,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
pipeIncX(pipe);
return;
}
-#ifdef SPLASH_CMYK
if (bitmap->mode == splashModeCMYK8 || bitmap->mode == splashModeDeviceN8) {
if (state->fillOverprint && state->overprintMode && pipe->pattern->isCMYK()) {
unsigned int overprintMask = 15;
@@ -383,7 +367,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
state->overprintMask = overprintMask;
}
}
-#endif
}
if (pipe->noTransparency && !state->blendFunc) {
@@ -422,7 +405,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
*pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]];
*pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]];
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
if (state->overprintMask & 1) {
pipe->destColorPtr[0] = (state->overprintAdditive) ?
@@ -456,7 +438,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
}
pipe->destColorPtr += (SPOT_NCOMPS+4);
break;
-#endif
}
if (pipe->destAlphaPtr) {
*pipe->destAlphaPtr++ = 255;
@@ -481,16 +462,12 @@ void Splash::pipeRun(SplashPipe *pipe) {
destColorPtr += (alpha0X+pipe->x) * 3;
break;
case splashModeXBGR8:
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
-#endif
destColorPtr += (alpha0X+pipe->x) * 4;
break;
-#ifdef SPLASH_CMYK
case splashModeDeviceN8:
destColorPtr += (alpha0X+pipe->x) * (SPOT_NCOMPS + 4);
break;
-#endif
}
} else {
destColorPtr = pipe->destColorPtr;
@@ -518,7 +495,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
cDest[1] = destColorPtr[1];
cDest[2] = destColorPtr[0];
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
cDest[0] = destColorPtr[0];
cDest[1] = destColorPtr[1];
@@ -529,7 +505,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
for (cp = 0; cp < SPOT_NCOMPS + 4; cp++)
cDest[cp] = destColorPtr[cp];
break;
-#endif
}
if (pipe->destAlphaPtr) {
aDest = *pipe->destAlphaPtr;
@@ -565,7 +540,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
} else {
t = (aDest * 255) / pipe->shape - aDest;
switch (bitmap->mode) {
-#ifdef SPLASH_CMYK
case splashModeDeviceN8:
for (cp = 0; cp < SPOT_NCOMPS + 4; cp++)
cSrcNonIso[cp] = clip255(pipe->cSrc[cp] +
@@ -576,7 +550,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
cSrcNonIso[cp] = clip255(pipe->cSrc[cp] +
((pipe->cSrc[cp] - cDest[cp]) * t) / 255);
break;
-#endif
case splashModeXBGR8:
cSrcNonIso[3] = 255;
// fallthrough
@@ -606,13 +579,11 @@ void Splash::pipeRun(SplashPipe *pipe) {
//----- blend function
if (state->blendFunc) {
-#ifdef SPLASH_CMYK
if (bitmap->mode == splashModeDeviceN8) {
for (int k = 4; k < 4 + SPOT_NCOMPS; k++) {
cBlend[k] = 0;
}
}
-#endif
(*state->blendFunc)(cSrc, cDest, cBlend, bitmap->mode);
}
@@ -653,7 +624,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
cResult2 = state->rgbTransferB[div255((255 - aDest) * cSrc[2] +
aDest * cBlend[2])];
break;
-#ifdef SPLASH_CMYK
case splashPipeResultColorNoAlphaBlendCMYK:
cResult0 = state->cmykTransferC[div255((255 - aDest) * cSrc[0] +
aDest * cBlend[0])];
@@ -669,7 +639,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
cResult[cp] = state->deviceNTransfer[cp][div255((255 - aDest) * cSrc[cp] +
aDest * cBlend[cp])];
break;
-#endif
case splashPipeResultColorAlphaNoBlendMono:
if (alphaI == 0) {
@@ -693,7 +662,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
aSrc * cSrc[2]) / alphaI];
}
break;
-#ifdef SPLASH_CMYK
case splashPipeResultColorAlphaNoBlendCMYK:
if (alphaI == 0) {
cResult0 = 0;
@@ -721,7 +689,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
aSrc * cSrc[cp]) / alphaI];
}
break;
-#endif
case splashPipeResultColorAlphaBlendMono:
if (alphaI == 0) {
@@ -753,7 +720,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
alphaI];
}
break;
-#ifdef SPLASH_CMYK
case splashPipeResultColorAlphaBlendCMYK:
if (alphaI == 0) {
cResult0 = 0;
@@ -791,7 +757,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
alphaI];
}
break;
-#endif
}
//----- write destination pixel
@@ -827,7 +792,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
*pipe->destColorPtr++ = cResult1;
*pipe->destColorPtr++ = cResult0;
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
if (state->overprintMask & 1) {
pipe->destColorPtr[0] = (state->overprintAdditive) ?
@@ -861,7 +825,6 @@ void Splash::pipeRun(SplashPipe *pipe) {
}
pipe->destColorPtr += (SPOT_NCOMPS+4);
break;
-#endif
}
if (pipe->destAlphaPtr) {
*pipe->destAlphaPtr++ = aResult;
@@ -944,7 +907,6 @@ void Splash::pipeRunSimpleBGR8(SplashPipe *pipe) {
++pipe->x;
}
-#ifdef SPLASH_CMYK
// special case:
// !pipe->pattern && pipe->noTransparency && !state->blendFunc &&
// bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) {
@@ -993,7 +955,6 @@ void Splash::pipeRunSimpleDeviceN8(SplashPipe *pipe) {
++pipe->x;
}
-#endif
// special case:
// !pipe->pattern && !pipe->noTransparency && !state->softMask &&
@@ -1235,7 +1196,6 @@ void Splash::pipeRunAABGR8(SplashPipe *pipe) {
++pipe->x;
}
-#ifdef SPLASH_CMYK
// special case:
// !pipe->pattern && !pipe->noTransparency && !state->softMask &&
// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc &&
@@ -1350,7 +1310,6 @@ void Splash::pipeRunAADeviceN8(SplashPipe *pipe) {
++pipe->x;
}
-#endif
inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) {
pipe->x = x;
@@ -1374,14 +1333,12 @@ inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) {
case splashModeXBGR8:
pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x];
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x];
break;
case splashModeDeviceN8:
pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + (SPOT_NCOMPS + 4) * x];
break;
-#endif
}
if (bitmap->alpha) {
pipe->destAlphaPtr = &bitmap->alpha[y * bitmap->width + x];
@@ -1419,14 +1376,12 @@ inline void Splash::pipeIncX(SplashPipe *pipe) {
case splashModeXBGR8:
pipe->destColorPtr += 4;
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
pipe->destColorPtr += 4;
break;
case splashModeDeviceN8:
pipe->destColorPtr += (SPOT_NCOMPS+4);
break;
-#endif
}
if (pipe->destAlphaPtr) {
++pipe->destAlphaPtr;
@@ -1996,7 +1951,6 @@ void Splash::clear(SplashColorPtr color, unsigned char alpha) {
}
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
if (color[0] == color[1] && color[1] == color[2] && color[2] == color[3]) {
if (bitmap->rowSize < 0) {
@@ -2030,7 +1984,6 @@ void Splash::clear(SplashColorPtr color, unsigned char alpha) {
row += bitmap->rowSize;
}
break;
-#endif
}
if (bitmap->alpha) {
@@ -3733,7 +3686,6 @@ SplashError Splash::drawImage(SplashImageSource src, SplashICCTransform tf, void
ok = srcMode == splashModeBGR8;
nComps = 3;
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
ok = srcMode == splashModeCMYK8;
nComps = 4;
@@ -3742,7 +3694,6 @@ SplashError Splash::drawImage(SplashImageSource src, SplashICCTransform tf, void
ok = srcMode == splashModeDeviceN8;
nComps = SPOT_NCOMPS+4;
break;
-#endif
default:
ok = false;
break;
@@ -4213,10 +4164,8 @@ void Splash::scaleImageYdXd(SplashImageSource src, void *srcData,
unsigned char *lineBuf, *alphaLineBuf;
unsigned int *pixBuf, *alphaPixBuf;
unsigned int pix0, pix1, pix2;
-#ifdef SPLASH_CMYK
unsigned int pix3;
unsigned int pix[SPOT_NCOMPS+4], cp;
-#endif
unsigned int alpha;
unsigned char *destPtr, *destAlphaPtr;
int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, xxa, d, d0, d1;
@@ -4378,7 +4327,6 @@ void Splash::scaleImageYdXd(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix0;
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
// compute the final pixel
@@ -4421,7 +4369,6 @@ void Splash::scaleImageYdXd(SplashImageSource src, void *srcData,
for (cp = 0; cp < SPOT_NCOMPS+4; cp++)
*destPtr++ = (unsigned char)pix[cp];
break;
-#endif
case splashModeMono1: // mono1 is not allowed
@@ -4563,7 +4510,6 @@ void Splash::scaleImageYdXu(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix[0];
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
for (i = 0; i < xStep; ++i) {
*destPtr++ = (unsigned char)pix[0];
@@ -4578,7 +4524,6 @@ void Splash::scaleImageYdXu(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix[cp];
}
break;
-#endif
}
// process alpha
@@ -4715,7 +4660,6 @@ void Splash::scaleImageYuXd(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix[0];
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
for (i = 0; i < yStep; ++i) {
destPtr = destPtr0 + (i * scaledWidth + x) * nComps;
@@ -4732,7 +4676,6 @@ void Splash::scaleImageYuXd(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix[cp];
}
break;
-#endif
}
// process alpha
@@ -4868,7 +4811,6 @@ void Splash::scaleImageYuXu(SplashImageSource src, void *srcData,
}
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
for (i = 0; i < yStep; ++i) {
for (j = 0; j < xStep; ++j) {
@@ -4889,7 +4831,6 @@ void Splash::scaleImageYuXu(SplashImageSource src, void *srcData,
}
}
break;
-#endif
}
// process alpha
@@ -5029,7 +4970,6 @@ void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData,
*destPtr++ = (unsigned char)pix[1];
*destPtr++ = (unsigned char)pix[0];
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
*destPtr++ = (unsigned char)pix[0];
*destPtr++ = (unsigned char)pix[1];
@@ -5040,7 +4980,6 @@ void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData,
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
*destPtr++ = (unsigned char)pix[cp];
break;
-#endif
}
// process alpha
@@ -5356,10 +5295,8 @@ void Splash::compositeBackground(SplashColorPtr color) {
SplashColorPtr p;
unsigned char *q;
unsigned char alpha, alpha1, c, color0, color1, color2;
-#ifdef SPLASH_CMYK
unsigned char color3;
unsigned char colorsp[SPOT_NCOMPS+4], cp;
-#endif
int x, y, mask;
if (unlikely(bitmap->alpha == nullptr)) {
@@ -5458,7 +5395,6 @@ void Splash::compositeBackground(SplashColorPtr color) {
}
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
color0 = color[0];
color1 = color[1];
@@ -5511,7 +5447,6 @@ void Splash::compositeBackground(SplashColorPtr color) {
}
}
break;
-#endif
}
memset(bitmap->alpha, 255, bitmap->width * bitmap->height);
}
@@ -5567,14 +5502,12 @@ bool Splash::gouraudTriangleShadedFill(SplashGouraudColor *shading)
case splashModeXBGR8:
colorComps=4;
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
colorComps=4;
break;
case splashModeDeviceN8:
colorComps=SPOT_NCOMPS+4;
break;
-#endif
}
SplashPipe pipe;
@@ -5926,7 +5859,6 @@ SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
}
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
for (y = 0; y < height; ++y) {
p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest];
@@ -5949,7 +5881,6 @@ SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
}
}
break;
-#endif
}
if (bitmap->alpha) {
diff --git a/splash/Splash.h b/splash/Splash.h
index d458a273..f18d7ae9 100644
--- a/splash/Splash.h
+++ b/splash/Splash.h
@@ -58,25 +58,18 @@ typedef void (*SplashICCTransform)(void *data, SplashBitmap *bitmap);
//------------------------------------------------------------------------
enum SplashPipeResultColorCtrl {
-#ifdef SPLASH_CMYK
splashPipeResultColorNoAlphaBlendCMYK,
splashPipeResultColorNoAlphaBlendDeviceN,
-#endif
splashPipeResultColorNoAlphaBlendRGB,
splashPipeResultColorNoAlphaBlendMono,
splashPipeResultColorAlphaNoBlendMono,
splashPipeResultColorAlphaNoBlendRGB,
-#ifdef SPLASH_CMYK
splashPipeResultColorAlphaNoBlendCMYK,
splashPipeResultColorAlphaNoBlendDeviceN,
-#endif
splashPipeResultColorAlphaBlendMono,
- splashPipeResultColorAlphaBlendRGB
-#ifdef SPLASH_CMYK
- ,
+ splashPipeResultColorAlphaBlendRGB,
splashPipeResultColorAlphaBlendCMYK,
splashPipeResultColorAlphaBlendDeviceN
-#endif
};
//------------------------------------------------------------------------
@@ -297,19 +290,15 @@ private:
void pipeRunSimpleRGB8(SplashPipe *pipe);
void pipeRunSimpleXBGR8(SplashPipe *pipe);
void pipeRunSimpleBGR8(SplashPipe *pipe);
-#ifdef SPLASH_CMYK
void pipeRunSimpleCMYK8(SplashPipe *pipe);
void pipeRunSimpleDeviceN8(SplashPipe *pipe);
-#endif
void pipeRunAAMono1(SplashPipe *pipe);
void pipeRunAAMono8(SplashPipe *pipe);
void pipeRunAARGB8(SplashPipe *pipe);
void pipeRunAAXBGR8(SplashPipe *pipe);
void pipeRunAABGR8(SplashPipe *pipe);
-#ifdef SPLASH_CMYK
void pipeRunAACMYK8(SplashPipe *pipe);
void pipeRunAADeviceN8(SplashPipe *pipe);
-#endif
void pipeSetXY(SplashPipe *pipe, int x, int y);
void pipeIncX(SplashPipe *pipe);
void drawPixel(SplashPipe *pipe, int x, int y, bool noClip);
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index d12ef46a..6b3957d7 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -89,7 +89,6 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPadA,
rowSize = -1;
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
if (width > 0 && width <= INT_MAX / 4) {
rowSize = width * 4;
@@ -104,7 +103,6 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPadA,
rowSize = -1;
}
break;
-#endif
}
if (rowSize > 0) {
rowSize += rowPad - 1;
@@ -249,14 +247,12 @@ SplashError SplashBitmap::writePNMFile(FILE *f) {
}
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
case splashModeDeviceN8:
// PNM doesn't support CMYK
error(errInternal, -1, "unsupported SplashBitmap mode");
return splashErrGeneric;
break;
-#endif
}
return splashOk;
}
@@ -310,7 +306,6 @@ void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
pixel[1] = p[1];
pixel[2] = p[0];
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
p = &data[y * rowSize + 4 * x];
pixel[0] = p[0];
@@ -323,7 +318,6 @@ void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
for (int cp = 0; cp < SPOT_NCOMPS + 4; cp++)
pixel[cp] = p[cp];
break;
-#endif
}
}
@@ -379,12 +373,10 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
#endif
#ifdef ENABLE_LIBJPEG
- #ifdef SPLASH_CMYK
case splashFormatJpegCMYK:
writer = new JpegWriter(JpegWriter::CMYK);
setJpegParams(writer, params);
break;
- #endif
case splashFormatJpeg:
writer = new JpegWriter();
setJpegParams(writer, params);
@@ -406,12 +398,10 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
case splashModeBGR8:
writer = new TiffWriter(TiffWriter::RGB);
break;
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
case splashModeDeviceN8:
writer = new TiffWriter(TiffWriter::CMYK);
break;
-#endif
default:
fprintf(stderr, "TiffWriter: Mode %d not supported\n", mode);
writer = new TiffWriter();
@@ -446,7 +436,6 @@ void SplashBitmap::getRGBLine(int yl, SplashColorPtr line) {
m = byteToDbl(col[1]);
y = byteToDbl(col[2]);
k = byteToDbl(col[3]);
-#ifdef SPLASH_CMYK
if (separationList->size() > 0) {
for (std::size_t i = 0; i < separationList->size(); i++) {
if (col[i+4] > 0) {
@@ -470,7 +459,6 @@ void SplashBitmap::getRGBLine(int yl, SplashColorPtr line) {
if (y > 1) y = 1;
if (k > 1) k = 1;
}
-#endif
c1 = 1 - c;
m1 = 1 - m;
y1 = 1 - y;
@@ -492,7 +480,6 @@ void SplashBitmap::getXBGRLine(int yl, SplashColorPtr line, ConversionMode conve
m = byteToDbl(col[1]);
y = byteToDbl(col[2]);
k = byteToDbl(col[3]);
-#ifdef SPLASH_CMYK
if (separationList->size() > 0) {
for (std::size_t i = 0; i < separationList->size(); i++) {
if (col[i+4] > 0) {
@@ -516,7 +503,6 @@ void SplashBitmap::getXBGRLine(int yl, SplashColorPtr line, ConversionMode conve
if (y > 1) y = 1;
if (k > 1) k = 1;
}
-#endif
c1 = 1 - c;
m1 = 1 - m;
y1 = 1 - y;
@@ -596,7 +582,6 @@ bool SplashBitmap::convertToXBGR(ConversionMode conversionMode) {
return newdata != nullptr;
}
-#ifdef SPLASH_CMYK
void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) {
SplashColor col;
@@ -636,13 +621,10 @@ void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) {
*line++ = col[3];
}
}
-#endif
SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI, SplashColorMode imageWriterFormat) {
if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1 && mode != splashModeXBGR8 && mode != splashModeBGR8
-#ifdef SPLASH_CMYK
&& mode != splashModeCMYK8 && mode != splashModeDeviceN8
-#endif
) {
error(errInternal, -1, "unsupported SplashBitmap mode");
return splashErrGeneric;
@@ -653,7 +635,6 @@ SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int
}
switch (mode) {
-#ifdef SPLASH_CMYK
case splashModeCMYK8:
if (writer->supportCMYK()) {
SplashColorPtr row;
@@ -704,7 +685,6 @@ SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int
delete[] row;
}
break;
-#endif
case splashModeRGB8:
{
SplashColorPtr row;
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index 8ffe15cf..3b98092f 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -98,9 +98,7 @@ public:
void getPixel(int x, int y, SplashColorPtr pixel);
void getRGBLine(int y, SplashColorPtr line);
void getXBGRLine(int y, SplashColorPtr line, ConversionMode conversionMode = conversionOpaque);
-#ifdef SPLASH_CMYK
void getCMYKLine(int y, SplashColorPtr line);
-#endif
unsigned char getAlpha(int x, int y);
// Caller takes ownership of the bitmap data. The SplashBitmap
diff --git a/splash/SplashState.cc b/splash/SplashState.cc
index 733fa0a3..9d4eb6fd 100644
--- a/splash/SplashState.cc
+++ b/splash/SplashState.cc
@@ -35,10 +35,7 @@
// number of components in each color mode
int splashColorModeNComps[] = {
- 1, 1, 3, 3, 4
-#ifdef SPLASH_CMYK
- , 4, 4 + SPOT_NCOMPS
-#endif
+ 1, 1, 3, 3, 4, 4, 4 + SPOT_NCOMPS
};
SplashState::SplashState(int width, int height, bool vectorAntialias,
@@ -80,14 +77,12 @@ SplashState::SplashState(int width, int height, bool vectorAntialias,
rgbTransferG[i] = (unsigned char)i;
rgbTransferB[i] = (unsigned char)i;
grayTransfer[i] = (unsigned char)i;
-#ifdef SPLASH_CMYK
cmykTransferC[i] = (unsigned char)i;
cmykTransferM[i] = (unsigned char)i;
cmykTransferY[i] = (unsigned char)i;
cmykTransferK[i] = (unsigned char)i;
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
deviceNTransfer[cp][i] = (unsigned char)i;
-#endif
}
overprintMask = 0xffffffff;
overprintAdditive = false;
@@ -133,14 +128,12 @@ SplashState::SplashState(int width, int height, bool vectorAntialias,
rgbTransferG[i] = (unsigned char)i;
rgbTransferB[i] = (unsigned char)i;
grayTransfer[i] = (unsigned char)i;
-#ifdef SPLASH_CMYK
cmykTransferC[i] = (unsigned char)i;
cmykTransferM[i] = (unsigned char)i;
cmykTransferY[i] = (unsigned char)i;
cmykTransferK[i] = (unsigned char)i;
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
deviceNTransfer[cp][i] = (unsigned char)i;
-#endif
}
overprintMask = 0xffffffff;
overprintAdditive = false;
@@ -184,14 +177,12 @@ SplashState::SplashState(SplashState *state) {
memcpy(rgbTransferG, state->rgbTransferG, 256);
memcpy(rgbTransferB, state->rgbTransferB, 256);
memcpy(grayTransfer, state->grayTransfer, 256);
-#ifdef SPLASH_CMYK
memcpy(cmykTransferC, state->cmykTransferC, 256);
memcpy(cmykTransferM, state->cmykTransferM, 256);
memcpy(cmykTransferY, state->cmykTransferY, 256);
memcpy(cmykTransferK, state->cmykTransferK, 256);
for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)
memcpy(deviceNTransfer[cp], state->deviceNTransfer[cp], 256);
-#endif
overprintMask = state->overprintMask;
overprintAdditive = state->overprintAdditive;
next = nullptr;
@@ -246,22 +237,18 @@ void SplashState::setSoftMask(SplashBitmap *softMaskA) {
void SplashState::setTransfer(unsigned char *red, unsigned char *green, unsigned char *blue,
unsigned char *gray) {
-#ifdef SPLASH_CMYK
- int i;
-
- for (i = 0; i < 256; ++i) {
+ for (int i = 0; i < 256; ++i) {
cmykTransferC[i] = 255 - rgbTransferR[255 - i];
cmykTransferM[i] = 255 - rgbTransferG[255 - i];
cmykTransferY[i] = 255 - rgbTransferB[255 - i];
cmykTransferK[i] = 255 - grayTransfer[255 - i];
}
- for (i = 0; i < 256; ++i) {
+ for (int i = 0; i < 256; ++i) {
deviceNTransfer[0][i] = 255 - rgbTransferR[255 - i];
deviceNTransfer[1][i] = 255 - rgbTransferG[255 - i];
deviceNTransfer[2][i] = 255 - rgbTransferB[255 - i];
deviceNTransfer[3][i] = 255 - grayTransfer[255 - i];
}
-#endif
memcpy(rgbTransferR, red, 256);
memcpy(rgbTransferG, green, 256);
memcpy(rgbTransferB, blue, 256);
diff --git a/splash/SplashState.h b/splash/SplashState.h
index e367f5f2..58d8338e 100644
--- a/splash/SplashState.h
+++ b/splash/SplashState.h
@@ -125,13 +125,11 @@ private:
rgbTransferG[256],
rgbTransferB[256];
unsigned char grayTransfer[256];
-#ifdef SPLASH_CMYK
unsigned char cmykTransferC[256],
cmykTransferM[256],
cmykTransferY[256],
cmykTransferK[256];
unsigned char deviceNTransfer[SPOT_NCOMPS+4][256];
-#endif
unsigned int overprintMask;
bool overprintAdditive;
diff --git a/splash/SplashTypes.h b/splash/SplashTypes.h
index deb91881..b00693fe 100644
--- a/splash/SplashTypes.h
+++ b/splash/SplashTypes.h
@@ -27,6 +27,8 @@
#ifndef SPLASHTYPES_H
#define SPLASHTYPES_H
+#include <cstddef>
+
//------------------------------------------------------------------------
// coordinates
//------------------------------------------------------------------------
@@ -59,16 +61,13 @@ enum SplashColorMode {
// RGBRGB...
splashModeBGR8, // 1 byte per component, 3 bytes per pixel:
// BGRBGR...
- splashModeXBGR8 // 1 byte per component, 4 bytes per pixel:
+ splashModeXBGR8, // 1 byte per component, 4 bytes per pixel:
// XBGRXBGR...
-#ifdef SPLASH_CMYK
- ,
splashModeCMYK8, // 1 byte per component, 4 bytes per pixel:
// CMYKCMYK...
splashModeDeviceN8 // 1 byte per component,
// 4 bytes + n bytes spot colors per pixel:
// CMYKSSSSCMYKSSSS...
-#endif
};
enum SplashThinLineMode {
@@ -82,11 +81,7 @@ enum SplashThinLineMode {
extern int splashColorModeNComps[];
// max number of components in any SplashColor
-#ifdef SPLASH_CMYK
-#define splashMaxColorComps SPOT_NCOMPS+4
-#else
-#define splashMaxColorComps 4
-#endif
+constexpr std::size_t splashMaxColorComps = SPOT_NCOMPS+4;
typedef unsigned char SplashColor[splashMaxColorComps];
typedef unsigned char *SplashColorPtr;
@@ -101,7 +96,6 @@ static inline unsigned char splashBGR8R(SplashColorPtr bgr8) { return bgr8[2]; }
static inline unsigned char splashBGR8G(SplashColorPtr bgr8) { return bgr8[1]; }
static inline unsigned char splashBGR8B(SplashColorPtr bgr8) { return bgr8[0]; }
-#ifdef SPLASH_CMYK
// CMYK8
static inline unsigned char splashCMYK8C(SplashColorPtr cmyk8) { return cmyk8[0]; }
static inline unsigned char splashCMYK8M(SplashColorPtr cmyk8) { return cmyk8[1]; }
@@ -114,39 +108,32 @@ static inline unsigned char splashDeviceN8M(SplashColorPtr deviceN8) { return de
static inline unsigned char splashDeviceN8Y(SplashColorPtr deviceN8) { return deviceN8[2]; }
static inline unsigned char splashDeviceN8K(SplashColorPtr deviceN8) { return deviceN8[3]; }
static inline unsigned char splashDeviceN8S(SplashColorPtr deviceN8, int nSpot) { return deviceN8[4 + nSpot]; }
-#endif
static inline void splashClearColor(SplashColorPtr dest) {
dest[0] = 0;
dest[1] = 0;
dest[2] = 0;
-#ifdef SPLASH_CMYK
dest[3] = 0;
for (int i = 4; i < SPOT_NCOMPS + 4; i++)
dest[i] = 0;
-#endif
}
static inline void splashColorCopy(SplashColorPtr dest, SplashColorPtr src) {
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
-#ifdef SPLASH_CMYK
dest[3] = src[3];
for (int i = 4; i < SPOT_NCOMPS + 4; i++)
dest[i] = src[i];
-#endif
}
static inline void splashColorXor(SplashColorPtr dest, SplashColorPtr src) {
dest[0] ^= src[0];
dest[1] ^= src[1];
dest[2] ^= src[2];
-#ifdef SPLASH_CMYK
dest[3] ^= src[3];
for (int i = 4; i < SPOT_NCOMPS + 4; i++)
dest[i] ^= src[i];
-#endif
}
//------------------------------------------------------------------------