~ubuntu-branches/ubuntu/lucid/swftools/lucid

« back to all changes in this revision

Viewing changes to lib/pdf/xpdf/Splash.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-04-30 05:22:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430052219-l1n64qofzeq5pej8
Tags: 0.9.0-0ubuntu1
* New upstream release (LP: #369931)
  - patches/01_manpages: edited to match updated version of src/pdf2swf.1 and
    src/wav2swf.1
  - patches/02_faq: edited to match updated version of FAQ
  - patches/04_makefile: edited to delete the patch on lib/Makefile.in and 
    src/Makefile.in (applied upstream)
  - deleted patch 99_configure_for_python2.5_and_2.6 (applied upstream)
  - debian/swftools.doc: deleted installation of TODO and 
    pdf2swf/HOWTO_pdf2swf as they don't exist anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// Splash.h
 
4
//
 
5
//========================================================================
 
6
 
 
7
#ifndef SPLASH_H
 
8
#define SPLASH_H
 
9
 
 
10
#include <aconf.h>
 
11
 
 
12
#ifdef USE_GCC_PRAGMAS
 
13
#pragma interface
 
14
#endif
 
15
 
 
16
#include "SplashTypes.h"
 
17
#include "SplashClip.h"
 
18
 
 
19
class Splash;
 
20
class SplashBitmap;
 
21
struct SplashGlyphBitmap;
 
22
class SplashState;
 
23
class SplashPattern;
 
24
class SplashScreen;
 
25
class SplashPath;
 
26
class SplashXPath;
 
27
class SplashFont;
 
28
struct SplashPipe;
 
29
 
 
30
//------------------------------------------------------------------------
 
31
 
 
32
// Retrieves the next line of pixels in an image mask.  Normally,
 
33
// fills in *<line> and returns true.  If the image stream is
 
34
// exhausted, returns false.
 
35
typedef GBool (*SplashImageMaskSource)(void *data, SplashColorPtr pixel);
 
36
 
 
37
// Retrieves the next line of pixels in an image.  Normally, fills in
 
38
// *<line> and returns true.  If the image stream is exhausted,
 
39
// returns false.
 
40
typedef GBool (*SplashImageSource)(void *data, SplashColorPtr colorLine,
 
41
                                   Guchar *alphaLine);
 
42
 
 
43
//------------------------------------------------------------------------
 
44
 
 
45
enum SplashPipeResultColorCtrl {
 
46
#if SPLASH_CMYK
 
47
  splashPipeResultColorNoAlphaBlendCMYK,
 
48
#endif
 
49
  splashPipeResultColorNoAlphaBlendRGB,
 
50
  splashPipeResultColorNoAlphaBlendMono,
 
51
  splashPipeResultColorAlphaNoBlendMono,
 
52
  splashPipeResultColorAlphaNoBlendRGB,
 
53
#if SPLASH_CMYK
 
54
  splashPipeResultColorAlphaNoBlendCMYK,
 
55
#endif
 
56
  splashPipeResultColorAlphaBlendMono,
 
57
  splashPipeResultColorAlphaBlendRGB
 
58
#if SPLASH_CMYK
 
59
  ,
 
60
  splashPipeResultColorAlphaBlendCMYK
 
61
#endif
 
62
};
 
63
 
 
64
//------------------------------------------------------------------------
 
65
// Splash
 
66
//------------------------------------------------------------------------
 
67
 
 
68
class Splash {
 
69
public:
 
70
 
 
71
  // Create a new rasterizer object.
 
72
  Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
 
73
         SplashScreenParams *screenParams = NULL);
 
74
  Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
 
75
         SplashScreen *screenA);
 
76
 
 
77
  ~Splash();
 
78
 
 
79
  //----- state read
 
80
 
 
81
  SplashCoord *getMatrix();
 
82
  SplashPattern *getStrokePattern();
 
83
  SplashPattern *getFillPattern();
 
84
  SplashScreen *getScreen();
 
85
  SplashBlendFunc getBlendFunc();
 
86
  SplashCoord getStrokeAlpha();
 
87
  SplashCoord getFillAlpha();
 
88
  SplashCoord getLineWidth();
 
89
  int getLineCap();
 
90
  int getLineJoin();
 
91
  SplashCoord getMiterLimit();
 
92
  SplashCoord getFlatness();
 
93
  SplashCoord *getLineDash();
 
94
  int getLineDashLength();
 
95
  SplashCoord getLineDashPhase();
 
96
  SplashClip *getClip();
 
97
  SplashBitmap *getSoftMask();
 
98
  GBool getInNonIsolatedGroup();
 
99
 
 
100
  //----- state write
 
101
 
 
102
  void setMatrix(SplashCoord *matrix);
 
103
  void setStrokePattern(SplashPattern *strokeColor);
 
104
  void setFillPattern(SplashPattern *fillColor);
 
105
  void setScreen(SplashScreen *screen);
 
