1 //========================================================================
5 // Copyright 2003 Glyph & Cog, LLC
7 //========================================================================
9 #ifndef SPLASHOUTPUTDEV_H
10 #define SPLASHOUTPUTDEV_H
14 #ifdef USE_GCC_PRAGMAS
19 #include "SplashTypes.h"
21 #include "OutputDev.h"
29 class SplashFontEngine
;
32 struct T3FontCacheTag
;
35 //------------------------------------------------------------------------
37 // number of Type 3 fonts to cache
38 #define splashOutT3FontCacheSize 8
40 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
44 class SplashOutputDev
: public OutputDev
{
48 SplashOutputDev(SplashColorMode colorModeA
, int bitmapRowPadA
,
49 GBool reverseVideoA
, SplashColorPtr paperColorA
,
50 GBool bitmapTopDownA
= gTrue
,
51 GBool allowAntialiasA
= gTrue
);
54 virtual ~SplashOutputDev();
56 //----- get info about output device
58 // Does this device use upside-down coordinates?
59 // (Upside-down means (0,0) is the top left corner of the page.)
60 virtual GBool
upsideDown() { return gTrue
; }
62 // Does this device use drawChar() or drawString()?
63 virtual GBool
useDrawChar() { return gTrue
; }
65 // Does this device use beginType3Char/endType3Char? Otherwise,
66 // text in Type 3 fonts will be drawn with drawChar/drawString.
67 virtual GBool
interpretType3Chars() { return gTrue
; }
69 //----- initialization and control
72 virtual GBool
startPage(int pageNum
, GfxState
*state
);
75 virtual void endPage();
78 virtual void drawLink(Link
*link
, Catalog
*catalog
);
80 //----- save/restore graphics state
81 virtual void saveState(GfxState
*state
);
82 virtual void restoreState(GfxState
*state
);
84 //----- update graphics state
85 virtual void updateAll(GfxState
*state
);
86 virtual void updateCTM(GfxState
*state
, double m11
, double m12
,
87 double m21
, double m22
, double m31
, double m32
);
88 virtual void updateLineDash(GfxState
*state
);
89 virtual void updateFlatness(GfxState
*state
);
90 virtual void updateLineJoin(GfxState
*state
);
91 virtual void updateLineCap(GfxState
*state
);
92 virtual void updateMiterLimit(GfxState
*state
);
93 virtual void updateLineWidth(GfxState
*state
);
94 virtual void updateFillColor(GfxState
*state
);
95 virtual void updateStrokeColor(GfxState
*state
);
96 virtual void updateBlendMode(GfxState
*state
);
97 virtual void updateFillOpacity(GfxState
*state
);
98 virtual void updateStrokeOpacity(GfxState
*state
);
100 //----- update text state
101 virtual void updateFont(GfxState
*state
);
103 //----- path painting
104 virtual void stroke(GfxState
*state
);
105 virtual void fill(GfxState
*state
);
106 virtual void eoFill(GfxState
*state
);
108 //----- path clipping
109 virtual void clip(GfxState
*state
);
110 virtual void eoClip(GfxState
*state
);
113 virtual void drawChar(GfxState
*state
, double x
, double y
,
114 double dx
, double dy
,
115 double originX
, double originY
,
116 CharCode code
, int nBytes
, Unicode
*u
, int uLen
);
117 virtual GBool
beginType3Char(GfxState
*state
, double x
, double y
,
118 double dx
, double dy
,
119 CharCode code
, Unicode
*u
, int uLen
);
120 virtual void endType3Char(GfxState
*state
);
121 virtual void endTextObject(GfxState
*state
);
123 //----- image drawing
124 virtual void drawImageMask(GfxState
*state
, Object
*ref
, Stream
*str
,
125 int width
, int height
, GBool invert
,
127 virtual void drawImage(GfxState
*state
, Object
*ref
, Stream
*str
,
128 int width
, int height
, GfxImageColorMap
*colorMap
,
129 int *maskColors
, GBool inlineImg
);
130 virtual void drawMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
131 int width
, int height
,
132 GfxImageColorMap
*colorMap
,
133 Stream
*maskStr
, int maskWidth
, int maskHeight
,
135 virtual void drawSoftMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
136 int width
, int height
,
137 GfxImageColorMap
*colorMap
,
139 int maskWidth
, int maskHeight
,
140 GfxImageColorMap
*maskColorMap
);
142 //----- Type 3 font operators
143 virtual void type3D0(GfxState
*state
, double wx
, double wy
);
144 virtual void type3D1(GfxState
*state
, double wx
, double wy
,
145 double llx
, double lly
, double urx
, double ury
);
147 //----- special access
149 // Called to indicate that a new PDF document has been loaded.
150 void startDoc(XRef
*xrefA
);
152 void setPaperColor(SplashColorPtr paperColorA
);
154 GBool
isReverseVideo() { return reverseVideo
; }
155 void setReverseVideo(GBool reverseVideoA
) { reverseVideo
= reverseVideoA
; }
157 // Get the bitmap and its size.
158 SplashBitmap
*getBitmap() { return bitmap
; }
159 int getBitmapWidth();
160 int getBitmapHeight();
162 // Returns the last rasterized bitmap, transferring ownership to the
164 SplashBitmap
*takeBitmap();
166 // Get the Splash object.
167 Splash
*getSplash() { return splash
; }
169 // Get the modified region.
170 void getModRegion(int *xMin
, int *yMin
, int *xMax
, int *yMax
);
172 // Clear the modified region.
173 void clearModRegion();
175 // Set the Splash fill color.
176 void setFillColor(int r
, int g
, int b
);
178 // Get a font object for a Base-14 font, using the Latin-1 encoding.
179 SplashFont
*getFont(GString
*name
, double *mat
);
181 SplashFont
*getCurrentFont() { return font
; }
186 SplashPattern
*getColor(GfxGray gray
, GfxRGB
*rgb
, GfxCMYK
*cmyk
);
188 SplashPattern
*getColor(GfxGray gray
, GfxRGB
*rgb
);
190 SplashPath
*convertPath(GfxState
*state
, GfxPath
*path
);
191 void drawType3Glyph(T3FontCache
*t3Font
,
192 T3FontCacheTag
*tag
, Guchar
*data
,
194 static GBool
imageMaskSrc(void *data
, SplashColorPtr line
);
195 static GBool
imageSrc(void *data
, SplashColorPtr line
);
196 static GBool
alphaImageSrc(void *data
, SplashColorPtr line
);
197 static GBool
maskedImageSrc(void *data
, SplashColorPtr line
);
199 SplashColorMode colorMode
;
202 GBool allowAntialias
;
203 GBool reverseVideo
; // reverse video mode
204 SplashColor paperColor
; // paper color
206 XRef
*xref
; // xref table for current document
208 SplashBitmap
*bitmap
;
210 SplashFontEngine
*fontEngine
;
212 T3FontCache
* // Type 3 font cache
213 t3FontCache
[splashOutT3FontCacheSize
];
214 int nT3Fonts
; // number of valid entries in t3FontCache
215 T3GlyphStack
*t3GlyphStack
; // Type 3 glyph context stack
217 SplashFont
*font
; // current font
218 GBool needFontUpdate
; // set when the font needs to be updated
219 SplashPath
*textClipPath
; // clipping path built with text object