Fix flixker after switch

This commit is contained in:
Leith Bade
2014-11-10 00:23:09 +11:00
parent b6616f0aa3
commit 6b65aa62a1
4 changed files with 27 additions and 15 deletions

View File

@@ -284,22 +284,26 @@ bool NativeMapView::createSurface(ANativeWindow* window_) {
return false;
}
if (!eglMakeCurrent(display, surface, surface, context)) {
LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError());
}
if (!first_time) {
first_time = true;
log_gl_string(GL_VENDOR, "Vendor");
log_gl_string(GL_RENDERER, "Renderer");
log_gl_string(GL_VERSION, "Version");
log_gl_string(GL_SHADING_LANGUAGE_VERSION, "SL Version"); // In the emulator this returns NULL with error code 0? https://code.google.com/p/android/issues/detail?id=78977
log_gl_string(GL_EXTENSIONS, "Extensions");
if (!eglMakeCurrent(display, surface, surface, context)) {
LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError());
}
loadExtensions();
log_gl_string(GL_VENDOR, "Vendor");
log_gl_string(GL_RENDERER, "Renderer");
log_gl_string(GL_VERSION, "Version");
log_gl_string(GL_SHADING_LANGUAGE_VERSION, "SL Version"); // In the emulator this returns NULL with error code 0? https://code.google.com/p/android/issues/detail?id=78977
log_gl_string(GL_EXTENSIONS, "Extensions");
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT)) {
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
eglGetError());
loadExtensions();
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT)) {
LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d",
eglGetError());
}
}
resume();

View File

@@ -91,6 +91,8 @@ private:
std::string style_url;
std::string api_key;
bool first_time = false;
};
class MBGLView: public mbgl::View {

View File

@@ -374,6 +374,7 @@ public class MapView extends SurfaceView {
mNativeMapView.initializeDisplay();
mNativeMapView.initializeContext();
mNativeMapView.start();
}
// Called when we need to save instance state
@@ -393,6 +394,7 @@ public class MapView extends SurfaceView {
// Must be called from Activity onDestroy
public void onDestroy() {
Log.v(TAG, "onDestroy");
mNativeMapView.stop();
mNativeMapView.terminateContext();
mNativeMapView.terminateDisplay();
}
@@ -401,14 +403,14 @@ public class MapView extends SurfaceView {
// Must be called from Activity onStart
public void onStart() {
Log.v(TAG, "onStart");
mNativeMapView.start();
//mNativeMapView.start();
}
// Called when we need to terminate the GL context
// Must be called from Activity onPause
public void onStop() {
Log.v(TAG, "onStop");
mNativeMapView.stop();
//mNativeMapView.stop();
}
// Called when we need to stop the render thread

View File

@@ -230,12 +230,16 @@ void Map::run() {
void Map::check_for_pause() {
mutex_run->lock();
while (pausing) {
view.make_inactive();
mutex_pause->lock();
is_paused = true;
cond_pause->broadcast();
mutex_pause->unlock();
cond_run->wait(*mutex_run);
view.make_active();
}
mutex_pause->lock();