changeset 516:0d9f1f4d3154 Android_Skia

set stroke width for a shape. It also modify procedure of creating a redraw_man.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 01 Dec 2009 22:55:27 +0800
parents ccc6bdc7e5a0
children 82c1ea2ba929
files Android/jni/Android.mk Android/jni/mbfly.cpp
diffstat 2 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Android/jni/Android.mk	Tue Dec 01 22:55:27 2009 +0800
+++ b/Android/jni/Android.mk	Tue Dec 01 22:55:27 2009 +0800
@@ -4,7 +4,7 @@
 
 LOCAL_MODULE := libmbfly-jni
 LOCAL_SRC_FILES := mbfly.cpp
-LOCAL_SHARED_LIBRARIES := libcorecg libsgl libnativehelper
+LOCAL_SHARED_LIBRARIES := libcorecg libsgl libnativehelper libcutils
 LOCAL_STATIC_LIBRARIES := libmbfly
 LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libmbfly \
 	$(call include-path-for,corecg) \
--- a/Android/jni/mbfly.cpp	Tue Dec 01 22:55:27 2009 +0800
+++ b/Android/jni/mbfly.cpp	Tue Dec 01 22:55:27 2009 +0800
@@ -9,6 +9,10 @@
 #include <mb.h>
 #include <jni.h>
 
+#define ASSERT(x)
+
+
+extern mbe_t *skia_mbe_create_by_canvas(SkCanvas *canvas);
 
 jint Java_org_madbutterfly__1jni_redraw_1man_1new(JNIEnv *env,
 						  jobject cls,
@@ -18,6 +22,7 @@
     jfieldID fid;
     SkCanvas *_cr, *_backend;
     redraw_man_t *rdman;
+    mbe_t *mbe1, *mbe2;
     
     canvas_cls = env->GetObjectClass(cr);
     fid = env->GetFieldID(canvas_cls, "mNativeCanvas", "I");
@@ -25,9 +30,15 @@
     canvas_cls = env->GetObjectClass(backend);
     fid = env->GetFieldID(canvas_cls, "mNativeCanvas", "I");
     _backend = (SkCanvas *)env->GetIntField(backend, fid);
+
+    mbe1 = skia_mbe_create_by_canvas(_cr);
+    mbe2 = skia_mbe_create_by_canvas(_backend);
+    ASSERT(mbe1 != NULL && mbe2 != NULL);
+    
     rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t));
-    redraw_man_init(rdman, (mbe_t *)_cr, (mbe_t *)_backend);
-
+    ASSERT(rdman != NULL);
+    redraw_man_init(rdman, mbe1, mbe2);
+    
     return (jint)rdman;
 }
 
@@ -154,6 +165,13 @@
     return shape;
 }
 
+void Java_org_madbutterfly__1jni_sh_1set_1stroke_1width(JNIEnv *env,
+							       jobject cls,
+							       jint shape,
+							       jfloat w) {
+    sh_set_stroke_width((shape_t *)shape, w);
+}
+
 jint Java_org_madbutterfly__1jni_rdman_1paint_1color_1new(JNIEnv *env,
 							  jobject cls,
 							  jint rdman,