diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-08-20 16:24:42 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-08-20 16:40:31 -0400 |
commit | 5989ff4eb781ca25172807d97bf4828438971bed (patch) | |
tree | 3410bec6ace053d78a39a0ece83459bfd261fb46 /src | |
parent | fd98607c5fcb14aaa29c046a0b7115f47aaf2ddc (diff) | |
download | qtlocation-mapboxgl-5989ff4eb781ca25172807d97bf4828438971bed.tar.gz |
use the global animationTime instead of querying our own time
this reduces the amount of std::chrono::steady_clock::now() calls
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/frame_history.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/renderer/frame_history.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/renderer/painter_symbol.cpp | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp index cdc60f4eb6..f54d04c573 100644 --- a/src/mbgl/renderer/frame_history.cpp +++ b/src/mbgl/renderer/frame_history.cpp @@ -3,7 +3,7 @@ using namespace mbgl; // Record frame history that will be used to calculate fading params -void FrameHistory::record(const TimePoint& now, float zoom) { +void FrameHistory::record(const TimePoint now, float zoom) { // first frame ever if (history.empty()) { history.emplace_back(FrameSnapshot{TimePoint::min(), zoom}); @@ -47,15 +47,13 @@ bool FrameHistory::needsAnimation(const Duration& duration) const { return false; } -FadeProperties FrameHistory::getFadeProperties(const Duration& duration) { - const TimePoint currentTime = Clock::now(); - +FadeProperties FrameHistory::getFadeProperties(const TimePoint now, const Duration& duration) { // Remove frames until only one is outside the duration, or until there are only three - while (history.size() > 3 && history[1].now + duration < currentTime) { + while (history.size() > 3 && history[1].now + duration < now) { history.pop_front(); } - if (history[1].now + duration < currentTime) { + if (history[1].now + duration < now) { history[0].z = history[1].z; } @@ -74,7 +72,7 @@ FadeProperties FrameHistory::getFadeProperties(const Duration& duration) { // At end of a zoom when the zoom stops changing continue pretending to zoom at that speed // bump is how much farther it would have been if it had continued zooming at the same rate - float bump = std::chrono::duration<float>(currentTime - lastFrame.now) / duration * fadedist; + float bump = std::chrono::duration<float>(now - lastFrame.now) / duration * fadedist; return FadeProperties { fadedist, diff --git a/src/mbgl/renderer/frame_history.hpp b/src/mbgl/renderer/frame_history.hpp index ef52b2a5ec..9193183f0d 100644 --- a/src/mbgl/renderer/frame_history.hpp +++ b/src/mbgl/renderer/frame_history.hpp @@ -11,7 +11,7 @@ namespace mbgl { struct FrameSnapshot { - explicit inline FrameSnapshot(const TimePoint& now_, float z_) : now(now_), z(z_) {} + explicit inline FrameSnapshot(TimePoint now_, float z_) : now(now_), z(z_) {} const TimePoint now; float z; }; @@ -26,10 +26,10 @@ struct FadeProperties { class FrameHistory { public: // Record frame history that will be used to calculate fading params - void record(const TimePoint& now, float zoom); + void record(TimePoint now, float zoom); bool needsAnimation(const Duration& duration) const; - FadeProperties getFadeProperties(const Duration& duration); + FadeProperties getFadeProperties(TimePoint now, const Duration& duration); public: std::deque<FrameSnapshot> history; diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 6d12768e2f..af0781d2e4 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -53,7 +53,7 @@ void Painter::renderSDF(SymbolBucket &bucket, sdfShader.u_zoom = (state.getNormalizedZoom() - zoomAdjust) * 10; // current zoom level - FadeProperties f = frameHistory.getFadeProperties(data.getDefaultFadeDuration()); + FadeProperties f = frameHistory.getFadeProperties(data.getAnimationTime(), data.getDefaultFadeDuration()); sdfShader.u_fadedist = f.fadedist * 10; sdfShader.u_minfadezoom = std::floor(f.minfadezoom * 10); sdfShader.u_maxfadezoom = std::floor(f.maxfadezoom * 10); |