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 public static void init() { | |
25 try { | |
26 System.loadLibrary("skia_android"); | |
27 System.loadLibrary("canvasproof"); | |
28 } catch (java.lang.Error e) { | |
29 Log.v(TAG, "System.loadLibrary error", e); | |
30 } | |
31 } | |
32 | |
33 public static long create(InputStream inputStream) throws IOException { | |
34 byte[] buffer = new byte[16384]; | |
35 long p = 0; | |
36 try { | |
37 p = CreateSkiaPicture.createImpl(inputStream, buffer); | |
38 } catch (UnsatisfiedLinkError e) { | |
39 Log.e(TAG, "UnsatisfiedLinkError createImpl"); | |
40 } | |
41 inputStream.close(); | |
42 return p; | |
43 } | |
44 public static void delete(long ptr) { | |
djsollen
2015/08/24 12:42:56
spaces between java methods.
hal.canary
2015/08/31 21:16:55
Done.
| |
45 try { | |
46 if (ptr != 0) { | |
47 CreateSkiaPicture.deleteImpl(ptr); | |
48 } | |
49 } catch (UnsatisfiedLinkError e) { | |
50 Log.e(TAG, "UnsatisfiedLinkError deleteImpl"); | |
51 } | |
52 | |
53 } | |
54 public static native void deleteImpl(long ptr); | |
55 private static native long createImpl(InputStream s, byte[] b); | |
56 } | |
OLD | NEW |