diff options
Diffstat (limited to 'libs/hwui/utils/MathUtils.h')
-rw-r--r-- | libs/hwui/utils/MathUtils.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/libs/hwui/utils/MathUtils.h b/libs/hwui/utils/MathUtils.h index 8d20f2142e73..5475898bff28 100644 --- a/libs/hwui/utils/MathUtils.h +++ b/libs/hwui/utils/MathUtils.h @@ -16,8 +16,8 @@ #ifndef MATHUTILS_H #define MATHUTILS_H -#include <algorithm> #include <math.h> +#include <algorithm> namespace android { namespace uirenderer { @@ -34,9 +34,7 @@ public: return (value >= -NON_ZERO_EPSILON) && (value <= NON_ZERO_EPSILON); } - inline static bool isPositive(float value) { - return value >= NON_ZERO_EPSILON; - } + inline static bool isPositive(float value) { return value >= NON_ZERO_EPSILON; } /** * Clamps alpha value, and snaps when very near 0 or 1 @@ -69,28 +67,24 @@ public: * Returns the number of points (beyond two, the start and end) needed to form a polygonal * approximation of an arc, with a given threshold value. */ - inline static int divisionsNeededToApproximateArc(float radius, - float angleInRads, float threshold) { + inline static int divisionsNeededToApproximateArc(float radius, float angleInRads, + float threshold) { const float errConst = (-threshold / radius + 1); const float targetCosVal = 2 * errConst * errConst - 1; // needed divisions are rounded up from approximation - return (int)(ceilf(angleInRads / acos(targetCosVal)/2)) * 2; + return (int)(ceilf(angleInRads / acos(targetCosVal) / 2)) * 2; } - inline static bool areEqual(float valueA, float valueB) { - return isZero(valueA - valueB); - } + inline static bool areEqual(float valueA, float valueB) { return isZero(valueA - valueB); } - template<typename T> + template <typename T> static inline T clamp(T a, T minValue, T maxValue) { return std::min(std::max(a, minValue), maxValue); } - inline static float lerp(float v1, float v2, float t) { - return v1 + ((v2 - v1) * t); - } -}; // class MathUtils + inline static float lerp(float v1, float v2, float t) { return v1 + ((v2 - v1) * t); } +}; // class MathUtils } /* namespace uirenderer */ } /* namespace android */ |