summaryrefslogtreecommitdiff
path: root/android/cpp/jni.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-06-25 14:39:42 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-06-26 10:32:06 -0700
commitdca42018d26aaab2148db0b8f2971821ebc3a4cf (patch)
tree376402b108bc895ea4e5c45cdcda14af959abb61 /android/cpp/jni.cpp
parent84e2ea886dc55917a1d6b665337fff6d3862984a (diff)
downloadqtlocation-mapboxgl-dca42018d26aaab2148db0b8f2971821ebc3a4cf.tar.gz
drive Android rendering from the main thread via invalidate() calls
Diffstat (limited to 'android/cpp/jni.cpp')
-rw-r--r--android/cpp/jni.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp
index 64e72e1499..36ef273d68 100644
--- a/android/cpp/jni.cpp
+++ b/android/cpp/jni.cpp
@@ -30,6 +30,7 @@ std::string dataPath;
std::string apkPath;
std::string androidRelease;
+jmethodID onInvalidateId = nullptr;
jmethodID onMapChangedId = nullptr;
jmethodID onFpsChangedId = nullptr;
@@ -277,6 +278,13 @@ void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
nativeMapView->getMap().update();
}
+void JNICALL nativeOnInvalidate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
+ mbgl::Log::Debug(mbgl::Event::JNI, "nativeOnInvalidate");
+ assert(nativeMapViewPtr != 0);
+ NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
+ nativeMapView->onInvalidate();
+}
+
void JNICALL nativeResize(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jint width, jint height,
jfloat ratio, jint fbWidth, jint fbHeight) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResize");
@@ -805,6 +813,12 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
+ onInvalidateId = env->GetMethodID(nativeMapViewClass, "onInvalidate", "()V");
+ if (onInvalidateId == nullptr) {
+ env->ExceptionDescribe();
+ return JNI_ERR;
+ }
+
onMapChangedId = env->GetMethodID(nativeMapViewClass, "onMapChanged", "()V");
if (onMapChangedId == nullptr) {
env->ExceptionDescribe();
@@ -921,6 +935,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
{"nativePause", "(J)V", reinterpret_cast<void *>(&nativePause)},
{"nativeResume", "(J)V", reinterpret_cast<void *>(&nativeResume)},
{"nativeUpdate", "(J)V", reinterpret_cast<void *>(&nativeUpdate)},
+ {"nativeOnInvalidate", "(J)V", reinterpret_cast<void *>(&nativeOnInvalidate)},
{"nativeResize", "(JIIFII)V",
reinterpret_cast<void *>(static_cast<void JNICALL (
*)(JNIEnv *, jobject, jlong, jint, jint, jfloat, jint, jint)>(&nativeResize))},
@@ -1092,6 +1107,7 @@ extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
latLngZoomLatitudeId = nullptr;
latLngZoomZoomId = nullptr;
+ onInvalidateId = nullptr;
onMapChangedId = nullptr;
onFpsChangedId = nullptr;