]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 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 <config.h> | |
13 | ||
14 | #ifdef USE_GCC_PRAGMAS | |
15 | #pragma interface | |
16 | #endif | |
17 | ||
18 | #include "gtypes.h" | |
19 | #include "SplashTypes.h" | |
20 | #include "config.h" | |
21 | #include "OutputDev.h" | |
22 | #include "GfxState.h" | |
23 | ||
24 | class Gfx8BitFont; | |
25 | class SplashBitmap; | |
26 | class Splash; | |
27 | class SplashPath; | |
28 | class SplashPattern; | |
29 | class SplashFontEngine; | |
30 | class SplashFont; | |
31 | class T3FontCache; | |
32 | struct T3FontCacheTag; | |
33 | struct T3GlyphStack; | |
34 | ||
35 | //------------------------------------------------------------------------ | |
36 | ||
37 | // number of Type 3 fonts to cache | |
38 | #define splashOutT3FontCacheSize 8 | |
39 | ||
40 | //------------------------------------------------------------------------ | |
41 | // SplashOutputDev | |
42 | //------------------------------------------------------------------------ | |
43 | ||
44 | class SplashOutputDev: public OutputDev { | |
45 | public: | |
46 | ||
47 | // Constructor. | |
48 | SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA, | |
49 | GBool reverseVideoA, SplashColorPtr paperColorA, | |
50 | GBool bitmapTopDownA = gTrue, | |
51 | GBool allowAntialiasA = gTrue); | |
52 | ||
53 | // Destructor. | |
54 | virtual ~SplashOutputDev(); | |
55 | ||
56 | //----- get info about output device | |
57 | ||
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; } | |
61 | ||
62 | // Does this device use drawChar() or drawString()? | |
63 | virtual GBool useDrawChar() { return gTrue; } | |
64 | ||
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; } | |
68 | ||
69 | //----- initialization and control | |
70 | ||
71 | // Start a page. | |
72 | virtual GBool startPage(int pageNum, GfxState *state); | |
73 | ||
74 | // End a page. | |
75 | virtual void endPage(); | |
76 | ||
77 | //----- link borders | |
78 | virtual void drawLink(Link *link, Catalog *catalog); | |
79 | ||
80 | //----- save/restore graphics state | |
81 | virtual void saveState(GfxState *state); | |
82 | virtual void restoreState(GfxState *state); | |
83 | ||
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); | |
96 | virtual void updateBlendMode(GfxState *state); | |
97 | virtual void updateFillOpacity(GfxState *state); | |
98 | virtual void updateStrokeOpacity(GfxState *state); | |
99 | ||
100 | //----- update text state | |
101 | virtual void updateFont(GfxState *state); | |
102 | ||
103 | //----- path painting | |
104 | virtual void stroke(GfxState *state); | |
105 | virtual void fill(GfxState *state); | |
106 | virtual void eoFill(GfxState *state); | |
107 | ||
108 | //----- path clipping | |
109 | virtual void clip(GfxState *state); | |
110 | virtual void eoClip(GfxState *state); | |
111 | ||
112 | //----- text drawing | |
113 | virtual void drawChar(GfxState *state, double x, double y, | |
114 | double dx, double dy, | |
115 | double originX, double originY, | |
116 | CharCode code, int nBytes, Unicode *u, int uLen); | |
117 | virtual GBool beginType3Char(GfxState *state, double x, double y, | |
118 | double dx, double dy, | |
119 | CharCode code, Unicode *u, int uLen); | |
120 | virtual void endType3Char(GfxState *state); | |
121 | virtual void endTextObject(GfxState *state); | |
122 | ||
123 | //----- image drawing | |
124 | virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, | |
125 | int width, int height, GBool invert, | |
126 | GBool inlineImg); | |
127 | virtual void drawImage(GfxState *state, Object *ref, Stream *str, | |
128 | int width, int height, GfxImageColorMap *colorMap, | |
129 | int *maskColors, GBool inlineImg); | |
130 | virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, | |
131 | int width, int height, | |
132 | GfxImageColorMap *colorMap, | |
133 | Stream *maskStr, int maskWidth, int maskHeight, | |
134 | GBool maskInvert); | |
135 | virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, | |
136 | int width, int height, | |
137 | GfxImageColorMap *colorMap, | |
138 | Stream *maskStr, | |
139 | int maskWidth, int maskHeight, | |
140 | GfxImageColorMap *maskColorMap); | |
141 | ||
142 | //----- Type 3 font operators | |
143 | virtual void type3D0(GfxState *state, double wx, double wy); | |
144 | virtual void type3D1(GfxState *state, double wx, double wy, | |
145 | double llx, double lly, double urx, double ury); | |
146 | ||
147 | //----- special access | |
148 | ||
149 | // Called to indicate that a new PDF document has been loaded. | |
150 | void startDoc(XRef *xrefA); | |
151 | ||
152 | void setPaperColor(SplashColorPtr paperColorA); | |
153 | ||
154 | GBool isReverseVideo() { return reverseVideo; } | |
155 | void setReverseVideo(GBool reverseVideoA) { reverseVideo = reverseVideoA; } | |
156 | ||
157 | // Get the bitmap and its size. | |
158 | SplashBitmap *getBitmap() { return bitmap; } | |
159 | int getBitmapWidth(); | |
160 | int getBitmapHeight(); | |
161 | ||
162 | // Returns the last rasterized bitmap, transferring ownership to the | |
163 | // caller. | |
164 | SplashBitmap *takeBitmap(); | |
165 | ||
166 | // Get the Splash object. | |
167 | Splash *getSplash() { return splash; } | |
168 | ||
169 | // Get the modified region. | |
170 | void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax); | |
171 | ||
172 | // Clear the modified region. | |
173 | void clearModRegion(); | |
174 | ||
175 | // Set the Splash fill color. | |
176 | void setFillColor(int r, int g, int b); | |
177 | ||
178 | // Get a font object for a Base-14 font, using the Latin-1 encoding. | |
179 | SplashFont *getFont(GString *name, double *mat); | |
180 | ||
181 | SplashFont *getCurrentFont() { return font; } | |
182 | ||
183 | private: | |
184 | ||
185 | #if SPLASH_CMYK | |
186 | SplashPattern *getColor(GfxGray gray, GfxRGB *rgb, GfxCMYK *cmyk); | |
187 | #else | |
188 | SplashPattern *getColor(GfxGray gray, GfxRGB *rgb); | |
189 | #endif | |
190 | SplashPath *convertPath(GfxState *state, GfxPath *path); | |
191 | void drawType3Glyph(T3FontCache *t3Font, | |
192 | T3FontCacheTag *tag, Guchar *data, | |
193 | double x, double y); | |
194 | static GBool imageMaskSrc(void *data, SplashColorPtr line); | |
195 | static GBool imageSrc(void *data, SplashColorPtr line); | |
196 | static GBool alphaImageSrc(void *data, SplashColorPtr line); | |
197 | static GBool maskedImageSrc(void *data, SplashColorPtr line); | |
198 | ||
199 | SplashColorMode colorMode; | |
200 | int bitmapRowPad; | |
201 | GBool bitmapTopDown; | |
202 | GBool allowAntialias; | |
203 | GBool reverseVideo; // reverse video mode | |
204 | SplashColor paperColor; // paper color | |
205 | ||
206 | XRef *xref; // xref table for current document | |
207 | ||
208 | SplashBitmap *bitmap; | |
209 | Splash *splash; | |
210 | SplashFontEngine *fontEngine; | |
211 | ||
212 | T3FontCache * // Type 3 font cache | |
213 | t3FontCache[splashOutT3FontCacheSize]; | |
214 | int nT3Fonts; // number of valid entries in t3FontCache | |
215 | T3GlyphStack *t3GlyphStack; // Type 3 glyph context stack | |
216 | ||
217 | SplashFont *font; // current font | |
218 | GBool needFontUpdate; // set when the font needs to be updated | |
219 | SplashPath *textClipPath; // clipping path built with text object | |
220 | }; | |
221 | ||
222 | #endif |