]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/SplashOutputDev.h
b2ecfea17c06f01a21ac5a285c79e311a597369f
[evince.git] / pdf / xpdf / SplashOutputDev.h
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 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include "gtypes.h"
19 #include "SplashTypes.h"
20 #include "xpdfconfig.h"
21 #include "OutputDev.h"
22
23 class GfxState;
24 class GfxPath;
25 class Gfx8BitFont;
26 class SplashBitmap;
27 class Splash;
28 class SplashPath;
29 class SplashPattern;
30 class SplashFontEngine;
31 class SplashFont;
32 class T3FontCache;
33 class XRef;
34 struct T3FontCacheTag;
35 struct T3GlyphStack;
36 struct GfxRGB;
37
38 //------------------------------------------------------------------------
39
40 // number of Type 3 fonts to cache
41 #define splashOutT3FontCacheSize 8
42
43 //------------------------------------------------------------------------
44 // SplashOutputDev
45 //------------------------------------------------------------------------
46
47 class SplashOutputDev: public OutputDev {
48 public:
49
50   // Constructor.
51   SplashOutputDev(SplashColorMode colorModeA, GBool reverseVideoA,
52                   SplashColor paperColorA);
53
54   // Destructor.
55   virtual ~SplashOutputDev();
56
57   //----- get info about output device
58
59   // Does this device use upside-down coordinates?
60   // (Upside-down means (0,0) is the top left corner of the page.)
61   virtual GBool upsideDown() { return gTrue; }
62
63   // Does this device use drawChar() or drawString()?
64   virtual GBool useDrawChar() { return gTrue; }
65
66   // Does this device use beginType3Char/endType3Char?  Otherwise,
67   // text in Type 3 fonts will be drawn with drawChar/drawString.
68   virtual GBool interpretType3Chars() { return gTrue; }
69
70   //----- initialization and control
71
72   // Start a page.
73   virtual void startPage(int pageNum, GfxState *state);
74
75   // End a page.
76   virtual void endPage();
77
78   //----- link borders
79   virtual void drawLink(Link *link, Catalog *catalog);
80
81   //----- save/restore graphics state
82   virtual void saveState(GfxState *state);
83   virtual void restoreState(GfxState *state);
84
85   //----- update graphics state
86   virtual void updateAll(GfxState *state);
87   virtual void updateCTM(GfxState *state, double m11, double m12,
88                          double m21, double m22, double m31, double m32);
89   virtual void updateLineDash(GfxState *state);
90   virtual void updateFlatness(GfxState *state);
91   virtual void updateLineJoin(GfxState *state);
92   virtual void updateLineCap(GfxState *state);
93   virtual void updateMiterLimit(GfxState *state);
94   virtual void updateLineWidth(GfxState *state);
95   virtual void updateFillColor(GfxState *state);
96   virtual void updateStrokeColor(GfxState *state);
97
98   //----- update text state
99   virtual void updateFont(GfxState *state);
100
101   //----- path painting
102   virtual void stroke(GfxState *state);
103   virtual void fill(GfxState *state);
104   virtual void eoFill(GfxState *state);
105
106   //----- path clipping
107   virtual void clip(GfxState *state);
108   virtual void eoClip(GfxState *state);
109
110   //----- text drawing
111   virtual void drawChar(GfxState *state, double x, double y,
112                         double dx, double dy,
113                         double originX, double originY,
114                         CharCode code, Unicode *u, int uLen);
115   virtual GBool beginType3Char(GfxState *state, double x, double y,
116                                double dx, double dy,
117                                CharCode code, Unicode *u, int uLen);
118   virtual void endType3Char(GfxState *state);
119   virtual void endTextObject(GfxState *state);
120
121   //----- image drawing
122   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
123                              int width, int height, GBool invert,
124                              GBool inlineImg);
125   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
126                          int width, int height, GfxImageColorMap *colorMap,
127                          int *maskColors, GBool inlineImg);
128
129   //----- Type 3 font operators
130   virtual void type3D0(GfxState *state, double wx, double wy);
131   virtual void type3D1(GfxState *state, double wx, double wy,
132                        double llx, double lly, double urx, double ury);
133
134   //----- special access
135
136   // Called to indicate that a new PDF document has been loaded.
137   void startDoc(XRef *xrefA);
138  
139   GBool isReverseVideo() { return reverseVideo; }
140
141   // Get the bitmap and its size.
142   SplashBitmap *getBitmap() { return bitmap; }
143   int getBitmapWidth();
144   int getBitmapHeight();
145
146   // Get the Splash object.
147   Splash *getSplash() { return splash; }
148
149   // XOR a rectangular region in the bitmap with <pattern>.  <pattern>
150   // is passed to Splash::setFillPattern, so it should not be used
151   // after calling this function.
152   void xorRectangle(int x0, int y0, int x1, int y1, SplashPattern *pattern);
153
154   // Set the Splash fill color.
155   void setFillColor(int r, int g, int b);
156
157   // Get a font object for a Base-14 font, using the Latin-1 encoding.
158   SplashFont *getFont(GString *name, double *mat);
159
160   void setUnderlayCbk(void (*cbk)(void *data), void *data)
161     { underlayCbk = cbk; underlayCbkData = data; }
162
163 private:
164
165   SplashPattern *getColor(double gray, GfxRGB *rgb);
166   SplashPath *convertPath(GfxState *state, GfxPath *path);
167   void drawType3Glyph(T3FontCache *t3Font,
168                       T3FontCacheTag *tag, Guchar *data,
169                       double x, double y);
170   static GBool imageMaskSrc(void *data, SplashMono1 *pixel);
171   static GBool imageSrc(void *data, SplashColor *pixel, Guchar *alpha);
172
173   SplashColorMode colorMode;
174   GBool reverseVideo;           // reverse video mode
175   SplashColor paperColor;       // paper color
176
177   XRef *xref;                   // xref table for current document
178
179   SplashBitmap *bitmap;
180   Splash *splash;
181   SplashFontEngine *fontEngine;
182
183   T3FontCache *                 // Type 3 font cache
184     t3FontCache[splashOutT3FontCacheSize];
185   int nT3Fonts;                 // number of valid entries in t3FontCache
186   T3GlyphStack *t3GlyphStack;   // Type 3 glyph context stack
187
188   SplashFont *font;             // current font
189   GBool needFontUpdate;         // set when the font needs to be updated
190   SplashPath *textClipPath;     // clipping path built with text object
191
192   void (*underlayCbk)(void *data);
193   void *underlayCbkData;
194 };
195
196 #endif