Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: tools/viewer/sk_app/android/surface_glue_android.cpp

Issue 2031383002: Allow animation in Android viewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Revision Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1821a53efe3a25d1b073b65bf012fafa0bebc4f2 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 "SkTime.h"
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::GetMSecs(); }
+
void* SkiaAndroidApp::pthread_main(void* arg) {
SkDebugf("pthread_main begins");
@@ -173,16 +176,24 @@ 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) {
+ const int ident = ALooper_pollAll(0, nullptr, nullptr, nullptr);
jvanverth1 2016/06/06 14:18:11 I'm surprised a timeout of 0 doesn't cause a busy
liyuqian 2016/06/06 14:30:46 I checked the CPU usage on Android and it indeed d
+
+ 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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698