mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
mobile/ebitenmobileview: Bug fix: Use Math.floor to shrink the size a little bit
Fixes #956
This commit is contained in:
parent
43a8881ab8
commit
bf07ead6ae
@ -377,20 +377,16 @@ public class EbitenView extends ViewGroup {
|
|||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int widthInDp = (int)Math.floor(pxToDp(right - left));
|
int widthInDp = (int)Math.ceil(pxToDp(right - left));
|
||||||
int heightInDp = (int)Math.floor(pxToDp(bottom - top));
|
int heightInDp = (int)Math.ceil(pxToDp(bottom - top));
|
||||||
Ebitenmobileview.layout(widthInDp, heightInDp, new ViewRectSetter() {
|
Ebitenmobileview.layout(widthInDp, heightInDp, new ViewRectSetter() {
|
||||||
@Override
|
@Override
|
||||||
public void setViewRect(long xInDp, long yInDp, long widthInDp, long heightInDp) {
|
public void setViewRect(long xInDp, long yInDp, long widthInDp, long heightInDp) {
|
||||||
int width = (int)Math.ceil(dpToPx(widthInDp));
|
// Use Math.floor to use smaller and safer values, or glitches can appear (#956).
|
||||||
int height = (int)Math.ceil(dpToPx(heightInDp));
|
final int widthInPx = (int)Math.floor(dpToPx(widthInDp));
|
||||||
int x = (int)Math.ceil(dpToPx(xInDp));
|
final int heightInPx = (int)Math.floor(dpToPx(heightInDp));
|
||||||
int y = (int)Math.ceil(dpToPx(yInDp));
|
final int xInPx = (int)Math.floor(dpToPx(xInDp));
|
||||||
// Use even numbers to avoid glitches (#956).
|
final int yInPx = (int)Math.floor(dpToPx(yInDp));
|
||||||
final int xInPx = x / 2 * 2;
|
|
||||||
final int yInPx = y / 2 * 2;
|
|
||||||
final int widthInPx = width / 2 * 2;
|
|
||||||
final int heightInPx = height / 2 * 2;
|
|
||||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -49,8 +49,10 @@ func layout(viewWidth, viewHeight int, viewRectSetter ViewRectSetter) {
|
|||||||
scaleY := float64(viewHeight) / float64(h)
|
scaleY := float64(viewHeight) / float64(h)
|
||||||
scale := math.Min(scaleX, scaleY)
|
scale := math.Min(scaleX, scaleY)
|
||||||
|
|
||||||
width := int(math.Ceil(float64(w) * scale))
|
// To convert a logical offscreen size to the actual screen size, use Math.floor to use smaller and safer
|
||||||
height := int(math.Ceil(float64(h) * scale))
|
// values, or glitches can appear (#956).
|
||||||
|
width := int(math.Floor(float64(w) * scale))
|
||||||
|
height := int(math.Floor(float64(h) * scale))
|
||||||
x := (viewWidth - width) / 2
|
x := (viewWidth - width) / 2
|
||||||
y := (viewHeight - height) / 2
|
y := (viewHeight - height) / 2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user