/src/poppler/poppler/OutputDev.cc
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // OutputDev.cc |
4 | | // |
5 | | // Copyright 1996-2003 Glyph & Cog, LLC |
6 | | // |
7 | | //======================================================================== |
8 | | |
9 | | //======================================================================== |
10 | | // |
11 | | // Modified under the Poppler project - http://poppler.freedesktop.org |
12 | | // |
13 | | // All changes made under the Poppler project to this file are licensed |
14 | | // under GPL version 2 or later |
15 | | // |
16 | | // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> |
17 | | // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no> |
18 | | // Copyright (C) 2007, 2017 Adrian Johnson <ajohnson@redneon.com> |
19 | | // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> |
20 | | // Copyright (C) 2009, 2012, 2013, 2018, 2019, 2025, 2026 Albert Astals Cid <aacid@kde.org> |
21 | | // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> |
22 | | // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> |
23 | | // Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk> |
24 | | // Copyright (C) 2025 Arnav V <arnav0872@gmail.com> |
25 | | // Copyright (C) 2026 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de> |
26 | | // |
27 | | // To see a description of the changes please see the Changelog file that |
28 | | // came with your tarball or type make ChangeLog if you are building from git |
29 | | // |
30 | | //======================================================================== |
31 | | |
32 | | #include <config.h> |
33 | | |
34 | | #include "Object.h" |
35 | | #include "Stream.h" |
36 | | #include "GfxState.h" |
37 | | #include "OutputDev.h" |
38 | | |
39 | | //------------------------------------------------------------------------ |
40 | | // OutputDev |
41 | | //------------------------------------------------------------------------ |
42 | | |
43 | | OutputDev::OutputDev() |
44 | | #if USE_CMS |
45 | 472k | : iccColorSpaceCache(5) |
46 | | #endif |
47 | 472k | { |
48 | 472k | } |
49 | | |
50 | 472k | OutputDev::~OutputDev() = default; |
51 | | |
52 | | void OutputDev::setDefaultCTM(const std::array<double, 6> &ctm) |
53 | 452k | { |
54 | 452k | defCTM = ctm; |
55 | 452k | } |
56 | | |
57 | | void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) |
58 | 0 | { |
59 | 0 | *dx = static_cast<int>(defCTM[0] * ux + defCTM[2] * uy + defCTM[4] + 0.5); |
60 | 0 | *dy = static_cast<int>(defCTM[1] * ux + defCTM[3] * uy + defCTM[5] + 0.5); |
61 | 0 | } |
62 | | |
63 | | void OutputDev::updateAll(GfxState *state) |
64 | 300k | { |
65 | 300k | updateLineDash(state); |
66 | 300k | updateFlatness(state); |
67 | 300k | updateLineJoin(state); |
68 | 300k | updateLineCap(state); |
69 | 300k | updateMiterLimit(state); |
70 | 300k | updateLineWidth(state); |
71 | 300k | updateStrokeAdjust(state); |
72 | 300k | updateFillColorSpace(state); |
73 | 300k | updateFillColor(state); |
74 | 300k | updateStrokeColorSpace(state); |
75 | 300k | updateStrokeColor(state); |
76 | 300k | updateBlendMode(state); |
77 | 300k | updateFillOpacity(state); |
78 | 300k | updateStrokeOpacity(state); |
79 | 300k | updateFillOverprint(state); |
80 | 300k | updateStrokeOverprint(state); |
81 | 300k | updateTransfer(state); |
82 | 300k | updateFont(state); |
83 | 300k | } |
84 | | |
85 | | bool OutputDev::beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, CharCode /*code*/, const Unicode * /*u*/, int /*uLen*/) |
86 | 0 | { |
87 | 0 | return false; |
88 | 0 | } |
89 | | |
90 | | void OutputDev::drawImageMask(GfxState * /*state*/, Object * /*ref*/, Stream *str, int width, int height, bool /*invert*/, bool /*interpolate*/, bool inlineImg) |
91 | 0 | { |
92 | 0 | int i, j; |
93 | |
|
94 | 0 | if (inlineImg) { |
95 | 0 | if (!str->rewind()) { |
96 | 0 | return; |
97 | 0 | } |
98 | 0 | j = height * ((width + 7) / 8); |
99 | 0 | for (i = 0; i < j; ++i) { |
100 | 0 | str->getChar(); |
101 | 0 | } |
102 | 0 | str->close(); |
103 | 0 | } |
104 | 0 | } |
105 | | |
106 | | bool OutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, std::array<double, 6> & /*baseMatrix*/) |
107 | 79 | { |
108 | 79 | drawImageMask(state, ref, str, width, height, invert, false, inlineImg); |
109 | 79 | return true; |
110 | 79 | } |
111 | | |
112 | 79 | void OutputDev::unsetSoftMaskFromImageMask(GfxState * /*state*/, std::array<double, 6> & /*baseMatrix*/) { } |
113 | | |
114 | | void OutputDev::drawImage(GfxState * /*state*/, Object * /*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool /*interpolate*/, const int * /*maskColors*/, bool inlineImg) |
115 | 0 | { |
116 | 0 | int i, j; |
117 | |
|
118 | 0 | if (inlineImg) { |
119 | 0 | if (!str->rewind()) { |
120 | 0 | return; |
121 | 0 | } |
122 | 0 | j = height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8); |
123 | 0 | for (i = 0; i < j; ++i) { |
124 | 0 | str->getChar(); |
125 | 0 | } |
126 | 0 | str->close(); |
127 | 0 | } |
128 | 0 | } |
129 | | |
130 | | void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream * /*maskStr*/, int /*maskWidth*/, int /*maskHeight*/, bool /*maskInvert*/, |
131 | | bool /*maskInterpolate*/) |
132 | 0 | { |
133 | 0 | drawImage(state, ref, str, width, height, colorMap, interpolate, nullptr, false); |
134 | 0 | } |
135 | | |
136 | | void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream * /*maskStr*/, int /*maskWidth*/, int /*maskHeight*/, |
137 | | GfxImageColorMap * /*maskColorMap*/, bool /*maskInterpolate*/) |
138 | 0 | { |
139 | 0 | drawImage(state, ref, str, width, height, colorMap, interpolate, nullptr, false); |
140 | 0 | } |
141 | | |
142 | 444k | void OutputDev::endMarkedContent(GfxState * /*state*/) { } |
143 | | |
144 | 215k | void OutputDev::beginMarkedContent(const std::string & /*name*/, Dict * /*properties*/) { } |
145 | | |
146 | 2.82k | void OutputDev::markPoint(const std::string & /*name*/) { } |
147 | | |
148 | 1.79k | void OutputDev::markPoint(const std::string & /*name*/, Dict * /*properties*/) { } |
149 | | |
150 | 0 | void OutputDev::opiBegin(GfxState * /*state*/, const Dict & /*opiDict*/) { } |
151 | | |
152 | 0 | void OutputDev::opiEnd(GfxState * /*state*/, const Dict & /*opiDict*/) { } |
153 | | |
154 | | void OutputDev::startProfile() |
155 | 0 | { |
156 | 0 | profileHash = std::make_unique<std::unordered_map<std::string, ProfileData>>(); |
157 | 0 | } |
158 | | |
159 | | std::unique_ptr<std::unordered_map<std::string, ProfileData>> OutputDev::endProfile() |
160 | 0 | { |
161 | 0 | return std::move(profileHash); |
162 | 0 | } |