Index: tools/viewer/sk_app/android/surface_glue_android.cpp |
diff --git a/tools/viewer/sk_app/android/surface_glue_android.cpp b/tools/viewer/sk_app/android/surface_glue_android.cpp |
index daf26a3852ed2c6275816f4756829dc2d06a0567..acdd78f79418d7576ea5b4e0f92345613484f358 100644 |
--- a/tools/viewer/sk_app/android/surface_glue_android.cpp |
+++ b/tools/viewer/sk_app/android/surface_glue_android.cpp |
@@ -22,6 +22,7 @@ |
#include "SkTypes.h" |
#include "SkUtils.h" |
#include "Window_android.h" |
+#include "Timer.h" |
scroggo
2016/06/03 19:11:06
I think you just use SkTIme, which is defined in S
liyuqian
2016/06/06 13:38:27
Done.
|
namespace sk_app { |
@@ -160,6 +161,8 @@ int SkiaAndroidApp::message_callback(int fd, int events, void* data) { |
return 1; // continue receiving callbacks |
} |
+static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
scroggo
2016/06/03 19:11:06
Why not call SkTime::GetMSecs()?
And while we're
liyuqian
2016/06/06 13:38:27
Done.
|
+ |
void* SkiaAndroidApp::pthread_main(void* arg) { |
SkDebugf("pthread_main begins"); |
@@ -173,16 +176,27 @@ void* SkiaAndroidApp::pthread_main(void* arg) { |
ALooper_addFd(looper, skiaAndroidApp->fPipes[0], LOOPER_ID_MESSAGEPIPE, ALOOPER_EVENT_INPUT, |
message_callback, skiaAndroidApp); |
- int ident; |
- int events; |
- struct android_poll_source* source; |
- |
skiaAndroidApp->fApp = Application::Create(0, nullptr, skiaAndroidApp); |
- while ((ident = ALooper_pollAll(-1, nullptr, &events, (void**)&source)) >= 0) { |
- SkDebugf("ALooper_pollAll ident=%d", ident); |
+ double currentTime = 0.0; |
+ double previousTime = 0.0; |
+ while (true) { |
+ int ident; |
scroggo
2016/06/03 19:11:06
It's easier to follow (and less error-prone) if yo
liyuqian
2016/06/06 13:38:27
Done.
|
+ int events; |
+ struct android_poll_source* source; |
scroggo
2016/06/03 19:11:06
You don't use either of these variables. Will ALoo
liyuqian
2016/06/06 13:38:27
Unfortunately, the Android developer document does
scroggo
2016/06/06 14:17:00
I suppose their implementation could vary based on
|
+ ident = ALooper_pollAll(0, nullptr, &events, (void**)&source); |
+ |
+ if (ident >= 0) { |
+ SkDebugf("Unhandled ALooper_pollAll ident=%d !", ident); |
+ } else { |
+ previousTime = currentTime; |
+ currentTime = now_ms(); |
+ skiaAndroidApp->fApp->onIdle(currentTime - previousTime); |
+ } |
} |
+ SkDebugf("pthread_main ends"); |
+ |
return nullptr; |
} |