? 01-xpdf-3.00pl1.patch ? 02-xpdf-3.00pl2.patch ? 03-xpdf-3.00pl3.patch ? 10-xpdf-3.01-docs.patch ? 11-xpdf-3.01-fixedpoint.patch ? goo/FixedPoint.cc ? goo/FixedPoint.h Index: configure.ac =================================================================== RCS file: /cvs/poppler/poppler/configure.ac,v retrieving revision 1.35 diff -u -r1.35 configure.ac --- configure.ac 7 Sep 2005 03:00:36 -0000 1.35 +++ configure.ac 15 Sep 2005 09:31:15 -0000 @@ -23,6 +23,10 @@ AC_DEFINE([MULTITHREADED], [1], [Enable multithreading support.]) AC_DEFINE([TEXTOUT_WORD_LIST], [1], [Enable word list support.]) +AC_ARG_ENABLE(fixedpoint, +[ --enable-fixedpoint use fixed point (instead of floating point) arithmetic], +AC_DEFINE(USE_FIXEDPOINT, [], [Use fixed point arithmetic])) + dnl ##### Path to xpdfrc. dnl This ugly kludge to get the sysconfdir path is needed because dnl autoconf doesn't actually set the prefix variable until later. Index: goo/Makefile.am =================================================================== RCS file: /cvs/poppler/poppler/goo/Makefile.am,v retrieving revision 1.2 diff -u -r1.2 Makefile.am --- goo/Makefile.am 29 Apr 2005 19:37:07 -0000 1.2 +++ goo/Makefile.am 15 Sep 2005 09:31:16 -0000 @@ -10,7 +10,8 @@ gmem.h \ gtypes.h \ gmem.h \ - gfile.h + gfile.h \ + FixedPoint.h libgoo_la_SOURCES = \ gfile.cc \ @@ -19,4 +20,5 @@ GooList.cc \ GooTimer.cc \ GooString.cc \ - gmem.c + gmem.c \ + FixedPoint.cc Index: splash/Makefile.am =================================================================== RCS file: /cvs/poppler/poppler/splash/Makefile.am,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile.am --- splash/Makefile.am 3 Mar 2005 19:45:59 -0000 1.1.1.1 +++ splash/Makefile.am 15 Sep 2005 09:31:17 -0000 @@ -1,5 +1,6 @@ INCLUDES = \ -I$(top_srcdir) \ + -I$(top_srcdir)/goo \ $(FREETYPE_CFLAGS) noinst_LTLIBRARIES = libsplash.la Index: splash/SplashFTFont.cc =================================================================== RCS file: /cvs/poppler/poppler/splash/SplashFTFont.cc,v retrieving revision 1.2 diff -u -r1.2 SplashFTFont.cc --- splash/SplashFTFont.cc 2 May 2005 00:44:26 -0000 1.2 +++ splash/SplashFTFont.cc 15 Sep 2005 09:31:18 -0000 @@ -116,10 +116,17 @@ } // compute the transform matrix +#if USE_FIXEDPOINT + matrix.xx = (FT_Fixed)((mat[0] / size).getRaw()); + matrix.yx = (FT_Fixed)((mat[1] / size).getRaw()); + matrix.xy = (FT_Fixed)((mat[2] / size).getRaw()); + matrix.yy = (FT_Fixed)((mat[3] / size).getRaw()); +#else matrix.xx = (FT_Fixed)((mat[0] / size) * 65536); matrix.yx = (FT_Fixed)((mat[1] / size) * 65536); matrix.xy = (FT_Fixed)((mat[2] / size) * 65536); matrix.yy = (FT_Fixed)((mat[3] / size) * 65536); +#endif } SplashFTFont::~SplashFTFont() { Index: splash/SplashMath.h =================================================================== RCS file: /cvs/poppler/poppler/splash/SplashMath.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 SplashMath.h --- splash/SplashMath.h 3 Mar 2005 19:45:59 -0000 1.1.1.1 +++ splash/SplashMath.h 15 Sep 2005 09:31:18 -0000 @@ -7,31 +7,59 @@ #ifndef SPLASHMATH_H #define SPLASHMATH_H +#if USE_FIXEDPONT +#include "FixedPoint.h" +#else #include +#endif #include "SplashTypes.h" static inline SplashCoord splashAbs(SplashCoord x) { +#if USE_FIXEDPOINT + return FixedPoint::abs(x); +#else return fabs(x); +#endif } static inline int splashFloor(SplashCoord x) { - return (int)floor(x); + #if USE_FIXEDPOINT + return FixedPoint::floor(x); + #else + return (int)floor(x); + #endif } static inline int splashCeil(SplashCoord x) { +#if USE_FIXEDPOINT + return FixedPoint::ceil(x); +#else return (int)ceil(x); +#endif } static inline int splashRound(SplashCoord x) { +#if USE_FIXEDPOINT + return FixedPoint::round(x); +#else return (int)floor(x + 0.5); +#endif } static inline SplashCoord splashSqrt(SplashCoord x) { +#if USE_FIXEDPOINT + return FixedPoint::sqrt(x); +#else return sqrt(x); +#endif } static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) { +#if USE_FIXEDPOINT + return FixedPoint::pow(x, y); +#else return pow(x, y); +#endif } static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0, @@ -39,7 +67,11 @@ SplashCoord dx, dy; dx = x1 - x0; dy = y1 - y0; +#if USE_FIXEDPOINT + return FixedPoint::sqrt(dx * dx + dy * dy); +#else return sqrt(dx * dx + dy * dy); +#endif } #endif Index: splash/SplashTypes.h =================================================================== RCS file: /cvs/poppler/poppler/splash/SplashTypes.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 SplashTypes.h --- splash/SplashTypes.h 3 Mar 2005 19:45:59 -0000 1.1.1.1 +++ splash/SplashTypes.h 15 Sep 2005 09:31:18 -0000 @@ -13,7 +13,12 @@ // coordinates //------------------------------------------------------------------------ +#if USE_FIXEDPOINT +#include "FixedPoint.h" +typedef FixedPoint SplashCoord; +#else typedef double SplashCoord; +#endif //------------------------------------------------------------------------ // colors 0a1,95 > //======================================================================== > // > // FixedPoint.cc > // > // Fixed point type, with C++ operators. > // > // Copyright 2004 Glyph & Cog, LLC > // > //======================================================================== > > #include > > #if USE_FIXEDPOINT > > #ifdef USE_GCC_PRAGMAS > #pragma implementation > #endif > > #include "FixedPoint.h" > > FixedPoint FixedPoint::sqrt(FixedPoint x) { > FixedPoint y0, y1, z; > > if (x.val <= 0) { > y1.val = 0; > } else { > y1.val = x.val >> 1; > do { > y0.val = y1.val; > z = x / y0; > y1.val = (y0.val + z.val) >> 1; > } while (::abs(y0.val - y1.val) > 1); > } > return y1; > } > > //~ this is not very accurate > FixedPoint FixedPoint::pow(FixedPoint x, FixedPoint y) { > FixedPoint t, t2, lnx0, lnx, z0, z; > int d, i; > > if (y.val <= 0) { > z.val = 0; > } else { > // y * ln(x) > t = (x - 1) / (x + 1); > t2 = t * t; > d = 1; > lnx = 0; > do { > lnx0 = lnx; > lnx += t / d; > t *= t2; > d += 2; > } while (::abs(lnx.val - lnx0.val) > 2); > lnx.val <<= 1; > t = y * lnx; > // exp(y * ln(x)) > t2 = t; > d = 1; > i = 1; > z = 1; > do { > z0 = z; > z += t2 / d; > t2 *= t; > ++i; > d *= i; > } while (::abs(z.val - z0.val) > 2 && d < (1 << fixptShift)); > } > return z; > } > > int FixedPoint::mul(int x, int y) { > #if 1 //~tmp > return ((FixPtInt64)x * y) >> fixptShift; > #else > int ah0, ah, bh, al, bl; > ah0 = x & fixptMaskH; > ah = x >> fixptShift; > al = x - ah0; > bh = y >> fixptShift; > bl = y - (bh << fixptShift); > return ah0 * bh + ah * bl + al * bh + ((al * bl) >> fixptShift); > #endif > } > > int FixedPoint::div(int x, int y) { > #if 1 //~tmp > return ((FixPtInt64)x << fixptShift) / y; > #else > #endif > } > > #endif // USE_FIXEDPOINT 0a1,150 > //======================================================================== > // > // FixedPoint.h > // > // Fixed point type, with C++ operators. > // > // Copyright 2004 Glyph & Cog, LLC > // > //======================================================================== > > #ifndef FIXEDPOINT_H > #define FIXEDPOINT_H > > #include > > #if USE_FIXEDPOINT > > #ifdef USE_GCC_PRAGMAS > #pragma interface > #endif > > #include > #include > > #define fixptShift 16 > #define fixptMaskL ((1 << fixptShift) - 1) > #define fixptMaskH (~fixptMaskL) > > typedef long long FixPtInt64; > > class FixedPoint { > public: > > FixedPoint() { val = 0; } > FixedPoint(const FixedPoint &x) { val = x.val; } > FixedPoint(double x) { val = (int)(x * (1 << fixptShift) + 0.5); } > FixedPoint(int x) { val = x << fixptShift; } > FixedPoint(long x) { val = x << fixptShift; } > > operator float() > { return (float) val * ((float)1 / (float)(1 << fixptShift)); } > operator double() > { return (double) val * (1.0 / (double)(1 << fixptShift)); } > operator int() > { return val >> fixptShift; } > > int getRaw() { return val; } > > FixedPoint operator =(FixedPoint x) { val = x.val; return *this; } > > int operator ==(FixedPoint x) { return val == x.val; } > int operator ==(double x) { return *this == (FixedPoint)x; } > int operator ==(int x) { return *this == (FixedPoint)x; } > int operator ==(long x) { return *this == (FixedPoint)x; } > > int operator !=(FixedPoint x) { return val != x.val; } > int operator !=(double x) { return *this != (FixedPoint)x; } > int operator !=(int x) { return *this != (FixedPoint)x; } > int operator !=(long x) { return *this != (FixedPoint)x; } > > int operator <(FixedPoint x) { return val < x.val; } > int operator <(double x) { return *this < (FixedPoint)x; } > int operator <(int x) { return *this < (FixedPoint)x; } > int operator <(long x) { return *this < (FixedPoint)x; } > > int operator <=(FixedPoint x) { return val <= x.val; } > int operator <=(double x) { return *this <= (FixedPoint)x; } > int operator <=(int x) { return *this <= (FixedPoint)x; } > int operator <=(long x) { return *this <= (FixedPoint)x; } > > int operator >(FixedPoint x) { return val > x.val; } > int operator >(double x) { return *this > (FixedPoint)x; } > int operator >(int x) { return *this > (FixedPoint)x; } > int operator >(long x) { return *this > (FixedPoint)x; } > > int operator >=(FixedPoint x) { return val >= x.val; } > int operator >=(double x) { return *this >= (FixedPoint)x; } > int operator >=(int x) { return *this >= (FixedPoint)x; } > int operator >=(long x) { return *this >= (FixedPoint)x; } > > FixedPoint operator -() { return make(-val); } > > FixedPoint operator +(FixedPoint x) { return make(val + x.val); } > FixedPoint operator +(double x) { return *this + (FixedPoint)x; } > FixedPoint operator +(int x) { return *this + (FixedPoint)x; } > FixedPoint operator +(long x) { return *this + (FixedPoint)x; } > > FixedPoint operator +=(FixedPoint x) { val = val + x.val; return *this; } > FixedPoint operator +=(double x) { return *this += (FixedPoint)x; } > FixedPoint operator +=(int x) { return *this += (FixedPoint)x; } > FixedPoint operator +=(long x) { return *this += (FixedPoint)x; } > > FixedPoint operator -(FixedPoint x) { return make(val - x.val); } > FixedPoint operator -(double x) { return *this - (FixedPoint)x; } > FixedPoint operator -(int x) { return *this - (FixedPoint)x; } > FixedPoint operator -(long x) { return *this - (FixedPoint)x; } > > FixedPoint operator -=(FixedPoint x) { val = val - x.val; return *this; } > FixedPoint operator -=(double x) { return *this -= (FixedPoint)x; } > FixedPoint operator -=(int x) { return *this -= (FixedPoint)x; } > FixedPoint operator -=(long x) { return *this -= (FixedPoint)x; } > > FixedPoint operator *(FixedPoint x) { return make(mul(val, x.val)); } > FixedPoint operator *(double x) { return *this * (FixedPoint)x; } > FixedPoint operator *(int x) { return *this * (FixedPoint)x; } > FixedPoint operator *(long x) { return *this * (FixedPoint)x; } > > FixedPoint operator *=(FixedPoint x) { val = mul(val, x.val); return *this; } > FixedPoint operator *=(double x) { return *this *= (FixedPoint)x; } > FixedPoint operator *=(int x) { return *this *= (FixedPoint)x; } > FixedPoint operator *=(long x) { return *this *= (FixedPoint)x; } > > FixedPoint operator /(FixedPoint x) { return make(div(val, x.val)); } > FixedPoint operator /(double x) { return *this / (FixedPoint)x; } > FixedPoint operator /(int x) { return *this / (FixedPoint)x; } > FixedPoint operator /(long x) { return *this / (FixedPoint)x; } > > FixedPoint operator /=(FixedPoint x) { val = div(val, x.val); return *this; } > FixedPoint operator /=(double x) { return *this /= (FixedPoint)x; } > FixedPoint operator /=(int x) { return *this /= (FixedPoint)x; } > FixedPoint operator /=(long x) { return *this /= (FixedPoint)x; } > > static FixedPoint abs(FixedPoint x) { return make(::abs(x.val)); } > > static int floor(FixedPoint x) { return x.val >> fixptShift; } > > static int ceil(FixedPoint x) > { return (x.val & fixptMaskL) ? ((x.val >> fixptShift) + 1) > : (x.val >> fixptShift); } > > static int round(FixedPoint x) > { return (x.val + (1 << (fixptShift - 1))) >> fixptShift; } > > static FixedPoint sqrt(FixedPoint x); > > static FixedPoint pow(FixedPoint x, FixedPoint y); > > private: > > static FixedPoint make(int valA) { FixedPoint x; x.val = valA; return x; } > > static int mul(int x, int y); > static int div(int x, int y); > > int val; // 16.16 fixed point > }; > > #endif // USE_FIXEDPOINT > > #endif