106
  void setBlendFunc(SplashBlendFunc func);
 
107
  void setStrokeAlpha(SplashCoord alpha);
 
108
  void setFillAlpha(SplashCoord alpha);
 
109
  void setLineWidth(SplashCoord lineWidth);
 
110
  void setLineCap(int lineCap);
 
111
  void setLineJoin(int lineJoin);
 
112
  void setMiterLimit(SplashCoord miterLimit);
 
113
  void setFlatness(SplashCoord flatness);
 
114
  // the <lineDash> array will be copied
 
115
  void setLineDash(SplashCoord *lineDash, int lineDashLength,
 
116
                   SplashCoord lineDashPhase);
 
117
  void setStrokeAdjust(GBool strokeAdjust);
 
118
  // NB: uses transformed coordinates.
 
119
  void clipResetToRect(SplashCoord x0, SplashCoord y0,
 
120
                       SplashCoord x1, SplashCoord y1);
 
121
  // NB: uses transformed coordinates.
 
122
  SplashError clipToRect(SplashCoord x0, SplashCoord y0,
 
123
                         SplashCoord x1, SplashCoord y1);
 
124
  // NB: uses untransformed coordinates.
 
125
  SplashError clipToPath(SplashPath *path, GBool eo);
 
126
  void setSoftMask(SplashBitmap *softMask);
 
127
  void setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA,
 
128
                             int alpha0XA, int alpha0YA);
 
129
 
 
130
  //----- state save/restore
 
131
 
 
132
  void saveState();
 
133
  SplashError restoreState();
 
134
 
 
135
  //----- drawing operations
 
136
 
 
137
  // Fill the bitmap with <color>.  This is not subject to clipping.
 
138
  void clear(SplashColorPtr color, Guchar alpha = 0x00);
 
139
 
 
140
  // Stroke a path using the current stroke pattern.
 
141
  SplashError stroke(SplashPath *path);
 
142
 
 
143
  // Fill a path using the current fill pattern.
 
144
  SplashError fill(SplashPath *path, GBool eo);
 
145
 
 
146
  // Fill a path, XORing with the current fill pattern.
 
147
  SplashError xorFill(SplashPath *path, GBool eo);
 
148
 
 
149
  // Draw a character, using the current fill pattern.
 
150
  SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
 
151
 
 
152
  // Draw a glyph, using the current fill pattern.  This function does
 
153
  // not free any data, i.e., it ignores glyph->freeData.
 
154
  SplashError fillGlyph(SplashCoord x, SplashCoord y,
 
155
                        SplashGlyphBitmap *glyph);
 
156
 
 
157
  // Draws an image mask using the fill color.  This will read <h>
 
158
  // lines of <w> pixels from <src>, starting with the top line.  "1"
 
159
  // pixels will be drawn with the current fill color; "0" pixels are
 
160
  // transparent.  The matrix:
 
161
  //    [ mat[0] mat[1] 0 ]
 
162
  //    [ mat[2] mat[3] 0 ]
 
163
  //    [ mat[4] mat[5] 1 ]
 
164
  // maps a unit square to the desired destination for the image, in
 
165
  // PostScript style:
 
166
  //    [x' y' 1] = [x y 1] * mat
 
167
  // Note that the Splash y axis points downward, and the image source
 
168
  // is assumed to produce pixels in raster order, starting from the
 
169
  // top line.
 
170
  SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
 
171
                            int w, int h, SplashCoord *mat,
 
172
                            GBool glyphMode);
 
173
 
 
174
  // Draw an image.  This will read <h> lines of <w> pixels from
 
175
  // <src>, starting with the top line.  These pixels are assumed to
 
176
  // be in the source mode, <srcMode>.  If <srcAlpha> is true, the
 
177
  // alpha values returned by <src> are used; otherwise they are
 
178
  // ignored.  The following combinations of source and target modes
 
179
  // are supported:
 
180
  //    source       target
 
181
  //    ------       ------
 
182
  //    Mono1        Mono1
 
183
  //    Mono8        Mono1   -- with dithering
 
184
  //    Mono8        Mono8
 
185
  //    RGB8         RGB8
 
186
  //    BGR8         BGR8
 
187
  //    CMYK8        CMYK8
 
188
  // The matrix behaves as for fillImageMask.
 
189
  SplashError drawImage(SplashImageSource src, void *srcData,
 
190
                        SplashColorMode srcMode, GBool srcAlpha,
 
191
                        int w, int h, SplashCoord *mat);
 
192
 
 
193
  // Composite a rectangular region from <src> onto this Splash
 
194
  // object.
 
195
  SplashError composite(SplashBitmap *src, int xSrc, int ySrc,
 
196
                        int xDest, int yDest, int w, int h,
 
197
                        GBool noClip, GBool nonIsolated);
 
198
 
 
199
  // Composite this Splash object onto a background color.  The
 
200
  // background alpha is assumed to be 1.
 
201
  void compositeBackground(SplashColorPtr color);
 
