| OLD | NEW |
| 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; } | 16 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
| 17 | 17 |
| 18 using sk_app::Application; |
| 19 |
| 18 /** | 20 /** |
| 19 * This is the main entry point of a native application that is using | 21 * This is the main entry point of a native application that is using |
| 20 * android_native_app_glue. It runs in its own thread, with its own | 22 * android_native_app_glue. It runs in its own thread, with its own |
| 21 * event loop for receiving input events and doing other things. | 23 * event loop for receiving input events and doing other things. |
| 22 */ | 24 */ |
| 23 void android_main(struct android_app* state) { | 25 void android_main(struct android_app* state) { |
| 24 // Make sure glue isn't stripped. | 26 // Make sure glue isn't stripped. |
| 25 app_dummy(); | 27 app_dummy(); |
| 26 | 28 |
| 27 static const char* gCmdLine[] = { | 29 static const char* gCmdLine[] = { |
| 28 "vulkanviewer", | 30 "viewer", |
| 29 "--skps", | 31 "--skps", |
| 30 "/data/local/tmp/skp", | 32 "/data/local/tmp/skp", |
| 31 }; | 33 }; |
| 32 | 34 |
| 33 std::unique_ptr<Application> vkApp(Application::Create(SK_ARRAY_COUNT(gCmdLi
ne), | 35 std::unique_ptr<Application> vkApp(Application::Create(SK_ARRAY_COUNT(gCmdLi
ne), |
| 34 const_cast<char**>(gC
mdLine), | 36 const_cast<char**>(gC
mdLine), |
| 35 state)); | 37 state)); |
| 36 | 38 |
| 37 double currentTime = 0.0; | 39 double currentTime = 0.0; |
| 38 double previousTime = 0.0; | 40 double previousTime = 0.0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 return; | 60 return; |
| 59 } | 61 } |
| 60 | 62 |
| 61 previousTime = currentTime; | 63 previousTime = currentTime; |
| 62 currentTime = now_ms(); | 64 currentTime = now_ms(); |
| 63 vkApp->onIdle(currentTime - previousTime); | 65 vkApp->onIdle(currentTime - previousTime); |
| 64 } | 66 } |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 //END_INCLUDE(all) | 69 //END_INCLUDE(all) |
| OLD | NEW |