1 #ifndef __gfxoutputdev_h__
2 #define __gfxoutputdev_h__
4 #include "../gfxdevice.h"
5 #include "../gfxsource.h"
6 #include "../gfxtools.h"
9 #include "InfoOutputDev.h"
11 #include "GlobalParams.h"
12 #include "CommonOutputDev.h"
14 class GFXOutputState {
19 char transparencygroup;
28 gfxresult_t* grouprecording; // for transparency groups
29 gfxresult_t* softmaskrecording; // for soft masks
31 gfxdevice_t* olddevice;
36 typedef struct _feature
42 void addGlobalFont(const char*filename);
43 void addGlobalLanguageDir(const char*dir);
44 void addGlobalFontDir(const char*dirname);
46 class GFXOutputGlobals {
48 feature_t*featurewarnings;
49 gfxfontlist_t*gfxfontlist;
50 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
51 int jpeginfo; // did we write "File contains jpegs" yet?
52 int pbminfo; // did we write "File contains jpegs" yet?
53 int linkinfo; // did we write "File contains links" yet?
62 class GFXOutputDev: public CommonOutputDev {
66 GFXOutputDev(InfoOutputDev*info, PDFDoc*doc);
67 virtual ~GFXOutputDev() ;
69 virtual void setDevice(gfxdevice_t*dev);
70 virtual void setMove(int x,int y);
71 virtual void setClip(int x1,int y1,int x2,int y2);
72 virtual void setParameter(const char*key, const char*value);
75 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
76 virtual void endPage();
78 //----- get info about output device
80 // Does this device use upside-down coordinates?
81 // (Upside-down means (0,0) is the top left corner of the page.)
82 virtual GBool upsideDown();
84 // Does this device use drawChar() or drawString()?
85 virtual GBool useDrawChar();
87 virtual GBool interpretType3Chars();
89 //virtual GBool useShadedFills() { return gTrue; }
92 virtual void processLink(Link *link, Catalog *catalog);
94 //----- save/restore graphics state
95 virtual void saveState(GfxState *state) ;
96 virtual void restoreState(GfxState *state) ;
98 //----- update graphics state
100 virtual void updateLineDash(GfxState *state);
101 virtual void updateFont(GfxState *state);
102 virtual void updateFontMatrix(GfxState *state);
103 virtual void updateFillColor(GfxState *state);
104 virtual void updateStrokeColor(GfxState *state);
105 virtual void updateLineWidth(GfxState *state);
106 virtual void updateLineJoin(GfxState *state);
107 virtual void updateLineCap(GfxState *state);
108 virtual void updateFillOpacity(GfxState *state);
109 virtual void updateStrokeOpacity(GfxState *state);
110 virtual void updateFillOverprint(GfxState *state);
111 virtual void updateStrokeOverprint(GfxState *state);
112 virtual void updateTransfer(GfxState *state);
114 virtual void updateAll(GfxState *state)
117 updateFillColor(state);
118 updateStrokeColor(state);
119 updateLineWidth(state);
120 updateLineJoin(state);
121 updateLineCap(state);
124 //----- path painting
125 virtual void stroke(GfxState *state) ;
126 virtual void fill(GfxState *state) ;
127 virtual void eoFill(GfxState *state) ;
129 //----- path clipping
130 virtual void clip(GfxState *state) ;
131 virtual void eoClip(GfxState *state) ;
132 virtual void clipToStrokePath(GfxState *state);
135 virtual GBool useTilingPatternFill();
136 virtual GBool useShadedFills();
138 #if (xpdfMajorVersion < 3) || (xpdfMinorVersion < 2) || (xpdfUpdateVersion < 7)
139 virtual void tilingPatternFill(GfxState *state, Object *str,
140 int paintType, Dict *resDict,
141 double *mat, double *bbox,
142 int x0, int y0, int x1, int y1,
143 double xStep, double yStep);
145 virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *str,
146 int paintType, Dict *resDict,
147 double *mat, double *bbox,
148 int x0, int y0, int x1, int y1,
149 double xStep, double yStep);
151 virtual GBool functionShadedFill(GfxState *state,
152 GfxFunctionShading *shading);
153 virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading);
154 virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading);
157 virtual void beginString(GfxState *state, GString *s) ;
158 virtual void endString(GfxState *state) ;
159 virtual void endTextObject(GfxState *state);
160 virtual void drawChar(GfxState *state, double x, double y,
161 double dx, double dy,
162 double originX, double originY,
163 CharCode code, int nBytes, Unicode *u, int uLen);
165 //----- image drawing
166 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
167 int width, int height, GBool invert,
169 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
170 int width, int height, GfxImageColorMap *colorMap,
171 int *maskColors, GBool inlineImg);
172 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
173 int width, int height,
174 GfxImageColorMap *colorMap,
175 Stream *maskStr, int maskWidth, int maskHeight,
177 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
178 int width, int height,
179 GfxImageColorMap *colorMap,
181 int maskWidth, int maskHeight,
182 GfxImageColorMap *maskColorMap);
184 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
185 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
186 GfxColorSpace *blendingColorSpace,
187 GBool isolated, GBool knockout,
189 virtual void endTransparencyGroup(GfxState *state);
190 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
191 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
192 virtual void clearSoftMask(GfxState *state);
195 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
196 virtual void endType3Char(GfxState *state);
198 virtual void type3D0(GfxState *state, double wx, double wy);
199 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
201 virtual void preparePage(int pdfpage, int outputpage);
203 char* searchForSuitableFont(GfxFont*gfxFont);
207 virtual GBool useDrawForm();
208 virtual void drawForm(Ref id);
209 virtual GBool needNonText();
211 //virtual void dump();
212 //virtual void beginStringOp(GfxState *state);
213 //virtual void drawString(GfxState *state, GString *s);
214 //virtual void endStringOp(GfxState *state);
215 //virtual GBool getVectorAntialias() { return gFalse; }
216 //virtual void setVectorAntialias(GBool vaa) {}
217 //virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
220 gfxline_t* gfxPath_to_gfxline(GfxState*state, GfxPath*path, int closed, int user_movex, int user_movey);
222 void transformXY(GfxState*state, double x, double y, double*nx, double*ny);
224 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
225 int width, int height, GfxImageColorMap*colorMap, GBool invert,
226 GBool inlineImg, int mask, int *maskColors,
227 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
229 void strokeGfxline(GfxState *state, gfxline_t*line, int flags);
230 void clipToGfxLine(GfxState *state, gfxline_t*line);
231 void fillGfxLine(GfxState *state, gfxline_t*line);
233 gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src);
235 void showfeature(const char*feature,char fully, char warn);
236 void warnfeature(const char*feature,char fully);
237 void infofeature(const char*feature);
239 char* searchFont(const char*name);
240 char* substituteFont(GfxFont*gfxFont, char*oldname);
241 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
245 char outer_clip_box; //whether the page clip box is still on
247 GFXOutputState states[64];
253 int type3active; // are we between beginType3()/endType3()?
257 int user_movex,user_movey;
258 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
260 /* upper left corner of clipping rectangle (cropbox)- needs to be
261 added to all drawing coordinates to give the impression that all
262 pages start at (0,0)*/
266 gfxline_t* current_text_stroke;
267 gfxline_t* current_text_clip;
268 gfxfont_t* current_gfxfont;
269 FontInfo*current_fontinfo;
270 gfxmatrix_t current_font_matrix;
273 int config_use_fontconfig;
274 int config_break_on_warning;
275 int config_remapunicode;
276 int config_transparent;
277 int config_extrafontdata;
278 int config_convertgradients;
279 int config_optimize_polygons;
282 double config_fontquality;
289 class GFXGlobalParams: public GlobalParams {
293 virtual DisplayFontParam *getDisplayFont(GString *fontName);
296 #endif //__gfxoutputdev_h__