202
 
 
203
  // Copy a rectangular region from <src> onto the bitmap belonging to
 
204
  // this Splash object.  The destination alpha values are all set to
 
205
  // zero.
 
206
  SplashError blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
 
207
                              int xDest, int yDest, int w, int h);
 
208
 
 
209
  //----- misc
 
210
 
 
211
  // Construct a path for a stroke, given the path to be stroked, and
 
212
  // using the current line parameters.  If <flatten> is true, this
 
213
  // function will first flatten the path and handle the linedash.
 
214
  SplashPath *makeStrokePath(SplashPath *path, GBool flatten = gTrue);
 
215
 
 
216
  // Return the associated bitmap.
 
217
  SplashBitmap *getBitmap() { return bitmap; }
 
218
 
 
219
  // Get a bounding box which includes all modifications since the
 
220
  // last call to clearModRegion.
 
221
  void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax)
 
222
    { *xMin = modXMin; *yMin = modYMin; *xMax = modXMax; *yMax = modYMax; }
 
223
 
 
224
  // Clear the modified region bounding box.
 
225
  void clearModRegion();
 
226
 
 
227
  // Get clipping status for the last drawing operation subject to
 
228
  // clipping.
 
229
  SplashClipResult getClipRes() { return opClipRes; }
 
230
 
 
231
  // Toggle debug mode on or off.
 
232
  void setDebugMode(GBool debugModeA) { debugMode = debugModeA; }
 
233
 
 
234
#if 1 //~tmp: turn off anti-aliasing temporarily
 
235
  GBool getVectorAntialias() { return vectorAntialias; }
 
236
  void setVectorAntialias(GBool vaa) { vectorAntialias = vaa; }
 
237
#endif
 
238
 
 
239
private:
 
240
 
 
241
  void pipeInit(SplashPipe *pipe, int x, int y,
 
242
                SplashPattern *pattern, SplashColorPtr cSrc,
 
243
                SplashCoord aInput, GBool usesShape,
 
244
                GBool nonIsolatedGroup);
 
245
  void pipeRun(SplashPipe *pipe);
 
246
  void pipeSetXY(SplashPipe *pipe, int x, int y);
 
247
  void pipeIncX(SplashPipe *pipe);
 
248
  void drawPixel(SplashPipe *pipe, int x, int y, GBool noClip);
 
249
  void drawAAPixelInit();
 
250
  void drawAAPixel(SplashPipe *pipe, int x, int y);
 
251
  void drawSpan(SplashPipe *pipe, int x0, int x1, int y, GBool noClip);
 
252
  void drawAALine(SplashPipe *pipe, int x0, int x1, int y);
 
253
  void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi,
 
254
                 SplashCoord *xo, SplashCoord *yo);
 
255
  void updateModX(int x);
 
256
  void updateModY(int y);
 
257
  void strokeNarrow(SplashPath *path);
 
258
  void strokeWide(SplashPath *path);
 
259
  SplashPath *flattenPath(SplashPath *path, SplashCoord *matrix,
 
260
                          SplashCoord flatness);
 
261
  void flattenCurve(SplashCoord x0, SplashCoord y0,
 
262
                    SplashCoord x1, SplashCoord y1,
 
263
                    SplashCoord x2, SplashCoord y2,
 
264
                    SplashCoord x3, SplashCoord y3,
 
265
                    SplashCoord *matrix, SplashCoord flatness2,
 
266
                    SplashPath *fPath);
 
267
  SplashPath *makeDashedPath(SplashPath *xPath);
 
268
  SplashError fillWithPattern(SplashPath *path, GBool eo,
 
269
                              SplashPattern *pattern, SplashCoord alpha);
 
270
  SplashError fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph);
 
271
  void dumpPath(SplashPath *path);
 
272
  void dumpXPath(SplashXPath *path);
 
273
 
 
274
  static SplashPipeResultColorCtrl pipeResultColorNoAlphaBlend[];
 
275
  static SplashPipeResultColorCtrl pipeResultColorAlphaNoBlend[];
 
276
  static SplashPipeResultColorCtrl pipeResultColorAlphaBlend[];
 
277
  static int pipeNonIsoGroupCorrection[];
 
278
 
 
279
  SplashBitmap *bitmap;
 
280
  SplashState *state;
 
281
  SplashBitmap *aaBuf;
 
282
  int aaBufY;
 
283
  SplashBitmap *alpha0Bitmap;   // for non-isolated groups, this is the
 
284
                                //   bitmap containing the alpha0 values
 
285
  int alpha0X, alpha0Y;         // offset within alpha0Bitmap
 
286
  SplashCoord aaGamma[splashAASize * splashAASize + 1];
 
287
  int modXMin, modYMin, modXMax, modYMax;
 
288
  SplashClipResult opClipRes;
 
289
  GBool vectorAntialias;
 
290
  GBool debugMode;
 
291
};
 
292
 
 
293
#endif