2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiEffects_RendererMathAdapterFunctions.h
20 * @brief The adapter math functions for user types
24 #ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_ADAPTER_FUNCTIONS_H_
25 #define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_ADAPTER_FUNCTIONS_H_
27 #include <renderer/math/FUiEffects_RendererMathCommon.h>
29 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math
32 inline float EffectsSqrt(float value);
33 inline double EffectsSqrt(double value);
35 inline float EffectsCos(float angle);
36 inline double EffectsCos(double angle);
37 inline float EffectsAcos(float angle);
38 inline double EffectsAcos(double angle);
40 inline float EffectsSin(float angle);
41 inline double EffectsSin(double angle);
42 inline float EffectsAsin(float angle);
43 inline double EffectsAsin(double angle);
45 template<class T> inline T EffectsAbs(const T& value);
46 inline float EffectsAbs(const float& value);
47 inline double EffectsAbs(const double& value);
49 inline float EffectsAtan2(float x, float y);
50 inline double EffectsAtan2(double x, double y);
52 inline float EffectsAtan(float value);
53 inline double EffectsAtan(double value);
55 template<class T> struct EffectsEpsilon
57 static inline const T& Epsilon(void)
59 return get_epsilon(static_cast<const T*>(0));
63 template<> struct EffectsEpsilon<float>
65 static inline const float& Epsilon(void)
71 template<> struct EffectsEpsilon<double>
73 static inline const double& Epsilon(void)
79 inline bool EffectsEqual(const float& lhv, const float& rhv, const float& epsilon = F_EPS);
80 inline bool EffectsEqual(const double& lhv, const double& rhv, const double& epsilon = D_EPS);
82 template<class T> inline void EffectsSwap(T& lhv, T& rhv);
83 inline void EffectsSwap(float& lhv, float& rhv);
84 inline void EffectsSwap(double& lhv, double& rhv);
86 template<class T> inline T EffectsClamp(const T& value, const T& min, const T& max);
87 inline float EffectsClamp(const float& value, const float& min, const float& max);
88 inline double EffectsClamp(const double& value, const double& min, const double& max);
90 template<class T> inline T EffectsLerp(const T& from, const T& to, const T& coeff);
91 inline float EffectsLerp(const float& from, const float& to, const float& coeff);
92 inline double EffectsLerp(const double& from, const double& to, const double& coeff);
93 inline int EffectsLerp(const int& from, const int& to, const int& coeff);
94 inline unsigned int EffectsLerp(const unsigned int& from, const unsigned int& to, const unsigned int& coeff);
96 template<class T> inline T EffectsMin(const T& a1, const T& a2);
97 template<class T> inline T EffectsMin3(const T& a1, const T& a2, const T& a3);
98 template<class T> inline T EffectsMax(const T& a1, const T& a2);
99 template<class T> inline T EffectsMax3(const T& a1, const T& a2, const T& a3);
101 inline float EffectsSqrt(float value)
105 inline double EffectsSqrt(double value)
110 template<class T> inline bool EffectsEqual(const T& lhv, const T& rhv, const T& epsilon = EffectsEpsilon<T>::epsilon())
114 inline bool EffectsEqual(const float& lhv, const float& rhv, const float& epsilon)
116 return (lhv + epsilon >= rhv) && (lhv - epsilon <= rhv);
118 inline bool EffectsEqual(const double& lhv, const double& rhv, const double& epsilon)
120 return (lhv + epsilon >= rhv) && (lhv - epsilon <= rhv);
123 inline float EffectsCos(float angle)
127 inline double EffectsCos(double angle)
131 inline float EffectsAcos(float angle)
135 inline double EffectsAcos(double angle)
140 inline float EffectsSin(float angle)
144 inline double EffectsSin(double angle)
149 inline float EffectsAsin(float angle)
153 inline double EffectsAsin(double angle)
158 template<class T> inline T EffectsAbs(const T& value)
162 inline float EffectsAbs(const float &value)
166 inline double EffectsAbs(const double &value)
171 inline float EffectsAtan2(float x, float y)
175 inline double EffectsAtan2(double x, double y)
180 inline float EffectsAtan(float value)
184 inline double EffectsAtan(double value)
189 template<class T> inline void EffectsSwap(T& lhv, T& rhv)
195 inline void EffectsSwap(float& lhv, float& rhv)
199 inline void EffectsSwap(double& lhv, double& rhv)
204 template<class T> inline T EffectsClamp(const T& value, const T& min, const T& max)
216 inline float EffectsClamp(const float& value, const float& min, const float& max)
228 inline double EffectsClamp(const double& value, const double& min, const double& max)
241 template<class T> inline T EffectsLerp(const T& from, const T& to, const T& coeff)
243 return from + (to - from) * coeff;
245 inline float EffectsLerp(const float& from, const float& to, const float& coeff)
247 return from + (to - from) * coeff;
249 inline double EffectsLerp(const double& from, const double& to, const double& coeff)
251 return from + (to - from) * coeff;
253 inline int EffectsLerp(const int& from, const int& to, const int& coeff)
255 return from + (((to - from) * coeff) >> 8);
257 inline unsigned int EffectsLerp(const unsigned int& from, const unsigned int& to, const unsigned int& coeff)
259 return from + (((to - from) * coeff) >> 8);
262 template<class T> inline T EffectsMin(const T& a1, const T& a2)
270 template<class T> inline T EffectsMin3(const T& a1, const T& a2, const T& a3)
272 return EffectsMin(EffectsMin(a1, a2), a3);
274 template<class T> inline T EffectsMax(const T& a1, const T& a2)
283 template<class T> inline T EffectsMax3(const T& a1, const T& a2, const T& a3)
285 return EffectsMax(EffectsMax(a1, a2), a3);
288 }}}}} //Tizen::Ui::Effects::_Renderer::Math
290 #endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_ADAPTER_FUNCTIONS_H_