1 #ifndef __gfxoutputdev_h__
2 #define __gfxoutputdev_h__
4 #include "../gfxdevice.h"
5 #include "../gfxsource.h"
6 #include "../gfxtools.h"
9 #include "InfoOutputDev.h"
12 typedef struct _fontlist
19 class GFXOutputState {
24 char transparencygroup;
31 gfxresult_t* grouprecording; // for transparency groups
32 gfxresult_t* softmaskrecording; // for soft masks
34 gfxdevice_t* olddevice;
37 typedef struct _parameter
41 struct _parameter*next;
44 void addGlobalFont(const char*filename);
45 void addGlobalLanguageDir(const char*dir);
46 void addGlobalFontDir(const char*dirname);
48 class GFXOutputDev: public OutputDev {
53 GFXOutputDev(parameter_t*p);
54 void setDevice(gfxdevice_t*dev);
57 virtual ~GFXOutputDev() ;
59 void setMove(int x,int y);
60 void setClip(int x1,int y1,int x2,int y2);
61 void setParameter(const char*key, const char*value);
63 void setInfo(InfoOutputDev*info) {this->info = info;}
66 void startFrame(int width, int height);
68 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
72 //----- get info about output device
74 // Does this device use upside-down coordinates?
75 // (Upside-down means (0,0) is the top left corner of the page.)
76 virtual GBool upsideDown();
78 // Does this device use drawChar() or drawString()?
79 virtual GBool useDrawChar();
81 virtual GBool interpretType3Chars();
83 //virtual GBool useShadedFills() { return gTrue; }
85 //----- initialization and control
87 void setXRef(PDFDoc*doc, XRef *xref);
90 virtual void processLink(Link *link, Catalog *catalog);
92 //----- save/restore graphics state
93 virtual void saveState(GfxState *state) ;
94 virtual void restoreState(GfxState *state) ;
96 //----- update graphics state
98 virtual void updateFont(GfxState *state);
99 virtual void updateFillColor(GfxState *state);
100 virtual void updateStrokeColor(GfxState *state);
101 virtual void updateLineWidth(GfxState *state);
102 virtual void updateLineJoin(GfxState *state);
103 virtual void updateLineCap(GfxState *state);
104 virtual void updateFillOpacity(GfxState *state);
105 virtual void updateStrokeOpacity(GfxState *state);
106 virtual void updateFillOverprint(GfxState *state);
107 virtual void updateStrokeOverprint(GfxState *state);
108 virtual void updateTransfer(GfxState *state);
110 virtual void updateAll(GfxState *state)
113 updateFillColor(state);
114 updateStrokeColor(state);
115 updateLineWidth(state);
116 updateLineJoin(state);
117 updateLineCap(state);
120 //----- path painting
121 virtual void stroke(GfxState *state) ;
122 virtual void fill(GfxState *state) ;
123 virtual void eoFill(GfxState *state) ;
125 //----- path clipping
126 virtual void clip(GfxState *state) ;
127 virtual void eoClip(GfxState *state) ;
128 virtual void clipToStrokePath(GfxState *state);
131 virtual GBool useTilingPatternFill();
132 virtual GBool useShadedFills();
135 virtual void tilingPatternFill(GfxState *state, Object *str,
136 int paintType, Dict *resDict,
137 double *mat, double *bbox,
138 int x0, int y0, int x1, int y1,
139 double xStep, double yStep) {}
140 virtual void functionShadedFill(GfxState *state,
141 GfxFunctionShading *shading) {}
142 virtual void axialShadedFill(GfxState *state, GfxAxialShading *shading) {}
143 virtual void radialShadedFill(GfxState *state, GfxRadialShading *shading) {}
147 virtual void beginString(GfxState *state, GString *s) ;
148 virtual void endString(GfxState *state) ;
149 virtual void endTextObject(GfxState *state);
150 virtual void drawChar(GfxState *state, double x, double y,
151 double dx, double dy,
152 double originX, double originY,
153 CharCode code, int nBytes, Unicode *u, int uLen);
155 //----- image drawing
156 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
157 int width, int height, GBool invert,
159 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
160 int width, int height, GfxImageColorMap *colorMap,
161 int *maskColors, GBool inlineImg);
162 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
163 int width, int height,
164 GfxImageColorMap *colorMap,
165 Stream *maskStr, int maskWidth, int maskHeight,
167 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
168 int width, int height,
169 GfxImageColorMap *colorMap,
171 int maskWidth, int maskHeight,
172 GfxImageColorMap *maskColorMap);
174 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
175 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
176 GfxColorSpace *blendingColorSpace,
177 GBool isolated, GBool knockout,
179 virtual void endTransparencyGroup(GfxState *state);
180 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
181 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
182 virtual void clearSoftMask(GfxState *state);
185 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
186 virtual void endType3Char(GfxState *state);
188 virtual void type3D0(GfxState *state, double wx, double wy);
189 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
191 void preparePage(int pdfpage, int outputpage);
193 char* searchForSuitableFont(GfxFont*gfxFont);
197 virtual GBool useDrawForm();
198 virtual void drawForm(Ref id);
199 virtual GBool needNonText();
200 virtual void endPage();
202 //virtual void dump();
203 //virtual void beginStringOp(GfxState *state);
204 //virtual void drawString(GfxState *state, GString *s);
205 //virtual void endStringOp(GfxState *state);
206 //virtual GBool getVectorAntialias() { return gFalse; }
207 //virtual void setVectorAntialias(GBool vaa) {}
208 //virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
211 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
212 int width, int height, GfxImageColorMap*colorMap, GBool invert,
213 GBool inlineImg, int mask, int *maskColors,
214 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
215 int setGfxFont(char*id, char*name, char*filename, double maxSize, CharCodeToUnicode*ctu);
216 void strokeGfxline(GfxState *state, gfxline_t*line, int flags);
217 void clipToGfxLine(GfxState *state, gfxline_t*line);
218 void fillGfxLine(GfxState *state, gfxline_t*line);
220 void showfeature(const char*feature,char fully, char warn);
221 void warnfeature(const char*feature,char fully);
222 void infofeature(const char*feature);
224 char outer_clip_box; //whether the page clip box is still on
226 gfxfontlist_t*gfxfontlist;
228 GBool do_interpretType3Chars;
231 GFXOutputState states[64];
239 char* searchFont(const char*name);
240 char* substituteFont(GfxFont*gfxFont, char*oldname);
241 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
243 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
244 int jpeginfo; // did we write "File contains jpegs" yet?
245 int pbminfo; // did we write "File contains jpegs" yet?
246 int linkinfo; // did we write "File contains links" yet?
248 int type3active; // are we between beginType3()/endType3()?
254 const char* substitutetarget[256];
255 const char* substitutesource[256];
258 int user_movex,user_movey;
259 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
261 /* upper left corner of clipping rectangle (cropbox)- needs to be
262 added to all drawing coordinates to give the impression that all
263 pages start at (0,0)*/
269 gfxline_t* current_text_stroke;
270 gfxline_t* current_text_clip;
271 char* current_font_id;
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;
286 parameter_t*parameters;
289 class GFXGlobalParams: public GlobalParams {
293 virtual DisplayFontParam *getDisplayFont(GString *fontName);
296 #endif //__gfxoutputdev_h__