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;
34 typedef struct _parameter
38 struct _parameter*next;
41 typedef struct _feature
47 void addGlobalFont(const char*filename);
48 void addGlobalLanguageDir(const char*dir);
49 void addGlobalFontDir(const char*dirname);
51 class GFXOutputDev: public CommonOutputDev {
55 GFXOutputDev(InfoOutputDev*info, PDFDoc*doc);
56 virtual ~GFXOutputDev() ;
58 virtual void setDevice(gfxdevice_t*dev);
59 virtual void setMove(int x,int y);
60 virtual void setClip(int x1,int y1,int x2,int y2);
61 virtual void setParameter(const char*key, const char*value);
64 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
65 virtual void endPage();
67 //----- get info about output device
69 // Does this device use upside-down coordinates?
70 // (Upside-down means (0,0) is the top left corner of the page.)
71 virtual GBool upsideDown();
73 // Does this device use drawChar() or drawString()?
74 virtual GBool useDrawChar();
76 virtual GBool interpretType3Chars();
78 //virtual GBool useShadedFills() { return gTrue; }
81 virtual void processLink(Link *link, Catalog *catalog);
83 //----- save/restore graphics state
84 virtual void saveState(GfxState *state) ;
85 virtual void restoreState(GfxState *state) ;
87 //----- update graphics state
89 virtual void updateFont(GfxState *state);
90 virtual void updateFontMatrix(GfxState *state);
91 virtual void updateFillColor(GfxState *state);
92 virtual void updateStrokeColor(GfxState *state);
93 virtual void updateLineWidth(GfxState *state);
94 virtual void updateLineJoin(GfxState *state);
95 virtual void updateLineCap(GfxState *state);
96 virtual void updateFillOpacity(GfxState *state);
97 virtual void updateStrokeOpacity(GfxState *state);
98 virtual void updateFillOverprint(GfxState *state);
99 virtual void updateStrokeOverprint(GfxState *state);
100 virtual void updateTransfer(GfxState *state);
102 virtual void updateAll(GfxState *state)
105 updateFillColor(state);
106 updateStrokeColor(state);
107 updateLineWidth(state);
108 updateLineJoin(state);
109 updateLineCap(state);
112 //----- path painting
113 virtual void stroke(GfxState *state) ;
114 virtual void fill(GfxState *state) ;
115 virtual void eoFill(GfxState *state) ;
117 //----- path clipping
118 virtual void clip(GfxState *state) ;
119 virtual void eoClip(GfxState *state) ;
120 virtual void clipToStrokePath(GfxState *state);
123 virtual GBool useTilingPatternFill();
124 virtual GBool useShadedFills();
126 #if (xpdfMajorVersion < 3) || (xpdfMinorVersion < 2) || (xpdfUpdateVersion < 7)
127 virtual void tilingPatternFill(GfxState *state, Object *str,
128 int paintType, Dict *resDict,
129 double *mat, double *bbox,
130 int x0, int y0, int x1, int y1,
131 double xStep, double yStep);
133 virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *str,
134 int paintType, Dict *resDict,
135 double *mat, double *bbox,
136 int x0, int y0, int x1, int y1,
137 double xStep, double yStep);
139 virtual GBool functionShadedFill(GfxState *state,
140 GfxFunctionShading *shading);
141 virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading);
142 virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading);
145 virtual void beginString(GfxState *state, GString *s) ;
146 virtual void endString(GfxState *state) ;
147 virtual void endTextObject(GfxState *state);
148 virtual void drawChar(GfxState *state, double x, double y,
149 double dx, double dy,
150 double originX, double originY,
151 CharCode code, int nBytes, Unicode *u, int uLen);
153 //----- image drawing
154 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
155 int width, int height, GBool invert,
157 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
158 int width, int height, GfxImageColorMap *colorMap,
159 int *maskColors, GBool inlineImg);
160 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
161 int width, int height,
162 GfxImageColorMap *colorMap,
163 Stream *maskStr, int maskWidth, int maskHeight,
165 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
166 int width, int height,
167 GfxImageColorMap *colorMap,
169 int maskWidth, int maskHeight,
170 GfxImageColorMap *maskColorMap);
172 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
173 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
174 GfxColorSpace *blendingColorSpace,
175 GBool isolated, GBool knockout,
177 virtual void endTransparencyGroup(GfxState *state);
178 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
179 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
180 virtual void clearSoftMask(GfxState *state);
183 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
184 virtual void endType3Char(GfxState *state);
186 virtual void type3D0(GfxState *state, double wx, double wy);
187 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
189 virtual void preparePage(int pdfpage, int outputpage);
191 char* searchForSuitableFont(GfxFont*gfxFont);
195 virtual GBool useDrawForm();
196 virtual void drawForm(Ref id);
197 virtual GBool needNonText();
199 //virtual void dump();
200 //virtual void beginStringOp(GfxState *state);
201 //virtual void drawString(GfxState *state, GString *s);
202 //virtual void endStringOp(GfxState *state);
203 //virtual GBool getVectorAntialias() { return gFalse; }
204 //virtual void setVectorAntialias(GBool vaa) {}
205 //virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
208 gfxline_t* gfxPath_to_gfxline(GfxState*state, GfxPath*path, int closed, int user_movex, int user_movey);
210 void transformXY(GfxState*state, double x, double y, double*nx, double*ny);
212 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
213 int width, int height, GfxImageColorMap*colorMap, GBool invert,
214 GBool inlineImg, int mask, int *maskColors,
215 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
216 int setGfxFont(char*id, char*name, char*filename, double maxSize, CharCodeToUnicode*ctu);
217 void strokeGfxline(GfxState *state, gfxline_t*line, int flags);
218 void clipToGfxLine(GfxState *state, gfxline_t*line);
219 void fillGfxLine(GfxState *state, gfxline_t*line);
221 void showfeature(const char*feature,char fully, char warn);
222 void warnfeature(const char*feature,char fully);
223 void infofeature(const char*feature);
225 feature_t*featurewarnings;
227 char outer_clip_box; //whether the page clip box is still on
229 gfxfontlist_t*gfxfontlist;
231 GBool do_interpretType3Chars;
234 GFXOutputState states[64];
242 char* searchFont(const char*name);
243 char* substituteFont(GfxFont*gfxFont, char*oldname);
244 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
246 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
247 int jpeginfo; // did we write "File contains jpegs" yet?
248 int pbminfo; // did we write "File contains jpegs" yet?
249 int linkinfo; // did we write "File contains links" yet?
251 int type3active; // are we between beginType3()/endType3()?
257 const char* substitutetarget[256];
258 const char* substitutesource[256];
261 int user_movex,user_movey;
262 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
264 /* upper left corner of clipping rectangle (cropbox)- needs to be
265 added to all drawing coordinates to give the impression that all
266 pages start at (0,0)*/
270 gfxline_t* current_text_stroke;
271 gfxline_t* current_text_clip;
272 gfxfont_t* current_gfxfont;
273 FontInfo*current_fontinfo;
274 gfxmatrix_t current_font_matrix;
281 int config_use_fontconfig;
282 int config_break_on_warning;
283 int config_remapunicode;
284 int config_transparent;
285 int config_extrafontdata;
286 int config_convertgradients;
287 int config_optimize_polygons;
288 double config_fontquality;
290 parameter_t*parameters;
293 class GFXGlobalParams: public GlobalParams {
297 virtual DisplayFontParam *getDisplayFont(GString *fontName);
300 #endif //__gfxoutputdev_h__