MapContext::updated doesn't need to be atomic

This commit is contained in:
John Firebaugh
2015-04-23 16:02:22 -07:00
parent 8bb7fc64ff
commit 59255a3d9e
2 changed files with 9 additions and 9 deletions

View File

@@ -188,27 +188,25 @@ void MapContext::update() {
const auto now = Clock::now();
data.setAnimationTime(now);
auto u = updated.exchange(static_cast<UpdateType>(Update::Nothing)) |
data.transform.updateTransitions(now);
updated |= data.transform.updateTransitions(now);
transformState = data.transform.currentState();
if (u & static_cast<UpdateType>(Update::Debug)) {
if (updated & static_cast<UpdateType>(Update::Debug)) {
assert(painter);
painter->setDebug(data.getDebug());
}
if (style) {
if (u & static_cast<UpdateType>(Update::DefaultTransitionDuration)) {
if (updated & static_cast<UpdateType>(Update::DefaultTransitionDuration)) {
style->setDefaultTransitionDuration(data.getDefaultTransitionDuration());
}
if (u & static_cast<UpdateType>(Update::Classes)) {
if (updated & static_cast<UpdateType>(Update::Classes)) {
style->cascade(data.getClasses());
}
if (u & static_cast<UpdateType>(Update::Classes) ||
u & static_cast<UpdateType>(Update::Zoom)) {
if (updated & static_cast<UpdateType>(Update::Classes) ||
updated & static_cast<UpdateType>(Update::Zoom)) {
style->recalculate(transformState.getNormalizedZoom(), now);
}
@@ -220,6 +218,8 @@ void MapContext::update() {
view.invalidate([this] { render(); });
}
updated = static_cast<UpdateType>(Update::Nothing);
}
void MapContext::renderStill(StillImageCallback fn) {

View File

@@ -74,7 +74,7 @@ private:
Environment env;
EnvironmentScope envScope;
std::atomic<UpdateType> updated { static_cast<UpdateType>(Update::Nothing) };
UpdateType updated { static_cast<UpdateType>(Update::Nothing) };
std::unique_ptr<uv::async> asyncUpdate;
std::unique_ptr<Worker> workers;