Index: platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java |
diff --git a/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java b/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..61aa14a7b703a67230c425dac63bf4c3bd3d60b1 |
--- /dev/null |
+++ b/platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java |
@@ -0,0 +1,58 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+/* |
+AJAR=$ANDROID_SDK_ROOT/platforms/android-19/android.jar |
+CLASS=CreateSkiaPicture |
+SRC=platform_tools/android/apps/canvasproof/src/main |
+javac -classpath $AJAR $SRC/java/org/skia/canvasproof/$CLASS.java |
+javah -classpath $AJAR:$SRC/java -d $SRC/jni org.skia.canvasproof.$CLASS |
+*/ |
+ |
+package org.skia.canvasproof; |
+ |
+import android.util.Log; |
+import java.io.IOException; |
+import java.io.InputStream; |
+import java.lang.UnsatisfiedLinkError; |
+ |
+public class CreateSkiaPicture { |
+ private static final String TAG = "CreateSkiaPicture"; |
+ |
+ public static void init() { |
+ try { |
+ System.loadLibrary("skia_android"); |
+ System.loadLibrary("canvasproof"); |
+ } catch (java.lang.Error e) { |
+ Log.v(TAG, "System.loadLibrary error", e); |
+ } |
+ } |
+ |
+ public static long create(InputStream inputStream) throws IOException { |
+ byte[] buffer = new byte[16 * (1 << 10)]; // 16 KByte |
+ long p = 0; |
+ try { |
+ p = CreateSkiaPicture.createImpl(inputStream, buffer); |
+ } catch (UnsatisfiedLinkError e) { |
+ Log.e(TAG, "UnsatisfiedLinkError createImpl"); |
+ } |
+ inputStream.close(); |
+ return p; |
+ } |
+ |
+ public static void delete(long ptr) { |
+ try { |
+ if (ptr != 0) { |
+ CreateSkiaPicture.deleteImpl(ptr); |
+ } |
+ } catch (UnsatisfiedLinkError e) { |
+ Log.e(TAG, "UnsatisfiedLinkError deleteImpl"); |
+ } |
+ |
+ } |
+ private static native void deleteImpl(long ptr); |
+ private static native long createImpl(InputStream s, byte[] b); |
+} |