1 //========================================================================
5 //========================================================================
7 //========================================================================
9 // Modified under the Poppler project - http://poppler.freedesktop.org
11 // All changes made under the Poppler project to this file are licensed
12 // under GPL version 2 or later
14 // Copyright (C) 2009, 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
16 // To see a description of the changes please see the Changelog file that
17 // came with your tarball or type make ChangeLog if you are building from git
19 //========================================================================
23 #ifdef USE_GCC_PRAGMAS
24 #pragma implementation
29 #include "SplashPattern.h"
30 #include "SplashScreen.h"
31 #include "SplashClip.h"
32 #include "SplashBitmap.h"
33 #include "SplashState.h"
35 //------------------------------------------------------------------------
37 //------------------------------------------------------------------------
39 // number of components in each color mode
40 int splashColorModeNComps
[] = {
47 SplashState::SplashState(int width
, int height
, GBool vectorAntialias
,
48 SplashScreenParams
*screenParams
) {
52 matrix
[0] = 1; matrix
[1] = 0;
53 matrix
[2] = 0; matrix
[3] = 1;
54 matrix
[4] = 0; matrix
[5] = 0;
55 memset(&color
, 0, sizeof(SplashColor
));
56 strokePattern
= new SplashSolidColor(color
);
57 fillPattern
= new SplashSolidColor(color
);
58 screen
= new SplashScreen(screenParams
);
63 lineCap
= splashLineCapButt
;
64 lineJoin
= splashLineJoinMiter
;
70 strokeAdjust
= gFalse
;
71 clip
= new SplashClip(0, 0, width
- 0.001, height
- 0.001, vectorAntialias
);
73 deleteSoftMask
= gFalse
;
74 inNonIsolatedGroup
= gFalse
;
75 fillOverprint
= gFalse
;
76 strokeOverprint
= gFalse
;
78 for (i
= 0; i
< 256; ++i
) {
79 rgbTransferR
[i
] = (Guchar
)i
;
80 rgbTransferG
[i
] = (Guchar
)i
;
81 rgbTransferB
[i
] = (Guchar
)i
;
82 grayTransfer
[i
] = (Guchar
)i
;
84 cmykTransferC
[i
] = (Guchar
)i
;
85 cmykTransferM
[i
] = (Guchar
)i
;
86 cmykTransferY
[i
] = (Guchar
)i
;
87 cmykTransferK
[i
] = (Guchar
)i
;
88 for (int cp
= 0; cp
< SPOT_NCOMPS
+4; cp
++)
89 deviceNTransfer
[cp
][i
] = (Guchar
)i
;
92 overprintMask
= 0xffffffff;
93 overprintAdditive
= gFalse
;
97 SplashState::SplashState(int width
, int height
, GBool vectorAntialias
,
98 SplashScreen
*screenA
) {
102 matrix
[0] = 1; matrix
[1] = 0;
103 matrix
[2] = 0; matrix
[3] = 1;
104 matrix
[4] = 0; matrix
[5] = 0;
105 memset(&color
, 0, sizeof(SplashColor
));
106 strokePattern
= new SplashSolidColor(color
);
107 fillPattern
= new SplashSolidColor(color
);
108 screen
= screenA
->copy();
113 lineCap
= splashLineCapButt
;
114 lineJoin
= splashLineJoinMiter
;
120 strokeAdjust
= gFalse
;
121 clip
= new SplashClip(0, 0, width
- 0.001, height
- 0.001, vectorAntialias
);
123 deleteSoftMask
= gFalse
;
124 inNonIsolatedGroup
= gFalse
;
125 fillOverprint
= gFalse
;
126 strokeOverprint
= gFalse
;
128 for (i
= 0; i
< 256; ++i
) {
129 rgbTransferR
[i
] = (Guchar
)i
;
130 rgbTransferG
[i
] = (Guchar
)i
;
131 rgbTransferB
[i
] = (Guchar
)i
;
132 grayTransfer
[i
] = (Guchar
)i
;
134 cmykTransferC
[i
] = (Guchar
)i
;
135 cmykTransferM
[i
] = (Guchar
)i
;
136 cmykTransferY
[i
] = (Guchar
)i
;
137 cmykTransferK
[i
] = (Guchar
)i
;
138 for (int cp
= 0; cp
< SPOT_NCOMPS
+4; cp
++)
139 deviceNTransfer
[cp
][i
] = (Guchar
)i
;
142 overprintMask
= 0xffffffff;
143 overprintAdditive
= gFalse
;
147 SplashState::SplashState(SplashState
*state
) {
148 memcpy(matrix
, state
->matrix
, 6 * sizeof(SplashCoord
));
149 strokePattern
= state
->strokePattern
->copy();
150 fillPattern
= state
->fillPattern
->copy();
151 screen
= state
->screen
->copy();
152 blendFunc
= state
->blendFunc
;
153 strokeAlpha
= state
->strokeAlpha
;
154 fillAlpha
= state
->fillAlpha
;
155 lineWidth
= state
->lineWidth
;
156 lineCap
= state
->lineCap
;
157 lineJoin
= state
->lineJoin
;
158 miterLimit
= state
->miterLimit
;
159 flatness
= state
->flatness
;
160 if (state
->lineDash
) {
161 lineDashLength
= state
->lineDashLength
;
162 lineDash
= (SplashCoord
*)gmallocn(lineDashLength
, sizeof(SplashCoord
));
163 memcpy(lineDash
, state
->lineDash
, lineDashLength
* sizeof(SplashCoord
));
168 lineDashPhase
= state
->lineDashPhase
;
169 strokeAdjust
= state
->strokeAdjust
;
170 clip
= state
->clip
->copy();
171 softMask
= state
->softMask
;
172 deleteSoftMask
= gFalse
;
173 inNonIsolatedGroup
= state
->inNonIsolatedGroup
;
174 fillOverprint
= state
->fillOverprint
;
175 strokeOverprint
= state
->strokeOverprint
;
176 overprintMode
= state
->overprintMode
;
177 memcpy(rgbTransferR
, state
->rgbTransferR
, 256);
178 memcpy(rgbTransferG
, state
->rgbTransferG
, 256);
179 memcpy(rgbTransferB
, state
->rgbTransferB
, 256);
180 memcpy(grayTransfer
, state
->grayTransfer
, 256);
182 memcpy(cmykTransferC
, state
->cmykTransferC
, 256);
183 memcpy(cmykTransferM
, state
->cmykTransferM
, 256);
184 memcpy(cmykTransferY
, state
->cmykTransferY
, 256);
185 memcpy(cmykTransferK
, state
->cmykTransferK
, 256);
186 for (int cp
= 0; cp
< SPOT_NCOMPS
+4; cp
++)
187 memcpy(deviceNTransfer
[cp
], state
->deviceNTransfer
[cp
], 256);
189 overprintMask
= state
->overprintMask
;
190 overprintAdditive
= state
->overprintAdditive
;
194 SplashState::~SplashState() {
195 delete strokePattern
;
200 if (deleteSoftMask
&& softMask
) {
205 void SplashState::setStrokePattern(SplashPattern
*strokePatternA
) {
206 delete strokePattern
;
207 strokePattern
= strokePatternA
;
210 void SplashState::setFillPattern(SplashPattern
*fillPatternA
) {
212 fillPattern
= fillPatternA
;
215 void SplashState::setScreen(SplashScreen
*screenA
) {
220 void SplashState::setLineDash(SplashCoord
*lineDashA
, int lineDashLengthA
,
221 SplashCoord lineDashPhaseA
) {
223 lineDashLength
= lineDashLengthA
;
224 if (lineDashLength
> 0) {
225 lineDash
= (SplashCoord
*)gmallocn(lineDashLength
, sizeof(SplashCoord
));
226 memcpy(lineDash
, lineDashA
, lineDashLength
* sizeof(SplashCoord
));
230 lineDashPhase
= lineDashPhaseA
;
233 void SplashState::setSoftMask(SplashBitmap
*softMaskA
) {
234 if (deleteSoftMask
) {
237 softMask
= softMaskA
;
238 deleteSoftMask
= gTrue
;
241 void SplashState::setTransfer(Guchar
*red
, Guchar
*green
, Guchar
*blue
,
246 for (i
= 0; i
< 256; ++i
) {
247 cmykTransferC
[i
] = 255 - rgbTransferR
[255 - i
];
248 cmykTransferM
[i
] = 255 - rgbTransferG
[255 - i
];
249 cmykTransferY
[i
] = 255 - rgbTransferB
[255 - i
];
250 cmykTransferK
[i
] = 255 - grayTransfer
[255 - i
];
252 for (i
= 0; i
< 256; ++i
) {
253 deviceNTransfer
[0][i
] = 255 - rgbTransferR
[255 - i
];
254 deviceNTransfer
[1][i
] = 255 - rgbTransferG
[255 - i
];
255 deviceNTransfer
[2][i
] = 255 - rgbTransferB
[255 - i
];
256 deviceNTransfer
[3][i
] = 255 - grayTransfer
[255 - i
];
259 memcpy(rgbTransferR
, red
, 256);
260 memcpy(rgbTransferG
, green
, 256);
261 memcpy(rgbTransferB
, blue
, 256);
262 memcpy(grayTransfer
, gray
, 256);