annotate Android/jni/mbfly.cpp @ 496:71ad34f73a6e Android_Skia

JNI interface for Android
author Thinker K.F. Li <thinker@branda.to>
date Thu, 26 Nov 2009 15:03:01 +0800
parents
children a53fc3eff8f1
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
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13 jint Java_org_madbutterfly__1jni_redraw_1man_1new(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 jobject cr,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15 jobject backend) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 jclass cls;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 jfieldID fid;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 SkCanvas *_cr, *_backend;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 redraw_man_t *rdman;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 cls = env->GetObjectClass(cr);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 fid = env->GetFieldID(cls, "mNativeCanvas", "I");
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 _cr = (SkCanvas *)env->GetIntField(cr, fid);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 _backend = (SkCanvas *)env->GetIntField(backend, fid);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t));
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 redraw_man_init(rdman, (mbe_t *)_cr, (mbe_t *)_backend);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 return (jint)rdman;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 void Java_org_madbutterfly__1jni_redraw_1man_1free(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 jint rdman) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 redraw_man_destroy((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 free((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 jint Java_org_madbutterfly__1jni_rdman_1add_1shape(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 jint shape,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 jint r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 r = rdman_add_shape((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 (shape_t *)shape,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 return r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 jint Java_org_madbutterfly__1jni_rdman_1get_1root(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 jint rdman) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 jint root;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 root = (jint)rdman_get_root((redraw_man_t *)rdman);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 return root;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 jint Java_org_madbutterfly__1jni_rdman_1redraw_1all(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 jint rdman) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 jint r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 r = rdman_redraw_all((redraw_man_t *)rdman);
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 void Java_org_madbutterfly__1jni_rdman_1paint_1fill(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
66 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 jint paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69 rdman_paint_fill((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
70 (paint_t *)paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 (shape_t *)shape);
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 void Java_org_madbutterfly__1jni_rdman_1paint_1stroke(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
75 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76 jint paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78 rdman_paint_stroke((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79 (paint_t *)paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 (shape_t *)shape);
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 jint Java_org_madbutterfly__1jni_rdman_1coord_1new(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 jint parent) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 jint coord;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 coord = (jint)rdman_coord_new((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 (coord_t *)parent);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90 return coord;
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_1coord_1free(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
94 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
95 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 rdman_coord_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
98 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
99
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
100 void Java_org_madbutterfly__1jni_rdman_1coord_1subtree_1free(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
101 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
102 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
103 rdman_coord_subtree_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
104 (coord_t *)coord);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
105 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
106
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
107 void Java_org_madbutterfly__1jni_rdman_1coord_1changed(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
108 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
109 jint coord) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
110 rdman_coord_changed((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
111 (coord_t *)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_1shape_1changed(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
115 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
116 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
117 rdman_shape_changed((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
118 (shape_t *)shape);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
119 }
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 void Java_org_madbutterfly__1jni_rdman_1shape_1free(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
123 jint shape) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
124 rdman_shape_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
125 (shape_t *)shape);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
126 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 jint Java_org_madbutterfly__1jni_rdman_1shape_1path_1new(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
129 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
130 jstring data) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
131 const char *str;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
132 jint shape;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
133
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
134 str = env->GetStringUTFChars(data, NULL);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
135 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
136 env->ReleaseStringUTFChars(data, str);
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 return shape;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
139 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
140
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
141 jint Java_org_madbutterfly__1jni_rdman_1paint_1color_1new(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
142 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
143 jfloat r, jfloat g,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
144 jfloat b, jfloat a) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
145 jint paint;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
146
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
147 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
148 r, g, b, a);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
149 return paint;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
150 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
151
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
152 jint Java_org_madbutterfly__1jni_rdman_1paint_1free(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
153 jint rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
154 jint paint) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
155 jint r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
156
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
157 r = rdman_paint_free((redraw_man_t *)rdman,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
158 (paint_t *)paint);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
159 return r;
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
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
162 void Java_org_madbutterfly__1jni_paint_1color_1set(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
163 jint paint,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
164 jfloat r, jfloat g,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
165 jfloat b, jfloat a) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
166 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
167 }
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
168
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
169 jfloatArray Java_org_madbutterfly__1jni_paint_1color_1get(JNIEnv *env,
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
170 jint paint) {
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
171 co_comp_t r, g, b, a;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
172 jfloat color[4];
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
173 jfloatArray result;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
174
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
175 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
176 color[0] = r;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
177 color[1] = g;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
178 color[2] = b;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
179 color[3] = a;
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
180
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
181 result = env->NewFloatArray(4);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
182 env->SetFloatArrayRegion(result, 0, 4, color);
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
183
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
184 return result;
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 END_C
71ad34f73a6e JNI interface for Android
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
188