From 424066616b085b36d88a39d56a618ea57cebc9e9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 13 Sep 2014 15:27:43 +0200 Subject: AnimatorBase.finishLifecycleAction(): Non blocking call shall return true, success - otherwise pause()/.. return value is inconsistent. Caller of e.g. pause() running on the anim-thread or AWT-EDT (AWTAnimatorImpl) will be non-blocking. Before this change, a non-blocking simply did not wait until the 'hold' condition is reached and returned its negated value. This ofc is 'false', indicated unsuccessful operation. Caller use the return value to determine whether the call actually paused (or ..) the animator. Despite the non-blocking nature, the pause state was set, even if not reached. Hence a resume() would be required to continue operation after a temporary pause. +++ This change ignores the non-blocking nature's unmet condition. finishLifecycleAction() returns !nok || !blocking, i.e. either true for the reached condition (blocking) or true if non-blocking. Blocking calls with unmet condition still return false. +++ In case an animated GLAutoDrawableis being pulled after a non-blocking animator pause() call, the GLAutoDrawable's implementation thread-safety must ensure proper operation. +++ --- src/jogl/classes/com/jogamp/opengl/util/Animator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/util/Animator.java') 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) { -- cgit v1.2.3