]> www.fi.muni.cz Git - evince.git/blob - pdf/splash/Splash.h
guard against unloaded docs when the title is accessed.
[evince.git] / pdf / splash / Splash.h
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
18 class SplashBitmap;
19 class SplashGlyphBitmap;
20 class SplashState;
21 class SplashPattern;
22 class SplashScreen;
23 class SplashPath;
24 class SplashXPath;
25 class SplashClip;
26 class SplashFont;
27
28 //------------------------------------------------------------------------
29
30 // Retrieves the next pixel in an image mask.  Normally, fills in
31 // *<pixel> and returns true.  If the image stream is exhausted,
32 // returns false.
33 typedef GBool (*SplashImageMaskSource)(void *data, SplashMono1 *pixel);
34
35 // Retrieves the next pixel in an image.  Normally, fills in *<pixel>
36 // (pixel color) and *<alpha> (1 for opaque, 0 for transparent), and
37 // returns true.  If the image stream is exhausted, returns false.
38 typedef GBool (*SplashImageSource)(void *data, SplashColor *pixel,
39                                    Guchar *alpha);
40
41 //------------------------------------------------------------------------
42 // Splash
43 //------------------------------------------------------------------------
44
45 class Splash {
46 public:
47
48   // Create a new rasterizer object.
49   Splash(SplashBitmap *bitmapA);
50
51   ~Splash();
52
53   //----- state read
54
55   SplashPattern *getStrokePattern();
56   SplashPattern *getFillPattern();
57   SplashScreen *getScreen();
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 setLineWidth(SplashCoord lineWidth);
74   void setLineCap(int lineCap);
75   void setLineJoin(int lineJoin);
76   void setMiterLimit(SplashCoord miterLimit);
77   void setFlatness(SplashCoord flatness);
78   // the <lineDash> array will be copied
79   void setLineDash(SplashCoord *lineDash, int lineDashLength,
80                    SplashCoord lineDashPhase);
81   void clipResetToRect(SplashCoord x0, SplashCoord y0,
82                        SplashCoord x1, SplashCoord y1);
83   SplashError clipToRect(SplashCoord x0, SplashCoord y0,
84                          SplashCoord x1, SplashCoord y1);
85   SplashError clipToPath(SplashPath *path, GBool eo);
86
87   //----- state save/restore
88
89   void saveState();
90   SplashError restoreState();
91
92   //----- drawing operations
93
94   // Fill the bitmap with <color>.  This is not subject to clipping.
95   void clear(SplashColor color);
96
97   // Stroke a path using the current stroke pattern.
98   SplashError stroke(SplashPath *path);
99
100   // Fill a path using the current fill pattern.
101   SplashError fill(SplashPath *path, GBool eo);
102
103   // Fill a path, XORing with the current fill pattern.
104   SplashError xorFill(SplashPath *path, GBool eo);
105
106   // Draw a character, using the current fill pattern.
107   SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
108
109   // Draw a glyph, using the current fill pattern.  This function does
110   // not free any data, i.e., it ignores glyph->freeData.
111   SplashError fillGlyph(SplashCoord x, SplashCoord y,
112                         SplashGlyphBitmap *glyph);
113
114   // Draws an image mask using the fill color.  This will read <w>*<h>
115   // pixels from <src>, in raster order, starting with the top line.
116   // "1" pixels will be drawn with the current fill color; "0" pixels
117   // are transparent.  The matrix:
118   //    [ mat[0] mat[1] 0 ]
119   //    [ mat[2] mat[3] 0 ]
120   //    [ mat[4] mat[5] 1 ]
121   // maps a unit square to the desired destination for the image, in
122   // PostScript style:
123   //    [x' y' 1] = [x y 1] * mat
124   // Note that the Splash y axis points downward, and the image source
125   // is assumed to produce pixels in raster order, starting from the
126   // top line.
127   SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
128                             int w, int h, SplashCoord *mat);
129
130   // Draw an image.  This will read <w>*<h> pixels from <src>, in
131   // raster order, starting with the top line.  These pixels are
132   // assumed to be in the source mode, <srcMode>.  The following
133   // combinations of source and target modes are supported:
134   //    source       target
135   //    ------       ------
136   //    Mono1        Mono1
137   //    Mono8        Mono1   -- with dithering
138   //    Mono8        Mono8
139   //    RGB8         RGB8
140   //    BGR8packed   BGR8Packed
141   // The matrix behaves as for fillImageMask.
142   SplashError drawImage(SplashImageSource src, void *srcData,
143                         SplashColorMode srcMode,
144                         int w, int h, SplashCoord *mat);
145
146   //~ drawMaskedImage
147
148   //----- misc
149
150   // Return the associated bitmap.
151   SplashBitmap *getBitmap() { return bitmap; }
152
153   // Toggle debug mode on or off.
154   void setDebugMode(GBool debugModeA) { debugMode = debugModeA; }
155
156 private:
157
158   void strokeNarrow(SplashXPath *xPath);
159   void strokeWide(SplashXPath *xPath);
160   SplashXPath *makeDashedPath(SplashXPath *xPath);
161   SplashError fillWithPattern(SplashPath *path, GBool eo,
162                               SplashPattern *pattern);
163   void drawPixel(int x, int y, SplashColor *color, GBool noClip);
164   void drawPixel(int x, int y, SplashPattern *pattern, GBool noClip);
165   void drawSpan(int x0, int x1, int y, SplashPattern *pattern, GBool noClip);
166   void xorSpan(int x0, int x1, int y, SplashPattern *pattern, GBool noClip);
167   void putPixel(int x, int y, SplashColor *pixel);
168   void getPixel(int x, int y, SplashColor *pixel);
169   void dumpPath(SplashPath *path);
170
171   SplashBitmap *bitmap;
172   SplashState *state;
173   GBool debugMode;
174 };
175
176 #endif