From 250d23c712ec417261c7b705e1e2388945c94659 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Sat, 6 Oct 2012 15:06:26 +0800 Subject: [PATCH] remove hypot --- src/HTMLRenderer/draw.cc | 4 ++-- src/HTMLRenderer/state.cc | 5 ++--- src/include/util.h | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HTMLRenderer/draw.cc b/src/HTMLRenderer/draw.cc index a64dc2b..adbbfe4 100644 --- a/src/HTMLRenderer/draw.cc +++ b/src/HTMLRenderer/draw.cc @@ -104,7 +104,7 @@ static void get_shading_bbox(GfxState * state, GfxShading * shading, */ static double get_angle(double dx, double dy) { - double r = hypot(dx, dy); + double r = _hypot(dx, dy); /* * acos always returns [0, pi] @@ -358,7 +358,7 @@ void HTMLRenderer::css_draw_rectangle(double x, double y, double w, double h, co double i1 = (new_tm[0] + new_tm[2]) / sqrt2; double i2 = (new_tm[1] + new_tm[3]) / sqrt2; - scale = hypot(i1, i2); + scale = _hypot(i1, i2); if(_is_positive(scale)) { for(int i = 0; i < 4; ++i) diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc index fc94015..615cf36 100644 --- a/src/HTMLRenderer/state.cc +++ b/src/HTMLRenderer/state.cc @@ -17,13 +17,12 @@ #include "HTMLRenderer.h" #include "namespace.h" - +#include "util.h" namespace pdf2htmlEX { using std::max; using std::abs; -using std::hypot; void HTMLRenderer::updateAll(GfxState * state) { @@ -148,7 +147,7 @@ void HTMLRenderer::check_state_change(GfxState * state) double new_draw_text_tm[6]; memcpy(new_draw_text_tm, cur_text_tm, sizeof(new_draw_text_tm)); - double new_draw_text_scale = 1.0/text_scale_factor2 * hypot(new_draw_text_tm[2], new_draw_text_tm[3]); + double new_draw_text_scale = 1.0/text_scale_factor2 * _hypot(new_draw_text_tm[2], new_draw_text_tm[3]); double new_draw_font_size = cur_font_size; if(_is_positive(new_draw_text_scale)) diff --git a/src/include/util.h b/src/include/util.h index 5c1032b..ffae09e 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -46,6 +46,7 @@ static inline bool _tm_equal(const double * tm1, const double * tm2, int size = return false; return true; } +static inline double _hypot(double x, double y) { return std::sqrt(x*x+y*y); } void _tm_transform(const double * tm, double & x, double & y, bool is_delta = false); void _tm_multiply(double * tm_left, const double * tm_right);