Commit 9c0b20ab authored by Albert Astals Cid's avatar Albert Astals Cid

Add the possibility of using float for splash variables instead of double

Based on a patch by Marius Vollmer marius.vollmer@nokia.com
See bug 25578 for more info
parent 30e5f76e
......@@ -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)
......@@ -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}"
......
......@@ -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
......
......@@ -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@kde.org>
// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@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
}
......
......@@ -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@kde.org>
// Copyright (C) 2006, 2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
// Copyright (C) 2009 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 Stefan Thomas <thomas@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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment