From: Hermet Park Date: Wed, 3 Nov 2021 11:24:36 +0000 (+0900) Subject: common shape: ++tiny optimization X-Git-Tag: accepted/tizen/unified/20211112.135649~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d45416bde559796fe8b5ea4e485d2a273308fc23;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git common shape: ++tiny optimization reduce the binary size by 80 bytes. --- diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index e1eaa59..5614b23 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -22,7 +22,6 @@ #define _USE_MATH_DEFINES //Math Constants are not defined in Standard C/C++. -#include #include #include #include "tvgShapeImpl.h" @@ -163,18 +162,16 @@ Result Shape::appendCircle(float cx, float cy, float rx, float ry) noexcept Result Shape::appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept { - const float M_PI_HALF = (float)(M_PI * 0.5f); - //just circle - if (sweep >= 360 || sweep <= -360) return appendCircle(cx, cy, radius, radius); + if (sweep >= 360.0f || sweep <= -360.0f) return appendCircle(cx, cy, radius, radius); - startAngle = (startAngle * M_PI) / 180; - sweep = sweep * M_PI / 180; + startAngle = (startAngle * M_PI) / 180.0f; + sweep = sweep * M_PI / 180.0f; - auto nCurves = ceil(fabsf(sweep / M_PI_HALF)); + auto nCurves = ceil(fabsf(sweep / M_PI_2)); auto sweepSign = (sweep < 0 ? -1 : 1); - auto fract = fmodf(sweep, M_PI_HALF); - fract = (fabsf(fract) < std::numeric_limits::epsilon()) ? M_PI_HALF * sweepSign : fract; + auto fract = fmodf(sweep, M_PI_2); + fract = (fabsf(fract) < FLT_EPSILON) ? M_PI_2 * sweepSign : fract; //Start from here Point start = {radius * cosf(startAngle), radius * sinf(startAngle)}; @@ -187,7 +184,7 @@ Result Shape::appendArc(float cx, float cy, float radius, float startAngle, floa } for (int i = 0; i < nCurves; ++i) { - auto endAngle = startAngle + ((i != nCurves - 1) ? M_PI_HALF * sweepSign : fract); + auto endAngle = startAngle + ((i != nCurves - 1) ? M_PI_2 * sweepSign : fract); Point end = {radius * cosf(endAngle), radius * sinf(endAngle)}; //variables needed to calculate bezier control points