[core] Display modify, expires debug information
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef MBGL_UTIL_TIME
|
||||
#define MBGL_UTIL_TIME
|
||||
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
@@ -12,6 +14,9 @@ namespace util {
|
||||
// Returns the RFC1123 formatted date. E.g. "Tue, 04 Nov 2014 02:13:24 GMT"
|
||||
std::string rfc1123(std::time_t time);
|
||||
|
||||
// YYYY-mm-dd HH:MM:SS e.g. "2015-11-26 16:11:23"
|
||||
std::string iso8601(std::time_t time);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user