diff options
author | Sven Gothel <[email protected]> | 2013-06-23 00:56:00 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-23 00:56:00 +0200 |
commit | cdeee16cdb14a6977e6c2344ba16a2d9a02759ce (patch) | |
tree | de9b8bb65a61be0c5765e5a5c57edd4ff80846fa /src/jogl/classes/com | |
parent | a053732720628d57d38bda401053833259bf1657 (diff) |
AnimatorBase.setModeBits(..): Only issue initImpl() if required - and throw 'is started' exception in such case; Cleanup brackets.
Diffstat (limited to 'src/jogl/classes/com')
3 files changed, 13 insertions, 9 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java index 26d299663..8de178e49 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java @@ -165,6 +165,6 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { }; public boolean blockUntilDone(Thread thread) { - return ((Thread.currentThread() != thread) && !EventQueue.isDispatchThread()); + return Thread.currentThread() != thread && !EventQueue.isDispatchThread(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 837fc84bd..ef92100ad 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -115,6 +115,10 @@ public abstract class AnimatorBase implements GLAnimatorControl { drawablesEmpty = true; } + private static final boolean useAWTAnimatorImpl(int modeBits) { + return 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz; + } + /** * Initializes implementation details post setup, * invoked at {@link #add(GLAutoDrawable)}, {@link #start()}, .. @@ -125,9 +129,9 @@ public abstract class AnimatorBase implements GLAnimatorControl { * * @throws GLException if Animator is {@link #isStarted()} */ - protected void initImpl(boolean force) { + protected synchronized void initImpl(boolean force) { if( force || null == impl ) { - if( 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz ) { + if( useAWTAnimatorImpl( modeBits ) ) { try { impl = (AnimatorImpl) awtAnimatorImplClazz.newInstance(); baseName = getBaseName("AWT"); @@ -150,20 +154,20 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @param enable * @param bitValues * - * @throws GLException if Animator is {@link #isStarted()} + * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD */ public synchronized void setModeBits(boolean enable, int bitValues) throws GLException { - if( isStarted() ) { - throw new GLException("Animator already started"); - } final int _oldModeBits = modeBits; if(enable) { modeBits |= bitValues; } else { modeBits &= ~bitValues; } - if( _oldModeBits != modeBits ) { + if( useAWTAnimatorImpl( _oldModeBits ) != useAWTAnimatorImpl( modeBits ) ) { + if( isStarted() ) { + throw new GLException("Animator already started"); + } initImpl(true); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index 23b0845ee..bbd2951b9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -61,6 +61,6 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { } public boolean blockUntilDone(Thread thread) { - return (Thread.currentThread() != thread); + return Thread.currentThread() != thread; } } |