aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/Animator.java14
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java13
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java4
4 files changed, 22 insertions, 15 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index d9a957199..4d61adaa6 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -62,7 +62,7 @@ public class Animator extends AnimatorBase {
private Runnable runnable;
private boolean runAsFastAsPossible;
protected boolean isAnimating;
- protected boolean pauseIssued;
+ protected volatile boolean pauseIssued;
protected volatile boolean stopIssued;
/**
@@ -149,7 +149,7 @@ public class Animator extends AnimatorBase {
synchronized (Animator.this) {
// Pause; Also don't consume CPU unless there is work to be done and not paused
boolean ectCleared = false;
- while (!stopIssued && (pauseIssued || drawablesEmpty)) {
+ while ( !stopIssued && ( pauseIssued || drawablesEmpty ) ) {
if( drawablesEmpty ) {
pauseIssued = true;
}
@@ -193,7 +193,7 @@ public class Animator extends AnimatorBase {
Animator.this.notifyAll();
}
} // sync Animator.this
- if (!stopIssued) {
+ if ( !pauseIssued && !stopIssued ) {
try {
display();
} catch (final UncaughtAnimatorException dre) {
@@ -202,10 +202,10 @@ public class Animator extends AnimatorBase {
isAnimating = false;
break; // end animation loop
}
- }
- if (!stopIssued && !runAsFastAsPossible) {
- // Avoid swamping the CPU
- Thread.yield();
+ if ( !runAsFastAsPossible ) {
+ // Avoid swamping the CPU
+ Thread.yield();
+ }
}
}
} catch( final ThreadDeath td) {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
index 8b4e125fc..539d81beb 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
@@ -85,8 +85,8 @@ public abstract class AnimatorBase implements GLAnimatorControl {
* @param printExceptions
* @throws UncaughtAnimatorException as caused by {@link GLAutoDrawable#display()}
*/
- void display(ArrayList<GLAutoDrawable> drawables, boolean ignoreExceptions, boolean printExceptions) throws UncaughtAnimatorException;
- boolean blockUntilDone(Thread thread);
+ void display(final ArrayList<GLAutoDrawable> drawables, final boolean ignoreExceptions, final boolean printExceptions) throws UncaughtAnimatorException;
+ boolean blockUntilDone(final Thread thread);
}
protected int modeBits;
@@ -559,7 +559,8 @@ public abstract class AnimatorBase implements GLAnimatorControl {
* @param waitCondition method will wait until TO is reached or {@link Condition#eval() waitCondition.eval()} returns <code>false</code>.
* @param pollPeriod if <code>0</code>, method will wait until TO is reached or being notified.
* if &gt; <code>0</code>, method will wait for the given <code>pollPeriod</code> in milliseconds.
- * @return <code>true</code> if {@link Condition#eval() waitCondition.eval()} returned <code>false</code>, otherwise <code>false</code>.
+ * @return <code>true</code> if {@link Condition#eval() waitCondition.eval()} returned <code>false</code>
+ * or if {@link AnimatorImpl#blockUntilDone(Thread) non-blocking}. Otherwise returns <code>false</code>.
*/
protected final synchronized boolean finishLifecycleAction(final Condition waitCondition, long pollPeriod) {
/**
@@ -572,6 +573,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
final boolean blocking;
long remaining;
boolean nok;
+
if( impl.blockUntilDone(animThread) ) {
blocking = true;
remaining = TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION;
@@ -605,12 +607,13 @@ public abstract class AnimatorBase implements GLAnimatorControl {
nok = waitCondition.eval();
}
}
+ final boolean res = !nok || !blocking;
if(DEBUG || blocking && nok) { // Info only if DEBUG or ( blocking && not-ok ) ; !blocking possible if AWT
if( blocking && remaining<=0 && nok ) {
System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + getThreadName());
}
System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+
- "- pollPeriod "+pollPeriod+", blocking "+blocking+
+ "- pollPeriod "+pollPeriod+", blocking "+blocking+" -> res "+res+
", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION +
" - " + getThreadName());
System.err.println(" - "+toString());
@@ -618,7 +621,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
Thread.dumpStack();
}
}
- return !nok;
+ return res;
}
@Override
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 78310c654..3b24cc2af 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -471,10 +471,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
if (backend != null && backend.getContext() != null) {
- boolean animatorPaused = false;
+ final boolean animatorPaused;
final GLAnimatorControl animator = getAnimator();
if(null!=animator) {
animatorPaused = animator.pause();
+ } else {
+ animatorPaused = false;
}
if(backend.getContext().isCreated()) {
@@ -486,7 +488,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
isInitialized = false;
}
- if(animatorPaused) {
+ if( animatorPaused ) {
animator.resume();
}
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 42b886742..2ba030f76 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -606,10 +606,12 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
@Override
public synchronized boolean pauseRenderingAction() {
- boolean animatorPaused = false;
+ final boolean animatorPaused;
savedAnimator = GLWindow.this.getAnimator();
if ( null != savedAnimator ) {
animatorPaused = savedAnimator.pause();
+ } else {
+ animatorPaused = false;
}
return animatorPaused;
}