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

Side by Side Diff: tools/viewer/sk_app/android/main_android.cpp

Issue 2129613002: More accurate render time and continuous fresh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove ms argument of onIdle function Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « tools/viewer/sk_app/Application.h ('k') | tools/viewer/sk_app/android/surface_glue_android.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <errno.h> 9 #include <errno.h>
10 10
11 #include <android_native_app_glue.h> 11 #include <android_native_app_glue.h>
12 12
13 #include "../Application.h" 13 #include "../Application.h"
14 #include "Timer.h" 14 #include "Timer.h"
15 15
16 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
17
18 using sk_app::Application; 16 using sk_app::Application;
19 17
20 /** 18 /**
21 * This is the main entry point of a native application that is using 19 * This is the main entry point of a native application that is using
22 * android_native_app_glue. It runs in its own thread, with its own 20 * android_native_app_glue. It runs in its own thread, with its own
23 * event loop for receiving input events and doing other things. 21 * event loop for receiving input events and doing other things.
24 */ 22 */
25 void android_main(struct android_app* state) { 23 void android_main(struct android_app* state) {
26 // Make sure glue isn't stripped. 24 // Make sure glue isn't stripped.
27 app_dummy(); 25 app_dummy();
28 26
29 static const char* gCmdLine[] = { 27 static const char* gCmdLine[] = {
30 "viewer", 28 "viewer",
31 "--skps", 29 "--skps",
32 "/data/local/tmp/skp", 30 "/data/local/tmp/skp",
33 }; 31 };
34 32
35 std::unique_ptr<Application> vkApp(Application::Create(SK_ARRAY_COUNT(gCmdLi ne), 33 std::unique_ptr<Application> vkApp(Application::Create(SK_ARRAY_COUNT(gCmdLi ne),
36 const_cast<char**>(gC mdLine), 34 const_cast<char**>(gC mdLine),
37 state)); 35 state));
38 36
39 double currentTime = 0.0;
40 double previousTime = 0.0;
41
42 // loop waiting for stuff to do. 37 // loop waiting for stuff to do.
43 while (1) { 38 while (1) {
44 // Read all pending events. 39 // Read all pending events.
45 int ident; 40 int ident;
46 int events; 41 int events;
47 struct android_poll_source* source; 42 struct android_poll_source* source;
48 43
49 // block forever waiting for events. 44 // block forever waiting for events.
50 while ((ident=ALooper_pollAll(-1, NULL, &events, 45 while ((ident=ALooper_pollAll(-1, NULL, &events,
51 (void**)&source)) >= 0) { 46 (void**)&source)) >= 0) {
52 47
53 // Process this event. 48 // Process this event.
54 if (source != NULL) { 49 if (source != NULL) {
55 source->process(state, source); 50 source->process(state, source);
56 } 51 }
57 52
58 // Check if we are exiting. 53 // Check if we are exiting.
59 if (state->destroyRequested != 0) { 54 if (state->destroyRequested != 0) {
60 return; 55 return;
61 } 56 }
62 57
63 previousTime = currentTime; 58 vkApp->onIdle();
64 currentTime = now_ms();
65 vkApp->onIdle(currentTime - previousTime);
66 } 59 }
67 } 60 }
68 } 61 }
69 //END_INCLUDE(all) 62 //END_INCLUDE(all)
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/Application.h ('k') | tools/viewer/sk_app/android/surface_glue_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698