"Fossies" - the Fresh Open Source Software Archive

Member "xpdf-4.04/xpdf/GfxState.h" (18 Apr 2022, 43452 Bytes) of package /linux/misc/xpdf-4.04.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "GfxState.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 4.03_vs_4.04.

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