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

Unified Diff: tools/vulkan/android/main_android.cpp

Issue 1903253003: VulkanViewer on Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gyp Created 4 years, 8 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 | « tools/vulkan/android/Window_android.cpp ('k') | tools/vulkan/viewer/GMSlide.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/vulkan/android/main_android.cpp
diff --git a/tools/vulkan/android/main_android.cpp b/tools/vulkan/android/main_android.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..783cd1f7835f96749a61a182adda0e11a6c12ee7
--- /dev/null
+++ b/tools/vulkan/android/main_android.cpp
@@ -0,0 +1,67 @@
+/*
+* Copyright 2016 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
+
+#include <jni.h>
+#include <errno.h>
+
+#include <android_native_app_glue.h>
+
+#include "../Application.h"
+#include "Timer.h"
+
+static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
+
+/**
+ * This is the main entry point of a native application that is using
+ * android_native_app_glue. It runs in its own thread, with its own
+ * event loop for receiving input events and doing other things.
+ */
+void android_main(struct android_app* state) {
+ // Make sure glue isn't stripped.
+ app_dummy();
+
+ static const char* gCmdLine[] = {
+ "vulkanviewer",
+ "--skps",
+ "/data/local/tmp/skp",
+ };
+
+ std::unique_ptr<Application> vkApp(Application::Create(SK_ARRAY_COUNT(gCmdLine),
+ const_cast<char**>(gCmdLine),
+ state));
+
+ double currentTime = 0.0;
+ double previousTime = 0.0;
+
+ // loop waiting for stuff to do.
+ while (1) {
+ // Read all pending events.
+ int ident;
+ int events;
+ struct android_poll_source* source;
+
+ // block forever waiting for events.
+ while ((ident=ALooper_pollAll(-1, NULL, &events,
+ (void**)&source)) >= 0) {
+
+ // Process this event.
+ if (source != NULL) {
+ source->process(state, source);
+ }
+
+ // Check if we are exiting.
+ if (state->destroyRequested != 0) {
+ return;
+ }
+
+ previousTime = currentTime;
+ currentTime = now_ms();
+ vkApp->onIdle(currentTime - previousTime);
+ }
+ }
+}
+//END_INCLUDE(all)
« no previous file with comments | « tools/vulkan/android/Window_android.cpp ('k') | tools/vulkan/viewer/GMSlide.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698