#ifndef GFXSTATE_H
#define GFXSTATE_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
#include "Object.h"
#include "Function.h"
class Array;
class GfxFont;
class PDFRectangle;
class GfxShading;
enum GfxBlendMode {
gfxBlendNormal,
gfxBlendMultiply,
gfxBlendScreen,
gfxBlendOverlay,
gfxBlendDarken,
gfxBlendLighten,
gfxBlendColorDodge,
gfxBlendColorBurn,
gfxBlendHardLight,
gfxBlendSoftLight,
gfxBlendDifference,
gfxBlendExclusion,
gfxBlendHue,
gfxBlendSaturation,
gfxBlendColor,
gfxBlendLuminosity
};
typedef int GfxColorComp;
#define gfxColorComp1 0x10000
static inline GfxColorComp dblToCol(double x) {
return (GfxColorComp)(x * gfxColorComp1);
}
static inline double colToDbl(GfxColorComp x) {
return (double)x / (double)gfxColorComp1;
}
static inline GfxColorComp byteToCol(Guchar x) {
return (GfxColorComp)((x << 8) + x + (x >> 7));
}
static inline Guchar colToByte(GfxColorComp x) {
return (Guchar)(((x << 8) - x + 0x8000) >> 16);
}
#define gfxColorMaxComps funcMaxOutputs
struct GfxColor {
GfxColorComp c[gfxColorMaxComps];
};
typedef GfxColorComp GfxGray;
struct GfxRGB {
GfxColorComp r, g, b;
};
struct GfxCMYK {
GfxColorComp c, m, y, k;
};
enum GfxColorSpaceMode {
csDeviceGray,
csCalGray,
csDeviceRGB,
csCalRGB,
csDeviceCMYK,
csLab,
csICCBased,
csIndexed,
csSeparation,
csDeviceN,
csPattern
};
class GfxColorSpace {
public:
GfxColorSpace();
virtual ~GfxColorSpace();
virtual GfxColorSpace *copy() = 0;
virtual GfxColorSpaceMode getMode() = 0;
static GfxColorSpace *parse(Object *csObj);
virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0;
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0;
virtual int getNComps() = 0;
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
static int getNumColorSpaceModes();
static char *getColorSpaceModeName(int idx);
private:
};
class GfxDeviceGrayColorSpace: public GfxColorSpace {
public:
GfxDeviceGrayColorSpace();
virtual ~GfxDeviceGrayColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceGray; }
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 1; }
private:
};
class GfxCalGrayColorSpace: public GfxColorSpace {
public:
GfxCalGrayColorSpace();
virtual ~GfxCalGrayColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csCalGray; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 1; }
double getWhiteX() { return whiteX; }
double getWhiteY() { return whiteY; }
double getWhiteZ() { return whiteZ; }
double getBlackX() { return blackX; }
double getBlackY() { return blackY; }
double getBlackZ() { return blackZ; }
double getGamma() { return gamma; }
private:
double whiteX, whiteY, whiteZ; double blackX, blackY, blackZ; double gamma; };
class GfxDeviceRGBColorSpace: public GfxColorSpace {
public:
GfxDeviceRGBColorSpace();
virtual ~GfxDeviceRGBColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceRGB; }
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 3; }
private:
};
class GfxCalRGBColorSpace: public GfxColorSpace {
public:
GfxCalRGBColorSpace();
virtual ~GfxCalRGBColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csCalRGB; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 3; }
double getWhiteX() { return whiteX; }
double getWhiteY() { return whiteY; }
double getWhiteZ() { return whiteZ; }
double getBlackX() { return blackX; }
double getBlackY() { return blackY; }
double getBlackZ() { return blackZ; }
double getGammaR() { return gammaR; }
double getGammaG() { return gammaG; }
double getGammaB() { return gammaB; }
double *getMatrix() { return mat; }
private:
double whiteX, whiteY, whiteZ; double blackX, blackY, blackZ; double gammaR, gammaG, gammaB; double mat[9]; };
class GfxDeviceCMYKColorSpace: public GfxColorSpace {
public:
GfxDeviceCMYKColorSpace();
virtual ~GfxDeviceCMYKColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; }
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 4; }
private:
};
class GfxLabColorSpace: public GfxColorSpace {
public:
GfxLabColorSpace();
virtual ~GfxLabColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csLab; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 3; }
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
double getWhiteX() { return whiteX; }
double getWhiteY() { return whiteY; }
double getWhiteZ() { return whiteZ; }
double getBlackX() { return blackX; }
double getBlackY() { return blackY; }
double getBlackZ() { return blackZ; }
double getAMin() { return aMin; }
double getAMax() { return aMax; }
double getBMin() { return bMin; }
double getBMax() { return bMax; }
private:
double whiteX, whiteY, whiteZ; double blackX, blackY, blackZ; double aMin, aMax, bMin, bMax; double kr, kg, kb; };
class GfxICCBasedColorSpace: public GfxColorSpace {
public:
GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA,
Ref *iccProfileStreamA);
virtual ~GfxICCBasedColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csICCBased; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return nComps; }
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
GfxColorSpace *getAlt() { return alt; }
private:
int nComps; GfxColorSpace *alt; double rangeMin[4]; double rangeMax[4]; Ref iccProfileStream; };
class GfxIndexedColorSpace: public GfxColorSpace {
public:
GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
virtual ~GfxIndexedColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csIndexed; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 1; }
virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel);
GfxColorSpace *getBase() { return base; }
int getIndexHigh() { return indexHigh; }
Guchar *getLookup() { return lookup; }
GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor);
private:
GfxColorSpace *base; int indexHigh; Guchar *lookup; };
class GfxSeparationColorSpace: public GfxColorSpace {
public:
GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA,
Function *funcA);
virtual ~GfxSeparationColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csSeparation; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 1; }
GString *getName() { return name; }
GfxColorSpace *getAlt() { return alt; }
Function *getFunc() { return func; }
private:
GString *name; GfxColorSpace *alt; Function *func; };
class GfxDeviceNColorSpace: public GfxColorSpace {
public:
GfxDeviceNColorSpace(int nCompsA, GfxColorSpace *alt, Function *func);
virtual ~GfxDeviceNColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csDeviceN; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return nComps; }
GString *getColorantName(int i) { return names[i]; }
GfxColorSpace *getAlt() { return alt; }
Function *getTintTransformFunc() { return func; }
private:
int nComps; GString *names[gfxColorMaxComps];
GfxColorSpace *alt; Function *func; };
class GfxPatternColorSpace: public GfxColorSpace {
public:
GfxPatternColorSpace(GfxColorSpace *underA);
virtual ~GfxPatternColorSpace();
virtual GfxColorSpace *copy();
virtual GfxColorSpaceMode getMode() { return csPattern; }
static GfxColorSpace *parse(Array *arr);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
virtual int getNComps() { return 0; }
GfxColorSpace *getUnder() { return under; }
private:
GfxColorSpace *under; };
class GfxPattern {
public:
GfxPattern(int typeA);
virtual ~GfxPattern();
static GfxPattern *parse(Object *obj);
virtual GfxPattern *copy() = 0;
int getType() { return type; }
private:
int type;
};
class GfxTilingPattern: public GfxPattern {
public:
static GfxTilingPattern *parse(Object *patObj);
virtual ~GfxTilingPattern();
virtual GfxPattern *copy();
int getPaintType() { return paintType; }
int getTilingType() { return tilingType; }
double *getBBox() { return bbox; }
double getXStep() { return xStep; }
double getYStep() { return yStep; }
Dict *getResDict()
{ return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
double *getMatrix() { return matrix; }
Object *getContentStream() { return &contentStream; }
private:
GfxTilingPattern(int paintTypeA, int tilingTypeA,
double *bboxA, double xStepA, double yStepA,
Object *resDictA, double *matrixA,
Object *contentStreamA);
int paintType;
int tilingType;
double bbox[4];
double xStep, yStep;
Object resDict;
double matrix[6];
Object contentStream;
};
class GfxShadingPattern: public GfxPattern {
public:
static GfxShadingPattern *parse(Object *patObj);
virtual ~GfxShadingPattern();
virtual GfxPattern *copy();
GfxShading *getShading() { return shading; }
double *getMatrix() { return matrix; }
private:
GfxShadingPattern(GfxShading *shadingA, double *matrixA);
GfxShading *shading;
double matrix[6];
};
class GfxShading {
public:
GfxShading(int typeA);
GfxShading(GfxShading *shading);
virtual ~GfxShading();
static GfxShading *parse(Object *obj);
virtual GfxShading *copy() = 0;
int getType() { return type; }
GfxColorSpace *getColorSpace() { return colorSpace; }
GfxColor *getBackground() { return &background; }
GBool getHasBackground() { return hasBackground; }
void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
{ *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
GBool getHasBBox() { return hasBBox; }
protected:
GBool init(Dict *dict);
int type;
GfxColorSpace *colorSpace;
GfxColor background;
GBool hasBackground;
double xMin, yMin, xMax, yMax;
GBool hasBBox;
};
class GfxFunctionShading: public GfxShading {
public:
GfxFunctionShading(double x0A, double y0A,
double x1A, double y1A,
double *matrixA,
Function **funcsA, int nFuncsA);
GfxFunctionShading(GfxFunctionShading *shading);
virtual ~GfxFunctionShading();
static GfxFunctionShading *parse(Dict *dict);
virtual GfxShading *copy();
void getDomain(double *x0A, double *y0A, double *x1A, double *y1A)
{ *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
double *getMatrix() { return matrix; }
int getNFuncs() { return nFuncs; }
Function *getFunc(int i) { return funcs[i]; }
void getColor(double x, double y, GfxColor *color);
private:
double x0, y0, x1, y1;
double matrix[6];
Function *funcs[gfxColorMaxComps];
int nFuncs;
};
class GfxAxialShading: public GfxShading {
public:
GfxAxialShading(double x0A, double y0A,
double x1A, double y1A,
double t0A, double t1A,
Function **funcsA, int nFuncsA,
GBool extend0A, GBool extend1A);
GfxAxialShading(GfxAxialShading *shading);
virtual ~GfxAxialShading();
static GfxAxialShading *parse(Dict *dict);
virtual GfxShading *copy();
void getCoords(double *x0A, double *y0A, double *x1A, double *y1A)
{ *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
double getDomain0() { return t0; }
double getDomain1() { return t1; }
GBool getExtend0() { return extend0; }
GBool getExtend1() { return extend1; }
int getNFuncs() { return nFuncs; }
Function *getFunc(int i) { return funcs[i]; }
void getColor(double t, GfxColor *color);
private:
double x0, y0, x1, y1;
double t0, t1;
Function *funcs[gfxColorMaxComps];
int nFuncs;
GBool extend0, extend1;
};
class GfxRadialShading: public GfxShading {
public:
GfxRadialShading(double x0A, double y0A, double r0A,
double x1A, double y1A, double r1A,
double t0A, double t1A,
Function **funcsA, int nFuncsA,
GBool extend0A, GBool extend1A);
GfxRadialShading(GfxRadialShading *shading);
virtual ~GfxRadialShading();
static GfxRadialShading *parse(Dict *dict);
virtual GfxShading *copy();
void getCoords(double *x0A, double *y0A, double *r0A,
double *x1A, double *y1A, double *r1A)
{ *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
double getDomain0() { return t0; }
double getDomain1() { return t1; }
GBool getExtend0() { return extend0; }
GBool getExtend1() { return extend1; }
int getNFuncs() { return nFuncs; }
Function *getFunc(int i) { return funcs[i]; }
void getColor(double t, GfxColor *color);
private:
double x0, y0, r0, x1, y1, r1;
double t0, t1;
Function *funcs[gfxColorMaxComps];
int nFuncs;
GBool extend0, extend1;
};
struct GfxGouraudVertex {
double x, y;
GfxColor color;
};
class GfxGouraudTriangleShading: public GfxShading {
public:
GfxGouraudTriangleShading(int typeA,
GfxGouraudVertex *verticesA, int nVerticesA,
int (*trianglesA)[3], int nTrianglesA,
Function **funcsA, int nFuncsA);
GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading);
virtual ~GfxGouraudTriangleShading();
static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str);
virtual GfxShading *copy();
int getNTriangles() { return nTriangles; }
void getTriangle(int i, double *x0, double *y0, GfxColor *color0,
double *x1, double *y1, GfxColor *color1,
double *x2, double *y2, GfxColor *color2);
private:
GfxGouraudVertex *vertices;
int nVertices;
int (*triangles)[3];
int nTriangles;
Function *funcs[gfxColorMaxComps];
int nFuncs;
};
struct GfxPatch {
double x[4][4];
double y[4][4];
GfxColor color[2][2];
};
class GfxPatchMeshShading: public GfxShading {
public:
GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA,
Function **funcsA, int nFuncsA);
GfxPatchMeshShading(GfxPatchMeshShading *shading);
virtual ~GfxPatchMeshShading();
static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str);
virtual GfxShading *copy();
int getNPatches() { return nPatches; }
GfxPatch *getPatch(int i) { return &patches[i]; }
private:
GfxPatch *patches;
int nPatches;
Function *funcs[gfxColorMaxComps];
int nFuncs;
};
class GfxImageColorMap {
public:
GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA);
~GfxImageColorMap();
GfxImageColorMap *copy() { return new GfxImageColorMap(this); }
GBool isOk() { return ok; }
GfxColorSpace *getColorSpace() { return colorSpace; }
int getNumPixelComps() { return nComps; }
int getBits() { return bits; }
double getDecodeLow(int i) { return decodeLow[i]; }
double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
void getGray(Guchar *x, GfxGray *gray);
void getRGB(Guchar *x, GfxRGB *rgb);
void getCMYK(Guchar *x, GfxCMYK *cmyk);
void getColor(Guchar *x, GfxColor *color);
private:
GfxImageColorMap(GfxImageColorMap *colorMap);
GfxColorSpace *colorSpace; int bits; int nComps; GfxColorSpace *colorSpace2; int nComps2; GfxColorComp * lookup[gfxColorMaxComps];
double decodeLow[gfxColorMaxComps];
double decodeRange[gfxColorMaxComps];
GBool ok;
};
class GfxSubpath {
public:
GfxSubpath(double x1, double y1);
~GfxSubpath();
GfxSubpath *copy() { return new GfxSubpath(this); }
int getNumPoints() { return n; }
double getX(int i) { return x[i]; }
double getY(int i) { return y[i]; }
GBool getCurve(int i) { return curve[i]; }
double getLastX() { return x[n-1]; }
double getLastY() { return y[n-1]; }
void lineTo(double x1, double y1);
void curveTo(double x1, double y1, double x2, double y2,
double x3, double y3);
void close();
GBool isClosed() { return closed; }
void offset(double dx, double dy);
private:
double *x, *y; GBool *curve; int n; int size; GBool closed;
GfxSubpath(GfxSubpath *subpath);
};
class GfxPath {
public:
GfxPath();
~GfxPath();
GfxPath *copy()
{ return new GfxPath(justMoved, firstX, firstY, subpaths, n, size); }
GBool isCurPt() { return n > 0 || justMoved; }
GBool isPath() { return n > 0; }
int getNumSubpaths() { return n; }
GfxSubpath *getSubpath(int i) { return subpaths[i]; }
double getLastX() { return subpaths[n-1]->getLastX(); }
double getLastY() { return subpaths[n-1]->getLastY(); }
void moveTo(double x, double y);
void lineTo(double x, double y);
void curveTo(double x1, double y1, double x2, double y2,
double x3, double y3);
void close();
void append(GfxPath *path);
void offset(double dx, double dy);
private:
GBool justMoved; double firstX, firstY; GfxSubpath **subpaths; int n; int size;
GfxPath(GBool justMoved1, double firstX1, double firstY1,
GfxSubpath **subpaths1, int n1, int size1);
};
class GfxState {
public:
GfxState(double hDPI, double vDPI, PDFRectangle *pageBox,
int rotateA, GBool upsideDown);
~GfxState();
GfxState *copy() { return new GfxState(this); }
double *getCTM() { return ctm; }
double getX1() { return px1; }
double getY1() { return py1; }
double getX2() { return px2; }
double getY2() { return py2; }
double getPageWidth() { return pageWidth; }
double getPageHeight() { return pageHeight; }
int getRotate() { return rotate; }
GfxColor *getFillColor() { return &fillColor; }
GfxColor *getStrokeColor() { return &strokeColor; }
void getFillGray(GfxGray *gray)
{ fillColorSpace->getGray(&fillColor, gray); }
void getStrokeGray(GfxGray *gray)
{ strokeColorSpace->getGray(&strokeColor, gray); }
void getFillRGB(GfxRGB *rgb)
{ fillColorSpace->getRGB(&fillColor, rgb); }
void getStrokeRGB(GfxRGB *rgb)
{ strokeColorSpace->getRGB(&strokeColor, rgb); }
void getFillCMYK(GfxCMYK *cmyk)
{ fillColorSpace->getCMYK(&fillColor, cmyk); }
void getStrokeCMYK(GfxCMYK *cmyk)
{ strokeColorSpace->getCMYK(&strokeColor, cmyk); }
GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
GfxPattern *getFillPattern() { return fillPattern; }
GfxPattern *getStrokePattern() { return strokePattern; }
GfxBlendMode getBlendMode() { return blendMode; }
double getFillOpacity() { return fillOpacity; }
double getStrokeOpacity() { return strokeOpacity; }
GBool getFillOverprint() { return fillOverprint; }
GBool getStrokeOverprint() { return strokeOverprint; }
double getLineWidth() { return lineWidth; }
void getLineDash(double **dash, int *length, double *start)
{ *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
int getFlatness() { return flatness; }
int getLineJoin() { return lineJoin; }
int getLineCap() { return lineCap; }
double getMiterLimit() { return miterLimit; }
GfxFont *getFont() { return font; }
double getFontSize() { return fontSize; }
double *getTextMat() { return textMat; }
double getCharSpace() { return charSpace; }
double getWordSpace() { return wordSpace; }
double getHorizScaling() { return horizScaling; }
double getLeading() { return leading; }
double getRise() { return rise; }
int getRender() { return render; }
GfxPath *getPath() { return path; }
void setPath(GfxPath *pathA);
double getCurX() { return curX; }
double getCurY() { return curY; }
void getClipBBox(double *xMin, double *yMin, double *xMax, double *yMax)
{ *xMin = clipXMin; *yMin = clipYMin; *xMax = clipXMax; *yMax = clipYMax; }
void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax);
double getLineX() { return lineX; }
double getLineY() { return lineY; }
GBool isCurPt() { return path->isCurPt(); }
GBool isPath() { return path->isPath(); }
void transform(double x1, double y1, double *x2, double *y2)
{ *x2 = ctm[0] * x1 + ctm[2] * y1 + ctm[4];
*y2 = ctm[1] * x1 + ctm[3] * y1 + ctm[5]; }
void transformDelta(double x1, double y1, double *x2, double *y2)
{ *x2 = ctm[0] * x1 + ctm[2] * y1;
*y2 = ctm[1] * x1 + ctm[3] * y1; }
void textTransform(double x1, double y1, double *x2, double *y2)
{ *x2 = textMat[0] * x1 + textMat[2] * y1 + textMat[4];
*y2 = textMat[1] * x1 + textMat[3] * y1 + textMat[5]; }
void textTransformDelta(double x1, double y1, double *x2, double *y2)
{ *x2 = textMat[0] * x1 + textMat[2] * y1;
*y2 = textMat[1] * x1 + textMat[3] * y1; }
double transformWidth(double w);
double getTransformedLineWidth()
{ return transformWidth(lineWidth); }
double getTransformedFontSize();
void getFontTransMat(double *m11, double *m12, double *m21, double *m22);
void setCTM(double a, double b, double c,
double d, double e, double f);
void concatCTM(double a, double b, double c,
double d, double e, double f);
void setFillColorSpace(GfxColorSpace *colorSpace);
void setStrokeColorSpace(GfxColorSpace *colorSpace);
void setFillColor(GfxColor *color) { fillColor = *color; }
void setStrokeColor(GfxColor *color) { strokeColor = *color; }
void setFillPattern(GfxPattern *pattern);
void setStrokePattern(GfxPattern *pattern);
void setBlendMode(GfxBlendMode mode) { blendMode = mode; }
void setFillOpacity(double opac) { fillOpacity = opac; }
void setStrokeOpacity(double opac) { strokeOpacity = opac; }
void setFillOverprint(GBool op) { fillOverprint = op; }
void setStrokeOverprint(GBool op) { strokeOverprint = op; }
void setLineWidth(double width) { lineWidth = width; }
void setLineDash(double *dash, int length, double start);
void setFlatness(int flatness1) { flatness = flatness1; }
void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
void setLineCap(int lineCap1) { lineCap = lineCap1; }
void setMiterLimit(double limit) { miterLimit = limit; }
void setFont(GfxFont *fontA, double fontSizeA)
{ font = fontA; fontSize = fontSizeA; }
void setTextMat(double a, double b, double c,
double d, double e, double f)
{ textMat[0] = a; textMat[1] = b; textMat[2] = c;
textMat[3] = d; textMat[4] = e; textMat[5] = f; }
void setCharSpace(double space)
{ charSpace = space; }
void setWordSpace(double space)
{ wordSpace = space; }
void setHorizScaling(double scale)
{ horizScaling = 0.01 * scale; }
void setLeading(double leadingA)
{ leading = leadingA; }
void setRise(double riseA)
{ rise = riseA; }
void setRender(int renderA)
{ render = renderA; }
void moveTo(double x, double y)
{ path->moveTo(curX = x, curY = y); }
void lineTo(double x, double y)
{ path->lineTo(curX = x, curY = y); }
void curveTo(double x1, double y1, double x2, double y2,
double x3, double y3)
{ path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); }
void closePath()
{ path->close(); curX = path->getLastX(); curY = path->getLastY(); }
void clearPath();
void clip();
void textSetPos(double tx, double ty) { lineX = tx; lineY = ty; }
void textMoveTo(double tx, double ty)
{ lineX = tx; lineY = ty; textTransform(tx, ty, &curX, &curY); }
void textShift(double tx, double ty);
void shift(double dx, double dy);
GfxState *save();
GfxState *restore();
GBool hasSaves() { return saved != NULL; }
GBool parseBlendMode(Object *obj, GfxBlendMode *mode);
private:
double ctm[6]; double px1, py1, px2, py2; double pageWidth, pageHeight; int rotate;
GfxColorSpace *fillColorSpace; GfxColorSpace *strokeColorSpace; GfxColor fillColor; GfxColor strokeColor; GfxPattern *fillPattern; GfxPattern *strokePattern; GfxBlendMode blendMode; double fillOpacity; double strokeOpacity; GBool fillOverprint; GBool strokeOverprint;
double lineWidth; double *lineDash; int lineDashLength;
double lineDashStart;
int flatness; int lineJoin; int lineCap; double miterLimit;
GfxFont *font; double fontSize; double textMat[6]; double charSpace; double wordSpace; double horizScaling; double leading; double rise; int render;
GfxPath *path; double curX, curY; double lineX, lineY;
double clipXMin, clipYMin, clipXMax, clipYMax;
GfxState *saved;
GfxState(GfxState *state);
};
#endif