Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
SquirrelJME
Commits
3f5a8a44
Commit
3f5a8a44
authored
Feb 26, 2022
by
Stephanie Gawroriski
Browse files
MIDP 2 does not preserve the GameCanvas buffer; Add fill color for canvases.
parent
1fd28e04
Pipeline
#89963
passed with stages
in 5 minutes and 58 seconds
Changes
5
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/DoubleBuffer.java
View file @
3f5a8a44
...
...
@@ -25,12 +25,10 @@ public final class DoubleBuffer
.
getGraphics
());
/** The off-screen buffer. */
private
final
SingleBuffer
_offScreen
=
new
SingleBuffer
();
private
final
SingleBuffer
_offScreen
;
/** The on-screen buffer. */
private
final
SingleBuffer
_onScreen
=
new
SingleBuffer
();
private
final
SingleBuffer
_onScreen
;
/** The last used width. */
private
volatile
int
_lastWidth
=
...
...
@@ -40,6 +38,29 @@ public final class DoubleBuffer
private
volatile
int
_lastHeight
=
-
1
;
/**
* Initializes the double buffer.
*
* @param __resizeFillColor The color to set when resizing, this is to
* prevent skewed graphics from appearing.
* @since 2022/02/25
*/
public
DoubleBuffer
(
int
__resizeFillColor
)
{
this
.
_offScreen
=
new
SingleBuffer
(
__resizeFillColor
);
this
.
_onScreen
=
new
SingleBuffer
(
0
);
}
/**
* Clears the off-screen buffer.
*
* @since 2022/02/25
*/
public
void
clear
()
{
this
.
_offScreen
.
clear
();
}
/**
* Flushes the off-screen buffer to be on-screen.
*
...
...
modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/ProxyGraphics.java
View file @
3f5a8a44
...
...
@@ -279,9 +279,9 @@ public final class ProxyGraphics
* @since 2022/02/25
*/
@Override
public
void
fillRect
(
int
__
a
,
int
__
b
,
int
__
c
,
int
__
d
)
public
void
fillRect
(
int
__
x
,
int
__
y
,
int
__
w
,
int
__
h
)
{
this
.
__graphics
().
fillRect
(
__
a
,
__
b
,
__
c
,
__
d
);
this
.
__graphics
().
fillRect
(
__
x
,
__
y
,
__
w
,
__
h
);
}
/**
...
...
modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/SingleBuffer.java
View file @
3f5a8a44
...
...
@@ -9,7 +9,6 @@
package
cc.squirreljme.runtime.lcdui.gfx
;
import
cc.squirreljme.jvm.mle.constants.UIPixelFormat
;
import
cc.squirreljme.runtime.cldc.debug.Debugging
;
import
cc.squirreljme.runtime.lcdui.mle.PencilGraphics
;
import
java.util.Arrays
;
import
javax.microedition.lcdui.Graphics
;
...
...
@@ -21,6 +20,9 @@ import javax.microedition.lcdui.Graphics;
*/
public
final
class
SingleBuffer
{
/** The color to fill with on resizes. */
private
final
int
fillColor
;
/** Available pixels. */
private
volatile
int
[]
_pixels
=
new
int
[
1
];
...
...
@@ -33,6 +35,27 @@ public final class SingleBuffer
private
volatile
int
_height
=
1
;
/**
* Initializes the single buffer.
*
* @param __resizeFillColor The color to fill with when resizing.
* @since 2022/02/25
*/
public
SingleBuffer
(
int
__resizeFillColor
)
{
this
.
fillColor
=
__resizeFillColor
;
}
/**
* Clears the buffer to the fill color.
*
* @since 2022/02/25
*/
public
void
clear
()
{
Arrays
.
fill
(
this
.
_pixels
,
this
.
fillColor
);
}
/**
* Copies from the source buffer.
*
...
...
@@ -95,7 +118,12 @@ public final class SingleBuffer
int
currentLimit
=
pixels
.
length
;
int
wantedArea
=
__width
*
__height
;
if
(
wantedArea
>
currentLimit
)
this
.
_pixels
=
(
pixels
=
Arrays
.
copyOf
(
pixels
,
wantedArea
));
{
this
.
_pixels
=
(
pixels
=
new
int
[
wantedArea
]);
// Fill resized area accordingly
Arrays
.
fill
(
pixels
,
this
.
fillColor
);
}
// Set new parameters
this
.
_width
=
__width
;
...
...
modules/midp-lcdui/src/main/java/javax/microedition/lcdui/game/GameCanvas.java
View file @
3f5a8a44
...
...
@@ -51,7 +51,7 @@ public abstract class GameCanvas
/** The double buffered image. */
private
final
DoubleBuffer
_doubleBuffer
=
new
DoubleBuffer
();
new
DoubleBuffer
(
0xFFFFFFFF
);
/**
* Initializes the game canvas.
...
...
@@ -64,7 +64,7 @@ public abstract class GameCanvas
*/
protected
GameCanvas
(
boolean
__suppressGameKeys
)
{
this
(
__suppressGameKeys
,
tru
e
);
this
(
__suppressGameKeys
,
fals
e
);
}
/**
...
...
@@ -171,7 +171,12 @@ public abstract class GameCanvas
private
void
__flip
()
{
// Flush off-screen to on-screen
this
.
_doubleBuffer
.
flush
();
DoubleBuffer
doubleBuffer
=
this
.
_doubleBuffer
;
doubleBuffer
.
flush
();
// If we are not preserving the buffer, clear to white
if
(!
this
.
_preserveBuffer
)
doubleBuffer
.
clear
();
// Signal and wait for refresh
super
.
repaint
(
0
,
0
,
this
.
getWidth
(),
this
.
getHeight
());
...
...
modules/nttdocomo-api/src/main/java/com/nttdocomo/ui/__MIDPCanvas__.java
View file @
3f5a8a44
...
...
@@ -25,7 +25,7 @@ final class __MIDPCanvas__
/** Double buffered image for drawing operations. */
final
DoubleBuffer
_doubleBuffer
=
new
DoubleBuffer
();
new
DoubleBuffer
(
0xFFFFFFFF
);
/**
* Initializes the base canvas.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment