diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-06-16 16:29:44 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-06-16 16:29:44 -0700 |
commit | 2ca8fcbc8a7a3ef6adfac154c47068c1696205d0 (patch) | |
tree | de3f825c75b1b92908825f68af8a4e7146cf97fd /third_party/agg23/agg_math.h | |
parent | ea44bd064a86679a47a7265020f997d6e3b88336 (diff) | |
download | pdfium-2ca8fcbc8a7a3ef6adfac154c47068c1696205d0.tar.xz |
Separate agg-authored code from fx-authored code.chromium/2439chromium/2438chromium/2437chromium/2436chromium/2435
Creates a separate library so we can apply less-strict warnings to
the code we can't change from upstream vs. the code we can change,
reducing noise in the standalone build.
Remove needless foo.{cpp,h} files that merely perform indirection
via #include "some_other_path/foo.{cpp,h}".
BUG=pdfium:166
R=brucedawson@chromium.org, thestig@chromium.org
Review URL: https://codereview.chromium.org/1152743007.
Diffstat (limited to 'third_party/agg23/agg_math.h')
-rw-r--r-- | third_party/agg23/agg_math.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/third_party/agg23/agg_math.h b/third_party/agg23/agg_math.h new file mode 100644 index 0000000000..31e0daf3bb --- /dev/null +++ b/third_party/agg23/agg_math.h @@ -0,0 +1,63 @@ + +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.3 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// Bessel function (besj) was adapted for use in AGG library by Andy Wilk +// Contact: castor.vulgaris@gmail.com +//---------------------------------------------------------------------------- +#ifndef AGG_MATH_INCLUDED +#define AGG_MATH_INCLUDED +#include "agg_basics.h" +namespace agg +{ +const FX_FLOAT intersection_epsilon = 1.0e-30f; +AGG_INLINE FX_FLOAT calc_point_location(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x, FX_FLOAT y) +{ + return FXSYS_Mul(x - x2, y2 - y1) - FXSYS_Mul(y - y2, x2 - x1); +} +AGG_INLINE FX_FLOAT calc_distance(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) +{ + FX_FLOAT dx = x2 - x1; + FX_FLOAT dy = y2 - y1; + return FXSYS_sqrt2(dx, dy); +} +AGG_INLINE FX_FLOAT calc_line_point_distance(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x, FX_FLOAT y) +{ + FX_FLOAT dx = x2 - x1; + FX_FLOAT dy = y2 - y1; + FX_FLOAT d = FXSYS_sqrt2(dx, dy); + if(d < intersection_epsilon) { + return calc_distance(x1, y1, x, y); + } + return FXSYS_MulDiv(x - x2, dy, d) - FXSYS_MulDiv(y - y2, dx, d); +} +AGG_INLINE bool calc_intersection(FX_FLOAT ax, FX_FLOAT ay, FX_FLOAT bx, FX_FLOAT by, + FX_FLOAT cx, FX_FLOAT cy, FX_FLOAT dx, FX_FLOAT dy, + FX_FLOAT* x, FX_FLOAT* y) +{ + FX_FLOAT num = FXSYS_Mul(ay - cy, dx - cx) - FXSYS_Mul(ax - cx, dy - cy); + FX_FLOAT den = FXSYS_Mul(bx - ax, dy - cy) - FXSYS_Mul(by - ay, dx - cx); + if (FXSYS_fabs(den) < intersection_epsilon) { + return false; + } + *x = ax + FXSYS_MulDiv(bx - ax, num, den); + *y = ay + FXSYS_MulDiv(by - ay, num, den); + return true; +} +} +#endif |