summaryrefslogtreecommitdiff
path: root/platform/android/src/native_map_view.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-04-13 19:53:29 +0300
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-14 13:51:27 -0700
commit7b3c61f6198cd36b1cc08f26d9a3d8e748a49a99 (patch)
tree561c051b9698c69695d566a9ba6969e05960d4f1 /platform/android/src/native_map_view.cpp
parenta65c19c5694a54770eddf03536ff8dcb585608b1 (diff)
downloadqtlocation-mapboxgl-7b3c61f6198cd36b1cc08f26d9a3d8e748a49a99.tar.gz
[android] Do not attach/detach to threads
Not needed as everything is now running on the same thread.
Diffstat (limited to 'platform/android/src/native_map_view.cpp')
-rwxr-xr-xplatform/android/src/native_map_view.cpp36
1 files changed, 6 insertions, 30 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 6b1d4ff327..0607dd1cca 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -54,14 +54,15 @@ void log_gl_string(GLenum name, const char *label) {
}
}
-NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int availableProcessors_, size_t totalMemory_)
+NativeMapView::NativeMapView(JNIEnv *env_, jobject obj_, float pixelRatio_, int availableProcessors_, size_t totalMemory_)
: mbgl::View(*this),
+ env(env_),
pixelRatio(pixelRatio_),
availableProcessors(availableProcessors_),
totalMemory(totalMemory_) {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::NativeMapView");
- assert(env != nullptr);
+ assert(env_ != nullptr);
assert(obj_ != nullptr);
if (env->GetJavaVM(&vm) < 0) {
@@ -104,16 +105,10 @@ NativeMapView::~NativeMapView() {
map.reset();
fileSource.reset();
- jint ret;
- JNIEnv *env = nullptr;
- ret = vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
- if (ret == JNI_OK) {
- env->DeleteWeakGlobalRef(obj);
- } else {
- mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
- throw std::runtime_error("GetEnv() failed");
- }
+ env->DeleteWeakGlobalRef(obj);
+
obj = nullptr;
+ env = nullptr;
vm = nullptr;
}
@@ -134,8 +129,6 @@ void NativeMapView::activate() {
assert(vm != nullptr);
- renderDetach = attach_jni_thread(vm, &renderEnv, "Map Thread");
-
if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE) && (context != EGL_NO_CONTEXT)) {
if (!eglMakeCurrent(display, surface, surface, context)) {
mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent() returned error %d",
@@ -166,8 +159,6 @@ void NativeMapView::deactivate() {
} else {
mbgl::Log::Info(mbgl::Event::Android, "Not deactivating as we are not ready");
}
-
- detach_jni_thread(vm, &renderEnv, renderDetach);
}
void NativeMapView::invalidate() {
@@ -176,15 +167,10 @@ void NativeMapView::invalidate() {
assert(vm != nullptr);
assert(obj != nullptr);
- JNIEnv *env = nullptr;
- bool detach = attach_jni_thread(vm, &env, "NativeMapView::invalidate()");
-
env->CallVoidMethod(obj, onInvalidateId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
-
- detach_jni_thread(vm, &env, detach);
}
void NativeMapView::render() {
@@ -661,15 +647,10 @@ void NativeMapView::notifyMapChange(mbgl::MapChange change) {
assert(vm != nullptr);
assert(obj != nullptr);
- JNIEnv *env = nullptr;
- bool detach = attach_jni_thread(vm, &env, "NativeMapView::notifyMapChange()");
-
env->CallVoidMethod(obj, onMapChangedId, change);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
-
- detach_jni_thread(vm, &env, detach);
}
void NativeMapView::enableFps(bool enable) {
@@ -703,15 +684,10 @@ void NativeMapView::updateFps() {
assert(vm != nullptr);
assert(obj != nullptr);
- JNIEnv *env = nullptr;
- bool detach = attach_jni_thread(vm, &env, "NativeMapView::updateFps()");
-
env->CallVoidMethod(obj, onFpsChangedId, fps);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}
-
- detach_jni_thread(vm, &env, detach);
}
void NativeMapView::resizeView(int w, int h) {