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