1 //========================================================================
5 // Copyright 2003 Glyph & Cog, LLC
7 //========================================================================
9 #ifndef SPLASHOUTPUTDEV_H
10 #define SPLASHOUTPUTDEV_H
14 #ifdef USE_GCC_PRAGMAS
19 #include "SplashTypes.h"
20 #include "xpdfconfig.h"
21 #include "OutputDev.h"
30 class SplashFontEngine;
34 struct T3FontCacheTag;
38 //------------------------------------------------------------------------
40 // number of Type 3 fonts to cache
41 #define splashOutT3FontCacheSize 8
43 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
47 class SplashOutputDev: public OutputDev {
51 SplashOutputDev(SplashColorMode colorModeA, GBool reverseVideoA,
52 SplashColor paperColorA);
55 virtual ~SplashOutputDev();
57 //----- get info about output device
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; }
63 // Does this device use drawChar() or drawString()?
64 virtual GBool useDrawChar() { return gTrue; }
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; }
70 //----- initialization and control
73 virtual void startPage(int pageNum, GfxState *state);
76 virtual void endPage();
79 virtual void drawLink(Link *link, Catalog *catalog);
81 //----- save/restore graphics state
82 virtual void saveState(GfxState *state);
83 virtual void restoreState(GfxState *state);
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);
98 //----- update text state
99 virtual void updateFont(GfxState *state);
101 //----- path painting
102 virtual void stroke(GfxState *state);
103 virtual void fill(GfxState *state);
104 virtual void eoFill(GfxState *state);
106 //----- path clipping
107 virtual void clip(GfxState *state);
108 virtual void eoClip(GfxState *state);
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);
121 //----- image drawing
122 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
123 int width, int height, GBool invert,
125 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
126 int width, int height, GfxImageColorMap *colorMap,
127 int *maskColors, GBool inlineImg);
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);
134 //----- special access
136 // Called to indicate that a new PDF document has been loaded.
137 void startDoc(XRef *xrefA);
139 GBool isReverseVideo() { return reverseVideo; }
141 // Get the bitmap and its size.
142 SplashBitmap *getBitmap() { return bitmap; }
143 int getBitmapWidth();
144 int getBitmapHeight();
146 // Get the Splash object.
147 Splash *getSplash() { return splash; }
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);
154 // Set the Splash fill color.
155 void setFillColor(int r, int g, int b);
157 // Get a font object for a Base-14 font, using the Latin-1 encoding.
158 SplashFont *getFont(GString *name, double *mat);
160 void setUnderlayCbk(void (*cbk)(void *data), void *data)
161 { underlayCbk = cbk; underlayCbkData = data; }
165 SplashPattern *getColor(double gray, GfxRGB *rgb);
166 SplashPath *convertPath(GfxState *state, GfxPath *path);
167 void drawType3Glyph(T3FontCache *t3Font,
168 T3FontCacheTag *tag, Guchar *data,
170 static GBool imageMaskSrc(void *data, SplashMono1 *pixel);
171 static GBool imageSrc(void *data, SplashColor *pixel, Guchar *alpha);
173 SplashColorMode colorMode;
174 GBool reverseVideo; // reverse video mode
175 SplashColor paperColor; // paper color
177 XRef *xref; // xref table for current document
179 SplashBitmap *bitmap;
181 SplashFontEngine *fontEngine;
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
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
192 void (*underlayCbk)(void *data);
193 void *underlayCbkData;