Coverage Report

Created: 2025-08-08 06:36

/src/xpdf-4.05/xpdf/SplashOutputDev.h
Line
Count
Source (jump to first uncovered line)
1
//========================================================================
2
//
3
// SplashOutputDev.h
4
//
5
// Copyright 2003 Glyph & Cog, LLC
6
//
7
//========================================================================
8
9
#ifndef SPLASHOUTPUTDEV_H
10
#define SPLASHOUTPUTDEV_H
11
12
#include <aconf.h>
13
14
#include "gtypes.h"
15
#include "SplashTypes.h"
16
#include "config.h"
17
#include "OutputDev.h"
18
#include "GfxState.h"
19
20
class Gfx8BitFont;
21
class SplashBitmap;
22
class Splash;
23
class SplashPath;
24
class SplashPattern;
25
class SplashFontEngine;
26
class SplashFont;
27
class T3FontCache;
28
struct T3FontCacheTag;
29
struct T3GlyphStack;
30
struct SplashTransparencyGroup;
31
32
//------------------------------------------------------------------------
33
34
// number of Type 3 fonts to cache
35
#define splashOutT3FontCacheSize 8
36
37
//------------------------------------------------------------------------
38
// SplashOutputDev
39
//------------------------------------------------------------------------
40
41
class SplashOutputDev: public OutputDev {
42
public:
43
44
  // Constructor.
45
  SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
46
      GBool reverseVideoA, SplashColorPtr paperColorA,
47
      GBool bitmapTopDownA = gTrue,
48
      GBool allowAntialiasA = gTrue);
49
50
51
  // Destructor.
52
  virtual ~SplashOutputDev();
53
54
  //----- get info about output device
55
56
  // Does this device use upside-down coordinates?
57
  // (Upside-down means (0,0) is the top left corner of the page.)
58
0
  virtual GBool upsideDown() { return bitmapTopDown ^ bitmapUpsideDown; }
59
60
  // Does this device use drawChar() or drawString()?
61
0
  virtual GBool useDrawChar() { return gTrue; }
62
63
  // Does this device use tilingPatternFill()?  If this returns false,
64
  // tiling pattern fills will be reduced to a series of other drawing
65
  // operations.
66
0
  virtual GBool useTilingPatternFill() { return gTrue; }
67
68
  // Does this device use beginType3Char/endType3Char?  Otherwise,
69
  // text in Type 3 fonts will be drawn with drawChar/drawString.
70
0
  virtual GBool interpretType3Chars() { return gTrue; }
71
72
73
74
  //----- initialization and control
75
76
  // Start a page.
77
  virtual void startPage(int pageNum, GfxState *state);
78
79
  // End a page.
80
  virtual void endPage();
81
82
  //----- save/restore graphics state
83
  virtual void saveState(GfxState *state);
84
  virtual void restoreState(GfxState *state);
85
86
  //----- update graphics state
87
  virtual void updateAll(GfxState *state);
88
  virtual void updateCTM(GfxState *state, double m11, double m12,
89
       double m21, double m22, double m31, double m32);
90
  virtual void updateLineDash(GfxState *state);
91
  virtual void updateFlatness(GfxState *state);
92
  virtual void updateLineJoin(GfxState *state);
93
  virtual void updateLineCap(GfxState *state);
94
  virtual void updateMiterLimit(GfxState *state);
95
  virtual void updateLineWidth(GfxState *state);
96
  virtual void updateStrokeAdjust(GfxState *state);
97
  virtual void updateFillColor(GfxState *state);
98
  virtual void updateStrokeColor(GfxState *state);
99
  virtual void updateBlendMode(GfxState *state);
100
  virtual void updateFillOpacity(GfxState *state);
101
  virtual void updateStrokeOpacity(GfxState *state);
102
  virtual void updateRenderingIntent(GfxState *state);
103
  virtual void updateTransfer(GfxState *state);
104
105
  //----- update text state
106
  virtual void updateFont(GfxState *state);
107
108
  //----- path painting
109
  virtual void stroke(GfxState *state);
110
  virtual void fill(GfxState *state);
111
  virtual void eoFill(GfxState *state);
112
  virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *strRef,
113
         int paintType, int tilingType, Dict *resDict,
114
         double *mat, double *bbox,
115
         int x0, int y0, int x1, int y1,
116
         double xStep, double yStep);
117
  virtual GBool shadedFill(GfxState *state, GfxShading *shading);
118
119
  //----- path clipping
120
  virtual void clip(GfxState *state);
