diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-07 02:17:49 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-07 02:33:42 +0200 |
commit | 0ce2d740a2ed93a029a290fe88748ac92baff9a0 (patch) | |
tree | 3751cf456702440375fac64790df35bbf46a2dd2 /vcl/android | |
parent | 8ba203c726df97039125ad8b3223802fc80a9110 (diff) |
Handle damage tracking and redrawing properly in the "desktop" Android app
In the damaged() method do a callback up to Java code in Desktop that
invalidates the view. For now store the view in a static field, but need to do
that in a cleaner way eventually. There might in some circumstancest be
several instances of the Desktop activity present. Obviously should also run
just one LO thread.
Get rid of the temporary self-invalidattion in onDraw() silliness.
Start the LO thread that runs soffice_main() from Java, not from native
code. Apparently only threads created from Java have proper class loaders in
Android.
No need for an own DoReleaseYield() in AndroidSalInstance, the one in the
SvpSalInstance base class does what needs to be done.
Change-Id: I4cb85b352fca1f1375f726620ec8c93d2047f113
Diffstat (limited to 'vcl/android')
-rw-r--r-- | vcl/android/androidinst.cxx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx index f742c1b576f0..c35321531fe1 100644 --- a/vcl/android/androidinst.cxx +++ b/vcl/android/androidinst.cxx @@ -42,8 +42,6 @@ #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOGTAG, __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOGTAG, __VA_ARGS__)) -static bool bHitIdle = false; - // Horrible hack static int viewWidth = 1, viewHeight = 1; @@ -305,13 +303,15 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buf if (pBuffer && pWindow) ANativeWindow_unlockAndPost(pWindow); - - mbQueueReDraw = false; } void AndroidSalInstance::damaged(AndroidSalFrame */* frame */) { - mbQueueReDraw = true; + // Call the Java layer to post an invalidate if necessary + // static public void org.libreoffice.experimental.desktop.Desktop.callbackDamaged(); + + if (m_nDesktopClass != 0 && m_nCallbackDamaged != 0) + m_pJNIEnv->CallStaticVoidMethod(m_nDesktopClass, m_nCallbackDamaged); } #if 0 @@ -583,8 +583,19 @@ extern "C" { AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex ) : SvpSalInstance( pMutex ) - , mbQueueReDraw( false ) { + int res = (lo_get_javavm())->AttachCurrentThread(&m_pJNIEnv, NULL); + LOGI("AttachCurrentThread res=%d env=%p", res, m_pJNIEnv); + + m_nDesktopClass = m_pJNIEnv->FindClass("org/libreoffice/experimental/desktop/Desktop"); + if (m_nDesktopClass == 0) + LOGE("Could not find Desktop class"); + else { + m_nCallbackDamaged = m_pJNIEnv->GetStaticMethodID(m_nDesktopClass, "callbackDamaged", "()V"); + if (m_nCallbackDamaged == 0) + LOGE("Could not find the callbackDamaged method"); + } + LOGI("created Android Sal Instance thread: %d", (int)pthread_self()); } @@ -600,6 +611,8 @@ void AndroidSalInstance::Wakeup() LOGI("busted - no global looper"); } +#if 0 + void AndroidSalInstance::DoReleaseYield (int nTimeoutMS) { if (!bHitIdle) @@ -655,6 +668,8 @@ void AndroidSalInstance::DoReleaseYield (int nTimeoutMS) #endif } +#endif + bool AndroidSalInstance::AnyInput( sal_uInt16 nType ) { if( (nType & VCL_INPUT_TIMER) != 0 ) @@ -847,9 +862,6 @@ Java_org_libreoffice_experimental_desktop_Desktop_renderVCL(JNIEnv *env, jobject /* clazz */, jobject bitmap) { - if (!bHitIdle) - return; - AndroidBitmapInfo info; void* pixels; int ret; |