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;
26 gfxresult_t* grouprecording; // for transparency groups
27 gfxresult_t* softmaskrecording; // for soft masks
29 gfxdevice_t* olddevice;
32 typedef struct _parameter
36 struct _parameter*next;
39 void addGlobalFont(const char*filename);
40 void addGlobalLanguageDir(const char*dir);
41 void addGlobalFontDir(const char*dirname);
43 class GFXOutputDev: public CommonOutputDev {
47 GFXOutputDev(InfoOutputDev*info, PDFDoc*doc);
48 virtual ~GFXOutputDev() ;
50 virtual void setDevice(gfxdevice_t*dev);
51 virtual void setMove(int x,int y);
52 virtual void setClip(int x1,int y1,int x2,int y2);
53 virtual void setParameter(const char*key, const char*value);
56 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
57 virtual void endPage();
59 //----- get info about output device
61 // Does this device use upside-down coordinates?
62 // (Upside-down means (0,0) is the top left corner of the page.)
63 virtual GBool upsideDown();
65 // Does this device use drawChar() or drawString()?
66 virtual GBool useDrawChar();
68 virtual GBool interpretType3Chars();
70 //virtual GBool useShadedFills() { return gTrue; }
73 virtual void processLink(Link *link, Catalog *catalog);
75 //----- save/restore graphics state
76 virtual void saveState(GfxState *state) ;
77 virtual void restoreState(GfxState *state) ;
79 //----- update graphics state
81 virtual void updateFont(GfxState *state);
82 virtual void updateFontMatrix(GfxState *state);
83 virtual void updateFillColor(GfxState *state);
84 virtual void updateStrokeColor(GfxState *state);
85 virtual void updateLineWidth(GfxState *state);
86 virtual void updateLineJoin(GfxState *state);
87 virtual void updateLineCap(GfxState *state);
88 virtual void updateFillOpacity(GfxState *state);
89 virtual void updateStrokeOpacity(GfxState *state);
90 virtual void updateFillOverprint(GfxState *state);
91 virtual void updateStrokeOverprint(GfxState *state);
92 virtual void updateTransfer(GfxState *state);
94 virtual void updateAll(GfxState *state)
97 updateFillColor(state);
98 updateStrokeColor(state);
99 updateLineWidth(state);
100 updateLineJoin(state);
101 updateLineCap(state);
104 //----- path painting
105 virtual void stroke(GfxState *state) ;
106 virtual void fill(GfxState *state) ;
107 virtual void eoFill(GfxState *state) ;
109 //----- path clipping
110 virtual void clip(GfxState *state) ;
111 virtual void eoClip(GfxState *state) ;
112 virtual void clipToStrokePath(GfxState *state);
115 virtual GBool useTilingPatternFill();
116 virtual GBool useShadedFills();
119 virtual void tilingPatternFill(GfxState *state, Object *str,
120 int paintType, Dict *resDict,
121 double *mat, double *bbox,
122 int x0, int y0, int x1, int y1,
123 double xStep, double yStep) {}
124 virtual void functionShadedFill(GfxState *state,
125 GfxFunctionShading *shading) {}
126 virtual void axialShadedFill(GfxState *state, GfxAxialShading *shading) {}
127 virtual void radialShadedFill(GfxState *state, GfxRadialShading *shading) {}
131 virtual void beginString(GfxState *state, GString *s) ;
132 virtual void endString(GfxState *state) ;
133 virtual void endTextObject(GfxState *state);
134 virtual void drawChar(GfxState *state, double x, double y,
135 double dx, double dy,
136 double originX, double originY,
137 CharCode code, int nBytes, Unicode *u, int uLen);
139 //----- image drawing
140 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
141 int width, int height, GBool invert,
143 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
144 int width, int height, GfxImageColorMap *colorMap,
145 int *maskColors, GBool inlineImg);
146 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
147 int width, int height,
148 GfxImageColorMap *colorMap,
149 Stream *maskStr, int maskWidth, int maskHeight,
151 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
152 int width, int height,
153 GfxImageColorMap *colorMap,
155 int maskWidth, int maskHeight,
156 GfxImageColorMap *maskColorMap);
158 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
159 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
160 GfxColorSpace *blendingColorSpace,
161 GBool isolated, GBool knockout,
163 virtual void endTransparencyGroup(GfxState *state);
164 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
165 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
166 virtual void clearSoftMask(GfxState *state);
169 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
170 virtual void endType3Char(GfxState *state);
172 virtual void type3D0(GfxState *state, double wx, double wy);
173 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
175 virtual void preparePage(int pdfpage, int outputpage);
177 char* searchForSuitableFont(GfxFont*gfxFont);
181 virtual GBool useDrawForm();
182 virtual void drawForm(Ref id);
183 virtual GBool needNonText();
185 //virtual void dump();
186 //virtual void beginStringOp(GfxState *state);
187 //virtual void drawString(GfxState *state, GString *s);
188 //virtual void endStringOp(GfxState *state);
189 //virtual GBool getVectorAntialias() { return gFalse; }
190 //virtual void setVectorAntialias(GBool vaa) {}
191 //virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
194 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
195 int width, int height, GfxImageColorMap*colorMap, GBool invert,
196 GBool inlineImg, int mask, int *maskColors,
197 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
198 int setGfxFont(char*id, char*name, char*filename, double maxSize, CharCodeToUnicode*ctu);
199 void strokeGfxline(GfxState *state, gfxline_t*line, int flags);
200 void clipToGfxLine(GfxState *state, gfxline_t*line);
201 void fillGfxLine(GfxState *state, gfxline_t*line);
203 void showfeature(const char*feature,char fully, char warn);
204 void warnfeature(const char*feature,char fully);
205 void infofeature(const char*feature);
207 char outer_clip_box; //whether the page clip box is still on
209 gfxfontlist_t*gfxfontlist;
211 GBool do_interpretType3Chars;
214 GFXOutputState states[64];
222 char* searchFont(const char*name);
223 char* substituteFont(GfxFont*gfxFont, char*oldname);
224 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
226 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
227 int jpeginfo; // did we write "File contains jpegs" yet?
228 int pbminfo; // did we write "File contains jpegs" yet?
229 int linkinfo; // did we write "File contains links" yet?
231 int type3active; // are we between beginType3()/endType3()?
237 const char* substitutetarget[256];
238 const char* substitutesource[256];
241 int user_movex,user_movey;
242 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
244 /* upper left corner of clipping rectangle (cropbox)- needs to be
245 added to all drawing coordinates to give the impression that all
246 pages start at (0,0)*/
250 gfxline_t* current_text_stroke;
251 gfxline_t* current_text_clip;
252 char* current_font_id;
253 gfxfont_t* current_gfxfont;
254 FontInfo*current_fontinfo;
255 gfxmatrix_t current_font_matrix;
262 int config_use_fontconfig;
263 int config_break_on_warning;
264 int config_remapunicode;
265 int config_transparent;
266 int config_extrafontdata;
268 parameter_t*parameters;
271 class GFXGlobalParams: public GlobalParams {
275 virtual DisplayFontParam *getDisplayFont(GString *fontName);
278 #endif //__gfxoutputdev_h__