121
  virtual void eoClip(GfxState *state);
122
  virtual void clipToStrokePath(GfxState *state);
123
124
  //----- text drawing
125
  virtual void drawChar(GfxState *state, double x, double y,
126
      double dx, double dy,
127
      double originX, double originY,
128
      CharCode code, int nBytes, Unicode *u, int uLen,
129
      GBool fill, GBool stroke, GBool makePath);
130
  virtual void fillTextPath(GfxState *state);
131
  virtual void strokeTextPath(GfxState *state);
132
  virtual void clipToTextPath(GfxState *state);
133
  virtual void clipToTextStrokePath(GfxState *state);
134
  virtual void clearTextPath(GfxState *state);
135
  virtual void addTextPathToSavedClipPath(GfxState *state);
136
  virtual void clipToSavedClipPath(GfxState *state);
137
  virtual GBool beginType3Char(GfxState *state, double x, double y,
138
             double dx, double dy,
139
             CharCode code, Unicode *u, int uLen);
140
  virtual void endType3Char(GfxState *state);
141
  virtual void endTextObject(GfxState *state);
142
143
  //----- image drawing
144
  virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
145
           int width, int height, GBool invert,
146
           GBool inlineImg, GBool interpolate);
147
  virtual void setSoftMaskFromImageMask(GfxState *state,
148
          Object *ref, Stream *str,
149
          int width, int height, GBool invert,
150
          GBool inlineImg, GBool interpolate);
151
  virtual void drawImage(GfxState *state, Object *ref, Stream *str,
152
       int width, int height, GfxImageColorMap *colorMap,
153
       int *maskColors, GBool inlineImg, GBool interpolate);
154
  virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
155
             int width, int height,
156
             GfxImageColorMap *colorMap,
157
             Object *maskRef, Stream *maskStr,
158
             int maskWidth, int maskHeight,
159
             GBool maskInvert, GBool interpolate);
160
  virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
161
           int width, int height,
162
           GfxImageColorMap *colorMap,
163
           Object *maskRef, Stream *maskStr,
164
           int maskWidth, int maskHeight,
165
           GfxImageColorMap *maskColorMap,
166
           double *matte, GBool interpolate);
167
168
  //----- Type 3 font operators
169
  virtual void type3D0(GfxState *state, double wx, double wy);
170
  virtual void type3D1(GfxState *state, double wx, double wy,
171
           double llx, double lly, double urx, double ury);
172
173
  //----- transparency groups and soft masks
174
  virtual GBool beginTransparencyGroup(GfxState *state, double *bbox,
175
               GfxColorSpace *blendingColorSpace,
176
               GBool isolated, GBool knockout,
177
               GBool forSoftMask);
178
  virtual void endTransparencyGroup(GfxState *state);
179
  virtual void paintTransparencyGroup(GfxState *state, double *bbox);
180
  virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha,
181
         Function *transferFunc, GfxColor *backdropColor);
182
  virtual void clearSoftMask(GfxState *state);
183
184
  //----- special access
185
186
  // Called to indicate that a new PDF document has been loaded.
187
  void startDoc(XRef *xrefA);
188
189
  void setStartPageCallback(void (*cbk)(void *data), void *data)
190
0
    { startPageCbk = cbk; startPageCbkData = data; }
191
 
192
  void setPaperColor(SplashColorPtr paperColorA);
193
194
0
  GBool isReverseVideo() { return reverseVideo; }
195
0
  void setReverseVideo(GBool reverseVideoA) { reverseVideo = reverseVideoA; }
196
197
  // Get the bitmap and its size.
198
0
  SplashBitmap *getBitmap() { return bitmap; }
199
  int getBitmapWidth();
200
  int getBitmapHeight();
201
202
  // Returns the last rasterized bitmap, transferring ownership to the
203
  // caller.
204
  SplashBitmap *takeBitmap();
205
206
  // Set this flag to true to generate an upside-down bitmap (useful
207
  // for Windows BMP files).
208
0
  void setBitmapUpsideDown(GBool f) { bitmapUpsideDown = f; }
209
210
  // Setting this to true disables the final composite (with the
211
  // opaque paper color), resulting in transparent output.
212
0
  void setNoComposite(GBool f) { noComposite = f; }
213
214
  // Get the Splash object.
215
0
  Splash *getSplash() { return splash; }
216
217
  // Get the modified region.
218
  void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax);
219
220
  // Clear the modified region.
221
  void clearModRegion();
222
223
  // Set the Splash fill color.
