Created
October 13, 2014 22:25
-
-
Save sehugg/37b28646f119859dd27e to your computer and use it in GitHub Desktop.
iOS setContinuousRendering() potential fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java | |
index 330b7fb..fe9bd53 100644 | |
--- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java | |
+++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java | |
@@ -65,7 +65,8 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
@Override | |
public void viewWillAppear (boolean arg0) { | |
super.viewWillAppear(arg0); | |
- setPaused(!graphics.isContinuous); | |
+ // start GLKViewController even though we may only draw a single frame | |
+ viewController.setPaused(false); | |
} | |
@Override | |
@@ -151,9 +152,10 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
private float ppcY = 0; | |
private float density = 1; | |
- volatile boolean paused; | |
+ volatile boolean appPaused; | |
private long frameId = -1; | |
private boolean isContinuous = true; | |
+ private boolean isFrameRequested = true; | |
IOSApplicationConfiguration config; | |
EAGLContext context; | |
@@ -262,12 +264,12 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
lastFrameTime = System.nanoTime(); | |
framesStart = lastFrameTime; | |
- paused = false; | |
+ appPaused = false; | |
} | |
public void resume () { | |
- if (!paused) return; | |
- paused = false; | |
+ if (!appPaused) return; | |
+ appPaused = false; | |
Array<LifecycleListener> listeners = app.lifecycleListeners; | |
synchronized (listeners) { | |
@@ -279,8 +281,8 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
} | |
public void pause () { | |
- if (paused) return; | |
- paused = true; | |
+ if (appPaused) return; | |
+ appPaused = true; | |
Array<LifecycleListener> listeners = app.lifecycleListeners; | |
synchronized (listeners) { | |
@@ -306,7 +308,7 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
app.listener.resize(width, height); | |
created = true; | |
} | |
- if (paused) { | |
+ if (appPaused) { | |
return; | |
} | |
@@ -334,17 +336,17 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
public void update (GLKViewController controller) { | |
makeCurrent(); | |
app.processRunnables(); | |
+ // pause the GLKViewController render loop if we are no longer continuous | |
+ // and if we haven't requested a frame in the last loop iteration | |
+ if (!isContinuous && !isFrameRequested) | |
+ { | |
+ viewController.setPaused(true); | |
+ } | |
+ isFrameRequested = false; | |
} | |
@Override | |
public void willPause (GLKViewController controller, boolean pause) { | |
- if (pause) { | |
- if (paused) return; | |
- pause(); | |
- } else { | |
- if (!paused) return; | |
- resume(); | |
- } | |
} | |
@Override | |
@@ -464,9 +466,6 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
@Override | |
public void setContinuousRendering (boolean isContinuous) { | |
this.isContinuous = isContinuous; | |
- viewController.setPaused(!isContinuous); | |
- viewController.setResumeOnDidBecomeActive(isContinuous); | |
- view.setEnableSetNeedsDisplay(!isContinuous); | |
} | |
@Override | |
@@ -476,7 +475,9 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, | |
@Override | |
public void requestRendering () { | |
- view.setNeedsDisplay(); | |
+ isFrameRequested = true; | |
+ // start the GLKViewController render loop | |
+ viewController.setPaused(false); | |
} | |
@Override |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment