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: canvas.patch (4.0 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
Index: src/org/microemu/android/device/ui/AndroidCanvasUI.java
===================================================================
--- src/org/microemu/android/device/ui/AndroidCanvasUI.java (revision 2441)
+++ src/org/microemu/android/device/ui/AndroidCanvasUI.java (working copy)
@@ -46,14 +46,14 @@
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Handler;
-import android.view.Display;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.SurfaceHolder.Callback;
+import org.microemu.device.DeviceDisplay;

-public class AndroidCanvasUI extends AndroidDisplayableUI implements CanvasUI {
+public final class AndroidCanvasUI extends AndroidDisplayableUI implements CanvasUI {

private AndroidDisplayGraphics graphics = null;

@@ -64,10 +64,11 @@
public AndroidCanvasUI(final MicroEmulatorActivity activity, Canvas canvas) {
super(activity, canvas, false);

- Display display = activity.getWindowManager().getDefaultDisplay();
+ DeviceDisplay display = activity.getEmulatorContext().getDeviceDisplay();
initGraphics(display.getWidth(), display.getHeight());

activity.post(new Runnable() {
+ @Override
public void run() {
view = new CanvasView(activity, AndroidCanvasUI.this);
}
@@ -103,13 +104,13 @@
super.showNotify();

((AndroidDeviceDisplay) activity.getEmulatorContext().getDeviceDisplay()).addDisplayRepaintListener((DisplayRepaintListener) view);
- ((Canvas) displayable).repaint(0, 0, bitmap.getWidth(), bitmap.getHeight());
+ ((Canvas) displayable).repaint(0, 0, bitmap.getWidth(), bitmap.getHeight());
}

public AndroidDisplayGraphics getGraphics() {
return graphics;
}
-
+
//
// CanvasUI
//
@@ -142,12 +143,15 @@

callback = new Callback() {

+ @Override
public void surfaceCreated(SurfaceHolder holder) {
}

+ @Override
public void surfaceDestroyed(SurfaceHolder holder) {
}

+ @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
initGraphics(width, height);
((Canvas) displayable).repaint(0, 0, width, height);
@@ -169,10 +173,10 @@
if (canvas != null) {
canvas.drawBitmap(bitmap, scale, null);
if (overlay != null) {
- overlay.onDraw(canvas);
+ overlay.onDraw(canvas);
}
- holder.unlockCanvasAndPost(canvas);
- }
+ holder.unlockCanvasAndPost(canvas);
+ }
} else {
repaintListener.flushGraphics();
}
@@ -196,17 +200,22 @@
MIDletAccess ma = MIDletBridge.getMIDletAccess();
if (ma == null) {
return;
- }
-
+ }
+
graphics.reset(androidCanvas);
graphics.setClip(0, 0, view.getWidth(), view.getHeight());
ma.getDisplayAccess().paint(graphics);
if (overlay != null) {
overlay.onDraw(androidCanvas);
}
- }
-
+ }
+
@Override
+ public void onSizeChanged(int w, int h, int oldw, int oldh) {
+ initGraphics(w, h);
+ }
+
+ @Override
public boolean onTouchEvent(MotionEvent event) {
if (overlay != null && overlay.onTouchEvent(event)) {
return true;
@@ -249,6 +258,7 @@
// DisplayRepaintListener
//

+ @Override
public void repaintInvoked(Object repaintObject)
{
onDraw(bitmapCanvas);
Powered by Google Project Hosting