source: trunk/poppler/mypoppler/splash/Splash.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 6.4 KB
Line 
1//========================================================================
2//
3// Splash.h
4//
5//========================================================================
6
7#ifndef SPLASH_H
8#define SPLASH_H
9
10#ifdef USE_GCC_PRAGMAS
11#pragma interface
12#endif
13
14#include "SplashTypes.h"
15#include "SplashClip.h"
16
17class SplashBitmap;
18struct SplashGlyphBitmap;
19class SplashState;
20class SplashPattern;
21class SplashScreen;
22class SplashPath;
23class SplashXPath;
24class SplashFont;
25
26//------------------------------------------------------------------------
27
28// Retrieves the next line of pixels in an image mask.  Normally,
29// fills in *<line> and returns true.  If the image stream is
30// exhausted, returns false.
31typedef GBool (*SplashImageMaskSource)(void *data, SplashColorPtr pixel);
32
33// Retrieves the next line of pixels in an image.  Normally, fills in
34// *<line> and returns true.  If the image stream is exhausted,
35// returns false.
36typedef GBool (*SplashImageSource)(void *data, SplashColorPtr line);
37
38//------------------------------------------------------------------------
39// Splash
40//------------------------------------------------------------------------
41
42class Splash {
43public:
44
45  // Create a new rasterizer object.
46  Splash(SplashBitmap *bitmapA);
47
48  ~Splash();
49
50  //----- state read
51
52  SplashPattern *getStrokePattern();
53  SplashPattern *getFillPattern();
54  SplashScreen *getScreen();
55  SplashBlendFunc getBlendFunc();
56  SplashCoord getStrokeAlpha();
57  SplashCoord getFillAlpha();
58  SplashCoord getLineWidth();
59  int getLineCap();
60  int getLineJoin();
61  SplashCoord getMiterLimit();
62  SplashCoord getFlatness();
63  SplashCoord *getLineDash();
64  int getLineDashLength();
65  SplashCoord getLineDashPhase();
66  SplashClip *getClip();
67
68  //----- state write
69
70  void setStrokePattern(SplashPattern *strokeColor);
71  void setFillPattern(SplashPattern *fillColor);
72  void setScreen(SplashScreen *screen);
73  void setBlendFunc(SplashBlendFunc func);
74  void setStrokeAlpha(SplashCoord alpha);
75  void setFillAlpha(SplashCoord alpha);
76  void setLineWidth(SplashCoord lineWidth);
77  void setLineCap(int lineCap);
78  void setLineJoin(int lineJoin);
79  void setMiterLimit(SplashCoord miterLimit);
80  void setFlatness(SplashCoord flatness);
81  // the <lineDash> array will be copied
82  void setLineDash(SplashCoord *lineDash, int lineDashLength,
83                   SplashCoord lineDashPhase);
84  void clipResetToRect(SplashCoord x0, SplashCoord y0,
85                       SplashCoord x1, SplashCoord y1);
86  SplashError clipToRect(SplashCoord x0, SplashCoord y0,
87                         SplashCoord x1, SplashCoord y1);
88  SplashError clipToPath(SplashPath *path, GBool eo);
89
90  //----- state save/restore
91
92  void saveState();
93  SplashError restoreState();
94
95  //----- soft mask
96
97  void setSoftMask(SplashBitmap *softMaskA);
98
99  //----- drawing operations
100
101  // Fill the bitmap with <color>.  This is not subject to clipping.
102  void clear(SplashColorPtr color);
103
104  // Stroke a path using the current stroke pattern.
105  SplashError stroke(SplashPath *path);
106
107  // Fill a path using the current fill pattern.
108  SplashError fill(SplashPath *path, GBool eo);
109
110  // Fill a path, XORing with the current fill pattern.
111  SplashError xorFill(SplashPath *path, GBool eo);
112
113  // Draw a character, using the current fill pattern.
114  SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
115
116  // Draw a glyph, using the current fill pattern.  This function does
117  // not free any data, i.e., it ignores glyph->freeData.
118  SplashError fillGlyph(SplashCoord x, SplashCoord y,
119                        SplashGlyphBitmap *glyph);
120
121  // Draws an image mask using the fill color.  This will read <h>
122  // lines of <w> pixels from <src>, starting with the top line.  "1"
123  // pixels will be drawn with the current fill color; "0" pixels are
124  // transparent.  The matrix:
125  //    [ mat[0] mat[1] 0 ]
126  //    [ mat[2] mat[3] 0 ]
127  //    [ mat[4] mat[5] 1 ]
128  // maps a unit square to the desired destination for the image, in
129  // PostScript style:
130  //    [x' y' 1] = [x y 1] * mat
131  // Note that the Splash y axis points downward, and the image source
132  // is assumed to produce pixels in raster order, starting from the
133  // top line.
134  SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
135                            int w, int h, SplashCoord *mat);
136
137  // Draw an image.  This will read <h> lines of <w> pixels from
138  // <src>, starting with the top line.  These pixels are assumed to
139  // be in the source mode, <srcMode>.  The following combinations of
140  // source and target modes are supported:
141  //    source       target
142  //    ------       ------
143  //    Mono1        Mono1
144  //    Mono8        Mono1   -- with dithering
145  //    Mono8        Mono8
146  //    RGB8         RGB8
147  //    BGR8         BGR8
148  //    ARGB8        RGB8    -- with source alpha (masking)
149  //    BGRA8        BGR8    -- with source alpha (masking)
150  // The matrix behaves as for fillImageMask.
151  SplashError drawImage(SplashImageSource src, void *srcData,
152                        SplashColorMode srcMode,
153                        int w, int h, SplashCoord *mat);
154
155  //----- misc
156
157  // Return the associated bitmap.
158  SplashBitmap *getBitmap() { return bitmap; }
159
160  // Get a bounding box which includes all modifications since the
161  // last call to clearModRegion.
162  void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax)
163    { *xMin = modXMin; *yMin = modYMin; *xMax = modXMax; *yMax = modYMax; }
164
165  // Clear the modified region bounding box.
166  void clearModRegion();
167
168  // Get clipping status for the last drawing operation subject to
169  // clipping.
170  SplashClipResult getClipRes() { return opClipRes; }
171
172  // Toggle debug mode on or off.
173  void setDebugMode(GBool debugModeA) { debugMode = debugModeA; }
174
175private:
176
177  void updateModX(int x);
178  void updateModY(int y);
179  void strokeNarrow(SplashXPath *xPath);
180  void strokeWide(SplashXPath *xPath);
181  SplashXPath *makeDashedPath(SplashXPath *xPath);
182  SplashError fillWithPattern(SplashPath *path, GBool eo,
183                              SplashPattern *pattern, SplashCoord alpha);
184  void drawPixel(int x, int y, SplashColorPtr color,
185                 SplashCoord alpha, GBool noClip);
186  void drawPixel(int x, int y, SplashPattern *pattern,
187                 SplashCoord alpha, GBool noClip);
188  void drawSpan(int x0, int x1, int y, SplashPattern *pattern,
189                SplashCoord alpha, GBool noClip);
190  void xorSpan(int x0, int x1, int y, SplashPattern *pattern, GBool noClip);
191  void dumpPath(SplashPath *path);
192  void dumpXPath(SplashXPath *path);
193
194  SplashBitmap *bitmap;
195  SplashState *state;
196  SplashBitmap *softMask;
197  int modXMin, modYMin, modXMax, modYMax;
198  SplashClipResult opClipRes;
199  GBool debugMode;
200};
201
202#endif
Note: See TracBrowser for help on using the repository browser.