move animationTime to MapData store
This commit is contained in:
@@ -164,7 +164,7 @@ public:
|
||||
bool getDebug() const;
|
||||
|
||||
inline const TransformState &getState() const { return state; }
|
||||
inline std::chrono::steady_clock::time_point getTime() const { return animationTime; }
|
||||
std::chrono::steady_clock::time_point getTime() const;
|
||||
inline AnnotationManager& getAnnotationManager() const { return *annotationManager; }
|
||||
|
||||
private:
|
||||
@@ -255,8 +255,6 @@ private:
|
||||
|
||||
std::chrono::steady_clock::duration defaultTransitionDuration;
|
||||
|
||||
std::chrono::steady_clock::time_point animationTime = std::chrono::steady_clock::time_point::min();
|
||||
|
||||
std::set<util::ptr<StyleSource>> activeSources;
|
||||
|
||||
std::atomic<UpdateType> updated;
|
||||
|
||||
@@ -604,6 +604,10 @@ bool Map::getDebug() const {
|
||||
return data->getDebug();
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::time_point Map::getTime() const {
|
||||
return data->getAnimationTime();
|
||||
}
|
||||
|
||||
void Map::addClass(const std::string& klass) {
|
||||
if (hasClass(klass)) return;
|
||||
classes.push_back(klass);
|
||||
@@ -770,15 +774,15 @@ void Map::prepare() {
|
||||
}
|
||||
|
||||
// Update transform transitions.
|
||||
animationTime = std::chrono::steady_clock::now();
|
||||
|
||||
const auto animationTime = std::chrono::steady_clock::now();
|
||||
data->setAnimationTime(animationTime);
|
||||
if (transform.needsTransition()) {
|
||||
transform.updateTransitions(animationTime);
|
||||
}
|
||||
|
||||
state = transform.currentState();
|
||||
|
||||
animationTime = std::chrono::steady_clock::now();
|
||||
|
||||
if (style) {
|
||||
updateSources();
|
||||
style->updateProperties(state.getNormalizedZoom(), animationTime);
|
||||
@@ -803,7 +807,7 @@ void Map::render() {
|
||||
|
||||
assert(painter);
|
||||
painter->render(*style, activeSources,
|
||||
state, animationTime);
|
||||
state, data->getAnimationTime());
|
||||
// Schedule another rerender when we definitely need a next frame.
|
||||
if (transform.needsTransition() || style->hasTransitions()) {
|
||||
triggerUpdate();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -17,6 +18,10 @@ class MapData {
|
||||
using Lock = std::lock_guard<std::mutex>;
|
||||
|
||||
public:
|
||||
inline MapData() {
|
||||
setAnimationTime(std::chrono::steady_clock::time_point::min());
|
||||
}
|
||||
|
||||
inline StyleInfo getStyleInfo() const {
|
||||
Lock lock(mtx);
|
||||
return styleInfo;
|
||||
@@ -26,15 +31,31 @@ public:
|
||||
styleInfo = info;
|
||||
}
|
||||
|
||||
inline bool getDebug() const { return debug; }
|
||||
inline bool toggleDebug() { return debug ^= 1u; }
|
||||
inline void setDebug(bool value) { debug = value; }
|
||||
inline bool getDebug() const {
|
||||
return debug;
|
||||
}
|
||||
inline bool toggleDebug() {
|
||||
return debug ^= 1u;
|
||||
}
|
||||
inline void setDebug(bool value) {
|
||||
debug = value;
|
||||
}
|
||||
|
||||
inline std::chrono::steady_clock::time_point getAnimationTime() const {
|
||||
// We're casting the time_point to and from a duration because libstdc++
|
||||
// has a bug that doesn't allow time_points to be atomic.
|
||||
return std::chrono::steady_clock::time_point(animationTime);
|
||||
}
|
||||
inline void setAnimationTime(std::chrono::steady_clock::time_point timePoint) {
|
||||
animationTime = timePoint.time_since_epoch();
|
||||
};
|
||||
|
||||
private:
|
||||
mutable std::mutex mtx;
|
||||
|
||||
StyleInfo styleInfo;
|
||||
std::atomic<uint8_t> debug;
|
||||
std::atomic<uint8_t> debug { false };
|
||||
std::atomic<std::chrono::steady_clock::time_point::duration> animationTime;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user