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