Check-in [4b0cab57c8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Base drawing of active display, nothing actually drawn yet.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4b0cab57c8da4824bbaf243041d9e56a4257873b
User & Date: stephanie.gawroriski 2019-05-16 18:40:04
Context
2019-05-16
23:33
Base for drawing display things. check-in: 7e8eb4865c user: stephanie.gawroriski tags: trunk
18:40
Base drawing of active display, nothing actually drawn yet. check-in: 4b0cab57c8 user: stephanie.gawroriski tags: trunk
18:05
Registration of callback for native ui. check-in: 5ead2a7a1b user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess.java.

476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
	{
		/** Resize lock timer. */
		final Timer _resizetimer =
			new Timer(100, this);
		
		/** The image to be displayed. */
		volatile BufferedImage _image =
			ColorInfo.create(Math.max(320, this.getWidth()),
				Math.max(240, this.getHeight()), new Color(0xFFFFFFFF));
		
		/** The last mouse button pressed. */
		volatile int _lastbutton =
			Integer.MIN_VALUE;
		
		/**
		 * Initializes more panel details.







|
|







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
	{
		/** Resize lock timer. */
		final Timer _resizetimer =
			new Timer(100, this);
		
		/** The image to be displayed. */
		volatile BufferedImage _image =
			ColorInfo.create(Math.max(240, this.getWidth()),
				Math.max(320, this.getHeight()), new Color(0xFFFFFFFF));
		
		/** The last mouse button pressed. */
		volatile int _lastbutton =
			Integer.MIN_VALUE;
		
		/**
		 * Initializes more panel details.

Changes to runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/ActiveDisplay.java.

5
6
7
8
9
10
11

12

13
14
15
16
17
18
19
..
39
40
41
42
43
44
45
46


47
























// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;


import javax.microedition.lcdui.Image;


/**
 * This contains the display display along with the internal image buffer.
 *
 * @since 2019/05/16
 */
public final class ActiveDisplay
................................................................................
		// Set sizes
		this.width = __w;
		this.height = __h;
		
		// Setup buffer
		this.image = Image.createImage(__w, __h);
	}
}


































>

>







 







|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Arrays;

/**
 * This contains the display display along with the internal image buffer.
 *
 * @since 2019/05/16
 */
public final class ActiveDisplay
................................................................................
		// Set sizes
		this.width = __w;
		this.height = __h;
		
		// Setup buffer
		this.image = Image.createImage(__w, __h);
	}
	
	/**
	 * Paints whatever is in the active display.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public final void paint(int __x, int __y, int __w, int __h)
	{
		// Get display details
		Graphics dg = this.image.getGraphics();
		int dw = this.width,
			dh = this.height;
		
		// Draw box
		dg.setColor(0x0000FF);
		dg.fillRect(0, 0, dw, dh);
		
		// Draw an X
		dg.setColor(0xFFFF00);
		dg.drawLine(0, 0, dw, dh);
		dg.drawLine(0, dh, dw, 0);
	}
}

Changes to runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/NativeUIBackend.java.

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
..
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
...
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
...
139
140
141
142
143
144
145




146
147
148
149
150
151
152
...
160
161
162
163
164
165
166
167



















168
169
170
171
172
173
174
...
181
182
183
184
185
186
187




188
189
190
191
192
193
194
...
201
202
203
204
205
206
207




208
209
210
211
212
213
214
215
216
217




218
219
220
221
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;

import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;



/**
 * This is a backend which utilizes the SquirrelJME UI interface for all of
 * the related drawing applications.
 *
 * @since 2019/05/16
 */
