diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-25 16:01:08 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-27 17:47:02 +0200 |
commit | 044e92f5e8ff2049702aa9ff6bbf4eecf9d86fa7 (patch) | |
tree | cefa84bba5f90291678f8f44acc70e0ecf8a0cdc /src/mbgl | |
parent | 591e0dde2fb97f4d40db6e11b5fbfbe4c3c0efc8 (diff) | |
download | qtlocation-mapboxgl-044e92f5e8ff2049702aa9ff6bbf4eecf9d86fa7.tar.gz |
[core] Display modify, expires debug information
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/renderer/debug_bucket.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/renderer/debug_bucket.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/renderer/painter_debug.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/util/time.cpp | 8 |
4 files changed, 29 insertions, 4 deletions
diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp index 63562a6714..048ded2cda 100644 --- a/src/mbgl/renderer/debug_bucket.cpp +++ b/src/mbgl/renderer/debug_bucket.cpp @@ -1,6 +1,7 @@ #include <mbgl/renderer/debug_bucket.hpp> #include <mbgl/renderer/painter.hpp> #include <mbgl/shader/plain_shader.hpp> +#include <mbgl/util/time.hpp> #include <mbgl/platform/gl.hpp> @@ -9,9 +10,20 @@ using namespace mbgl; -DebugBucket::DebugBucket(const TileID id, const TileData::State state_) : state(state_) { +DebugBucket::DebugBucket(const TileID id, const TileData::State state_, Seconds modified_, Seconds expires_) + : state(state_), + modified(modified_), + expires(expires_) { const std::string text = std::string(id) + " - " + TileData::StateToString(state); fontBuffer.addText(text.c_str(), 50, 200, 5); + + if (modified > Seconds::zero() && expires > Seconds::zero()) { + const std::string modifiedText = "modified: " + util::iso8601(modified.count()); + fontBuffer.addText(modifiedText.c_str(), 50, 400, 5); + + const std::string expiresText = "expires: " + util::iso8601(expires.count()); + fontBuffer.addText(expiresText.c_str(), 50, 600, 5); + } } void DebugBucket::drawLines(PlainShader& shader) { diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp index a5b163c0a3..fe09afc03f 100644 --- a/src/mbgl/renderer/debug_bucket.hpp +++ b/src/mbgl/renderer/debug_bucket.hpp @@ -4,6 +4,7 @@ #include <mbgl/map/tile_data.hpp> #include <mbgl/geometry/debug_font_buffer.hpp> #include <mbgl/geometry/vao.hpp> +#include <mbgl/util/chrono.hpp> namespace mbgl { @@ -11,12 +12,14 @@ class PlainShader; class DebugBucket : private util::noncopyable { public: - DebugBucket(TileID id, TileData::State); + DebugBucket(TileID id, TileData::State, Seconds modified, Seconds expires); void drawLines(PlainShader& shader); void drawPoints(PlainShader& shader); const TileData::State state; + const Seconds modified; + const Seconds expires; private: DebugFontBuffer fontBuffer; diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp index b981dae260..88eca9ffb1 100644 --- a/src/mbgl/renderer/painter_debug.cpp +++ b/src/mbgl/renderer/painter_debug.cpp @@ -24,8 +24,10 @@ void Painter::renderDebugText(TileData& tileData, const mat4 &matrix) { config.depthTest = GL_FALSE; - if (!tileData.debugBucket || tileData.debugBucket->state != tileData.getState()) { - tileData.debugBucket = std::make_unique<DebugBucket>(tileData.id, tileData.getState()); + 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); } config.program = plainShader->program; diff --git a/src/mbgl/util/time.cpp b/src/mbgl/util/time.cpp index 4612ae29b5..00a3419cca 100644 --- a/src/mbgl/util/time.cpp +++ b/src/mbgl/util/time.cpp @@ -19,5 +19,13 @@ std::string rfc1123(std::time_t time) { return buffer; } +std::string iso8601(std::time_t time) { + std::tm info; + gmtime_r(&time, &info); + char buffer[30]; + std::strftime(buffer, sizeof(buffer), "%F %T", &info); + return buffer; +} + } } |