]> git.ipfire.org Git - thirdparty/cups.git/blame - pdftops/SplashMath.h
Load cups into easysw/current.
[thirdparty/cups.git] / pdftops / SplashMath.h
CommitLineData
ef416fc2 1//========================================================================
2//
3// SplashMath.h
4//
5//========================================================================
6
7#ifndef SPLASHMATH_H
8#define SPLASHMATH_H
9
10#include <config.h>
11#if USE_FIXEDPONT
12#include "FixedPoint.h"
13#else
14#include <math.h>
15#endif
16#include "SplashTypes.h"
17
18static inline SplashCoord splashAbs(SplashCoord x) {
19#if USE_FIXEDPOINT
20 return FixedPoint::abs(x);
21#else
22 return fabs(x);
23#endif
24}
25
26static inline int splashFloor(SplashCoord x) {
27#if USE_FIXEDPOINT
28 return FixedPoint::floor(x);
29#else
30 return (int)floor(x);
31#endif
32}
33
34static inline int splashCeil(SplashCoord x) {
35#if USE_FIXEDPOINT
36 return FixedPoint::ceil(x);
37#else
38 return (int)ceil(x);
39#endif
40}
41
42static inline int splashRound(SplashCoord x) {
43#if USE_FIXEDPOINT
44 return FixedPoint::round(x);
45#else
46 return (int)floor(x + 0.5);
47#endif
48}
49
50static inline SplashCoord splashSqrt(SplashCoord x) {
51#if USE_FIXEDPOINT
52 return FixedPoint::sqrt(x);
53#else
54 return sqrt(x);
55#endif
56}
57
58static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) {
59#if USE_FIXEDPOINT
60 return FixedPoint::pow(x, y);
61#else
62 return pow(x, y);
63#endif
64}
65
66static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0,
67 SplashCoord x1, SplashCoord y1) {
68 SplashCoord dx, dy;
69 dx = x1 - x0;
70 dy = y1 - y0;
71#if USE_FIXEDPOINT
72 return FixedPoint::sqrt(dx * dx + dy * dy);
73#else
74 return sqrt(dx * dx + dy * dy);
75#endif
76}
77
78#endif