/src/poppler/poppler/CairoOutputDev.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // CairoOutputDev.h |
4 | | // |
5 | | // Copyright 2003 Glyph & Cog, LLC |
6 | | // Copyright 2004 Red Hat, INC |
7 | | // |
8 | | //======================================================================== |
9 | | |
10 | | //======================================================================== |
11 | | // |
12 | | // Modified under the Poppler project - http://poppler.freedesktop.org |
13 | | // |
14 | | // All changes made under the Poppler project to this file are licensed |
15 | | // under GPL version 2 or later |
16 | | // |
17 | | // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net> |
18 | | // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> |
19 | | // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> |
20 | | // Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> |
21 | | // Copyright (C) 2008, 2009, 2011-2017, 2022-2024 Adrian Johnson <ajohnson@redneon.com> |
22 | | // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> |
23 | | // Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de> |
24 | | // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> |
25 | | // Copyright (C) 2016 Jason Crain <jason@aquaticape.us> |
26 | | // Copyright (C) 2018, 2019, 2021, 2025, 2026 Albert Astals Cid <aacid@kde.org> |
27 | | // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich |
28 | | // Copyright (C) 2020 Michal <sudolskym@gmail.com> |
29 | | // Copyright (C) 2021 Christian Persch <chpe@src.gnome.org> |
30 | | // Copyright (C) 2022 Marek Kasik <mkasik@redhat.com> |
31 | | // Copyright (C) 2024 Nelson Benítez León <nbenitezl@gmail.com> |
32 | | // Copyright (C) 2025, 2026 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk> |
33 | | // Copyright (C) 2026 Stefan Brüns <stefan.bruens@rwth-aachen.de> |
34 | | // |
35 | | // To see a description of the changes please see the Changelog file that |
36 | | // came with your tarball or type make ChangeLog if you are building from git |
37 | | // |
38 | | //======================================================================== |
39 | | |
40 | | #ifndef CAIROOUTPUTDEV_H |
41 | | #define CAIROOUTPUTDEV_H |
42 | | |
43 | | #include <unordered_set> |
44 | | |
45 | | #include <cairo-ft.h> |
46 | | #include "OutputDev.h" |
47 | | #include "TextOutputDev.h" |
48 | | #include "GfxState.h" |
49 | | #include "StructElement.h" |
50 | | #include "StructTreeRoot.h" |
51 | | #include "Annot.h" |
52 | | #include "Link.h" |
53 | | |
54 | | class PDFDoc; |
55 | | class GfxState; |
56 | | class GfxPath; |
57 | | class Gfx8BitFont; |
58 | | struct GfxRGB; |
59 | | class CairoFontEngine; |
60 | | class CairoFont; |
61 | | |
62 | | //------------------------------------------------------------------------ |
63 | | |
64 | | //------------------------------------------------------------------------ |
65 | | // CairoImage |
66 | | //------------------------------------------------------------------------ |
67 | | class CairoImage |
68 | | { |
69 | | public: |
70 | | // Constructor. |
71 | | CairoImage(double x1, double y1, double x2, double y2); |
72 | | |
73 | | // Destructor. |
74 | | ~CairoImage(); |
75 | | |
76 | | CairoImage(const CairoImage &) = delete; |
77 | | CairoImage &operator=(const CairoImage &) = delete; |
78 | | |
79 | | // Set the image cairo surface |
80 | | void setImage(cairo_surface_t *image); |
81 | | |
82 | | // Get the image cairo surface |
83 | 0 | cairo_surface_t *getImage() const { return image; } |
84 | | |
85 | | // Get the image rectangle |
86 | | void getRect(double *xa1, double *ya1, double *xa2, double *ya2) const |
87 | 0 | { |
88 | 0 | *xa1 = x1; |
89 | 0 | *ya1 = y1; |
90 | 0 | *xa2 = x2; |
91 | 0 | *ya2 = y2; |
92 | 0 | } |
93 | | |
94 | | private: |
95 | | cairo_surface_t *image; // image cairo surface |
96 | | double x1, y1; // upper left corner |
97 | | double x2, y2; // lower right corner |
98 | | }; |
99 | | |
100 | | //------------------------------------------------------------------------ |
101 | | // CairoOutputDev |
102 | | //------------------------------------------------------------------------ |
103 | | |
104 | | class CairoOutputDev : public OutputDev |
105 | | { |
106 | | public: |
107 | | // Constructor. |
108 | | CairoOutputDev(); |
109 | | |
110 | | // Destructor. |
111 | | ~CairoOutputDev() override; |
112 | | |
113 | | //----- get info about output device |
114 | | |
115 | | // Does this device use upside-down coordinates? |
116 | | // (Upside-down means (0,0) is the top left corner of the page.) |
117 | 8.41k | bool upsideDown() override { return true; } |
118 | | |
119 | | // Does this device use drawChar() or drawString()? |
120 | 3.81M | bool useDrawChar() override { return true; } |
121 | | |
122 | | // Does this device use tilingPatternFill()? If this returns false, |
123 | | // tiling pattern fills will be reduced to a series of other drawing |
124 | | // operations. |
125 | 1.66k | bool useTilingPatternFill() override { return true; } |
126 | | |
127 | | // Does this device use functionShadedFill(), axialShadedFill(), and |
128 | | // radialShadedFill()? If this returns false, these shaded fills |
129 | | // will be reduced to a series of other drawing operations. |
130 | 5.06k | bool useShadedFills(int type) override { return type <= 7; } |
131 | | |
132 | | // Does this device use FillColorStop()? |
133 | 396k | bool useFillColorStop() override { return true; } |
134 | | |
135 | | // Does this device use beginType3Char/endType3Char? Otherwise, |
136 | | // text in Type 3 fonts will be drawn with drawChar/drawString. |
137 | 14.1k | bool interpretType3Chars() override { return false; } |
138 | | |
139 | | // Does this device need to clip pages to the crop box even when the |
140 | | // box is the crop box? |
141 | 4.20k | bool needClipToCropBox() override { return true; } |
142 | | |
143 | | //----- initialization and control |
144 | | |
145 | | // Start a page. |
146 | | void startPage(int pageNum, GfxState *state, XRef *xref) override; |
147 | | |
148 | | // End a page. |
149 | | void endPage() override; |
150 | | |
151 | | // Must be called before last call to endPage() |
152 | | void emitStructTree(); |
153 | | |
154 | | void beginForm(Object *obj, Ref id) override; |
155 | | void endForm(Object *obj, Ref id) override; |
156 | | |
157 | | //----- save/restore graphics state |
158 | | void saveState(GfxState *state) override; |
159 | | void restoreState(GfxState *state) override; |
160 | | |
161 | | //----- update graphics state |
162 | | void updateAll(GfxState *state) override; |
163 | | void setDefaultCTM(const std::array<double, 6> &ctm) override; |
164 | | void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) override; |
165 | | void updateLineDash(GfxState *state) override; |
166 | | void updateFlatness(GfxState *state) override; |
167 | | void updateLineJoin(GfxState *state) override; |
168 | | void updateLineCap(GfxState *state) override; |
169 | | void updateMiterLimit(GfxState *state) override; |
170 | | void updateLineWidth(GfxState *state) override; |
171 | | void updateFillColor(GfxState *state) override; |
172 | | void updateStrokeColor(GfxState *state) override; |
173 | | void updateFillOpacity(GfxState *state) override; |
174 | | void updateStrokeOpacity(GfxState *state) override; |
175 | | void updateFillColorStop(GfxState *state, double offset) override; |
176 | | void updateBlendMode(GfxState *state) override; |
177 | | |
178 | | //----- update text state |
179 | | void updateFont(GfxState *state) override; |
180 | | |
181 | | //----- path painting |
182 | | void stroke(GfxState *state) override; |
183 | | void fill(GfxState *state) override; |
184 | | void eoFill(GfxState *state) override; |
185 | | void clipToStrokePath(GfxState *state) override; |
186 | | bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const std::array<double, 6> &mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override; |
187 | | bool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override; |
188 | | bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; |
189 | | bool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override; |
190 | | bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override; |
191 | | bool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override; |
192 | | bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override; |
193 | | bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override; |
194 | | |
195 | | //----- path clipping |
196 | | void clip(GfxState *state) override; |
197 | | void eoClip(GfxState *state) override; |
198 | | |
199 | | //----- text drawing |
200 | | void beginString(GfxState *state, const std::string &s) override; |
201 | | void endString(GfxState *state) override; |
202 | | void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) override; |
203 | | void beginActualText(GfxState *state, const std::string &text) override; |
204 | | void endActualText(GfxState *state) override; |
205 | | |
206 | | bool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, const Unicode *u, int uLen) override; |
207 | | void endType3Char(GfxState *state) override; |
208 | | void beginTextObject(GfxState *state) override; |
209 | | void endTextObject(GfxState *state) override; |
210 | | |
211 | | void beginMarkedContent(const std::string &name, Dict *properties) override; |
212 | | void endMarkedContent(GfxState *state) override; |
213 | | |
214 | | //----- image drawing |
215 | | void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override; |
216 | | bool setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, std::array<double, 6> &baseMatrix) override; |
217 | | void unsetSoftMaskFromImageMask(GfxState *state, std::array<double, 6> &baseMatrix) override; |
218 | | void drawImageMaskRegular(GfxState *state, Stream *str, int width, int height, bool invert, bool interpolate); |
219 | | |
220 | | void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override; |
221 | | void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, |
222 | | bool maskInterpolate) override; |
223 | | |
224 | | void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override; |
225 | | |
226 | | // Does this device supports transparency (alpha channel) in JPX streams? |
227 | 388 | bool supportJPXtransparency() override { return true; } |
228 | | |
229 | | //----- transparency groups and soft masks |
230 | | void beginTransparencyGroup(GfxState * /*state*/, const std::array<double, 4> & /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override; |
231 | | void endTransparencyGroup(GfxState * /*state*/) override; |
232 | | void popTransparencyGroup(); |
233 | | void paintTransparencyGroup(GfxState * /*state*/, const std::array<double, 4> & /*bbox*/) override; |
234 | | void setSoftMask(GfxState * /*state*/, const std::array<double, 4> & /*bbox*/, bool /*alpha*/, Function * /*transferFunc*/, const GfxColor & /*backdropColor*/) override; |
235 | | void clearSoftMask(GfxState * /*state*/) override; |
236 | | |
237 | | //----- Type 3 font operators |
238 | | void type3D0(GfxState *state, double wx, double wy) override; |
239 | | void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) override; |
240 | | |
241 | | //----- special access |
242 | | |
243 | | // Called to indicate that a new PDF document has been loaded. |
244 | | void startDoc(PDFDoc *docA, CairoFontEngine *fontEngine = nullptr); |
245 | | |
246 | | // Called to prepare this output dev for rendering CairoType3Font. |
247 | | void startType3Render(XRef *xref); |
248 | | |
249 | | void setCairo(cairo_t *cr); |
250 | | void setTextPage(std::shared_ptr<TextPage> text); |
251 | | void setPrinting(bool printingA) |
252 | 4.35k | { |
253 | 4.35k | printing = printingA; |
254 | 4.35k | needFontUpdate = true; |
255 | 4.35k | } |
256 | | static void copyAntialias(cairo_t *cr, cairo_t *source_cr); |
257 | 0 | void setLogicalStructure(bool logStruct) { this->logicalStruct = logStruct; } |
258 | | |
259 | | enum Type3RenderType |
260 | | { |
261 | | Type3RenderNone, |
262 | | Type3RenderMask, |
263 | | Type3RenderColor |
264 | | }; |
265 | 12.1k | void setType3RenderType(Type3RenderType state) { t3_render_state = state; } |
266 | | void getType3GlyphWidth(double *wx, double *wy) const |
267 | 11.7k | { |
268 | 11.7k | *wx = t3_glyph_wx; |
269 | 11.7k | *wy = t3_glyph_wy; |
270 | 11.7k | } |
271 | 11.7k | bool hasType3GlyphBBox() const { return t3_glyph_has_bbox; } |
272 | 11.3k | double *getType3GlyphBBox() { return t3_glyph_bbox; } |
273 | 5.86k | bool type3GlyphHasColor() const { return t3_glyph_has_color; } |
274 | | |
275 | | protected: |
276 | | void doPath(cairo_t *cairo, const GfxPath *path); |
277 | | cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface); |
278 | | static void getScaledSize(const cairo_matrix_t *matrix, int orig_width, int orig_height, int *scaledWidth, int *scaledHeight); |
279 | | cairo_filter_t getFilterForSurface(cairo_surface_t *image, bool interpolate); |
280 | | static bool getStreamData(Stream *str, char **buffer, int *length); |
281 | | void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height); |
282 | | void fillToStrokePathClip(); |
283 | | void alignStrokeCoords(const GfxSubpath *subpath, int i, double *x, double *y); |
284 | | AnnotLink *findLinkObject(const StructElement *elem); |
285 | | static void quadToCairoRect(const AnnotQuadrilaterals *quads, int idx, double destPageHeight, cairo_rectangle_t *rect); |
286 | | bool appendLinkDestRef(std::string &s, const LinkDest *dest); |
287 | | static void appendLinkDestXY(std::string &s, const LinkDest *dest, double destPageHeight); |
288 | | bool beginLinkTag(AnnotLink *annotLink); |
289 | | bool beginLink(const StructElement *linkElem); |
290 | | static void getStructElemAttributeString(const StructElement *elem); |
291 | | int getContentElementStructParents(const StructElement *element); |
292 | | bool checkIfStructElementNeeded(const StructElement *element); |
293 | | void emitStructElement(const StructElement *elem); |
294 | | void startFirstPage(XRef *xrefA); |
295 | | static bool setMimeDataForJBIG2Globals(Stream *str, cairo_surface_t *image); |
296 | | static bool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height); |
297 | | static void textStringToQuotedUtf8(const GooString *text, GooString *s); |
298 | | bool isPDF(); |
299 | | |
300 | | std::optional<GfxRGB> fill_color, stroke_color; |
301 | | cairo_pattern_t *fill_pattern, *stroke_pattern; |
302 | | double fill_opacity; |
303 | | double stroke_opacity; |
304 | | bool stroke_adjust; |
305 | | bool adjusted_stroke_width; |
306 | | bool align_stroke_coords; |
307 | | std::shared_ptr<CairoFont> currentFont; |
308 | | XRef *xref; |
309 | | |
310 | | struct StrokePathClip |
311 | | { |
312 | | GfxPath *path; |
313 | | cairo_matrix_t ctm; |
314 | | double line_width; |
315 | | double *dashes; |
316 | | int dash_count; |
317 | | double dash_offset; |
318 | | cairo_line_cap_t cap; |
319 | | cairo_line_join_t join; |
320 | | double miter; |
321 | | int ref_count; |
322 | | } *strokePathClip; |
323 | | |
324 | | PDFDoc *doc; // the current document |
325 | | |
326 | | static FT_Library ft_lib; |
327 | | static std::once_flag ft_lib_once_flag; |
328 | | |
329 | | CairoFontEngine *fontEngine; |
330 | | bool fontEngine_owner; |
331 | | |
332 | | cairo_t *cairo; |
333 | | cairo_matrix_t orig_matrix; |
334 | | bool needFontUpdate; // set when the font needs to be updated |
335 | | bool printing; |
336 | | bool use_show_text_glyphs; |
337 | | bool text_matrix_valid; |
338 | | cairo_glyph_t *glyphs; |
339 | | int glyphCount; |
340 | | cairo_text_cluster_t *clusters; |
341 | | int clusterCount; |
342 | | char *utf8; |
343 | | int utf8Count; |
344 | | int utf8Max; |
345 | | cairo_path_t *textClipPath; |
346 | | bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2) |
347 | | Type3RenderType t3_render_state; |
348 | | double t3_glyph_wx, t3_glyph_wy; |
349 | | bool t3_glyph_has_bbox; |
350 | | bool t3_glyph_has_color; |
351 | | bool has_color; |
352 | | double t3_glyph_bbox[4]; |
353 | | bool logicalStruct; |
354 | | bool firstPage; |
355 | | int pdfPageNum; // page number of the PDF file |
356 | | int cairoPageNum; // page number in cairo output |
357 | | std::vector<std::string> markedContentStack; |
358 | | std::vector<std::shared_ptr<Annot>> annotations; |
359 | | std::set<std::string> emittedDestinations; |
360 | | std::map<int, int> pdfPageToCairoPageMap; |
361 | | |
362 | | std::shared_ptr<TextPage> textPage; // text for the current page |
363 | | std::unique_ptr<ActualText> actualText; |
364 | | |
365 | | cairo_pattern_t *group; |
366 | | cairo_pattern_t *shape; |
367 | | cairo_pattern_t *mask; |
368 | | cairo_matrix_t mask_matrix; |
369 | | cairo_t *cairo_shape; |
370 | | int knockoutCount; |
371 | | struct ColorSpaceStack |
372 | | { |
373 | | bool knockout; |
374 | | GfxColorSpace *cs; |
375 | | cairo_matrix_t group_matrix; |
376 | | struct ColorSpaceStack *next; |
377 | | } *groupColorSpaceStack; |
378 | | |
379 | | struct SaveStateElement |
380 | | { |
381 | | // These patterns hold a reference |
382 | | cairo_pattern_t *fill_pattern; |
383 | | cairo_pattern_t *stroke_pattern; |
384 | | double fill_opacity; |
385 | | double stroke_opacity; |
386 | | cairo_pattern_t *mask; // can be null |
387 | | cairo_matrix_t mask_matrix; |
388 | | Ref fontRef; |
389 | | }; |
390 | | std::vector<SaveStateElement> saveStateStack; |
391 | | |
392 | | std::map<Ref, std::map<std::string, std::unique_ptr<LinkDest>>> destsMap; |
393 | | std::map<Ref, int> pdfPageRefToCairoPageNumMap; |
394 | | std::vector<int> structParentsStack; |
395 | | int currentStructParents; |
396 | | |
397 | | struct StructParentsMcidHash |
398 | | { |
399 | 0 | size_t operator()(std::pair<int, int> x) const { return x.first << 16 | x.second; } |
400 | | }; |
401 | | std::unordered_set<std::pair<int, int>, StructParentsMcidHash> mcidEmitted; // <structParent, MCID> |
402 | | |
403 | | std::unordered_set<const StructElement *> structElementNeeded; |
404 | | }; |
405 | | |
406 | | //------------------------------------------------------------------------ |
407 | | // CairoImageOutputDev |
408 | | //------------------------------------------------------------------------ |
409 | | |
410 | | // XXX: this should ideally not inherit from CairoOutputDev but use it instead perhaps |
411 | | class CairoImageOutputDev : public CairoOutputDev |
412 | | { |
413 | | public: |
414 | | // Constructor. |
415 | | CairoImageOutputDev(); |
416 | | |
417 | | // Destructor. |
418 | | ~CairoImageOutputDev() override; |
419 | | |
420 | | //----- get info about output device |
421 | | |
422 | | // Does this device use upside-down coordinates? |
423 | | // (Upside-down means (0,0) is the top left corner of the page.) |
424 | 0 | bool upsideDown() override { return true; } |
425 | | |
426 | | // Does this device use drawChar() or drawString()? |
427 | 0 | bool useDrawChar() override { return false; } |
428 | | |
429 | | // Does this device use tilingPatternFill()? If this returns false, |
430 | | // tiling pattern fills will be reduced to a series of other drawing |
431 | | // operations. |
432 | 0 | bool useTilingPatternFill() override { return true; } |
433 | | |
434 | | // Does this device use functionShadedFill(), axialShadedFill(), and |
435 | | // radialShadedFill()? If this returns false, these shaded fills |
436 | | // will be reduced to a series of other drawing operations. |
437 | 0 | bool useShadedFills(int type) override { return type <= 7; } |
438 | | |
439 | | // Does this device use FillColorStop()? |
440 | 0 | bool useFillColorStop() override { return false; } |
441 | | |
442 | | // Does this device use beginType3Char/endType3Char? Otherwise, |
443 | | // text in Type 3 fonts will be drawn with drawChar/drawString. |
444 | 0 | bool interpretType3Chars() override { return false; } |
445 | | |
446 | | // Does this device need non-text content? |
447 | 0 | bool needNonText() override { return true; } |
448 | | |
449 | | //----- save/restore graphics state |
450 | 0 | void saveState(GfxState * /*state*/) override { } |
451 | 0 | void restoreState(GfxState * /*state*/) override { } |
452 | | |
453 | | //----- update graphics state |
454 | 0 | void updateAll(GfxState * /*state*/) override { } |
455 | 0 | void setDefaultCTM(const std::array<double, 6> & /*ctm*/) override { } |
456 | 0 | void updateCTM(GfxState * /*state*/, double /*m11*/, double /*m12*/, double /*m21*/, double /*m22*/, double /*m31*/, double /*m32*/) override { } |
457 | 0 | void updateLineDash(GfxState * /*state*/) override { } |
458 | 0 | void updateFlatness(GfxState * /*state*/) override { } |
459 | 0 | void updateLineJoin(GfxState * /*state*/) override { } |
460 | 0 | void updateLineCap(GfxState * /*state*/) override { } |
461 | 0 | void updateMiterLimit(GfxState * /*state*/) override { } |
462 | 0 | void updateLineWidth(GfxState * /*state*/) override { } |
463 | 0 | void updateFillColor(GfxState * /*state*/) override { } |
464 | 0 | void updateStrokeColor(GfxState * /*state*/) override { } |
465 | 0 | void updateFillOpacity(GfxState * /*state*/) override { } |
466 | 0 | void updateStrokeOpacity(GfxState * /*state*/) override { } |
467 | 0 | void updateBlendMode(GfxState * /*state*/) override { } |
468 | | |
469 | | //----- update text state |
470 | 0 | void updateFont(GfxState * /*state*/) override { } |
471 | | |
472 | | //----- path painting |
473 | 0 | void stroke(GfxState * /*state*/) override { } |
474 | 0 | void fill(GfxState * /*state*/) override { } |
475 | 0 | void eoFill(GfxState * /*state*/) override { } |
476 | 0 | void clipToStrokePath(GfxState * /*state*/) override { } |
477 | | bool tilingPatternFill(GfxState * /*state*/, Gfx * /*gfx*/, Catalog * /*cat*/, GfxTilingPattern * /*tPat*/, const std::array<double, 6> & /*mat*/, int /*x0*/, int /*y0*/, int /*x1*/, int /*y1*/, double /*xStep*/, |
478 | | double /*yStep*/) override |
479 | 0 | { |
480 | 0 | return true; |
481 | 0 | } |
482 | 0 | bool axialShadedFill(GfxState * /*state*/, GfxAxialShading * /*shading*/, double /*tMin*/, double /*tMax*/) override { return true; } |
483 | 0 | bool radialShadedFill(GfxState * /*state*/, GfxRadialShading * /*shading*/, double /*sMin*/, double /*sMax*/) override { return true; } |
484 | | |
485 | | //----- path clipping |
486 | 0 | void clip(GfxState * /*state*/) override { } |
487 | 0 | void eoClip(GfxState * /*state*/) override { } |
488 | | |
489 | | //----- image drawing |
490 | | void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override; |
491 | | void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override; |
492 | | void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, |
493 | | bool maskInterpolate) override; |
494 | | void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override; |
495 | | bool setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, std::array<double, 6> &baseMatrix) override; |
496 | 0 | void unsetSoftMaskFromImageMask(GfxState * /*state*/, std::array<double, 6> & /*baseMatrix*/) override { } |
497 | | |
498 | | //----- transparency groups and soft masks |
499 | 0 | void beginTransparencyGroup(GfxState * /*state*/, const std::array<double, 4> & /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override { } |
500 | 0 | void endTransparencyGroup(GfxState * /*state*/) override { } |
501 | 0 | void paintTransparencyGroup(GfxState * /*state*/, const std::array<double, 4> & /*bbox*/) override { } |
502 | 0 | void setSoftMask(GfxState * /*state*/, const std::array<double, 4> & /*bbox*/, bool /*alpha*/, Function * /*transferFunc*/, const GfxColor & /*backdropColor*/) override { } |
503 | 0 | void clearSoftMask(GfxState * /*state*/) override { } |
504 | | |
505 | | //----- Image list |
506 | | // By default images are not rendred |
507 | | void setImageDrawDecideCbk(bool (*cbk)(int img_id, void *data), void *data) |
508 | 0 | { |
509 | 0 | imgDrawCbk = cbk; |
510 | 0 | imgDrawCbkData = data; |
511 | 0 | } |
512 | | // Iterate through list of images. |
513 | 0 | int getNumImages() const { return numImages; } |
514 | 0 | CairoImage *getImage(int i) const { return images[i]; } |
515 | | |
516 | | private: |
517 | | void saveImage(CairoImage *image); |
518 | | static void getBBox(GfxState *state, int width, int height, double *x1, double *y1, double *x2, double *y2); |
519 | | |
520 | | CairoImage **images; |
521 | | int numImages; |
522 | | int size; |
523 | | bool (*imgDrawCbk)(int img_id, void *data); |
524 | | void *imgDrawCbkData; |
525 | | }; |
526 | | |
527 | | #endif |