Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:23:47

0001 //========================================================================
0002 //
0003 // GfxState.h
0004 //
0005 // Copyright 1996-2003 Glyph & Cog, LLC
0006 //
0007 //========================================================================
0008 
0009 //========================================================================
0010 //
0011 // Modified under the Poppler project - http://poppler.freedesktop.org
0012 //
0013 // All changes made under the Poppler project to this file are licensed
0014 // under GPL version 2 or later
0015 //
0016 // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
0017 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
0018 // Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
0019 // Copyright (C) 2009 Koji Otani <sho@bbr.jp>
0020 // Copyright (C) 2009-2011, 2013, 2016-2022 Albert Astals Cid <aacid@kde.org>
0021 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
0022 // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com>
0023 // Copyright (C) 2011-2014, 2016, 2020 Thomas Freitag <Thomas.Freitag@alfa.de>
0024 // Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com>
0025 // Copyright (C) 2015, 2017, 2020, 2022 Adrian Johnson <ajohnson@redneon.com>
0026 // Copyright (C) 2017, 2019, 2022 Oliver Sander <oliver.sander@tu-dresden.de>
0027 // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
0028 // Copyright (C) 2020, 2021 Philipp Knechtges <philipp-dev@knechtges.com>
0029 //
0030 // To see a description of the changes please see the Changelog file that
0031 // came with your tarball or type make ChangeLog if you are building from git
0032 //
0033 //========================================================================
0034 
0035 #ifndef GFXSTATE_H
0036 #define GFXSTATE_H
0037 
0038 #include "poppler-config.h"
0039 #include "poppler_private_export.h"
0040 
0041 #include "Object.h"
0042 #include "Function.h"
0043 
0044 #include <cassert>
0045 #include <map>
0046 #include <memory>
0047 #include <vector>
0048 
0049 class Array;
0050 class Gfx;
0051 class GfxFont;
0052 class PDFRectangle;
0053 class GfxShading;
0054 class OutputDev;
0055 class GfxState;
0056 class GfxResources;
0057 class GfxSeparationColorSpace;
0058 
0059 class Matrix
0060 {
0061 public:
0062     double m[6];
0063 
0064     void init(double xx, double yx, double xy, double yy, double x0, double y0)
0065     {
0066         m[0] = xx;
0067         m[1] = yx;
0068         m[2] = xy;
0069         m[3] = yy;
0070         m[4] = x0;
0071         m[5] = y0;
0072     }
0073     bool invertTo(Matrix *other) const;
0074     void translate(double tx, double ty);
0075     void scale(double sx, double sy);
0076     void transform(double x, double y, double *tx, double *ty) const;
0077     double determinant() const { return m[0] * m[3] - m[1] * m[2]; }
0078     double norm() const;
0079 };
0080 
0081 //------------------------------------------------------------------------
0082 // GfxBlendMode
0083 //------------------------------------------------------------------------
0084 
0085 enum GfxBlendMode
0086 {
0087     gfxBlendNormal,
0088     gfxBlendMultiply,
0089     gfxBlendScreen,
0090     gfxBlendOverlay,
0091     gfxBlendDarken,
0092     gfxBlendLighten,
0093     gfxBlendColorDodge,
0094     gfxBlendColorBurn,
0095     gfxBlendHardLight,
0096     gfxBlendSoftLight,
0097     gfxBlendDifference,
0098     gfxBlendExclusion,
0099     gfxBlendHue,
0100     gfxBlendSaturation,
0101     gfxBlendColor,
0102     gfxBlendLuminosity
0103 };
0104 
0105 //------------------------------------------------------------------------
0106 // GfxColorComp
0107 //------------------------------------------------------------------------
0108 
0109 // 16.16 fixed point color component
0110 typedef int GfxColorComp;
0111 
0112 #define gfxColorComp1 0x10000
0113 
0114 static inline GfxColorComp dblToCol(double x)
0115 {
0116     return (GfxColorComp)(x * gfxColorComp1);
0117 }
0118 
0119 static inline double colToDbl(GfxColorComp x)
0120 {
0121     return (double)x / (double)gfxColorComp1;
0122 }
0123 
0124 static inline unsigned char dblToByte(double x)
0125 {
0126     return static_cast<unsigned char>(x * 255.0);
0127 }
0128 
0129 static inline double byteToDbl(unsigned char x)
0130 {
0131     return (double)x / (double)255.0;
0132 }
0133 
0134 static inline GfxColorComp byteToCol(unsigned char x)
0135 {
0136     // (x / 255) << 16  =  (0.0000000100000001... * x) << 16
0137     //                  =  ((x << 8) + (x) + (x >> 8) + ...) << 16
0138     //                  =  (x << 8) + (x) + (x >> 7)
0139     //                                      [for rounding]
0140     return (GfxColorComp)((x << 8) + x + (x >> 7));
0141 }
0142 
0143 static inline unsigned char colToByte(GfxColorComp x)
0144 {
0145     // 255 * x + 0.5  =  256 * x - x + 0x8000
0146     return (unsigned char)(((x << 8) - x + 0x8000) >> 16);
0147 }
0148 
0149 static inline unsigned short colToShort(GfxColorComp x)
0150 {
0151     return (unsigned short)(x);
0152 }
0153 
0154 //------------------------------------------------------------------------
0155 // GfxColor
0156 //------------------------------------------------------------------------
0157 
0158 #define gfxColorMaxComps funcMaxOutputs
0159 
0160 struct GfxColor
0161 {
0162     GfxColorComp c[gfxColorMaxComps];
0163 };
0164 
0165 static inline void clearGfxColor(GfxColor *gfxColor)
0166 {
0167     memset(gfxColor->c, 0, sizeof(GfxColorComp) * gfxColorMaxComps);
0168 }
0169 
0170 //------------------------------------------------------------------------
0171 // GfxGray
0172 //------------------------------------------------------------------------
0173 
0174 typedef GfxColorComp GfxGray;
0175 
0176 //------------------------------------------------------------------------
0177 // GfxRGB
0178 //------------------------------------------------------------------------
0179 
0180 struct GfxRGB
0181 {
0182     GfxColorComp r, g, b;
0183 
0184     bool operator==(GfxRGB other) const { return r == other.r && g == other.g && b == other.b; }
0185 };
0186 
0187 //------------------------------------------------------------------------
0188 // GfxCMYK
0189 //------------------------------------------------------------------------
0190 
0191 struct GfxCMYK
0192 {
0193     GfxColorComp c, m, y, k;
0194 };
0195 
0196 //------------------------------------------------------------------------
0197 // GfxColorSpace
0198 //------------------------------------------------------------------------
0199 
0200 // NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames
0201 // array defined in GfxState.cc must match this enum.
0202 enum GfxColorSpaceMode
0203 {
0204     csDeviceGray,
0205     csCalGray,
0206     csDeviceRGB,
0207     csCalRGB,
0208     csDeviceCMYK,
0209     csLab,
0210     csICCBased,
0211     csIndexed,
0212     csSeparation,
0213     csDeviceN,
0214     csPattern
0215 };
0216 
0217 // This shall hold a cmsHPROFILE handle.
0218 // Only use the make_GfxLCMSProfilePtr function to construct this pointer,
0219 // to ensure that the resources are properly released after usage.
0220 typedef std::shared_ptr<void> GfxLCMSProfilePtr;
0221 
0222 #ifdef USE_CMS
0223 GfxLCMSProfilePtr POPPLER_PRIVATE_EXPORT make_GfxLCMSProfilePtr(void *profile);
0224 #endif
0225 
0226 // wrapper of cmsHTRANSFORM to copy
0227 class GfxColorTransform
0228 {
0229 public:
0230     void doTransform(void *in, void *out, unsigned int size);
0231     // transformA should be a cmsHTRANSFORM
0232     GfxColorTransform(void *transformA, int cmsIntent, unsigned int inputPixelType, unsigned int transformPixelType);
0233     ~GfxColorTransform();
0234     GfxColorTransform(const GfxColorTransform &) = delete;
0235     GfxColorTransform &operator=(const GfxColorTransform &) = delete;
0236     int getIntent() const { return cmsIntent; }
0237     int getInputPixelType() const { return inputPixelType; }
0238     int getTransformPixelType() const { return transformPixelType; }
0239 
0240 private:
0241     GfxColorTransform() { }
0242     void *transform;
0243     int cmsIntent;
0244     unsigned int inputPixelType;
0245     unsigned int transformPixelType;
0246 };
0247 
0248 class POPPLER_PRIVATE_EXPORT GfxColorSpace
0249 {
0250 public:
0251     GfxColorSpace();
0252     virtual ~GfxColorSpace();
0253 
0254     GfxColorSpace(const GfxColorSpace &) = delete;
0255     GfxColorSpace &operator=(const GfxColorSpace &other) = delete;
0256 
0257     virtual GfxColorSpace *copy() const = 0;
0258     virtual GfxColorSpaceMode getMode() const = 0;
0259 
0260     // Construct a color space.  Returns nullptr if unsuccessful.
0261     static GfxColorSpace *parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion = 0);
0262 
0263     // Convert to gray, RGB, or CMYK.
0264     virtual void getGray(const GfxColor *color, GfxGray *gray) const = 0;
0265     virtual void getRGB(const GfxColor *color, GfxRGB *rgb) const = 0;
0266     virtual void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const = 0;
0267     virtual void getDeviceN(const GfxColor *color, GfxColor *deviceN) const = 0;
0268     virtual void getGrayLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getGrayLine this should not happen"); }
0269     virtual void getRGBLine(unsigned char * /*in*/, unsigned int * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBLine (first variant) this should not happen"); }
0270     virtual void getRGBLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBLine (second variant) this should not happen"); }
0271     virtual void getRGBXLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getRGBXLine this should not happen"); }
0272     virtual void getCMYKLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getCMYKLine this should not happen"); }
0273     virtual void getDeviceNLine(unsigned char * /*in*/, unsigned char * /*out*/, int /*length*/) { error(errInternal, -1, "GfxColorSpace::getDeviceNLine this should not happen"); }
0274 
0275     // create mapping for spot colorants
0276     virtual void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps);
0277     int *getMapping() const { return mapping; }
0278 
0279     // Does this ColorSpace support getRGBLine?
0280     virtual bool useGetRGBLine() const { return false; }
0281     // Does this ColorSpace support getGrayLine?
0282     virtual bool useGetGrayLine() const { return false; }
0283     // Does this ColorSpace support getCMYKLine?
0284     virtual bool useGetCMYKLine() const { return false; }
0285     // Does this ColorSpace support getDeviceNLine?
0286     virtual bool useGetDeviceNLine() const { return false; }
0287 
0288     // Return the number of color components.
0289     virtual int getNComps() const = 0;
0290 
0291     // Get this color space's default color.
0292     virtual void getDefaultColor(GfxColor *color) const = 0;
0293 
0294     // Return the default ranges for each component, assuming an image
0295     // with a max pixel value of <maxImgPixel>.
0296     virtual void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const;
0297 
0298     // Returns true if painting operations in this color space never
0299     // mark the page (e.g., the "None" colorant).
0300     virtual bool isNonMarking() const { return false; }
0301 
0302     // Return the color space's overprint mask.
0303     unsigned int getOverprintMask() const { return overprintMask; }
0304 
0305     // Return the number of color space modes
0306     static int getNumColorSpaceModes();
0307 
0308     // Return the name of the <idx>th color space mode.
0309     static const char *getColorSpaceModeName(int idx);
0310 
0311 protected:
0312     unsigned int overprintMask;
0313     int *mapping;
0314 };
0315 
0316 //------------------------------------------------------------------------
0317 // GfxDeviceGrayColorSpace
0318 //------------------------------------------------------------------------
0319 
0320 class POPPLER_PRIVATE_EXPORT GfxDeviceGrayColorSpace : public GfxColorSpace
0321 {
0322 public:
0323     GfxDeviceGrayColorSpace();
0324     ~GfxDeviceGrayColorSpace() override;
0325     GfxColorSpace *copy() const override;
0326     GfxColorSpaceMode getMode() const override { return csDeviceGray; }
0327 
0328     void getGray(const GfxColor *color, GfxGray *gray) const override;
0329     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0330     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0331     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0332     void getGrayLine(unsigned char *in, unsigned char *out, int length) override;
0333     void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
0334     void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
0335     void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
0336     void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
0337     void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
0338 
0339     bool useGetRGBLine() const override { return true; }
0340     bool useGetGrayLine() const override { return true; }
0341     bool useGetCMYKLine() const override { return true; }
0342     bool useGetDeviceNLine() const override { return true; }
0343 
0344     int getNComps() const override { return 1; }
0345     void getDefaultColor(GfxColor *color) const override;
0346 
0347 private:
0348 };
0349 
0350 //------------------------------------------------------------------------
0351 // GfxCalGrayColorSpace
0352 //------------------------------------------------------------------------
0353 
0354 class GfxCalGrayColorSpace : public GfxColorSpace
0355 {
0356 public:
0357     GfxCalGrayColorSpace();
0358     ~GfxCalGrayColorSpace() override;
0359     GfxColorSpace *copy() const override;
0360     GfxColorSpaceMode getMode() const override { return csCalGray; }
0361 
0362     // Construct a CalGray color space.  Returns nullptr if unsuccessful.
0363     static GfxColorSpace *parse(Array *arr, GfxState *state);
0364 
0365     void getGray(const GfxColor *color, GfxGray *gray) const override;
0366     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0367     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0368     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0369 
0370     int getNComps() const override { return 1; }
0371     void getDefaultColor(GfxColor *color) const override;
0372 
0373     // CalGray-specific access.
0374     double getWhiteX() const { return whiteX; }
0375     double getWhiteY() const { return whiteY; }
0376     double getWhiteZ() const { return whiteZ; }
0377     double getBlackX() const { return blackX; }
0378     double getBlackY() const { return blackY; }
0379     double getBlackZ() const { return blackZ; }
0380     double getGamma() const { return gamma; }
0381 
0382 private:
0383     double whiteX, whiteY, whiteZ; // white point
0384     double blackX, blackY, blackZ; // black point
0385     double gamma; // gamma value
0386     void getXYZ(const GfxColor *color, double *pX, double *pY, double *pZ) const;
0387 #ifdef USE_CMS
0388     std::shared_ptr<GfxColorTransform> transform;
0389 #endif
0390 };
0391 
0392 //------------------------------------------------------------------------
0393 // GfxDeviceRGBColorSpace
0394 //------------------------------------------------------------------------
0395 
0396 class POPPLER_PRIVATE_EXPORT GfxDeviceRGBColorSpace : public GfxColorSpace
0397 {
0398 public:
0399     GfxDeviceRGBColorSpace();
0400     ~GfxDeviceRGBColorSpace() override;
0401     GfxColorSpace *copy() const override;
0402     GfxColorSpaceMode getMode() const override { return csDeviceRGB; }
0403 
0404     void getGray(const GfxColor *color, GfxGray *gray) const override;
0405     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0406     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0407     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0408     void getGrayLine(unsigned char *in, unsigned char *out, int length) override;
0409     void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
0410     void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
0411     void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
0412     void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
0413     void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
0414 
0415     bool useGetRGBLine() const override { return true; }
0416     bool useGetGrayLine() const override { return true; }
0417     bool useGetCMYKLine() const override { return true; }
0418     bool useGetDeviceNLine() const override { return true; }
0419 
0420     int getNComps() const override { return 3; }
0421     void getDefaultColor(GfxColor *color) const override;
0422 
0423 private:
0424 };
0425 
0426 //------------------------------------------------------------------------
0427 // GfxCalRGBColorSpace
0428 //------------------------------------------------------------------------
0429 
0430 class GfxCalRGBColorSpace : public GfxColorSpace
0431 {
0432 public:
0433     GfxCalRGBColorSpace();
0434     ~GfxCalRGBColorSpace() override;
0435     GfxColorSpace *copy() const override;
0436     GfxColorSpaceMode getMode() const override { return csCalRGB; }
0437 
0438     // Construct a CalRGB color space.  Returns nullptr if unsuccessful.
0439     static GfxColorSpace *parse(Array *arr, GfxState *state);
0440 
0441     void getGray(const GfxColor *color, GfxGray *gray) const override;
0442     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0443     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0444     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0445 
0446     int getNComps() const override { return 3; }
0447     void getDefaultColor(GfxColor *color) const override;
0448 
0449     // CalRGB-specific access.
0450     double getWhiteX() const { return whiteX; }
0451     double getWhiteY() const { return whiteY; }
0452     double getWhiteZ() const { return whiteZ; }
0453     double getBlackX() const { return blackX; }
0454     double getBlackY() const { return blackY; }
0455     double getBlackZ() const { return blackZ; }
0456     double getGammaR() const { return gammaR; }
0457     double getGammaG() const { return gammaG; }
0458     double getGammaB() const { return gammaB; }
0459     const double *getMatrix() const { return mat; }
0460 
0461 private:
0462     double whiteX, whiteY, whiteZ; // white point
0463     double blackX, blackY, blackZ; // black point
0464     double gammaR, gammaG, gammaB; // gamma values
0465     double mat[9]; // ABC -> XYZ transform matrix
0466     void getXYZ(const GfxColor *color, double *pX, double *pY, double *pZ) const;
0467 #ifdef USE_CMS
0468     std::shared_ptr<GfxColorTransform> transform;
0469 #endif
0470 };
0471 
0472 //------------------------------------------------------------------------
0473 // GfxDeviceCMYKColorSpace
0474 //------------------------------------------------------------------------
0475 
0476 class POPPLER_PRIVATE_EXPORT GfxDeviceCMYKColorSpace : public GfxColorSpace
0477 {
0478 public:
0479     GfxDeviceCMYKColorSpace();
0480     ~GfxDeviceCMYKColorSpace() override;
0481     GfxColorSpace *copy() const override;
0482     GfxColorSpaceMode getMode() const override { return csDeviceCMYK; }
0483 
0484     void getGray(const GfxColor *color, GfxGray *gray) const override;
0485     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0486     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0487     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0488     void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
0489     void getRGBLine(unsigned char *, unsigned char *out, int length) override;
0490     void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
0491     void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
0492     void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
0493     bool useGetRGBLine() const override { return true; }
0494     bool useGetCMYKLine() const override { return true; }
0495     bool useGetDeviceNLine() const override { return true; }
0496 
0497     int getNComps() const override { return 4; }
0498     void getDefaultColor(GfxColor *color) const override;
0499 
0500 private:
0501 };
0502 
0503 //------------------------------------------------------------------------
0504 // GfxLabColorSpace
0505 //------------------------------------------------------------------------
0506 
0507 class GfxLabColorSpace : public GfxColorSpace
0508 {
0509 public:
0510     GfxLabColorSpace();
0511     ~GfxLabColorSpace() override;
0512     GfxColorSpace *copy() const override;
0513     GfxColorSpaceMode getMode() const override { return csLab; }
0514 
0515     // Construct a Lab color space.  Returns nullptr if unsuccessful.
0516     static GfxColorSpace *parse(Array *arr, GfxState *state);
0517 
0518     void getGray(const GfxColor *color, GfxGray *gray) const override;
0519     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0520     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0521     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0522 
0523     int getNComps() const override { return 3; }
0524     void getDefaultColor(GfxColor *color) const override;
0525 
0526     void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const override;
0527 
0528     // Lab-specific access.
0529     double getWhiteX() const { return whiteX; }
0530     double getWhiteY() const { return whiteY; }
0531     double getWhiteZ() const { return whiteZ; }
0532     double getBlackX() const { return blackX; }
0533     double getBlackY() const { return blackY; }
0534     double getBlackZ() const { return blackZ; }
0535     double getAMin() const { return aMin; }
0536     double getAMax() const { return aMax; }
0537     double getBMin() const { return bMin; }
0538     double getBMax() const { return bMax; }
0539 
0540 private:
0541     double whiteX, whiteY, whiteZ; // white point
0542     double blackX, blackY, blackZ; // black point
0543     double aMin, aMax, bMin, bMax; // range for the a and b components
0544     void getXYZ(const GfxColor *color, double *pX, double *pY, double *pZ) const;
0545 #ifdef USE_CMS
0546     std::shared_ptr<GfxColorTransform> transform;
0547 #endif
0548 };
0549 
0550 //------------------------------------------------------------------------
0551 // GfxICCBasedColorSpace
0552 //------------------------------------------------------------------------
0553 
0554 class POPPLER_PRIVATE_EXPORT GfxICCBasedColorSpace : public GfxColorSpace
0555 {
0556 public:
0557     GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA, const Ref *iccProfileStreamA);
0558     ~GfxICCBasedColorSpace() override;
0559     GfxColorSpace *copy() const override;
0560     GfxColorSpaceMode getMode() const override { return csICCBased; }
0561 
0562     // Construct an ICCBased color space.  Returns nullptr if unsuccessful.
0563     static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
0564 
0565     void getGray(const GfxColor *color, GfxGray *gray) const override;
0566     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0567     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0568     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0569     void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
0570     void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
0571     void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
0572     void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
0573     void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
0574 
0575     bool useGetRGBLine() const override;
0576     bool useGetCMYKLine() const override;
0577     bool useGetDeviceNLine() const override;
0578 
0579     int getNComps() const override { return nComps; }
0580     void getDefaultColor(GfxColor *color) const override;
0581 
0582     void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const override;
0583 
0584     // ICCBased-specific access.
0585     GfxColorSpace *getAlt() { return alt; }
0586     Ref getRef() { return iccProfileStream; }
0587 #ifdef USE_CMS
0588     char *getPostScriptCSA();
0589     void buildTransforms(GfxState *state);
0590     void setProfile(GfxLCMSProfilePtr &profileA) { profile = profileA; }
0591     GfxLCMSProfilePtr getProfile() { return profile; }
0592 #endif
0593 
0594 private:
0595     int nComps; // number of color components (1, 3, or 4)
0596     GfxColorSpace *alt; // alternate color space
0597     double rangeMin[4]; // min values for each component
0598     double rangeMax[4]; // max values for each component
0599     Ref iccProfileStream; // the ICC profile
0600 #ifdef USE_CMS
0601     GfxLCMSProfilePtr profile;
0602     char *psCSA;
0603     int getIntent() { return (transform != nullptr) ? transform->getIntent() : 0; }
0604     std::shared_ptr<GfxColorTransform> transform;
0605     std::shared_ptr<GfxColorTransform> lineTransform; // color transform for line
0606     mutable std::map<unsigned int, unsigned int> cmsCache;
0607 #endif
0608 };
0609 //------------------------------------------------------------------------
0610 // GfxIndexedColorSpace
0611 //------------------------------------------------------------------------
0612 
0613 class GfxIndexedColorSpace : public GfxColorSpace
0614 {
0615 public:
0616     GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
0617     ~GfxIndexedColorSpace() override;
0618     GfxColorSpace *copy() const override;
0619     GfxColorSpaceMode getMode() const override { return csIndexed; }
0620 
0621     // Construct an Indexed color space.  Returns nullptr if unsuccessful.
0622     static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
0623 
0624     void getGray(const GfxColor *color, GfxGray *gray) const override;
0625     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0626     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0627     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0628     void getRGBLine(unsigned char *in, unsigned int *out, int length) override;
0629     void getRGBLine(unsigned char *in, unsigned char *out, int length) override;
0630     void getRGBXLine(unsigned char *in, unsigned char *out, int length) override;
0631     void getCMYKLine(unsigned char *in, unsigned char *out, int length) override;
0632     void getDeviceNLine(unsigned char *in, unsigned char *out, int length) override;
0633 
0634     bool useGetRGBLine() const override { return true; }
0635     bool useGetCMYKLine() const override { return true; }
0636     bool useGetDeviceNLine() const override { return true; }
0637 
0638     int getNComps() const override { return 1; }
0639     void getDefaultColor(GfxColor *color) const override;
0640 
0641     void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel) const override;
0642 
0643     // Indexed-specific access.
0644     GfxColorSpace *getBase() { return base; }
0645     int getIndexHigh() const { return indexHigh; }
0646     unsigned char *getLookup() { return lookup; }
0647     GfxColor *mapColorToBase(const GfxColor *color, GfxColor *baseColor) const;
0648     unsigned int getOverprintMask() const { return base->getOverprintMask(); }
0649     void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps) override { base->createMapping(separationList, maxSepComps); }
0650 
0651 private:
0652     GfxColorSpace *base; // base color space
0653     int indexHigh; // max pixel value
0654     unsigned char *lookup; // lookup table
0655 };
0656 
0657 //------------------------------------------------------------------------
0658 // GfxSeparationColorSpace
0659 //------------------------------------------------------------------------
0660 
0661 class GfxSeparationColorSpace : public GfxColorSpace
0662 {
0663 public:
0664     GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA, Function *funcA);
0665     ~GfxSeparationColorSpace() override;
0666     GfxColorSpace *copy() const override;
0667     GfxColorSpaceMode getMode() const override { return csSeparation; }
0668 
0669     // Construct a Separation color space.  Returns nullptr if unsuccessful.
0670     static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
0671 
0672     void getGray(const GfxColor *color, GfxGray *gray) const override;
0673     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0674     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0675     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0676 
0677     void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps) override;
0678 
0679     int getNComps() const override { return 1; }
0680     void getDefaultColor(GfxColor *color) const override;
0681 
0682     bool isNonMarking() const override { return nonMarking; }
0683 
0684     // Separation-specific access.
0685     const GooString *getName() const { return name; }
0686     GfxColorSpace *getAlt() { return alt; }
0687     const Function *getFunc() const { return func; }
0688 
0689 private:
0690     GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA, Function *funcA, bool nonMarkingA, unsigned int overprintMaskA, int *mappingA);
0691 
0692     GooString *name; // colorant name
0693     GfxColorSpace *alt; // alternate color space
0694     Function *func; // tint transform (into alternate color space)
0695     bool nonMarking;
0696 };
0697 
0698 //------------------------------------------------------------------------
0699 // GfxDeviceNColorSpace
0700 //------------------------------------------------------------------------
0701 
0702 class GfxDeviceNColorSpace : public GfxColorSpace
0703 {
0704 public:
0705     GfxDeviceNColorSpace(int nCompsA, std::vector<std::string> &&namesA, GfxColorSpace *alt, Function *func, std::vector<GfxSeparationColorSpace *> *sepsCS);
0706     ~GfxDeviceNColorSpace() override;
0707     GfxColorSpace *copy() const override;
0708     GfxColorSpaceMode getMode() const override { return csDeviceN; }
0709 
0710     // Construct a DeviceN color space.  Returns nullptr if unsuccessful.
0711     static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
0712 
0713     void getGray(const GfxColor *color, GfxGray *gray) const override;
0714     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0715     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0716     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0717 
0718     void createMapping(std::vector<GfxSeparationColorSpace *> *separationList, int maxSepComps) override;
0719 
0720     int getNComps() const override { return nComps; }
0721     void getDefaultColor(GfxColor *color) const override;
0722 
0723     bool isNonMarking() const override { return nonMarking; }
0724 
0725     // DeviceN-specific access.
0726     const std::string &getColorantName(int i) const { return names[i]; }
0727     GfxColorSpace *getAlt() { return alt; }
0728     const Function *getTintTransformFunc() const { return func; }
0729 
0730 private:
0731     GfxDeviceNColorSpace(int nCompsA, const std::vector<std::string> &namesA, GfxColorSpace *alt, Function *func, std::vector<GfxSeparationColorSpace *> *sepsCSA, int *mappingA, bool nonMarkingA, unsigned int overprintMaskA);
0732 
0733     const int nComps; // number of components
0734     const std::vector<std::string> names; // colorant names
0735     GfxColorSpace *alt; // alternate color space
0736     Function *func; // tint transform (into alternate color space)
0737     bool nonMarking;
0738     std::vector<GfxSeparationColorSpace *> *sepsCS; // list of separation cs for spot colorants;
0739 };
0740 
0741 //------------------------------------------------------------------------
0742 // GfxPatternColorSpace
0743 //------------------------------------------------------------------------
0744 
0745 class GfxPatternColorSpace : public GfxColorSpace
0746 {
0747 public:
0748     explicit GfxPatternColorSpace(GfxColorSpace *underA);
0749     ~GfxPatternColorSpace() override;
0750     GfxColorSpace *copy() const override;
0751     GfxColorSpaceMode getMode() const override { return csPattern; }
0752 
0753     // Construct a Pattern color space.  Returns nullptr if unsuccessful.
0754     static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
0755 
0756     void getGray(const GfxColor *color, GfxGray *gray) const override;
0757     void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
0758     void getCMYK(const GfxColor *color, GfxCMYK *cmyk) const override;
0759     void getDeviceN(const GfxColor *color, GfxColor *deviceN) const override;
0760 
0761     int getNComps() const override { return 0; }
0762     void getDefaultColor(GfxColor *color) const override;
0763 
0764     // Pattern-specific access.
0765     GfxColorSpace *getUnder() { return under; }
0766 
0767 private:
0768     GfxColorSpace *under; // underlying color space (for uncolored
0769                           //   patterns)
0770 };
0771 
0772 //------------------------------------------------------------------------
0773 // GfxPattern
0774 //------------------------------------------------------------------------
0775 
0776 class GfxPattern
0777 {
0778 public:
0779     GfxPattern(int typeA, int patternRefNumA);
0780     virtual ~GfxPattern();
0781 
0782     GfxPattern(const GfxPattern &) = delete;
0783     GfxPattern &operator=(const GfxPattern &other) = delete;
0784 
0785     static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum);
0786 
0787     virtual GfxPattern *copy() const = 0;
0788 
0789     int getType() const { return type; }
0790 
0791     int getPatternRefNum() const { return patternRefNum; }
0792 
0793 private:
0794     int type;
0795     int patternRefNum;
0796 };
0797 
0798 //------------------------------------------------------------------------
0799 // GfxTilingPattern
0800 //------------------------------------------------------------------------
0801 
0802 class GfxTilingPattern : public GfxPattern
0803 {
0804 public:
0805     static GfxTilingPattern *parse(Object *patObj, int patternRefNum);
0806     ~GfxTilingPattern() override;
0807 
0808     GfxPattern *copy() const override;
0809 
0810     int getPaintType() const { return paintType; }
0811     int getTilingType() const { return tilingType; }
0812     const double *getBBox() const { return bbox; }
0813     double getXStep() const { return xStep; }
0814     double getYStep() const { return yStep; }
0815     Dict *getResDict() { return resDict.isDict() ? resDict.getDict() : (Dict *)nullptr; }
0816     const double *getMatrix() const { return matrix; }
0817     Object *getContentStream() { return &contentStream; }
0818 
0819 private:
0820     GfxTilingPattern(int paintTypeA, int tilingTypeA, const double *bboxA, double xStepA, double yStepA, const Object *resDictA, const double *matrixA, const Object *contentStreamA, int patternRefNumA);
0821 
0822     int paintType;
0823     int tilingType;
0824     double bbox[4];
0825     double xStep, yStep;
0826     Object resDict;
0827     double matrix[6];
0828     Object contentStream;
0829 };
0830 
0831 //------------------------------------------------------------------------
0832 // GfxShadingPattern
0833 //------------------------------------------------------------------------
0834 
0835 class GfxShadingPattern : public GfxPattern
0836 {
0837 public:
0838     static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum);
0839     ~GfxShadingPattern() override;
0840 
0841     GfxPattern *copy() const override;
0842 
0843     GfxShading *getShading() { return shading; }
0844     const double *getMatrix() const { return matrix; }
0845 
0846 private:
0847     GfxShadingPattern(GfxShading *shadingA, const double *matrixA, int patternRefNumA);
0848 
0849     GfxShading *shading;
0850     double matrix[6];
0851 };
0852 
0853 //------------------------------------------------------------------------
0854 // GfxShading
0855 //------------------------------------------------------------------------
0856 
0857 class POPPLER_PRIVATE_EXPORT GfxShading
0858 {
0859 public:
0860     explicit GfxShading(int typeA);
0861     explicit GfxShading(const GfxShading *shading);
0862     virtual ~GfxShading();
0863 
0864     GfxShading(const GfxShading &) = delete;
0865     GfxShading &operator=(const GfxShading &other) = delete;
0866 
0867     static GfxShading *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state);
0868 
0869     virtual GfxShading *copy() const = 0;
0870 
0871     int getType() const { return type; }
0872     GfxColorSpace *getColorSpace() { return colorSpace; }
0873     const GfxColor *getBackground() const { return &background; }
0874     bool getHasBackground() const { return hasBackground; }
0875     void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) const
0876     {
0877         *xMinA = bbox_xMin;
0878         *yMinA = bbox_yMin;
0879         *xMaxA = bbox_xMax;
0880         *yMaxA = bbox_yMax;
0881     }
0882     bool getHasBBox() const { return hasBBox; }
0883 
0884 protected:
0885     virtual bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
0886 
0887     // 1: Function-based shading
0888     // 2: Axial shading
0889     // 3: Radial shading
0890     // 4: Free-form Gouraud-shaded triangle mesh
0891     // 5: Lattice-form Gouraud-shaded triangle mesh
0892     // 6: Coons patch mesh
0893     // 7: Tensor-product patch mesh
0894     int type;
0895     bool hasBackground;
0896     bool hasBBox;
0897     GfxColorSpace *colorSpace;
0898     GfxColor background;
0899     double bbox_xMin, bbox_yMin, bbox_xMax, bbox_yMax;
0900 };
0901 
0902 //------------------------------------------------------------------------
0903 // GfxUnivariateShading
0904 //------------------------------------------------------------------------
0905 
0906 class POPPLER_PRIVATE_EXPORT GfxUnivariateShading : public GfxShading
0907 {
0908 public:
0909     GfxUnivariateShading(int typeA, double t0A, double t1A, std::vector<std::unique_ptr<Function>> &&funcsA, bool extend0A, bool extend1A);
0910     explicit GfxUnivariateShading(const GfxUnivariateShading *shading);
0911     ~GfxUnivariateShading() override;
0912 
0913     double getDomain0() const { return t0; }
0914     double getDomain1() const { return t1; }
0915     bool getExtend0() const { return extend0; }
0916     bool getExtend1() const { return extend1; }
0917     int getNFuncs() const { return funcs.size(); }
0918     const Function *getFunc(int i) const { return funcs[i].get(); }
0919     // returns the nComps of the shading
0920     // i.e. how many positions of color have been set
0921     int getColor(double t, GfxColor *color);
0922 
0923     void setupCache(const Matrix *ctm, double xMin, double yMin, double xMax, double yMax);
0924 
0925     virtual void getParameterRange(double *lower, double *upper, double xMin, double yMin, double xMax, double yMax) = 0;
0926 
0927     virtual double getDistance(double sMin, double sMax) const = 0;
0928 
0929 protected:
0930     bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
0931 
0932 private:
0933     double t0, t1;
0934     std::vector<std::unique_ptr<Function>> funcs;
0935     bool extend0, extend1;
0936 
0937     int cacheSize, lastMatch;
0938     double *cacheBounds;
0939     double *cacheCoeff;
0940     double *cacheValues;
0941 };
0942 
0943 //------------------------------------------------------------------------
0944 // GfxFunctionShading
0945 //------------------------------------------------------------------------
0946 
0947 class POPPLER_PRIVATE_EXPORT GfxFunctionShading : public GfxShading
0948 {
0949 public:
0950     GfxFunctionShading(double x0A, double y0A, double x1A, double y1A, const double *matrixA, std::vector<std::unique_ptr<Function>> &&funcsA);
0951     explicit GfxFunctionShading(const GfxFunctionShading *shading);
0952     ~GfxFunctionShading() override;
0953 
0954     static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
0955 
0956     GfxShading *copy() const override;
0957 
0958     void getDomain(double *x0A, double *y0A, double *x1A, double *y1A) const
0959     {
0960         *x0A = x0;
0961         *y0A = y0;
0962         *x1A = x1;
0963         *y1A = y1;
0964     }
0965     const double *getMatrix() const { return matrix; }
0966     int getNFuncs() const { return funcs.size(); }
0967     const Function *getFunc(int i) const { return funcs[i].get(); }
0968     void getColor(double x, double y, GfxColor *color) const;
0969 
0970 protected:
0971     bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
0972 
0973 private:
0974     double x0, y0, x1, y1;
0975     double matrix[6];
0976     std::vector<std::unique_ptr<Function>> funcs;
0977 };
0978 
0979 //------------------------------------------------------------------------
0980 // GfxAxialShading
0981 //------------------------------------------------------------------------
0982 
0983 class GfxAxialShading : public GfxUnivariateShading
0984 {
0985 public:
0986     GfxAxialShading(double x0A, double y0A, double x1A, double y1A, double t0A, double t1A, std::vector<std::unique_ptr<Function>> &&funcsA, bool extend0A, bool extend1A);
0987     explicit GfxAxialShading(const GfxAxialShading *shading);
0988     ~GfxAxialShading() override;
0989 
0990     static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
0991 
0992     GfxShading *copy() const override;
0993 
0994     void getCoords(double *x0A, double *y0A, double *x1A, double *y1A) const
0995     {
0996         *x0A = x0;
0997         *y0A = y0;
0998         *x1A = x1;
0999         *y1A = y1;
1000     }
1001 
1002     void getParameterRange(double *lower, double *upper, double xMin, double yMin, double xMax, double yMax) override;
1003 
1004     double getDistance(double sMin, double sMax) const override;
1005 
1006 private:
1007     double x0, y0, x1, y1;
1008 };
1009 
1010 //------------------------------------------------------------------------
1011 // GfxRadialShading
1012 //------------------------------------------------------------------------
1013 
1014 class GfxRadialShading : public GfxUnivariateShading
1015 {
1016 public:
1017     GfxRadialShading(double x0A, double y0A, double r0A, double x1A, double y1A, double r1A, double t0A, double t1A, std::vector<std::unique_ptr<Function>> &&funcsA, bool extend0A, bool extend1A);
1018     explicit GfxRadialShading(const GfxRadialShading *shading);
1019     ~GfxRadialShading() override;
1020 
1021     static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
1022 
1023     GfxShading *copy() const override;
1024 
1025     void getCoords(double *x0A, double *y0A, double *r0A, double *x1A, double *y1A, double *r1A) const
1026     {
1027         *x0A = x0;
1028         *y0A = y0;
1029         *r0A = r0;
1030         *x1A = x1;
1031         *y1A = y1;
1032         *r1A = r1;
1033     }
1034 
1035     void getParameterRange(double *lower, double *upper, double xMin, double yMin, double xMax, double yMax) override;
1036 
1037     double getDistance(double sMin, double sMax) const override;
1038 
1039 private:
1040     double x0, y0, r0, x1, y1, r1;
1041 };
1042 
1043 //------------------------------------------------------------------------
1044 // GfxGouraudTriangleShading
1045 //------------------------------------------------------------------------
1046 
1047 struct GfxGouraudVertex
1048 {
1049     double x, y;
1050     GfxColor color;
1051 };
1052 
1053 class POPPLER_PRIVATE_EXPORT GfxGouraudTriangleShading : public GfxShading
1054 {
1055 public:
1056     GfxGouraudTriangleShading(int typeA, GfxGouraudVertex *verticesA, int nVerticesA, int (*trianglesA)[3], int nTrianglesA, std::vector<std::unique_ptr<Function>> &&funcsA);
1057     explicit GfxGouraudTriangleShading(const GfxGouraudTriangleShading *shading);
1058     ~GfxGouraudTriangleShading() override;
1059 
1060     static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
1061 
1062     GfxShading *copy() const override;
1063 
1064     int getNTriangles() const { return nTriangles; }
1065 
1066     bool isParameterized() const { return !funcs.empty(); }
1067 
1068     /**
1069      * @precondition isParameterized() == true
1070      */
1071     double getParameterDomainMin() const
1072     {
1073         assert(isParameterized());
1074         return funcs[0]->getDomainMin(0);
1075     }
1076 
1077     /**
1078      * @precondition isParameterized() == true
1079      */
1080     double getParameterDomainMax() const
1081     {
1082         assert(isParameterized());
1083         return funcs[0]->getDomainMax(0);
1084     }
1085 
1086     /**
1087      * @precondition isParameterized() == false
1088      */
1089     void getTriangle(int i, double *x0, double *y0, GfxColor *color0, double *x1, double *y1, GfxColor *color1, double *x2, double *y2, GfxColor *color2);
1090 
1091     /**
1092      * Variant for functions.
1093      *
1094      * @precondition isParameterized() == true
1095      */
1096     void getTriangle(int i, double *x0, double *y0, double *color0, double *x1, double *y1, double *color1, double *x2, double *y2, double *color2);
1097 
1098     void getParameterizedColor(double t, GfxColor *color) const;
1099 
1100 protected:
1101     bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
1102 
1103 private:
1104     GfxGouraudVertex *vertices;
1105     int nVertices;
1106     int (*triangles)[3];
1107     int nTriangles;
1108     std::vector<std::unique_ptr<Function>> funcs;
1109 };
1110 
1111 //------------------------------------------------------------------------
1112 // GfxPatchMeshShading
1113 //------------------------------------------------------------------------
1114 
1115 /**
1116  * A tensor product cubic bezier patch consisting of 4x4 points and 4 color
1117  * values.
1118  *
1119  * See the Shading Type 7 specifications. Note that Shading Type 6 is also
1120  * represented using GfxPatch.
1121  */
1122 struct GfxPatch
1123 {
1124     /**
1125      * Represents a single color value for the patch.
1126      */
1127     struct ColorValue
1128     {
1129         /**
1130          * For parameterized patches, only element 0 is valid; it contains
1131          * the single parameter.
1132          *
1133          * For non-parameterized patches, c contains all color components
1134          * as decoded from the input stream. In this case, you will need to
1135          * use dblToCol() before assigning them to GfxColor.
1136          */
1137         double c[gfxColorMaxComps];
1138     };
1139 
1140     double x[4][4];
1141     double y[4][4];
1142     ColorValue color[2][2];
1143 };
1144 
1145 class POPPLER_PRIVATE_EXPORT GfxPatchMeshShading : public GfxShading
1146 {
1147 public:
1148     GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA, std::vector<std::unique_ptr<Function>> &&funcsA);
1149     explicit GfxPatchMeshShading(const GfxPatchMeshShading *shading);
1150     ~GfxPatchMeshShading() override;
1151 
1152     static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
1153 
1154     GfxShading *copy() const override;
1155 
1156     int getNPatches() const { return nPatches; }
1157     const GfxPatch *getPatch(int i) const { return &patches[i]; }
1158 
1159     bool isParameterized() const { return !funcs.empty(); }
1160 
1161     /**
1162      * @precondition isParameterized() == true
1163      */
1164     double getParameterDomainMin() const
1165     {
1166         assert(isParameterized());
1167         return funcs[0]->getDomainMin(0);
1168     }
1169 
1170     /**
1171      * @precondition isParameterized() == true
1172      */
1173     double getParameterDomainMax() const
1174     {
1175         assert(isParameterized());
1176         return funcs[0]->getDomainMax(0);
1177     }
1178 
1179     void getParameterizedColor(double t, GfxColor *color) const;
1180 
1181 protected:
1182     bool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) override;
1183 
1184 private:
1185     GfxPatch *patches;
1186     int nPatches;
1187     std::vector<std::unique_ptr<Function>> funcs;
1188 };
1189 
1190 //------------------------------------------------------------------------
1191 // GfxImageColorMap
1192 //------------------------------------------------------------------------
1193 
1194 class POPPLER_PRIVATE_EXPORT GfxImageColorMap
1195 {
1196 public:
1197     // Constructor.
1198     GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
1199 
1200     // Destructor.
1201     ~GfxImageColorMap();
1202 
1203     GfxImageColorMap(const GfxImageColorMap &) = delete;
1204     GfxImageColorMap &operator=(const GfxImageColorMap &) = delete;
1205 
1206     // Return a copy of this color map.
1207     GfxImageColorMap *copy() const { return new GfxImageColorMap(this); }
1208 
1209     // Is color map valid?
1210     bool isOk() const { return ok; }
1211 
1212     // Get the color space.
1213     GfxColorSpace *getColorSpace() { return colorSpace; }
1214 
1215     // Get stream decoding info.
1216     int getNumPixelComps() const { return nComps; }
1217     int getBits() const { return bits; }
1218 
1219     // Get decode table.
1220     double getDecodeLow(int i) const { return decodeLow[i]; }
1221     double getDecodeHigh(int i) const { return decodeLow[i] + decodeRange[i]; }
1222 
1223     bool useRGBLine() const { return (colorSpace2 && colorSpace2->useGetRGBLine()) || (!colorSpace2 && colorSpace->useGetRGBLine()); }
1224     bool useCMYKLine() const { return (colorSpace2 && colorSpace2->useGetCMYKLine()) || (!colorSpace2 && colorSpace->useGetCMYKLine()); }
1225     bool useDeviceNLine() const { return (colorSpace2 && colorSpace2->useGetDeviceNLine()) || (!colorSpace2 && colorSpace->useGetDeviceNLine()); }
1226 
1227     // Convert an image pixel to a color.
1228     void getGray(const unsigned char *x, GfxGray *gray);
1229     void getRGB(const unsigned char *x, GfxRGB *rgb);
1230     void getRGBLine(unsigned char *in, unsigned int *out, int length);
1231     void getRGBLine(unsigned char *in, unsigned char *out, int length);
1232     void getRGBXLine(unsigned char *in, unsigned char *out, int length);
1233     void getGrayLine(unsigned char *in, unsigned char *out, int length);
1234     void getCMYKLine(unsigned char *in, unsigned char *out, int length);
1235     void getDeviceNLine(unsigned char *in, unsigned char *out, int length);
1236     void getCMYK(const unsigned char *x, GfxCMYK *cmyk);
1237     void getDeviceN(const unsigned char *x, GfxColor *deviceN);
1238     void getColor(const unsigned char *x, GfxColor *color);
1239 
1240     // Matte color ops
1241     void setMatteColor(const GfxColor *color)
1242     {
1243         useMatte = true;
1244         matteColor = *color;
1245     }
1246     const GfxColor *getMatteColor() const { return (useMatte) ? &matteColor : nullptr; }
1247 
1248 private:
1249     explicit GfxImageColorMap(const GfxImageColorMap *colorMap);
1250 
1251     GfxColorSpace *colorSpace; // the image color space
1252     int bits; // bits per component
1253     int nComps; // number of components in a pixel
1254     GfxColorSpace *colorSpace2; // secondary color space
1255     int nComps2; // number of components in colorSpace2
1256     GfxColorComp * // lookup table
1257             lookup[gfxColorMaxComps];
1258     GfxColorComp * // optimized case lookup table
1259             lookup2[gfxColorMaxComps];
1260     unsigned char *byte_lookup;
1261     double // minimum values for each component
1262             decodeLow[gfxColorMaxComps];
1263     double // max - min value for each component
1264             decodeRange[gfxColorMaxComps];
1265     bool useMatte;
1266     GfxColor matteColor;
1267     bool ok;
1268 };
1269 
1270 //------------------------------------------------------------------------
1271 // GfxSubpath and GfxPath
1272 //------------------------------------------------------------------------
1273 
1274 class GfxSubpath
1275 {
1276 public:
1277     // Constructor.
1278     GfxSubpath(double x1, double y1);
1279 
1280     // Destructor.
1281     ~GfxSubpath();
1282 
1283     GfxSubpath(const GfxSubpath &) = delete;
1284     GfxSubpath &operator=(const GfxSubpath &) = delete;
1285 
1286     // Copy.
1287     GfxSubpath *copy() const { return new GfxSubpath(this); }
1288 
1289     // Get points.
1290     int getNumPoints() const { return n; }
1291     double getX(int i) const { return x[i]; }
1292     double getY(int i) const { return y[i]; }
1293     bool getCurve(int i) const { return curve[i]; }
1294 
1295     void setX(int i, double a) { x[i] = a; }
1296     void setY(int i, double a) { y[i] = a; }
1297 
1298     // Get last point.
1299     double getLastX() const { return x[n - 1]; }
1300     double getLastY() const { return y[n - 1]; }
1301 
1302     // Add a line segment.
1303     void lineTo(double x1, double y1);
1304 
1305     // Add a Bezier curve.
1306     void curveTo(double x1, double y1, double x2, double y2, double x3, double y3);
1307 
1308     // Close the subpath.
1309     void close();
1310     bool isClosed() const { return closed; }
1311 
1312     // Add (<dx>, <dy>) to each point in the subpath.
1313     void offset(double dx, double dy);
1314 
1315 private:
1316     double *x, *y; // points
1317     bool *curve; // curve[i] => point i is a control point
1318                  //   for a Bezier curve
1319     int n; // number of points
1320     int size; // size of x/y arrays
1321     bool closed; // set if path is closed
1322 
1323     explicit GfxSubpath(const GfxSubpath *subpath);
1324 };
1325 
1326 class POPPLER_PRIVATE_EXPORT GfxPath
1327 {
1328 public:
1329     // Constructor.
1330     GfxPath();
1331 
1332     // Destructor.
1333     ~GfxPath();
1334 
1335     GfxPath(const GfxPath &) = delete;
1336     GfxPath &operator=(const GfxPath &) = delete;
1337 
1338     // Copy.
1339     GfxPath *copy() const { return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
1340 
1341     // Is there a current point?
1342     bool isCurPt() const { return n > 0 || justMoved; }
1343 
1344     // Is the path non-empty, i.e., is there at least one segment?
1345     bool isPath() const { return n > 0; }
1346 
1347     // Get subpaths.
1348     int getNumSubpaths() const { return n; }
1349     GfxSubpath *getSubpath(int i) { return subpaths[i]; }
1350     const GfxSubpath *getSubpath(int i) const { return subpaths[i]; }
1351 
1352     // Get last point on last subpath.
1353     double getLastX() const { return subpaths[n - 1]->getLastX(); }
1354     double getLastY() const { return subpaths[n - 1]->getLastY(); }
1355 
1356     // Move the current point.
1357     void moveTo(double x, double y);
1358 
1359     // Add a segment to the last subpath.
1360     void lineTo(double x, double y);
1361 
1362     // Add a Bezier curve to the last subpath
1363     void curveTo(double x1, double y1, double x2, double y2, double x3, double y3);
1364 
1365     // Close the last subpath.
1366     void close();
1367 
1368     // Append <path> to <this>.
1369     void append(GfxPath *path);
1370 
1371     // Add (<dx>, <dy>) to each point in the path.
1372     void offset(double dx, double dy);
1373 
1374 private:
1375     bool justMoved; // set if a new subpath was just started
1376     double firstX, firstY; // first point in new subpath
1377     GfxSubpath **subpaths; // subpaths
1378     int n; // number of subpaths
1379     int size; // size of subpaths array
1380 
1381     GfxPath(bool justMoved1, double firstX1, double firstY1, GfxSubpath **subpaths1, int n1, int size1);
1382 };
1383 
1384 //------------------------------------------------------------------------
1385 // GfxState
1386 //------------------------------------------------------------------------
1387 
1388 class POPPLER_PRIVATE_EXPORT GfxState
1389 {
1390 public:
1391     /**
1392      * When GfxState::getReusablePath() is invoked, the currently active
1393      * path is taken per reference and its coordinates can be re-edited.
1394      *
1395      * A ReusablePathIterator is intended to reduce overhead when the same
1396      * path type is used a lot of times, only with different coordinates. It
1397      * allows just to update the coordinates (occurring in the same order as
1398      * in the original path).
1399      */
1400     class ReusablePathIterator
1401     {
1402     public:
1403         /**
1404          * Creates the ReusablePathIterator. This should only be done from
1405          * GfxState::getReusablePath().
1406          *
1407          * @param path the path as it is used so far. Changing this path,
1408          * deleting it or starting a new path from scratch will most likely
1409          * invalidate the iterator (and may cause serious problems). Make
1410          * sure the path's memory structure is not changed during the
1411          * lifetime of the ReusablePathIterator.
1412          */
1413         explicit ReusablePathIterator(GfxPath *path);
1414 
1415         /**
1416          * Returns true if and only if the current iterator position is
1417          * beyond the last valid point.
1418          *
1419          * A call to setCoord() will be undefined.
1420          */
1421         bool isEnd() const;
1422 
1423         /**
1424          * Advances the iterator.
1425          */
1426         void next();
1427 
1428         /**
1429          * Updates the coordinates associated to the current iterator
1430          * position.
1431          */
1432         void setCoord(double x, double y);
1433 
1434         /**
1435          * Resets the iterator.
1436          */
1437         void reset();
1438 
1439     private:
1440         GfxPath *path;
1441         int subPathOff;
1442 
1443         int coordOff;
1444         int numCoords;
1445 
1446         GfxSubpath *curSubPath;
1447     };
1448 
1449     // Construct a default GfxState, for a device with resolution <hDPI>
1450     // x <vDPI>, page box <pageBox>, page rotation <rotateA>, and
1451     // coordinate system specified by <upsideDown>.
1452     GfxState(double hDPIA, double vDPIA, const PDFRectangle *pageBox, int rotateA, bool upsideDown);
1453 
1454     // Destructor.
1455     ~GfxState();
1456 
1457     GfxState(const GfxState &) = delete;
1458     GfxState &operator=(const GfxState &) = delete;
1459 
1460     // Copy.
1461     GfxState *copy(bool copyPath = false) const { return new GfxState(this, copyPath); }
1462 
1463     // Accessors.
1464     double getHDPI() const { return hDPI; }
1465     double getVDPI() const { return vDPI; }
1466     const double *getCTM() const { return ctm; }
1467     void getCTM(Matrix *m) const { memcpy(m->m, ctm, sizeof m->m); }
1468     double getX1() const { return px1; }
1469     double getY1() const { return py1; }
1470     double getX2() const { return px2; }
1471     double getY2() const { return py2; }
1472     double getPageWidth() const { return pageWidth; }
1473     double getPageHeight() const { return pageHeight; }
1474     int getRotate() const { return rotate; }
1475     const GfxColor *getFillColor() const { return &fillColor; }
1476     const GfxColor *getStrokeColor() const { return &strokeColor; }
1477     void getFillGray(GfxGray *gray) { fillColorSpace->getGray(&fillColor, gray); }
1478     void getStrokeGray(GfxGray *gray) { strokeColorSpace->getGray(&strokeColor, gray); }
1479     void getFillRGB(GfxRGB *rgb) const { fillColorSpace->getRGB(&fillColor, rgb); }
1480     void getStrokeRGB(GfxRGB *rgb) const { strokeColorSpace->getRGB(&strokeColor, rgb); }
1481     void getFillCMYK(GfxCMYK *cmyk) { fillColorSpace->getCMYK(&fillColor, cmyk); }
1482     void getFillDeviceN(GfxColor *deviceN) { fillColorSpace->getDeviceN(&fillColor, deviceN); }
1483     void getStrokeCMYK(GfxCMYK *cmyk) { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
1484     void getStrokeDeviceN(GfxColor *deviceN) { strokeColorSpace->getDeviceN(&strokeColor, deviceN); }
1485     GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
1486     GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
1487     GfxPattern *getFillPattern() { return fillPattern; }
1488     GfxPattern *getStrokePattern() { return strokePattern; }
1489     GfxBlendMode getBlendMode() const { return blendMode; }
1490     double getFillOpacity() const { return fillOpacity; }
1491     double getStrokeOpacity() const { return strokeOpacity; }
1492     bool getFillOverprint() const { return fillOverprint; }
1493     bool getStrokeOverprint() const { return strokeOverprint; }
1494     int getOverprintMode() const { return overprintMode; }
1495     Function **getTransfer() { return transfer; }
1496     double getLineWidth() const { return lineWidth; }
1497     const std::vector<double> &getLineDash(double *start)
1498     {
1499         *start = lineDashStart;
1500         return lineDash;
1501     }
1502     int getFlatness() const { return flatness; }
1503     int getLineJoin() const { return lineJoin; }
1504     int getLineCap() const { return lineCap; }
1505     double getMiterLimit() const { return miterLimit; }
1506     bool getStrokeAdjust() const { return strokeAdjust; }
1507     bool getAlphaIsShape() const { return alphaIsShape; }
1508     bool getTextKnockout() const { return textKnockout; }
1509     const std::shared_ptr<GfxFont> &getFont() const { return font; }
1510     double getFontSize() const { return fontSize; }
1511     const double *getTextMat() const { return textMat; }
1512     double getCharSpace() const { return charSpace; }
1513     double getWordSpace() const { return wordSpace; }
1514     double getHorizScaling() const { return horizScaling; }
1515     double getLeading() const { return leading; }
1516     double getRise() const { return rise; }
1517     int getRender() const { return render; }
1518     const char *getRenderingIntent() const { return renderingIntent; }
1519     const GfxPath *getPath() const { return path; }
1520     void setPath(GfxPath *pathA);
1521     double getCurX() const { return curX; }
1522     double getCurY() const { return curY; }
1523     void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const
1524     {
1525         *xMin = clipXMin;
1526         *yMin = clipYMin;
1527         *xMax = clipXMax;
1528         *yMax = clipYMax;
1529     }
1530     void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax) const;
1531     double getLineX() const { return lineX; }
1532     double getLineY() const { return lineY; }
1533 
1534     // Is there a current point/path?
1535     bool isCurPt() const { return path->isCurPt(); }
1536     bool isPath() const { return path->isPath(); }
1537 
1538     // Transforms.
1539     void transform(double x1, double y1, double *x2, double *y2) const
1540     {
1541         *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
1542         *y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5];
1543     }
1544     void transformDelta(double x1, double y1, double *x2, double *y2) const
1545     {
1546         *x2 = ctm[0] * x1 + ctm[2] * y1;
1547         *y2 = ctm[1] * x1 + ctm[3] * y1;
1548     }
1549     void textTransform(double x1, double y1, double *x2, double *y2) const
1550     {
1551         *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
1552         *y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5];
1553     }
1554     void textTransformDelta(double x1, double y1, double *x2, double *y2) const
1555     {
1556         *x2 = textMat[0] * x1 + textMat[2] * y1;
1557         *y2 = textMat[1] * x1 + textMat[3] * y1;
1558     }
1559     double transformWidth(double w) const;
1560     double getTransformedLineWidth() const { return transformWidth(lineWidth); }
1561     double getTransformedFontSize() const;
1562     void getFontTransMat(double *m11, double *m12, double *m21, double *m22) const;
1563 
1564     // Change state parameters.
1565     void setCTM(double a, double b, double c, double d, double e, double f);
1566     void concatCTM(double a, double b, double c, double d, double e, double f);
1567     void shiftCTMAndClip(double tx, double ty);
1568     void setFillColorSpace(GfxColorSpace *colorSpace);
1569     void setStrokeColorSpace(GfxColorSpace *colorSpace);
1570     void setFillColor(const GfxColor *color) { fillColor = *color; }
1571     void setStrokeColor(const GfxColor *color) { strokeColor = *color; }
1572     void setFillPattern(GfxPattern *pattern);
1573     void setStrokePattern(GfxPattern *pattern);
1574     void setBlendMode(GfxBlendMode mode) { blendMode = mode; }
1575     void setFillOpacity(double opac) { fillOpacity = opac; }
1576     void setStrokeOpacity(double opac) { strokeOpacity = opac; }
1577     void setFillOverprint(bool op) { fillOverprint = op; }
1578     void setStrokeOverprint(bool op) { strokeOverprint = op; }
1579     void setOverprintMode(int op) { overprintMode = op; }
1580     void setTransfer(Function **funcs);
1581     void setLineWidth(double width) { lineWidth = width; }
1582     void setLineDash(std::vector<double> &&dash, double start);
1583     void setFlatness(int flatness1) { flatness = flatness1; }
1584     void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
1585     void setLineCap(int lineCap1) { lineCap = lineCap1; }
1586     void setMiterLimit(double limit) { miterLimit = limit; }
1587     void setStrokeAdjust(bool sa) { strokeAdjust = sa; }
1588     void setAlphaIsShape(bool ais) { alphaIsShape = ais; }
1589     void setTextKnockout(bool tk) { textKnockout = tk; }
1590     void setFont(std::shared_ptr<GfxFont> fontA, double fontSizeA);
1591     void setTextMat(double a, double b, double c, double d, double e, double f)
1592     {
1593         textMat[0] = a;
1594         textMat[1] = b;
1595         textMat[2] = c;
1596         textMat[3] = d;
1597         textMat[4] = e;
1598         textMat[5] = f;
1599     }
1600     void setCharSpace(double space) { charSpace = space; }
1601     void setWordSpace(double space) { wordSpace = space; }
1602     void setHorizScaling(double scale) { horizScaling = 0.01 * scale; }
1603     void setLeading(double leadingA) { leading = leadingA; }
1604     void setRise(double riseA) { rise = riseA; }
1605     void setRender(int renderA) { render = renderA; }
1606     void setRenderingIntent(const char *intent) { strncpy(renderingIntent, intent, 31); }
1607 
1608 #ifdef USE_CMS
1609     void setDisplayProfile(const GfxLCMSProfilePtr &localDisplayProfileA);
1610     GfxLCMSProfilePtr getDisplayProfile() { return localDisplayProfile; }
1611     std::shared_ptr<GfxColorTransform> getXYZ2DisplayTransform();
1612     int getCmsRenderingIntent();
1613     static GfxLCMSProfilePtr sRGBProfile;
1614 #endif
1615 
1616     void setDefaultGrayColorSpace(GfxColorSpace *cs) { defaultGrayColorSpace = cs; }
1617 
1618     void setDefaultRGBColorSpace(GfxColorSpace *cs) { defaultRGBColorSpace = cs; }
1619 
1620     void setDefaultCMYKColorSpace(GfxColorSpace *cs) { defaultCMYKColorSpace = cs; }
1621 
1622     GfxColorSpace *copyDefaultGrayColorSpace()
1623     {
1624         if (defaultGrayColorSpace) {
1625             return defaultGrayColorSpace->copy();
1626         }
1627         return new GfxDeviceGrayColorSpace();
1628     }
1629 
1630     GfxColorSpace *copyDefaultRGBColorSpace()
1631     {
1632         if (defaultRGBColorSpace) {
1633             return defaultRGBColorSpace->copy();
1634         }
1635         return new GfxDeviceRGBColorSpace();
1636     }
1637 
1638     GfxColorSpace *copyDefaultCMYKColorSpace()
1639     {
1640         if (defaultCMYKColorSpace) {
1641             return defaultCMYKColorSpace->copy();
1642         }
1643         return new GfxDeviceCMYKColorSpace();
1644     }
1645 
1646     // Add to path.
1647     void moveTo(double x, double y) { path->moveTo(curX = x, curY = y); }
1648     void lineTo(double x, double y) { path->lineTo(curX = x, curY = y); }
1649     void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
1650     void closePath()
1651     {
1652         path->close();
1653         curX = path->getLastX();
1654         curY = path->getLastY();
1655     }
1656     void clearPath();
1657 
1658     // Update clip region.
1659     void clip();
1660     void clipToStrokePath();
1661     void clipToRect(double xMin, double yMin, double xMax, double yMax);
1662 
1663     // Text position.
1664     void textSetPos(double tx, double ty)
1665     {
1666         lineX = tx;
1667         lineY = ty;
1668     }
1669     void textMoveTo(double tx, double ty)
1670     {
1671         lineX = tx;
1672         lineY = ty;
1673         textTransform(tx, ty, &curX, &curY);
1674     }
1675     void textShift(double tx, double ty);
1676     void shift(double dx, double dy);
1677 
1678     // Push/pop GfxState on/off stack.
1679     GfxState *save();
1680     GfxState *restore();
1681     bool hasSaves() const { return saved != nullptr; }
1682     bool isParentState(GfxState *state) { return saved == state || (saved && saved->isParentState(state)); }
1683 
1684     // Misc
1685     bool parseBlendMode(Object *obj, GfxBlendMode *mode);
1686 
1687     ReusablePathIterator *getReusablePath() { return new ReusablePathIterator(path); }
1688 
1689 private:
1690     double hDPI, vDPI; // resolution
1691     double ctm[6]; // coord transform matrix
1692     double px1, py1, px2, py2; // page corners (user coords)
1693     double pageWidth, pageHeight; // page size (pixels)
1694     int rotate; // page rotation angle
1695 
1696     GfxColorSpace *fillColorSpace; // fill color space
1697     GfxColorSpace *strokeColorSpace; // stroke color space
1698     GfxColor fillColor; // fill color
1699     GfxColor strokeColor; // stroke color
1700     GfxPattern *fillPattern; // fill pattern
1701     GfxPattern *strokePattern; // stroke pattern
1702     GfxBlendMode blendMode; // transparency blend mode
1703     double fillOpacity; // fill opacity
1704     double strokeOpacity; // stroke opacity
1705     bool fillOverprint; // fill overprint
1706     bool strokeOverprint; // stroke overprint
1707     int overprintMode; // overprint mode
1708     Function *transfer[4]; // transfer function (entries may be: all
1709                            //   nullptr = identity; last three nullptr =
1710                            //   single function; all four non-nullptr =
1711                            //   R,G,B,gray functions)
1712 
1713     double lineWidth; // line width
1714     std::vector<double> lineDash; // line dash
1715     double lineDashStart;
1716     int flatness; // curve flatness
1717     int lineJoin; // line join style
1718     int lineCap; // line cap style
1719     double miterLimit; // line miter limit
1720     bool strokeAdjust; // stroke adjustment
1721     bool alphaIsShape; // alpha is shape
1722     bool textKnockout; // text knockout
1723 
1724     std::shared_ptr<GfxFont> font; // font
1725     double fontSize; // font size
1726     double textMat[6]; // text matrix
1727     double charSpace; // character spacing
1728     double wordSpace; // word spacing
1729     double horizScaling; // horizontal scaling
1730     double leading; // text leading
1731     double rise; // text rise
1732     int render; // text rendering mode
1733 
1734     GfxPath *path; // array of path elements
1735     double curX, curY; // current point (user coords)
1736     double lineX, lineY; // start of current text line (text coords)
1737 
1738     double clipXMin, clipYMin, // bounding box for clip region
1739             clipXMax, clipYMax;
1740     char renderingIntent[32];
1741 
1742     GfxState *saved; // next GfxState on stack
1743 
1744     GfxState(const GfxState *state, bool copyPath);
1745 
1746 #ifdef USE_CMS
1747     GfxLCMSProfilePtr localDisplayProfile;
1748     std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformRelCol;
1749     std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformAbsCol;
1750     std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformSat;
1751     std::shared_ptr<GfxColorTransform> XYZ2DisplayTransformPerc;
1752     static GfxLCMSProfilePtr XYZProfile;
1753 #endif
1754 
1755     GfxColorSpace *defaultGrayColorSpace;
1756     GfxColorSpace *defaultRGBColorSpace;
1757     GfxColorSpace *defaultCMYKColorSpace;
1758 };
1759 
1760 #endif