summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-03-20 18:53:44 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-03-23 11:01:02 +0100
commit03e400e00224e8012d4272ad9ebcba0bc11ed3f5 (patch)
tree9a633f874075da160f783e80df7ea011f8651ecf /src
parentebd2985f785e19f3d4976f2d803ac017b755d0d9 (diff)
downloadqtlocation-mapboxgl-03e400e00224e8012d4272ad9ebcba0bc11ed3f5.tar.gz
make the debug flag atomic and move to MapData
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map.cpp15
-rw-r--r--src/mbgl/map/map_data.hpp6
2 files changed, 15 insertions, 6 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 57000e040c..e00cf6e0ab 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -591,18 +591,17 @@ void Map::updateAnnotationTiles(std::vector<Tile::ID>& ids) {
#pragma mark - Toggles
void Map::setDebug(bool value) {
- debug = value;
- assert(painter);
- painter->setDebug(debug);
- triggerUpdate();
+ data->setDebug(value);
+ triggerUpdate(Update::Debug);
}
void Map::toggleDebug() {
- setDebug(!debug);
+ data->toggleDebug();
+ triggerUpdate(Update::Debug);
}
bool Map::getDebug() const {
- return debug;
+ return data->getDebug();
}
void Map::addClass(const std::string& klass) {
@@ -765,6 +764,10 @@ void Map::prepare() {
if (u & static_cast<UpdateType>(Update::StyleInfo)) {
reloadStyle();
}
+ if (u & static_cast<UpdateType>(Update::Debug)) {
+ assert(painter);
+ painter->setDebug(data->getDebug());
+ }
// Update transform transitions.
animationTime = std::chrono::steady_clock::now();
diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp
index 98d2518a2c..55bf5f7f6e 100644
--- a/src/mbgl/map/map_data.hpp
+++ b/src/mbgl/map/map_data.hpp
@@ -3,6 +3,7 @@
#include <string>
#include <mutex>
+#include <atomic>
namespace mbgl {
@@ -25,10 +26,15 @@ public:
styleInfo = info;
}
+ inline bool getDebug() const { return debug; }
+ inline bool toggleDebug() { return debug ^= 1u; }
+ inline void setDebug(bool value) { debug = value; }
+
private:
mutable std::mutex mtx;
StyleInfo styleInfo;
+ std::atomic<uint8_t> debug;
};
}