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

Unified Diff: platform_tools/android/apps/canvasproof/src/main/java/org/skia/canvasproof/CreateSkiaPicture.java

Issue 1258123004: android/apps: Add CanvasProof App; (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-09-04 (Friday) 13:29:02 EDT Created 5 years, 3 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
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);
+}

Powered by Google App Engine
This is Rietveld 408576698