1//========================================================================
2//
3// PreScanOutputDev.h
4//
5// Copyright 2005 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) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
17// Copyright (C) 2010, 2018-2021 Albert Astals Cid <aacid@kde.org>
18// Copyright (C) 2011, 2014 William Bader <williambader@hotmail.com>
19// Copyright (C) 2011, 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
20// Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com>
21//
22// To see a description of the changes please see the Changelog file that
23// came with your tarball or type make ChangeLog if you are building from git
24//
25//========================================================================
26
27#ifndef PRESCANOUTPUTDEV_H
28#define PRESCANOUTPUTDEV_H
29
30#include "Object.h"
31#include "GfxState.h"
32#include "OutputDev.h"
33#include "PSOutputDev.h"
34
35//------------------------------------------------------------------------
36// PreScanOutputDev
37//------------------------------------------------------------------------
38
39class PreScanOutputDev : public OutputDev
40{
41public:
42 // Constructor.
43 explicit PreScanOutputDev(PSLevel levelA);
44
45 // Destructor.
46 ~PreScanOutputDev() override;
47
48 //----- get info about output device
49
50 // Does this device use upside-down coordinates?
51 // (Upside-down means (0,0) is the top left corner of the page.)
52 bool upsideDown() override { return true; }
53
54 // Does this device use drawChar() or drawString()?
55 bool useDrawChar() override { return true; }
56
57 // Does this device use tilingPatternFill()? If this returns false,
58 // tiling pattern fills will be reduced to a series of other drawing
59 // operations.
60 bool useTilingPatternFill() override { return true; }
61
62 // Does this device use functionShadedFill(), axialShadedFill(), and
63 // radialShadedFill()? If this returns false, these shaded fills
64 // will be reduced to a series of other drawing operations.
65 bool useShadedFills(int type) override { return true; }
66
67 // Does this device use beginType3Char/endType3Char? Otherwise,
68 // text in Type 3 fonts will be drawn with drawChar/drawString.
69 bool interpretType3Chars() override { return true; }
70
71 //----- initialization and control
72
73 // Start a page.
74 void startPage(int pageNum, GfxState *state, XRef *xref) override;
75
76 // End a page.
77 void endPage() override;
78
79 //----- path painting
80 void stroke(GfxState *state) override;
81 void fill(GfxState *state) override;
82 void eoFill(GfxState *state) override;
83 bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override;
84 bool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override;
85 bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override;
86 bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax) override;
87
88 //----- path clipping
89 void clip(GfxState *state) override;
90 void eoClip(GfxState *state) override;
91
92 //----- text drawing
93 void beginStringOp(GfxState *state) override;
94 void endStringOp(GfxState *state) override;
95 bool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, const Unicode *u, int uLen) override;
96 void endType3Char(GfxState *state) override;
97
98 //----- image drawing
99 void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override;
100 void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override;
101 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;
102 void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap,
103 bool maskInterpolate) override;
104
105 //----- transparency groups and soft masks
106 void beginTransparencyGroup(GfxState *state, const double *bbox, GfxColorSpace *blendingColorSpace, bool isolated, bool knockout, bool forSoftMask) override;
107 void paintTransparencyGroup(GfxState *state, const double *bbox) override;
108 void setSoftMask(GfxState *state, const double *bbox, bool alpha, Function *transferFunc, GfxColor *backdropColor) override;
109
110 //----- special access
111
112 // Returns true if the operations performed since the last call to
113 // clearStats() are all monochrome (black or white).
114 bool isMonochrome() { return mono; }
115
116 // Returns true if the operations performed since the last call to
117 // clearStats() are all gray.
118 bool isGray() { return gray; }
119
120 // Returns true if the operations performed since the last call to
121 // clearStats() included any transparency.
122 bool usesTransparency() { return transparency; }
123
124 // Returns true if the operations performed since the last call to
125 // clearStats() are all rasterizable by GDI calls in GDIOutputDev.
126 bool isAllGDI() { return gdi; }
127
128 // Returns true if the operations performed since the last call to
129 // clearStats() included any image mask fills with a pattern color
130 // space. (only level1!)
131 bool usesPatternImageMask() { return patternImgMask; }
132
133 // Clear the stats used by the above functions.
134 void clearStats();
135
136private:
137 void check(GfxColorSpace *colorSpace, const GfxColor *color, double opacity, GfxBlendMode blendMode);
138
139 bool mono;
140 bool gray;
141 bool transparency;
142 bool gdi;
143 PSLevel level; // PostScript level (1, 2, separation)
144 bool patternImgMask;
145 int inTilingPatternFill;
146};
147
148#endif
149

source code of poppler/poppler/PreScanOutputDev.h