diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-01-26 10:29:38 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-01-26 10:29:38 +0000 |
commit | 7c4c1832ccd4830f903d7d647466f96aa6755711 (patch) | |
tree | 068c7fad565eef36d17ed45207065d7002b863e0 | |
parent | 0f32f98564f8e0e66bc2d2ee5c55406930007044 (diff) |
android: move lo-bootstrap to osl/detail, Attach threads as created
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 2 | ||||
-rw-r--r-- | sal/Package_inc.mk | 1 | ||||
-rw-r--r-- | sal/android/lo-bootstrap.c | 2 | ||||
-rw-r--r-- | sal/inc/osl/detail/android-bootstrap.h (renamed from solenv/inc/unxandr/lo-bootstrap.h) | 5 | ||||
-rw-r--r-- | sal/osl/unx/file.cxx | 2 | ||||
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 4 | ||||
-rw-r--r-- | sal/osl/unx/module.c | 2 | ||||
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 2 | ||||
-rw-r--r-- | sal/osl/unx/thread.c | 18 | ||||
-rw-r--r-- | sal/osl/unx/uunxapi.cxx | 2 | ||||
-rw-r--r-- | vcl/android/androidinst.cxx | 26 | ||||
-rw-r--r-- | vcl/inc/android/androidinst.hxx | 1 |
12 files changed, 50 insertions, 17 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index a8d82581d16e..f28882186ba9 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -65,7 +65,7 @@ #include "diagnostics.h" #ifdef ANDROID -#include <lo-bootstrap.h> +#include <osl/detail/android-bootstrap.h> #endif #if defined HAVE_VALGRIND_H diff --git a/sal/Package_inc.mk b/sal/Package_inc.mk index e43de3e46388..304ab9d68797 100644 --- a/sal/Package_inc.mk +++ b/sal/Package_inc.mk @@ -65,6 +65,7 @@ $(eval $(call gb_Package_add_file,sal_inc,inc/osl/time.h,osl/time.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/util.h,osl/util.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/file.h,osl/detail/file.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/android_native_app_glue.h,osl/detail/android_native_app_glue.h)) +$(eval $(call gb_Package_add_file,sal_inc,inc/osl/detail/android-bootstrap.h,osl/detail/android-bootstrap.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/rtl/allocator.hxx,rtl/allocator.hxx)) $(eval $(call gb_Package_add_file,sal_inc,inc/rtl/alloc.h,rtl/alloc.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/rtl/bootstrap.h,rtl/bootstrap.h)) diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c index 55bc643f38ab..98db089c2d7d 100644 --- a/sal/android/lo-bootstrap.c +++ b/sal/android/lo-bootstrap.c @@ -48,7 +48,7 @@ #include "uthash.h" -#include "lo-bootstrap.h" +#include "osl/detail/android-bootstrap.h" #pragma GCC diagnostic ignored "-Wdeclaration-after-statement" diff --git a/solenv/inc/unxandr/lo-bootstrap.h b/sal/inc/osl/detail/android-bootstrap.h index d78d88beaaab..65396873ac93 100644 --- a/solenv/inc/unxandr/lo-bootstrap.h +++ b/sal/inc/osl/detail/android-bootstrap.h @@ -27,6 +27,8 @@ * instead of those above. */ +#ifndef ANDROID_BOOSTRAP_H +#define ANDROID_BOOSTRAP_H #if defined(ANDROID) #include <jni.h> @@ -72,6 +74,7 @@ struct android_app *lo_get_app(void); } #endif -#endif +#endif // ANDROID +#endif // ANDROID_BOOTSTRAP_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 63e9775fa25e..b8a851f5a84d 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -59,7 +59,7 @@ #endif /* MACOSX */ #ifdef ANDROID -#include <lo-bootstrap.h> +#include <osl/detail/android-bootstrap.h> #endif #ifdef DEBUG_OSL_FILE diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index 260b711ee1da..962d7bf3701a 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -55,7 +55,7 @@ #include <algorithm> #ifdef ANDROID -#include <lo-bootstrap.h> +#include <osl/detail/android-bootstrap.h> #endif /************************************************************************ @@ -774,7 +774,7 @@ static oslFileError osl_psz_removeFile( const sal_Char* pszPath ) int nRet=0; struct stat aStat; - nRet = lstat(pszPath,&aStat); + nRet = lstat_c(pszPath,&aStat); if ( nRet < 0 ) { nRet=errno; diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index 2889a7723a91..792f0cd81207 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -44,7 +44,7 @@ #endif #ifdef ANDROID -#include <lo-bootstrap.h> +#include <osl/detail/android-bootstrap.h> #endif /* implemented in file.c */ diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 83c5c8872dbe..d90fdea310ff 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -60,7 +60,7 @@ #include "uunxapi.h" #ifdef ANDROID -#include <lo-bootstrap.h> +#include <osl/detail/android-bootstrap.h> #endif /*************************************** diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c index 4128d08f0d63..59a0514b322b 100644 --- a/sal/osl/unx/thread.c +++ b/sal/osl/unx/thread.c @@ -37,6 +37,10 @@ #include <rtl/textenc.h> #include <rtl/alloc.h> #include <sal/macros.h> +#ifdef ANDROID +#include <jni.h> +#include <osl/detail/android-bootstrap.h> +#endif #if defined LINUX && ! defined __FreeBSD_kernel__ #include <sys/prctl.h> @@ -288,8 +292,22 @@ static void* osl_thread_start_Impl (void* pData) if (!terminate) { +#ifdef ANDROID + { + JNIEnv* env = 0; + int res = (*lo_get_javavm())->AttachCurrentThread(lo_get_javavm(), &env, NULL); // res == 0 + fprintf (stderr, "new sal thread started and attached %d!\n", res); + } +#endif /* call worker function */ pImpl->m_WorkerFunction(pImpl->m_pData); + +#ifdef ANDROID + { + int res = (*lo_get_javavm())->DetachCurrentThread(lo_get_javavm()); + fprintf (stderr, "detached finished sal thread %d!\n", res); + } +#endif } /* call cleanup handler and leave */ diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx index 8abe57f3b2f7..270f5c33513a 100644 --- a/sal/osl/unx/uunxapi.cxx +++ b/sal/osl/unx/uunxapi.cxx @@ -48,7 +48,7 @@ #endif #ifdef ANDROID - #include <lo-bootstrap.h> + #include <osl/detail/android-bootstrap.h> #endif //########################### diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx index 4772a74a306d..d867fa817e19 100644 --- a/vcl/android/androidinst.cxx +++ b/vcl/android/androidinst.cxx @@ -29,9 +29,10 @@ #include <android/androidinst.hxx> #include <headless/svpdummies.hxx> #include <generic/gendata.hxx> +#include <jni.h> #include <android/log.h> #include <android/looper.h> -#include <lo-bootstrap.h> +#include <osl/detail/android-bootstrap.h> #include <osl/detail/android_native_app_glue.h> #include <rtl/strbuf.hxx> @@ -78,12 +79,13 @@ static void BlitFrameRegionToWindow(ANativeWindow *pWindow, const ARect &rSrcRect, int nDestX, int nDestY) { - fprintf (stderr, "Blit frame src %d,%d->%d,%d to position %d, %d\n", + fprintf (stderr, "Blit frame #2 src %d,%d->%d,%d to position %d, %d\n", rSrcRect.left, rSrcRect.top, rSrcRect.right, rSrcRect.bottom, nDestX, nDestY); ARect aRect; ANativeWindow_Buffer aOutBuffer; memset ((void *)&aOutBuffer, 0, sizeof (aOutBuffer)); + fprintf (stderr, "pre lock\n"); int32_t nRet = ANativeWindow_lock(pWindow, &aOutBuffer, &aRect); fprintf (stderr, "locked window %d returned rect: %d,%d->%d,%d " "buffer: %dx%d stride %d, format %d, bits %p\n", @@ -110,6 +112,7 @@ static void BlitFrameRegionToWindow(ANativeWindow *pWindow, unsigned char *dp = ( (unsigned char *)aOutBuffer.bits + aOutBuffer.stride * (y + nDestY) + nDestX * 4 /* dest pixel size */ ); + fprintf (stderr, "y %d, sp %p dp %p\n", y, sp, dp); for (unsigned int x = 0; x < (unsigned int)(aSrcRect.right - aSrcRect.left); x++) { dp[x*4 + 0] = sp[x*3 + 0]; // B @@ -164,8 +167,7 @@ void AndroidSalInstance::onAppCmd (struct android_app* app, int32_t cmd) fprintf (stderr, "we have an app window ! %p %dx%x (%d)\n", pWindow, aRect.right, aRect.bottom, ANativeWindow_getFormat(pWindow)); - - RedrawWindows(pWindow); + mbQueueReDraw = true; break; } case APP_CMD_WINDOW_RESIZED: @@ -176,13 +178,13 @@ void AndroidSalInstance::onAppCmd (struct android_app* app, int32_t cmd) fprintf (stderr, "app window resized to ! %p %dx%x (%d)\n", pWindow, aRect.right, aRect.bottom, ANativeWindow_getFormat(pWindow)); - RedrawWindows(pWindow); + mbQueueReDraw = true; break; } case APP_CMD_WINDOW_REDRAW_NEEDED: { - RedrawWindows(pWindow); + mbQueueReDraw = true; break; } @@ -259,6 +261,8 @@ extern "C" { AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex ) : SvpSalInstance( pMutex ) + , mpApp( NULL ) + , mbQueueReDraw( false ) { mpApp = lo_get_app(); fprintf (stderr, "created Android Sal Instance for app %p window %p\n", @@ -297,8 +301,12 @@ void AndroidSalInstance::DoReleaseYield (int nTimeoutMS) fprintf (stderr, "DoReleaseYield #2 %d ms\n", nTimeoutMS); void *outData = NULL; int outFd = 0, outEvents = 0; + + if (mbQueueReDraw) + nTimeoutMS = 0; + int nRet = ALooper_pollAll(nTimeoutMS, &outFd, &outEvents, &outData); - fprintf (stderr, "ret %d %d %d %p\n", nRet, outFd, outEvents, outData); + fprintf (stderr, "ret #3 %d %d %d %p\n", nRet, outFd, outEvents, outData); // acquire yield mutex again AcquireYieldMutex(nAcquireCount); @@ -307,8 +315,10 @@ void AndroidSalInstance::DoReleaseYield (int nTimeoutMS) // set a callback in the native app glue's ALooper_addFd ? if (nRet == LOOPER_ID_MAIN) mpApp->cmdPollSource.process(mpApp, &mpApp->cmdPollSource); - if (nRet == LOOPER_ID_INPUT) + else if (nRet == LOOPER_ID_INPUT) mpApp->inputPollSource.process(mpApp, &mpApp->inputPollSource); + else if (mbQueueReDraw) + RedrawWindows (mpApp->window); } bool AndroidSalInstance::AnyInput( sal_uInt16 nType ) diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx index aec273553df9..e39f1478c4bc 100644 --- a/vcl/inc/android/androidinst.hxx +++ b/vcl/inc/android/androidinst.hxx @@ -57,6 +57,7 @@ public: protected: virtual void DoReleaseYield( int nTimeoutMS ); struct android_app *mpApp; + bool mbQueueReDraw; }; #endif // ANDROID_SALINST_H |