~ubuntu-branches/ubuntu/lucid/swftools/lucid

« back to all changes in this revision

Viewing changes to lib/pdf/xpdf/SplashMath.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-04-30 05:22:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430052219-l1n64qofzeq5pej8
Tags: 0.9.0-0ubuntu1
* New upstream release (LP: #369931)
  - patches/01_manpages: edited to match updated version of src/pdf2swf.1 and
    src/wav2swf.1
  - patches/02_faq: edited to match updated version of FAQ
  - patches/04_makefile: edited to delete the patch on lib/Makefile.in and 
    src/Makefile.in (applied upstream)
  - deleted patch 99_configure_for_python2.5_and_2.6 (applied upstream)
  - debian/swftools.doc: deleted installation of TODO and 
    pdf2swf/HOWTO_pdf2swf as they don't exist anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// SplashMath.h
 
4
//
 
5
//========================================================================
 
6
 
 
7
#ifndef SPLASHMATH_H
 
8
#define SPLASHMATH_H
 
9
 
 
10
#include <aconf.h>
 
11
#if USE_FIXEDPONT
 
12
#include "FixedPoint.h"
 
13
#else
 
14
#include <math.h>
 
15
#endif
 
16
#include "SplashTypes.h"
 
17
 
 
18
static inline SplashCoord splashAbs(SplashCoord x) {
 
19
#if USE_FIXEDPOINT
 
20
  return FixedPoint::abs(x);
 
21
#else
 
22
  return fabs(x);
 
23
#endif
 
24
}
 
25
 
 
26
static 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
 
 
34
static 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
 
 
42
static 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
 
 
50
static inline SplashCoord splashSqrt(SplashCoord x) {
 
51
#if USE_FIXEDPOINT
 
52
  return FixedPoint::sqrt(x);
 
53
#else
 
54
  return sqrt(x);
 
55
#endif
 
56
}
 
57
 
 
58
static 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
 
 
66
static 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
  // this handles the situation where dx*dx or dy*dy is too large to
 
73
  // fit in the 16.16 fixed point format
 
74
  SplashCoord dxa, dya;
 
75
  dxa = splashAbs(dx);
 
76
  dya = splashAbs(dy);
 
77
  if (dxa == 0 && dya == 0) {
 
78
    return 0;
 
79
  } else if (dxa > dya) {
 
80
    return dxa * FixedPoint::sqrt(dya / dxa + 1);
 
81
  } else {
 
82
    return dya * FixedPoint::sqrt(dxa / dya + 1);
 
83
  }
 
84
#else
 
85
  return sqrt(dx * dx + dy * dy);
 
86
#endif
 
87
}
 
88
 
 
89
#endif