diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-29 18:13:12 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-31 16:53:07 +0200 |
commit | 38f536049a8ed8f4bdf7706f4afcbbaf06c974c9 (patch) | |
tree | f65bb6ad0ebde1840e523b18d539f122548194ab /src/mbgl/util | |
parent | a70bfd89108cf1aef75181819ae43e550a69255e (diff) | |
download | qtlocation-mapboxgl-38f536049a8ed8f4bdf7706f4afcbbaf06c974c9.tar.gz |
[core] Moved util::log2 to its own header
- Added util::{MIN,MAX}_ZOOM_F to avoid consecutive conversions from
double to float
- Move util::log2 to its own header (part of mbgl/math)
Diffstat (limited to 'src/mbgl/util')
-rw-r--r-- | src/mbgl/util/math.cpp | 35 | ||||
-rw-r--r-- | src/mbgl/util/math.hpp | 6 |
2 files changed, 0 insertions, 41 deletions
diff --git a/src/mbgl/util/math.cpp b/src/mbgl/util/math.cpp deleted file mode 100644 index 7b1516c041..0000000000 --- a/src/mbgl/util/math.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <mbgl/util/math.hpp> - -namespace mbgl { -namespace util { - -// From http://stackoverflow.com/questions/3272424/compute-fast-log-base-2-ceiling -uint32_t ceil_log2(uint64_t x) { - static const uint64_t t[6] = {0xFFFFFFFF00000000, 0x00000000FFFF0000, - 0x000000000000FF00, 0x00000000000000F0, - 0x000000000000000C, 0x0000000000000002}; - uint32_t y = (((x & (x - 1)) == 0) ? 0 : 1); - uint32_t j = 32; - - for (const auto& i : t) { - const uint32_t k = (((x & i) == 0) ? 0 : j); - y += k; - x >>= k; - j >>= 1; - } - - return y; -} - -double log2(double x) { -// log2() is producing wrong results on ARMv5 binaries -// running on ARMv7+ CPUs. -#if defined(__ANDROID__) - return std::log(x) / 0.6931471805599453; // log(x) / log(2) -#else - return ::log2(x); -#endif -} - -} // namespace util -} // namespace mbgl diff --git a/src/mbgl/util/math.hpp b/src/mbgl/util/math.hpp index 5d4220d0a2..f969ecaedd 100644 --- a/src/mbgl/util/math.hpp +++ b/src/mbgl/util/math.hpp @@ -106,11 +106,5 @@ T smoothstep(T edge0, T edge1, T x) { return t * t * (T(3) - T(2) * t); } -// Computes the log2(x) rounded up to the next integer. -// (== number of bits required to store x) -uint32_t ceil_log2(uint64_t x); - -double log2(double x); - } // namespace util } // namespace mbgl |