224
  void setFillColor(int r, int g, int b);
225
226
  // Get a font object for a Base-14 font, using the Latin-1 encoding.
227
  SplashFont *getFont(GString *name, SplashCoord *textMatA);
228
229
0
  SplashFont *getCurrentFont() { return font; }
230
231
  // If <skipTextA> is true, don't draw horizontal text.
232
  // If <skipRotatedTextA> is true, don't draw rotated (non-horizontal) text.
233
  void setSkipText(GBool skipHorizTextA, GBool skipRotatedTextA)
234
0
    { skipHorizText = skipHorizTextA; skipRotatedText = skipRotatedTextA; }
235
236
0
  int getNestCount() { return nestCount; }
237
238
239
  // Get the screen parameters.
240
0
  SplashScreenParams *getScreenParams() { return &screenParams; }
241
242
private:
243
244
  void setupScreenParams(double hDPI, double vDPI);
245
  SplashPattern *getColor(GfxGray gray);
246
  SplashPattern *getColor(GfxRGB *rgb);
247
#if SPLASH_CMYK
248
  SplashPattern *getColor(GfxCMYK *cmyk);
249
#endif
250
  void getColor(GfxGray gray, SplashColorPtr color);
251
  void getColor(GfxRGB *rgb, SplashColorPtr color);
252
#if SPLASH_CMYK
253
  void getColor(GfxCMYK *cmyk, SplashColorPtr color);
254
#endif
255
  void setOverprintMask(GfxState *state, GfxColorSpace *colorSpace,
256
      GBool overprintFlag, int overprintMode,
257
      GfxColor *singleColor);
258
  SplashPath *convertPath(GfxState *state, GfxPath *path,
259
        GBool dropEmptySubpaths);
260
  void doUpdateFont(GfxState *state);
261
  void drawType3Glyph(GfxState *state, T3FontCache *t3Font,
262
          T3FontCacheTag *tag, Guchar *data);
263
  static GBool imageMaskSrc(void *data, Guchar *line);
264
  static GBool imageSrc(void *data, SplashColorPtr colorLine,
265
      Guchar *alphaLine);
266
  static GBool alphaImageSrc(void *data, SplashColorPtr line,
267
           Guchar *alphaLine);
268
  static GBool maskedImageSrc(void *data, SplashColorPtr line,
269
            Guchar *alphaLine);
270
  static GBool softMaskMatteImageSrc(void *data,
271
             SplashColorPtr colorLine,
272
             Guchar *alphaLine);
273
  GString *makeImageTag(Object *ref, GfxRenderingIntent ri,
274
      GfxColorSpace *colorSpace);
275
  void reduceImageResolution(Stream *str, double *mat,
276
           int *width, int *height);
277
  void clearMaskRegion(GfxState *state,
278
           Splash *maskSplash,
279
           double xMin, double yMin,
280
           double xMax, double yMax);
281
  void copyState(Splash *oldSplash, GBool copyColors);
282
#if 1 //~tmp: turn off anti-aliasing temporarily
283
  void setInShading(GBool sh);
284
#endif
285
286
  SplashColorMode colorMode;
287
  int bitmapRowPad;
288
  GBool bitmapTopDown;
289
  GBool bitmapUpsideDown;
290
  GBool noComposite;
291
  GBool allowAntialias;
292
  GBool vectorAntialias;
293
  GBool reverseVideo;   // reverse video mode
294
  GBool reverseVideoInvertImages;
295
  SplashColor paperColor; // paper color
296
  SplashScreenParams screenParams;
297
  GBool skipHorizText;
298
  GBool skipRotatedText;
299
300
  XRef *xref;     // xref table for current document
301
302
  SplashBitmap *bitmap;
303
  Splash *splash;
304
  SplashFontEngine *fontEngine;
305
306
  T3FontCache *     // Type 3 font cache
307
    t3FontCache[splashOutT3FontCacheSize];
308
  int nT3Fonts;     // number of valid entries in t3FontCache
309
  T3GlyphStack *t3GlyphStack; // Type 3 glyph context stack
310
311
  SplashFont *font;   // current font
312
  GBool needFontUpdate;   // set when the font needs to be updated
313
  SplashPath *savedTextPath;  // path built for text string
314
  SplashPath *savedClipPath;  // clipping path built with text object
315
316
  SplashTransparencyGroup * // transparency group stack
317
    transpGroupStack;
318
319
  int nestCount;
320
321
  void (*startPageCbk)(void *data);
322
  void *startPageCbkData;
323
};
324
325
#endif