[poppler] poppler/PSOutputDev.cc poppler/PSOutputDev.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Aug 30 07:19:15 UTC 2018
poppler/PSOutputDev.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
poppler/PSOutputDev.h | 4 ++-
2 files changed, 58 insertions(+), 1 deletion(-)
New commits:
commit e3a3e3fa996f318c36f9926fa8cc5dfc9edfac20
Author: Philipp Knechtges <philipp-dev at knechtges.com>
Date: Sun Aug 26 19:37:29 2018 +0200
PSOutputDev: add native support for type 7 shadings when using level 3
Type 7 shadings are identical for PS and PDF, so we can just emit the corresponding
information rather than tiling the whole domain.
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index d1ead586..0c320fac 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -33,6 +33,7 @@
// Copyright (C) 2016 Caolán McNamara <caolanm at redhat.com>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
// Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
+// Copyright (C) 2018 Philipp Knechtges <philipp-dev at knechtges.com>
//
// 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
@@ -4927,6 +4928,60 @@ GBool PSOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading,
return gTrue;
}
+GBool PSOutputDev::patchMeshShadedFill(GfxState *state,
+ GfxPatchMeshShading *shading) {
+ // TODO: support parametrized shading
+ if (level < psLevel3 || shading->isParameterized()) {
+ return gFalse;
+ }
+
+ writePS("%% Begin patchMeshShadedFill\n");
+
+ // ShadingType 7 shadings are pretty much the same for pdf and ps.
+ // As such, we basically just need to invert GfxPatchMeshShading::parse here.
+
+ writePS("<<\n");
+ writePS(" /ShadingType 7\n");
+ writePS(" /ColorSpace ");
+ dumpColorSpaceL2(shading->getColorSpace(), gFalse, gFalse, gFalse);
+ writePS("\n");
+ writePS(" /DataSource [\n");
+
+ const int ncomps = shading->getColorSpace()->getNComps();
+
+ for (int i = 0; i < shading->getNPatches(); ++i) {
+ const auto& patch = *shading->getPatch(i);
+ // Print Flag, for us always f = 0
+ writePS(" 0 \n");
+
+ // Print coordinates
+ const std::array<std::pair<int,int>, 16> coordindices = {{ {0,0}, {0,1}, {0,2}, {0,3},
+ {1,3}, {2,3}, {3,3}, {3,2},
+ {3,1}, {3,0}, {2,0}, {1,0},
+ {1,1}, {1,2}, {2,2}, {2,1} }};
+ for (const auto& index: coordindices) {
+ writePSFmt(" {0:.6g} {1:.6g}\n", patch.x[index.first][index.second],
+ patch.y[index.first][index.second]);
+ }
+
+ // Print colors
+ const std::array<std::pair<int, int>, 4> colindices = {{ {0,0}, {0,1}, {1,1}, {1,0} }};
+ for (const auto& index: colindices) {
+ writePS(" ");
+ for (int comp = 0; comp < ncomps; ++comp) {
+ writePSFmt(" {0:.6g}", colToDbl(patch.color[index.first][index.second].c[comp]));
+ }
+ writePS("\n");
+ }
+ }
+
+ writePS(" ]\n");
+
+ writePS(">> shfill\n");
+ writePS("%% End patchMeshShadedFill\n");
+ return gTrue;
+}
+
void PSOutputDev::clip(GfxState *state) {
doPath(state->getPath());
writePS("W\n");
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index b51cf472..ef6106bb 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -26,6 +26,7 @@
// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
// Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
+// Copyright (C) 2018 Philipp Knechtges <philipp-dev at knechtges.com>
//
// 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
@@ -152,7 +153,7 @@ public:
// radialShadedFill()? If this returns false, these shaded fills
// will be reduced to a series of other drawing operations.
GBool useShadedFills(int type) override
- { return type < 4 && level >= psLevel2; }
+ { return (type < 4 && level >= psLevel2) || (type == 7 && level >= psLevel3); }
// Does this device use drawForm()? If this returns false,
// form-type XObjects will be interpreted (i.e., unrolled).
@@ -249,6 +250,7 @@ public:
GfxFunctionShading *shading) override;
GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/) override;
GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/) override;
+ GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override;
//----- path clipping
void clip(GfxState *state) override;
More information about the poppler
mailing list