Commit 51670972 authored by Albert Astals Cid's avatar Albert Astals Cid

Last xpdf 3.01 merge (at least from my side)

It's very big, but noone has opposed in the 2 weeks time i gave on the ml so either poppler is dead or people agree with the patch
parent 10dfa225
2005-10-30 Albert Astals Cid <aacid@kde.org>
* glib/poppler-page.cc
* poppler/ArthurOutputDev.cc
* poppler/ArthurOutputDev.h
* poppler/CairoOutputDev.cc
* poppler/CairoOutputDev.h
* poppler/Gfx.cc
* poppler/Gfx.h
* poppler/GfxState.cc
* poppler/GfxState.h
* poppler/OutputDev.cc
* poppler/OutputDev.h
* poppler/PDFDoc.cc
* poppler/PDFDoc.h
* poppler/PSOutputDev.cc
* poppler/PSOutputDev.h
* poppler/Page.cc
* poppler/Page.h
* poppler/SplashOutputDev.cc
* poppler/SplashOutputDev.h
* poppler/TextOutputDev.cc
* poppler/TextOutputDev.h
* qt/poppler-page.cc
* qt4/src/poppler-page.cc
* splash/Splash.cc
* splash/Splash.h
* splash/SplashBitmap.cc
* splash/SplashBitmap.h
* splash/SplashPattern.cc
* splash/SplashPattern.h
* splash/SplashState.cc
* splash/SplashState.h
* splash/SplashTypes.h
* test/gtk-cairo-test.cc
* test/gtk-splash-test.cc
* test/pdf-inspector.cc: Last xpdf 3.01 merges
2005-10-16 Kristian Høgsberg <krh@redhat.com>
* poppler/poppler-config.h.in (GCC_PRINTF_FORMAT): Remove evil
......
......@@ -85,11 +85,11 @@ poppler_page_get_size (PopplerPage *page,
rotate = page->page->getRotate ();
if (rotate == 90 || rotate == 270) {
page_height = page->page->getWidth ();
page_width = page->page->getHeight ();
page_height = page->page->getCropWidth ();
page_width = page->page->getCropHeight ();
} else {
page_width = page->page->getWidth ();
page_height = page->page->getHeight ();
page_width = page->page->getCropWidth ();
page_height = page->page->getCropHeight ();
}
if (width != NULL)
......@@ -129,11 +129,11 @@ poppler_page_prepare_output_dev (PopplerPage *page,
rotate = (rotation + page->page->getRotate()) % 360;
if (rotate == 90 || rotate == 270) {
cairo_width = MAX ((int)(page->page->getHeight() * scale + 0.5), 1);
cairo_height = MAX ((int)(page->page->getWidth() * scale + 0.5), 1);
cairo_width = MAX ((int)(page->page->getCropHeight() * scale + 0.5), 1);
cairo_height = MAX ((int)(page->page->getCropWidth() * scale + 0.5), 1);
} else {
cairo_width = MAX ((int)(page->page->getWidth() * scale + 0.5), 1);
cairo_height = MAX ((int)(page->page->getHeight() * scale + 0.5), 1);
cairo_width = MAX ((int)(page->page->getCropWidth() * scale + 0.5), 1);
cairo_height = MAX ((int)(page->page->getCropHeight() * scale + 0.5), 1);
}
output_dev = page->document->output_dev;
......@@ -301,6 +301,7 @@ poppler_page_render_to_pixbuf (PopplerPage *page,
page->page->displaySlice(page->document->output_dev,
72.0 * scale, 72.0 * scale,
rotation,
gFalse, /* useMediaBox */
gTrue, /* Crop */
src_x, src_y,
src_width, src_height,
......@@ -318,6 +319,7 @@ poppler_page_get_text_output_dev (PopplerPage *page)
page->gfx = page->page->createGfx(page->text_dev,
72.0, 72.0, 0,
gFalse, /* useMediaBox */
gTrue, /* Crop */
-1, -1, -1, -1,
NULL, /* links */
......@@ -642,15 +644,17 @@ poppler_page_find_text (PopplerPage *page,
doc = page->document->doc;
poppler_page_get_size (page, NULL, &height);
page->page->display (output_dev, 72, 72, 0,
page->page->display (output_dev, 72, 72, 0, gFalse,
gTrue, NULL, doc->getCatalog());
matches = NULL;
xMin = 0;
yMin = 0;
#warning you probably want to add caseSensitive and backwards as parameters
while (output_dev->findText (ucs4, ucs4_len,
gFalse, gTrue, // startAtTop, stopAtBottom
gTrue, gFalse, // startAtLast, stopAtLast
gFalse, gFalse, // caseSensitive, backwards
&xMin, &yMin, &xMax, &yMax))
{
match = g_new (PopplerRectangle, 1);
......@@ -693,7 +697,7 @@ poppler_page_render_to_ps (PopplerPage *page,
ps_file->document->doc->displayPage (ps_file->out, page->index + 1, 72.0, 72.0,
0, gTrue, gFalse);
0, gFalse, gTrue, gFalse);
}
static void
......@@ -780,10 +784,10 @@ poppler_page_get_link_mapping (PopplerPage *page)
link->getRect (&(mapping->area.x1), &(mapping->area.y1),
&(mapping->area.x2), &(mapping->area.y2));
mapping->area.x1 -= page->page->getBox()->x1;
mapping->area.x2 -= page->page->getBox()->x1;
mapping->area.y1 -= page->page->getBox()->y1;
mapping->area.y2 -= page->page->getBox()->y1;
mapping->area.x1 -= page->page->getCropBox()->x1;
mapping->area.x2 -= page->page->getCropBox()->x1;
mapping->area.y1 -= page->page->getCropBox()->y1;
mapping->area.y2 -= page->page->getCropBox()->y1;
map_list = g_list_prepend (map_list, mapping);
}
......
......@@ -485,7 +485,7 @@ void ArthurOutputDev::eoClip(GfxState *state)
void ArthurOutputDev::drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, Unicode *u, int uLen) {
CharCode code, int nBytes, Unicode *u, int uLen) {
double x1, y1;
// SplashPath *path;
int render;
......
......@@ -102,7 +102,7 @@ public:
virtual void drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, Unicode *u, int uLen);
CharCode code, int nBytes, Unicode *u, int uLen);
virtual GBool beginType3Char(GfxState *state, double x, double y,
double dx, double dy,
CharCode code, Unicode *u, int uLen);
......
......@@ -348,7 +348,7 @@ void CairoOutputDev::beginString(GfxState *state, GooString *s)
void CairoOutputDev::drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, Unicode *u, int uLen)
CharCode code, int nBytes, Unicode *u, int uLen)
{
double tx, ty;
......
......@@ -102,7 +102,7 @@ public:
void drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, Unicode *u, int uLen);
CharCode code, int nBytes, Unicode *u, int uLen);
virtual GBool beginType3Char(GfxState *state, double x, double y,
double dx, double dy,
......
This diff is collapsed.
......@@ -32,6 +32,9 @@ class GfxShading;
class GfxFunctionShading;
class GfxAxialShading;
class GfxRadialShading;
class GfxGouraudTriangleShading;
class GfxPatchMeshShading;
struct GfxPatch;
class GfxState;
struct GfxColor;
class Gfx;
......@@ -100,14 +103,14 @@ public:
// Constructor for regular output.
Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
double hDPI, double vDPI, PDFRectangle *box, GBool crop,
double hDPI, double vDPI, PDFRectangle *box,
PDFRectangle *cropBox, int rotate,
GBool (*abortCheckCbkA)(void *data) = NULL,
void *abortCheckCbkDataA = NULL);
// Constructor for a sub-page object.
Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
PDFRectangle *box, GBool crop, PDFRectangle *cropBox,
PDFRectangle *box, PDFRectangle *cropBox,
GBool (*abortCheckCbkA)(void *data) = NULL,
void *abortCheckCbkDataA = NULL);
......@@ -127,6 +130,9 @@ public:
// Restore graphics state.
void restoreState();
// Get the current graphics state object.
GfxState *getState() { return state; }
private:
XRef *xref; // the xref table for this PDF file
......@@ -216,6 +222,13 @@ private:
GfxColor *colors, int depth);
void doAxialShFill(GfxAxialShading *shading);
void doRadialShFill(GfxRadialShading *shading);
void doGouraudTriangleShFill(GfxGouraudTriangleShading *shading);
void gouraudFillTriangle(double x0, double y0, GfxColor *color0,
double x1, double y1, GfxColor *color1,
double x2, double y2, GfxColor *color2,
int nComps, int depth);
void doPatchMeshShFill(GfxPatchMeshShading *shading);
void fillPatch(GfxPatch *patch, int nComps, int depth);
void doEndPath();
// path clipping operators
......
This diff is collapsed.
......@@ -30,6 +30,58 @@ public:
void transform(double x, double y, double *tx, double *ty);
};
//------------------------------------------------------------------------
// 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
......@@ -38,15 +90,21 @@ public:
#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;
};
//------------------------------------------------------------------------
......@@ -54,7 +112,7 @@ struct GfxRGB {
//------------------------------------------------------------------------
struct GfxCMYK {
double c, m, y, k;
GfxColorComp c, m, y, k;
};
//------------------------------------------------------------------------
......@@ -89,7 +147,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;
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
......@@ -123,7 +181,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);
virtual void getGrayLine(Guchar *in, Guchar *out, int length);
......@@ -149,7 +207,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);
virtual void getGrayLine(Guchar *in, Guchar *out, int length);
......@@ -185,7 +243,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);
virtual void getGrayLine(Guchar *in, Guchar *out, int length);
......@@ -211,7 +269,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);
virtual void getGrayLine(Guchar *in, Guchar *out, int length);
......@@ -251,7 +309,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);
......@@ -275,7 +333,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);
......@@ -320,7 +378,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);
......@@ -357,7 +415,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);
virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
......@@ -396,7 +454,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);
......@@ -429,7 +487,7 @@ 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);
......@@ -464,7 +522,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);
......@@ -617,6 +675,8 @@ public:
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:
......@@ -650,9 +710,11 @@ public:
{ *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
double getDomain0() { return t0; }
double getDomain1() { return t1; }
void getColor(double t, GfxColor *color);
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:
......@@ -687,9 +749,11 @@ public:
{ *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; }
double getDomain0() { return t0; }
double getDomain1() { return t1; }
void getColor(double t, GfxColor *color);
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:
......@@ -700,6 +764,77 @@ private:
GBool extend0, extend1;
};
//------------------------------------------------------------------------
// GfxGouraudTriangleShading
//------------------------------------------------------------------------
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;
};
//------------------------------------------------------------------------
// 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;
};
//------------------------------------------------------------------------
// GfxImageColorMap
//------------------------------------------------------------------------
......@@ -731,7 +866,7 @@ 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 getRGBLine(Guchar *in, unsigned int *out, int length);
void getCMYK(Guchar *x, GfxCMYK *cmyk);
......@@ -746,7 +881,8 @@ private:
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];
Guchar *byte_lookup;
Guchar *tmp_line;
double // minimum values for each component
......@@ -874,10 +1010,10 @@ class GfxState {
public:
// Construct a default GfxState, for a device with resolution <hDPI>
// x <vDPI>, page box <pageBox>, page rotation <rotate>, and
// x <vDPI>, page box <pageBox>, page rotation <rotateA>, and
// coordinate system specified by <upsideDown>.
GfxState(double hDPI, double vDPI, PDFRectangle *pageBox,
int rotate, GBool upsideDown);
int rotateA, GBool upsideDown);
// Destructor.
~GfxState();
......@@ -894,11 +1030,12 @@ 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(double *gray)
void getFillGray(GfxGray *gray)
{ fillColorSpace->getGray(&fillColor, gray); }
void getStrokeGray(double *gray)
void getStrokeGray(GfxGray *gray)
{ strokeColorSpace->getGray(&strokeColor, gray); }
void getFillRGB(GfxRGB *rgb)
{ fillColorSpace->getRGB(&fillColor, rgb); }
......@@ -912,8 +1049,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; }
......@@ -974,8 +1114,11 @@ 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; }
......@@ -1028,11 +1171,15 @@ public:
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)
</