[poppler] poppler/SplashOutputDev.cc splash/Splash.cc splash/SplashFontEngine.cc splash/SplashFontEngine.h splash/SplashFTFontEngine.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Dec 10 11:15:17 PST 2013
poppler/SplashOutputDev.cc | 18 +++++++++---
splash/Splash.cc | 63 ++++++++++++++++++++++++++++++++------------
splash/SplashFTFontEngine.h | 3 ++
splash/SplashFontEngine.cc | 13 +++++++++
splash/SplashFontEngine.h | 5 +++
5 files changed, 82 insertions(+), 20 deletions(-)
New commits:
commit 6c0e7d35f273583acc2aa818860e3120b0cab64f
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date: Tue Dec 10 20:14:39 2013 +0100
correction for knockout transparency groups
Fixes test "G" in eci_altona-test-suite-v2_technical2_x4.pdf
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 2ca42a4..d0a9454 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -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;
}
diff --git a/splash/Splash.cc b/splash/Splash.cc
index 6bb0dfe..4a7d814 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -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() {
diff --git a/splash/SplashFTFontEngine.h b/splash/SplashFTFontEngine.h
index aa1ad5f..11bbea7 100644
--- a/splash/SplashFTFontEngine.h
+++ b/splash/SplashFTFontEngine.h
@@ -15,6 +15,7 @@
// Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
// Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2011 Andreas Hartmetz <ahartmetz at gmail.com>
+// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at 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:
diff --git a/splash/SplashFontEngine.cc b/splash/SplashFontEngine.cc
index 2e74f5a..968e820 100644
--- a/splash/SplashFontEngine.cc
+++ b/splash/SplashFontEngine.cc
@@ -16,6 +16,7 @@
// Copyright (C) 2009 Kovid Goyal <kovid at kovidgoyal.net>
// Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2011 Andreas Hartmetz <ahartmetz at gmail.com>
+// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at 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) {
diff --git a/splash/SplashFontEngine.h b/splash/SplashFontEngine.h
index 54926b4..6502ea5 100644
--- a/splash/SplashFontEngine.h
+++ b/splash/SplashFontEngine.h
@@ -15,6 +15,7 @@
// Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
// Copyright (C) 2009, 2011 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2011 Andreas Hartmetz <ahartmetz at gmail.com>
+// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at 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:
More information about the poppler
mailing list