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