1 //========================================================================
2 //
3 // PreScanOutputDev.h
4 //
5 // Copyright 2005 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #ifndef PRESCANOUTPUTDEV_H
10 #define PRESCANOUTPUTDEV_H
11 
12 #include <aconf.h>
13 
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17 
18 #include "gtypes.h"
19 #include "GfxState.h"
20 #include "OutputDev.h"
21 
22 //------------------------------------------------------------------------
23 // PreScanOutputDev
24 //------------------------------------------------------------------------
25 
26 class PreScanOutputDev: public OutputDev {
27 public:
28 
29   // Constructor.
30   PreScanOutputDev();
31 
32   // Destructor.
33   virtual ~PreScanOutputDev();
34 
35   //----- get info about output device
36 
37   // Does this device use upside-down coordinates?
38   // (Upside-down means (0,0) is the top left corner of the page.)
upsideDown()39   virtual GBool upsideDown() { return gTrue; }
40 
41   // Does this device use drawChar() or drawString()?
useDrawChar()42   virtual GBool useDrawChar() { return gTrue; }
43 
44   // Does this device use tilingPatternFill()?  If this returns false,
45   // tiling pattern fills will be reduced to a series of other drawing
46   // operations.
useTilingPatternFill()47   virtual GBool useTilingPatternFill() { return gTrue; }
48 
49   // Does this device use beginType3Char/endType3Char?  Otherwise,
50   // text in Type 3 fonts will be drawn with drawChar/drawString.
interpretType3Chars()51   virtual GBool interpretType3Chars() { return gTrue; }
52 
53   //----- initialization and control
54 
55   // Start a page.
56   virtual void startPage(int pageNum, GfxState *state);
57 
58   // End a page.
59   virtual void endPage();
60 
61   //----- path painting
62   virtual void stroke(GfxState *state);
63   virtual void fill(GfxState *state);
64   virtual void eoFill(GfxState *state);
65   virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *strRef,
66 				 int paintType, int tilingType, Dict *resDict,
67 				 double *mat, double *bbox,
68 				 int x0, int y0, int x1, int y1,
69 				 double xStep, double yStep);
70   virtual GBool shadedFill(GfxState *state, GfxShading *shading);
71 
72   //----- path clipping
73   virtual void clip(GfxState *state);
74   virtual void eoClip(GfxState *state);
75 
76   //----- text drawing
77   virtual void beginStringOp(GfxState *state);
78   virtual void endStringOp(GfxState *state);
79   virtual GBool beginType3Char(GfxState *state, double x, double y,
80 			       double dx, double dy,
81 			       CharCode code, Unicode *u, int uLen);
82   virtual void endType3Char(GfxState *state);
83 
84   //----- image drawing
85   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
86 			     int width, int height, GBool invert,
87 			     GBool inlineImg, GBool interpolate);
88   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
89 			 int width, int height, GfxImageColorMap *colorMap,
90 			 int *maskColors, GBool inlineImg, GBool interpolate);
91   virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
92 			       int width, int height,
93 			       GfxImageColorMap *colorMap,
94 			       Object *maskRef, Stream *maskStr,
95 			       int maskWidth, int maskHeight,
96 			       GBool maskInvert, GBool interpolate);
97   virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
98 				   int width, int height,
99 				   GfxImageColorMap *colorMap,
100 				   Object *maskRef, Stream *maskStr,
101 				   int maskWidth, int maskHeight,
102 				   GfxImageColorMap *maskColorMap,
103 				   double *matte, GBool interpolate);
104 
105   //----- transparency groups and soft masks
106   virtual void beginTransparencyGroup(GfxState *state, double *bbox,
107 				      GfxColorSpace *blendingColorSpace,
108 				      GBool isolated, GBool knockout,
109 				      GBool forSoftMask);
110 
111   //----- special access
112 
113   // Returns true if the operations performed since the last call to
114   // clearStats() are all monochrome (black or white).
isMonochrome()115   GBool isMonochrome() { return mono; }
116 
117   // Returns true if the operations performed since the last call to
118   // clearStats() are all gray.
isGray()119   GBool isGray() { return gray; }
120 
121   // Returns true if the operations performed since the last call to
122   // clearStats() included any transparency.
usesTransparency()123   GBool usesTransparency() { return transparency; }
124 
125   // Returns true if the operations performed since the last call to
126   // clearStats() included any image mask fills with a pattern color
127   // space.
usesPatternImageMask()128   GBool usesPatternImageMask() { return patternImgMask; }
129 
130   // Returns true if the operations performed since the last call to
131   // clearStats() are all rasterizable by GDI calls in GDIOutputDev.
isAllGDI()132   GBool isAllGDI() { return gdi; }
133 
134   // Clear the stats used by the above functions.
135   void clearStats();
136 
137 private:
138 
139   void check(GfxState *state, GfxColorSpace *colorSpace, GfxColor *color,
140 	     double opacity, GfxBlendMode blendMode);
141 
142   GBool mono;
143   GBool gray;
144   GBool transparency;
145   GBool patternImgMask;
146   GBool gdi;
147 };
148 
149 #endif
150