[core] Added MapDebugOptions
Map debug options are now cycled up to all debug options enabled, then back to none.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user