From 59255a3d9e48196ee0c7d3a2850d5f37d2e4e8b5 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 23 Apr 2015 16:02:22 -0700 Subject: [PATCH] MapContext::updated doesn't need to be atomic --- src/mbgl/map/map_context.cpp | 16 ++++++++-------- src/mbgl/map/map_context.hpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index e10a46e99..da71b787d 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -188,27 +188,25 @@ void MapContext::update() { const auto now = Clock::now(); data.setAnimationTime(now); - auto u = updated.exchange(static_cast(Update::Nothing)) | - data.transform.updateTransitions(now); - + updated |= data.transform.updateTransitions(now); transformState = data.transform.currentState(); - if (u & static_cast(Update::Debug)) { + if (updated & static_cast(Update::Debug)) { assert(painter); painter->setDebug(data.getDebug()); } if (style) { - if (u & static_cast(Update::DefaultTransitionDuration)) { + if (updated & static_cast(Update::DefaultTransitionDuration)) { style->setDefaultTransitionDuration(data.getDefaultTransitionDuration()); } - if (u & static_cast(Update::Classes)) { + if (updated & static_cast(Update::Classes)) { style->cascade(data.getClasses()); } - if (u & static_cast(Update::Classes) || - u & static_cast(Update::Zoom)) { + if (updated & static_cast(Update::Classes) || + updated & static_cast(Update::Zoom)) { style->recalculate(transformState.getNormalizedZoom(), now); } @@ -220,6 +218,8 @@ void MapContext::update() { view.invalidate([this] { render(); }); } + + updated = static_cast(Update::Nothing); } void MapContext::renderStill(StillImageCallback fn) { diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index 6e7b082f2..2c9f28708 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -74,7 +74,7 @@ private: Environment env; EnvironmentScope envScope; - std::atomic updated { static_cast(Update::Nothing) }; + UpdateType updated { static_cast(Update::Nothing) }; std::unique_ptr asyncUpdate; std::unique_ptr workers;