My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 54 attachment: acui.diff (4.3 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
Index: AndroidCanvasUI.java
===================================================================
--- AndroidCanvasUI.java (revision 2446)
+++ AndroidCanvasUI.java (working copy)
@@ -27,9 +27,11 @@
package org.microemu.android.device.ui;

import javax.microedition.lcdui.Canvas;
+import javax.microedition.lcdui.game.GameCanvas;

import org.microemu.MIDletAccess;
import org.microemu.MIDletBridge;
+import org.microemu.DisplayAccess;
import org.microemu.android.MicroEmulatorActivity;
import org.microemu.android.device.AndroidDeviceDisplay;
import org.microemu.android.device.AndroidDisplayGraphics;
@@ -74,16 +76,29 @@
});
}

- public void initGraphics(int width, int height) {
+ public boolean initGraphics(int width, int height) {
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);
+ boolean sizeChanged = bitmap != null && (bitmap.getWidth() != width || bitmap.getHeight() != height);
+ if (bitmap == null || sizeChanged) {
+ bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
+ bitmapCanvas = new android.graphics.Canvas(bitmap);
+ graphics.reset(bitmapCanvas);
}
- graphics.reset(bitmapCanvas);
+ return sizeChanged;
}
+
+ public void sizeChanged() {
+ MIDletAccess ma = MIDletBridge.getMIDletAccess();
+ if (ma == null) {
+ return;
+ }
+ DisplayAccess da = ma.getDisplayAccess();
+ if (da != null) {
+ da.sizeChanged();
+ }
+ }

public View getView() {
return view;
@@ -92,7 +107,11 @@
@Override
public void hideNotify()
{
- ((AndroidDeviceDisplay) activity.getEmulatorContext().getDeviceDisplay()).removeDisplayRepaintListener((DisplayRepaintListener) view);
+ activity.runOnUiThread(new Runnable() {
+ public void run() {
+ ((AndroidDeviceDisplay) activity.getEmulatorContext().getDeviceDisplay()).removeDisplayRepaintListener((DisplayRepaintListener) view);
+ }
+ });

super.hideNotify();
}
@@ -101,8 +120,8 @@
public void showNotify()
{
super.showNotify();
-
- activity.post(new Runnable() {
+
+ activity.runOnUiThread(new Runnable() {
public void run() {
((AndroidDeviceDisplay) activity.getEmulatorContext().getDeviceDisplay()).addDisplayRepaintListener((DisplayRepaintListener) view);
((Canvas) displayable).repaint(0, 0, bitmap.getWidth(), bitmap.getHeight());
@@ -111,6 +130,16 @@
}

public AndroidDisplayGraphics getGraphics() {
+ while (graphics == null) {
+/*
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+*/
+ Thread.yield();
+ }
return graphics;
}

@@ -143,6 +172,7 @@

setFocusable(true);
setFocusableInTouchMode(true);
+ setId(1611);

callback = new Callback() {

@@ -153,12 +183,16 @@
}

public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- initGraphics(width, height);
- ((Canvas) displayable).repaint(0, 0, width, height);
+ if (initGraphics(width, height)) {
+ sizeChanged();
+ } else {
+ flushGraphics(0, 0, width, height);
+ }
}

};
getHolder().addCallback(callback);
+ getHolder().setFormat(android.graphics.PixelFormat.RGB_565);
}

public AndroidCanvasUI getUI() {
@@ -255,7 +289,9 @@

public void repaintInvoked(Object repaintObject)
{
- onDraw(bitmapCanvas);
+ if (!(displayable instanceof GameCanvas)) {
+ onDraw(bitmapCanvas);
+ }
Rect r = (Rect) repaintObject;
flushGraphics(r.left, r.top, r.width(), r.height());
}
Powered by Google Project Hosting