summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-03-11 19:43:13 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-03-12 12:16:38 +0100
commit47ede853c4c0dd8e953f3ee98b807f044d178d76 (patch)
tree75d56f01853cb64b200d8977069dfe992266e9de /android
parentba9d2420699507c6d32b12272151529663c8d2fd (diff)
downloadqtlocation-mapboxgl-47ede853c4c0dd8e953f3ee98b807f044d178d76.tar.gz
fixes black flicker on rotating the device
fixes #838 instead of rendering ad libitum on the map thread, we are now driving rendering from the UI thread on iOS via the map.renderSync() function. There are still white bars during the rotation, but the general content of the view is kept visible. - upgrades GLFW to 3.1 - removes swapped/needsSwap in favor of a more explicit scheme - View#invalidate() now replaces View#swap() and is called whenever the View needs to trigger a rerender. GLFW and Android to this right away, while iOS goes back to the main thread and does the Map redrawing as part of the GLKView update - sets all iOS deployment targets to 7.0 - disables SQLite3 version check, since the library version changed on iOS 8.2
Diffstat (limited to 'android')
-rw-r--r--android/cpp/jni.cpp28
-rw-r--r--android/cpp/native_map_view.cpp9
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java22
3 files changed, 7 insertions, 52 deletions
diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp
index 1163c33b57..8a67c0e876 100644
--- a/android/cpp/jni.cpp
+++ b/android/cpp/jni.cpp
@@ -291,18 +291,11 @@ void JNICALL nativeRun(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
nativeMapView->getMap().run();
}
-void JNICALL nativeRerender(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
- mbgl::Log::Debug(mbgl::Event::JNI, "nativeRerender");
- assert(nativeMapViewPtr != 0);
- NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- nativeMapView->getMap().rerender();
-}
-
void JNICALL nativeUpdate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeUpdate");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- nativeMapView->getMap().update();
+ nativeMapView->getMap().triggerUpdate();
}
void JNICALL nativeTerminate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
@@ -312,20 +305,6 @@ void JNICALL nativeTerminate(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
nativeMapView->getMap().terminate();
}
-jboolean JNICALL nativeNeedsSwap(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
- mbgl::Log::Debug(mbgl::Event::JNI, "nativeNeedsSwap");
- assert(nativeMapViewPtr != 0);
- NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- return nativeMapView->getMap().needsSwap();
-}
-
-void JNICALL nativeSwapped(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
- mbgl::Log::Debug(mbgl::Event::JNI, "nativeSwapped");
- assert(nativeMapViewPtr != 0);
- NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- nativeMapView->getMap().swapped();
-}
-
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");
@@ -1002,7 +981,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
// NOTE: if you get java.lang.UnsatisfiedLinkError you likely forgot to set the size of the
// array correctly (too large)
- std::array<JNINativeMethod, 66> methods = {{ // Can remove the extra brace in C++14
+ std::array<JNINativeMethod, 63> methods = {{ // Can remove the extra brace in C++14
{"nativeCreate", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J",
reinterpret_cast<void *>(&nativeCreate)},
{"nativeDestroy", "(J)V", reinterpret_cast<void *>(&nativeDestroy)},
@@ -1018,11 +997,8 @@ 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)},
{"nativeRun", "(J)V", reinterpret_cast<void *>(&nativeRun)},
- {"nativeRerender", "(J)V", reinterpret_cast<void *>(&nativeRerender)},
{"nativeUpdate", "(J)V", reinterpret_cast<void *>(&nativeUpdate)},
{"nativeTerminate", "(J)V", reinterpret_cast<void *>(&nativeTerminate)},
- {"nativeNeedsSwap", "(J)Z", reinterpret_cast<void *>(&nativeNeedsSwap)},
- {"nativeSwapped", "(J)V", reinterpret_cast<void *>(&nativeSwapped)},
{"nativeResize", "(JIIFII)V",
reinterpret_cast<void *>(static_cast<void JNICALL (
*)(JNIEnv *, jobject, jlong, jint, jint, jfloat, jint, jint)>(&nativeResize))},
diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp
index 35bb6b88a9..39a777bff2 100644
--- a/android/cpp/native_map_view.cpp
+++ b/android/cpp/native_map_view.cpp
@@ -121,16 +121,17 @@ void NativeMapView::deactivate() {
}
}
-void NativeMapView::swap() {
- mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::swap");
+void NativeMapView::invalidate() {
+ mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::invalidate");
+
+ if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) {
+ map.render();
- if (map.needsSwap() && (display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) {
if (!eglSwapBuffers(display, surface)) {
mbgl::Log::Error(mbgl::Event::OpenGL, "eglSwapBuffers() returned error %d",
eglGetError());
throw new std::runtime_error("eglSwapBuffers() failed");
}
- map.swapped();
updateFps();
} else {
mbgl::Log::Info(mbgl::Event::Android, "Not swapping as we are not ready");
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java
index a73a89d2d7..186b391a84 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/NativeMapView.java
@@ -93,26 +93,10 @@ class NativeMapView {
nativeRun(mNativeMapViewPtr);
}
- public void rerender() {
- nativeRerender(mNativeMapViewPtr);
- }
-
public void update() {
nativeUpdate(mNativeMapViewPtr);
}
- public void terminate() {
- nativeTerminate(mNativeMapViewPtr);
- }
-
- public boolean needsSwap() {
- return nativeNeedsSwap(mNativeMapViewPtr);
- }
-
- public void swapped() {
- nativeSwapped(mNativeMapViewPtr);
- }
-
public void resize(int width, int height, float ratio, int fbWidth,
int fbHeight) {
if (width < 0) {
@@ -440,16 +424,10 @@ class NativeMapView {
private native void nativeRun(long nativeMapViewPtr);
- private native void nativeRerender(long nativeMapViewPtr);
-
private native void nativeUpdate(long nativeMapViewPtr);
private native void nativeTerminate(long nativeMapViewPtr);
- private native boolean nativeNeedsSwap(long nativeMapViewPtr);
-
- private native void nativeSwapped(long nativeMapViewPtr);
-
private native void nativeResize(long nativeMapViewPtr, int width,
int height, float ratio, int fbWidth, int fbHeight);