From e4fd71a3468d3e62d3951e5d8998da348cdb5988 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sun, 14 Aug 2011 21:55:24 +0930 Subject: [PATCH 1/2] ps: use PS Patterns for tiling fill when PS level >= 2 --- poppler/CairoOutputDev.cc | 2 +- poppler/CairoOutputDev.h | 4 +- poppler/Gfx.cc | 4 +- poppler/OutputDev.h | 2 +- poppler/PSOutputDev.cc | 59 +++++++++++++++++++++++++++++++++++++++--- poppler/PSOutputDev.h | 13 ++++++++- poppler/PreScanOutputDev.cc | 2 +- poppler/PreScanOutputDev.h | 2 +- poppler/SplashOutputDev.cc | 2 +- poppler/SplashOutputDev.h | 2 +- 10 files changed, 76 insertions(+), 16 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 477030a..5b93dca 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -692,7 +692,7 @@ void CairoOutputDev::eoFill(GfxState *state) { } GBool CairoOutputDev::tilingPatternFill(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int /*tilingType*/, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep) diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index 730a23c..809bd78 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -159,7 +159,7 @@ public: virtual void eoFill(GfxState *state); virtual void clipToStrokePath(GfxState *state); virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); @@ -412,7 +412,7 @@ public: virtual void fill(GfxState *state) { } virtual void eoFill(GfxState *state) { } virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep) { return gTrue; } diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index ca93477..94f5e55 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -2142,8 +2142,8 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, m1[5] = m[5]; if (out->useTilingPatternFill() && out->tilingPatternFill(state, catalog, tPat->getContentStream(), - tPat->getMatrix(), tPat->getPaintType(), tPat->getResDict(), - m1, tPat->getBBox(), + tPat->getMatrix(), tPat->getPaintType(), tPat->getTilingType(), + tPat->getResDict(), m1, tPat->getBBox(), xi0, yi0, xi1, yi1, xstep, ystep)) { goto restore; } else { diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h index 2e3f9ae..bf984fc 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -197,7 +197,7 @@ public: virtual void fill(GfxState * /*state*/) {} virtual void eoFill(GfxState * /*state*/) {} virtual GBool tilingPatternFill(GfxState * /*state*/, Catalog * /*cat*/, Object * /*str*/, - double * /*pmat*/, int /*paintType*/, Dict * /*resDict*/, + double * /*pmat*/, int /*paintType*/, int /*tilingType*/, Dict * /*resDict*/, double * /*mat*/, double * /*bbox*/, int /*x0*/, int /*y0*/, int /*x1*/, int /*y1*/, double /*xStep*/, double /*yStep*/) diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 0a3df51..89cfdbc 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -4005,11 +4005,11 @@ void PSOutputDev::eoFill(GfxState *state) { writePS("f*\n"); } -GBool PSOutputDev::tilingPatternFill(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep) { +GBool PSOutputDev::tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) { PDFRectangle box; Gfx *gfx; @@ -4072,6 +4072,55 @@ GBool PSOutputDev::tilingPatternFill(GfxState *state, Catalog *cat, Object *str, return gTrue; } +GBool PSOutputDev::tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) { + PDFRectangle box; + Gfx *gfx; + double cxMin, cyMin, cxMax, cyMax; + + writePS("<<\n /PatternType 1\n"); + writePSFmt(" /PaintType {0:d}\n", paintType); + writePSFmt(" /TilingType {0:d}\n", tilingType); + writePSFmt(" /BBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}]\n", bbox[0], bbox[1], bbox[2], bbox[3]); + writePSFmt(" /XStep {0:.6g}\n", xStep); + writePSFmt(" /YStep {0:.6g}\n", yStep); + writePS(" /PaintProc { \n"); + box.x1 = bbox[0]; + box.y1 = bbox[1]; + box.x2 = bbox[2]; + box.y2 = bbox[3]; + gfx = new Gfx(xref, this, resDict, m_catalog, &box, NULL); + inType3Char = gTrue; + gfx->display(str); + inType3Char = gFalse; + delete gfx; + writePS(" }\n"); + writePS(">>\n"); + writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}]\n", pmat[0], pmat[1], pmat[2], pmat[3], pmat[4], pmat[5]); + writePS("makepattern setpattern\n"); + state->getClipBBox(&cxMin, &cyMin, &cxMax, &cyMax); + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} rectfill\n", cxMin, cyMin, cxMax - cxMin, cyMax - cyMin); + + return gTrue; +} + +GBool PSOutputDev::tilingPatternFill(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) { + if (level == psLevel1 || level == psLevel1Sep) { + return tilingPatternFillL1(state, cat, str, pmat, paintType, tilingType, resDict, + mat, bbox, x0, y0, x1, y1, xStep, yStep); + } else { + return tilingPatternFillL2(state, cat, str, pmat, paintType, tilingType, resDict, + mat, bbox, x0, y0, x1, y1, xStep, yStep); + } +} + GBool PSOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading) { double x0, y0, x1, y1; diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 6b37d18..792c4d7 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -210,7 +210,7 @@ public: virtual void fill(GfxState *state); virtual void eoFill(GfxState *state); virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); @@ -338,6 +338,17 @@ private: void dumpColorSpaceL2(GfxColorSpace *colorSpace, GBool genXform, GBool updateColors, GBool map01); + GBool tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep); + GBool tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep); + #if OPI_SUPPORT void opiBegin20(GfxState *state, Dict *dict); void opiBegin13(GfxState *state, Dict *dict); diff --git a/poppler/PreScanOutputDev.cc b/poppler/PreScanOutputDev.cc index 39e8287..70a7be7 100644 --- a/poppler/PreScanOutputDev.cc +++ b/poppler/PreScanOutputDev.cc @@ -81,7 +81,7 @@ void PreScanOutputDev::eoFill(GfxState *state) { } GBool PreScanOutputDev::tilingPatternFill(GfxState *state, Catalog *catalog, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int /*tilingType*/, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep) { diff --git a/poppler/PreScanOutputDev.h b/poppler/PreScanOutputDev.h index d97f0f7..a72d243 100644 --- a/poppler/PreScanOutputDev.h +++ b/poppler/PreScanOutputDev.h @@ -80,7 +80,7 @@ public: virtual void fill(GfxState *state); virtual void eoFill(GfxState *state); virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index e0683db..025fe1b 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -3775,7 +3775,7 @@ void SplashOutputDev::setFreeTypeHinting(GBool enable, GBool enableSlightHinting } GBool SplashOutputDev::tilingPatternFill(GfxState *state, Catalog *catalog, Object *str, - double *ptm, int paintType, Dict *resDict, + double *ptm, int paintType, int /*tilingType*/, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep) diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index e44e61c..c6340c3 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -271,7 +271,7 @@ public: virtual void fill(GfxState *state); virtual void eoFill(GfxState *state); virtual GBool tilingPatternFill(GfxState *state, Catalog *catalog, Object *str, - double *pmat, int paintType, Dict *resDict, + double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); -- 1.7.4.1