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