diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-03 14:53:03 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-05 08:56:36 -0700 |
commit | 66da7594263b657b78aff54a16905184505e275e (patch) | |
tree | 3f940c3852ff7a7d4f2b885c742e4fac06c84abc /src/mbgl/map/zoom_history.hpp | |
parent | fd104dd3c229ce42d149a143260407cd259b716c (diff) | |
download | qtlocation-mapboxgl-66da7594263b657b78aff54a16905184505e275e.tar.gz |
[core] Reduce use of RecalculateStyle
* Don't use it to track zoom changes. Instead, Style::update can use the zoom history to check for a change in zoom from the previous frame.
* Don't use it to track active property transitions. Style already knows which layers/light have an active transition, and can re-evaluate only those that do.
This leaves layer property changes as the only use of RecalculateStyle.
Diffstat (limited to 'src/mbgl/map/zoom_history.hpp')
-rw-r--r-- | src/mbgl/map/zoom_history.hpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/mbgl/map/zoom_history.hpp b/src/mbgl/map/zoom_history.hpp index 8c88ea6507..308846b1e3 100644 --- a/src/mbgl/map/zoom_history.hpp +++ b/src/mbgl/map/zoom_history.hpp @@ -12,25 +12,30 @@ struct ZoomHistory { TimePoint lastIntegerZoomTime; bool first = true; - void update(float z, const TimePoint& now) { + bool update(float z, const TimePoint& now) { if (first) { first = false; - lastIntegerZoom = std::floor(z); lastIntegerZoomTime = TimePoint(Duration::zero()); lastZoom = z; + return true; + } else { + if (std::floor(lastZoom) < std::floor(z)) { + lastIntegerZoom = std::floor(z); + lastIntegerZoomTime = now; + } else if (std::floor(lastZoom) > std::floor(z)) { + lastIntegerZoom = std::floor(z + 1); + lastIntegerZoomTime = now; + } + + if (z != lastZoom) { + lastZoom = z; + return true; + } + + return false; } - - if (std::floor(lastZoom) < std::floor(z)) { - lastIntegerZoom = std::floor(z); - lastIntegerZoomTime = now; - - } else if (std::floor(lastZoom) > std::floor(z)) { - lastIntegerZoom = std::floor(z + 1); - lastIntegerZoomTime = now; - } - - lastZoom = z; } }; + } // namespace mbgl |