1 //========================================================================
5 //========================================================================
12 #ifdef USE_GCC_PRAGMAS
16 #include "SplashTypes.h"
17 #include "SplashClip.h"
20 struct SplashGlyphBitmap
;
28 //------------------------------------------------------------------------
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.
33 typedef GBool (*SplashImageMaskSource
)(void *data
, SplashColorPtr pixel
);
35 // Retrieves the next line of pixels in an image. Normally, fills in
36 // *<line> and returns true. If the image stream is exhausted,
38 typedef GBool (*SplashImageSource
)(void *data
, SplashColorPtr line
);
40 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
47 // Create a new rasterizer object.
48 Splash(SplashBitmap
*bitmapA
);
54 SplashPattern
*getStrokePattern();
55 SplashPattern
*getFillPattern();
56 SplashScreen
*getScreen();
57 SplashBlendFunc
getBlendFunc();
58 SplashCoord
getStrokeAlpha();
59 SplashCoord
getFillAlpha();
60 SplashCoord
getLineWidth();
63 SplashCoord
getMiterLimit();
64 SplashCoord
getFlatness();
65 SplashCoord
*getLineDash();
66 int getLineDashLength();
67 SplashCoord
getLineDashPhase();
68 SplashClip
*getClip();
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
);
92 //----- state save/restore
95 SplashError
restoreState();
99 void setSoftMask(SplashBitmap
*softMaskA
);
101 //----- drawing operations
103 // Fill the bitmap with <color>. This is not subject to clipping.
104 void clear(SplashColorPtr color
);
106 // Stroke a path using the current stroke pattern.
107 SplashError
stroke(SplashPath
*path
);
109 // Fill a path using the current fill pattern.
110 SplashError
fill(SplashPath
*path
, GBool eo
);
112 // Fill a path, XORing with the current fill pattern.
113 SplashError
xorFill(SplashPath
*path
, GBool eo
);
115 // Draw a character, using the current fill pattern.
116 SplashError
fillChar(SplashCoord x
, SplashCoord y
, int c
, SplashFont
*font
);
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
);
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
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
136 SplashError
fillImageMask(SplashImageMaskSource src
, void *srcData
,
137 int w
, int h
, SplashCoord
*mat
);
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:
146 // Mono8 Mono1 -- with dithering
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
);
159 // Return the associated bitmap.
160 SplashBitmap
*getBitmap() { return bitmap
; }
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
; }
167 // Clear the modified region bounding box.
168 void clearModRegion();
170 // Get clipping status for the last drawing operation subject to
172 SplashClipResult
getClipRes() { return opClipRes
; }
174 // Toggle debug mode on or off.
175 void setDebugMode(GBool debugModeA
) { debugMode
= debugModeA
; }
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
);
196 SplashBitmap
*bitmap
;
198 SplashBitmap
*softMask
;
199 int modXMin
, modYMin
, modXMax
, modYMax
;
200 SplashClipResult opClipRes
;