1 //========================================================================
2 //
3 // OutputDev.h
4 //
5 // Copyright 1996-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 Jonathan Blandford <jrb@redhat.com>
17 // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no>
18 // Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
19 // Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com>
20 // Copyright (C) 2009, 2010 Thomas Freitag <Thomas.Freitag@alfa.de>
21 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
22 // Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
23 // Copyright (C) 2010 Christian Feuers�nger <cfeuersaenger@googlemail.com>
24 //
25 // To see a description of the changes please see the Changelog file that
26 // came with your tarball or type make ChangeLog if you are building from git
27 //
28 //========================================================================
29 
30 #ifndef OUTPUTDEV_H
31 #define OUTPUTDEV_H
32 
33 #ifdef USE_GCC_PRAGMAS
34 #pragma interface
35 #endif
36 
37 #include "poppler-config.h"
38 #include "goo/gtypes.h"
39 #include "CharTypes.h"
40 #include "Object.h"
41 
42 class Dict;
43 class GooHash;
44 class GooString;
45 class GfxState;
46 struct GfxColor;
47 class GfxColorSpace;
48 class GfxImageColorMap;
49 class GfxFunctionShading;
50 class GfxAxialShading;
51 class GfxGouraudTriangleShading;
52 class GfxPatchMeshShading;
53 class GfxRadialShading;
54 class Stream;
55 class Links;
56 class Link;
57 class Catalog;
58 class Page;
59 class Function;
60 
61 //------------------------------------------------------------------------
62 // OutputDev
63 //------------------------------------------------------------------------
64 
65 class OutputDev {
66 public:
67 
68   // Constructor.
OutputDev()69   OutputDev() { profileHash = NULL; }
70 
71   // Destructor.
~OutputDev()72   virtual ~OutputDev() {}
73 
74   //----- get info about output device
75 
76   // Does this device use upside-down coordinates?
77   // (Upside-down means (0,0) is the top left corner of the page.)
78   virtual GBool upsideDown() = 0;
79 
80   // Does this device use drawChar() or drawString()?
81   virtual GBool useDrawChar() = 0;
82 
83   // Does this device use tilingPatternFill()?  If this returns false,
84   // tiling pattern fills will be reduced to a series of other drawing
85   // operations.
useTilingPatternFill()86   virtual GBool useTilingPatternFill() { return gFalse; }
87 
88   // Does this device support specific shading types?
89   // see gouraudTriangleShadedFill() and patchMeshShadedFill()
useShadedFills(int type)90   virtual GBool useShadedFills(int type) { return gFalse; }
91 
92   // Does this device use FillColorStop()?
useFillColorStop()93   virtual GBool useFillColorStop() { return gFalse; }
94 
95   // Does this device use drawForm()?  If this returns false,
96   // form-type XObjects will be interpreted (i.e., unrolled).
useDrawForm()97   virtual GBool useDrawForm() { return gFalse; }
98 
99   // Does this device use beginType3Char/endType3Char?  Otherwise,
100   // text in Type 3 fonts will be drawn with drawChar/drawString.
101   virtual GBool interpretType3Chars() = 0;
102 
103   // Does this device need non-text content?
needNonText()104   virtual GBool needNonText() { return gTrue; }
105 
106   // If current colorspace ist pattern,
107   // does this device support text in pattern colorspace?
108   // Default is false
supportTextCSPattern(GfxState *)109   virtual GBool supportTextCSPattern(GfxState * /*state*/) { return gFalse; }
110 
111   // If current colorspace ist pattern,
112   // need this device special handling for masks in pattern colorspace?
113   // Default is false
fillMaskCSPattern(GfxState *)114   virtual GBool fillMaskCSPattern(GfxState * /*state*/) { return gFalse; }
endMaskClip(GfxState *)115   virtual void endMaskClip(GfxState * /*state*/) {}
116 
117   //----- initialization and control
118 
119   // Set default transform matrix.
120   virtual void setDefaultCTM(double *ctm);
121 
122   // Check to see if a page slice should be displayed.  If this
123   // returns false, the page display is aborted.  Typically, an
124   // OutputDev will use some alternate means to display the page
125   // before returning false.
126   virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI,
127 			       int rotate, GBool useMediaBox, GBool crop,
128 			       int sliceX, int sliceY, int sliceW, int sliceH,
129 			       GBool printing, Catalog * catalog,
130 			       GBool (* abortCheckCbk)(void *data) = NULL,
131 			       void * abortCheckCbkData = NULL)
132     { return gTrue; }
133 
134   // Start a page.
startPage(int pageNum,GfxState * state)135   virtual void startPage(int pageNum, GfxState *state) {}
136 
137   // End a page.
endPage()138   virtual void endPage() {}
139 
140   // Dump page contents to display.
dump()141   virtual void dump() {}
142 
143   //----- coordinate conversion
144 
145   // Convert between device and user coordinates.
146   virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
147   virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
148 
getDefCTM()149   double *getDefCTM() { return defCTM; }
getDefICTM()150   double *getDefICTM() { return defICTM; }
151 
152   //----- save/restore graphics state
saveState(GfxState *)153   virtual void saveState(GfxState * /*state*/) {}
restoreState(GfxState *)154   virtual void restoreState(GfxState * /*state*/) {}
155 
156   //----- update graphics state
157   virtual void updateAll(GfxState *state);
updateCTM(GfxState *,double,double,double,double,double,double)158   virtual void updateCTM(GfxState * /*state*/, double /*m11*/, double /*m12*/,
159 			 double /*m21*/, double /*m22*/, double /*m31*/, double /*m32*/) {}
updateLineDash(GfxState *)160   virtual void updateLineDash(GfxState * /*state*/) {}
updateFlatness(GfxState *)161   virtual void updateFlatness(GfxState * /*state*/) {}
updateLineJoin(GfxState *)162   virtual void updateLineJoin(GfxState * /*state*/) {}
updateLineCap(GfxState *)163   virtual void updateLineCap(GfxState * /*state*/) {}
updateMiterLimit(GfxState *)164   virtual void updateMiterLimit(GfxState * /*state*/) {}
updateLineWidth(GfxState *)165   virtual void updateLineWidth(GfxState * /*state*/) {}
updateStrokeAdjust(GfxState *)166   virtual void updateStrokeAdjust(GfxState * /*state*/) {}
updateAlphaIsShape(GfxState *)167   virtual void updateAlphaIsShape(GfxState * /*state*/) {}
updateTextKnockout(GfxState *)168   virtual void updateTextKnockout(GfxState * /*state*/) {}
updateFillColorSpace(GfxState *)169   virtual void updateFillColorSpace(GfxState * /*state*/) {}
updateStrokeColorSpace(GfxState *)170   virtual void updateStrokeColorSpace(GfxState * /*state*/) {}
updateFillColor(GfxState *)171   virtual void updateFillColor(GfxState * /*state*/) {}
updateStrokeColor(GfxState *)172   virtual void updateStrokeColor(GfxState * /*state*/) {}
updateBlendMode(GfxState *)173   virtual void updateBlendMode(GfxState * /*state*/) {}
updateFillOpacity(GfxState *)174   virtual void updateFillOpacity(GfxState * /*state*/) {}
updateStrokeOpacity(GfxState *)175   virtual void updateStrokeOpacity(GfxState * /*state*/) {}
updateFillOverprint(GfxState *)176   virtual void updateFillOverprint(GfxState * /*state*/) {}
updateStrokeOverprint(GfxState *)177   virtual void updateStrokeOverprint(GfxState * /*state*/) {}
updateTransfer(GfxState *)178   virtual void updateTransfer(GfxState * /*state*/) {}
updateFillColorStop(GfxState *,double)179   virtual void updateFillColorStop(GfxState * /*state*/, double /*offset*/) {}
180 
181   //----- update text state
updateFont(GfxState *)182   virtual void updateFont(GfxState * /*state*/) {}
updateTextMat(GfxState *)183   virtual void updateTextMat(GfxState * /*state*/) {}
updateCharSpace(GfxState *)184   virtual void updateCharSpace(GfxState * /*state*/) {}
updateRender(GfxState *)185   virtual void updateRender(GfxState * /*state*/) {}
updateRise(GfxState *)186   virtual void updateRise(GfxState * /*state*/) {}
updateWordSpace(GfxState *)187   virtual void updateWordSpace(GfxState * /*state*/) {}
updateHorizScaling(GfxState *)188   virtual void updateHorizScaling(GfxState * /*state*/) {}
updateTextPos(GfxState *)189   virtual void updateTextPos(GfxState * /*state*/) {}
updateTextShift(GfxState *,double)190   virtual void updateTextShift(GfxState * /*state*/, double /*shift*/) {}
191 
192   //----- path painting
stroke(GfxState *)193   virtual void stroke(GfxState * /*state*/) {}
fill(GfxState *)194   virtual void fill(GfxState * /*state*/) {}
eoFill(GfxState *)195   virtual void eoFill(GfxState * /*state*/) {}
tilingPatternFill(GfxState *,Object *,int,Dict *,double *,double *,int,int,int,int,double,double)196   virtual GBool tilingPatternFill(GfxState * /*state*/, Object * /*str*/,
197 				  int /*paintType*/, Dict * /*resDict*/,
198 				  double * /*mat*/, double * /*bbox*/,
199 				  int /*x0*/, int /*y0*/, int /*x1*/, int /*y1*/,
200 				  double /*xStep*/, double /*yStep*/)
201     { return gFalse; }
functionShadedFill(GfxState *,GfxFunctionShading *)202   virtual GBool functionShadedFill(GfxState * /*state*/,
203 				   GfxFunctionShading * /*shading*/)
204     { return gFalse; }
axialShadedFill(GfxState *,GfxAxialShading *,double,double)205   virtual GBool axialShadedFill(GfxState * /*state*/, GfxAxialShading * /*shading*/, double /*tMin*/, double /*tMax*/)
206     { return gFalse; }
axialShadedSupportExtend(GfxState *,GfxAxialShading *)207   virtual GBool axialShadedSupportExtend(GfxState * /*state*/, GfxAxialShading * /*shading*/)
208     { return gFalse; }
radialShadedFill(GfxState *,GfxRadialShading *,double,double)209   virtual GBool radialShadedFill(GfxState * /*state*/, GfxRadialShading * /*shading*/, double /*sMin*/, double /*sMax*/)
210     { return gFalse; }
radialShadedSupportExtend(GfxState *,GfxRadialShading *)211   virtual GBool radialShadedSupportExtend(GfxState * /*state*/, GfxRadialShading * /*shading*/)
212     { return gFalse; }
gouraudTriangleShadedFill(GfxState * state,GfxGouraudTriangleShading * shading)213   virtual GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading)
214     { return gFalse; }
patchMeshShadedFill(GfxState * state,GfxPatchMeshShading * shading)215   virtual GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading)
216     { return gFalse; }
217 
218   //----- path clipping
clip(GfxState *)219   virtual void clip(GfxState * /*state*/) {}
eoClip(GfxState *)220   virtual void eoClip(GfxState * /*state*/) {}
clipToStrokePath(GfxState *)221   virtual void clipToStrokePath(GfxState * /*state*/) {}
222 
223   //----- text drawing
beginStringOp(GfxState *)224   virtual void beginStringOp(GfxState * /*state*/) {}
endStringOp(GfxState *)225   virtual void endStringOp(GfxState * /*state*/) {}
beginString(GfxState *,GooString *)226   virtual void beginString(GfxState * /*state*/, GooString * /*s*/) {}
endString(GfxState *)227   virtual void endString(GfxState * /*state*/) {}
drawChar(GfxState *,double,double,double,double,double,double,CharCode,int,Unicode *,int)228   virtual void drawChar(GfxState * /*state*/, double /*x*/, double /*y*/,
229 			double /*dx*/, double /*dy*/,
230 			double /*originX*/, double /*originY*/,
231 			CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/) {}
drawString(GfxState *,GooString *)232   virtual void drawString(GfxState * /*state*/, GooString * /*s*/) {}
233   virtual GBool beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/,
234 			       double /*dx*/, double /*dy*/,
235 			       CharCode /*code*/, Unicode * /*u*/, int /*uLen*/);
endType3Char(GfxState *)236   virtual void endType3Char(GfxState * /*state*/) {}
beginTextObject(GfxState *)237   virtual void beginTextObject(GfxState * /*state*/) {}
deviceHasTextClip(GfxState *)238   virtual GBool deviceHasTextClip(GfxState * /*state*/) { return gFalse; }
endTextObject(GfxState *)239   virtual void endTextObject(GfxState * /*state*/) {}
240 
241   //----- image drawing
242   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
243 			     int width, int height, GBool invert, GBool interpolate,
244 			     GBool inlineImg);
245   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
246 			 int width, int height, GfxImageColorMap *colorMap,
247 			 GBool interpolate, int *maskColors, GBool inlineImg);
248   virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
249 			       int width, int height,
250 			       GfxImageColorMap *colorMap, GBool interpolate,
251 			       Stream *maskStr, int maskWidth, int maskHeight,
252 			       GBool maskInvert, GBool maskInterpolate);
253   virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
254 				   int width, int height,
255 				   GfxImageColorMap *colorMap,
256 				   GBool interpolate,
257 				   Stream *maskStr,
258 				   int maskWidth, int maskHeight,
259 				   GfxImageColorMap *maskColorMap,
260 				   GBool maskInterpolate);
261 
262   //----- grouping operators
263 
264   virtual void endMarkedContent(GfxState *state);
265   virtual void beginMarkedContent(char *name, Dict *properties);
266   virtual void markPoint(char *name);
267   virtual void markPoint(char *name, Dict *properties);
268 
269 
270 
271 #if OPI_SUPPORT
272   //----- OPI functions
273   virtual void opiBegin(GfxState *state, Dict *opiDict);
274   virtual void opiEnd(GfxState *state, Dict *opiDict);
275 #endif
276 
277   //----- Type 3 font operators
type3D0(GfxState *,double,double)278   virtual void type3D0(GfxState * /*state*/, double /*wx*/, double /*wy*/) {}
type3D1(GfxState *,double,double,double,double,double,double)279   virtual void type3D1(GfxState * /*state*/, double /*wx*/, double /*wy*/,
280 		       double /*llx*/, double /*lly*/, double /*urx*/, double /*ury*/) {}
281 
282   //----- form XObjects
drawForm(Ref)283   virtual void drawForm(Ref /*id*/) {}
284 
285   //----- PostScript XObjects
psXObject(Stream *,Stream *)286   virtual void psXObject(Stream * /*psStream*/, Stream * /*level1Stream*/) {}
287 
288   //----- Profiling
289   virtual void startProfile();
getProfileHash()290   virtual GooHash *getProfileHash() {return profileHash; }
291   virtual GooHash *endProfile();
292 
293   //----- transparency groups and soft masks
beginTransparencyGroup(GfxState *,double *,GfxColorSpace *,GBool,GBool,GBool)294   virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
295 				      GfxColorSpace * /*blendingColorSpace*/,
296 				      GBool /*isolated*/, GBool /*knockout*/,
297 				      GBool /*forSoftMask*/) {}
endTransparencyGroup(GfxState *)298   virtual void endTransparencyGroup(GfxState * /*state*/) {}
paintTransparencyGroup(GfxState *,double *)299   virtual void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) {}
setSoftMask(GfxState *,double *,GBool,Function *,GfxColor *)300   virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
301 			   Function * /*transferFunc*/, GfxColor * /*backdropColor*/) {}
clearSoftMask(GfxState *)302   virtual void clearSoftMask(GfxState * /*state*/) {}
303 
304   //----- links
processLink(Link *,Catalog *)305   virtual void processLink(Link * /*link*/, Catalog * /*catalog*/) {}
306 
307 #if 1 //~tmp: turn off anti-aliasing temporarily
getVectorAntialias()308   virtual GBool getVectorAntialias() { return gFalse; }
setVectorAntialias(GBool)309   virtual void setVectorAntialias(GBool /*vaa*/) {}
310 #endif
311 
312 private:
313 
314   double defCTM[6];		// default coordinate transform matrix
315   double defICTM[6];		// inverse of default CTM
316   GooHash *profileHash;
317 };
318 
319 #endif
320