2016-04-21 14:59:44 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2016-05-04 20:49:13 +00:00
|
|
|
using sk_app::Application;
|
|
|
|
|
2016-04-21 14:59:44 +00:00
|
|
|
/**
|
|
|
|
* 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[] = {
|
2016-05-04 20:49:13 +00:00
|
|
|
"viewer",
|
2016-04-21 14:59:44 +00:00
|
|
|
"--skps",
|
2017-05-26 16:06:21 +00:00
|
|
|
"/data/local/tmp/skps",
|
2016-10-14 13:12:53 +00:00
|
|
|
// TODO: figure out how to use am start with extra params to pass in additional arguments at
|
|
|
|
// runtime
|
|
|
|
// "--atrace",
|
2016-04-21 14:59:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<Application> vkApp(Application::Create(SK_ARRAY_COUNT(gCmdLine),
|
|
|
|
const_cast<char**>(gCmdLine),
|
|
|
|
state));
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2016-07-06 21:11:32 +00:00
|
|
|
vkApp->onIdle();
|
2016-04-21 14:59:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//END_INCLUDE(all)
|