[core] Added MapDebugOptions
Map debug options are now cycled up to all debug options enabled, then back to none.
This commit is contained in:
@@ -1330,8 +1330,8 @@ public final class MapView extends FrameLayout {
|
||||
* @see MapView#isDebugActive()
|
||||
*/
|
||||
@UiThread
|
||||
public void toggleDebug() {
|
||||
mNativeMapView.toggleDebug();
|
||||
public void cycleDebugOptions() {
|
||||
mNativeMapView.cycleDebugOptions();
|
||||
mNativeMapView.toggleCollisionDebug();
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ final class NativeMapView {
|
||||
nativeSetDebug(mNativeMapViewPtr, debug);
|
||||
}
|
||||
|
||||
public void toggleDebug() {
|
||||
public void cycleDebugOptions() {
|
||||
nativeToggleDebug(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -322,8 +322,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
switch (menuItem.getItemId()) {
|
||||
|
||||
case R.id.action_debug:
|
||||
// Toggle debug mode
|
||||
mMapView.toggleDebug();
|
||||
// Cycle map debug options
|
||||
mMapView.cycleDebugOptions();
|
||||
toggleFpsCounter(mMapView.isDebugActive());
|
||||
return true;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<string name="action_gps">Toggle GPS location</string>
|
||||
<string name="action_user_location_tracking">User location tracking</string>
|
||||
<string name="action_compass">Toggle compass</string>
|
||||
<string name="action_debug">Toggle debug mode</string>
|
||||
<string name="action_debug">Cycle map debug options</string>
|
||||
<string name="action_point_annotations">Toggle point annotations</string>
|
||||
<string name="action_info_window_adapter">InfoWindow Adapter</string>
|
||||
<string name="action_map_fragment">MapFragment</string>
|
||||
|
||||
@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) {
|
||||
map.setBearing(bearing);
|
||||
|
||||
if (debug) {
|
||||
map.setDebug(debug);
|
||||
map.setDebug(debug ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus : mbgl::MapDebugOptions::NoDebug);
|
||||
}
|
||||
|
||||
uv_async_t *async = new uv_async_t;
|
||||
|
||||
@@ -46,4 +46,4 @@ If you want to run the tests in Xcode instead, first `make ipackage` to create a
|
||||
- Double-tap to zoom in one level
|
||||
- Two-finger single-tap to zoom out one level
|
||||
- Double-tap, long-pressing the second, then pan up and down to "quick zoom" (iPhone only, meant for one-handed use)
|
||||
- Use the debug menu to add test annotations, reset position, and toggle debug info.
|
||||
- Use the debug menu to add test annotations, reset position, and cycle through the debug options.
|
||||
|
||||
@@ -405,8 +405,8 @@ IB_DESIGNABLE
|
||||
* The default value of this property is `NO`. */
|
||||
@property (nonatomic, getter=isDebugActive) BOOL debugActive;
|
||||
|
||||
/** Toggle the current value of debugActive. */
|
||||
- (void)toggleDebug;
|
||||
/** Cycle map debug options. */
|
||||
- (void)cycleDebugOptions;
|
||||
|
||||
/** Empties the in-memory tile cache. */
|
||||
- (void)emptyMemoryCache;
|
||||
|
||||
@@ -168,12 +168,13 @@ public:
|
||||
void onLowMemory();
|
||||
|
||||
// Debug
|
||||
void setDebug(bool value);
|
||||
void toggleDebug();
|
||||
bool getDebug() const;
|
||||
void setDebug(MapDebugOptions);
|
||||
void cycleDebugOptions();
|
||||
MapDebugOptions getDebug() const;
|
||||
void setCollisionDebug(bool value);
|
||||
void toggleCollisionDebug();
|
||||
bool getCollisionDebug() const;
|
||||
|
||||
bool isFullyLoaded() const;
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
enum class MapMode : uint8_t {
|
||||
using EnumType = uint32_t;
|
||||
|
||||
enum class MapMode : EnumType {
|
||||
Continuous, // continually updating map
|
||||
Still, // a once-off still image
|
||||
};
|
||||
@@ -14,18 +16,38 @@ enum class MapMode : uint8_t {
|
||||
// being shared. In a shared GL context case, we need to make sure that the
|
||||
// correct GL configurations are in use - they might have changed between render
|
||||
// calls.
|
||||
enum class GLContextMode : uint8_t {
|
||||
enum class GLContextMode : EnumType {
|
||||
Unique,
|
||||
Shared,
|
||||
};
|
||||
|
||||
// We can choose to constrain the map both horizontally or vertically, or only
|
||||
// vertically e.g. while panning.
|
||||
enum class ConstrainMode : uint8_t {
|
||||
enum class ConstrainMode : EnumType {
|
||||
HeightOnly,
|
||||
WidthAndHeight,
|
||||
};
|
||||
|
||||
enum class MapDebugOptions : EnumType {
|
||||
NoDebug = 0,
|
||||
TileBorders = 1 << 1,
|
||||
ParseStatus = 1 << 2,
|
||||
Timestamps = 1 << 3,
|
||||
};
|
||||
|
||||
inline MapDebugOptions operator| (const MapDebugOptions& lhs, const MapDebugOptions& rhs) {
|
||||
return MapDebugOptions(static_cast<EnumType>(lhs) | static_cast<EnumType>(rhs));
|
||||
}
|
||||
|
||||
inline MapDebugOptions& operator|=(MapDebugOptions& lhs, const MapDebugOptions& rhs) {
|
||||
lhs = lhs | rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
inline bool operator& (const MapDebugOptions& lhs, const MapDebugOptions& rhs) {
|
||||
return static_cast<EnumType>(lhs) & static_cast<EnumType>(rhs);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
#endif // MBGL_MAP_MODE
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
MGLUserTrackingMode userTrackingMode = MGLUserTrackingModeNone;
|
||||
bool showsUserLocation = false;
|
||||
|
||||
bool debug = false;
|
||||
uint32_t debug = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef MBGL_JSON_SETTINGS
|
||||
#define MBGL_JSON_SETTINGS
|
||||
|
||||
#include <mbgl/map/mode.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Settings_JSON {
|
||||
@@ -17,7 +19,7 @@ public:
|
||||
double bearing = 0;
|
||||
double pitch = 0;
|
||||
|
||||
bool debug = false;
|
||||
EnumType debug = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ static UIColor *const kTintColor = [UIColor colorWithRed:0.120 green:0.550 blue:
|
||||
destructiveButtonTitle:nil
|
||||
otherButtonTitles:@"Reset North",
|
||||
@"Reset Position",
|
||||
@"Toggle Debug",
|
||||
@"Cycle debug options",
|
||||
@"Empty Memory",
|
||||
@"Add 100 Points",
|
||||
@"Add 1,000 Points",
|
||||
@@ -156,7 +156,7 @@ static UIColor *const kTintColor = [UIColor colorWithRed:0.120 green:0.550 blue:
|
||||
}
|
||||
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2)
|
||||
{
|
||||
[self.mapView toggleDebug];
|
||||
[self.mapView cycleDebugOptions];
|
||||
}
|
||||
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 3)
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
|
||||
map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom);
|
||||
map.setBearing(settings.bearing);
|
||||
map.setPitch(settings.pitch);
|
||||
map.setDebug(settings.debug);
|
||||
map.setDebug(mbgl::MapDebugOptions(settings.debug));
|
||||
}
|
||||
|
||||
view->setChangeStyleCallback([&map] () {
|
||||
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
|
||||
settings.zoom = map.getZoom();
|
||||
settings.bearing = map.getBearing();
|
||||
settings.pitch = map.getPitch();
|
||||
settings.debug = map.getDebug();
|
||||
settings.debug = mbgl::EnumType(map.getDebug());
|
||||
if (!skipConfig) {
|
||||
settings.save();
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ int main(int argc, char* argv[]) {
|
||||
map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom);
|
||||
map.setBearing(settings.bearing);
|
||||
map.setPitch(settings.pitch);
|
||||
map.setDebug(settings.debug);
|
||||
map.setDebug(mbgl::MapDebugOptions(settings.debug));
|
||||
|
||||
view.setChangeStyleCallback([&map, &view] () {
|
||||
static uint8_t currentStyleIndex;
|
||||
@@ -205,7 +205,7 @@ int main(int argc, char* argv[]) {
|
||||
settings.zoom = map.getZoom();
|
||||
settings.bearing = map.getBearing();
|
||||
settings.pitch = map.getPitch();
|
||||
settings.debug = map.getDebug();
|
||||
settings.debug = uint32_t(map.getDebug());
|
||||
settings.save();
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -375,6 +375,7 @@ std::pair<mbgl::AnnotationSegment, mbgl::ShapeAnnotation::Properties> annotation
|
||||
namespace {
|
||||
|
||||
using namespace mbgl::android;
|
||||
using DebugOptions = mbgl::MapDebugOptions;
|
||||
|
||||
jlong JNICALL nativeCreate(JNIEnv *env, jobject obj, jstring cachePath_, jstring dataPath_, jstring apkPath_, jfloat pixelRatio, jint availableProcessors, jlong totalMemory) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeCreate");
|
||||
@@ -1293,7 +1294,10 @@ void JNICALL nativeSetDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jb
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetDebug");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().setDebug(debug);
|
||||
|
||||
DebugOptions debugOptions = debug ? DebugOptions::TileBorders | DebugOptions::ParseStatus
|
||||
: DebugOptions::NoDebug;
|
||||
nativeMapView->getMap().setDebug(debugOptions);
|
||||
nativeMapView->enableFps(debug);
|
||||
}
|
||||
|
||||
@@ -1301,15 +1305,15 @@ void JNICALL nativeToggleDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr)
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeToggleDebug");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().toggleDebug();
|
||||
nativeMapView->enableFps(nativeMapView->getMap().getDebug());
|
||||
nativeMapView->getMap().cycleDebugOptions();
|
||||
nativeMapView->enableFps(nativeMapView->getMap().getDebug() != DebugOptions::NoDebug);
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeGetDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetDebug");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
return nativeMapView->getMap().getDebug();
|
||||
return nativeMapView->getMap().getDebug() != DebugOptions::NoDebug;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetCollisionDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jboolean debug) {
|
||||
|
||||
@@ -102,7 +102,7 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_)
|
||||
printf("- `Control` + mouse drag to rotate\n");
|
||||
printf("- `Shift` + mouse drag to tilt\n");
|
||||
printf("\n");
|
||||
printf("- Press `Tab` to toggle debug information\n");
|
||||
printf("- Press `Tab` to cycle through the map debug options\n");
|
||||
printf("- Press `Esc` to quit\n");
|
||||
printf("\n");
|
||||
printf("================================================================================\n");
|
||||
@@ -127,7 +127,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
break;
|
||||
case GLFW_KEY_TAB:
|
||||
view->map->toggleDebug();
|
||||
view->map->cycleDebugOptions();
|
||||
break;
|
||||
case GLFW_KEY_C:
|
||||
view->map->toggleCollisionDebug();
|
||||
|
||||
@@ -35,5 +35,5 @@ void Settings_JSON::clear() {
|
||||
zoom = 0;
|
||||
bearing = 0;
|
||||
pitch = 0;
|
||||
debug = false;
|
||||
debug = 0;
|
||||
}
|
||||
|
||||
@@ -747,7 +747,7 @@ std::chrono::steady_clock::duration durationInSeconds(float duration)
|
||||
self.glSnapshotView.image = self.glView.snapshot;
|
||||
self.glSnapshotView.hidden = NO;
|
||||
|
||||
if (_mbglMap->getDebug() && [self.glSnapshotView.subviews count] == 0)
|
||||
if (_mbglMap->getDebug() != mbgl::MapDebugOptions::NoDebug && [self.glSnapshotView.subviews count] == 0)
|
||||
{
|
||||
UIView *snapshotTint = [[UIView alloc] initWithFrame:self.glSnapshotView.bounds];
|
||||
snapshotTint.autoresizingMask = self.glSnapshotView.autoresizingMask;
|
||||
@@ -1502,13 +1502,14 @@ std::chrono::steady_clock::duration durationInSeconds(float duration)
|
||||
|
||||
- (void)setDebugActive:(BOOL)debugActive
|
||||
{
|
||||
_mbglMap->setDebug(debugActive);
|
||||
_mbglMap->setDebug(debugActive ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus
|
||||
: mbgl::MapDebugOptions::NoDebug);
|
||||
_mbglMap->setCollisionDebug(debugActive);
|
||||
}
|
||||
|
||||
- (BOOL)isDebugActive
|
||||
{
|
||||
return (_mbglMap->getDebug() || _mbglMap->getCollisionDebug());
|
||||
return (_mbglMap->getDebug() != mbgl::MapDebugOptions::NoDebug || _mbglMap->getCollisionDebug());
|
||||
}
|
||||
|
||||
- (void)resetNorth
|
||||
@@ -1527,9 +1528,9 @@ std::chrono::steady_clock::duration durationInSeconds(float duration)
|
||||
_mbglMap->resetPosition();
|
||||
}
|
||||
|
||||
- (void)toggleDebug
|
||||
- (void)cycleDebugOptions
|
||||
{
|
||||
_mbglMap->toggleDebug();
|
||||
_mbglMap->cycleDebugOptions();
|
||||
_mbglMap->toggleCollisionDebug();
|
||||
}
|
||||
|
||||
|
||||
@@ -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