1 //========================================================================
5 // Copyright 2003 Glyph & Cog, LLC
6 // Copyright 2004 Red Hat, INC
8 //========================================================================
10 #ifndef CAIROOUTPUTDEV_H
11 #define CAIROOUTPUTDEV_H
13 #ifdef USE_GCC_PRAGMAS
17 #include "goo/gtypes.h"
19 #include "OutputDev.h"
26 class CairoFontEngine
;
29 //------------------------------------------------------------------------
31 //------------------------------------------------------------------------
33 //------------------------------------------------------------------------
35 class CairoOutputDev
: public OutputDev
{
42 virtual ~CairoOutputDev();
44 //----- get info about output device
46 // Does this device use upside-down coordinates?
47 // (Upside-down means (0,0) is the top left corner of the page.)
48 virtual GBool
upsideDown() { return gTrue
; }
50 // Does this device use drawChar() or drawString()?
51 virtual GBool
useDrawChar() { return gTrue
; }
53 // Does this device use beginType3Char/endType3Char? Otherwise,
54 // text in Type 3 fonts will be drawn with drawChar/drawString.
55 virtual GBool
interpretType3Chars() { return gTrue
; }
57 //----- initialization and control
60 virtual void startPage(int pageNum
, GfxState
*state
) { }
63 virtual void endPage() { }
66 virtual void drawLink(Link
*link
, Catalog
*catalog
);
68 //----- save/restore graphics state
69 virtual void saveState(GfxState
*state
);
70 virtual void restoreState(GfxState
*state
);
72 //----- update graphics state
73 virtual void updateAll(GfxState
*state
);
74 virtual void setDefaultCTM(double *ctm
);
75 virtual void updateCTM(GfxState
*state
, double m11
, double m12
,
76 double m21
, double m22
, double m31
, double m32
);
77 virtual void updateLineDash(GfxState
*state
);
78 virtual void updateFlatness(GfxState
*state
);
79 virtual void updateLineJoin(GfxState
*state
);
80 virtual void updateLineCap(GfxState
*state
);
81 virtual void updateMiterLimit(GfxState
*state
);
82 virtual void updateLineWidth(GfxState
*state
);
83 virtual void updateFillColor(GfxState
*state
);
84 virtual void updateStrokeColor(GfxState
*state
);
85 virtual void updateFillOpacity(GfxState
*state
);
86 virtual void updateStrokeOpacity(GfxState
*state
);
88 //----- update text state
89 virtual void updateFont(GfxState
*state
);
92 virtual void stroke(GfxState
*state
);
93 virtual void fill(GfxState
*state
);
94 virtual void eoFill(GfxState
*state
);
97 virtual void clip(GfxState
*state
);
98 virtual void eoClip(GfxState
*state
);
101 void beginString(GfxState
*state
, GooString
*s
);
102 void endString(GfxState
*state
);
103 void drawChar(GfxState
*state
, double x
, double y
,
104 double dx
, double dy
,
105 double originX
, double originY
,
106 CharCode code
, int nBytes
, Unicode
*u
, int uLen
);
108 virtual GBool
beginType3Char(GfxState
*state
, double x
, double y
,
109 double dx
, double dy
,
110 CharCode code
, Unicode
*u
, int uLen
);
111 virtual void endType3Char(GfxState
*state
);
112 virtual void endTextObject(GfxState
*state
);
114 //----- image drawing
115 virtual void drawImageMask(GfxState
*state
, Object
*ref
, Stream
*str
,
116 int width
, int height
, GBool invert
,
118 virtual void drawImage(GfxState
*state
, Object
*ref
, Stream
*str
,
119 int width
, int height
, GfxImageColorMap
*colorMap
,
120 int *maskColors
, GBool inlineImg
);
121 virtual void drawSoftMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
122 int width
, int height
,
123 GfxImageColorMap
*colorMap
,
125 int maskWidth
, int maskHeight
,
126 GfxImageColorMap
*maskColorMap
);
128 virtual void drawMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
129 int width
, int height
,
130 GfxImageColorMap
*colorMap
,
132 int maskWidth
, int maskHeight
,
136 //----- Type 3 font operators
137 virtual void type3D0(GfxState
*state
, double wx
, double wy
);
138 virtual void type3D1(GfxState
*state
, double wx
, double wy
,
139 double llx
, double lly
, double urx
, double ury
);
141 //----- special access
143 // Called to indicate that a new PDF document has been loaded.
144 void startDoc(XRef
*xrefA
);
146 GBool
isReverseVideo() { return gFalse
; }
148 void setCairo (cairo_t
*cr
);
151 void doPath(GfxState
*state
, GfxPath
*path
);
153 GfxRGB fill_color
, stroke_color
;
154 cairo_pattern_t
*fill_pattern
, *stroke_pattern
;
156 double stroke_opacity
;
157 CairoFont
*currentFont
;
159 XRef
*xref
; // xref table for current document
162 CairoFontEngine
*fontEngine
;
164 GBool needFontUpdate
; // set when the font needs to be updated
165 cairo_surface_t
*surface
;
166 cairo_glyph_t
*glyphs
;
168 cairo_path_t
*textClipPath
;