From 92856f394c76f75051a72fbc5944b63cbea7ccde Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 27 Nov 2015 10:44:14 +0200 Subject: [PATCH] [core] Collision debug is now MapDebugOptions::Collision --- .../com/mapbox/mapboxsdk/views/MapView.java | 9 +++---- .../mapbox/mapboxsdk/views/NativeMapView.java | 18 ------------- include/mbgl/map/map.hpp | 3 --- include/mbgl/map/mode.hpp | 1 + platform/android/jni.cpp | 26 +------------------ platform/default/glfw_view.cpp | 4 --- platform/ios/MGLMapView.mm | 9 ++++--- src/mbgl/map/map.cpp | 14 ---------- src/mbgl/map/map_data.hpp | 15 +++-------- src/mbgl/map/source.cpp | 4 +-- 10 files changed, 16 insertions(+), 87 deletions(-) diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java index dba17ece6..cad1ede04 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java @@ -1306,7 +1306,7 @@ public final class MapView extends FrameLayout { */ @UiThread public boolean isDebugActive() { - return mNativeMapView.getDebug() || mNativeMapView.getCollisionDebug(); + return mNativeMapView.getDebug(); } /** @@ -1319,20 +1319,19 @@ public final class MapView extends FrameLayout { @UiThread public void setDebugActive(boolean debugActive) { mNativeMapView.setDebug(debugActive); - mNativeMapView.setCollisionDebug(debugActive); } /** - * Toggles whether the map debug information is shown. + * Cycles through the map debug options. *

- * The value of {@link MapView#isDebugActive()} is toggled. + * The value of {@link MapView#isDebugActive()} reflects whether there are + * any map debug options enabled or disabled. * * @see MapView#isDebugActive() */ @UiThread public void cycleDebugOptions() { mNativeMapView.cycleDebugOptions(); - mNativeMapView.toggleCollisionDebug(); } // True if map has finished loading the view diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java index d75b83cf8..6f34ecc84 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java @@ -409,18 +409,6 @@ final class NativeMapView { return nativeGetDebug(mNativeMapViewPtr); } - public void setCollisionDebug(boolean debug) { - nativeSetCollisionDebug(mNativeMapViewPtr, debug); - } - - public void toggleCollisionDebug() { - nativeToggleCollisionDebug(mNativeMapViewPtr); - } - - public boolean getCollisionDebug() { - return nativeGetCollisionDebug(mNativeMapViewPtr); - } - public boolean isFullyLoaded() { return nativeIsFullyLoaded(mNativeMapViewPtr); } @@ -614,12 +602,6 @@ final class NativeMapView { private native boolean nativeGetDebug(long nativeMapViewPtr); - private native void nativeSetCollisionDebug(long nativeMapViewPtr, boolean debug); - - private native void nativeToggleCollisionDebug(long nativeMapViewPtr); - - private native boolean nativeGetCollisionDebug(long nativeMapViewPtr); - private native boolean nativeIsFullyLoaded(long nativeMapViewPtr); private native void nativeSetReachability(long nativeMapViewPtr, boolean status); diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 43c3b1452..8401976e1 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -171,9 +171,6 @@ public: void setDebug(MapDebugOptions); void cycleDebugOptions(); MapDebugOptions getDebug() const; - void setCollisionDebug(bool value); - void toggleCollisionDebug(); - bool getCollisionDebug() const; bool isFullyLoaded() const; void dumpDebugLogs() const; diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp index 0fe2c46dd..c197b2858 100644 --- a/include/mbgl/map/mode.hpp +++ b/include/mbgl/map/mode.hpp @@ -33,6 +33,7 @@ enum class MapDebugOptions : EnumType { TileBorders = 1 << 1, ParseStatus = 1 << 2, Timestamps = 1 << 3, + Collision = 1 << 4, }; inline MapDebugOptions operator| (const MapDebugOptions& lhs, const MapDebugOptions& rhs) { diff --git a/platform/android/jni.cpp b/platform/android/jni.cpp index f3181b2a8..79281a0ad 100644 --- a/platform/android/jni.cpp +++ b/platform/android/jni.cpp @@ -1295,7 +1295,7 @@ void JNICALL nativeSetDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jb assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - DebugOptions debugOptions = debug ? DebugOptions::TileBorders | DebugOptions::ParseStatus + DebugOptions debugOptions = debug ? DebugOptions::TileBorders | DebugOptions::ParseStatus | DebugOptions::Collision : DebugOptions::NoDebug; nativeMapView->getMap().setDebug(debugOptions); nativeMapView->enableFps(debug); @@ -1316,27 +1316,6 @@ jboolean JNICALL nativeGetDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr return nativeMapView->getMap().getDebug() != DebugOptions::NoDebug; } -void JNICALL nativeSetCollisionDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jboolean debug) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetCollisionDebug"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().setCollisionDebug(debug); -} - -void JNICALL nativeToggleCollisionDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeToggleCollisionDebug"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().toggleCollisionDebug(); -} - -jboolean JNICALL nativeGetCollisionDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { - mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetCollisionDebug"); - assert(nativeMapViewPtr != 0); - NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - return nativeMapView->getMap().getCollisionDebug(); -} - jboolean JNICALL nativeIsFullyLoaded(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeIsFullyLoaded"); assert(nativeMapViewPtr != 0); @@ -1955,9 +1934,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativeSetDebug", "(JZ)V", reinterpret_cast(&nativeSetDebug)}, {"nativeToggleDebug", "(J)V", reinterpret_cast(&nativeToggleDebug)}, {"nativeGetDebug", "(J)Z", reinterpret_cast(&nativeGetDebug)}, - {"nativeSetCollisionDebug", "(JZ)V", reinterpret_cast(&nativeSetCollisionDebug)}, - {"nativeToggleCollisionDebug", "(J)V", reinterpret_cast(&nativeToggleCollisionDebug)}, - {"nativeGetCollisionDebug", "(J)Z", reinterpret_cast(&nativeGetCollisionDebug)}, {"nativeIsFullyLoaded", "(J)Z", reinterpret_cast(&nativeIsFullyLoaded)}, {"nativeSetReachability", "(JZ)V", reinterpret_cast(&nativeSetReachability)}, {"nativeGetMetersPerPixelAtLatitude", "(JDD)D", reinterpret_cast(&nativeGetMetersPerPixelAtLatitude)}, diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 998eb6479..4e00722e2 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -89,7 +89,6 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) printf("- Press `S` to cycle through bundled styles\n"); printf("- Press `X` to reset the transform\n"); printf("- Press `N` to reset north\n"); - printf("- Press `C` to toggle symbol collision debug boxes\n"); printf("- Press `R` to toggle any available `night` style class\n"); printf("\n"); printf("- Press `1` through `6` to add increasing numbers of point annotations for testing\n"); @@ -129,9 +128,6 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, case GLFW_KEY_TAB: view->map->cycleDebugOptions(); break; - case GLFW_KEY_C: - view->map->toggleCollisionDebug(); - break; case GLFW_KEY_X: if (!mods) view->map->resetPosition(); diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index d3faf8c09..ad9a7e37e 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1502,14 +1503,15 @@ std::chrono::steady_clock::duration durationInSeconds(float duration) - (void)setDebugActive:(BOOL)debugActive { - _mbglMap->setDebug(debugActive ? mbgl::MapDebugOptions::TileBorders | mbgl::MapDebugOptions::ParseStatus + _mbglMap->setDebug(debugActive ? mbgl::MapDebugOptions::TileBorders + | mbgl::MapDebugOptions::ParseStatus + | mbgl::MapDebugOptions::Collision : mbgl::MapDebugOptions::NoDebug); - _mbglMap->setCollisionDebug(debugActive); } - (BOOL)isDebugActive { - return (_mbglMap->getDebug() != mbgl::MapDebugOptions::NoDebug || _mbglMap->getCollisionDebug()); + return (_mbglMap->getDebug() != mbgl::MapDebugOptions::NoDebug); } - (void)resetNorth @@ -1531,7 +1533,6 @@ std::chrono::steady_clock::duration durationInSeconds(float duration) - (void)cycleDebugOptions { _mbglMap->cycleDebugOptions(); - _mbglMap->toggleCollisionDebug(); } - (void)emptyMemoryCache diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 573500fd6..57f8c3e7f 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -434,20 +434,6 @@ MapDebugOptions Map::getDebug() const { return data->getDebug(); } -void Map::setCollisionDebug(bool value) { - data->setCollisionDebug(value); - update(Update::Repaint); -} - -void Map::toggleCollisionDebug() { - data->toggleCollisionDebug(); - update(Update::Repaint); -} - -bool Map::getCollisionDebug() const { - return data->getCollisionDebug(); -} - bool Map::isFullyLoaded() const { return context->invokeSync(&MapContext::isLoaded); } diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp index 9b02d372d..d8c1e5cb0 100644 --- a/src/mbgl/map/map_data.hpp +++ b/src/mbgl/map/map_data.hpp @@ -55,8 +55,10 @@ public: } inline void cycleDebugOptions() { - if (debugOptions & MapDebugOptions::Timestamps) + if (debugOptions & MapDebugOptions::Collision) debugOptions = MapDebugOptions::NoDebug; + else if (debugOptions & MapDebugOptions::Timestamps) + debugOptions = debugOptions | MapDebugOptions::Collision; else if (debugOptions & MapDebugOptions::ParseStatus) debugOptions = debugOptions | MapDebugOptions::Timestamps; else if (debugOptions & MapDebugOptions::TileBorders) @@ -69,16 +71,6 @@ public: debugOptions = debugOptions_; } - inline bool getCollisionDebug() const { - return collisionDebug; - } - inline bool toggleCollisionDebug() { - return collisionDebug ^= 1u; - } - inline void setCollisionDebug(bool value) { - collisionDebug = value; - } - inline TimePoint getAnimationTime() const { // We're casting the TimePoint to and from a Duration because libstdc++ // has a bug that doesn't allow TimePoints to be atomic. @@ -147,7 +139,6 @@ private: std::vector classes; std::atomic debugOptions { MapDebugOptions::NoDebug }; - std::atomic collisionDebug { false }; std::atomic animationTime; std::atomic defaultFadeDuration; std::atomic defaultTransitionDuration; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 62014bd05..4e8e60de5 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -519,7 +519,7 @@ bool Source::update(const TransformState& transformState, for (auto& tilePtr : tilePtrs) { tilePtr->data->redoPlacement( - { transformState.getAngle(), transformState.getPitch(), data.getCollisionDebug() }); + { transformState.getAngle(), transformState.getPitch(), data.getDebug() & MapDebugOptions::Collision }); } updated = data.getAnimationTime(); @@ -562,7 +562,7 @@ void Source::tileLoadingCompleteCallback(const TileID& normalized_id, const Tran return; } - tileData->redoPlacement({ transformState.getAngle(), transformState.getPitch(), data.getCollisionDebug() }); + tileData->redoPlacement({ transformState.getAngle(), transformState.getPitch(), data.getDebug() & MapDebugOptions::Collision}); emitTileLoaded(true); }