annotate Android/jni/mbfly.cpp @ 1456:894a4bf35fe6

Start implement FSM editor window
author Thinker K.F. Li <thinker@codemud.net>
date Sat, 16 Apr 2011 19:41:12 +0800
parents 0d9f1f4d3154
children
rev   line source
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #include <SkCanvas.h>
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #define DECL_C extern "C" {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 #define END_C }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 DECL_C
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 #include <stdio.h>
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 #include <mb.h>
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 #include <jni.h>
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11
516
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
12 #define ASSERT(x)
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
13
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
14
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
15 extern mbe_t *skia_mbe_create_by_canvas(SkCanvas *canvas);
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 jint Java_org_madbutterfly__1jni_redraw_1man_1new(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
18 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 jobject cr,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 jobject backend) {
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
21 jclass canvas_cls;
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 jfieldID fid;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 SkCanvas *_cr, *_backend;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 redraw_man_t *rdman;
516
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
25 mbe_t *mbe1, *mbe2;
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
27 canvas_cls = env->GetObjectClass(cr);
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
28 fid = env->GetFieldID(canvas_cls, "mNativeCanvas", "I");
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 _cr = (SkCanvas *)env->GetIntField(cr, fid);
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
30 canvas_cls = env->GetObjectClass(backend);
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
31 fid = env->GetFieldID(canvas_cls, "mNativeCanvas", "I");
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 _backend = (SkCanvas *)env->GetIntField(backend, fid);
516
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
33
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
34 mbe1 = skia_mbe_create_by_canvas(_cr);
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
35 mbe2 = skia_mbe_create_by_canvas(_backend);
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
36 ASSERT(mbe1 != NULL && mbe2 != NULL);
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
37
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t));
516
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
39 ASSERT(rdman != NULL);
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
40 redraw_man_init(rdman, mbe1, mbe2);
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
41
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42 return (jint)rdman;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 void Java_org_madbutterfly__1jni_redraw_1man_1free(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
46 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 jint rdman) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 redraw_man_destroy((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 free((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 jint Java_org_madbutterfly__1jni_rdman_1add_1shape(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
53 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 jint shape,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 jint r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 r = rdman_add_shape((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60 (shape_t *)shape,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 return r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65 jint Java_org_madbutterfly__1jni_rdman_1get_1root(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
66 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 jint rdman) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 jint root;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
70 root = (jint)rdman_get_root((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 return root;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
72 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
73
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
74 jint Java_org_madbutterfly__1jni_rdman_1redraw_1all(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
75 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76 jint rdman) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 jint r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79 r = rdman_redraw_all((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 return r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
81 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
82
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
83 void Java_org_madbutterfly__1jni_rdman_1paint_1fill(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
84 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 jint paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 rdman_paint_fill((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 (paint_t *)paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90 (shape_t *)shape);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
91 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
92
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
93 void Java_org_madbutterfly__1jni_rdman_1paint_1stroke(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
94 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
95 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 jint paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
98 rdman_paint_stroke((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
99 (paint_t *)paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
100 (shape_t *)shape);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
101 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
102
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
103 jint Java_org_madbutterfly__1jni_rdman_1coord_1new(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
104 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
105 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
106 jint parent) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
107 jint coord;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
108
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
109 coord = (jint)rdman_coord_new((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
110 (coord_t *)parent);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
111 return coord;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
112 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
113
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
114 void Java_org_madbutterfly__1jni_rdman_1coord_1free(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
115 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
116 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
117 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
118 rdman_coord_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
119 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
120 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
121
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122 void Java_org_madbutterfly__1jni_rdman_1coord_1subtree_1free(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
123 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
124 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
125 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
126 rdman_coord_subtree_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
129
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
130 void Java_org_madbutterfly__1jni_rdman_1coord_1changed(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
131 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
132 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
133 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
134 rdman_coord_changed((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
135 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
136 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
137
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
138 void Java_org_madbutterfly__1jni_rdman_1shape_1changed(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
139 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
140 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
141 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
142 rdman_shape_changed((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
143 (shape_t *)shape);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
144 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
145
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
146 void Java_org_madbutterfly__1jni_rdman_1shape_1free(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
147 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
148 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
149 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
150 rdman_shape_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
151 (shape_t *)shape);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
152 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
153
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
154 jint Java_org_madbutterfly__1jni_rdman_1shape_1path_1new(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
155 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
156 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
157 jstring data) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
158 const char *str;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
159 jint shape;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
160
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
161 str = env->GetStringUTFChars(data, NULL);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
162 shape = (jint)rdman_shape_path_new((redraw_man_t *)rdman, (char *)str);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
163 env->ReleaseStringUTFChars(data, str);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
164
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
165 return shape;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
166 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
167
516
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
168 void Java_org_madbutterfly__1jni_sh_1set_1stroke_1width(JNIEnv *env,
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
169 jobject cls,
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
170 jint shape,
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
171 jfloat w) {
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
172 sh_set_stroke_width((shape_t *)shape, w);
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
173 }
0d9f1f4d3154 set stroke width for a shape.
Thinker K.F. Li <thinker@branda.to>
parents: 502
diff changeset
174
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
175 jint Java_org_madbutterfly__1jni_rdman_1paint_1color_1new(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
176 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
177 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
178 jfloat r, jfloat g,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
179 jfloat b, jfloat a) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
180 jint paint;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
181
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
182 paint = (jint)rdman_paint_color_new((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
183 r, g, b, a);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
184 return paint;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
185 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
186
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
187 jint Java_org_madbutterfly__1jni_rdman_1paint_1free(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
188 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
189 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
190 jint paint) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
191 jint r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
192
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
193 r = rdman_paint_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
194 (paint_t *)paint);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
195 return r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
196 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
197
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
198 void Java_org_madbutterfly__1jni_paint_1color_1set(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
199 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
200 jint paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
201 jfloat r, jfloat g,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
202 jfloat b, jfloat a) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
203 paint_color_set((paint_t *)paint, r, g, b, a);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
204 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
205
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
206 jfloatArray Java_org_madbutterfly__1jni_paint_1color_1get(JNIEnv *env,
502
a53fc3eff8f1 Every static native method has the 2rd argument as class object.
Thinker K.F. Li <thinker@branda.to>
parents: 496
diff changeset
207 jobject cls,
496
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
208 jint paint) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
209 co_comp_t r, g, b, a;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
210 jfloat color[4];
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
211 jfloatArray result;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
212
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
213 paint_color_get((paint_t *)paint, &r, &g, &b, &a);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
214 color[0] = r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
215 color[1] = g;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
216 color[2] = b;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
217 color[3] = a;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
218
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
219 result = env->NewFloatArray(4);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
220 env->SetFloatArrayRegion(result, 0, 4, color);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
221
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
222 return result;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
223 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
224
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
225 END_C
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
226