OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 /* |
| 8 AJAR=$ANDROID_SDK_ROOT/platforms/android-19/android.jar |
| 9 CLASS=CreateSkiaPicture |
| 10 SRC=platform_tools/android/apps/canvasproof/src/main |
| 11 javac -classpath $AJAR $SRC/java/org/skia/canvasproof/$CLASS.java |
| 12 javah -classpath $AJAR:$SRC/java -d $SRC/jni org.skia.canvasproof.$CLASS |
| 13 */ |
| 14 |
| 15 package org.skia.canvasproof; |
| 16 |
| 17 import android.util.Log; |
| 18 import java.io.IOException; |
| 19 import java.io.InputStream; |
| 20 import java.lang.UnsatisfiedLinkError; |
| 21 |
| 22 public class CreateSkiaPicture { |
| 23 private static final String TAG = "CreateSkiaPicture"; |
| 24 |
| 25 public static void init() { |
| 26 try { |
| 27 System.loadLibrary("skia_android"); |
| 28 System.loadLibrary("canvasproof"); |
| 29 } catch (java.lang.Error e) { |
| 30 Log.v(TAG, "System.loadLibrary error", e); |
| 31 } |
| 32 } |
| 33 |
| 34 public static long create(InputStream inputStream) throws IOException { |
| 35 byte[] buffer = new byte[16 * (1 << 10)]; // 16 KByte |
| 36 long p = 0; |
| 37 try { |
| 38 p = CreateSkiaPicture.createImpl(inputStream, buffer); |
| 39 } catch (UnsatisfiedLinkError e) { |
| 40 Log.e(TAG, "UnsatisfiedLinkError createImpl"); |
| 41 } |
| 42 inputStream.close(); |
| 43 return p; |
| 44 } |
| 45 |
| 46 public static void delete(long ptr) { |
| 47 try { |
| 48 if (ptr != 0) { |
| 49 CreateSkiaPicture.deleteImpl(ptr); |
| 50 } |
| 51 } catch (UnsatisfiedLinkError e) { |
| 52 Log.e(TAG, "UnsatisfiedLinkError deleteImpl"); |
| 53 } |
| 54 |
| 55 } |
| 56 private static native void deleteImpl(long ptr); |
| 57 private static native long createImpl(InputStream s, byte[] b); |
| 58 } |
OLD | NEW |