comparison dox/Android.h @ 484:5af3178ccdef Android_Skia

Document integration of MadButterfly and Android.
author Thinker K.F. Li <thinker@branda.to>
date Sat, 21 Nov 2009 22:57:26 +0800
parents
children 80b8f0a4aeb9
comparison
equal deleted inserted replaced
483:d984a6672be7 484:5af3178ccdef
1 /*! \page android Integrate MadButterfly with Android
2 *
3 * I think almost all technical guys know Android, the mobile OS
4 * project from Google. Once I know Android, my first idea is it is
5 * cool if Android programmers can be powered by MadButterfly.
6 * MadButterfly is very feasible for a lof of programs running on
7 * devices that Android targets for. This document is about how the
8 * MadButterfly been integrated with Android and power Android
9 * applications.
10 *
11 * \section android_jni Android Native Code
12 *
13 * Android applications are actually Java code running on Dalvik VM.
14 * Although, Java bytecode was translated into bytecode of Dalvik.
15 * The interface of bytecode running in VM and native code is JNI,
16 * just like Java. So, we must implement a set of API on JNI as the
17 * channel for communication between Android applications and
18 * MadButterfly. Following image is how the MadButterfly integrated
19 * with the Android.
20 *
21 * \image html Android-int.png
22 *
23 * MB JNI is JNI part of MadButterfly for interaction between
24 * Madbufferfly and Android applications. Android applications draw
25 * everything on Canvases (backed by a surface). A canvas is actually
26 * bridge to a SkCanvas provided by Skia. So, MadButterfly can draw
27 * on the SkCanvas for drawing on screen.
28 *
29 * The idea is to make MadButterfly as a View of Android UI.
30 * SurfaceView is extended as MBView; the type of view for
31 * MadButterfly. The SurfaceView own a surface. The surface is
32 * passed to MadButterfly as a SurfaceHolder. MB JNI get Canvas from
33 * the SurfaceHolder, and get SkCanvas of Canvas in turn. With
34 * SkCanvas, MadButterfly can draw on the screen for the MBView
35 * object.
36 *
37 * \section android_mem Memory Management for Android JNI Interface
38 *
39 * Some memory allocated and returned by MadButterfly should be
40 * managed by the application. A memory block should not be freed
41 * until it is no more used by MadButterfly engine. It means Android
42 * applications reponsible for managing memory blocks. To simplify
43 * implmentation of MB JNI, MB JNI always return the address of an
44 * allocated objects as a Java integer. The Java part should take
45 * care about these addresses, and call proper functions for freeing
46 * objects specified by addresses.
47 *
48 * A Java side framework should be designed to easy the work of
49 * Android application programmers. The framework should take care
50 * the tracing life-cycle of MadButterfly objects. The namespace of
51 * the framework should be 'org.madbutterfly'.
52 *
53 */