public final class NativeUIBackend
	implements NativeDisplayEventCallback, PhoneDisplayBackend
{










	/** The native display ID. */
	protected final int nid;
	
	/** The pixel format of the buffer. */
	protected final PixelFormat pixelformat;
		
	/** The buffer data. */
	protected final Object buffer;
	
	/** The palette. */
	protected final int[] palette;
	
	/** The buffer width. */
	public final int width;
	
	/** The buffer height. */
	public final int height;
	
	/** Is the alpha channel used? */
	protected final boolean alpha;
	
	/** The pitch. */
	protected final int pitch;
	
	/** The offset into the buffer. */
	protected final int offset;
	
	/** The virtual X origin. */
	protected final int virtxorig;
	
	/** The virtual Y origin. */
	protected final int virtyorig;
	
	/** The active display to use. */
	private volatile ActiveDisplay _activedisplay;
	
	/**
	 * Initializes the native UI backend using the given display ID.
	 *
................................................................................
	 * @since 2019/05/16
	 */
	public NativeUIBackend(int __nid)
	{
		this.nid = __nid;
		
		// Get data buffers and properties
		Object buf = NativeDisplayAccess.framebufferObject(__nid);
		int[] pal = NativeDisplayAccess.framebufferPalette(__nid);
		int[] params = NativeDisplayAccess.framebufferParameters(__nid);
		
		// Set parameters
		this.pixelformat = PixelFormat.of(
			params[NativeDisplayAccess.PARAMETER_PIXELFORMAT]);
		this.buffer = buf;
		this.palette = pal;
		this.width = params[NativeDisplayAccess.PARAMETER_BUFFERWIDTH];
		this.height = params[NativeDisplayAccess.PARAMETER_BUFFERHEIGHT];
		this.alpha = params[NativeDisplayAccess.PARAMETER_ALPHA] != 0;
		this.pitch = params[NativeDisplayAccess.PARAMETER_PITCH];
		this.offset = params[NativeDisplayAccess.PARAMETER_OFFSET];
		this.virtxorig = params[NativeDisplayAccess.PARAMETER_VIRTXOFF];
		this.virtyorig = params[NativeDisplayAccess.PARAMETER_VIRTYOFF];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
................................................................................
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void command(int __d, int __c)
	{




		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void exitRequest(int __d)
	{




		todo.TODO.note("Implement");
	}





































	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final boolean isUpsidedown()
................................................................................
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time)
	{




		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
................................................................................
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void paintDisplay(int __d, int __x, int __y,
		int __w, int __h)
	{
		todo.TODO.note("Implement");



















	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
................................................................................
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time)
	{




		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
................................................................................
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void shown(int __d, int __shown)
	{




		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void sizeChanged(int __d, int __w, int __h)
	{




		todo.TODO.note("Implement");
	}
}








>

>
>










>
>
>
>
>
>
>
>
>
>





<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<





<
<
<
<
<
<
<
<
<







 







>
>
>
>










>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>







 







>
>
>
>










>
>
>
>




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
..
51
52
53
54
55
56
57


58
59
60
61
62









63
64
65
66
67
68
69
..
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
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
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
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.gfx.AcceleratedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This is a backend which utilizes the SquirrelJME UI interface for all of
 * the related drawing applications.
 *
 * @since 2019/05/16
 */
public final class NativeUIBackend
	implements NativeDisplayEventCallback, PhoneDisplayBackend
{
	/**
	 * {@squirreljme.property cc.squirreljme.lcdui.acceleration=bool
	 * Should accelerated graphics be used if it is available? This defaults
	 * to {@code true} and it is recommended it be used, otherwise it may be
	 * disabled if it causes issues with some software.}
	 */
	public static boolean USE_ACCELERATION =
		Boolean.valueOf(System.getProperty("cc.squirreljme.lcdui.acceleration",
		"true"));
	
	/** The native display ID. */
	protected final int nid;
	
	/** The pixel format of the buffer. */
	protected final PixelFormat pixelformat;



























	
	/** The active display to use. */
	private volatile ActiveDisplay _activedisplay;
	
	/**
	 * Initializes the native UI backend using the given display ID.
	 *
................................................................................
	 * @since 2019/05/16
	 */
	public NativeUIBackend(int __nid)
	{
		this.nid = __nid;
		
		// Get data buffers and properties


		int[] params = NativeDisplayAccess.framebufferParameters(__nid);
		
		// Set parameters
		this.pixelformat = PixelFormat.of(
			params[NativeDisplayAccess.PARAMETER_PIXELFORMAT]);









	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
................................................................................
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void command(int __d, int __c)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void exitRequest(int __d)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * Returns the native display graphics.
	 *
	 * @since 2019/05/16
	 */
	public final Graphics graphics()
	{
		// If acceleration is enabled, try to get accelerated graphics
		int nid = this.nid;
		if (USE_ACCELERATION)
			try
			{
				return AcceleratedGraphics.instance(nid);
			}
			catch (UnsupportedOperationException e)
			{
			}
			
		// Get data buffers and properties
		Object buf = NativeDisplayAccess.framebufferObject(nid);
		int[] pal = NativeDisplayAccess.framebufferPalette(nid);
		int[] params = NativeDisplayAccess.framebufferParameters(nid);
		
		// Set parameters
		int width = params[NativeDisplayAccess.PARAMETER_BUFFERWIDTH];
		int height = params[NativeDisplayAccess.PARAMETER_BUFFERHEIGHT];
		boolean alpha = params[NativeDisplayAccess.PARAMETER_ALPHA] != 0;
		int pitch = params[NativeDisplayAccess.PARAMETER_PITCH];
		int offset = params[NativeDisplayAccess.PARAMETER_OFFSET];
		int virtxorig = params[NativeDisplayAccess.PARAMETER_VIRTXOFF];
		int virtyorig = params[NativeDisplayAccess.PARAMETER_VIRTYOFF];
		
		// Create graphics from it
		return this.pixelformat.createGraphics(buf, pal, width, height,
			alpha, pitch, offset, virtxorig, virtyorig);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final boolean isUpsidedown()
................................................................................
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
................................................................................
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void paintDisplay(int __d, int __x, int __y,
		int __w, int __h)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		// Paint whatever is in the active display
		ActiveDisplay ad = this._activedisplay;
		if (ad != null)
		{
			// Do painting operations (UI stuff)
			ad.paint(__x, __y, __w, __h);
			
			// This image will be drawn onto the screen
			Image image = ad.image;
			
			// Get screen graphics
			Graphics g = this.graphics();
			
			// Draw our image on the screen
			g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
................................................................................
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
................................................................................
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void shown(int __d, int __shown)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void sizeChanged(int __d, int __w, int __h)
	{
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
}