[core] FrameHistory cleanups

This commit is contained in:
Bruno de Oliveira Abinader
2016-03-24 20:31:39 +02:00
parent fe1b417d04
commit 3afdfc15a1
2 changed files with 9 additions and 9 deletions

View File

@@ -1,9 +1,10 @@
#include <mbgl/renderer/frame_history.hpp>
#include <mbgl/util/math.hpp>
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,7 +48,7 @@ bool FrameHistory::needsAnimation(const Duration& duration) const {
return false;
}
FadeProperties FrameHistory::getFadeProperties(const TimePoint now, const Duration& duration) {
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 < now) {
history.pop_front();
@@ -61,8 +62,8 @@ FadeProperties FrameHistory::getFadeProperties(const TimePoint now, const Durati
float startingZ = history.front().z;
const FrameSnapshot lastFrame = history.back();
float endingZ = lastFrame.z;
float lowZ = ::fmin(startingZ, endingZ);
float highZ = ::fmax(startingZ, endingZ);
float lowZ = util::min(startingZ, endingZ);
float highZ = util::max(startingZ, endingZ);
// Calculate the speed of zooming, and how far it would zoom in terms of zoom levels in one
// duration

View File

@@ -11,7 +11,6 @@
namespace mbgl {
struct FrameSnapshot {
explicit inline FrameSnapshot(TimePoint now_, float z_) : now(now_), z(z_) {}
const TimePoint now;
float z;
};
@@ -26,12 +25,12 @@ struct FadeProperties {
class FrameHistory {
public:
// Record frame history that will be used to calculate fading params
void record(TimePoint now, float zoom);
void record(const TimePoint&, float zoom);
bool needsAnimation(const Duration& duration) const;
FadeProperties getFadeProperties(TimePoint now, const Duration& duration);
bool needsAnimation(const Duration&) const;
FadeProperties getFadeProperties(const TimePoint&, const Duration&);
public:
private:
std::deque<FrameSnapshot> history;
};