Tidy code up more
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <mbgl/android/jni.hpp>
|
||||
#include <mbgl/android/log.hpp>
|
||||
#include <mbgl/android/native_map_view.hpp>
|
||||
#include <mbgl/platform/android/log_android.hpp>
|
||||
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
@@ -242,49 +243,49 @@ void JNICALL nativeRun(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeRun");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->run();
|
||||
native_map_view->getMap().run();
|
||||
}
|
||||
|
||||
void JNICALL nativeRerender(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeRerender");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->rerender();
|
||||
native_map_view->getMap().rerender();
|
||||
}
|
||||
|
||||
void JNICALL nativeUpdate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeUpdate");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->update();
|
||||
native_map_view->getMap().update();
|
||||
}
|
||||
|
||||
void JNICALL nativeCleanup(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeCleanup");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->cleanup();
|
||||
native_map_view->getMap().cleanup();
|
||||
}
|
||||
|
||||
void JNICALL nativeTerminate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeTerminate");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->terminate();
|
||||
native_map_view->getMap().terminate();
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeNeedsSwap(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeNeedsSwap");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->needsSwap();
|
||||
return native_map_view->getMap().needsSwap();
|
||||
}
|
||||
|
||||
void JNICALL nativeSwapped(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeSwapped");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->swapped();
|
||||
native_map_view->getMap().swapped();
|
||||
}
|
||||
|
||||
void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jint width, jint height, jfloat ratio) {
|
||||
@@ -295,7 +296,7 @@ void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, j
|
||||
LOG_ASSERT(width <= UINT16_MAX);
|
||||
LOG_ASSERT(height <= UINT16_MAX);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->resize(width, height, ratio);
|
||||
native_map_view->getMap().resize(width, height, ratio);
|
||||
}
|
||||
|
||||
void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jint width, jint height, jfloat ratio, jint fb_width, jint fb_height) {
|
||||
@@ -310,21 +311,21 @@ void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, j
|
||||
LOG_ASSERT(fb_width <= UINT16_MAX);
|
||||
LOG_ASSERT(fb_height <= UINT16_MAX);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->resize(width, height, ratio, fb_width, fb_height);
|
||||
native_map_view->getMap().resize(width, height, ratio, fb_width, fb_height);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetAppliedClasses(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject classes) {
|
||||
LOG_VERBOSE("nativeSetAppliedClasses");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setAppliedClasses(std_vector_string_from_jobject(env, classes));
|
||||
native_map_view->getMap().setAppliedClasses(std_vector_string_from_jobject(env, classes));
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetAppliedClasses(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetAppliedClasses");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return std_vector_string_to_jobject(env, native_map_view->getMap()->getAppliedClasses());
|
||||
return std_vector_string_to_jobject(env, native_map_view->getMap().getAppliedClasses());
|
||||
}
|
||||
|
||||
void JNICALL nativeSetDefaultTransitionDuration(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jlong duration_milliseconds) {
|
||||
@@ -333,56 +334,56 @@ void JNICALL nativeSetDefaultTransitionDuration(JNIEnv* env, jobject obj, jlong
|
||||
LOG_ASSERT(duration_milliseconds >= 0);
|
||||
//LOG_ASSERT(duration_milliseconds <= UINT64_MAX);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setDefaultTransitionDuration(duration_milliseconds);
|
||||
native_map_view->getMap().setDefaultTransitionDuration(duration_milliseconds);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetStyleURL(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring url) {
|
||||
LOG_VERBOSE("nativeSetStyleURL");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setStyleURL(std_string_from_jstring(env, url));
|
||||
native_map_view->getMap().setStyleURL(std_string_from_jstring(env, url));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetStyleJSON(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring new_style_json, jstring base) {
|
||||
LOG_VERBOSE("nativeSetStyleJSON");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setStyleJSON(std_string_from_jstring(env, new_style_json), std_string_from_jstring(env, base));
|
||||
native_map_view->getMap().setStyleJSON(std_string_from_jstring(env, new_style_json), std_string_from_jstring(env, base));
|
||||
}
|
||||
|
||||
jstring JNICALL nativeGetStyleJSON(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetStyleJSON");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return std_string_to_jstring(env, native_map_view->getMap()->getStyleJSON());
|
||||
return std_string_to_jstring(env, native_map_view->getMap().getStyleJSON());
|
||||
}
|
||||
|
||||
void JNICALL nativeSetAccessToken(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring access_token) {
|
||||
LOG_VERBOSE("nativeSetAccessToken");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setAccessToken(std_string_from_jstring(env, access_token));
|
||||
native_map_view->getMap().setAccessToken(std_string_from_jstring(env, access_token));
|
||||
}
|
||||
|
||||
jstring JNICALL nativeGetAccessToken(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetAccessToken");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return std_string_to_jstring(env, native_map_view->getMap()->getAccessToken());
|
||||
return std_string_to_jstring(env, native_map_view->getMap().getAccessToken());
|
||||
}
|
||||
|
||||
void JNICALL nativeCancelTransitions(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeCancelTransitions");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->cancelTransitions();
|
||||
native_map_view->getMap().cancelTransitions();
|
||||
}
|
||||
|
||||
void JNICALL nativeMoveBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble dx, jdouble dy, jdouble duration) {
|
||||
LOG_VERBOSE("nativeMoveBy");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->moveBy(dx, dy, duration);
|
||||
native_map_view->getMap().moveBy(dx, dy, duration);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject lon_lat, jdouble duration) {
|
||||
@@ -404,7 +405,7 @@ void JNICALL nativeSetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr
|
||||
|
||||
// TODO remove when fixed
|
||||
LOG_DEBUG("lon lat %f %f", lon, lat);
|
||||
native_map_view->getMap()->setLonLat(lon, lat, duration);
|
||||
native_map_view->getMap().setLonLat(lon, lat, duration);
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
@@ -412,7 +413,7 @@ jobject JNICALL nativeGetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
double lon, lat;
|
||||
native_map_view->getMap()->getLonLat(lon, lat);
|
||||
native_map_view->getMap().getLonLat(lon, lat);
|
||||
|
||||
jobject ret = env->NewObject(lon_lat_class, lon_lat_constructor_id, lon, lat);
|
||||
if (ret == nullptr) {
|
||||
@@ -427,56 +428,56 @@ void JNICALL nativeStartPanning(JNIEnv* env, jobject obj, jlong native_map_view_
|
||||
LOG_VERBOSE("nativeStartPanning");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->startPanning();
|
||||
native_map_view->getMap().startPanning();
|
||||
}
|
||||
|
||||
void JNICALL nativeStopPanning(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeStopPanning");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->stopPanning();
|
||||
native_map_view->getMap().stopPanning();
|
||||
}
|
||||
|
||||
void JNICALL nativeResetPosition(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeResetPosition");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->resetPosition();
|
||||
native_map_view->getMap().resetPosition();
|
||||
}
|
||||
|
||||
void JNICALL nativeScaleBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble ds, jdouble cx, jdouble cy, jdouble duration) {
|
||||
LOG_VERBOSE("nativeScaleBy");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->scaleBy(ds, cx, cy, duration);
|
||||
native_map_view->getMap().scaleBy(ds, cx, cy, duration);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetScale(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble scale, jdouble cx, jdouble cy, jdouble duration) {
|
||||
LOG_VERBOSE("nativeSetScale");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setScale(scale, cx, cy, duration);
|
||||
native_map_view->getMap().setScale(scale, cx, cy, duration);
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetScale(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetScale");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->getScale();
|
||||
return native_map_view->getMap().getScale();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble zoom, jdouble duration) {
|
||||
LOG_VERBOSE("nativeSetZoom");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setZoom(zoom, duration);
|
||||
native_map_view->getMap().setZoom(zoom, duration);
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetZoom");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->getZoom();
|
||||
return native_map_view->getMap().getZoom();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject lon_lat_zoom, jdouble duration) {
|
||||
@@ -502,7 +503,7 @@ void JNICALL nativeSetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view
|
||||
return;
|
||||
}
|
||||
|
||||
native_map_view->getMap()->setLonLatZoom(lon, lat, zoom, duration);
|
||||
native_map_view->getMap().setLonLatZoom(lon, lat, zoom, duration);
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
@@ -510,7 +511,7 @@ jobject JNICALL nativeGetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_v
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
double lon, lat, zoom;
|
||||
native_map_view->getMap()->getLonLatZoom(lon, lat, zoom);
|
||||
native_map_view->getMap().getLonLatZoom(lon, lat, zoom);
|
||||
|
||||
jobject ret = env->NewObject(lon_lat_zoom_class, lon_lat_zoom_constructor_id, lon, lat, zoom);
|
||||
if (ret == nullptr) {
|
||||
@@ -525,119 +526,119 @@ void JNICALL nativeResetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr
|
||||
LOG_VERBOSE("nativeResetZoom");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->resetZoom();
|
||||
native_map_view->getMap().resetZoom();
|
||||
}
|
||||
|
||||
void JNICALL nativeStartScaling(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeStartScaling");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->startScaling();
|
||||
native_map_view->getMap().startScaling();
|
||||
}
|
||||
|
||||
void JNICALL nativeStopScaling(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeStopScaling");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->stopScaling();
|
||||
native_map_view->getMap().stopScaling();
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetMinZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetMinZoom");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->getMinZoom();
|
||||
return native_map_view->getMap().getMinZoom();
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetMaxZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetMaxZoom");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->getMaxZoom();
|
||||
return native_map_view->getMap().getMaxZoom();
|
||||
}
|
||||
|
||||
void JNICALL nativeRotateBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble sx, jdouble sy, jdouble ex, jdouble ey, jdouble duration) {
|
||||
LOG_VERBOSE("nativeRotateBy");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->rotateBy(sx, sy, ex, ey, duration);
|
||||
native_map_view->getMap().rotateBy(sx, sy, ex, ey, duration);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble duration) {
|
||||
LOG_VERBOSE("nativeSetBearing");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setBearing(degrees, duration);
|
||||
native_map_view->getMap().setBearing(degrees, duration);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble cx, jdouble cy) {
|
||||
LOG_VERBOSE("nativeSetBearing");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setBearing(degrees, cx, cy);
|
||||
native_map_view->getMap().setBearing(degrees, cx, cy);
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetBearing");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->getBearing();
|
||||
return native_map_view->getMap().getBearing();
|
||||
}
|
||||
|
||||
void JNICALL nativeResetNorth(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeResetNorth");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->resetNorth();
|
||||
native_map_view->getMap().resetNorth();
|
||||
}
|
||||
|
||||
void JNICALL nativeStartRotating(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeStartRotating");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->startRotating();
|
||||
native_map_view->getMap().startRotating();
|
||||
}
|
||||
|
||||
void JNICALL nativeStopRotating(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeStopRotating");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->stopRotating();
|
||||
native_map_view->getMap().stopRotating();
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeCanRotate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeCanRotate");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->canRotate();
|
||||
return native_map_view->getMap().canRotate();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jboolean debug) {
|
||||
LOG_VERBOSE("nativeSetDebug");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setDebug(debug);
|
||||
native_map_view->getMap().setDebug(debug);
|
||||
}
|
||||
|
||||
void JNICALL nativeToggleDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeToggleDebug");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->toggleDebug();
|
||||
native_map_view->getMap().toggleDebug();
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeGetDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
LOG_VERBOSE("nativeGetDebug");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap()->getDebug();
|
||||
return native_map_view->getMap().getDebug();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetReachability(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jboolean status) {
|
||||
LOG_VERBOSE("nativeSetReachability");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap()->setReachability(status);
|
||||
native_map_view->getMap().setReachability(status);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -645,6 +646,8 @@ void JNICALL nativeSetReachability(JNIEnv* env, jobject obj, jlong native_map_vi
|
||||
extern "C" {
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
mbgl::Log::Set<mbgl::AndroidLogBackend>();
|
||||
|
||||
LOG_VERBOSE("JNI_OnLoad");
|
||||
|
||||
JNIEnv* env = nullptr;
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
#include <mbgl/android/log.hpp>
|
||||
#include <mbgl/android/native_map_view.hpp>
|
||||
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/platform/android/log_android.hpp>
|
||||
#include <mbgl/android/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -34,7 +32,55 @@ void log_gl_string(GLenum name, const char* label) {
|
||||
}
|
||||
}
|
||||
|
||||
NativeMapView::NativeMapView(JNIEnv* env, jobject obj_) {
|
||||
|
||||
void MBGLView::make_active() {
|
||||
LOG_VERBOSE("MBGLView::make_active");
|
||||
if ((nativeView.display != EGL_NO_DISPLAY)
|
||||
&& (nativeView.surface != EGL_NO_SURFACE)
|
||||
&& (nativeView.context != EGL_NO_CONTEXT)) {
|
||||
if (!eglMakeCurrent(nativeView.display, nativeView.surface,
|
||||
nativeView.surface, nativeView.context)) {
|
||||
LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError());
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG("Not activating as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::make_inactive() {
|
||||
LOG_VERBOSE("MBGLView::make_inactive");
|
||||
if (!eglMakeCurrent(nativeView.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::swap() {
|
||||
LOG_VERBOSE("MBGLView::swap");
|
||||
|
||||
if (map->needsSwap() && (nativeView.display != EGL_NO_DISPLAY)
|
||||
&& (nativeView.surface != EGL_NO_SURFACE)) {
|
||||
if (!eglSwapBuffers(nativeView.display, nativeView.surface)) {
|
||||
LOG_ERROR("eglSwapBuffers() returned error %d", eglGetError());
|
||||
}
|
||||
map->swapped();
|
||||
} else {
|
||||
LOG_DEBUG("Not swapping as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::notify() {
|
||||
LOG_VERBOSE("MBGLView::notify()");
|
||||
// noop
|
||||
}
|
||||
|
||||
void MBGLView::notify_map_change(mbgl::MapChange /* change */, mbgl::timestamp /* delay */) {
|
||||
LOG_VERBOSE("MBGLView::notify_map_change()");
|
||||
nativeView.notifyMapChange();
|
||||
}
|
||||
|
||||
NativeMapView::NativeMapView(JNIEnv* env, jobject obj_) : map(view), view(*this) {
|
||||
LOG_VERBOSE("NativeMapView::NativeMapView");
|
||||
|
||||
LOG_ASSERT(env != nullptr);
|
||||
@@ -50,11 +96,6 @@ NativeMapView::NativeMapView(JNIEnv* env, jobject obj_) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
|
||||
mbgl::Log::Set<mbgl::AndroidLogBackend>();
|
||||
|
||||
view = new MBGLView(this);
|
||||
map = new mbgl::Map(*view);
|
||||
}
|
||||
|
||||
NativeMapView::~NativeMapView() {
|
||||
@@ -63,12 +104,6 @@ NativeMapView::~NativeMapView() {
|
||||
destroySurface();
|
||||
terminateDisplay();
|
||||
|
||||
delete map;
|
||||
map = nullptr;
|
||||
|
||||
delete view;
|
||||
view = nullptr;
|
||||
|
||||
LOG_ASSERT(vm != nullptr);
|
||||
LOG_ASSERT(obj != nullptr);
|
||||
|
||||
@@ -168,8 +203,8 @@ bool NativeMapView::initializeDisplay() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO make_unique missing in Android NDK?
|
||||
// const std::unique_ptr<EGLConfig[]> configs = std::make_unique(new EGLConfig[num_configs]);
|
||||
// TODO: make_unique is missing in Android NDK?
|
||||
// const std::unique_ptr<EGLConfig[]> configs = std::make_unique(new EGLConfig[num_configs]);
|
||||
const std::unique_ptr<EGLConfig[]> configs(new EGLConfig[num_configs]);
|
||||
if (!eglChooseConfig(display, config_attribs, configs.get(), num_configs,
|
||||
&num_configs)) {
|
||||
@@ -198,8 +233,6 @@ bool NativeMapView::initializeDisplay() {
|
||||
void NativeMapView::terminateDisplay() {
|
||||
LOG_VERBOSE("NativeMapView::terminateDisplay");
|
||||
|
||||
//map->terminate();
|
||||
|
||||
if (display != EGL_NO_DISPLAY) {
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
@@ -244,8 +277,6 @@ bool NativeMapView::initializeContext() {
|
||||
void NativeMapView::terminateContext() {
|
||||
LOG_VERBOSE("NativeMapView::terminateContext");
|
||||
|
||||
//map->terminate();
|
||||
|
||||
if (display != EGL_NO_DISPLAY) {
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
@@ -480,7 +511,7 @@ void NativeMapView::start() {
|
||||
LOG_ASSERT(display != EGL_NO_DISPLAY);
|
||||
LOG_ASSERT(context != EGL_NO_CONTEXT);
|
||||
|
||||
map->start(true);
|
||||
map.start(true);
|
||||
}
|
||||
|
||||
void NativeMapView::loadExtensions() {
|
||||
@@ -515,7 +546,7 @@ void NativeMapView::stop() {
|
||||
LOG_ASSERT(display != EGL_NO_DISPLAY);
|
||||
LOG_ASSERT(context != EGL_NO_CONTEXT);
|
||||
|
||||
map->stop();
|
||||
map.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +556,7 @@ void NativeMapView::pause(bool wait_for_pause) {
|
||||
LOG_ASSERT(display != EGL_NO_DISPLAY);
|
||||
LOG_ASSERT(context != EGL_NO_CONTEXT);
|
||||
|
||||
map->pause(wait_for_pause);
|
||||
map.pause(wait_for_pause);
|
||||
}
|
||||
|
||||
void NativeMapView::resume() {
|
||||
@@ -535,7 +566,7 @@ void NativeMapView::resume() {
|
||||
LOG_ASSERT(context != EGL_NO_CONTEXT);
|
||||
|
||||
if (surface != EGL_NO_SURFACE) {
|
||||
map->resume();
|
||||
map.resume();
|
||||
} else {
|
||||
LOG_DEBUG("Not resuming because we are not ready");
|
||||
}
|
||||
@@ -553,7 +584,6 @@ void NativeMapView::notifyMapChange() {
|
||||
NULL
|
||||
};
|
||||
|
||||
// TODO do this only once per thread?
|
||||
jint ret;
|
||||
JNIEnv* env = nullptr;
|
||||
bool detach = false;
|
||||
@@ -584,52 +614,5 @@ void NativeMapView::notifyMapChange() {
|
||||
env = nullptr;
|
||||
}
|
||||
|
||||
void MBGLView::make_active() {
|
||||
LOG_VERBOSE("MBGLView::make_active");
|
||||
if ((nativeView->display != EGL_NO_DISPLAY)
|
||||
&& (nativeView->surface != EGL_NO_SURFACE)
|
||||
&& (nativeView->context != EGL_NO_CONTEXT)) {
|
||||
if (!eglMakeCurrent(nativeView->display, nativeView->surface,
|
||||
nativeView->surface, nativeView->context)) {
|
||||
LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError());
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG("Not activating as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::make_inactive() {
|
||||
LOG_VERBOSE("MBGLView::make_inactive");
|
||||
if (!eglMakeCurrent(nativeView->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::swap() {
|
||||
LOG_VERBOSE("MBGLView::swap");
|
||||
|
||||
if (map->needsSwap() && (nativeView->display != EGL_NO_DISPLAY)
|
||||
&& (nativeView->surface != EGL_NO_SURFACE)) {
|
||||
if (!eglSwapBuffers(nativeView->display, nativeView->surface)) {
|
||||
LOG_ERROR("eglSwapBuffers() returned error %d", eglGetError());
|
||||
}
|
||||
map->swapped();
|
||||
} else {
|
||||
LOG_DEBUG("Not swapping as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::notify() {
|
||||
LOG_VERBOSE("MBGLView::notify()");
|
||||
// noop
|
||||
}
|
||||
|
||||
void MBGLView::notify_map_change(mbgl::MapChange /* change */, mbgl::timestamp /* delay */) {
|
||||
LOG_VERBOSE("MBGLView::notify_map_change()");
|
||||
nativeView->notifyMapChange();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user