Rename old log functions
This commit is contained in:
@@ -141,7 +141,7 @@ using namespace mbgl::android;
|
||||
// TODO: wrap other sorts of exceptions? eg coffee catch
|
||||
|
||||
jlong JNICALL nativeCreate(JNIEnv* env, jobject obj, jstring default_style_json) {
|
||||
VERBOSE("nativeCreate");
|
||||
LOG_VERBOSE("nativeCreate");
|
||||
NativeMapView* native_map_view = new NativeMapView(env, obj, std_string_from_jstring(env, default_style_json));
|
||||
if (native_map_view == nullptr) {
|
||||
throw_error(env, "Unable to create NativeMapView.");
|
||||
@@ -152,16 +152,16 @@ jlong JNICALL nativeCreate(JNIEnv* env, jobject obj, jstring default_style_json)
|
||||
}
|
||||
|
||||
void JNICALL nativeDestroy(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeDestroy");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeDestroy");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
delete native_map_view;
|
||||
native_map_view = nullptr;
|
||||
}
|
||||
|
||||
void JNICALL nativeInitializeDisplay(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeInitializeDisplay");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeInitializeDisplay");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
if (!native_map_view->initializeDisplay()) {
|
||||
throw_error(env, "Unable to initialize GL display.");
|
||||
@@ -169,15 +169,15 @@ void JNICALL nativeInitializeDisplay(JNIEnv* env, jobject obj, jlong native_map_
|
||||
}
|
||||
|
||||
void JNICALL nativeTerminateDisplay(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeTerminateDisplay");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeTerminateDisplay");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->terminateDisplay();
|
||||
}
|
||||
|
||||
void JNICALL nativeInitializeContext(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeInitializeContext");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeInitializeContext");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
if (!native_map_view->initializeContext()) {
|
||||
throw_error(env, "Unable to initialize GL context.");
|
||||
@@ -185,15 +185,15 @@ void JNICALL nativeInitializeContext(JNIEnv* env, jobject obj, jlong native_map_
|
||||
}
|
||||
|
||||
void JNICALL nativeTerminateContext(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeTerminateContext");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeTerminateContext");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->terminateContext();
|
||||
}
|
||||
|
||||
void JNICALL nativeCreateSurface(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject surface) {
|
||||
VERBOSE("nativeCreateSurface");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeCreateSurface");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
if (!native_map_view->createSurface(ANativeWindow_fromSurface(env, surface))) {
|
||||
throw_error(env, "Unable to create GL surface.");
|
||||
@@ -201,127 +201,127 @@ void JNICALL nativeCreateSurface(JNIEnv* env, jobject obj, jlong native_map_view
|
||||
}
|
||||
|
||||
void JNICALL nativeDestroySurface(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeDestroySurface");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeDestroySurface");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->destroySurface();
|
||||
}
|
||||
|
||||
void JNICALL nativeStart(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStart");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeStart");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->start();
|
||||
}
|
||||
|
||||
void JNICALL nativeStop(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStop");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeStop");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->stop();
|
||||
}
|
||||
|
||||
void JNICALL nativeRerender(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeRerender");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeUpdate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeUpdate");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeCleanup(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeCleanup");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jint width, jint height, jfloat ratio) {
|
||||
VERBOSE("nativeResize");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
ASSERT(width >= 0);
|
||||
ASSERT(height >= 0);
|
||||
ASSERT(width <= UINT16_MAX);
|
||||
ASSERT(height <= UINT16_MAX);
|
||||
LOG_VERBOSE("nativeResize");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
LOG_ASSERT(width >= 0);
|
||||
LOG_ASSERT(height >= 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jint width, jint height, jfloat ratio, jint fb_width, jint fb_height) {
|
||||
VERBOSE("nativeResize");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
ASSERT(width >= 0);
|
||||
ASSERT(height >= 0);
|
||||
ASSERT(width <= UINT16_MAX);
|
||||
ASSERT(height <= UINT16_MAX);
|
||||
ASSERT(fb_width >= 0);
|
||||
ASSERT(fb_height >= 0);
|
||||
ASSERT(fb_width <= UINT16_MAX);
|
||||
ASSERT(fb_height <= UINT16_MAX);
|
||||
LOG_VERBOSE("nativeResize");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
LOG_ASSERT(width >= 0);
|
||||
LOG_ASSERT(height >= 0);
|
||||
LOG_ASSERT(width <= UINT16_MAX);
|
||||
LOG_ASSERT(height <= UINT16_MAX);
|
||||
LOG_ASSERT(fb_width >= 0);
|
||||
LOG_ASSERT(fb_height >= 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetAppliedClasses(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject applied_classes) {
|
||||
VERBOSE("nativeSetAppliedClasses");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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, applied_classes));
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetAppliedClasses(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetAppliedClasses");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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());
|
||||
}
|
||||
|
||||
void JNICALL nativeSetDefaultTransitionDuration(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jlong duration_milliseconds) {
|
||||
VERBOSE("nativeSetDefaultTransitionDuration");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
ASSERT(duration_milliseconds >= 0);
|
||||
//ASSERT(duration_milliseconds <= UINT64_MAX);
|
||||
LOG_VERBOSE("nativeSetDefaultTransitionDuration");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetStyleJSON(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring new_style_json) {
|
||||
VERBOSE("nativeSetStyleJSON");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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));
|
||||
}
|
||||
|
||||
jstring JNICALL nativeGetStyleJSON(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetStyleJSON");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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());
|
||||
}
|
||||
|
||||
void JNICALL nativeCancelTransitions(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeCancelTransitions");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeMoveBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble dx, jdouble dy, jdouble duration) {
|
||||
VERBOSE("nativeMoveBy");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject lon_lat, jdouble duration) {
|
||||
VERBOSE("nativeSetLonLat");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeSetLonLat");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
|
||||
double lon = env->GetDoubleField(lon_lat, lon_lat_lon_id);
|
||||
@@ -337,13 +337,13 @@ void JNICALL nativeSetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr
|
||||
}
|
||||
|
||||
// TODO remove when fixed
|
||||
DEBUG("lon lat %f %f", lon, lat);
|
||||
LOG_DEBUG("lon lat %f %f", lon, lat);
|
||||
native_map_view->getMap()->setLonLat(lon, lat, duration);
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetLonLat");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeGetLonLat");
|
||||
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);
|
||||
@@ -358,64 +358,64 @@ jobject JNICALL nativeGetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_
|
||||
}
|
||||
|
||||
void JNICALL nativeStartPanning(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStartPanning");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeStopPanning(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStopPanning");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeResetPosition(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeResetPosition");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeScaleBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble ds, jdouble cx, jdouble cy, jdouble duration) {
|
||||
VERBOSE("nativeScaleBy");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetScale(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble scale, jdouble cx, jdouble cy, jdouble duration) {
|
||||
VERBOSE("nativeSetScale");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetScale(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetScale");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble zoom, jdouble duration) {
|
||||
VERBOSE("nativeSetZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject lon_lat_zoom, jdouble duration) {
|
||||
VERBOSE("nativeSetLonLatZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeSetLonLatZoom");
|
||||
LOG_ASSERT(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
|
||||
double lon = env->GetDoubleField(lon_lat_zoom, lon_lat_zoom_lon_id);
|
||||
@@ -440,8 +440,8 @@ void JNICALL nativeSetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetLonLatZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
LOG_VERBOSE("nativeGetLonLatZoom");
|
||||
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);
|
||||
@@ -456,113 +456,113 @@ jobject JNICALL nativeGetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_v
|
||||
}
|
||||
|
||||
void JNICALL nativeResetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeResetZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeStartScaling(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStartScaling");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeStopScaling(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStopScaling");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetMinZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetMinZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetMaxZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetMaxZoom");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeRotateBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble sx, jdouble sy, jdouble ex, jdouble ey, jdouble duration) {
|
||||
VERBOSE("nativeRotateBy");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble duration) {
|
||||
VERBOSE("nativeSetBearing");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble cx, jdouble cy) {
|
||||
VERBOSE("nativeSetBearing");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetBearing");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeResetNorth(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeResetNorth");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeStartRotating(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStartRotating");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeStopRotating(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeStopRotating");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeCanRotate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeCanRotate");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jboolean debug) {
|
||||
VERBOSE("nativeSetDebug");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
void JNICALL nativeToggleDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeToggleDebug");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeGetDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
VERBOSE("nativeGetDebug");
|
||||
ASSERT(native_map_view_ptr != 0);
|
||||
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();
|
||||
}
|
||||
@@ -572,11 +572,11 @@ jboolean JNICALL nativeGetDebug(JNIEnv* env, jobject obj, jlong native_map_view_
|
||||
extern "C" {
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
VERBOSE("JNI_OnLoad");
|
||||
LOG_VERBOSE("JNI_OnLoad");
|
||||
|
||||
JNIEnv* env = nullptr;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
ERROR("GetEnv() failed");
|
||||
LOG_ERROR("GetEnv() failed");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
@@ -775,11 +775,11 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
VERBOSE("JNI_OnUnload");
|
||||
LOG_VERBOSE("JNI_OnUnload");
|
||||
|
||||
JNIEnv* env = nullptr;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
ERROR("GetEnv() failed");
|
||||
LOG_ERROR("GetEnv() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,28 +15,28 @@ namespace android {
|
||||
void log_egl_string(EGLDisplay display, EGLint name, const char* label) {
|
||||
const char* str = eglQueryString(display, name);
|
||||
if (str == nullptr) {
|
||||
ERROR("eglQueryString(%d) returned error %d", name, eglGetError());
|
||||
LOG_ERROR("eglQueryString(%d) returned error %d", name, eglGetError());
|
||||
} else {
|
||||
INFO("EGL %s: %s", label, str);
|
||||
LOG_INFO("EGL %s: %s", label, str);
|
||||
}
|
||||
}
|
||||
|
||||
void log_gl_string(GLenum name, const char* label) {
|
||||
const GLubyte* str = glGetString(name);
|
||||
if (str == nullptr) {
|
||||
ERROR("glGetString(%d) returned error %d", name, glGetError());
|
||||
LOG_ERROR("glGetString(%d) returned error %d", name, glGetError());
|
||||
} else {
|
||||
INFO("GL %s: %s", label, str);
|
||||
LOG_INFO("GL %s: %s", label, str);
|
||||
}
|
||||
}
|
||||
|
||||
NativeMapView::NativeMapView(JNIEnv* env, jobject obj_,
|
||||
std::string default_style_json_) :
|
||||
default_style_json(default_style_json_) {
|
||||
VERBOSE("NativeMapView::NativeMapView");
|
||||
LOG_VERBOSE("NativeMapView::NativeMapView");
|
||||
|
||||
ASSERT(env != nullptr);
|
||||
ASSERT(obj_ != nullptr);
|
||||
LOG_ASSERT(env != nullptr);
|
||||
LOG_ASSERT(obj_ != nullptr);
|
||||
|
||||
if (env->GetJavaVM(&vm) < 0) {
|
||||
env->ExceptionDescribe();
|
||||
@@ -61,7 +61,7 @@ NativeMapView::NativeMapView(JNIEnv* env, jobject obj_,
|
||||
}
|
||||
|
||||
NativeMapView::~NativeMapView() {
|
||||
VERBOSE("NativeMapView::~NativeMapView");
|
||||
LOG_VERBOSE("NativeMapView::~NativeMapView");
|
||||
terminateContext();
|
||||
|
||||
delete map;
|
||||
@@ -70,42 +70,42 @@ NativeMapView::~NativeMapView() {
|
||||
delete view;
|
||||
view = nullptr;
|
||||
|
||||
ASSERT(vm != nullptr);
|
||||
ASSERT(obj != nullptr);
|
||||
LOG_ASSERT(vm != nullptr);
|
||||
LOG_ASSERT(obj != nullptr);
|
||||
|
||||
jint ret;
|
||||
JNIEnv* env = nullptr;
|
||||
if ((ret = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6)) == JNI_OK) {
|
||||
env->DeleteGlobalRef(obj);
|
||||
} else {
|
||||
ERROR("GetEnv() failed with %i", ret);
|
||||
LOG_ERROR("GetEnv() failed with %i", ret);
|
||||
}
|
||||
obj = nullptr;
|
||||
vm = nullptr;
|
||||
}
|
||||
|
||||
bool NativeMapView::initializeDisplay() {
|
||||
VERBOSE("NativeMapView::initializeDisplay");
|
||||
LOG_VERBOSE("NativeMapView::initializeDisplay");
|
||||
|
||||
ASSERT(display == EGL_NO_DISPLAY);
|
||||
ASSERT(config == nullptr);
|
||||
ASSERT(format < 0);
|
||||
LOG_ASSERT(display == EGL_NO_DISPLAY);
|
||||
LOG_ASSERT(config == nullptr);
|
||||
LOG_ASSERT(format < 0);
|
||||
|
||||
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (display == EGL_NO_DISPLAY) {
|
||||
ERROR("eglGetDisplay() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglGetDisplay() returned error %d", eglGetError());
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
|
||||
EGLint major, minor;
|
||||
if (!eglInitialize(display, &major, &minor)) {
|
||||
ERROR("eglInitialize() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglInitialize() returned error %d", eglGetError());
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
if ((major <= 1) && (minor < 3)) {
|
||||
ERROR("EGL version is too low, need 1.3, got %d.%d", major, minor);
|
||||
LOG_ERROR("EGL version is too low, need 1.3, got %d.%d", major, minor);
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
@@ -133,12 +133,12 @@ bool NativeMapView::initializeDisplay() {
|
||||
};
|
||||
EGLint num_configs;
|
||||
if (!eglChooseConfig(display, config_attribs, nullptr, 0, &num_configs)) {
|
||||
ERROR("eglChooseConfig(NULL) returned error %d", eglGetError());
|
||||
LOG_ERROR("eglChooseConfig(NULL) returned error %d", eglGetError());
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
if (num_configs < 1) {
|
||||
ERROR("eglChooseConfig() returned no configs");
|
||||
LOG_ERROR("eglChooseConfig() returned no configs");
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
@@ -148,40 +148,40 @@ bool NativeMapView::initializeDisplay() {
|
||||
const std::unique_ptr<EGLConfig[]> configs(new EGLConfig[num_configs]);
|
||||
if (!eglChooseConfig(display, config_attribs, configs.get(), num_configs,
|
||||
&num_configs)) {
|
||||
ERROR("eglChooseConfig() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglChooseConfig() returned error %d", eglGetError());
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
|
||||
config = chooseConfig(configs.get(), num_configs, use565);
|
||||
if (config == nullptr) {
|
||||
ERROR("No config chosen");
|
||||
LOG_ERROR("No config chosen");
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format)) {
|
||||
ERROR("eglGetConfigAttrib() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglGetConfigAttrib() returned error %d", eglGetError());
|
||||
terminateDisplay();
|
||||
return false;
|
||||
}
|
||||
DEBUG("Chosen window format is %d", format);
|
||||
LOG_DEBUG("Chosen window format is %d", format);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NativeMapView::terminateDisplay() {
|
||||
VERBOSE("NativeMapView::terminateDisplay");
|
||||
LOG_VERBOSE("NativeMapView::terminateDisplay");
|
||||
|
||||
if (display != EGL_NO_DISPLAY) {
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
eglGetError());
|
||||
}
|
||||
|
||||
if (!eglTerminate(display)) {
|
||||
ERROR("eglTerminate() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglTerminate() returned error %d", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,11 +191,11 @@ void NativeMapView::terminateDisplay() {
|
||||
}
|
||||
|
||||
bool NativeMapView::initializeContext() {
|
||||
VERBOSE("NativeMapView::initializeContext");
|
||||
LOG_VERBOSE("NativeMapView::initializeContext");
|
||||
|
||||
ASSERT(display != EGL_NO_DISPLAY);
|
||||
ASSERT(context == EGL_NO_CONTEXT);
|
||||
ASSERT(config != nullptr);
|
||||
LOG_ASSERT(display != EGL_NO_DISPLAY);
|
||||
LOG_ASSERT(context == EGL_NO_CONTEXT);
|
||||
LOG_ASSERT(config != nullptr);
|
||||
|
||||
const EGLint context_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
@@ -204,18 +204,18 @@ bool NativeMapView::initializeContext() {
|
||||
context = eglCreateContext(display, config, EGL_NO_CONTEXT,
|
||||
context_attribs);
|
||||
if (context == EGL_NO_CONTEXT) {
|
||||
ERROR("eglCreateContext() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglCreateContext() returned error %d", eglGetError());
|
||||
terminateContext();
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO("Context initialized");
|
||||
LOG_INFO("Context initialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NativeMapView::terminateContext() {
|
||||
VERBOSE("NativeMapView::terminateContext");
|
||||
LOG_VERBOSE("NativeMapView::terminateContext");
|
||||
|
||||
map->terminate();
|
||||
|
||||
@@ -228,13 +228,13 @@ void NativeMapView::terminateContext() {
|
||||
if (display != EGL_NO_DISPLAY) {
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
eglGetError());
|
||||
}
|
||||
|
||||
if (context != EGL_NO_CONTEXT) {
|
||||
if (!eglDestroyContext(display, context)) {
|
||||
ERROR("eglDestroyContext() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglDestroyContext() returned error %d", eglGetError());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,16 +243,16 @@ void NativeMapView::terminateContext() {
|
||||
}
|
||||
|
||||
bool NativeMapView::createSurface(ANativeWindow* window_) {
|
||||
VERBOSE("NativeMapView::createSurface");
|
||||
LOG_VERBOSE("NativeMapView::createSurface");
|
||||
|
||||
ASSERT(window == nullptr);
|
||||
ASSERT(window_ != nullptr);
|
||||
LOG_ASSERT(window == nullptr);
|
||||
LOG_ASSERT(window_ != nullptr);
|
||||
window = window_;
|
||||
|
||||
ASSERT(display != EGL_NO_DISPLAY);
|
||||
ASSERT(surface == EGL_NO_SURFACE);
|
||||
ASSERT(config != nullptr);
|
||||
ASSERT(format >= 0);
|
||||
LOG_ASSERT(display != EGL_NO_DISPLAY);
|
||||
LOG_ASSERT(surface == EGL_NO_SURFACE);
|
||||
LOG_ASSERT(config != nullptr);
|
||||
LOG_ASSERT(format >= 0);
|
||||
|
||||
ANativeWindow_setBuffersGeometry(window, 0, 0, format);
|
||||
|
||||
@@ -261,7 +261,7 @@ bool NativeMapView::createSurface(ANativeWindow* window_) {
|
||||
};
|
||||
surface = eglCreateWindowSurface(display, config, window, surface_attribs);
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
ERROR("eglCreateWindowSurface() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglCreateWindowSurface() returned error %d", eglGetError());
|
||||
destroySurface();
|
||||
return false;
|
||||
}
|
||||
@@ -272,11 +272,11 @@ bool NativeMapView::createSurface(ANativeWindow* window_) {
|
||||
}
|
||||
|
||||
void NativeMapView::destroySurface() {
|
||||
VERBOSE("NativeMapView::destroySurface");
|
||||
LOG_VERBOSE("NativeMapView::destroySurface");
|
||||
|
||||
if (surface != EGL_NO_SURFACE) {
|
||||
if (!eglDestroySurface(display, surface)) {
|
||||
ERROR("eglDestroySurface() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglDestroySurface() returned error %d", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,88 +290,88 @@ void NativeMapView::destroySurface() {
|
||||
|
||||
EGLConfig NativeMapView::chooseConfig(const EGLConfig configs[],
|
||||
EGLint num_configs, bool use565) const {
|
||||
INFO("Found %d configs", num_configs);
|
||||
LOG_INFO("Found %d configs", num_configs);
|
||||
|
||||
int chosen_config = -1;
|
||||
for (int i = 0; i < num_configs; i++) {
|
||||
INFO("Config %d:", i);
|
||||
LOG_INFO("Config %d:", i);
|
||||
|
||||
EGLint bits, red, green, blue, alpha, alpha_mask, depth, stencil,
|
||||
sample_buffers, samples;
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_BUFFER_SIZE, &bits)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_BUFFER_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_BUFFER_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_RED_SIZE, &red)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_RED_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_RED_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_GREEN_SIZE, &green)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_GREEN_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_GREEN_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_BLUE_SIZE, &blue)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_BLUE_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_BLUE_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_ALPHA_SIZE, &alpha)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_ALPHA_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_ALPHA_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_ALPHA_MASK_SIZE,
|
||||
&alpha_mask)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_ALPHA_MASK_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_ALPHA_MASK_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_DEPTH_SIZE, &depth)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_DEPTH_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_DEPTH_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_STENCIL_SIZE,
|
||||
&stencil)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_STENCIL_SIZE) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_STENCIL_SIZE) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_SAMPLE_BUFFERS,
|
||||
&sample_buffers)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_SAMPLE_BUFFERS) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_SAMPLE_BUFFERS) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(display, configs[i], EGL_SAMPLES, &samples)) {
|
||||
ERROR("eglGetConfigAttrib(EGL_SAMPLES) returned error %d",
|
||||
LOG_ERROR("eglGetConfigAttrib(EGL_SAMPLES) returned error %d",
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
INFO("Color: %d", bits);
|
||||
INFO("Red: %d", red);
|
||||
INFO("Green: %d", green);
|
||||
INFO("Blue: %d", blue);
|
||||
INFO("Alpha: %d", alpha);
|
||||
INFO("Alpha mask: %d", alpha_mask);
|
||||
INFO("Depth: %d", depth);
|
||||
INFO("Stencil: %d", stencil);
|
||||
INFO("Sample buffers: %d", sample_buffers);
|
||||
INFO("Samples: %d", samples);
|
||||
LOG_INFO("Color: %d", bits);
|
||||
LOG_INFO("Red: %d", red);
|
||||
LOG_INFO("Green: %d", green);
|
||||
LOG_INFO("Blue: %d", blue);
|
||||
LOG_INFO("Alpha: %d", alpha);
|
||||
LOG_INFO("Alpha mask: %d", alpha_mask);
|
||||
LOG_INFO("Depth: %d", depth);
|
||||
LOG_INFO("Stencil: %d", stencil);
|
||||
LOG_INFO("Sample buffers: %d", sample_buffers);
|
||||
LOG_INFO("Samples: %d", samples);
|
||||
|
||||
bool config_ok = true;
|
||||
config_ok &= bits == (use565 ? 16 : 32);
|
||||
@@ -390,7 +390,7 @@ EGLConfig NativeMapView::chooseConfig(const EGLConfig configs[],
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG("Chosen config is %d", chosen_config);
|
||||
LOG_DEBUG("Chosen config is %d", chosen_config);
|
||||
if (chosen_config >= 0) {
|
||||
return configs[chosen_config];
|
||||
} else {
|
||||
@@ -399,7 +399,7 @@ EGLConfig NativeMapView::chooseConfig(const EGLConfig configs[],
|
||||
}
|
||||
|
||||
void NativeMapView::start() {
|
||||
VERBOSE("NativeMapView::start");
|
||||
LOG_VERBOSE("NativeMapView::start");
|
||||
|
||||
if (display == EGL_NO_DISPLAY) {
|
||||
initializeDisplay();
|
||||
@@ -413,7 +413,7 @@ void NativeMapView::start() {
|
||||
&& (context != EGL_NO_CONTEXT)) {
|
||||
|
||||
if (!eglMakeCurrent(display, surface, surface, context)) {
|
||||
ERROR("eglMakeCurrent() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError());
|
||||
}
|
||||
|
||||
log_gl_string(GL_VENDOR, "Vendor");
|
||||
@@ -424,18 +424,18 @@ void NativeMapView::start() {
|
||||
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
eglGetError());
|
||||
}
|
||||
|
||||
map->start();
|
||||
} else {
|
||||
DEBUG("Not starting because we are not ready");
|
||||
LOG_DEBUG("Not starting because we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::stop() {
|
||||
VERBOSE("NativeMapView::stop");
|
||||
LOG_VERBOSE("NativeMapView::stop");
|
||||
if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)
|
||||
&& (context != EGL_NO_CONTEXT)) {
|
||||
map->stop();
|
||||
@@ -443,10 +443,10 @@ void NativeMapView::stop() {
|
||||
}
|
||||
|
||||
void NativeMapView::notifyMapChange() {
|
||||
DEBUG("NativeMapView::notify_map_change()");
|
||||
LOG_DEBUG("NativeMapView::notify_map_change()");
|
||||
|
||||
ASSERT(vm != nullptr);
|
||||
ASSERT(obj != nullptr);
|
||||
LOG_ASSERT(vm != nullptr);
|
||||
LOG_ASSERT(obj != nullptr);
|
||||
|
||||
JavaVMAttachArgs args = {
|
||||
JNI_VERSION_1_2,
|
||||
@@ -459,11 +459,11 @@ void NativeMapView::notifyMapChange() {
|
||||
bool detach = false;
|
||||
if ((ret = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6)) != JNI_OK) {
|
||||
if (ret != JNI_EDETACHED) {
|
||||
ERROR("GetEnv() failed with %i", ret);
|
||||
LOG_ERROR("GetEnv() failed with %i", ret);
|
||||
return;
|
||||
} else {
|
||||
if ((ret = vm->AttachCurrentThread(&env, &args)) != JNI_OK) {
|
||||
ERROR("AttachCurrentThread() failed with %i", ret);
|
||||
LOG_ERROR("AttachCurrentThread() failed with %i", ret);
|
||||
return;
|
||||
}
|
||||
detach = true;
|
||||
@@ -478,7 +478,7 @@ void NativeMapView::notifyMapChange() {
|
||||
|
||||
if (detach) {
|
||||
if ((ret = vm->DetachCurrentThread()) != JNI_OK) {
|
||||
ERROR("DetachCurrentThread() failed with %i", ret);
|
||||
LOG_ERROR("DetachCurrentThread() failed with %i", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -486,64 +486,64 @@ void NativeMapView::notifyMapChange() {
|
||||
}
|
||||
|
||||
void MBGLView::make_active() {
|
||||
VERBOSE("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)) {
|
||||
ERROR("eglMakeCurrent() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError());
|
||||
}
|
||||
|
||||
// TODO still can't fix the black screen problem :-(
|
||||
EGLint width, height;
|
||||
if (!(eglQuerySurface(nativeView->display, nativeView->surface, EGL_WIDTH, &width)
|
||||
& eglQuerySurface(nativeView->display, nativeView->surface, EGL_HEIGHT, &height))) {
|
||||
ERROR("eglQuerySurface() returned error %d", eglGetError());
|
||||
LOG_ERROR("eglQuerySurface() returned error %d", eglGetError());
|
||||
}
|
||||
map->resize(width, height);
|
||||
|
||||
} else {
|
||||
DEBUG("Not activating as we are not ready");
|
||||
LOG_DEBUG("Not activating as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::make_inactive() {
|
||||
VERBOSE("MBGLView::make_inactive");
|
||||
LOG_VERBOSE("MBGLView::make_inactive");
|
||||
// FIXME: this gets called before swap? bug?
|
||||
if (!eglMakeCurrent(nativeView->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
|
||||
eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::swap() {
|
||||
VERBOSE("MBGLView::swap");
|
||||
LOG_VERBOSE("MBGLView::swap");
|
||||
// FIXME bug workaround
|
||||
make_active();
|
||||
|
||||
if (map->needsSwap() && (nativeView->display != EGL_NO_DISPLAY)
|
||||
&& (nativeView->surface != EGL_NO_SURFACE)) {
|
||||
if (!eglSwapBuffers(nativeView->display, nativeView->surface)) {
|
||||
ERROR("eglSwapBuffers() returned error %d", eglGetError());
|
||||
ERROR("%u", reinterpret_cast<unsigned int>(nativeView->surface)); // TODO remove
|
||||
LOG_ERROR("eglSwapBuffers() returned error %d", eglGetError());
|
||||
LOG_ERROR("%u", reinterpret_cast<unsigned int>(nativeView->surface)); // TODO remove
|
||||
}
|
||||
map->swapped();
|
||||
} else {
|
||||
DEBUG("Not swapping as we are not ready");
|
||||
LOG_DEBUG("Not swapping as we are not ready");
|
||||
}
|
||||
// FIXME bug workaround
|
||||
make_inactive();
|
||||
}
|
||||
|
||||
void MBGLView::notify() {
|
||||
DEBUG("MBGLView::notify()");
|
||||
LOG_DEBUG("MBGLView::notify()");
|
||||
// noop
|
||||
}
|
||||
|
||||
void MBGLView::notify_map_change(mbgl::MapChange /* change */, mbgl::timestamp /* delay */) {
|
||||
DEBUG("MBGLView::notify_map_change()");
|
||||
LOG_DEBUG("MBGLView::notify_map_change()");
|
||||
nativeView->notifyMapChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#define S_(x) S(x)
|
||||
#define S__LINE__ S_(__LINE__)
|
||||
|
||||
#define VERBOSE(fmt, args...) __android_log_print(ANDROID_LOG_VERBOSE, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define DEBUG(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define INFO(fmt, args...) __android_log_print(ANDROID_LOG_INFO, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define WARN(fmt, args...) __android_log_print(ANDROID_LOG_WARN, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define ERROR(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define ASSERT(cond, ...) ((cond)?(void)0:__android_log_assert(#cond, __FILE__ ":" S__LINE__, NULL))
|
||||
#define ASSERTMSG(cond, fmt, args...) ((cond)?(void)0:__android_log_assert(#cond, __FILE__ ":" S__LINE__, fmt, ##args))
|
||||
#define LOG_VERBOSE(fmt, args...) __android_log_print(ANDROID_LOG_VERBOSE, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define LOG_DEBUG(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define LOG_INFO(fmt, args...) __android_log_print(ANDROID_LOG_INFO, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define LOG_WARN(fmt, args...) __android_log_print(ANDROID_LOG_WARN, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define LOG_ERROR(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, __FILE__ ":" S__LINE__, fmt, ##args)
|
||||
#define LOG_ASSERT(cond, ...) ((cond)?(void)0:__android_log_assert(#cond, __FILE__ ":" S__LINE__, NULL))
|
||||
#define LOG_ASSERTMSG(cond, fmt, args...) ((cond)?(void)0:__android_log_assert(#cond, __FILE__ ":" S__LINE__, fmt, ##args))
|
||||
|
||||
#endif // LOG_H
|
||||
|
||||
Reference in New Issue
Block a user