1 //========================================================================
5 //========================================================================
10 #ifdef USE_GCC_PRAGMAS
14 #include "SplashTypes.h"
15 #include "SplashClip.h"
18 struct SplashGlyphBitmap
;
26 //------------------------------------------------------------------------
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.
31 typedef GBool (*SplashImageMaskSource
)(void *data
, SplashColorPtr pixel
);
33 // Retrieves the next line of pixels in an image. Normally, fills in
34 // *<line> and returns true. If the image stream is exhausted,
36 typedef GBool (*SplashImageSource
)(void *data
, SplashColorPtr line
);
38 //------------------------------------------------------------------------
40 //------------------------------------------------------------------------
45 // Create a new rasterizer object.
46 Splash(SplashBitmap
*bitmapA
);
52 SplashPattern
*getStrokePattern();
53 SplashPattern
*getFillPattern();
54 SplashScreen
*getScreen();
55 SplashBlendFunc
getBlendFunc();
56 SplashCoord
getStrokeAlpha();
57 SplashCoord
getFillAlpha();
58 SplashCoord
getLineWidth();
61 SplashCoord
getMiterLimit();
62 SplashCoord
getFlatness();
63 SplashCoord
*getLineDash();
64 int getLineDashLength();
65 SplashCoord
getLineDashPhase();
66 SplashClip
*getClip();
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
);
90 //----- state save/restore
93 SplashError
restoreState();
97 void setSoftMask(SplashBitmap
*softMaskA
);
99 //----- drawing operations
101 // Fill the bitmap with <color>. This is not subject to clipping.
102 void clear(SplashColorPtr color
);
104 // Stroke a path using the current stroke pattern.
105 SplashError
stroke(SplashPath
*path
);
107 // Fill a path using the current fill pattern.
108 SplashError
fill(SplashPath
*path
, GBool eo
);
110 // Fill a path, XORing with the current fill pattern.
111 SplashError
xorFill(SplashPath
*path
, GBool eo
);
113 // Draw a character, using the current fill pattern.
114 SplashError
fillChar(SplashCoord x
, SplashCoord y
, int c
, SplashFont
*font
);
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
);
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
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
134 SplashError
fillImageMask(SplashImageMaskSource src
, void *srcData
,
135 int w
, int h
, SplashCoord
*mat
);
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:
144 // Mono8 Mono1 -- with dithering
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
);
157 // Return the associated bitmap.
158 SplashBitmap
*getBitmap() { return bitmap
; }
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
; }
165 // Clear the modified region bounding box.
166 void clearModRegion();
168 // Get clipping status for the last drawing operation subject to
170 SplashClipResult
getClipRes() { return opClipRes
; }
172 // Toggle debug mode on or off.
173 void setDebugMode(GBool debugModeA
) { debugMode
= debugModeA
; }
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
);
194 SplashBitmap
*bitmap
;
196 SplashBitmap
*softMask
;
197 int modXMin
, modYMin
, modXMax
, modYMax
;
198 SplashClipResult opClipRes
;