source: trunk/poppler/mypoppler/poppler/SplashOutputDev.h @ 461

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 9.5 KB
Line 
1//========================================================================
2//
3// SplashOutputDev.h
4//
5// Copyright 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 Takashi Iwai <tiwai@suse.de>
17// Copyright (C) 2009, 2010 Thomas Freitag <Thomas.Freitag@alfa.de>
18// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
19//
20// To see a description of the changes please see the Changelog file that
21// came with your tarball or type make ChangeLog if you are building from git
22//
23//========================================================================
24
25#ifndef SPLASHOUTPUTDEV_H
26#define SPLASHOUTPUTDEV_H
27
28#ifdef USE_GCC_PRAGMAS
29#pragma interface
30#endif
31
32#include "goo/gtypes.h"
33#include "splash/SplashTypes.h"
34#include "poppler-config.h"
35#include "OutputDev.h"
36#include "GfxState.h"
37
38class Gfx8BitFont;
39class SplashBitmap;
40class Splash;
41class SplashPath;
42class SplashPattern;
43class SplashFontEngine;
44class SplashFont;
45class T3FontCache;
46struct T3FontCacheTag;
47struct T3GlyphStack;
48struct SplashTransparencyGroup;
49
50//------------------------------------------------------------------------
51
52// number of Type 3 fonts to cache
53#define splashOutT3FontCacheSize 8
54
55//------------------------------------------------------------------------
56// SplashOutputDev
57//------------------------------------------------------------------------
58
59class SplashOutputDev: public OutputDev {
60public:
61
62  // Constructor.
63  SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
64                  GBool reverseVideoA, SplashColorPtr paperColorA,
65                  GBool bitmapTopDownA = gTrue,
66                  GBool allowAntialiasA = gTrue);
67
68  // Destructor.
69  virtual ~SplashOutputDev();
70
71  //----- get info about output device
72
73  // Does this device use upside-down coordinates?
74  // (Upside-down means (0,0) is the top left corner of the page.)
75  virtual GBool upsideDown() { return gTrue; }
76
77  // Does this device use drawChar() or drawString()?
78  virtual GBool useDrawChar() { return gTrue; }
79
80  // Does this device use beginType3Char/endType3Char?  Otherwise,
81  // text in Type 3 fonts will be drawn with drawChar/drawString.
82  virtual GBool interpretType3Chars() { return gTrue; }
83
84  // This device now supports text in pattern colorspace!
85  virtual GBool supportTextCSPattern(GfxState *state)
86        { return state->getFillColorSpace()->getMode() == csPattern; }
87
88  //----- initialization and control
89
90  // Start a page.
91  virtual void startPage(int pageNum, GfxState *state);
92
93  // End a page.
94  virtual void endPage();
95
96  //----- save/restore graphics state
97  virtual void saveState(GfxState *state);
98  virtual void restoreState(GfxState *state);
99
100  //----- update graphics state
101  virtual void updateAll(GfxState *state);
102  virtual void updateCTM(GfxState *state, double m11, double m12,
103                         double m21, double m22, double m31, double m32);
104  virtual void updateLineDash(GfxState *state);
105  virtual void updateFlatness(GfxState *state);
106  virtual void updateLineJoin(GfxState *state);
107  virtual void updateLineCap(GfxState *state);
108  virtual void updateMiterLimit(GfxState *state);
109  virtual void updateLineWidth(GfxState *state);
110  virtual void updateStrokeAdjust(GfxState *state);
111  virtual void updateFillColor(GfxState *state);
112  virtual void updateStrokeColor(GfxState *state);
113  virtual void updateBlendMode(GfxState *state);
114  virtual void updateFillOpacity(GfxState *state);
115  virtual void updateStrokeOpacity(GfxState *state);
116
117  //----- update text state
118  virtual void updateFont(GfxState *state);
119  virtual void updateRender(GfxState *state);
120
121  //----- path painting
122  virtual void stroke(GfxState *state);
123  virtual void fill(GfxState *state);
124  virtual void eoFill(GfxState *state);
125
126  //----- path clipping
127  virtual void clip(GfxState *state);
128  virtual void eoClip(GfxState *state);
129  virtual void clipToStrokePath(GfxState *state);
130
131  //----- text drawing
132  virtual void drawChar(GfxState *state, double x, double y,
133                        double dx, double dy,
134                        double originX, double originY,
135                        CharCode code, int nBytes, Unicode *u, int uLen);
136  virtual GBool beginType3Char(GfxState *state, double x, double y,
137                               double dx, double dy,
138                               CharCode code, Unicode *u, int uLen);
139  virtual void endType3Char(GfxState *state);
140  virtual void beginTextObject(GfxState *state);
141  virtual GBool deviceHasTextClip(GfxState *state) { return textClipPath && haveCSPattern; }
142  virtual void endTextObject(GfxState *state);
143
144  //----- image drawing
145  virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
146                             int width, int height, GBool invert,
147                             GBool interpolate, GBool inlineImg);
148  virtual void drawImage(GfxState *state, Object *ref, Stream *str,
149                         int width, int height, GfxImageColorMap *colorMap,
150                         GBool interpolate, int *maskColors, GBool inlineImg);
151  virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
152                               int width, int height,
153                               GfxImageColorMap *colorMap,
154                               GBool interpolate,
155                               Stream *maskStr, int maskWidth, int maskHeight,
156                               GBool maskInvert, GBool maskInterpolate);
157  virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
158                                   int width, int height,
159                                   GfxImageColorMap *colorMap,
160                                   GBool interpolate,
161                                   Stream *maskStr,
162                                   int maskWidth, int maskHeight,
163                                   GfxImageColorMap *maskColorMap,
164                                   GBool maskInterpolate);
165  // If current colorspace ist pattern,
166  // need this device special handling for masks in pattern colorspace?
167  // Default is false
168  virtual GBool fillMaskCSPattern(GfxState * state)
169        { return state->getFillColorSpace()->getMode() == csPattern; }
170  virtual void endMaskClip(GfxState * /*state*/);
171
172  //----- Type 3 font operators
173  virtual void type3D0(GfxState *state, double wx, double wy);
174  virtual void type3D1(GfxState *state, double wx, double wy,
175                       double llx, double lly, double urx, double ury);
176
177  //----- transparency groups and soft masks
178  virtual void beginTransparencyGroup(GfxState *state, double *bbox,
179                                      GfxColorSpace *blendingColorSpace,
180                                      GBool isolated, GBool knockout,
181                                      GBool forSoftMask);
182  virtual void endTransparencyGroup(GfxState *state);
183  virtual void paintTransparencyGroup(GfxState *state, double *bbox);
184  virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha,
185                           Function *transferFunc, GfxColor *backdropColor);
186  virtual void clearSoftMask(GfxState *state);
187
188  //----- special access
189
190  // Called to indicate that a new PDF document has been loaded.
191  void startDoc(XRef *xrefA);
192 
193  void setPaperColor(SplashColorPtr paperColorA);
194
195  GBool isReverseVideo() { return reverseVideo; }
196  void setReverseVideo(GBool reverseVideoA) { reverseVideo = reverseVideoA; }
197
198  // Get the bitmap and its size.
199  SplashBitmap *getBitmap() { return bitmap; }
200  int getBitmapWidth();
201  int getBitmapHeight();
202
203  // Returns the last rasterized bitmap, transferring ownership to the
204  // caller.
205  SplashBitmap *takeBitmap();
206
207  // Get the Splash object.
208  Splash *getSplash() { return splash; }
209
210  // Get the modified region.
211  void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax);
212
213  // Clear the modified region.
214  void clearModRegion();
215
216  // Set the Splash fill color.
217  void setFillColor(int r, int g, int b);
218
219  SplashFont *getCurrentFont() { return font; }
220
221#if 1 //~tmp: turn off anti-aliasing temporarily
222  virtual GBool getVectorAntialias();
223  virtual void setVectorAntialias(GBool vaa);
224#endif
225
226  void setFreeTypeHinting(GBool enable);
227
228private:
229
230  void setupScreenParams(double hDPI, double vDPI);
231#if SPLASH_CMYK
232  SplashPattern *getColor(GfxGray gray, GfxRGB *rgb, GfxCMYK *cmyk);
233#else
234  SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
235#endif
236  SplashPath *convertPath(GfxState *state, GfxPath *path);
237  void doUpdateFont(GfxState *state);
238  void drawType3Glyph(T3FontCache *t3Font,
239                      T3FontCacheTag *tag, Guchar *data);
240  static GBool imageMaskSrc(void *data, SplashColorPtr line);
241  static GBool imageSrc(void *data, SplashColorPtr colorLine,
242                        Guchar *alphaLine);
243  static GBool alphaImageSrc(void *data, SplashColorPtr line,
244                             Guchar *alphaLine);
245  static GBool maskedImageSrc(void *data, SplashColorPtr line,
246                              Guchar *alphaLine);
247
248  GBool haveCSPattern;          // set if text has been drawn with a
249                                //   clipping render mode because of pattern colorspace
250  int savedRender;              // use if pattern colorspace
251  GBool keepAlphaChannel;       // don't fill with paper color, keep alpha channel
252
253  SplashColorMode colorMode;
254  int bitmapRowPad;
255  GBool bitmapTopDown;
256  GBool allowAntialias;
257  GBool vectorAntialias;
258  GBool enableFreeTypeHinting;
259  GBool reverseVideo;           // reverse video mode
260  SplashColor paperColor;       // paper color
261  SplashScreenParams screenParams;
262
263  XRef *xref;                   // xref table for current document
264
265  SplashBitmap *bitmap;
266  Splash *splash;
267  SplashFontEngine *fontEngine;
268
269  T3FontCache *                 // Type 3 font cache
270    t3FontCache[splashOutT3FontCacheSize];
271  int nT3Fonts;                 // number of valid entries in t3FontCache
272  T3GlyphStack *t3GlyphStack;   // Type 3 glyph context stack
273
274  SplashFont *font;             // current font
275  GBool needFontUpdate;         // set when the font needs to be updated
276  SplashPath *textClipPath;     // clipping path built with text object
277
278  SplashTransparencyGroup *     // transparency group stack
279    transpGroupStack;
280  SplashBitmap *maskBitmap; // for image masks in pattern colorspace
281};
282
283#endif
Note: See TracBrowser for help on using the repository browser.