}
JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init(JNIEnv* env,
- jobject thiz, jobject jsampleActivity, jint msaaSampleCount)
+ jobject thiz, jobject jsampleActivity, jstring cmdLineFlags, jint msaaSampleCount)
{
// setup jni hooks to the java activity
gActivityGlue.m_env = env;
env->DeleteLocalRef(clazz);
application_init();
- SkTArray<const char*> args;
- args.push_back("SampleApp");
- // TODO: push ability to select skp dir into the UI
- args.push_back("--pictureDir");
- args.push_back("/sdcard/skiabot/skia_skp");
+ const char* flags = env->GetStringUTFChars(cmdLineFlags, JNI_FALSE);
+ SkTArray<SkString> flagEntries;
+ SkStrSplit(flags, " ", &flagEntries);
- args.push_back("--resourcePath");
- args.push_back("/data/local/tmp/skia/resources/");
+ SkTArray<const char*> args;
+ args.push_back("SampleApp");
+ for (int i = 0; i < flagEntries.count(); i++) {
+ SkDebugf(flagEntries[i].c_str());
+ args.push_back(flagEntries[i].c_str());
+ }
SkString msaaSampleCountString;
if (msaaSampleCount > 0) {
args.push_back(msaaSampleCountString.c_str());
}
- gWindow = new SampleWindow(NULL, args.count(), const_cast<char**>(args.begin()), NULL);
+ if (gWindow) {
+ SkDebugf("The sample window already exists.");
+ } else {
+ gWindow = new SampleWindow(NULL, args.count(), const_cast<char**>(args.begin()), NULL);
+ }
+
+ // cleanup the command line flags
+ env->ReleaseStringUTFChars(cmdLineFlags, flags);
// send the list of slides up to the activity
const int slideCount = gWindow->sampleCount();
/*
* Class: com_skia_SkiaSampleRenderer
* Method: init
- * Signature: (Lcom/skia/SkiaSampleActivity;I)V
+ * Signature: (Lcom/skia/SkiaSampleActivity;Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init
- (JNIEnv *, jobject, jobject, jint);
+ (JNIEnv *, jobject, jobject, jstring, jint);
/*
* Class: com_skia_SkiaSampleRenderer
import android.app.ActionBar;
import android.app.Activity;
import android.app.DownloadManager;
+import android.content.Intent;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
mSampleView.terminate();
}
- mSampleView = new SkiaSampleView(this, useOpenGLAPI, msaaSampleCount);
+ // intent get intent extras if triggered from the command line
+ Intent intent = this.getIntent();
+ String flags = intent.getStringExtra("cmdLineFlags");
+
+ if (flags == null || flags.isEmpty()) {
+ flags = "--pictureDir /data/local/tmp/skia_skp ";
+ flags += "--resourcePath /data/local/tmp/skia_resources ";
+ }
+
+ mSampleView = new SkiaSampleView(this, flags, useOpenGLAPI, msaaSampleCount);
LinearLayout holder = (LinearLayout) findViewById(R.id.holder);
holder.addView(mSampleView, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
private final SkiaSampleView mSampleView;
private Handler mHandler = new Handler();
private int mMSAASampleCount;
+ private String mCmdLineFlags;
- SkiaSampleRenderer(SkiaSampleView view) {
+ SkiaSampleRenderer(SkiaSampleView view, String cmdLineFlags) {
mSampleView = view;
+ mCmdLineFlags = cmdLineFlags;
}
@Override
gl.glClearStencil(0);
gl.glClear(GL10.GL_STENCIL_BUFFER_BIT);
- init((SkiaSampleActivity)mSampleView.getContext(), mMSAASampleCount);
+
+ init((SkiaSampleActivity)mSampleView.getContext(), mCmdLineFlags, mMSAASampleCount);
}
// Called by JNI and the view.
mSampleView.requestRender();
}
- native void init(SkiaSampleActivity activity, int msaaSampleCount);
+ native void init(SkiaSampleActivity activity, String flags, int msaaSampleCount);
native void term();
native void draw();
native void updateSize(int w, int h);
private boolean mRequestedOpenGLAPI; // true == use (desktop) OpenGL. false == use OpenGL ES.
private int mRequestedMSAASampleCount;
- public SkiaSampleView(Context ctx, boolean useOpenGL, int msaaSampleCount) {
+ public SkiaSampleView(Context ctx, String cmdLineFlags, boolean useOpenGL, int msaaSampleCount) {
super(ctx);
- mSampleRenderer = new SkiaSampleRenderer(this);
+ mSampleRenderer = new SkiaSampleRenderer(this, cmdLineFlags);
mRequestedMSAASampleCount = msaaSampleCount;
setEGLContextClientVersion(2);
--- /dev/null
+#!/bin/bash
+#
+# android_launch_app: Launches the skia sampleApp on the device.
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+source $SCRIPT_DIR/android_setup.sh
+source $SCRIPT_DIR/utils/setup_adb.sh
+
+# TODO: check to ensure that the app exists on the device and prompt to install
+
+if [[ -n $RESOURCE_PATH ]]; then
+ adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH
+fi
+
+$ADB ${DEVICE_SERIAL} shell am start -S -n "com.skia/.SkiaSampleActivity" --es "cmdLineFlags" "${APP_ARGS[*]}"
+
if [ -f $HOST_DST ];
then
- #get the MD5 for dst and src
- ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_SRC`
+ #get the MD5 for dst and src depending on OS and/or OS revision
+ ANDROID_MD5_SUPPORT=`$ADB $DEVICE_SERIAL shell ls -ld /system/bin/md5`
+ if [ "${ANDROID_MD5_SUPPORT:0:15}" != "/system/bin/md5" ]; then
+ ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST`
+ else
+ ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5sum $ANDROID_DST`
+ fi
if [ $(uname) == "Darwin" ]; then
HOST_MD5=`md5 -q $HOST_DST`
else
ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST`
if [ "${ANDROID_LS:0:1}" == "-" ]; then
- #get the MD5 for dst and src
- ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST`
+ #get the MD5 for dst and src depending on OS and/or OS revision
+ ANDROID_MD5_SUPPORT=`$ADB $DEVICE_SERIAL shell ls -ld /system/bin/md5`
+ if [ "${ANDROID_MD5_SUPPORT:0:15}" != "/system/bin/md5" ]; then
+ ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST`
+ else
+ ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5sum $ANDROID_DST`
+ fi
+
if [ $(uname) == "Darwin" ]; then
HOST_MD5=`md5 -q $HOST_SRC`
else
./platform_tools/android/bin/android_install_app
-Finally to run the application you must navigate to the Skia Samples
-application using the application launcher on your device.
+Finally to run the application you can either navigate to the Skia Samples
+application using the application launcher on your device or from the command
+line. The command line option allows you to pass additional details to the
+application (similiar to other operating system) that specify where to find
+skp files and other resources.
+
+ ./platform_tools/android/bin/android_launch_app --resourcePath /data/local/tmp/resources
+
+By default if no additional parameters are specified the app will use the default
+params...
+
+ --resourcePath /data/local/tmp/skia_resoures
+ --pictureDir /data/local/tmp/skia_skp
Build tools
-----------