496
|
1 #include <SkCanvas.h>
|
|
2
|
|
3 #define DECL_C extern "C" {
|
|
4 #define END_C }
|
|
5
|
|
6 DECL_C
|
|
7
|
|
8 #include <stdio.h>
|
|
9 #include <mb.h>
|
|
10 #include <jni.h>
|
|
11
|
|
12
|
|
13 jint Java_org_madbutterfly__1jni_redraw_1man_1new(JNIEnv *env,
|
|
14 jobject cr,
|
|
15 jobject backend) {
|
|
16 jclass cls;
|
|
17 jfieldID fid;
|
|
18 SkCanvas *_cr, *_backend;
|
|
19 redraw_man_t *rdman;
|
|
20
|
|
21 cls = env->GetObjectClass(cr);
|
|
22 fid = env->GetFieldID(cls, "mNativeCanvas", "I");
|
|
23 _cr = (SkCanvas *)env->GetIntField(cr, fid);
|
|
24 _backend = (SkCanvas *)env->GetIntField(backend, fid);
|
|
25 rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t));
|
|
26 redraw_man_init(rdman, (mbe_t *)_cr, (mbe_t *)_backend);
|
|
27
|
|
28 return (jint)rdman;
|
|
29 }
|
|
30
|
|
31 void Java_org_madbutterfly__1jni_redraw_1man_1free(JNIEnv *env,
|
|
32 jint rdman) {
|
|
33 redraw_man_destroy((redraw_man_t *)rdman);
|
|
34 free((redraw_man_t *)rdman);
|
|
35 }
|
|
36
|
|
37 jint Java_org_madbutterfly__1jni_rdman_1add_1shape(JNIEnv *env,
|
|
38 jint rdman,
|
|
39 jint shape,
|
|
40 jint coord) {
|
|
41 jint r;
|
|
42
|
|
43 r = rdman_add_shape((redraw_man_t *)rdman,
|
|
44 (shape_t *)shape,
|
|
45 (coord_t *)coord);
|
|
46 return r;
|
|
47 }
|
|
48
|
|
49 jint Java_org_madbutterfly__1jni_rdman_1get_1root(JNIEnv *env,
|
|
50 jint rdman) {
|
|
51 jint root;
|
|
52
|
|
53 root = (jint)rdman_get_root((redraw_man_t *)rdman);
|
|
54 return root;
|
|
55 }
|
|
56
|
|
57 jint Java_org_madbutterfly__1jni_rdman_1redraw_1all(JNIEnv *env,
|
|
58 jint rdman) {
|
|
59 jint r;
|
|
60
|
|
61 r = rdman_redraw_all((redraw_man_t *)rdman);
|
|
62 return r;
|
|
63 }
|
|
64
|
|
65 void Java_org_madbutterfly__1jni_rdman_1paint_1fill(JNIEnv *env,
|
|
66 jint rdman,
|
|
67 jint paint,
|
|
68 jint shape) {
|
|
69 rdman_paint_fill((redraw_man_t *)rdman,
|
|
70 (paint_t *)paint,
|
|
71 (shape_t *)shape);
|
|
72 }
|
|
73
|
|
74 void Java_org_madbutterfly__1jni_rdman_1paint_1stroke(JNIEnv *env,
|
|
75 jint rdman,
|
|
76 jint paint,
|
|
77 jint shape) {
|
|
78 rdman_paint_stroke((redraw_man_t *)rdman,
|
|
79 (paint_t *)paint,
|
|
80 (shape_t *)shape);
|
|
81 }
|
|
82
|
|
83 jint Java_org_madbutterfly__1jni_rdman_1coord_1new(JNIEnv *env,
|
|
84 jint rdman,
|
|
85 jint parent) {
|
|
86 jint coord;
|
|
87
|
|
88 coord = (jint)rdman_coord_new((redraw_man_t *)rdman,
|
|
89 (coord_t *)parent);
|
|
90 return coord;
|
|
91 }
|
|
92
|
|
93 void Java_org_madbutterfly__1jni_rdman_1coord_1free(JNIEnv *env,
|
|
94 jint rdman,
|
|
95 jint coord) {
|
|
96 rdman_coord_free((redraw_man_t *)rdman,
|
|
97 (coord_t *)coord);
|
|
98 }
|
|
99
|
|
100 void Java_org_madbutterfly__1jni_rdman_1coord_1subtree_1free(JNIEnv *env,
|
|
101 jint rdman,
|
|
102 jint coord) {
|
|
103 rdman_coord_subtree_free((redraw_man_t *)rdman,
|
|
104 (coord_t *)coord);
|
|
105 }
|
|
106
|
|
107 void Java_org_madbutterfly__1jni_rdman_1coord_1changed(JNIEnv *env,
|
|
108 jint rdman,
|
|
109 jint coord) {
|
|
110 rdman_coord_changed((redraw_man_t *)rdman,
|
|
111 (coord_t *)coord);
|
|
112 }
|
|
113
|
|
114 void Java_org_madbutterfly__1jni_rdman_1shape_1changed(JNIEnv *env,
|
|
115 jint rdman,
|
|
116 jint shape) {
|
|
117 rdman_shape_changed((redraw_man_t *)rdman,
|
|
118 (shape_t *)shape);
|
|
119 }
|
|
120
|
|
121 void Java_org_madbutterfly__1jni_rdman_1shape_1free(JNIEnv *env,
|
|
122 jint rdman,
|
|
123 jint shape) {
|
|
124 rdman_shape_free((redraw_man_t *)rdman,
|
|
125 (shape_t *)shape);
|
|
126 }
|
|
127
|
|
128 jint Java_org_madbutterfly__1jni_rdman_1shape_1path_1new(JNIEnv *env,
|
|
129 jint rdman,
|
|
130 jstring data) {
|
|
131 const char *str;
|
|
132 jint shape;
|
|
133
|
|
134 str = env->GetStringUTFChars(data, NULL);
|
|
135 shape = (jint)rdman_shape_path_new((redraw_man_t *)rdman, (char *)str);
|
|
136 env->ReleaseStringUTFChars(data, str);
|
|
137
|
|
138 return shape;
|
|
139 }
|
|
140
|
|
141 jint Java_org_madbutterfly__1jni_rdman_1paint_1color_1new(JNIEnv *env,
|
|
142 jint rdman,
|
|
143 jfloat r, jfloat g,
|
|
144 jfloat b, jfloat a) {
|
|
145 jint paint;
|
|
146
|
|
147 paint = (jint)rdman_paint_color_new((redraw_man_t *)rdman,
|
|
148 r, g, b, a);
|
|
149 return paint;
|
|
150 }
|
|
151
|
|
152 jint Java_org_madbutterfly__1jni_rdman_1paint_1free(JNIEnv *env,
|
|
153 jint rdman,
|
|
154 jint paint) {
|
|
155 jint r;
|
|
156
|
|
157 r = rdman_paint_free((redraw_man_t *)rdman,
|
|
158 (paint_t *)paint);
|
|
159 return r;
|
|
160 }
|
|
161
|
|
162 void Java_org_madbutterfly__1jni_paint_1color_1set(JNIEnv *env,
|
|
163 jint paint,
|
|
164 jfloat r, jfloat g,
|
|
165 jfloat b, jfloat a) {
|
|
166 paint_color_set((paint_t *)paint, r, g, b, a);
|
|
167 }
|
|
168
|
|
169 jfloatArray Java_org_madbutterfly__1jni_paint_1color_1get(JNIEnv *env,
|
|
170 jint paint) {
|
|
171 co_comp_t r, g, b, a;
|
|
172 jfloat color[4];
|
|
173 jfloatArray result;
|
|
174
|
|
175 paint_color_get((paint_t *)paint, &r, &g, &b, &a);
|
|
176 color[0] = r;
|
|
177 color[1] = g;
|
|
178 color[2] = b;
|
|
179 color[3] = a;
|
|
180
|
|
181 result = env->NewFloatArray(4);
|
|
182 env->SetFloatArrayRegion(result, 0, 4, color);
|
|
183
|
|
184 return result;
|
|
185 }
|
|
186
|
|
187 END_C
|
|
188
|