Mercurial > MadButterfly
comparison Android/java/org/madbutterfly/redraw_man.java @ 493:1b6228092a57 Android_Skia
Java code for MadButterfly JNI.
This is Java code that access MadButterfly JNI interface.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 26 Nov 2009 15:02:51 +0800 |
parents | |
children | 2d7df44e6299 |
comparison
equal
deleted
inserted
replaced
492:e95598916dfb | 493:1b6228092a57 |
---|---|
1 package org.madbutterfly; | |
2 | |
3 import android.graphics.Canvas; | |
4 import android.view.SurfaceHolder; | |
5 import java.util.ArrayList; | |
6 | |
7 class redraw_man { | |
8 Canvas _cr, _backend; | |
9 int _rdman_addr; // address of redraw_man_t | |
10 coord root; | |
11 ArrayList paints; | |
12 MBView _view; | |
13 | |
14 public redraw_man(Canvas cr, Canvas backend, MBView view) { | |
15 int addr; | |
16 | |
17 _view = view; | |
18 _cr = cr; | |
19 _backend = backend; | |
20 | |
21 _rdman_addr = _jni.redraw_man_new(cr, backend); | |
22 addr = _jni.rdman_get_root(_rdman_addr); | |
23 root = new coord(this, addr); | |
24 | |
25 paints = new ArrayList(); | |
26 } | |
27 | |
28 static void _invalid_subtree(coord subtree) { | |
29 int i, sz; | |
30 coord child; | |
31 shape member; | |
32 | |
33 subtree.invalid(); | |
34 | |
35 sz = subtree.members.size(); | |
36 for(i = 0; i < sz; i ++) { | |
37 member = (shape)subtree.members.get(i); | |
38 member.invalid(); | |
39 } | |
40 | |
41 sz = subtree.children.size(); | |
42 for(i = 0; i < sz; i++) { | |
43 child = (coord)subtree.children.get(i); | |
44 _invalid_subtree(child); | |
45 } | |
46 } | |
47 | |
48 protected void finalize() { | |
49 int i, sz; | |
50 paint pnt; | |
51 | |
52 _invalid_subtree(root); | |
53 | |
54 /* invalid paints */ | |
55 sz = paints.size(); | |
56 for(i = 0; i < sz; i++) { | |
57 pnt = (paint)paints.get(i); | |
58 pnt.invalid(); | |
59 } | |
60 | |
61 _jni.redraw_man_free(_rdman_addr); | |
62 } | |
63 | |
64 public coord get_root() { | |
65 return root; | |
66 } | |
67 | |
68 public coord coord_new(coord parent) { | |
69 int addr; | |
70 coord child; | |
71 | |
72 addr = _jni.rdman_coord_new(_rdman_addr, parent.addr); | |
73 child = new coord(this, addr); | |
74 parent.children.add(child); | |
75 | |
76 return child; | |
77 } | |
78 | |
79 public void coord_free(coord obj) { | |
80 obj.finalize(); | |
81 obj.invalid(); | |
82 } | |
83 | |
84 public shape shape_path_new(String pathdata) { | |
85 int addr; | |
86 shape new_shape; | |
87 | |
88 addr = _jni.rdman_shape_path_new(_rdman_addr, pathdata); | |
89 new_shape = new shape(this, addr); | |
90 | |
91 return new_shape; | |
92 } | |
93 | |
94 public paint paint_color_new(float r, float g, float b, float a) { | |
95 int addr; | |
96 paint pnt; | |
97 | |
98 addr = _jni.rdman_paint_color_new(_rdman_addr, r, g, b, a); | |
99 pnt = new paint(this, addr); | |
100 | |
101 return pnt; | |
102 } | |
103 | |
104 public void redraw() { | |
105 _jni.rdman_redraw_all(_rdman_addr); | |
106 _view.redraw(); | |
107 } | |
108 } |