Mercurial > MadButterfly
comparison dox/Android.h @ 485:80b8f0a4aeb9 Android_Skia
more doc for Android
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 22 Nov 2009 14:18:09 +0800 |
parents | 5af3178ccdef |
children | 64b994566efe |
comparison
equal
deleted
inserted
replaced
484:5af3178ccdef | 485:80b8f0a4aeb9 |
---|---|
48 * A Java side framework should be designed to easy the work of | 48 * A Java side framework should be designed to easy the work of |
49 * Android application programmers. The framework should take care | 49 * Android application programmers. The framework should take care |
50 * the tracing life-cycle of MadButterfly objects. The namespace of | 50 * the tracing life-cycle of MadButterfly objects. The namespace of |
51 * the framework should be 'org.madbutterfly'. | 51 * the framework should be 'org.madbutterfly'. |
52 * | 52 * |
53 * \section android_jni _jni | |
54 * | |
55 * org.madbutterfly._jni class is the placeholder to collect JNI APIs | |
56 * for all MadButterfly functions. All methods of _jni are static. A | |
57 * method usually maps to a MadButterfly function. For example, | |
58 * rdman_coord_new() mapes to a MadButterfly function. | |
59 * | |
60 * The object returned by a MadButterfly function, for | |
61 * ex. rdman_coord_new(), is casted to a int, the address of the | |
62 * object. So, type of an argument or return value of an object is | |
63 * declared as a int. For example, | |
64 * \code | |
65 * class _jni { | |
66 * native static int rdman_coord_new(void); | |
67 * } | |
68 * \endcode | |
69 * Java code should keep these integers carefully for maintaining | |
70 * life-cycle of objects. | |
71 * | |
72 * MadButterfly provides only initial function for some objects, | |
73 * application should allocate memory for these function by them-self. | |
74 * For these function, a new JNI interface are used instead of | |
75 * initiali function. The new JNI interface is responsible for | |
76 * allocating memory and call initial function. For example, | |
77 * redraw_man_new() is defined as a JNI interface instead of | |
78 * redraw_man_init(). | |
79 * \code | |
80 * native static int redraw_man_new(int cr, int backend); | |
81 * \endcode | |
82 * First argument, rdman, of redraw_man_init() is replaced by a int | |
83 * returned value. cr and backend, mbe_t type by MadButterfly, are | |
84 * now int type by JNI interface. | |
85 * | |
86 * \section android_java_mb Java Likes MadButterfly | |
87 * | |
88 * To manage life-cycle for MadButterfly objects is not Java likes. | |
89 * To provie a Java style interface for MadButterfly, a framework to | |
90 * hide underlying life-cycle management is requried. Life-cycle is | |
91 * one major responsibility of the framework, it should keep integers | |
92 * of addresses of objects and free the associated resources with | |
93 * correct JNI methods and at right time. | |
94 * | |
95 * For example, org.madbutterfly.redraw_man is the respective Java | |
96 * class of redraw_man_t of MadButterfly engine. redraw_man has a | |
97 * private member variable redraw_man._rdman_addr. It is the address | |
98 * of the resptive redraw_man_t object of MadButterfly. redraw_man | |
99 * would call _jni.redraw_man_destroy() to release associated | |
100 * resources and free the memory before it is recycled. So, | |
101 * redraw_man.finalize() is defined for releasing resources. It would | |
102 * be called before the redraw_man object being recycled. | |
103 * | |
53 */ | 104 */ |