summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2015-11-26 22:38:14 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2015-11-27 17:47:02 +0200
commit1f0820c8e82810fb957cb1cd17fb4327debfc0e5 (patch)
tree976533b4a2b03ab033143ebcd013199222c7a9ca /src
parent044e92f5e8ff2049702aa9ff6bbf4eecf9d86fa7 (diff)
downloadqtlocation-mapboxgl-1f0820c8e82810fb957cb1cd17fb4327debfc0e5.tar.gz
[core] Added MapDebugOptions
Map debug options are now cycled up to all debug options enabled, then back to none.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map.cpp10
-rw-r--r--src/mbgl/map/map_data.hpp23
-rw-r--r--src/mbgl/renderer/debug_bucket.cpp19
-rw-r--r--src/mbgl/renderer/debug_bucket.hpp4
-rw-r--r--src/mbgl/renderer/painter_debug.cpp7
5 files changed, 40 insertions, 23 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 713222fe54..573500fd65 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -420,17 +420,17 @@ void Map::removeSprite(const std::string& name) {
#pragma mark - Toggles
-void Map::setDebug(bool value) {
- data->setDebug(value);
+void Map::setDebug(MapDebugOptions mode) {
+ data->setDebug(mode);
update(Update::Repaint);
}
-void Map::toggleDebug() {
- data->toggleDebug();
+void Map::cycleDebugOptions() {
+ data->cycleDebugOptions();
update(Update::Repaint);
}
-bool Map::getDebug() const {
+MapDebugOptions Map::getDebug() const {
return data->getDebug();
}
diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp
index c1898fc37f..597048167c 100644
--- a/src/mbgl/map/map_data.hpp
+++ b/src/mbgl/map/map_data.hpp
@@ -49,14 +49,23 @@ public:
std::vector<std::string> getClasses() const;
- inline bool getDebug() const {
- return debug;
+ inline MapDebugOptions getDebug() const {
+ return debugOptions;
}
- inline bool toggleDebug() {
- return debug ^= 1u;
+
+ inline void cycleDebugOptions() {
+ if (debugOptions & MapDebugOptions::Timestamps)
+ debugOptions = MapDebugOptions::NoDebug;
+ else if (debugOptions & MapDebugOptions::ParseStatus)
+ debugOptions = debugOptions | MapDebugOptions::Timestamps;
+ else if (debugOptions & MapDebugOptions::TileBorders)
+ debugOptions = debugOptions | MapDebugOptions::ParseStatus;
+ else
+ debugOptions = MapDebugOptions::TileBorders;
}
- inline void setDebug(bool value) {
- debug = value;
+
+ inline void setDebug(MapDebugOptions debugOptions_) {
+ debugOptions = debugOptions_;
}
inline bool getCollisionDebug() const {
@@ -136,7 +145,7 @@ private:
mutable std::mutex mtx;
std::vector<std::string> classes;
- std::atomic<uint8_t> debug { false };
+ std::atomic<MapDebugOptions> debugOptions { MapDebugOptions::NoDebug };
std::atomic<uint8_t> collisionDebug { false };
std::atomic<Duration> animationTime;
std::atomic<Duration> defaultFadeDuration;
diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp
index 048ded2cda..a1a24eab73 100644
--- a/src/mbgl/renderer/debug_bucket.cpp
+++ b/src/mbgl/renderer/debug_bucket.cpp
@@ -10,19 +10,24 @@
using namespace mbgl;
-DebugBucket::DebugBucket(const TileID id, const TileData::State state_, Seconds modified_, Seconds expires_)
+DebugBucket::DebugBucket(const TileID id, const TileData::State state_, Seconds modified_, Seconds expires_, MapDebugOptions debugMode_)
: state(state_),
modified(modified_),
- expires(expires_) {
- const std::string text = std::string(id) + " - " + TileData::StateToString(state);
- fontBuffer.addText(text.c_str(), 50, 200, 5);
+ expires(expires_),
+ debugMode(debugMode_) {
+ double baseline = 200;
+ if (debugMode & MapDebugOptions::ParseStatus) {
+ const std::string text = std::string(id) + " - " + TileData::StateToString(state);
+ fontBuffer.addText(text.c_str(), 50, baseline, 5);
+ baseline += 200;
+ }
- if (modified > Seconds::zero() && expires > Seconds::zero()) {
+ if (debugMode & MapDebugOptions::Timestamps && modified > Seconds::zero() && expires > Seconds::zero()) {
const std::string modifiedText = "modified: " + util::iso8601(modified.count());
- fontBuffer.addText(modifiedText.c_str(), 50, 400, 5);
+ fontBuffer.addText(modifiedText.c_str(), 50, baseline, 5);
const std::string expiresText = "expires: " + util::iso8601(expires.count());
- fontBuffer.addText(expiresText.c_str(), 50, 600, 5);
+ fontBuffer.addText(expiresText.c_str(), 50, baseline + 200, 5);
}
}
diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp
index fe09afc03f..7edee6beec 100644
--- a/src/mbgl/renderer/debug_bucket.hpp
+++ b/src/mbgl/renderer/debug_bucket.hpp
@@ -2,6 +2,7 @@
#define MBGL_RENDERER_DEBUGBUCKET
#include <mbgl/map/tile_data.hpp>
+#include <mbgl/map/mode.hpp>
#include <mbgl/geometry/debug_font_buffer.hpp>
#include <mbgl/geometry/vao.hpp>
#include <mbgl/util/chrono.hpp>
@@ -12,7 +13,7 @@ class PlainShader;
class DebugBucket : private util::noncopyable {
public:
- DebugBucket(TileID id, TileData::State, Seconds modified, Seconds expires);
+ DebugBucket(TileID id, TileData::State, Seconds modified, Seconds expires, MapDebugOptions);
void drawLines(PlainShader& shader);
void drawPoints(PlainShader& shader);
@@ -20,6 +21,7 @@ public:
const TileData::State state;
const Seconds modified;
const Seconds expires;
+ const MapDebugOptions debugMode;
private:
DebugFontBuffer fontBuffer;
diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp
index 88eca9ffb1..0a0900526a 100644
--- a/src/mbgl/renderer/painter_debug.cpp
+++ b/src/mbgl/renderer/painter_debug.cpp
@@ -12,7 +12,7 @@ using namespace mbgl;
void Painter::renderTileDebug(const Tile& tile) {
MBGL_DEBUG_GROUP(std::string { "debug " } + std::string(tile.id));
assert(tile.data);
- if (data.getDebug()) {
+ if (data.getDebug() != MapDebugOptions::NoDebug) {
prepareTile(tile);
renderDebugText(*tile.data, tile.matrix);
renderDebugFrame(tile.matrix);
@@ -26,8 +26,9 @@ void Painter::renderDebugText(TileData& tileData, const mat4 &matrix) {
if (!tileData.debugBucket || tileData.debugBucket->state != tileData.getState()
|| tileData.debugBucket->modified != tileData.modified
- || tileData.debugBucket->expires != tileData.expires) {
- tileData.debugBucket = std::make_unique<DebugBucket>(tileData.id, tileData.getState(), tileData.modified, tileData.expires);
+ || tileData.debugBucket->expires != tileData.expires
+ || tileData.debugBucket->debugMode != data.getDebug()) {
+ tileData.debugBucket = std::make_unique<DebugBucket>(tileData.id, tileData.getState(), tileData.modified, tileData.expires, data.getDebug());
}
config.program = plainShader->program;