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

correction for knockout transparency groups

Fixes test "G" in eci_altona-test-suite-v2_technical2_x4.pdf
parent f77bc218
......@@ -1195,6 +1195,7 @@ struct SplashTransparencyGroup {
SplashBitmap *shape;
GBool knockout;
SplashCoord knockoutOpacity;
GBool fontAA;
//----- saved state
SplashBitmap *origBitmap;
......@@ -3811,7 +3812,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
transpGroup->blendingColorSpace = blendingColorSpace;
transpGroup->isolated = isolated;
transpGroup->shape = (knockout && !isolated) ? SplashBitmap::copy(bitmap) : NULL;
transpGroup->knockout = gFalse;
transpGroup->knockout = (knockout && isolated);
transpGroup->knockoutOpacity = 1.0;
transpGroup->next = transpGroupStack;
transpGroupStack = transpGroup;
......@@ -3819,6 +3820,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
// save state
transpGroup->origBitmap = bitmap;
transpGroup->origSplash = splash;
transpGroup->fontAA = fontEngine->getAA();
//~ this handles the blendingColorSpace arg for soft masks, but
//~ not yet for transparency groups
......@@ -3850,6 +3852,9 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
bitmapTopDown, bitmap->getSeparationList());
splash = new Splash(bitmap, vectorAntialias,
transpGroup->origSplash->getScreen());
if (transpGroup->next != NULL && transpGroup->next->knockout) {
fontEngine->setAA(gFalse);
}
splash->setThinLineMode(transpGroup->origSplash->getThinLineMode());
splash->setMinLineWidth(globalParams->getMinLineWidth());
//~ Acrobat apparently copies at least the fill and stroke colors, and
......@@ -3868,8 +3873,12 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
} else {
SplashBitmap *shape = (knockout) ? transpGroup->shape :
(transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->shape : transpGroup->origBitmap;
int shapeTx = (knockout) ? tx :
(transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->tx + tx : tx;
int shapeTy = (knockout) ? ty :
(transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->ty + ty : ty;
splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h);
splash->setInNonIsolatedGroup(shape, tx, ty);
splash->setInNonIsolatedGroup(shape, shapeTx, shapeTy);
}
transpGroup->tBitmap = bitmap;
state->shiftCTMAndClip(-tx, -ty);
......@@ -3906,8 +3915,9 @@ void SplashOutputDev::paintTransparencyGroup(GfxState *state, double *bbox) {
: transpGroupStack->knockoutOpacity;
splash->setOverprintMask(0xffffffff, gFalse);
splash->composite(tBitmap, 0, 0, tx, ty,
tBitmap->getWidth(), tBitmap->getHeight(),
gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity);
tBitmap->getWidth(), tBitmap->getHeight(),
gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity);
fontEngine->setAA(transpGroupStack->fontAA);
if (transpGroupStack->next != NULL && transpGroupStack->next->shape != NULL) {
transpGroupStack->next->knockout = gTrue;
}
......
......@@ -446,39 +446,68 @@ void Splash::pipeRun(SplashPipe *pipe) {
//----- read destination pixel
Guchar *destColorPtr;
if (pipe->shape && state->blendFunc && pipe->knockout && alpha0Bitmap != NULL) {
destColorPtr = alpha0Bitmap->data + (alpha0Y+pipe->y)*alpha0Bitmap->rowSize;
switch (bitmap->mode) {
case splashModeMono1:
destColorPtr += (alpha0X+pipe->x) / 8;
break;
case splashModeMono8:
destColorPtr += (alpha0X+pipe->x);
break;
case splashModeRGB8:
case splashModeBGR8:
destColorPtr += (alpha0X+pipe->x) * 3;
break;
case splashModeXBGR8:
#if SPLASH_CMYK
case splashModeCMYK8:
#endif
destColorPtr += (alpha0X+pipe->x) * 4;
break;
#if SPLASH_CMYK
case splashModeDeviceN8:
destColorPtr += (alpha0X+pipe->x) * (SPOT_NCOMPS + 4);
break;
#endif
}
} else {
destColorPtr = pipe->destColorPtr;
}
switch (bitmap->mode) {
case splashModeMono1:
cDest[0] = (*pipe->destColorPtr & pipe->destColorMask) ? 0xff : 0x00;
cDest[0] = (*destColorPtr & pipe->destColorMask) ? 0xff : 0x00;
break;
case splashModeMono8:
cDest[0] = *pipe->destColorPtr;
cDest[0] = *destColorPtr;
break;
case splashModeRGB8:
cDest[0] = pipe->destColorPtr[0];
cDest[1] = pipe->destColorPtr[1];
cDest[2] = pipe->destColorPtr[2];
cDest[0] = destColorPtr[0];
cDest[1] = destColorPtr[1];
cDest[2] = destColorPtr[2];
break;
case splashModeXBGR8:
cDest[0] = pipe->destColorPtr[2];
cDest[1] = pipe->destColorPtr[1];
cDest[2] = pipe->destColorPtr[0];
cDest[0] = destColorPtr[2];
cDest[1] = destColorPtr[1];
cDest[2] = destColorPtr[0];
cDest[3] = 255;
break;
case splashModeBGR8:
cDest[0] = pipe->destColorPtr[2];
cDest[1] = pipe->destColorPtr[1];
cDest[2] = pipe->destColorPtr[0];
cDest[0] = destColorPtr[2];
cDest[1] = destColorPtr[1];
cDest[2] = destColorPtr[0];
break;
#if SPLASH_CMYK
case splashModeCMYK8:
cDest[0] = pipe->destColorPtr[0];
cDest[1] = pipe->destColorPtr[1];
cDest[2] = pipe->destColorPtr[2];
cDest[3] = pipe->destColorPtr[3];
cDest[0] = destColorPtr[0];
cDest[1] = destColorPtr[1];
cDest[2] = destColorPtr[2];
cDest[3] = destColorPtr[3];
break;
case splashModeDeviceN8:
for (cp = 0; cp < SPOT_NCOMPS + 4; cp++)
cDest[cp] = pipe->destColorPtr[cp];
cDest[cp] = destColorPtr[cp];
break;
#endif
}
......@@ -1549,6 +1578,7 @@ Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
thinLineMode = splashThinLineDefault;
clearModRegion();
debugMode = gFalse;
alpha0Bitmap = NULL;
}
Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
......@@ -1576,6 +1606,7 @@ Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
thinLineMode = splashThinLineDefault;
clearModRegion();
debugMode = gFalse;
alpha0Bitmap = NULL;
}
Splash::~Splash() {
......
......@@ -15,6 +15,7 @@
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -58,6 +59,8 @@ public:
int *codeToGID, int codeToGIDLen);
SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
int *codeToGID, int codeToGIDLen, int faceIndex = 0);
GBool getAA() { return aa; }
void setAA(GBool aaA) { aa = aaA; }
private:
......
......@@ -16,6 +16,7 @@
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -288,6 +289,18 @@ SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
return fontFile;
}
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
GBool SplashFontEngine::getAA() {
return (ftEngine == NULL) ? gFalse : ftEngine->getAA();
}
void SplashFontEngine::setAA(GBool aa) {
if (ftEngine != NULL) {
ftEngine->setAA(aa);
}
}
#endif
SplashFont *SplashFontEngine::getFont(SplashFontFile *fontFile,
SplashCoord *textMat,
SplashCoord *ctm) {
......
......@@ -15,6 +15,7 @@
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -89,6 +90,10 @@ public:
// Note that the Splash y axis points downward.
SplashFont *getFont(SplashFontFile *fontFile,
SplashCoord *textMat, SplashCoord *ctm);
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
GBool getAA();
void setAA(GBool aa);
#endif
private:
......
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