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