diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-09-11 11:04:53 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-09-22 23:33:56 +0300 |
commit | 15a47d116a0fc15d249b37574fcd932ce88909df (patch) | |
tree | 520327b215324b19cf30ecd207fad651b7b83fba /platform/android/src/native_map_view.cpp | |
parent | 347d7c19c0a70f91252163b14e37583eea83fdd5 (diff) | |
download | qtlocation-mapboxgl-15a47d116a0fc15d249b37574fcd932ce88909df.tar.gz |
[android] schedule work on the gl thread using GLSurfaceView#queueEvent
Diffstat (limited to 'platform/android/src/native_map_view.cpp')
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 1a0dc34bbc..51edd8079f 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -78,7 +78,8 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, *threadPool, jni::Make<std::string>(_env, _programCacheDir), - [this] { this->invalidate(); }); + [this] { this->requestRender(); }, + [this] { this->requestProcessing(); }); // Create the core map map = std::make_unique<mbgl::Map>(*rendererFrontend, *this, @@ -97,17 +98,23 @@ NativeMapView::~NativeMapView() { } /** - * Callback to java NativeMapView#onInvalidate(). + * Callback to java NativeMapView#requestRender(). * - * Called to invalidate the View and schedule a render on the next + * Called to schedule a render on the next * runloop iteration. */ -void NativeMapView::invalidate() { +void NativeMapView::requestRender() { android::UniqueEnv _env = android::AttachEnv(); - static auto onInvalidate = javaClass.GetMethod<void ()>(*_env, "onInvalidate"); + static auto onInvalidate = javaClass.GetMethod<void ()>(*_env, "requestRender"); javaPeer->Call(*_env, onInvalidate); } +void NativeMapView::requestProcessing() { + android::UniqueEnv _env = android::AttachEnv(); + static auto requestProcessing = javaClass.GetMethod<void ()>(*_env, "requestProcessing"); + javaPeer->Call(*_env, requestProcessing); +} + /** * From mbgl::RendererBackend. Callback to java NativeMapView#onMapChanged(int). * @@ -195,8 +202,9 @@ void NativeMapView::render(jni::JNIEnv& ) { updateFps(); } -void NativeMapView::update(jni::JNIEnv&) { - invalidate(); +// Called from the OpenGL renderer thread +void NativeMapView::process(jni::JNIEnv&) { + rendererFrontend->process(); } void NativeMapView::resizeView(jni::JNIEnv&, int w, int h) { @@ -1004,7 +1012,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) { "nativeInitialize", "nativeDestroy", METHOD(&NativeMapView::render, "nativeRender"), - METHOD(&NativeMapView::update, "nativeUpdate"), + METHOD(&NativeMapView::process, "nativeProcess"), METHOD(&NativeMapView::resizeView, "nativeResizeView"), METHOD(&NativeMapView::resizeFramebuffer, "nativeResizeFramebuffer"), METHOD(&NativeMapView::getStyleUrl, "nativeGetStyleUrl"), |