1 //========================================================================
5 //========================================================================
10 #pragma implementation
15 #include "SplashPattern.h"
16 #include "SplashScreen.h"
17 #include "SplashClip.h"
18 #include "SplashBitmap.h"
19 #include "SplashState.h"
21 //------------------------------------------------------------------------
23 //------------------------------------------------------------------------
25 // number of components in each color mode
26 int splashColorModeNComps
[] = {
30 SplashState::SplashState(int width
, int height
, GBool vectorAntialias
,
31 SplashScreenParams
*screenParams
) {
34 matrix
[0] = 1; matrix
[1] = 0;
35 matrix
[2] = 0; matrix
[3] = 1;
36 matrix
[4] = 0; matrix
[5] = 0;
37 memset(&color
, 0, sizeof(SplashColor
));
38 strokePattern
= new SplashSolidColor(color
);
39 fillPattern
= new SplashSolidColor(color
);
40 screen
= new SplashScreen(screenParams
);
45 lineCap
= splashLineCapButt
;
46 lineJoin
= splashLineJoinMiter
;
52 strokeAdjust
= gFalse
;
53 clip
= new SplashClip(0, 0, width
- 0.001, height
- 0.001, vectorAntialias
);
55 deleteSoftMask
= gFalse
;
56 inNonIsolatedGroup
= gFalse
;
60 SplashState::SplashState(int width
, int height
, GBool vectorAntialias
,
61 SplashScreen
*screenA
) {
64 matrix
[0] = 1; matrix
[1] = 0;
65 matrix
[2] = 0; matrix
[3] = 1;
66 matrix
[4] = 0; matrix
[5] = 0;
67 memset(&color
, 0, sizeof(SplashColor
));
68 strokePattern
= new SplashSolidColor(color
);
69 fillPattern
= new SplashSolidColor(color
);
70 screen
= screenA
->copy();
75 lineCap
= splashLineCapButt
;
76 lineJoin
= splashLineJoinMiter
;
82 strokeAdjust
= gFalse
;
83 clip
= new SplashClip(0, 0, width
- 0.001, height
- 0.001, vectorAntialias
);
85 deleteSoftMask
= gFalse
;
86 inNonIsolatedGroup
= gFalse
;
90 SplashState::SplashState(SplashState
*state
) {
91 memcpy(matrix
, state
->matrix
, 6 * sizeof(SplashCoord
));
92 strokePattern
= state
->strokePattern
->copy();
93 fillPattern
= state
->fillPattern
->copy();
94 screen
= state
->screen
->copy();
95 blendFunc
= state
->blendFunc
;
96 strokeAlpha
= state
->strokeAlpha
;
97 fillAlpha
= state
->fillAlpha
;
98 lineWidth
= state
->lineWidth
;
99 lineCap
= state
->lineCap
;
100 lineJoin
= state
->lineJoin
;
101 miterLimit
= state
->miterLimit
;
102 flatness
= state
->flatness
;
103 if (state
->lineDash
) {
104 lineDashLength
= state
->lineDashLength
;
105 lineDash
= (SplashCoord
*)gmallocn(lineDashLength
, sizeof(SplashCoord
));
106 memcpy(lineDash
, state
->lineDash
, lineDashLength
* sizeof(SplashCoord
));
111 lineDashPhase
= state
->lineDashPhase
;
112 strokeAdjust
= state
->strokeAdjust
;
113 clip
= state
->clip
->copy();
114 softMask
= state
->softMask
;
115 deleteSoftMask
= gFalse
;
116 inNonIsolatedGroup
= state
->inNonIsolatedGroup
;
120 SplashState::~SplashState() {
121 delete strokePattern
;
126 if (deleteSoftMask
&& softMask
) {
131 void SplashState::setStrokePattern(SplashPattern
*strokePatternA
) {
132 delete strokePattern
;
133 strokePattern
= strokePatternA
;
136 void SplashState::setFillPattern(SplashPattern
*fillPatternA
) {
138 fillPattern
= fillPatternA
;
141 void SplashState::setScreen(SplashScreen
*screenA
) {
146 void SplashState::setLineDash(SplashCoord
*lineDashA
, int lineDashLengthA
,
147 SplashCoord lineDashPhaseA
) {
149 lineDashLength
= lineDashLengthA
;
150 if (lineDashLength
> 0) {
151 lineDash
= (SplashCoord
*)gmallocn(lineDashLength
, sizeof(SplashCoord
));
152 memcpy(lineDash
, lineDashA
, lineDashLength
* sizeof(SplashCoord
));
156 lineDashPhase
= lineDashPhaseA
;
159 void SplashState::setSoftMask(SplashBitmap
*softMaskA
) {
160 if (deleteSoftMask
) {
163 softMask
= softMaskA
;
164 deleteSoftMask
= gTrue
;