Use the new CallbackHandler in the java bindings

Java callbacks are now directly dispatched to their handler, instead
of first going through filament's opportunistic dispatch, reducing
callback latency.
This commit is contained in:
Mathias Agopian
2021-09-30 20:49:05 -07:00
committed by Mathias Agopian
parent 3ac8a6a21c
commit 1c1cb11cf5
21 changed files with 171 additions and 133 deletions

View File

@@ -27,5 +27,8 @@ Java_com_google_android_filament_SwapChain_nSetFrameCompletedCallback(JNIEnv* en
jlong nativeSwapChain, jobject handler, jobject runnable) {
SwapChain* swapChain = (SwapChain*) nativeSwapChain;
auto *callback = JniCallback::make(env, handler, runnable);
swapChain->setFrameCompletedCallback(&JniCallback::invoke, callback);
swapChain->setFrameCompletedCallback([](void* user) {
JniCallback* callback = (JniCallback*)user;
JniCallback::postToJavaAndDestroy(callback);
}, callback);
}