projects
/
platform
/
core
/
uifw
/
dali-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Few warnings removed (MSVC).
[platform/core/uifw/dali-core.git]
/
dali
/
public-api
/
math
/
math-utils.h
diff --git
a/dali/public-api/math/math-utils.h
b/dali/public-api/math/math-utils.h
index
11e406c
..
55024c7
100644
(file)
--- a/
dali/public-api/math/math-utils.h
+++ b/
dali/public-api/math/math-utils.h
@@
-1,8
+1,8
@@
-#ifndef
__DALI_MATH_UTILS_H__
-#define
__DALI_MATH_UTILS_H__
+#ifndef
DALI_MATH_UTILS_H
+#define
DALI_MATH_UTILS_H
/*
/*
- * Copyright (c) 201
5
Samsung Electronics Co., Ltd.
+ * Copyright (c) 201
9
Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-18,6
+18,9
@@
*
*/
*
*/
+// EXTERNAL INCLUDES
+#include <cstdint> // uint32_t
+
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/constants.h>
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/constants.h>
@@
-33,14
+36,14
@@
namespace Dali
* @brief Returns the next power of two.
*
* In case of numbers which are already a power of two this function returns the original number.
* @brief Returns the next power of two.
*
* In case of numbers which are already a power of two this function returns the original number.
- * If i is zero returns 1
+ * If i is zero returns 1
.
* @SINCE_1_0.0
* @SINCE_1_0.0
- * @param[in] i
i
nput number
- * @return
next power of two or i itself in case it's a power of two
+ * @param[in] i
I
nput number
+ * @return
The
next power of two or i itself in case it's a power of two
*/
*/
-inline u
nsigned int NextPowerOfTwo( unsigned in
t i )
+inline u
int32_t NextPowerOfTwo( uint32_
t i )
{
{
- DALI_ASSERT_ALWAYS(i <= 1u << (sizeof(u
nsigned
) * 8 - 1) && "Return type cannot represent the next power of two greater than the argument.");
+ DALI_ASSERT_ALWAYS(i <= 1u << (sizeof(u
int32_t
) * 8 - 1) && "Return type cannot represent the next power of two greater than the argument.");
if(i==0u)
{
return 1u;
if(i==0u)
{
return 1u;
@@
-60,10
+63,10
@@
inline unsigned int NextPowerOfTwo( unsigned int i )
* @brief Whether a number is power of two.
*
* @SINCE_1_0.0
* @brief Whether a number is power of two.
*
* @SINCE_1_0.0
- * @param[in] i
i
nput number
- * @return
true if i is power of two
+ * @param[in] i
I
nput number
+ * @return
True if i is power of two.
*/
*/
-inline bool IsPowerOfTwo( u
nsigned in
t i )
+inline bool IsPowerOfTwo( u
int32_
t i )
{
return (i != 0u) && ((i & (i - 1u)) == 0u);
}
{
return (i != 0u) && ((i & (i - 1u)) == 0u);
}
@@
-107,7
+110,7
@@
inline void ClampInPlace( T& value, const T& min, const T& max )
*
* @SINCE_1_0.0
* @param[in] offset The offset through the range @p low to @p high.
*
* @SINCE_1_0.0
* @param[in] offset The offset through the range @p low to @p high.
- * This value is clamped between 0 and 1
+ * This value is clamped between 0 and 1
.
* @param[in] low Lowest value in range
* @param[in] high Highest value in range
* @return A value between low and high.
* @param[in] low Lowest value in range
* @param[in] high Highest value in range
* @return A value between low and high.
@@
-131,7
+134,7
@@
inline float GetRangedEpsilon( float a, float b )
const float absA = fabsf( a );
const float absB = fabsf( b );
const float absF = absA > absB ? absA : absB;
const float absA = fabsf( a );
const float absB = fabsf( b );
const float absF = absA > absB ? absA : absB;
- const int
absI = absF;
+ const int
32_t absI = static_cast<int32_t>( absF ); // truncated
float epsilon = Math::MACHINE_EPSILON_10000;
if (absF < 0.1f)
float epsilon = Math::MACHINE_EPSILON_10000;
if (absF < 0.1f)
@@
-164,13
+167,17
@@
inline float GetRangedEpsilon( float a, float b )
* @param[in] value the value to compare
* @return true if the value is equal to zero
*/
* @param[in] value the value to compare
* @return true if the value is equal to zero
*/
+#if __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
+#endif
inline bool EqualsZero( float value )
{
return value == 0.0f;
}
inline bool EqualsZero( float value )
{
return value == 0.0f;
}
+#if __GNUC__
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
+#endif
/**
* @brief Helper function to compare equality of two floating point values.
/**
* @brief Helper function to compare equality of two floating point values.
@@
-207,12
+214,12
@@
inline bool Equals( float a, float b, float epsilon )
* @param[in] pos decimal place
* @return a rounded float
*/
* @param[in] pos decimal place
* @return a rounded float
*/
-inline float Round(
float value, int pos
)
+inline float Round(
float value, int32_t pos
)
{
float temp;
{
float temp;
- temp = value * powf( 10
, pos
);
- temp = floorf( temp + 0.5 );
- temp *= powf( 10
, -pos
);
+ temp = value * powf( 10
.f, static_cast<float>( pos )
);
+ temp = floorf( temp + 0.5
f
);
+ temp *= powf( 10
.f, static_cast<float>( -pos )
);
return temp;
}
return temp;
}
@@
-226,14
+233,16
@@
inline float Round(float value, int pos)
* start: 2
* end: 8
*
* start: 2
* end: 8
*
+ * @code
* 2 8
* (\ / start) (\ / end)
* |----x |
* 2 8
* (\ / start) (\ / end)
* |----x |
+ * @endcode
*
* The value x will be confined to this domain.
*
* The value x will be confined to this domain.
- * If x is below 2 e.g. 0, then it is wraped to 6.
+ * If x is below 2 e.g. 0, then it is wrap
p
ed to 6.
* If x is above or equal to 8 e.g. 8.1 then it is
* If x is above or equal to 8 e.g. 8.1 then it is
- * wrapped to 2.1
+ * wrapped to 2.1
.
*
* Domain wrapping is useful for various problems from
* calculating positions in a space that repeats, to
*
* Domain wrapping is useful for various problems from
* calculating positions in a space that repeats, to
@@
-245,7
+254,7
@@
inline float Round(float value, int pos)
* @param[in] end The end of the domain
*
* @return the wrapped value over the domain (start) (end)
* @param[in] end The end of the domain
*
* @return the wrapped value over the domain (start) (end)
- * @note
i
f start = end (i.e. size of domain 0), then wrapping will not occur
+ * @note
I
f start = end (i.e. size of domain 0), then wrapping will not occur
* and result will always be equal to start.
*
*/
* and result will always be equal to start.
*
*/
@@
-267,12
+276,14
@@
inline float WrapInDomain(float x, float start, float end)
* @brief Find the shortest distance (magnitude) and direction (sign)
* from (a) to (b) in domain (start) to (end).
*
* @brief Find the shortest distance (magnitude) and direction (sign)
* from (a) to (b) in domain (start) to (end).
*
- * (\ / start) (\ / end)
- * |-a b<----|
+ * @code
+ * (\ / start) (\ / end)
+ * |-a b<----|
+ * @endcode
*
* Knowing the shortest distance is useful with wrapped domains
*
* Knowing the shortest distance is useful with wrapped domains
- * to solve problems such as determing the closest object to
- * a given point, or determing whether turning left or turning
+ * to solve problems such as determin
in
g the closest object to
+ * a given point, or determin
in
g whether turning left or turning
* right is the shortest route to get from angle 10 degrees
* to angle 350 degrees (clearly in a 0-360 degree domain, turning
* left 20 degrees is quicker than turning right 340 degrees).
* right is the shortest route to get from angle 10 degrees
* to angle 350 degrees (clearly in a 0-360 degree domain, turning
* left 20 degrees is quicker than turning right 340 degrees).
@@
-288,8
+299,8
@@
inline float WrapInDomain(float x, float start, float end)
* @param start the start of the domain
* @param end the end of the domain
* @return the shortest direction (the sign) and distance (the magnitude)
* @param start the start of the domain
* @param end the end of the domain
* @return the shortest direction (the sign) and distance (the magnitude)
- * @note
a
ssumes both (a) and (b) are already within the domain
- * (start) to (end)
+ * @note
A
ssumes both (a) and (b) are already within the domain
+ * (start) to (end)
.
*
*/
inline float ShortestDistanceInDomain( float a, float b, float start, float end )
*
*/
inline float ShortestDistanceInDomain( float a, float b, float start, float end )
@@
-330,7
+341,7
@@
inline float ShortestDistanceInDomain( float a, float b, float start, float end
* @return -1 for negative values, +1 for positive values and 0 if value is 0
*/
template <typename T>
* @return -1 for negative values, +1 for positive values and 0 if value is 0
*/
template <typename T>
-int Sign( T value )
+int
32_t
Sign( T value )
{
return ( T(0) < value ) - ( value < T(0) );
}
{
return ( T(0) < value ) - ( value < T(0) );
}
@@
-340,4
+351,4
@@
int Sign( T value )
*/
} // namespace Dali
*/
} // namespace Dali
-#endif //
__DALI_MATH_UTILS_H__
+#endif //
DALI_MATH_UTILS_H