[core] Collision debug is now MapDebugOptions::Collision

This commit is contained in:
Bruno de Oliveira Abinader
2015-11-27 10:44:14 +02:00
parent d55aa7929c
commit 92856f394c
10 changed files with 16 additions and 87 deletions

View File

@@ -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.
* <p/>
* 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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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) {

View File

@@ -1295,7 +1295,7 @@ void JNICALL nativeSetDebug(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jb
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(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<NativeMapView *>(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<NativeMapView *>(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<NativeMapView *>(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<void *>(&nativeSetDebug)},
{"nativeToggleDebug", "(J)V", reinterpret_cast<void *>(&nativeToggleDebug)},
{"nativeGetDebug", "(J)Z", reinterpret_cast<void *>(&nativeGetDebug)},
{"nativeSetCollisionDebug", "(JZ)V", reinterpret_cast<void *>(&nativeSetCollisionDebug)},
{"nativeToggleCollisionDebug", "(J)V", reinterpret_cast<void *>(&nativeToggleCollisionDebug)},
{"nativeGetCollisionDebug", "(J)Z", reinterpret_cast<void *>(&nativeGetCollisionDebug)},
{"nativeIsFullyLoaded", "(J)Z", reinterpret_cast<void *>(&nativeIsFullyLoaded)},
{"nativeSetReachability", "(JZ)V", reinterpret_cast<void *>(&nativeSetReachability)},
{"nativeGetMetersPerPixelAtLatitude", "(JDD)D", reinterpret_cast<void *>(&nativeGetMetersPerPixelAtLatitude)},

View File

@@ -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();

View File

@@ -12,6 +12,7 @@
#include <mbgl/annotation/shape_annotation.hpp>
#include <mbgl/sprite/sprite_image.hpp>
#include <mbgl/map/camera.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/platform/platform.hpp>
#include <mbgl/platform/darwin/reachability.h>
#include <mbgl/storage/sqlite_cache.hpp>
@@ -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

View File

@@ -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<bool>(&MapContext::isLoaded);
}

View File

@@ -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<std::string> classes;
std::atomic<MapDebugOptions> debugOptions { MapDebugOptions::NoDebug };
std::atomic<uint8_t> collisionDebug { false };
std::atomic<Duration> animationTime;
std::atomic<Duration> defaultFadeDuration;
std::atomic<Duration> defaultTransitionDuration;

View File

@@ -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);
}