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 void addGlobalFont(const char*filename);
42 void addGlobalLanguageDir(const char*dir);
43 void addGlobalFontDir(const char*dirname);
45 class GFXOutputDev: public CommonOutputDev {
49 GFXOutputDev(InfoOutputDev*info, PDFDoc*doc);
50 virtual ~GFXOutputDev() ;
52 virtual void setDevice(gfxdevice_t*dev);
53 virtual void setMove(int x,int y);
54 virtual void setClip(int x1,int y1,int x2,int y2);
55 virtual void setParameter(const char*key, const char*value);
58 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
59 virtual void endPage();
61 //----- get info about output device
63 // Does this device use upside-down coordinates?
64 // (Upside-down means (0,0) is the top left corner of the page.)
65 virtual GBool upsideDown();
67 // Does this device use drawChar() or drawString()?
68 virtual GBool useDrawChar();
70 virtual GBool interpretType3Chars();
72 //virtual GBool useShadedFills() { return gTrue; }
75 virtual void processLink(Link *link, Catalog *catalog);
77 //----- save/restore graphics state
78 virtual void saveState(GfxState *state) ;
79 virtual void restoreState(GfxState *state) ;
81 //----- update graphics state
83 virtual void updateFont(GfxState *state);
84 virtual void updateFontMatrix(GfxState *state);
85 virtual void updateFillColor(GfxState *state);
86 virtual void updateStrokeColor(GfxState *state);
87 virtual void updateLineWidth(GfxState *state);
88 virtual void updateLineJoin(GfxState *state);
89 virtual void updateLineCap(GfxState *state);
90 virtual void updateFillOpacity(GfxState *state);
91 virtual void updateStrokeOpacity(GfxState *state);
92 virtual void updateFillOverprint(GfxState *state);
93 virtual void updateStrokeOverprint(GfxState *state);
94 virtual void updateTransfer(GfxState *state);
96 virtual void updateAll(GfxState *state)
99 updateFillColor(state);
100 updateStrokeColor(state);
101 updateLineWidth(state);
102 updateLineJoin(state);
103 updateLineCap(state);
106 //----- path painting
107 virtual void stroke(GfxState *state) ;
108 virtual void fill(GfxState *state) ;
109 virtual void eoFill(GfxState *state) ;
111 //----- path clipping
112 virtual void clip(GfxState *state) ;
113 virtual void eoClip(GfxState *state) ;
114 virtual void clipToStrokePath(GfxState *state);
117 virtual GBool useTilingPatternFill();
118 virtual GBool useShadedFills();
120 #if (xpdfMajorVersion < 3) || (xpdfMinorVersion < 2) || (xpdfUpdateVersion < 7)
121 virtual void tilingPatternFill(GfxState *state, Object *str,
122 int paintType, Dict *resDict,
123 double *mat, double *bbox,
124 int x0, int y0, int x1, int y1,
125 double xStep, double yStep);
127 virtual void tilingPatternFill(GfxState *state, Gfx *gfx, 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 GBool functionShadedFill(GfxState *state,
134 GfxFunctionShading *shading);
135 virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading);
136 virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading);
139 virtual void beginString(GfxState *state, GString *s) ;
140 virtual void endString(GfxState *state) ;
141 virtual void endTextObject(GfxState *state);
142 virtual void drawChar(GfxState *state, double x, double y,
143 double dx, double dy,
144 double originX, double originY,
145 CharCode code, int nBytes, Unicode *u, int uLen);
147 //----- image drawing
148 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
149 int width, int height, GBool invert,
151 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
152 int width, int height, GfxImageColorMap *colorMap,
153 int *maskColors, GBool inlineImg);
154 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
155 int width, int height,
156 GfxImageColorMap *colorMap,
157 Stream *maskStr, int maskWidth, int maskHeight,
159 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
160 int width, int height,
161 GfxImageColorMap *colorMap,
163 int maskWidth, int maskHeight,
164 GfxImageColorMap *maskColorMap);
166 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
167 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
168 GfxColorSpace *blendingColorSpace,
169 GBool isolated, GBool knockout,
171 virtual void endTransparencyGroup(GfxState *state);
172 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
173 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
174 virtual void clearSoftMask(GfxState *state);
177 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
178 virtual void endType3Char(GfxState *state);
180 virtual void type3D0(GfxState *state, double wx, double wy);
181 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
183 virtual void preparePage(int pdfpage, int outputpage);
185 char* searchForSuitableFont(GfxFont*gfxFont);
189 virtual GBool useDrawForm();
190 virtual void drawForm(Ref id);
191 virtual GBool needNonText();
193 //virtual void dump();
194 //virtual void beginStringOp(GfxState *state);
195 //virtual void drawString(GfxState *state, GString *s);
196 //virtual void endStringOp(GfxState *state);
197 //virtual GBool getVectorAntialias() { return gFalse; }
198 //virtual void setVectorAntialias(GBool vaa) {}
199 //virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
202 gfxline_t* gfxPath_to_gfxline(GfxState*state, GfxPath*path, int closed, int user_movex, int user_movey);
204 void transformXY(GfxState*state, double x, double y, double*nx, double*ny);
206 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
207 int width, int height, GfxImageColorMap*colorMap, GBool invert,
208 GBool inlineImg, int mask, int *maskColors,
209 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
210 int setGfxFont(char*id, char*name, char*filename, double maxSize, CharCodeToUnicode*ctu);
211 void strokeGfxline(GfxState *state, gfxline_t*line, int flags);
212 void clipToGfxLine(GfxState *state, gfxline_t*line);
213 void fillGfxLine(GfxState *state, gfxline_t*line);
215 void showfeature(const char*feature,char fully, char warn);
216 void warnfeature(const char*feature,char fully);
217 void infofeature(const char*feature);
219 char outer_clip_box; //whether the page clip box is still on
221 gfxfontlist_t*gfxfontlist;
223 GBool do_interpretType3Chars;
226 GFXOutputState states[64];
234 char* searchFont(const char*name);
235 char* substituteFont(GfxFont*gfxFont, char*oldname);
236 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
238 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
239 int jpeginfo; // did we write "File contains jpegs" yet?
240 int pbminfo; // did we write "File contains jpegs" yet?
241 int linkinfo; // did we write "File contains links" yet?
243 int type3active; // are we between beginType3()/endType3()?
249 const char* substitutetarget[256];
250 const char* substitutesource[256];
253 int user_movex,user_movey;
254 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
256 /* upper left corner of clipping rectangle (cropbox)- needs to be
257 added to all drawing coordinates to give the impression that all
258 pages start at (0,0)*/
262 gfxline_t* current_text_stroke;
263 gfxline_t* current_text_clip;
264 gfxfont_t* current_gfxfont;
265 FontInfo*current_fontinfo;
266 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;
280 double config_fontquality;
282 parameter_t*parameters;
285 class GFXGlobalParams: public GlobalParams {
289 virtual DisplayFontParam *getDisplayFont(GString *fontName);
292 #endif //__gfxoutputdev_h__