[poppler] CMakeLists.txt config.h.cmake configure.ac splash/SplashMath.h splash/SplashTypes.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Jan 12 14:56:19 PST 2010
CMakeLists.txt | 7 ++++++-
config.h.cmake | 5 ++++-
configure.ac | 10 +++++++++-
splash/SplashMath.h | 14 ++++++++++++--
splash/SplashTypes.h | 4 +++-
5 files changed, 34 insertions(+), 6 deletions(-)
New commits:
commit 9c0b20ab8c104c2f5398a5a3b8409ca554f5fa39
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Jan 12 22:55:06 2010 +0000
Add the possibility of using float for splash variables instead of double
Based on a patch by Marius Vollmer marius.vollmer at nokia.com
See bug 25578 for more info
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e9c0306..61d5d8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,8 @@ option(ENABLE_LIBOPENJPEG "Use libopenjpeg for JPX streams." ON)
option(ENABLE_LCMS "Use liblcms for color management." ON)
option(ENABLE_ZLIB "TODO" OFF)
option(USE_EXCEPTIONS "Throw exceptions to deal with not enough memory and similar problems." OFF)
-option(USE_FIXEDPOINT "Use fixed point arithmetic" OFF)
+option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF)
+option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
@@ -464,3 +465,7 @@ show_end_message("use zlib" ENABLE_ZLIB)
show_end_message("use libopenjpeg" LIBOPENJPEG_FOUND)
show_end_message("use cms" USE_CMS)
show_end_message("command line utils" ENABLE_UTILS)
+
+if(USE_FIXEDPOINT AND USE_FLOAT)
+ message("Warning: Single precision and fixed point options should not be enabled at the same time")
+endif(USE_FIXEDPOINT AND USE_FLOAT)
diff --git a/config.h.cmake b/config.h.cmake
index 7145e6a..7150789 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -151,9 +151,12 @@
/* Throw exceptions to deal with not enough memory and similar problems */
#cmakedefine USE_EXCEPTIONS 1
-/* Use fixed point arithmetic */
+/* Use fixed point arithmetic in the Splash backend */
#cmakedefine USE_FIXEDPOINT 1
+/* Use single precision arithmetic in the Splash backend */
+#cmakedefine USE_FLOAT 1
+
/* Version number of package */
#define VERSION "${POPPLER_VERSION}"
diff --git a/configure.ac b/configure.ac
index 05834cf..29efd70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,8 +67,12 @@ AC_ARG_ENABLE(xpdf-headers,
enable_xpdf_headers="no")
AM_CONDITIONAL(ENABLE_XPDF_HEADERS, test x$enable_xpdf_headers = xyes)
+AC_ARG_ENABLE(single-precision,
+[ --enable-single-precision use single precision arithmetic (instead of double precision) in the Splash backend],
+AC_DEFINE(USE_FLOAT, [1], [Use single precision arithmetic]))
+
AC_ARG_ENABLE(fixedpoint,
-[ --enable-fixedpoint use fixed point (instead of floating point) arithmetic],
+[ --enable-fixedpoint use fixed point (instead of double precision) arithmetic in the Splash backend],
AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic]))
AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])
@@ -582,6 +586,10 @@ if test x$enable_splash_output = xno -a x$enable_cairo_output = xno; then
echo " Warning: There is no rendering backend enabled"
fi
+if test x$enable_single_precision = xyes -a x$enable_fixedpoint = xyes; then
+ echo " Warning: Single precision and fixed point options should not be enabled at the same time"
+fi
+
if test x$enable_libjpeg != xyes; then
echo " Warning: Using libjpeg is recommended"
fi
diff --git a/splash/SplashMath.h b/splash/SplashMath.h
index cb6dee9..0b07567 100644
--- a/splash/SplashMath.h
+++ b/splash/SplashMath.h
@@ -11,7 +11,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009, 2010 Albert Astals Cid <aacid at kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -31,6 +31,8 @@
static inline SplashCoord splashAbs(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::abs(x);
+#elif USE_FLOAT
+ return fabsf(x);
#else
return fabs(x);
#endif
@@ -39,6 +41,8 @@ static inline SplashCoord splashAbs(SplashCoord x) {
static inline int splashFloor(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::floor(x);
+ #elif USE_FLOAT
+ return (int)floorf(x);
#else
if (x > 0) return (int)x;
else return (int)floor(x);
@@ -48,6 +52,8 @@ static inline int splashFloor(SplashCoord x) {
static inline int splashCeil(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::ceil(x);
+#elif USE_FLOAT
+ return (int)ceilf(x);
#else
return (int)ceil(x);
#endif
@@ -64,6 +70,8 @@ static inline int splashRound(SplashCoord x) {
static inline SplashCoord splashSqrt(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::sqrt(x);
+#elif USE_FLOAT
+ return sqrtf(x);
#else
return sqrt(x);
#endif
@@ -72,6 +80,8 @@ static inline SplashCoord splashSqrt(SplashCoord x) {
static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) {
#if USE_FIXEDPOINT
return FixedPoint::pow(x, y);
+#elif USE_FLOAT
+ return powf(x, y);
#else
return pow(x, y);
#endif
@@ -96,7 +106,7 @@ static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0,
return dya * FixedPoint::sqrt(dxa / dya + 1);
}
#else
- return sqrt(dx * dx + dy * dy);
+ return splashSqrt(dx * dx + dy * dy);
#endif
}
diff --git a/splash/SplashTypes.h b/splash/SplashTypes.h
index b623fed..993dd46 100644
--- a/splash/SplashTypes.h
+++ b/splash/SplashTypes.h
@@ -11,7 +11,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2006 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare at gmail.com>
// Copyright (C) 2009 Thomas Freitag <Thomas.Freitag at alfa.de>
// Copyright (C) 2009 Stefan Thomas <thomas at eload24.com>
@@ -33,6 +33,8 @@
#if USE_FIXEDPOINT
#include "goo/FixedPoint.h"
typedef FixedPoint SplashCoord;
+#elif USE_FLOAT
+typedef float SplashCoord;
#else
typedef double SplashCoord;
#endif
More information about the poppler
mailing list