/src/xpdf-4.06/xpdf/GfxState.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // GfxState.h |
4 | | // |
5 | | // Copyright 1996-2016 Glyph & Cog, LLC |
6 | | // |
7 | | //======================================================================== |
8 | | |
9 | | #ifndef GFXSTATE_H |
10 | | #define GFXSTATE_H |
11 | | |
12 | | #include <aconf.h> |
13 | | |
14 | | #include "gtypes.h" |
15 | | #include "Object.h" |
16 | | #include "Function.h" |
17 | | |
18 | | class Array; |
19 | | class GfxFont; |
20 | | class PDFRectangle; |
21 | | class GfxDeviceNColorSpace; |
22 | | class GfxSeparationColorSpace; |
23 | | class GfxShading; |
24 | | class GfxState; |
25 | | class LocalParams; |
26 | | |
27 | | //------------------------------------------------------------------------ |
28 | | // GfxBlendMode |
29 | | //------------------------------------------------------------------------ |
30 | | |
31 | | enum GfxBlendMode { |
32 | | gfxBlendNormal, |
33 | | gfxBlendMultiply, |
34 | | gfxBlendScreen, |
35 | | gfxBlendOverlay, |
36 | | gfxBlendDarken, |
37 | | gfxBlendLighten, |
38 | | gfxBlendColorDodge, |
39 | | gfxBlendColorBurn, |
40 | | gfxBlendHardLight, |
41 | | gfxBlendSoftLight, |
42 | | gfxBlendDifference, |
43 | | gfxBlendExclusion, |
44 | | gfxBlendHue, |
45 | | gfxBlendSaturation, |
46 | | gfxBlendColor, |
47 | | gfxBlendLuminosity |
48 | | }; |
49 | | |
50 | | //------------------------------------------------------------------------ |
51 | | // GfxRenderingIntent |
52 | | //------------------------------------------------------------------------ |
53 | | |
54 | | enum GfxRenderingIntent { |
55 | | gfxRenderingIntentAbsoluteColorimetric, |
56 | | gfxRenderingIntentRelativeColorimetric, |
57 | | gfxRenderingIntentSaturation, |
58 | | gfxRenderingIntentPerceptual |
59 | | }; |
60 | | |
61 | | #define gfxNumRenderingIntents 4 |
62 | | |
63 | | //------------------------------------------------------------------------ |
64 | | // GfxColorComp |
65 | | //------------------------------------------------------------------------ |
66 | | |
67 | | // 16.16 fixed point color component |
68 | | typedef int GfxColorComp; |
69 | | |
70 | 139M | #define gfxColorComp1 0x10000 |
71 | | |
72 | 99.5M | static inline GfxColorComp dblToCol(double x) { |
73 | 99.5M | return (GfxColorComp)(x * gfxColorComp1); |
74 | 99.5M | } Unexecuted instantiation: fuzz_pdfload.cc:dblToCol(double) Unexecuted instantiation: Page.cc:dblToCol(double) Unexecuted instantiation: Stream.cc:dblToCol(double) Unexecuted instantiation: AcroForm.cc:dblToCol(double) Unexecuted instantiation: Annot.cc:dblToCol(double) Line | Count | Source | 72 | 800k | static inline GfxColorComp dblToCol(double x) { | 73 | 800k | return (GfxColorComp)(x * gfxColorComp1); | 74 | 800k | } |
GfxState.cc:dblToCol(double) Line | Count | Source | 72 | 59.5M | static inline GfxColorComp dblToCol(double x) { | 73 | 59.5M | return (GfxColorComp)(x * gfxColorComp1); | 74 | 59.5M | } |
Unexecuted instantiation: SplashOutputDev.cc:dblToCol(double) Unexecuted instantiation: OutputDev.cc:dblToCol(double) ShadingImage.cc:dblToCol(double) Line | Count | Source | 72 | 39.2M | static inline GfxColorComp dblToCol(double x) { | 73 | 39.2M | return (GfxColorComp)(x * gfxColorComp1); | 74 | 39.2M | } |
Unexecuted instantiation: fuzz_JBIG2.cc:dblToCol(double) |
75 | | |
76 | 8.67M | static inline double colToDbl(GfxColorComp x) { |
77 | 8.67M | return (double)x / (double)gfxColorComp1; |
78 | 8.67M | } Unexecuted instantiation: fuzz_pdfload.cc:colToDbl(int) Unexecuted instantiation: Page.cc:colToDbl(int) Unexecuted instantiation: Stream.cc:colToDbl(int) Unexecuted instantiation: AcroForm.cc:colToDbl(int) Unexecuted instantiation: Annot.cc:colToDbl(int) Unexecuted instantiation: Gfx.cc:colToDbl(int) GfxState.cc:colToDbl(int) Line | Count | Source | 76 | 8.67M | static inline double colToDbl(GfxColorComp x) { | 77 | 8.67M | return (double)x / (double)gfxColorComp1; | 78 | 8.67M | } |
SplashOutputDev.cc:colToDbl(int) Line | Count | Source | 76 | 2.20k | static inline double colToDbl(GfxColorComp x) { | 77 | 2.20k | return (double)x / (double)gfxColorComp1; | 78 | 2.20k | } |
Unexecuted instantiation: OutputDev.cc:colToDbl(int) Unexecuted instantiation: ShadingImage.cc:colToDbl(int) Unexecuted instantiation: fuzz_JBIG2.cc:colToDbl(int) |
79 | | |
80 | 0 | static inline GfxColorComp byteToCol(Guchar x) { |
81 | | // (x / 255) << 16 = (0.0000000100000001... * x) << 16 |
82 | | // = ((x << 8) + (x) + (x >> 8) + ...) |
83 | | // = (x << 8) + (x) + (x >> 7) |
84 | | // [for rounding] |
85 | 0 | return (GfxColorComp)((x << 8) + x + (x >> 7)); |
86 | 0 | } Unexecuted instantiation: fuzz_pdfload.cc:byteToCol(unsigned char) Unexecuted instantiation: Page.cc:byteToCol(unsigned char) Unexecuted instantiation: Stream.cc:byteToCol(unsigned char) Unexecuted instantiation: AcroForm.cc:byteToCol(unsigned char) Unexecuted instantiation: Annot.cc:byteToCol(unsigned char) Unexecuted instantiation: Gfx.cc:byteToCol(unsigned char) Unexecuted instantiation: GfxState.cc:byteToCol(unsigned char) Unexecuted instantiation: SplashOutputDev.cc:byteToCol(unsigned char) Unexecuted instantiation: OutputDev.cc:byteToCol(unsigned char) Unexecuted instantiation: ShadingImage.cc:byteToCol(unsigned char) Unexecuted instantiation: fuzz_JBIG2.cc:byteToCol(unsigned char) |
87 | | |
88 | 0 | static inline GfxColorComp wordToCol(Gushort x) { |
89 | 0 | // (x / 65535) << 16 = (0.0000000000000001... * x) << 16 |
90 | 0 | // = x + (x >> 15) |
91 | 0 | // [for rounding] |
92 | 0 | return (GfxColorComp)(x + (x >> 15)); |
93 | 0 | } Unexecuted instantiation: fuzz_pdfload.cc:wordToCol(unsigned short) Unexecuted instantiation: Page.cc:wordToCol(unsigned short) Unexecuted instantiation: Stream.cc:wordToCol(unsigned short) Unexecuted instantiation: AcroForm.cc:wordToCol(unsigned short) Unexecuted instantiation: Annot.cc:wordToCol(unsigned short) Unexecuted instantiation: Gfx.cc:wordToCol(unsigned short) Unexecuted instantiation: GfxState.cc:wordToCol(unsigned short) Unexecuted instantiation: SplashOutputDev.cc:wordToCol(unsigned short) Unexecuted instantiation: OutputDev.cc:wordToCol(unsigned short) Unexecuted instantiation: ShadingImage.cc:wordToCol(unsigned short) Unexecuted instantiation: fuzz_JBIG2.cc:wordToCol(unsigned short) |
94 | | |
95 | 36.6M | static inline Guchar colToByte(GfxColorComp x) { |
96 | | // 255 * x + 0.5 = 256 * x - x + 0.5 |
97 | | // = [256 * (x << 16) - (x << 16) + (1 << 15)] >> 16 |
98 | 36.6M | return (Guchar)(((x << 8) - x + 0x8000) >> 16); |
99 | 36.6M | } Unexecuted instantiation: fuzz_pdfload.cc:colToByte(int) Unexecuted instantiation: Page.cc:colToByte(int) Unexecuted instantiation: Stream.cc:colToByte(int) Unexecuted instantiation: AcroForm.cc:colToByte(int) Unexecuted instantiation: Annot.cc:colToByte(int) Unexecuted instantiation: Gfx.cc:colToByte(int) GfxState.cc:colToByte(int) Line | Count | Source | 95 | 20.8M | static inline Guchar colToByte(GfxColorComp x) { | 96 | | // 255 * x + 0.5 = 256 * x - x + 0.5 | 97 | | // = [256 * (x << 16) - (x << 16) + (1 << 15)] >> 16 | 98 | 20.8M | return (Guchar)(((x << 8) - x + 0x8000) >> 16); | 99 | 20.8M | } |
SplashOutputDev.cc:colToByte(int) Line | Count | Source | 95 | 9.15M | static inline Guchar colToByte(GfxColorComp x) { | 96 | | // 255 * x + 0.5 = 256 * x - x + 0.5 | 97 | | // = [256 * (x << 16) - (x << 16) + (1 << 15)] >> 16 | 98 | 9.15M | return (Guchar)(((x << 8) - x + 0x8000) >> 16); | 99 | 9.15M | } |
Unexecuted instantiation: OutputDev.cc:colToByte(int) ShadingImage.cc:colToByte(int) Line | Count | Source | 95 | 6.67M | static inline Guchar colToByte(GfxColorComp x) { | 96 | | // 255 * x + 0.5 = 256 * x - x + 0.5 | 97 | | // = [256 * (x << 16) - (x << 16) + (1 << 15)] >> 16 | 98 | 6.67M | return (Guchar)(((x << 8) - x + 0x8000) >> 16); | 99 | 6.67M | } |
Unexecuted instantiation: fuzz_JBIG2.cc:colToByte(int) |
100 | | |
101 | 0 | static inline Gushort colToWord(GfxColorComp x) { |
102 | 0 | // 65535 * x + 0.5 = 65536 * x - x + 0.5 |
103 | 0 | // = [65536 * (x << 16) - (x << 16) + (1 << 15)] >> 16 |
104 | 0 | return (Gushort)(((x << 16) - x + 0x8000) >> 16); |
105 | 0 | } Unexecuted instantiation: fuzz_pdfload.cc:colToWord(int) Unexecuted instantiation: Page.cc:colToWord(int) Unexecuted instantiation: Stream.cc:colToWord(int) Unexecuted instantiation: AcroForm.cc:colToWord(int) Unexecuted instantiation: Annot.cc:colToWord(int) Unexecuted instantiation: Gfx.cc:colToWord(int) Unexecuted instantiation: GfxState.cc:colToWord(int) Unexecuted instantiation: SplashOutputDev.cc:colToWord(int) Unexecuted instantiation: OutputDev.cc:colToWord(int) Unexecuted instantiation: ShadingImage.cc:colToWord(int) Unexecuted instantiation: fuzz_JBIG2.cc:colToWord(int) |
106 | | |
107 | | //------------------------------------------------------------------------ |
108 | | // GfxColor |
109 | | //------------------------------------------------------------------------ |
110 | | |
111 | 2.61M | #define gfxColorMaxComps funcMaxOutputs |
112 | | |
113 | | struct GfxColor { |
114 | | GfxColorComp c[gfxColorMaxComps]; |
115 | | }; |
116 | | |
117 | | //------------------------------------------------------------------------ |
118 | | // GfxGray |
119 | | //------------------------------------------------------------------------ |
120 | | |
121 | | typedef GfxColorComp GfxGray; |
122 | | |
123 | | //------------------------------------------------------------------------ |
124 | | // GfxRGB |
125 | | //------------------------------------------------------------------------ |
126 | | |
127 | | struct GfxRGB { |
128 | | GfxColorComp r, g, b; |
129 | | }; |
130 | | |
131 | | //------------------------------------------------------------------------ |
132 | | // GfxCMYK |
133 | | //------------------------------------------------------------------------ |
134 | | |
135 | | struct GfxCMYK { |
136 | | GfxColorComp c, m, y, k; |
137 | | }; |
138 | | |
139 | | |
140 | | |
141 | | |
142 | | |
143 | | //------------------------------------------------------------------------ |
144 | | // GfxColorSpace |
145 | | //------------------------------------------------------------------------ |
146 | | |
147 | | // NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames |
148 | | // array defined in GfxState.cc must match this enum. |
149 | | enum GfxColorSpaceMode { |
150 | | csDeviceGray, |
151 | | csCalGray, |
152 | | csDeviceRGB, |
153 | | csCalRGB, |
154 | | csDeviceCMYK, |
155 | | csLab, |
156 | | csICCBased, |
157 | | csIndexed, |
158 | | csSeparation, |
159 | | csDeviceN, |
160 | | csPattern |
161 | | }; |
162 | | |
163 | | class GfxColorSpace { |
164 | | public: |
165 | | |
166 | | GfxColorSpace(); |
167 | | virtual ~GfxColorSpace(); |
168 | | virtual GfxColorSpace *copy() = 0; |
169 | | virtual GfxColorSpaceMode getMode() = 0; |
170 | | |
171 | | // Construct a color space. Returns NULL if unsuccessful. |
172 | | static GfxColorSpace *parse(Object *csObj, |
173 | | int recursion = 0); |
174 | | |
175 | | // Construct a simple color space. The <mode> argument can be |
176 | | // csDeviceGray, csDeviceRGB, or csDeviceCMYK. |
177 | | static GfxColorSpace *create(GfxColorSpaceMode mode); |
178 | | |
179 | | |
180 | | // Convert to gray, RGB, or CMYK. |
181 | | virtual void getGray(GfxColor *color, GfxGray *gray, |
182 | | GfxRenderingIntent ri) = 0; |
183 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, |
184 | | GfxRenderingIntent ri) = 0; |
185 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, |
186 | | GfxRenderingIntent ri) = 0; |
187 | | |
188 | | // Return the number of color components. |
189 | | virtual int getNComps() = 0; |
190 | | |
191 | | // Get this color space's default color. |
192 | | virtual void getDefaultColor(GfxColor *color) = 0; |
193 | | |
194 | | // Return the default ranges for each component, assuming an image |
195 | | // with a max pixel value of <maxImgPixel>. |
196 | | virtual void getDefaultRanges(double *decodeLow, double *decodeRange, |
197 | | int maxImgPixel); |
198 | | |
199 | | // Returns true if painting operations in this color space never |
200 | | // mark the page (e.g., the "None" colorant). |
201 | 4.61M | virtual GBool isNonMarking() { return gFalse; } |
202 | | |
203 | | |
204 | | // Return the color space's overprint mask. |
205 | 2.61k | Guint getOverprintMask() { return overprintMask; } |
206 | | |
207 | | // Return true if this color space object is the result of |
208 | | // substituting a DefaultGray/RGB/CMYK color space for |
209 | | // DeviceGray/RGB/CMYK. |
210 | 6.27k | GBool isDefaultColorSpace() { return defaultColorSpace; } |
211 | | |
212 | | // Return the number of color space modes |
213 | | static int getNumColorSpaceModes(); |
214 | | |
215 | | // Return the name of the <idx>th color space mode. |
216 | | static const char *getColorSpaceModeName(int idx); |
217 | | |
218 | | protected: |
219 | | |
220 | | Guint overprintMask; |
221 | | GBool defaultColorSpace; |
222 | | }; |
223 | | |
224 | | //------------------------------------------------------------------------ |
225 | | // GfxDeviceGrayColorSpace |
226 | | //------------------------------------------------------------------------ |
227 | | |
228 | | class GfxDeviceGrayColorSpace: public GfxColorSpace { |
229 | | public: |
230 | | |
231 | | GfxDeviceGrayColorSpace(); |
232 | | virtual ~GfxDeviceGrayColorSpace(); |
233 | | virtual GfxColorSpace *copy(); |
234 | 616k | virtual GfxColorSpaceMode getMode() { return csDeviceGray; } |
235 | | |
236 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
237 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
238 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
239 | | |
240 | 86.1k | virtual int getNComps() { return 1; } |
241 | | virtual void getDefaultColor(GfxColor *color); |
242 | | |
243 | | private: |
244 | | }; |
245 | | |
246 | | //------------------------------------------------------------------------ |
247 | | // GfxCalGrayColorSpace |
248 | | //------------------------------------------------------------------------ |
249 | | |
250 | | class GfxCalGrayColorSpace: public GfxColorSpace { |
251 | | public: |
252 | | |
253 | | GfxCalGrayColorSpace(); |
254 | | virtual ~GfxCalGrayColorSpace(); |
255 | | virtual GfxColorSpace *copy(); |
256 | 398 | virtual GfxColorSpaceMode getMode() { return csCalGray; } |
257 | | |
258 | | // Construct a CalGray color space. Returns NULL if unsuccessful. |
259 | | static GfxColorSpace *parse(Array *arr, int recursion); |
260 | | |
261 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
262 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
263 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
264 | | |
265 | 391 | virtual int getNComps() { return 1; } |
266 | | virtual void getDefaultColor(GfxColor *color); |
267 | | |
268 | | // CalGray-specific access. |
269 | 0 | double getWhiteX() { return whiteX; } |
270 | 0 | double getWhiteY() { return whiteY; } |
271 | 0 | double getWhiteZ() { return whiteZ; } |
272 | 0 | double getBlackX() { return blackX; } |
273 | 0 | double getBlackY() { return blackY; } |
274 | 0 | double getBlackZ() { return blackZ; } |
275 | 0 | double getGamma() { return gamma; } |
276 | | |
277 | | private: |
278 | | |
279 | | double whiteX, whiteY, whiteZ; // white point |
280 | | double blackX, blackY, blackZ; // black point |
281 | | double gamma; // gamma value |
282 | | }; |
283 | | |
284 | | //------------------------------------------------------------------------ |
285 | | // GfxDeviceRGBColorSpace |
286 | | //------------------------------------------------------------------------ |
287 | | |
288 | | class GfxDeviceRGBColorSpace: public GfxColorSpace { |
289 | | public: |
290 | | |
291 | | GfxDeviceRGBColorSpace(); |
292 | | virtual ~GfxDeviceRGBColorSpace(); |
293 | | virtual GfxColorSpace *copy(); |
294 | 307k | virtual GfxColorSpaceMode getMode() { return csDeviceRGB; } |
295 | | |
296 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
297 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
298 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
299 | | |
300 | 409k | virtual int getNComps() { return 3; } |
301 | | virtual void getDefaultColor(GfxColor *color); |
302 | | |
303 | | private: |
304 | | }; |
305 | | |
306 | | //------------------------------------------------------------------------ |
307 | | // GfxCalRGBColorSpace |
308 | | //------------------------------------------------------------------------ |
309 | | |
310 | | class GfxCalRGBColorSpace: public GfxColorSpace { |
311 | | public: |
312 | | |
313 | | GfxCalRGBColorSpace(); |
314 | | virtual ~GfxCalRGBColorSpace(); |
315 | | virtual GfxColorSpace *copy(); |
316 | 1.07k | virtual GfxColorSpaceMode getMode() { return csCalRGB; } |
317 | | |
318 | | // Construct a CalRGB color space. Returns NULL if unsuccessful. |
319 | | static GfxColorSpace *parse(Array *arr, int recursion); |
320 | | |
321 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
322 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
323 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
324 | | |
325 | 156 | virtual int getNComps() { return 3; } |
326 | | virtual void getDefaultColor(GfxColor *color); |
327 | | |
328 | | // CalRGB-specific access. |
329 | 0 | double getWhiteX() { return whiteX; } |
330 | 0 | double getWhiteY() { return whiteY; } |
331 | 0 | double getWhiteZ() { return whiteZ; } |
332 | 0 | double getBlackX() { return blackX; } |
333 | 0 | double getBlackY() { return blackY; } |
334 | 0 | double getBlackZ() { return blackZ; } |
335 | 0 | double getGammaR() { return gammaR; } |
336 | 0 | double getGammaG() { return gammaG; } |
337 | 0 | double getGammaB() { return gammaB; } |
338 | 0 | double *getMatrix() { return mat; } |
339 | | |
340 | | private: |
341 | | |
342 | | double whiteX, whiteY, whiteZ; // white point |
343 | | double blackX, blackY, blackZ; // black point |
344 | | double gammaR, gammaG, gammaB; // gamma values |
345 | | double mat[9]; // ABC -> XYZ transform matrix |
346 | | }; |
347 | | |
348 | | //------------------------------------------------------------------------ |
349 | | // GfxDeviceCMYKColorSpace |
350 | | //------------------------------------------------------------------------ |
351 | | |
352 | | class GfxDeviceCMYKColorSpace: public GfxColorSpace { |
353 | | public: |
354 | | |
355 | | GfxDeviceCMYKColorSpace(); |
356 | | virtual ~GfxDeviceCMYKColorSpace(); |
357 | | virtual GfxColorSpace *copy(); |
358 | 38.1k | virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; } |
359 | | |
360 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
361 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
362 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
363 | | |
364 | 2.84M | virtual int getNComps() { return 4; } |
365 | | virtual void getDefaultColor(GfxColor *color); |
366 | | |
367 | | |
368 | | private: |
369 | | }; |
370 | | |
371 | | //------------------------------------------------------------------------ |
372 | | // GfxLabColorSpace |
373 | | //------------------------------------------------------------------------ |
374 | | |
375 | | class GfxLabColorSpace: public GfxColorSpace { |
376 | | public: |
377 | | |
378 | | GfxLabColorSpace(); |
379 | | virtual ~GfxLabColorSpace(); |
380 | | virtual GfxColorSpace *copy(); |
381 | 710 | virtual GfxColorSpaceMode getMode() { return csLab; } |
382 | | |
383 | | // Construct a Lab color space. Returns NULL if unsuccessful. |
384 | | static GfxColorSpace *parse(Array *arr, int recursion); |
385 | | |
386 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
387 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
388 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
389 | | |
390 | 1.89k | virtual int getNComps() { return 3; } |
391 | | virtual void getDefaultColor(GfxColor *color); |
392 | | |
393 | | virtual void getDefaultRanges(double *decodeLow, double *decodeRange, |
394 | | int maxImgPixel); |
395 | | |
396 | | // Lab-specific access. |
397 | 0 | double getWhiteX() { return whiteX; } |
398 | 0 | double getWhiteY() { return whiteY; } |
399 | 0 | double getWhiteZ() { return whiteZ; } |
400 | 0 | double getBlackX() { return blackX; } |
401 | 0 | double getBlackY() { return blackY; } |
402 | 0 | double getBlackZ() { return blackZ; } |
403 | 0 | double getAMin() { return aMin; } |
404 | 0 | double getAMax() { return aMax; } |
405 | 0 | double getBMin() { return bMin; } |
406 | 0 | double getBMax() { return bMax; } |
407 | | |
408 | | private: |
409 | | |
410 | | double whiteX, whiteY, whiteZ; // white point |
411 | | double blackX, blackY, blackZ; // black point |
412 | | double aMin, aMax, bMin, bMax; // range for the a and b components |
413 | | double kr, kg, kb; // gamut mapping mulitpliers |
414 | | }; |
415 | | |
416 | | //------------------------------------------------------------------------ |
417 | | // GfxICCBasedColorSpace |
418 | | //------------------------------------------------------------------------ |
419 | | |
420 | | class GfxICCBasedColorSpace: public GfxColorSpace { |
421 | | public: |
422 | | |
423 | | GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA, |
424 | | Ref *iccProfileStreamA); |
425 | | virtual ~GfxICCBasedColorSpace(); |
426 | | virtual GfxColorSpace *copy(); |
427 | 6.81k | virtual GfxColorSpaceMode getMode() { return csICCBased; } |
428 | | |
429 | | // Construct an ICCBased color space. Returns NULL if unsuccessful. |
430 | | static GfxColorSpace *parse(Array *arr, |
431 | | int recursion); |
432 | | |
433 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
434 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
435 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
436 | | |
437 | 10.0k | virtual int getNComps() { return nComps; } |
438 | | virtual void getDefaultColor(GfxColor *color); |
439 | | |
440 | | virtual void getDefaultRanges(double *decodeLow, double *decodeRange, |
441 | | int maxImgPixel); |
442 | | |
443 | | |
444 | | // ICCBased-specific access. |
445 | 0 | GfxColorSpace *getAlt() { return alt; } |
446 | 0 | Ref getICCProfileStreamRef() { return iccProfileStream; } |
447 | | |
448 | | private: |
449 | | |
450 | | int nComps; // number of color components (1, 3, or 4) |
451 | | GfxColorSpace *alt; // alternate color space |
452 | | double rangeMin[4]; // min values for each component |
453 | | double rangeMax[4]; // max values for each component |
454 | | Ref iccProfileStream; // the ICC profile |
455 | | }; |
456 | | |
457 | | //------------------------------------------------------------------------ |
458 | | // GfxIndexedColorSpace |
459 | | //------------------------------------------------------------------------ |
460 | | |
461 | | class GfxIndexedColorSpace: public GfxColorSpace { |
462 | | public: |
463 | | |
464 | | GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA); |
465 | | virtual ~GfxIndexedColorSpace(); |
466 | | virtual GfxColorSpace *copy(); |
467 | 4.48k | virtual GfxColorSpaceMode getMode() { return csIndexed; } |
468 | | |
469 | | // Construct an Indexed color space. Returns NULL if unsuccessful. |
470 | | static GfxColorSpace *parse(Array *arr, |
471 | | int recursion); |
472 | | |
473 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
474 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
475 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
476 | | |
477 | 2.43k | virtual int getNComps() { return 1; } |
478 | | virtual void getDefaultColor(GfxColor *color); |
479 | | |
480 | | virtual void getDefaultRanges(double *decodeLow, double *decodeRange, |
481 | | int maxImgPixel); |
482 | | |
483 | | // Indexed-specific access. |
484 | 2.20k | GfxColorSpace *getBase() { return base; } |
485 | 2.20k | int getIndexHigh() { return indexHigh; } |
486 | 2.20k | Guchar *getLookup() { return lookup; } |
487 | | GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor); |
488 | | |
489 | | private: |
490 | | |
491 | | GfxColorSpace *base; // base color space |
492 | | int indexHigh; // max pixel value |
493 | | Guchar *lookup; // lookup table |
494 | | }; |
495 | | |
496 | | //------------------------------------------------------------------------ |
497 | | // GfxSeparationColorSpace |
498 | | //------------------------------------------------------------------------ |
499 | | |
500 | | class GfxSeparationColorSpace: public GfxColorSpace { |
501 | | public: |
502 | | |
503 | | GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA, |
504 | | Function *funcA); |
505 | | virtual ~GfxSeparationColorSpace(); |
506 | | virtual GfxColorSpace *copy(); |
507 | 128k | virtual GfxColorSpaceMode getMode() { return csSeparation; } |
508 | | |
509 | | // Construct a Separation color space. Returns NULL if unsuccessful. |
510 | | static GfxColorSpace *parse(Array *arr, |
511 | | int recursion); |
512 | | |
513 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
514 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
515 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
516 | | |
517 | 1.63k | virtual int getNComps() { return 1; } |
518 | | virtual void getDefaultColor(GfxColor *color); |
519 | | |
520 | 386k | virtual GBool isNonMarking() { return nonMarking; } |
521 | | |
522 | | // Separation-specific access. |
523 | 0 | GString *getName() { return name; } |
524 | 45 | GfxColorSpace *getAlt() { return alt; } |
525 | 45 | Function *getFunc() { return func; } |
526 | | |
527 | | private: |
528 | | |
529 | | GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA, |
530 | | Function *funcA, GBool nonMarkingA, |
531 | | Guint overprintMaskA); |
532 | | |
533 | | GString *name; // colorant name |
534 | | GfxColorSpace *alt; // alternate color space |
535 | | Function *func; // tint transform (into alternate color space) |
536 | | GBool nonMarking; |
537 | | }; |
538 | | |
539 | | //------------------------------------------------------------------------ |
540 | | // GfxDeviceNColorSpace |
541 | | //------------------------------------------------------------------------ |
542 | | |
543 | | class GfxDeviceNColorSpace: public GfxColorSpace { |
544 | | public: |
545 | | |
546 | | GfxDeviceNColorSpace(int nCompsA, GString **namesA, |
547 | | GfxColorSpace *alt, Function *func, |
548 | | Object *attrsA); |
549 | | virtual ~GfxDeviceNColorSpace(); |
550 | | virtual GfxColorSpace *copy(); |
551 | 43 | virtual GfxColorSpaceMode getMode() { return csDeviceN; } |
552 | | |
553 | | // Construct a DeviceN color space. Returns NULL if unsuccessful. |
554 | | static GfxColorSpace *parse(Array *arr, |
555 | | int recursion); |
556 | | |
557 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
558 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
559 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
560 | | |
561 | 175 | virtual int getNComps() { return nComps; } |
562 | | virtual void getDefaultColor(GfxColor *color); |
563 | | |
564 | 13 | virtual GBool isNonMarking() { return nonMarking; } |
565 | | |
566 | | // DeviceN-specific access. |
567 | 0 | GString *getColorantName(int i) { return names[i]; } |
568 | 0 | GfxColorSpace *getAlt() { return alt; } |
569 | 0 | Function *getTintTransformFunc() { return func; } |
570 | 0 | Object *getAttrs() { return &attrs; } |
571 | | |
572 | | private: |
573 | | |
574 | | GfxDeviceNColorSpace(int nCompsA, GString **namesA, |
575 | | GfxColorSpace *alt, Function *func, |
576 | | Object *attrsA, |
577 | | GBool nonMarkingA, Guint overprintMaskA); |
578 | | |
579 | | int nComps; // number of components |
580 | | GString // colorant names |
581 | | *names[gfxColorMaxComps]; |
582 | | GfxColorSpace *alt; // alternate color space |
583 | | Function *func; // tint transform (into alternate color space) |
584 | | Object attrs; |
585 | | GBool nonMarking; |
586 | | }; |
587 | | |
588 | | //------------------------------------------------------------------------ |
589 | | // GfxPatternColorSpace |
590 | | //------------------------------------------------------------------------ |
591 | | |
592 | | class GfxPatternColorSpace: public GfxColorSpace { |
593 | | public: |
594 | | |
595 | | GfxPatternColorSpace(GfxColorSpace *underA); |
596 | | virtual ~GfxPatternColorSpace(); |
597 | | virtual GfxColorSpace *copy(); |
598 | 361k | virtual GfxColorSpaceMode getMode() { return csPattern; } |
599 | | |
600 | | // Construct a Pattern color space. Returns NULL if unsuccessful. |
601 | | static GfxColorSpace *parse(Array *arr, |
602 | | int recursion); |
603 | | |
604 | | virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri); |
605 | | virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri); |
606 | | virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri); |
607 | | |
608 | 12.7k | virtual int getNComps() { return 0; } |
609 | | virtual void getDefaultColor(GfxColor *color); |
610 | | |
611 | | // Pattern-specific access. |
612 | 1.63k | GfxColorSpace *getUnder() { return under; } |
613 | | |
614 | | private: |
615 | | |
616 | | GfxColorSpace *under; // underlying color space (for uncolored |
617 | | // patterns) |
618 | | }; |
619 | | |
620 | | //------------------------------------------------------------------------ |
621 | | // GfxPattern |
622 | | //------------------------------------------------------------------------ |
623 | | |
624 | | class GfxPattern { |
625 | | public: |
626 | | |
627 | | GfxPattern(int typeA); |
628 | | virtual ~GfxPattern(); |
629 | | |
630 | | static GfxPattern *parse(Object *objRef, Object *obj |
631 | | ); |
632 | | |
633 | | virtual GfxPattern *copy() = 0; |
634 | | |
635 | 65.3k | int getType() { return type; } |
636 | | |
637 | | private: |
638 | | |
639 | | int type; |
640 | | }; |
641 | | |
642 | | //------------------------------------------------------------------------ |
643 | | // GfxTilingPattern |
644 | | //------------------------------------------------------------------------ |
645 | | |
646 | | class GfxTilingPattern: public GfxPattern { |
647 | | public: |
648 | | |
649 | | static GfxTilingPattern *parse(Object *patObjRef, Object *patObj); |
650 | | virtual ~GfxTilingPattern(); |
651 | | |
652 | | virtual GfxPattern *copy(); |
653 | | |
654 | 41.9k | int getPaintType() { return paintType; } |
655 | 778 | int getTilingType() { return tilingType; } |
656 | 3.24k | double *getBBox() { return bbox; } |
657 | 811 | double getXStep() { return xStep; } |
658 | 811 | double getYStep() { return yStep; } |
659 | | Dict *getResDict() |
660 | 778 | { return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; } |
661 | 64.9k | double *getMatrix() { return matrix; } |
662 | 778 | Object *getContentStreamRef() { return &contentStreamRef; } |
663 | | GBool usesBlendMode(XRef *xref); |
664 | | |
665 | | private: |
666 | | |
667 | | GfxTilingPattern(int paintTypeA, int tilingTypeA, |
668 | | double *bboxA, double xStepA, double yStepA, |
669 | | Object *resDictA, double *matrixA, |
670 | | Object *contentStreamA); |
671 | | GBool scanResourcesForBlendMode(Object *resDict2, |
672 | | char *scannedObjs, XRef *xref); |
673 | | GBool scanExtGStateForBlendMode(Object *gsObj, |
674 | | char *scannedObjs, XRef *xref); |
675 | | GBool scanSoftMaskForBlendMode(Object *softMaskObj, |
676 | | char *scannedObjs, XRef *xref); |
677 | | GBool scanPatternForBlendMode(Object *patternObj, |
678 | | char *scannedObjs, XRef *xref); |
679 | | GBool scanXObjectForBlendMode(Object *xObj, |
680 | | char *scannedObjs, XRef *xref); |
681 | | |
682 | | int paintType; |
683 | | int tilingType; |
684 | | double bbox[4]; |
685 | | double xStep, yStep; |
686 | | Object resDict; |
687 | | double matrix[6]; |
688 | | Object contentStreamRef; |
689 | | }; |
690 | | |
691 | | //------------------------------------------------------------------------ |
692 | | // GfxShadingPattern |
693 | | //------------------------------------------------------------------------ |
694 | | |
695 | | class GfxShadingPattern: public GfxPattern { |
696 | | public: |
697 | | |
698 | | static GfxShadingPattern *parse(Object *patObj |
699 | | ); |
700 | | virtual ~GfxShadingPattern(); |
701 | | |
702 | | virtual GfxPattern *copy(); |
703 | | |
704 | 349 | GfxShading *getShading() { return shading; } |
705 | 349 | double *getMatrix() { return matrix; } |
706 | | |
707 | | private: |
708 | | |
709 | | GfxShadingPattern(GfxShading *shadingA, double *matrixA); |
710 | | |
711 | | GfxShading *shading; |
712 | | double matrix[6]; |
713 | | }; |
714 | | |
715 | | //------------------------------------------------------------------------ |
716 | | // GfxShading |
717 | | //------------------------------------------------------------------------ |
718 | | |
719 | | class GfxShading { |
720 | | public: |
721 | | |
722 | | GfxShading(int typeA); |
723 | | GfxShading(GfxShading *shading); |
724 | | virtual ~GfxShading(); |
725 | | |
726 | | static GfxShading *parse(Object *obj |
727 | | ); |
728 | | |
729 | | virtual GfxShading *copy() = 0; |
730 | | |
731 | 2.58k | int getType() { return type; } |
732 | 2.84M | GfxColorSpace *getColorSpace() { return colorSpace; } |
733 | 23 | GfxColor *getBackground() { return &background; } |
734 | 339 | GBool getHasBackground() { return hasBackground; } |
735 | | void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) |
736 | 1 | { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } |
737 | 2.58k | GBool getHasBBox() { return hasBBox; } |
738 | | |
739 | | protected: |
740 | | |
741 | | GBool init(Dict *dict |
742 | | ); |
743 | | |
744 | | int type; |
745 | | GfxColorSpace *colorSpace; |
746 | | GfxColor background; |
747 | | GBool hasBackground; |
748 | | double xMin, yMin, xMax, yMax; |
749 | | GBool hasBBox; |
750 | | }; |
751 | | |
752 | | //------------------------------------------------------------------------ |
753 | | // GfxFunctionShading |
754 | | //------------------------------------------------------------------------ |
755 | | |
756 | | class GfxFunctionShading: public GfxShading { |
757 | | public: |
758 | | |
759 | | GfxFunctionShading(double x0A, double y0A, |
760 | | double x1A, double y1A, |
761 | | double *matrixA, |
762 | | Function **funcsA, int nFuncsA); |
763 | | GfxFunctionShading(GfxFunctionShading *shading); |
764 | | virtual ~GfxFunctionShading(); |
765 | | |
766 | | static GfxFunctionShading *parse(Dict *dict |
767 | | ); |
768 | | |
769 | | virtual GfxShading *copy(); |
770 | | |
771 | | void getDomain(double *x0A, double *y0A, double *x1A, double *y1A) |
772 | 0 | { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; } |
773 | 0 | double *getMatrix() { return matrix; } |
774 | 0 | int getNFuncs() { return nFuncs; } |
775 | 0 | Function *getFunc(int i) { return funcs[i]; } |
776 | | void getColor(double x, double y, GfxColor *color); |
777 | | |
778 | | private: |
779 | | |
780 | | double x0, y0, x1, y1; |
781 | | double matrix[6]; |
782 | | Function *funcs[gfxColorMaxComps]; |
783 | | int nFuncs; |
784 | | }; |
785 | | |
786 | | //------------------------------------------------------------------------ |
787 | | // GfxAxialShading |
788 | | //------------------------------------------------------------------------ |
789 | | |
790 | | class GfxAxialShading: public GfxShading { |
791 | | public: |
792 | | |
793 | | GfxAxialShading(double x0A, double y0A, |
794 | | double x1A, double y1A, |
795 | | double t0A, double t1A, |
796 | | Function **funcsA, int nFuncsA, |
797 | | GBool extend0A, GBool extend1A); |
798 | | GfxAxialShading(GfxAxialShading *shading); |
799 | | virtual ~GfxAxialShading(); |
800 | | |
801 | | static GfxAxialShading *parse(Dict *dict |
802 | | ); |
803 | | |
804 | | virtual GfxShading *copy(); |
805 | | |
806 | | void getCoords(double *x0A, double *y0A, double *x1A, double *y1A) |
807 | 1.83k | { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; } |
808 | 1.83k | double getDomain0() { return t0; } |
809 | 1.83k | double getDomain1() { return t1; } |
810 | 1.83k | GBool getExtend0() { return extend0; } |
811 | 1.83k | GBool getExtend1() { return extend1; } |
812 | 0 | int getNFuncs() { return nFuncs; } |
813 | 0 | Function *getFunc(int i) { return funcs[i]; } |
814 | | void getColor(double t, GfxColor *color); |
815 | | |
816 | | private: |
817 | | |
818 | | double x0, y0, x1, y1; |
819 | | double t0, t1; |
820 | | Function *funcs[gfxColorMaxComps]; |
821 | | int nFuncs; |
822 | | GBool extend0, extend1; |
823 | | }; |
824 | | |
825 | | //------------------------------------------------------------------------ |
826 | | // GfxRadialShading |
827 | | //------------------------------------------------------------------------ |
828 | | |
829 | | class GfxRadialShading: public GfxShading { |
830 | | public: |
831 | | |
832 | | GfxRadialShading(double x0A, double y0A, double r0A, |
833 | | double x1A, double y1A, double r1A, |
834 | | double t0A, double t1A, |
835 | | Function **funcsA, int nFuncsA, |
836 | | GBool extend0A, GBool extend1A); |
837 | | GfxRadialShading(GfxRadialShading *shading); |
838 | | virtual ~GfxRadialShading(); |
839 | | |
840 | | static GfxRadialShading *parse(Dict *dict |
841 | | ); |
842 | | |
843 | | virtual GfxShading *copy(); |
844 | | |
845 | | void getCoords(double *x0A, double *y0A, double *r0A, |
846 | | double *x1A, double *y1A, double *r1A) |
847 | 16 | { *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; } |
848 | 16 | double getDomain0() { return t0; } |
849 | 16 | double getDomain1() { return t1; } |
850 | 16 | GBool getExtend0() { return extend0; } |
851 | 16 | GBool getExtend1() { return extend1; } |
852 | 0 | int getNFuncs() { return nFuncs; } |
853 | 0 | Function *getFunc(int i) { return funcs[i]; } |
854 | | void getColor(double t, GfxColor *color); |
855 | | |
856 | | private: |
857 | | |
858 | | double x0, y0, r0, x1, y1, r1; |
859 | | double t0, t1; |
860 | | Function *funcs[gfxColorMaxComps]; |
861 | | int nFuncs; |
862 | | GBool extend0, extend1; |
863 | | }; |
864 | | |
865 | | //------------------------------------------------------------------------ |
866 | | // GfxGouraudTriangleShading |
867 | | //------------------------------------------------------------------------ |
868 | | |
869 | | struct GfxGouraudVertex { |
870 | | double x, y; |
871 | | double color[gfxColorMaxComps]; |
872 | | }; |
873 | | |
874 | | class GfxGouraudTriangleShading: public GfxShading { |
875 | | public: |
876 | | |
877 | | GfxGouraudTriangleShading(int typeA, |
878 | | GfxGouraudVertex *verticesA, int nVerticesA, |
879 | | int (*trianglesA)[3], int nTrianglesA, |
880 | | int nCompsA, Function **funcsA, int nFuncsA); |
881 | | GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading); |
882 | | virtual ~GfxGouraudTriangleShading(); |
883 | | |
884 | | static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str |
885 | | ); |
886 | | |
887 | | virtual GfxShading *copy(); |
888 | | |
889 | 712k | int getNComps() { return nComps; } |
890 | 713k | int getNTriangles() { return nTriangles; } |
891 | | void getTriangle(int i, double *x0, double *y0, double *color0, |
892 | | double *x1, double *y1, double *color1, |
893 | | double *x2, double *y2, double *color2); |
894 | | void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA); |
895 | | void getColor(double *in, GfxColor *out); |
896 | | |
897 | | private: |
898 | | |
899 | | GfxGouraudVertex *vertices; |
900 | | int nVertices; |
901 | | int (*triangles)[3]; |
902 | | int nTriangles; |
903 | | Function *funcs[gfxColorMaxComps]; |
904 | | int nComps; // number of color components (1 if nFuncs > 0) |
905 | | int nFuncs; |
906 | | }; |
907 | | |
908 | | //------------------------------------------------------------------------ |
909 | | // GfxPatchMeshShading |
910 | | //------------------------------------------------------------------------ |
911 | | |
912 | | struct GfxPatch { |
913 | | double x[4][4]; |
914 | | double y[4][4]; |
915 | | double color[2][2][gfxColorMaxComps]; |
916 | | }; |
917 | | |
918 | | class GfxPatchMeshShading: public GfxShading { |
919 | | public: |
920 | | |
921 | | GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA, |
922 | | int nCompsA, Function **funcsA, int nFuncsA); |
923 | | GfxPatchMeshShading(GfxPatchMeshShading *shading); |
924 | | virtual ~GfxPatchMeshShading(); |
925 | | |
926 | | static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str |
927 | | ); |
928 | | |
929 | | virtual GfxShading *copy(); |
930 | | |
931 | 3.54M | int getNComps() { return nComps; } |
932 | 2.21k | int getNPatches() { return nPatches; } |
933 | 1.14k | GfxPatch *getPatch(int i) { return &patches[i]; } |
934 | | void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA); |
935 | | void getColor(double *in, GfxColor *out); |
936 | | |
937 | | private: |
938 | | |
939 | | GfxPatch *patches; |
940 | | int nPatches; |
941 | | Function *funcs[gfxColorMaxComps]; |
942 | | int nComps; // number of color components (1 if nFuncs > 0) |
943 | | int nFuncs; |
944 | | }; |
945 | | |
946 | | //------------------------------------------------------------------------ |
947 | | // GfxImageColorMap |
948 | | //------------------------------------------------------------------------ |
949 | | |
950 | | class GfxImageColorMap { |
951 | | public: |
952 | | |
953 | | // Constructor. |
954 | | GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA, |
955 | | int maxAllowedBits = 8); |
956 | | |
957 | | // Destructor. |
958 | | ~GfxImageColorMap(); |
959 | | |
960 | | // Return a copy of this color map. |
961 | 0 | GfxImageColorMap *copy() { return new GfxImageColorMap(this); } |
962 | | |
963 | | // Is color map valid? |
964 | 30.5k | GBool isOk() { return ok; } |
965 | | |
966 | | // Get the color space. |
967 | 50.7k | GfxColorSpace *getColorSpace() { return colorSpace; } |
968 | | |
969 | | // Get stream decoding info. |
970 | 61.8k | int getNumPixelComps() { return nComps; } |
971 | 72.9k | int getBits() { return bits; } |
972 | | |
973 | | // Get decode table. |
974 | 0 | double getDecodeLow(int i) { return decodeLow[i]; } |
975 | 0 | double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; } |
976 | | |
977 | | // Convert an image pixel to a color. |
978 | | void getGray(Guchar *x, GfxGray *gray, GfxRenderingIntent ri); |
979 | | void getRGB(Guchar *x, GfxRGB *rgb, GfxRenderingIntent ri); |
980 | | void getCMYK(Guchar *x, GfxCMYK *cmyk, GfxRenderingIntent ri); |
981 | | void getColor(Guchar *x, GfxColor *color); |
982 | | |
983 | | // Convert a line of <n> pixels to 8-bit colors. |
984 | | void getGrayByteLine(Guchar *in, Guchar *out, int n, GfxRenderingIntent ri); |
985 | | void getRGBByteLine(Guchar *in, Guchar *out, int n, GfxRenderingIntent ri); |
986 | | void getCMYKByteLine(Guchar *in, Guchar *out, int n, GfxRenderingIntent ri); |
987 | | |
988 | | private: |
989 | | |
990 | | GfxImageColorMap(GfxImageColorMap *colorMap); |
991 | | |
992 | | GfxColorSpace *colorSpace; // the image color space |
993 | | int bits; // bits per component |
994 | | int nComps; // number of components in a pixel |
995 | | GfxColorSpace *colorSpace2; // secondary color space |
996 | | int nComps2; // number of components in colorSpace2 |
997 | | GfxColorComp * // lookup table |
998 | | lookup[gfxColorMaxComps]; |
999 | | GfxColorComp * // optimized case lookup table |
1000 | | lookup2[gfxColorMaxComps]; |
1001 | | double // minimum values for each component |
1002 | | decodeLow[gfxColorMaxComps]; |
1003 | | double // max - min value for each component |
1004 | | decodeRange[gfxColorMaxComps]; |
1005 | | GBool ok; |
1006 | | }; |
1007 | | |
1008 | | //------------------------------------------------------------------------ |
1009 | | // GfxSubpath and GfxPath |
1010 | | //------------------------------------------------------------------------ |
1011 | | |
1012 | | class GfxSubpath { |
1013 | | public: |
1014 | | |
1015 | | // Constructor. |
1016 | | GfxSubpath(double x1, double y1); |
1017 | | |
1018 | | // Destructor. |
1019 | | ~GfxSubpath(); |
1020 | | |
1021 | | // Copy. |
1022 | 104k | GfxSubpath *copy() { return new GfxSubpath(this); } |
1023 | | |
1024 | | // Get points. |
1025 | 4.26M | int getNumPoints() { return n; } |
1026 | 3.95M | double getX(int i) { return x[i]; } |
1027 | 3.95M | double getY(int i) { return y[i]; } |
1028 | 1.74M | GBool getCurve(int i) { return curve[i]; } |
1029 | | |
1030 | | // Get last point. |
1031 | 434k | double getLastX() { return x[n-1]; } |
1032 | 434k | double getLastY() { return y[n-1]; } |
1033 | | |
1034 | | // Add a line segment. |
1035 | | void lineTo(double x1, double y1); |
1036 | | |
1037 | | // Add a Bezier curve. |
1038 | | void curveTo(double x1, double y1, double x2, double y2, |
1039 | | double x3, double y3); |
1040 | | |
1041 | | // Close the subpath. |
1042 | | void close(); |
1043 | 1.37M | GBool isClosed() { return closed; } |
1044 | | |
1045 | | // Add (<dx>, <dy>) to each point in the subpath. |
1046 | | void offset(double dx, double dy); |
1047 | | |
1048 | | private: |
1049 | | |
1050 | | double *x, *y; // points |
1051 | | GBool *curve; // curve[i] => point i is a control point |
1052 | | // for a Bezier curve |
1053 | | int n; // number of points |
1054 | | int size; // size of x/y arrays |
1055 | | GBool closed; // set if path is closed |
1056 | | |
1057 | | GfxSubpath(GfxSubpath *subpath); |
1058 | | }; |
1059 | | |
1060 | | class GfxPath { |
1061 | | public: |
1062 | | |
1063 | | // Constructor. |
1064 | | GfxPath(); |
1065 | | |
1066 | | // Destructor. |
1067 | | ~GfxPath(); |
1068 | | |
1069 | | // Copy. |
1070 | | GfxPath *copy() |
1071 | 2.40M | { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); } |
1072 | | |
1073 | | // Is there a current point? |
1074 | 1.86M | GBool isCurPt() { return n > 0 || justMoved; } |
1075 | | |
1076 | | // Is the path non-empty, i.e., is there at least one segment? |
1077 | 345k | GBool isPath() { return n > 0; } |
1078 | | |
1079 | | // Get subpaths. |
1080 | 1.54M | int getNumSubpaths() { return n; } |
1081 | 804k | GfxSubpath *getSubpath(int i) { return subpaths[i]; } |
1082 | | |
1083 | | // Get last point on last subpath. |
1084 | 426k | double getLastX() { return subpaths[n-1]->getLastX(); } |
1085 | 426k | double getLastY() { return subpaths[n-1]->getLastY(); } |
1086 | | |
1087 | | // Get the current point |
1088 | | double getCurX(); |
1089 | | double getCurY(); |
1090 | | |
1091 | | // Move the current point. |
1092 | | void moveTo(double x, double y); |
1093 | | |
1094 | | // Add a segment to the last subpath. |
1095 | | void lineTo(double x, double y); |
1096 | | |
1097 | | // Add a Bezier curve to the last subpath |
1098 | | void curveTo(double x1, double y1, double x2, double y2, |
1099 | | double x3, double y3); |
1100 | | |
1101 | | // Close the last subpath. |
1102 | | void close(); |
1103 | | |
1104 | | // Append <path> to <this>. |
1105 | | void append(GfxPath *path); |
1106 | | |
1107 | | // Add (<dx>, <dy>) to each point in the path. |
1108 | | void offset(double dx, double dy); |
1109 | | |
1110 | | private: |
1111 | | |
1112 | | GBool justMoved; // set if a new subpath was just started |
1113 | | double firstX, firstY; // first point in new subpath |
1114 | | GfxSubpath **subpaths; // subpaths |
1115 | | int n; // number of subpaths |
1116 | | int size; // size of subpaths array |
1117 | | |
1118 | | GfxPath(GBool justMoved1, double firstX1, double firstY1, |
1119 | | GfxSubpath **subpaths1, int n1, int size1); |
1120 | | }; |
1121 | | |
1122 | | //------------------------------------------------------------------------ |
1123 | | // GfxState |
1124 | | //------------------------------------------------------------------------ |
1125 | | |
1126 | | class GfxState { |
1127 | | public: |
1128 | | |
1129 | | // Construct a default GfxState, for a device with resolution <hDPI> |
1130 | | // x <vDPI>, page box <pageBox>, page rotation <rotateA>, and |
1131 | | // coordinate system specified by <upsideDown>. |
1132 | | GfxState(LocalParams *localParamsA, |
1133 | | double hDPIA, double vDPIA, PDFRectangle *pageBox, |
1134 | | int rotateA, GBool upsideDown |
1135 | | ); |
1136 | | |
1137 | | // Destructor. |
1138 | | ~GfxState(); |
1139 | | |
1140 | | // Copy. |
1141 | | GfxState *copy(GBool copyPath = gFalse) |
1142 | 3.11M | { return new GfxState(this, copyPath); } |
1143 | | |
1144 | | // Accessors. |
1145 | 401k | double getHDPI() { return hDPI; } |
1146 | 401k | double getVDPI() { return vDPI; } |
1147 | 8.87M | double *getCTM() { return ctm; } |
1148 | 0 | double getX1() { return px1; } |
1149 | 0 | double getY1() { return py1; } |
1150 | 0 | double getX2() { return px2; } |
1151 | 0 | double getY2() { return py2; } |
1152 | 401k | double getPageWidth() { return pageWidth; } |
1153 | 401k | double getPageHeight() { return pageHeight; } |
1154 | 0 | int getRotate() { return rotate; } |
1155 | 832k | GfxColor *getFillColor() { return &fillColor; } |
1156 | 158k | GfxColor *getStrokeColor() { return &strokeColor; } |
1157 | | void getFillGray(GfxGray *gray) |
1158 | 144 | { fillColorSpace->getGray(&fillColor, gray, renderingIntent); } |
1159 | | void getStrokeGray(GfxGray *gray) |
1160 | 118 | { strokeColorSpace->getGray(&strokeColor, gray, renderingIntent); } |
1161 | | void getFillRGB(GfxRGB *rgb) |
1162 | 2.97M | { fillColorSpace->getRGB(&fillColor, rgb, renderingIntent); } |
1163 | | void getStrokeRGB(GfxRGB *rgb) |
1164 | 626k | { strokeColorSpace->getRGB(&strokeColor, rgb, renderingIntent); } |
1165 | | void getFillCMYK(GfxCMYK *cmyk) |
1166 | 273 | { fillColorSpace->getCMYK(&fillColor, cmyk, renderingIntent); } |
1167 | | void getStrokeCMYK(GfxCMYK *cmyk) |
1168 | 275 | { strokeColorSpace->getCMYK(&strokeColor, cmyk, renderingIntent); } |
1169 | 6.96M | GfxColorSpace *getFillColorSpace() { return fillColorSpace; } |
1170 | 591k | GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; } |
1171 | 147k | GfxPattern *getFillPattern() { return fillPattern; } |
1172 | 197 | GfxPattern *getStrokePattern() { return strokePattern; } |
1173 | 15.9k | GfxBlendMode getBlendMode() { return blendMode; } |
1174 | 17.2k | double getFillOpacity() { return fillOpacity; } |
1175 | 11.6k | double getStrokeOpacity() { return strokeOpacity; } |
1176 | 858k | GBool getFillOverprint() { return fillOverprint; } |
1177 | 158k | GBool getStrokeOverprint() { return strokeOverprint; } |
1178 | 1.01M | int getOverprintMode() { return overprintMode; } |
1179 | 2.28M | GfxRenderingIntent getRenderingIntent() { return renderingIntent; } |
1180 | 731 | Function **getTransfer() { return transfer; } |
1181 | 603k | double getLineWidth() { return lineWidth; } |
1182 | | void getLineDash(double **dash, int *length, double *start) |
1183 | 450k | { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; } |
1184 | 0 | double getFlatness() { return flatness; } |
1185 | 417k | int getLineJoin() { return lineJoin; } |
1186 | 449k | int getLineCap() { return lineCap; } |
1187 | 430k | double getMiterLimit() { return miterLimit; } |
1188 | 0 | GBool getStrokeAdjust() { return strokeAdjust; } |
1189 | 3.94k | GBool getAlphaIsShape() { return alphaIsShape; } |
1190 | 3.69M | GfxFont *getFont() { return font; } |
1191 | 30.0M | double getFontSize() { return fontSize; } |
1192 | 83.7k | double *getTextMat() { return textMat; } |
1193 | 8.30M | double getCharSpace() { return charSpace; } |
1194 | 739k | double getWordSpace() { return wordSpace; } |
1195 | 8.88M | double getHorizScaling() { return horizScaling; } |
1196 | 3.73k | double getLeading() { return leading; } |
1197 | 676k | double getRise() { return rise; } |
1198 | 2.92M | int getRender() { return render; } |
1199 | 523k | GfxPath *getPath() { return path; } |
1200 | | void setPath(GfxPath *pathA); |
1201 | 6.82M | double getCurX() { return curX; } |
1202 | 6.82M | double getCurY() { return curY; } |
1203 | | void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) |
1204 | 44.1k | { *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; } |
1205 | | void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax); |
1206 | 187k | double getLineX() { return lineX; } |
1207 | 187k | double getLineY() { return lineY; } |
1208 | 687k | GBool getIgnoreColorOps() { return ignoreColorOps; } |
1209 | | |
1210 | | // Is there a current point/path? |
1211 | 1.86M | GBool isCurPt() { return path->isCurPt(); } |
1212 | 345k | GBool isPath() { return path->isPath(); } |
1213 | | |
1214 | | // Transforms. |
1215 | | void transform(double x1, double y1, double *x2, double *y2) |
1216 | 33.6M | { *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4]; |
1217 | 33.6M | *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; } |
1218 | | void transformDelta(double x1, double y1, double *x2, double *y2) |
1219 | 13.9M | { *x2 = ctm[0] * x1 + ctm[2] * y1; |
1220 | 13.9M | *y2 = ctm[1] * x1 + ctm[3] * y1; } |
1221 | | void textTransform(double x1, double y1, double *x2, double *y2) |
1222 | 666k | { *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4]; |
1223 | 666k | *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; } |
1224 | | void textTransformDelta(double x1, double y1, double *x2, double *y2) |
1225 | 15.8M | { *x2 = textMat[0] * x1 + textMat[2] * y1; |
1226 | 15.8M | *y2 = textMat[1] * x1 + textMat[3] * y1; } |
1227 | | double transformWidth(double w); |
1228 | | double getTransformedLineWidth() |
1229 | 0 | { return transformWidth(lineWidth); } |
1230 | | double getTransformedFontSize(); |
1231 | | void getFontTransMat(double *m11, double *m12, double *m21, double *m22); |
1232 | | |
1233 | | // Change state parameters. |
1234 | | void setCTM(double a, double b, double c, |
1235 | | double d, double e, double f); |
1236 | | void concatCTM(double a, double b, double c, |
1237 | | double d, double e, double f); |
1238 | | void shiftCTM(double tx, double ty); |
1239 | | void setFillColorSpace(GfxColorSpace *colorSpace); |
1240 | | void setStrokeColorSpace(GfxColorSpace *colorSpace); |
1241 | 2.57M | void setFillColor(GfxColor *color) { fillColor = *color; } |
1242 | 223k | void setStrokeColor(GfxColor *color) { strokeColor = *color; } |
1243 | | void setFillPattern(GfxPattern *pattern); |
1244 | | void setStrokePattern(GfxPattern *pattern); |
1245 | 5.47k | void setBlendMode(GfxBlendMode mode) { blendMode = mode; } |
1246 | 6.71k | void setFillOpacity(double opac) { fillOpacity = opac; } |
1247 | 6.63k | void setStrokeOpacity(double opac) { strokeOpacity = opac; } |
1248 | 44.8k | void setFillOverprint(GBool op) { fillOverprint = op; } |
1249 | 43.4k | void setStrokeOverprint(GBool op) { strokeOverprint = op; } |
1250 | 43.6k | void setOverprintMode(int opm) { overprintMode = opm; } |
1251 | | void setRenderingIntent(GfxRenderingIntent ri); |
1252 | | void setTransfer(Function **funcs); |
1253 | 201k | void setLineWidth(double width) { lineWidth = width; } |
1254 | | void setLineDash(double *dash, int length, double start); |
1255 | 114k | void setFlatness(double flatness1) { flatness = flatness1; } |
1256 | 15.4k | void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; } |
1257 | 47.4k | void setLineCap(int lineCap1) { lineCap = lineCap1; } |
1258 | 28.9k | void setMiterLimit(double limit) { miterLimit = limit; } |
1259 | 2.38k | void setStrokeAdjust(GBool sa) { strokeAdjust = sa; } |
1260 | 3.94k | void setAlphaIsShape(GBool ais) { alphaIsShape = ais; } |
1261 | | void setFont(GfxFont *fontA, double fontSizeA) |
1262 | 164k | { font = fontA; fontSize = fontSizeA; } |
1263 | | void setTextMat(double a, double b, double c, |
1264 | | double d, double e, double f) |
1265 | 478k | { textMat[0] = a; textMat[1] = b; textMat[2] = c; |
1266 | 478k | textMat[3] = d; textMat[4] = e; textMat[5] = f; } |
1267 | | void setCharSpace(double space) |
1268 | 26.7k | { charSpace = space; } |
1269 | | void setWordSpace(double space) |
1270 | 22.8k | { wordSpace = space; } |
1271 | | void setHorizScaling(double scale) |
1272 | 17.7k | { horizScaling = 0.01 * scale; } |
1273 | | void setLeading(double leadingA) |
1274 | 64.4k | { leading = leadingA; } |
1275 | | void setRise(double riseA) |
1276 | 1.16k | { rise = riseA; } |
1277 | | void setRender(int renderA) |
1278 | 23.5k | { render = renderA; } |
1279 | | |
1280 | | // Add to path. |
1281 | | void moveTo(double x, double y) |
1282 | 2.86M | { path->moveTo(curX = x, curY = y); } |
1283 | | void lineTo(double x, double y) |
1284 | 1.11M | { path->lineTo(curX = x, curY = y); } |
1285 | | void curveTo(double x1, double y1, double x2, double y2, |
1286 | | double x3, double y3) |
1287 | 182k | { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); } |
1288 | | void closePath() |
1289 | 426k | { path->close(); curX = path->getLastX(); curY = path->getLastY(); } |
1290 | | void clearPath(); |
1291 | | |
1292 | | // Update clip region. |
1293 | | void clip(); |
1294 | | void clipToStrokePath(); |
1295 | | void clipToRect(double xMin, double yMin, double xMax, double yMax); |
1296 | | void resetDevClipRect(double xMin, double yMin, double xMax, double yMax) |
1297 | 184 | { clipXMin = xMin; clipYMin = yMin; clipXMax = xMax; clipYMax = yMax; } |
1298 | | |
1299 | | // Text position. |
1300 | 0 | void textSetPos(double tx, double ty) { lineX = tx; lineY = ty; } |
1301 | | void textMoveTo(double tx, double ty) |
1302 | 666k | { lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); } |
1303 | | void textShift(double tx, double ty); |
1304 | | void shift(double dx, double dy); |
1305 | | |
1306 | | // Ignore color operators (in cached/uncolored Type 3 chars, and |
1307 | | // uncolored tiling patterns). Cached Type 3 char status. |
1308 | 31.3k | void setIgnoreColorOps(GBool ignore) { ignoreColorOps = ignore; } |
1309 | | |
1310 | | // Push/pop GfxState on/off stack. |
1311 | | GfxState *save(); |
1312 | | GfxState *restore(); |
1313 | 3.19M | GBool hasSaves() { return saved != NULL; } |
1314 | | |
1315 | | // Misc |
1316 | | GBool parseBlendMode(Object *obj, GfxBlendMode *mode); |
1317 | | |
1318 | | private: |
1319 | | |
1320 | | LocalParams *localParams; |
1321 | | |
1322 | | double hDPI, vDPI; // resolution |
1323 | | double ctm[6]; // coord transform matrix |
1324 | | double px1, py1, px2, py2; // page corners (user coords) |
1325 | | double pageWidth, pageHeight; // page size (pixels) |
1326 | | int rotate; // page rotation angle |
1327 | | |
1328 | | GfxColorSpace *fillColorSpace; // fill color space |
1329 | | GfxColorSpace *strokeColorSpace; // stroke color space |
1330 | | GfxColor fillColor; // fill color |
1331 | | GfxColor strokeColor; // stroke color |
1332 | | GfxPattern *fillPattern; // fill pattern |
1333 | | GfxPattern *strokePattern; // stroke pattern |
1334 | | GfxBlendMode blendMode; // transparency blend mode |
1335 | | double fillOpacity; // fill opacity |
1336 | | double strokeOpacity; // stroke opacity |
1337 | | GBool fillOverprint; // fill overprint |
1338 | | GBool strokeOverprint; // stroke overprint |
1339 | | int overprintMode; // overprint mode ("OPM") |
1340 | | GfxRenderingIntent renderingIntent; // rendering intent |
1341 | | Function *transfer[4]; // transfer function (entries may be: all |
1342 | | // NULL = identity; last three NULL = |
1343 | | // single function; all four non-NULL = |
1344 | | // R,G,B,gray functions) |
1345 | | |
1346 | | double lineWidth; // line width |
1347 | | double *lineDash; // line dash |
1348 | | int lineDashLength; |
1349 | | double lineDashStart; |
1350 | | double flatness; // curve flatness |
1351 | | int lineJoin; // line join style |
1352 | | int lineCap; // line cap style |
1353 | | double miterLimit; // line miter limit |
1354 | | GBool strokeAdjust; // stroke adjustment |
1355 | | GBool alphaIsShape; |
1356 | | |
1357 | | GfxFont *font; // font |
1358 | | double fontSize; // font size |
1359 | | double textMat[6]; // text matrix |
1360 | | double charSpace; // character spacing |
1361 | | double wordSpace; // word spacing |
1362 | | double horizScaling; // horizontal scaling |
1363 | | double leading; // text leading |
1364 | | double rise; // text rise |
1365 | | int render; // text rendering mode |
1366 | | |
1367 | | GfxPath *path; // array of path elements |
1368 | | double curX, curY; // current point (user coords) |
1369 | | double lineX, lineY; // start of current text line (text coords) |
1370 | | |
1371 | | double clipXMin, clipYMin, // bounding box for clip region |
1372 | | clipXMax, clipYMax; |
1373 | | |
1374 | | GBool ignoreColorOps; // ignore color ops (in cached/uncolored |
1375 | | // Type 3 chars, and uncolored tiling |
1376 | | // patterns) |
1377 | | |
1378 | | GfxState *saved; // next GfxState on stack |
1379 | | |
1380 | | GfxState(GfxState *state, GBool copyPath); |
1381 | | }; |
1382 | | |
1383 | | #endif |