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
Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[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
1c70719
..
521d266
100644
(file)
--- a/
dali/public-api/math/math-utils.h
+++ b/
dali/public-api/math/math-utils.h
@@
-2,7
+2,7
@@
#define __DALI_MATH_UTILS_H__
/*
#define __DALI_MATH_UTILS_H__
/*
- * Copyright (c) 201
5
Samsung Electronics Co., Ltd.
+ * Copyright (c) 201
8
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>
@@
-38,9
+41,9
@@
namespace Dali
* @param[in] i Input number
* @return The next power of two or i itself in case it's a power of two
*/
* @param[in] i Input 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;
@@
-63,7
+66,7
@@
inline unsigned int NextPowerOfTwo( unsigned int i )
* @param[in] i Input number
* @return True if i is power of two.
*/
* @param[in] i Input 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);
}
@@
-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)
@@
-207,12
+210,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;
}
@@
-334,7
+337,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) );
}