changeset 518:3a7bce43ec6e Android_Skia

Android native code with MB
author Thinker K.F. Li <thinker@branda.to>
date Tue, 01 Dec 2009 22:55:27 +0800
parents 82c1ea2ba929
children 7a1b17ebb3b4
files Android/examples/native_test/Android.mk Android/examples/native_test/native_test.cpp
diffstat 2 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Android/examples/native_test/Android.mk	Tue Dec 01 22:55:27 2009 +0800
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := native_test
+LOCAL_STATIC_LIBRARIES := libmbfly
+LOCAL_SHARED_LIBRARIES := libsgl
+LOCAL_C_INCLUDES += $(call include-path-for,corecg) \
+	$(TARGET_OUT_HEADERS)/libmbfly
+LOCAL_SRC_FILES := native_test.cpp
+
+include $(BUILD_EXECUTABLE)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Android/examples/native_test/native_test.cpp	Tue Dec 01 22:55:27 2009 +0800
@@ -0,0 +1,44 @@
+#include <SkCanvas.h>
+#include <SkBitmap.h>
+
+extern "C" {
+#include <mb.h>
+};
+
+void native_test(void) {
+    mbe_t *mbe1, *mbe2;
+    SkBitmap *bmap1, *bmap2;
+    redraw_man_t _rdman;
+    redraw_man_t *rdman = &_rdman;
+    coord_t *root;
+    shape_t *shape;
+    paint_t *paint;
+
+    bmap1 = new SkBitmap();
+    bmap1->setConfig(SkBitmap::kARGB_8888_Config, 300, 300);
+    mbe1 = mbe_create((mbe_surface_t *)bmap1);
+    bmap2 = new SkBitmap();
+    bmap2->setConfig(SkBitmap::kARGB_8888_Config, 300, 300);
+    mbe2 = mbe_create((mbe_surface_t *)bmap2);
+
+    redraw_man_init(rdman, mbe1, mbe2);
+    root = rdman_get_root(rdman);
+    shape = rdman_shape_path_new(rdman, "M 100 100 L 100 150 L 150 150 z");
+    paint = rdman_paint_color_new(rdman, 1, 0, 0, 1);
+    rdman_paint_stroke(rdman, paint, shape);
+    rdman_add_shape(rdman, shape, root);
+
+    rdman_shape_changed(rdman, shape);
+    rdman_paint_changed(rdman, paint);
+
+    rdman_redraw_all(rdman);
+
+    rdman_paint_free(rdman, paint);
+    rdman_shape_free(rdman, shape);
+    redraw_man_destroy(rdman);
+}
+
+int main(int argc, const char *argv[]) {
+    native_test();
+    return 0;
+}