diff options
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc | 188 |
1 files changed, 126 insertions, 62 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc index d758e25b306..581b804f3b0 100644 --- a/Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc +++ b/Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc @@ -8,10 +8,6 @@ #include <aconf.h> -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - #include <string.h> #include <math.h> #include <limits.h> @@ -598,6 +594,8 @@ struct SplashTransparencyGroup { SplashBitmap *tBitmap; // bitmap for transparency group GfxColorSpace *blendingColorSpace; GBool isolated; + GBool inSoftMask; // true if this, or any containing + // group, is a soft mask //----- modified region in tBitmap int modXMin, modYMin, modXMax, modYMax; @@ -654,7 +652,8 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, font = NULL; needFontUpdate = gFalse; - textClipPath = NULL; + savedTextPath = NULL; + savedClipPath = NULL; transpGroupStack = NULL; @@ -731,8 +730,11 @@ SplashOutputDev::~SplashOutputDev() { if (bitmap) { delete bitmap; } - if (textClipPath) { - delete textClipPath; + if (savedTextPath) { + delete savedTextPath; + } + if (savedClipPath) { + delete savedClipPath; } } @@ -1074,7 +1076,10 @@ void SplashOutputDev::setOverprintMask(GfxState *state, Guint mask; GfxCMYK cmyk; - if (overprintFlag && globalParams->getOverprintPreview()) { + // Adobe ignores overprint in soft masks. + if (overprintFlag && + !(transpGroupStack && transpGroupStack->inSoftMask) && + globalParams->getOverprintPreview()) { mask = colorSpace->getOverprintMask(); // The OPM (overprintMode) setting is only relevant when the color // space is DeviceCMYK or is "implicitly converted to DeviceCMYK". @@ -2218,27 +2223,24 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, - Unicode *u, int uLen) { - SplashPath *path; - int render; - GBool doFill, doStroke, doClip; - SplashStrokeAdjustMode strokeAdjust; - double m[4]; - GBool horiz; - + Unicode *u, int uLen, + GBool fill, GBool stroke, GBool makePath) { if (skipHorizText || skipRotatedText) { + double m[4]; state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); // this matches the 'diagonal' test in TextPage::updateFont() - horiz = m[0] > 0 && fabs(m[1]) < 0.001 && - fabs(m[2]) < 0.001 && m[3] < 0; + GBool horiz = m[0] > 0 && fabs(m[1]) < 0.001 && + fabs(m[2]) < 0.001 && m[3] < 0; if ((skipHorizText && horiz) || (skipRotatedText && !horiz)) { return; } } + fill = fill && !state->getFillColorSpace()->isNonMarking(); + stroke = stroke && !state->getStrokeColorSpace()->isNonMarking(); + // check for invisible text -- this is used by Acrobat Capture - render = state->getRender(); - if (render == 3) { + if (!fill && !stroke && !makePath) { return; } @@ -2252,13 +2254,8 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, x -= originX; y -= originY; - doFill = !(render & 1) && !state->getFillColorSpace()->isNonMarking(); - doStroke = ((render & 3) == 1 || (render & 3) == 2) && - !state->getStrokeColorSpace()->isNonMarking(); - doClip = render & 4; - - path = NULL; - if (doStroke || doClip) { + SplashPath *path = NULL; + if (stroke || makePath) { if ((path = font->getGlyphPath(code))) { path->offset((SplashCoord)x, (SplashCoord)y); } @@ -2267,14 +2264,19 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, // don't use stroke adjustment when stroking text -- the results // tend to be ugly (because characters with horizontal upper or // lower edges get misaligned relative to the other characters) - strokeAdjust = splashStrokeAdjustOff; // make gcc happy - if (doStroke) { - strokeAdjust = splash->getStrokeAdjust(); + SplashStrokeAdjustMode savedStrokeAdjust = splashStrokeAdjustOff; + if (stroke) { + savedStrokeAdjust = splash->getStrokeAdjust(); splash->setStrokeAdjust(splashStrokeAdjustOff); } - // fill and stroke - if (doFill && doStroke) { + // the possible operations are: + // - fill + // - stroke + // - fill + stroke + // - makePath + + if (fill && stroke) { if (path) { setOverprintMask(state, state->getFillColorSpace(), state->getFillOverprint(), state->getOverprintMode(), @@ -2286,37 +2288,33 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, splash->stroke(path); } - // fill - } else if (doFill) { + } else if (fill) { setOverprintMask(state, state->getFillColorSpace(), state->getFillOverprint(), state->getOverprintMode(), state->getFillColor()); splash->fillChar((SplashCoord)x, (SplashCoord)y, code, font); - // stroke - } else if (doStroke) { + } else if (stroke) { if (path) { setOverprintMask(state, state->getStrokeColorSpace(), state->getStrokeOverprint(), state->getOverprintMode(), state->getStrokeColor()); splash->stroke(path); } - } - // clip - if (doClip) { + } else if (makePath) { if (path) { - if (textClipPath) { - textClipPath->append(path); + if (savedTextPath) { + savedTextPath->append(path); } else { - textClipPath = path; + savedTextPath = path; path = NULL; } } } - if (doStroke) { - splash->setStrokeAdjust(strokeAdjust); + if (stroke) { + splash->setStrokeAdjust(savedStrokeAdjust); } if (path) { @@ -2324,6 +2322,73 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, } } +void SplashOutputDev::fillTextPath(GfxState *state) { + if (!savedTextPath) { + return; + } + setOverprintMask(state, state->getFillColorSpace(), + state->getFillOverprint(), state->getOverprintMode(), + state->getFillColor()); + splash->fill(savedTextPath, gFalse); +} + +void SplashOutputDev::strokeTextPath(GfxState *state) { + if (!savedTextPath) { + return; + } + setOverprintMask(state, state->getStrokeColorSpace(), + state->getStrokeOverprint(), state->getOverprintMode(), + state->getStrokeColor()); + splash->stroke(savedTextPath); +} + +void SplashOutputDev::clipToTextPath(GfxState *state) { + if (!savedTextPath) { + return; + } + splash->clipToPath(savedTextPath, gFalse); +} + +void SplashOutputDev::clipToTextStrokePath(GfxState *state) { + if (!savedTextPath) { + return; + } + SplashPath *path = splash->makeStrokePath(savedTextPath, + state->getLineWidth(), + state->getLineCap(), + state->getLineJoin()); + splash->clipToPath(path, gFalse); + delete path; +} + +void SplashOutputDev::clearTextPath(GfxState *state) { + if (savedTextPath) { + delete savedTextPath; + savedTextPath = NULL; + } +} + +void SplashOutputDev::addTextPathToSavedClipPath(GfxState *state) { + if (savedTextPath) { + if (savedClipPath) { + savedClipPath->append(savedTextPath); + delete savedTextPath; + } else { + savedClipPath = savedTextPath; + } + savedTextPath = NULL; + } +} + +void SplashOutputDev::clipToSavedClipPath(GfxState *state) { + if (!savedClipPath) { + return; + } + splash->clipToPath(savedClipPath, gFalse); + delete savedClipPath; + savedClipPath = NULL; +} + GBool SplashOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen) { @@ -2679,11 +2744,6 @@ void SplashOutputDev::drawType3Glyph(GfxState *state, T3FontCache *t3Font, } void SplashOutputDev::endTextObject(GfxState *state) { - if (textClipPath) { - splash->clipToPath(textClipPath, gFalse); - delete textClipPath; - textClipPath = NULL; - } } struct SplashOutImageMaskData { @@ -3855,7 +3915,7 @@ GBool SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, SplashBitmap *backdropBitmap; SplashColor color; double xMin, yMin, xMax, yMax, x, y; - int bw, bh, tx, ty, w, h, i; + int bw, bh, tx, ty, w, h, xx, yy, i; // transform the bbox state->transform(bbox[0], bbox[1], &x, &y); @@ -3928,21 +3988,23 @@ GBool SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, } else if (ty >= bh) { ty = bh - 1; } - w = (int)ceil(xMax) - tx + 1; - // NB bw and tx are both non-negative, so 'bw - tx' can't overflow - if (bw - tx < w) { - w = bw - tx; - } - if (w < 1) { + xx = (int)ceil(xMax); + if (xx < tx) { w = 1; + } else if (xx > bw - 1) { + // NB bw and tx are both non-negative, so 'bw - tx' can't overflow + w = bw - tx; + } else { + w = xx - tx + 1; } - h = (int)ceil(yMax) - ty + 1; - // NB bh and ty are both non-negative, so 'bh - ty' can't overflow - if (bh - ty < h) { - h = bh - ty; - } - if (h < 1) { + yy = (int)ceil(yMax); + if (yy < ty) { h = 1; + } else if (yy > bh - 1) { + // NB bh and ty are both non-negative, so 'bh - ty' can't overflow + h = bh - ty; + } else { + h = yy - ty + 1; } // optimization: a non-isolated group drawn with alpha=1 and @@ -3973,6 +4035,8 @@ GBool SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, transpGroup->ty = ty; transpGroup->blendingColorSpace = blendingColorSpace; transpGroup->isolated = isolated; + transpGroup->inSoftMask = (transpGroupStack && transpGroupStack->inSoftMask) + || forSoftMask; transpGroup->next = transpGroupStack; transpGroupStack = transpGroup; |