From 2aa296771e3e8dd6cf027f27b0455d1803244bfe Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 21 Nov 2010 03:41:22 +0100 Subject: JOGL/NEWT: Animator fixes Consider use cases with many drawables and no drawables at start, this had to be reflected all over this patch set, implementation, usage and test cases. - GLAnimatorControl - refine API doc / states - add 'void remove(GLAutoDrawable drawable);' - Animator*: - using RecursiveLock 'stateSync' for all actions out of the big synchronized (animator) block: - get status methods (thread, isPaused, ..), hence no more synchronized - display drawables change, utilizing synced ArrayList swap This removes the need for volatiles usage shouldPause/shouldStop within the display method. - added blocking wait for state change for add(GLAutoDrawable)/remove(GLAutoDrawable) method - remove flawed double checked locking in anim thread (pause/idle condition) - thread is now a daemon thread, hence it won't hinder the JVM from shutdown - - Animator use change: - Always resume after pause, except in case of final destroy -> NEWT invalidate / GLCanvas, this considers use cases with many drawables and no drawables at start. - GLDrawableHelper: Don't pause at implicit dispose() --- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/jogl/classes/javax/media/opengl/awt/GLCanvas.java') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index f2016a23c..265c7ff49 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -347,10 +347,17 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { } if(null!=context) { - boolean animatorWasAnimating = false; + boolean animatorPaused = false; GLAnimatorControl animator = getAnimator(); if(null!=animator) { - animatorWasAnimating = animator.isAnimating(); + if(regenerate) { + if(animator.isStarted() && !animator.isPaused()) { + animator.pause(); + animatorPaused = true; + } + } else { + animator.remove(this); + } } disposeRegenerate=regenerate; @@ -376,8 +383,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { drawableHelper.invokeGL(drawable, context, disposeAction, null); } - if(regenerate && animatorWasAnimating && animator.isPaused()) { - animator.resume(); + if(animatorPaused) { + animator.resume(); } } if(!regenerate) { -- cgit v1.2.3