My favorites
▼
|
Sign in
microemu
MicroEmu is a pure Java implementation of Java ME.
Project Home
Downloads
Wiki
Issues
Source
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
54
attachment: simpleacui3.patch
(6.9 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Index: AndroidCanvasUI.java
===================================================================
--- AndroidCanvasUI.java (revision 2450)
+++ AndroidCanvasUI.java (working copy)
@@ -28,61 +28,46 @@
import javax.microedition.lcdui.Canvas;
-import org.microemu.DisplayAccess;
import org.microemu.MIDletAccess;
import org.microemu.MIDletBridge;
import org.microemu.android.MicroEmulatorActivity;
import org.microemu.android.device.AndroidDeviceDisplay;
import org.microemu.android.device.AndroidDisplayGraphics;
import org.microemu.android.device.AndroidInputMethod;
-import org.microemu.android.util.AndroidRepaintListener;
import org.microemu.android.util.Overlay;
import org.microemu.app.ui.DisplayRepaintListener;
import org.microemu.device.Device;
-import org.microemu.device.DeviceDisplay;
import org.microemu.device.DeviceFactory;
import org.microemu.device.ui.CanvasUI;
import android.content.Context;
-import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Rect;
-import android.os.Handler;
import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
import android.view.View;
+import org.microemu.android.util.AndroidRepaintListener;
-public class AndroidCanvasUI extends AndroidDisplayableUI implements CanvasUI {
+public class AndroidCanvasUI extends AndroidDisplayableUI implements CanvasUI {
- private AndroidDisplayGraphics graphics = null;
+ private AndroidDisplayGraphics graphics = null;
- private Bitmap bitmap = null;
-
- private android.graphics.Canvas bitmapCanvas;
-
public AndroidCanvasUI(final MicroEmulatorActivity activity, Canvas canvas) {
super(activity, canvas, false);
+
- DeviceDisplay display = activity.getEmulatorContext().getDeviceDisplay();
- initGraphics(display.getWidth(), display.getHeight());
-
activity.post(new Runnable() {
+ @Override
public void run() {
view = new CanvasView(activity, AndroidCanvasUI.this);
}
});
}
-
- public void initGraphics(int width, int height) {
+
+ public void initGraphics(int width, int height, Matrix matrix) {
if (graphics == null) {
graphics = new AndroidDisplayGraphics();
- }
- if (bitmap == null || bitmap.getWidth() != width || bitmap.getHeight() != height) {
- bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
- bitmapCanvas = new android.graphics.Canvas(bitmap);
- }
- graphics.reset(bitmapCanvas);
+ ((CanvasView)view).scale = matrix;
+ }
}
public View getView() {
@@ -103,22 +88,23 @@
super.showNotify();
activity.post(new Runnable() {
+ @Override
public void run() {
((AndroidDeviceDisplay) activity.getEmulatorContext().getDeviceDisplay()).addDisplayRepaintListener((DisplayRepaintListener) view);
- ((Canvas) displayable).repaint(0, 0, bitmap.getWidth(), bitmap.getHeight());
+ ((Canvas) displayable).repaint();
}
});
- }
+ }
public AndroidDisplayGraphics getGraphics() {
return graphics;
}
-
+
//
// CanvasUI
//
- public class CanvasView extends SurfaceView implements DisplayRepaintListener {
+ public class CanvasView extends View implements DisplayRepaintListener {
private final static int FIRST_DRAG_SENSITIVITY_X = 5;
@@ -136,29 +122,19 @@
public CanvasView(Context context, AndroidCanvasUI ui) {
super(context);
-
- this.ui = ui;
-
+ this.ui = ui;
setFocusable(true);
setFocusableInTouchMode(true);
}
public AndroidCanvasUI getUI() {
return ui;
- }
-
+ }
+
public void flushGraphics(int x, int y, int width, int height) {
// TODO handle x, y, width and height
if (repaintListener == null) {
- SurfaceHolder holder = getHolder();
- android.graphics.Canvas canvas = holder.lockCanvas();
- if (canvas != null) {
- canvas.drawBitmap(bitmap, scale, null);
- if (overlay != null) {
- overlay.onDraw(canvas);
- }
- holder.unlockCanvasAndPost(canvas);
- }
+ postInvalidate();
} else {
repaintListener.flushGraphics();
}
@@ -179,37 +155,22 @@
@Override
public void onDraw(android.graphics.Canvas androidCanvas) {
+ super.onDraw(androidCanvas);
MIDletAccess ma = MIDletBridge.getMIDletAccess();
if (ma == null) {
return;
}
-
+ initGraphics(androidCanvas.getWidth(), androidCanvas.getHeight(), androidCanvas.getMatrix());
graphics.reset(androidCanvas);
- graphics.setClip(0, 0, view.getWidth(), view.getHeight());
+ //graphics.setClip(0, 0, view.getWidth(), view.getHeight());
+ androidCanvas.setMatrix(scale);
ma.getDisplayAccess().paint(graphics);
+ // androidCanvas.drawBitmap(bitmap, scale, null);
if (overlay != null) {
overlay.onDraw(androidCanvas);
- }
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
-
- initGraphics(w, h);
-
- AndroidDeviceDisplay deviceDisplay = (AndroidDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay();
- deviceDisplay.displayRectangleWidth = w;
- deviceDisplay.displayRectangleHeight = h;
- MIDletAccess ma = MIDletBridge.getMIDletAccess();
- if (ma == null) {
- return;
- }
- DisplayAccess da = ma.getDisplayAccess();
- if (da != null) {
- da.sizeChanged();
- }
- }
+ }
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
@@ -245,22 +206,16 @@
return true;
}
- @Override
- public Handler getHandler() {
- return super.getHandler();
- }
-
//
// DisplayRepaintListener
//
-
+
@Override
public void repaintInvoked(Object repaintObject)
{
- onDraw(bitmapCanvas);
Rect r = (Rect) repaintObject;
flushGraphics(r.left, r.top, r.width(), r.height());
- }
+ }
private AndroidRepaintListener repaintListener;
@@ -268,7 +223,7 @@
{
this.repaintListener = repaintListener;
}
-
- }
+ }
+
}
Powered by
Google Project Hosting