summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-08-13 12:20:03 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-08-22 10:17:25 +0300
commit80e4b2f1abfb59cf956d8fdea4576e566357ba25 (patch)
treec78979a4cff069c3bc59f999fb7afb9d1de1e1bd
parentd21f19686bad074e8ae4ef103e10191665feaaed (diff)
downloadqtlocation-mapboxgl-80e4b2f1abfb59cf956d8fdea4576e566357ba25.tar.gz
[core] Update ZoomHistory.lastInteger{Zoom,Time} if different from floor zoom
-rw-r--r--src/mbgl/map/zoom_history.hpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/mbgl/map/zoom_history.hpp b/src/mbgl/map/zoom_history.hpp
index 697e28573c..ddec53e6af 100644
--- a/src/mbgl/map/zoom_history.hpp
+++ b/src/mbgl/map/zoom_history.hpp
@@ -8,34 +8,39 @@ namespace mbgl {
struct ZoomHistory {
float lastZoom;
+ float lastFloorZoom;
float lastIntegerZoom;
TimePoint lastIntegerZoomTime;
bool first = true;
bool update(float z, const TimePoint& now) {
constexpr TimePoint zero = TimePoint(Duration::zero());
+ const float floorZ = std::floor(z);
+
if (first) {
first = false;
- lastIntegerZoom = std::floor(z);
+ lastIntegerZoom = floorZ;
lastIntegerZoomTime = zero;
lastZoom = z;
+ lastFloorZoom = floorZ;
+ return true;
+ }
+
+ if (lastFloorZoom > floorZ) {
+ lastIntegerZoom = floorZ + 1;
+ lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
+ } else if (lastFloorZoom < floorZ || lastIntegerZoom != floorZ) {
+ lastIntegerZoom = floorZ;
+ lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
+ }
+
+ if (z != lastZoom) {
+ lastZoom = z;
+ lastFloorZoom = floorZ;
return true;
- } else {
- if (std::floor(lastZoom) < std::floor(z)) {
- lastIntegerZoom = std::floor(z);
- lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
- } else if (std::floor(lastZoom) > std::floor(z)) {
- lastIntegerZoom = std::floor(z + 1);
- lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
- }
-
- if (z != lastZoom) {
- lastZoom = z;
- return true;
- }
-
- return false;
}
+
+ return false;
}
};