mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2026-04-23 00:07:15 +08:00
cmd/ebitenmobile: bug fix: consider EbitenSurfaceView recreation
On Android Emulator (Small Desktop API 32), EbitenRenderer can be easily recreated by resizing the window. Thus, EbitenRenderer should not have any flags like strictContextRestoration. Also, the flag onceSurfaceCreated_ doesn't work there.
This commit is contained in:
@@ -59,12 +59,13 @@ class EbitenSurfaceView extends GLSurfaceView implements Renderer {
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
if (!onceSurfaceCreated_) {
|
||||
onceSurfaceCreated_ = true;
|
||||
// As EbitenSurfaceView can be recreated anytime, this flag for strict context restoration must be checked every time.
|
||||
if (Ebitenmobileview.usesStrictContextRestoration()) {
|
||||
Ebitenmobileview.onContextLost();
|
||||
return;
|
||||
}
|
||||
if (hasStrictContextRestoration()) {
|
||||
Ebitenmobileview.onContextLost();
|
||||
if (!onceSurfaceCreated_) {
|
||||
onceSurfaceCreated_ = true;
|
||||
return;
|
||||
}
|
||||
contextLost_ = true;
|
||||
@@ -81,8 +82,6 @@ class EbitenSurfaceView extends GLSurfaceView implements Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean strictContextRestoration_ = false;
|
||||
|
||||
public EbitenSurfaceView(Context context) {
|
||||
super(context);
|
||||
initialize();
|
||||
@@ -123,15 +122,6 @@ class EbitenSurfaceView extends GLSurfaceView implements Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setStrictContextRestoration(boolean strictContextRestoration) {
|
||||
strictContextRestoration_ = strictContextRestoration;
|
||||
}
|
||||
|
||||
private synchronized boolean hasStrictContextRestoration() {
|
||||
return strictContextRestoration_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void requestRenderIfNeeded() {
|
||||
if (getRenderMode() == RENDERMODE_WHEN_DIRTY) {
|
||||
|
||||
Reference in New Issue
Block a user