X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fxpdf%2FGfxState.h;h=e1d68013dfcaab6766eab8fd711d44180f677f12;hb=1ab98ed6db3874c0a9ab243f2efd05bf39066eda;hp=2056c4d1fb36f6f110a82fbb08d103f3e3e64e4e;hpb=fc554a43712b76d16b41ec77dd311b4a78b1ef6b;p=swftools.git diff --git a/pdf2swf/xpdf/GfxState.h b/pdf2swf/xpdf/GfxState.h index 2056c4d..e1d6801 100644 --- a/pdf2swf/xpdf/GfxState.h +++ b/pdf2swf/xpdf/GfxState.h @@ -2,40 +2,103 @@ // // GfxState.h // -// Copyright 1996 Derek B. Noonburg +// Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== #ifndef GFXSTATE_H #define GFXSTATE_H -#ifdef __GNUC__ +#include + +#ifdef USE_GCC_PRAGMAS #pragma interface #endif #include "gtypes.h" #include "Object.h" +#include "Function.h" class Array; -class Function; class GfxFont; +class PDFRectangle; +class GfxShading; + +//------------------------------------------------------------------------ +// GfxBlendMode +//------------------------------------------------------------------------ + +enum GfxBlendMode { + gfxBlendNormal, + gfxBlendMultiply, + gfxBlendScreen, + gfxBlendOverlay, + gfxBlendDarken, + gfxBlendLighten, + gfxBlendColorDodge, + gfxBlendColorBurn, + gfxBlendHardLight, + gfxBlendSoftLight, + gfxBlendDifference, + gfxBlendExclusion, + gfxBlendHue, + gfxBlendSaturation, + gfxBlendColor, + gfxBlendLuminosity +}; + +//------------------------------------------------------------------------ +// GfxColorComp +//------------------------------------------------------------------------ + +// 16.16 fixed point color component +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) { + // (x / 255) << 16 = (0.0000000100000001... * x) << 16 + // = ((x << 8) + (x) + (x >> 8) + ...) << 16 + // = (x << 8) + (x) + (x >> 7) + // [for rounding] + return (GfxColorComp)((x << 8) + x + (x >> 7)); +} + +static inline Guchar colToByte(GfxColorComp x) { + // 255 * x + 0.5 = 256 * x - x + 0x8000 + return (Guchar)(((x << 8) - x + 0x8000) >> 16); +} //------------------------------------------------------------------------ // GfxColor //------------------------------------------------------------------------ -#define gfxColorMaxComps 8 +#define gfxColorMaxComps funcMaxOutputs struct GfxColor { - double c[gfxColorMaxComps]; + GfxColorComp c[gfxColorMaxComps]; }; //------------------------------------------------------------------------ +// GfxGray +//------------------------------------------------------------------------ + +typedef GfxColorComp GfxGray; + +//------------------------------------------------------------------------ // GfxRGB //------------------------------------------------------------------------ struct GfxRGB { - double r, g, b; + GfxColorComp r, g, b; }; //------------------------------------------------------------------------ @@ -43,13 +106,15 @@ struct GfxRGB { //------------------------------------------------------------------------ struct GfxCMYK { - double c, m, y, k; + GfxColorComp c, m, y, k; }; //------------------------------------------------------------------------ // GfxColorSpace //------------------------------------------------------------------------ +// NB: The nGfxColorSpaceModes constant and the gfxColorSpaceModeNames +// array defined in GfxState.cc must match this enum. enum GfxColorSpaceMode { csDeviceGray, csCalGray, @@ -76,7 +141,7 @@ public: static GfxColorSpace *parse(Object *csObj); // Convert to gray, RGB, or CMYK. - virtual void getGray(GfxColor *color, double *gray) = 0; + virtual void getGray(GfxColor *color, GfxGray *gray) = 0; virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0; virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0; @@ -88,6 +153,12 @@ public: virtual void getDefaultRanges(double *decodeLow, double *decodeRange, int maxImgPixel); + // Return the number of color space modes + static int getNumColorSpaceModes(); + + // Return the name of the th color space mode. + static char *getColorSpaceModeName(int idx); + private: }; @@ -103,7 +174,7 @@ public: virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csDeviceGray; } - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -127,7 +198,7 @@ public: // Construct a CalGray color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -161,7 +232,7 @@ public: virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csDeviceRGB; } - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -185,7 +256,7 @@ public: // Construct a CalRGB color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -201,14 +272,14 @@ public: double getGammaR() { return gammaR; } double getGammaG() { return gammaG; } double getGammaB() { return gammaB; } - double *getMatrix() { return m; } + double *getMatrix() { return mat; } private: double whiteX, whiteY, whiteZ; // white point double blackX, blackY, blackZ; // black point double gammaR, gammaG, gammaB; // gamma values - double m[9]; // ABC -> XYZ transform matrix + double mat[9]; // ABC -> XYZ transform matrix }; //------------------------------------------------------------------------ @@ -223,7 +294,7 @@ public: virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; } - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -247,7 +318,7 @@ public: // Construct a Lab color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -283,8 +354,8 @@ private: class GfxICCBasedColorSpace: public GfxColorSpace { public: - GfxICCBasedColorSpace(int nComps, GfxColorSpace *alt, - Ref *iccProfileStream); + GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA, + Ref *iccProfileStreamA); virtual ~GfxICCBasedColorSpace(); virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csICCBased; } @@ -292,7 +363,7 @@ public: // Construct an ICCBased color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -320,7 +391,7 @@ private: class GfxIndexedColorSpace: public GfxColorSpace { public: - GfxIndexedColorSpace(GfxColorSpace *base, int indexHigh); + GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA); virtual ~GfxIndexedColorSpace(); virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csIndexed; } @@ -328,7 +399,7 @@ public: // Construct a Lab color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -341,6 +412,7 @@ public: GfxColorSpace *getBase() { return base; } int getIndexHigh() { return indexHigh; } Guchar *getLookup() { return lookup; } + GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor); private: @@ -356,8 +428,8 @@ private: class GfxSeparationColorSpace: public GfxColorSpace { public: - GfxSeparationColorSpace(GString *name, GfxColorSpace *alt, - Function *func); + GfxSeparationColorSpace(GString *nameA, GfxColorSpace *altA, + Function *funcA); virtual ~GfxSeparationColorSpace(); virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csSeparation; } @@ -365,7 +437,7 @@ public: // Construct a Separation color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -390,7 +462,7 @@ private: class GfxDeviceNColorSpace: public GfxColorSpace { public: - GfxDeviceNColorSpace(int nComps, GfxColorSpace *alt, Function *func); + GfxDeviceNColorSpace(int nCompsA, GfxColorSpace *alt, Function *func); virtual ~GfxDeviceNColorSpace(); virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csDeviceN; } @@ -398,14 +470,16 @@ public: // Construct a DeviceN color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + 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; } // DeviceN-specific access. + GString *getColorantName(int i) { return names[i]; } GfxColorSpace *getAlt() { return alt; } + Function *getTintTransformFunc() { return func; } private: @@ -414,7 +488,6 @@ private: *names[gfxColorMaxComps]; GfxColorSpace *alt; // alternate color space Function *func; // tint transform (into alternate color space) - }; //------------------------------------------------------------------------ @@ -424,7 +497,7 @@ private: class GfxPatternColorSpace: public GfxColorSpace { public: - GfxPatternColorSpace(GfxColorSpace *under); + GfxPatternColorSpace(GfxColorSpace *underA); virtual ~GfxPatternColorSpace(); virtual GfxColorSpace *copy(); virtual GfxColorSpaceMode getMode() { return csPattern; } @@ -432,7 +505,7 @@ public: // Construct a Pattern color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr); - virtual void getGray(GfxColor *color, double *gray); + virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); @@ -454,7 +527,7 @@ private: class GfxPattern { public: - GfxPattern(int type); + GfxPattern(int typeA); virtual ~GfxPattern(); static GfxPattern *parse(Object *obj); @@ -475,7 +548,7 @@ private: class GfxTilingPattern: public GfxPattern { public: - GfxTilingPattern(Dict *streamDict, Object *stream); + static GfxTilingPattern *parse(Object *patObj); virtual ~GfxTilingPattern(); virtual GfxPattern *copy(); @@ -492,7 +565,10 @@ public: private: - GfxTilingPattern(GfxTilingPattern *pat); + GfxTilingPattern(int paintTypeA, int tilingTypeA, + double *bboxA, double xStepA, double yStepA, + Object *resDictA, double *matrixA, + Object *contentStreamA); int paintType; int tilingType; @@ -504,94 +580,242 @@ private: }; //------------------------------------------------------------------------ -// Function +// GfxShadingPattern //------------------------------------------------------------------------ -#define funcMaxInputs 1 -#define funcMaxOutputs 8 +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]; +}; + +//------------------------------------------------------------------------ +// GfxShading +//------------------------------------------------------------------------ -class Function { +class GfxShading { public: - Function(); + GfxShading(int typeA); + GfxShading(GfxShading *shading); + virtual ~GfxShading(); - virtual ~Function(); + static GfxShading *parse(Object *obj); - // Construct a function. Returns NULL if unsuccessful. - static Function *parse(Object *funcObj); + 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: - // Initialize the entries common to all function types. GBool init(Dict *dict); - virtual Function *copy() = 0; + int type; + GfxColorSpace *colorSpace; + GfxColor background; + GBool hasBackground; + double xMin, yMin, xMax, yMax; + GBool hasBBox; +}; + +//------------------------------------------------------------------------ +// GfxFunctionShading +//------------------------------------------------------------------------ - // Return size of input and output tuples. - int getInputSize() { return m; } - int getOutputSize() { return n; } +class GfxFunctionShading: public GfxShading { +public: - // Transform an input tuple into an output tuple. - virtual void transform(double *in, double *out) = 0; + GfxFunctionShading(double x0A, double y0A, + double x1A, double y1A, + double *matrixA, + Function **funcsA, int nFuncsA); + GfxFunctionShading(GfxFunctionShading *shading); + virtual ~GfxFunctionShading(); - virtual GBool isOk() = 0; + static GfxFunctionShading *parse(Dict *dict); -protected: + virtual GfxShading *copy(); - int m, n; // size of input and output tuples - double // min and max values for function domain - domain[funcMaxInputs][2]; - double // min and max values for function range - range[funcMaxOutputs][2]; - GBool hasRange; // set if range is defined + 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; }; //------------------------------------------------------------------------ -// SampledFunction +// GfxAxialShading //------------------------------------------------------------------------ -class SampledFunction: public Function { +class GfxAxialShading: public GfxShading { public: - SampledFunction(Object *funcObj, Dict *dict); - virtual ~SampledFunction(); - virtual Function *copy() { return new SampledFunction(this); } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return ok; } + 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: - SampledFunction(SampledFunction *func); + double x0, y0, x1, y1; + double t0, t1; + Function *funcs[gfxColorMaxComps]; + int nFuncs; + GBool extend0, extend1; +}; - int // number of samples for each domain element - sampleSize[funcMaxInputs]; - double // min and max values for domain encoder - encode[funcMaxInputs][2]; - double // min and max values for range decoder - decode[funcMaxOutputs][2]; - double *samples; // the samples - GBool ok; +//------------------------------------------------------------------------ +// GfxRadialShading +//------------------------------------------------------------------------ + +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; }; //------------------------------------------------------------------------ -// ExponentialFunction +// GfxGouraudTriangleShading //------------------------------------------------------------------------ -class ExponentialFunction: public Function { +struct GfxGouraudVertex { + double x, y; + GfxColor color; +}; + +class GfxGouraudTriangleShading: public GfxShading { public: - ExponentialFunction(Object *funcObj, Dict *dict); - virtual ~ExponentialFunction(); - virtual Function *copy() { return new ExponentialFunction(this); } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return ok; } + 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: - ExponentialFunction(ExponentialFunction *func); + GfxGouraudVertex *vertices; + int nVertices; + int (*triangles)[3]; + int nTriangles; + Function *funcs[gfxColorMaxComps]; + int nFuncs; +}; - double c0[funcMaxOutputs]; - double c1[funcMaxOutputs]; - double e; - GBool ok; +//------------------------------------------------------------------------ +// GfxPatchMeshShading +//------------------------------------------------------------------------ + +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; }; //------------------------------------------------------------------------ @@ -602,11 +826,14 @@ class GfxImageColorMap { public: // Constructor. - GfxImageColorMap(int bits, Object *decode, GfxColorSpace *colorSpace); + GfxImageColorMap(int bitsA, Object *decode, GfxColorSpace *colorSpaceA); // Destructor. ~GfxImageColorMap(); + // Return a copy of this color map. + GfxImageColorMap *copy() { return new GfxImageColorMap(this); } + // Is color map valid? GBool isOk() { return ok; } @@ -622,18 +849,22 @@ public: double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; } // Convert an image pixel to a color. - void getGray(Guchar *x, double *gray); + 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; // the image color space int bits; // bits per component int nComps; // number of components in a pixel GfxColorSpace *colorSpace2; // secondary color space int nComps2; // number of components in colorSpace2 - double *lookup; // lookup table + GfxColorComp * // lookup table + lookup[gfxColorMaxComps]; double // minimum values for each component decodeLow[gfxColorMaxComps]; double // max - min value for each component @@ -678,6 +909,9 @@ public: void close(); GBool isClosed() { return closed; } + // Add (, ) to each point in the subpath. + void offset(double dx, double dy); + private: double *x, *y; // points @@ -728,7 +962,13 @@ public: double x3, double y3); // Close the last subpath. - void close() { subpaths[n-1]->close(); } + void close(); + + // Append to . + void append(GfxPath *path); + + // Add (, ) to each point in the path. + void offset(double dx, double dy); private: @@ -749,11 +989,11 @@ private: class GfxState { public: - // Construct a default GfxState, for a device with resolution , - // page box (,)-(,), page rotation , and + // Construct a default GfxState, for a device with resolution + // x , page box , page rotation , and // coordinate system specified by . - GfxState(double dpi, double px1a, double py1a, - double px2a, double py2a, int rotate, GBool upsideDown); + GfxState(double hDPI, double vDPI, PDFRectangle *pageBox, + int rotateA, GBool upsideDown); // Destructor. ~GfxState(); @@ -769,8 +1009,13 @@ public: 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) @@ -783,8 +1028,11 @@ public: 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; } @@ -802,8 +1050,12 @@ public: 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; } @@ -841,16 +1093,19 @@ public: 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 miterLimit1) { miterLimit = miterLimit1; } - void setFont(GfxFont *font1, double fontSize1) - { font = font1; fontSize = fontSize1; } + 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; @@ -861,12 +1116,12 @@ public: { wordSpace = space; } void setHorizScaling(double scale) { horizScaling = 0.01 * scale; } - void setLeading(double leading1) - { leading = leading1; } - void setRise(double rise1) - { rise = rise1; } - void setRender(int render1) - { render = render1; } + void setLeading(double leadingA) + { leading = leadingA; } + void setRise(double riseA) + { rise = riseA; } + void setRender(int renderA) + { render = renderA; } // Add to path. void moveTo(double x, double y) @@ -880,22 +1135,30 @@ public: { path->close(); curX = path->getLastX(); curY = path->getLastY(); } void clearPath(); + // Update clip region. + void clip(); + // Text position. + 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); void textShift(double tx, double ty); + void shift(double dx, double dy); // Push/pop GfxState on/off stack. GfxState *save(); GfxState *restore(); GBool hasSaves() { return saved != NULL; } + // Misc + GBool parseBlendMode(Object *obj, GfxBlendMode *mode); + private: double ctm[6]; // coord transform matrix double px1, py1, px2, py2; // page corners (user coords) double pageWidth, pageHeight; // page size (pixels) + int rotate; // page rotation angle GfxColorSpace *fillColorSpace; // fill color space GfxColorSpace *strokeColorSpace; // stroke color space @@ -903,8 +1166,11 @@ private: GfxColor strokeColor; // stroke color GfxPattern *fillPattern; // fill pattern GfxPattern *strokePattern; // stroke pattern + GfxBlendMode blendMode; // transparency blend mode double fillOpacity; // fill opacity double strokeOpacity; // stroke opacity + GBool fillOverprint; // fill overprint + GBool strokeOverprint; // stroke overprint double lineWidth; // line width double *lineDash; // line dash @@ -929,6 +1195,9 @@ private: double curX, curY; // current point (user coords) double lineX, lineY; // start of current text line (text coords) + double clipXMin, clipYMin, // bounding box for clip region + clipXMax, clipYMax; + GfxState *saved; // next GfxState on stack GfxState(GfxState *state);