1 //========================================================================
2 //
3 // SplashState.h
4 //
5 // Copyright 2003-2013 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #ifndef SPLASHSTATE_H
10 #define SPLASHSTATE_H
11 
12 #include <aconf.h>
13 
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17 
18 #include "SplashTypes.h"
19 
20 class SplashPattern;
21 class SplashScreen;
22 class SplashClip;
23 class SplashBitmap;
24 class SplashPath;
25 
26 //------------------------------------------------------------------------
27 // line cap values
28 //------------------------------------------------------------------------
29 
30 #define splashLineCapButt       0
31 #define splashLineCapRound      1
32 #define splashLineCapProjecting 2
33 
34 //------------------------------------------------------------------------
35 // line join values
36 //------------------------------------------------------------------------
37 
38 #define splashLineJoinMiter     0
39 #define splashLineJoinRound     1
40 #define splashLineJoinBevel     2
41 
42 //------------------------------------------------------------------------
43 // SplashState
44 //------------------------------------------------------------------------
45 
46 class SplashState {
47 public:
48 
49   // Create a new state object, initialized with default settings.
50   SplashState(int width, int height, GBool vectorAntialias,
51 	      SplashScreenParams *screenParams);
52   SplashState(int width, int height, GBool vectorAntialias,
53 	      SplashScreen *screenA);
54 
55   // Copy a state object.
copy()56   SplashState *copy() { return new SplashState(this); }
57 
58   ~SplashState();
59 
60   // Set the stroke pattern.  This does not copy <strokePatternA>.
61   void setStrokePattern(SplashPattern *strokePatternA);
62 
63   // Set the fill pattern.  This does not copy <fillPatternA>.
64   void setFillPattern(SplashPattern *fillPatternA);
65 
66   // Set the screen.  This does not copy <screenA>.
67   void setScreen(SplashScreen *screenA);
68 
69   // Set the line dash pattern.  This copies the <lineDashA> array.
70   void setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
71 		   SplashCoord lineDashPhaseA);
72 
73   // Returns true if the current line dash pattern contains one or
74   // more zero-length "on" sections (dashes).
75   GBool lineDashContainsZeroLengthDashes();
76 
77   void clipResetToRect(SplashCoord x0, SplashCoord y0,
78 		       SplashCoord x1, SplashCoord y1);
79   SplashError clipToRect(SplashCoord x0, SplashCoord y0,
80 			 SplashCoord x1, SplashCoord y1);
81   SplashError clipToPath(SplashPath *path, GBool eo);
82 
83   // Set the soft mask bitmap.
84   void setSoftMask(SplashBitmap *softMaskA);
85 
86   // Set the transfer function.
87   void setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray);
88 
89 
90 private:
91 
92   SplashState(SplashState *state);
93 
94   SplashCoord matrix[6];
95   SplashPattern *strokePattern;
96   SplashPattern *fillPattern;
97   SplashScreen *screen;
98   SplashBlendFunc blendFunc;
99   SplashCoord strokeAlpha;
100   SplashCoord fillAlpha;
101   SplashCoord lineWidth;
102   int lineCap;
103   int lineJoin;
104   SplashCoord miterLimit;
105   SplashCoord flatness;
106   SplashCoord *lineDash;
107   int lineDashLength;
108   SplashCoord lineDashPhase;
109   SplashStrokeAdjustMode strokeAdjust;
110   SplashClip *clip;
111   GBool clipIsShared;
112   SplashBitmap *softMask;
113   GBool deleteSoftMask;
114   GBool inNonIsolatedGroup;
115   GBool inKnockoutGroup;
116   Guchar rgbTransferR[256],
117          rgbTransferG[256],
118          rgbTransferB[256];
119   Guchar grayTransfer[256];
120 #if SPLASH_CMYK
121   Guchar cmykTransferC[256],
122          cmykTransferM[256],
123          cmykTransferY[256],
124          cmykTransferK[256];
125 #endif
126   Guint overprintMask;
127   GBool enablePathSimplification;
128 
129 
130   SplashState *next;		// used by Splash class
131 
132   friend class Splash;
133 };
134 
135 #endif
136