-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinkscape-1.4-poppler-24.10.patch
353 lines (326 loc) · 15.2 KB
/
inkscape-1.4-poppler-24.10.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
diff -up inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.cpp.omv~ inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.cpp
--- inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.cpp.omv~ 2024-10-16 22:02:45.286278494 +0200
+++ inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.cpp 2024-10-16 23:49:12.890891669 +0200
@@ -810,7 +810,7 @@ void PdfParser::opSetExtGState(Object ar
_POPPLER_FREE(obj3);
if (_POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "G").isStream()) {
if (_POPPLER_CALL_ARGS_DEREF(obj4, obj3.streamGetDict()->lookup, "Group").isDict()) {
- GfxColorSpace *blendingColorSpace = nullptr;
+ std::unique_ptr<GfxColorSpace> blendingColorSpace = nullptr;
GBool isolated = gFalse;
GBool knockout = gFalse;
if (!_POPPLER_CALL_ARGS_DEREF(obj5, obj4.dictLookup, "CS").isNull()) {
@@ -857,7 +857,7 @@ void PdfParser::opSetExtGState(Object ar
}
void PdfParser::doSoftMask(Object *str, GBool alpha,
- GfxColorSpace *blendingColorSpace,
+ std::unique_ptr<GfxColorSpace> const &blendingColorSpace,
GBool isolated, GBool knockout,
Function *transferFunc, GfxColor *backdropColor) {
Dict *dict, *resDict;
@@ -920,9 +920,9 @@ void PdfParser::doSoftMask(Object *str,
alpha, transferFunc, backdropColor);
--formDepth;
- if (blendingColorSpace) {
- delete blendingColorSpace;
- }
+// if (blendingColorSpace) {
+// delete blendingColorSpace;
+// }
_POPPLER_FREE(obj1);
}
@@ -936,41 +936,28 @@ void PdfParser::opSetRenderingIntent(Obj
/**
* Get a newly allocated color space instance by CS operation argument.
- *
- * Maintains a cache for named color spaces to avoid expensive re-parsing.
*/
-GfxColorSpace *PdfParser::lookupColorSpaceCopy(Object &arg)
+std::unique_ptr<GfxColorSpace> PdfParser::lookupColorSpaceCopy(Object &arg)
{
assert(!arg.isNull());
- GfxColorSpace *colorSpace = nullptr;
if (char const *name = arg.isName() ? arg.getName() : nullptr) {
- auto const cache_name = std::to_string(formDepth) + "-" + name;
- if ((colorSpace = colorSpacesCache[cache_name].get())) {
- return colorSpace->copy();
- }
-
Object obj = res->lookupColorSpace(name);
if (obj.isNull()) {
- colorSpace = GfxColorSpace::parse(res, &arg, nullptr, state);
+ return GfxColorSpace::parse(res, &arg, nullptr, state);
} else {
- colorSpace = GfxColorSpace::parse(res, &obj, nullptr, state);
- }
-
- if (colorSpace && colorSpace->getMode() != csPattern) {
- colorSpacesCache[cache_name].reset(colorSpace->copy());
+ return GfxColorSpace::parse(res, &obj, nullptr, state);
}
} else {
// We were passed in an object directly.
- colorSpace = GfxColorSpace::parse(res, &arg, nullptr, state);
+ return GfxColorSpace::parse(res, &arg, nullptr, state);
}
- return colorSpace;
}
/**
* Look up pattern/gradients from the GfxResource dictionary
*/
-GfxPattern *PdfParser::lookupPattern(Object *obj, GfxState *state)
+std::unique_ptr<GfxPattern> PdfParser::lookupPattern(Object *obj, GfxState *state)
{
if (!obj->isName())
return nullptr;
@@ -983,7 +970,7 @@ void PdfParser::opSetFillGray(Object arg
GfxColor color;
builder->beforeStateChange(state);
state->setFillPattern(nullptr);
- state->setFillColorSpace(new GfxDeviceGrayColorSpace());
+ state->setFillColorSpace(std::unique_ptr<GfxColorSpace>(new GfxDeviceGrayColorSpace()));
color.c[0] = dblToCol(args[0].getNum());
state->setFillColor(&color);
builder->updateStyle(state);
@@ -995,7 +982,7 @@ void PdfParser::opSetStrokeGray(Object a
GfxColor color;
builder->beforeStateChange(state);
state->setStrokePattern(nullptr);
- state->setStrokeColorSpace(new GfxDeviceGrayColorSpace());
+ state->setStrokeColorSpace(std::unique_ptr<GfxColorSpace>(new GfxDeviceGrayColorSpace()));
color.c[0] = dblToCol(args[0].getNum());
state->setStrokeColor(&color);
builder->updateStyle(state);
@@ -1008,7 +995,7 @@ void PdfParser::opSetFillCMYKColor(Objec
int i;
builder->beforeStateChange(state);
state->setFillPattern(nullptr);
- state->setFillColorSpace(new GfxDeviceCMYKColorSpace());
+ state->setFillColorSpace(std::unique_ptr<GfxColorSpace>(new GfxDeviceCMYKColorSpace()));
for (i = 0; i < 4; ++i) {
color.c[i] = dblToCol(args[i].getNum());
}
@@ -1022,7 +1009,7 @@ void PdfParser::opSetStrokeCMYKColor(Obj
GfxColor color;
builder->beforeStateChange(state);
state->setStrokePattern(nullptr);
- state->setStrokeColorSpace(new GfxDeviceCMYKColorSpace());
+ state->setStrokeColorSpace(std::unique_ptr<GfxColorSpace>(new GfxDeviceCMYKColorSpace()));
for (int i = 0; i < 4; ++i) {
color.c[i] = dblToCol(args[i].getNum());
}
@@ -1036,7 +1023,7 @@ void PdfParser::opSetFillRGBColor(Object
GfxColor color;
builder->beforeStateChange(state);
state->setFillPattern(nullptr);
- state->setFillColorSpace(new GfxDeviceRGBColorSpace());
+ state->setFillColorSpace(std::unique_ptr<GfxColorSpace>(new GfxDeviceRGBColorSpace()));
for (int i = 0; i < 3; ++i) {
color.c[i] = dblToCol(args[i].getNum());
}
@@ -1049,7 +1036,7 @@ void PdfParser::opSetStrokeRGBColor(Obje
GfxColor color;
builder->beforeStateChange(state);
state->setStrokePattern(nullptr);
- state->setStrokeColorSpace(new GfxDeviceRGBColorSpace());
+ state->setStrokeColorSpace(std::unique_ptr<GfxColorSpace>(new GfxDeviceRGBColorSpace()));
for (int i = 0; i < 3; ++i) {
color.c[i] = dblToCol(args[i].getNum());
}
@@ -1061,13 +1048,13 @@ void PdfParser::opSetStrokeRGBColor(Obje
void PdfParser::opSetFillColorSpace(Object args[], int numArgs)
{
assert(numArgs >= 1);
- GfxColorSpace *colorSpace = lookupColorSpaceCopy(args[0]);
+ std::unique_ptr<GfxColorSpace> colorSpace = lookupColorSpaceCopy(args[0]);
builder->beforeStateChange(state);
state->setFillPattern(nullptr);
if (colorSpace) {
GfxColor color;
- state->setFillColorSpace(colorSpace);
+ state->setFillColorSpace(colorSpace->copy());
colorSpace->getDefaultColor(&color);
state->setFillColor(&color);
builder->updateStyle(state);
@@ -1082,13 +1069,13 @@ void PdfParser::opSetStrokeColorSpace(Ob
assert(numArgs >= 1);
builder->beforeStateChange(state);
- GfxColorSpace *colorSpace = lookupColorSpaceCopy(args[0]);
+ std::unique_ptr<GfxColorSpace> colorSpace = lookupColorSpaceCopy(args[0]);
state->setStrokePattern(nullptr);
if (colorSpace) {
GfxColor color;
- state->setStrokeColorSpace(colorSpace);
+ state->setStrokeColorSpace(colorSpace->copy());
colorSpace->getDefaultColor(&color);
state->setStrokeColor(&color);
builder->updateStyle(state);
@@ -1152,7 +1139,7 @@ void PdfParser::opSetFillColorN(Object a
builder->updateStyle(state);
}
if (auto pattern = lookupPattern(&(args[numArgs - 1]), state)) {
- state->setFillPattern(pattern);
+ state->setFillPattern(pattern->copy());
builder->updateStyle(state);
}
@@ -1195,7 +1182,7 @@ void PdfParser::opSetStrokeColorN(Object
builder->updateStyle(state);
}
if (auto pattern = lookupPattern(&(args[numArgs - 1]), state)) {
- state->setStrokePattern(pattern);
+ state->setStrokePattern(pattern->copy());
builder->updateStyle(state);
}
@@ -1572,7 +1559,7 @@ void PdfParser::doShadingPatternFillFall
// TODO not good that numArgs is ignored but args[] is used:
void PdfParser::opShFill(Object args[], int /*numArgs*/)
{
- GfxShading *shading = nullptr;
+ std::unique_ptr<GfxShading> shading = nullptr;
GfxPath *savedPath = nullptr;
bool savedState = false;
@@ -1608,19 +1595,19 @@ void PdfParser::opShFill(Object args[],
// do shading type-specific operations
switch (shading->getType()) {
case 1: // Function-based shading
- doFunctionShFill(static_cast<GfxFunctionShading *>(shading));
+ doFunctionShFill(static_cast<GfxFunctionShading *>(shading.get()));
break;
case 2: // Axial shading
case 3: // Radial shading
- builder->addClippedFill(shading, stateToAffine(state));
+ builder->addClippedFill(shading.get(), stateToAffine(state));
break;
case 4: // Free-form Gouraud-shaded triangle mesh
case 5: // Lattice-form Gouraud-shaded triangle mesh
- doGouraudTriangleShFill(static_cast<GfxGouraudTriangleShading *>(shading));
+ doGouraudTriangleShFill(static_cast<GfxGouraudTriangleShading *>(shading.get()));
break;
case 6: // Coons patch mesh
case 7: // Tensor-product patch mesh
- doPatchMeshShFill(static_cast<GfxPatchMeshShading *>(shading));
+ doPatchMeshShFill(static_cast<GfxPatchMeshShading *>(shading.get()));
break;
}
@@ -1630,7 +1617,6 @@ void PdfParser::opShFill(Object args[],
state->setPath(savedPath);
}
- delete shading;
}
void PdfParser::doFunctionShFill(GfxFunctionShading *shading) {
@@ -2521,7 +2507,7 @@ void PdfParser::doImage(Object * /*ref*/
} else {
// get color space and color map
- GfxColorSpace *colorSpace;
+ std::unique_ptr<GfxColorSpace> colorSpace;
_POPPLER_CALL_ARGS(obj1, dict->lookup, "ColorSpace");
if (obj1.isNull()) {
_POPPLER_FREE(obj1);
@@ -2530,11 +2516,11 @@ void PdfParser::doImage(Object * /*ref*/
if (!obj1.isNull()) {
colorSpace = lookupColorSpaceCopy(obj1);
} else if (csMode == streamCSDeviceGray) {
- colorSpace = new GfxDeviceGrayColorSpace();
+ colorSpace = std::unique_ptr<GfxColorSpace>(new GfxDeviceGrayColorSpace());
} else if (csMode == streamCSDeviceRGB) {
- colorSpace = new GfxDeviceRGBColorSpace();
+ colorSpace = std::unique_ptr<GfxColorSpace>(new GfxDeviceRGBColorSpace());
} else if (csMode == streamCSDeviceCMYK) {
- colorSpace = new GfxDeviceCMYKColorSpace();
+ colorSpace = std::unique_ptr<GfxColorSpace>(new GfxDeviceCMYKColorSpace());
} else {
colorSpace = nullptr;
}
@@ -2547,7 +2533,7 @@ void PdfParser::doImage(Object * /*ref*/
_POPPLER_FREE(obj1);
_POPPLER_CALL_ARGS(obj1, dict->lookup, "D");
}
- GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
+ GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace->copy());
_POPPLER_FREE(obj1);
if (!colorMap->isOk()) {
delete colorMap;
@@ -2617,7 +2603,7 @@ void PdfParser::doImage(Object * /*ref*/
_POPPLER_FREE(obj1);
_POPPLER_CALL_ARGS(obj1, maskDict->lookup, "CS");
}
- GfxColorSpace *maskColorSpace = lookupColorSpaceCopy(obj1);
+ std::unique_ptr<GfxColorSpace> maskColorSpace = lookupColorSpaceCopy(obj1);
_POPPLER_FREE(obj1);
if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
goto err1;
@@ -2627,7 +2613,7 @@ void PdfParser::doImage(Object * /*ref*/
_POPPLER_FREE(obj1);
_POPPLER_CALL_ARGS(obj1, maskDict->lookup, "D");
}
- maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
+ maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace->copy());
_POPPLER_FREE(obj1);
if (!maskColorMap->isOk()) {
delete maskColorMap;
@@ -2739,7 +2725,7 @@ void PdfParser::doForm(Object *str, doub
{
Dict *dict;
GBool transpGroup, isolated, knockout;
- GfxColorSpace *blendingColorSpace;
+ std::unique_ptr<GfxColorSpace> blendingColorSpace;
Object matrixObj, bboxObj;
double m[6], bbox[4];
Object resObj;
@@ -2831,14 +2817,11 @@ void PdfParser::doForm(Object *str, doub
doForm1(str, resDict, m, bbox, transpGroup, gFalse, blendingColorSpace, isolated, knockout);
--formDepth;
- if (blendingColorSpace) {
- delete blendingColorSpace;
- }
_POPPLER_FREE(resObj);
}
void PdfParser::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox, GBool transpGroup, GBool softMask,
- GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout, GBool alpha,
+ std::unique_ptr<GfxColorSpace> const &blendingColorSpace, GBool isolated, GBool knockout, GBool alpha,
Function *transferFunc, GfxColor *backdropColor)
{
Parser *oldParser;
@@ -2847,7 +2830,7 @@ void PdfParser::doForm1(Object *str, Dic
pushResources(resDict);
// Add a new container group before saving the state
- builder->startGroup(state, bbox, blendingColorSpace, isolated, knockout, softMask);
+ builder->startGroup(state, bbox, blendingColorSpace.get(), isolated, knockout, softMask);
// save current graphics state
saveState();
diff -up inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.h.omv~ inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.h
--- inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.h.omv~ 2024-10-16 22:03:47.306988617 +0200
+++ inkscape-1.4_2024-10-09_e7c3feb100/src/extension/internal/pdfinput/pdf-parser.h 2024-10-16 23:19:36.970279193 +0200
@@ -138,7 +138,7 @@ public:
void loadPatternColorProfiles(Dict *resources);
void loadColorProfile();
void loadColorSpaceProfile(GfxColorSpace *space, Object *obj);
- GfxPattern *lookupPattern(Object *obj, GfxState *state);
+ std::unique_ptr<GfxPattern> lookupPattern(Object *obj, GfxState *state);
std::shared_ptr<CairoFontEngine> getFontEngine();
@@ -174,10 +174,7 @@ private:
OpHistoryEntry *operatorHistory; // list containing the last N operators
- //! Caches color spaces by name
- std::map<std::string, std::unique_ptr<GfxColorSpace>> colorSpacesCache;
-
- GfxColorSpace *lookupColorSpaceCopy(Object &);
+ std::unique_ptr<GfxColorSpace> lookupColorSpaceCopy(Object &);
void setDefaultApproximationPrecision(); // init color deltas
void pushOperator(const char *name);
@@ -203,7 +200,7 @@ private:
void opSetMiterLimit(Object args[], int numArgs);
void opSetLineWidth(Object args[], int numArgs);
void opSetExtGState(Object args[], int numArgs);
- void doSoftMask(Object *str, GBool alpha, GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout,
+ void doSoftMask(Object *str, GBool alpha, std::unique_ptr<GfxColorSpace> const &blendingColorSpace, GBool isolated, GBool knockout,
Function *transferFunc, GfxColor *backdropColor);
void opSetRenderingIntent(Object args[], int numArgs);
@@ -297,7 +294,7 @@ private:
void doForm(Object *str, double *offset = nullptr);
void doForm1(Object *str, Dict *resDict, double *matrix, double *bbox,
GBool transpGroup = gFalse, GBool softMask = gFalse,
- GfxColorSpace *blendingColorSpace = nullptr,
+ std::unique_ptr<GfxColorSpace> const &blendingColorSpace = nullptr,
GBool isolated = gFalse, GBool knockout = gFalse,
GBool alpha = gFalse, Function *transferFunc = nullptr,
GfxColor *backdropColor = nullptr);