From 546f9b1a03c46b63f8bb18c1b8e2c80a8b66cf7c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 24 Sep 2014 01:25:49 +0200 Subject: Fix all backward compatibility issues w/ 2.2.0 and 2.2.1 - Preserve fields, but make them deprecated and don't use them anymore. Using a new version with less visibility. - Revert incompatible method prototype changes - GLFBODrawable: - Completly remove FBOMODE_DEFAULT and FBOMODE_USE_DEPTH usage and deprecate them - GLRendererQuirks: - Completly remove COUNT usage and deprecate it. - Add getCount() method for future compatibility. --- .../com/jogamp/opengl/GLRendererQuirks.java | 13 ++-- .../classes/com/jogamp/opengl/util/Animator.java | 80 +++++++++++++--------- .../com/jogamp/opengl/util/AnimatorBase.java | 7 +- .../com/jogamp/opengl/util/FPSAnimator.java | 7 +- .../classes/javax/media/opengl/GLFBODrawable.java | 18 ++--- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 2 +- 6 files changed, 73 insertions(+), 54 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index f81d2f2d0..eafc52ef8 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -341,8 +341,11 @@ public class GLRendererQuirks { */ public static final int BuggyColorRenderbuffer = 18; - /** Number of quirks known. */ - public static final int COUNT = 19; + /** @deprecated Use {@link #getCount()}, this value is no more valid! */ + public static final int COUNT = 18; + + /** Return the number of known quirks. */ + public static final int getCount() { return 19; } private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", @@ -509,7 +512,7 @@ public class GLRendererQuirks { } sb.append("["); boolean first=true; - for(int i=0; i */ public class Animator extends AnimatorBase { + /** @deprecated no more used */ protected ThreadGroup threadGroup; - private Runnable runnable; - private boolean runAsFastAsPossible; + /** @deprecated no more used */ protected boolean isAnimating; - protected volatile boolean pauseIssued; + /** @deprecated no more used */ + protected boolean pauseIssued; + /** @deprecated no more used */ protected volatile boolean stopIssued; + private ThreadGroup threadGroup2; + private Runnable runnable; + private boolean runAsFastAsPossible; + boolean isAnimating2; + volatile boolean pauseIssued2; + volatile boolean stopIssued2; + /** * Creates a new, empty Animator. */ @@ -82,7 +91,7 @@ public class Animator extends AnimatorBase { super(); setThreadGroup(tg); if(DEBUG) { - System.err.println("Animator created, ThreadGroup: "+threadGroup); + System.err.println("Animator created, ThreadGroup: "+threadGroup2); } } @@ -105,7 +114,7 @@ public class Animator extends AnimatorBase { setThreadGroup(tg); add(drawable); if(DEBUG) { - System.err.println("Animator created, ThreadGroup: "+threadGroup+" and "+drawable); + System.err.println("Animator created, ThreadGroup: "+threadGroup2+" and "+drawable); } } @@ -142,19 +151,19 @@ public class Animator extends AnimatorBase { } fpsCounter.resetFPSCounter(); animThread = Thread.currentThread(); - isAnimating = false; + isAnimating2 = false; // 'waitForStartedCondition' wake-up is handled below! } - while (!stopIssued) { + while (!stopIssued2) { 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 ( !stopIssued2 && ( pauseIssued2 || drawablesEmpty ) ) { if( drawablesEmpty ) { - pauseIssued = true; + pauseIssued2 = true; } - final boolean wasPaused = pauseIssued; + final boolean wasPaused = pauseIssued2; if (DEBUG) { System.err.println("Animator pause on " + animThread.getName() + ": " + toString()); } @@ -165,11 +174,11 @@ public class Animator extends AnimatorBase { display(); // propagate exclusive context -> off! } catch (final UncaughtAnimatorException dre) { caughtException = dre; - stopIssued = true; + stopIssued2 = true; break; // end pause loop } } - isAnimating = false; + isAnimating2 = false; Animator.this.notifyAll(); try { Animator.this.wait(); @@ -183,22 +192,22 @@ public class Animator extends AnimatorBase { } } } - if (!stopIssued && !isAnimating) { + if (!stopIssued2 && !isAnimating2) { // Wakes up 'waitForStartedCondition' sync // - and - // Resume from pause or drawablesEmpty, // implies !pauseIssued and !drawablesEmpty - isAnimating = true; + isAnimating2 = true; setDrawablesExclCtxState(exclusiveContext); // may re-enable exclusive context Animator.this.notifyAll(); } } // sync Animator.this - if ( !pauseIssued && !stopIssued ) { + if ( !pauseIssued2 && !stopIssued2 ) { try { display(); } catch (final UncaughtAnimatorException dre) { caughtException = dre; - stopIssued = true; + stopIssued2 = true; break; // end animation loop } if ( !runAsFastAsPossible ) { @@ -237,12 +246,17 @@ public class Animator extends AnimatorBase { caughtException.printStackTrace(); } } - stopIssued = false; - pauseIssued = false; - isAnimating = false; + stopIssued2 = false; + pauseIssued2 = false; + isAnimating2 = false; if( null != caughtException ) { flushGLRunnables = true; - throwCaughtException = !handleUncaughtException(caughtException); + if( null != uncaughtExceptionHandler ) { + handleUncaughtException(caughtException); + throwCaughtException = false; + } else { + throwCaughtException = true; + } } animThread = null; Animator.this.notifyAll(); @@ -261,12 +275,12 @@ public class Animator extends AnimatorBase { @Override public final synchronized boolean isAnimating() { - return animThread != null && isAnimating ; + return animThread != null && isAnimating2 ; } @Override public final synchronized boolean isPaused() { - return animThread != null && pauseIssued ; + return animThread != null && pauseIssued2 ; } /** @@ -279,7 +293,7 @@ public class Animator extends AnimatorBase { if ( isStarted() ) { throw new GLException("Animator already started."); } - threadGroup = tg; + threadGroup2 = tg; } @Override @@ -293,10 +307,10 @@ public class Animator extends AnimatorBase { fpsCounter.resetFPSCounter(); final String threadName = getThreadName()+"-"+baseName; Thread thread; - if(null==threadGroup) { + if(null==threadGroup2) { thread = new Thread(runnable, threadName); } else { - thread = new Thread(threadGroup, runnable, threadName); + thread = new Thread(threadGroup2, runnable, threadName); } thread.setDaemon(false); // force to be non daemon, regardless of parent thread if(DEBUG) { @@ -309,7 +323,7 @@ public class Animator extends AnimatorBase { private final Condition waitForStartedCondition = new Condition() { @Override public boolean eval() { - return !isStarted() || (!drawablesEmpty && !isAnimating) ; + return !isStarted() || (!drawablesEmpty && !isAnimating2) ; } }; @Override @@ -317,7 +331,7 @@ public class Animator extends AnimatorBase { if ( !isStarted() ) { return false; } - stopIssued = true; + stopIssued2 = true; return finishLifecycleAction(waitForStoppedCondition, 0); } private final Condition waitForStoppedCondition = new Condition() { @@ -328,31 +342,31 @@ public class Animator extends AnimatorBase { @Override public final synchronized boolean pause() { - if ( !isStarted() || pauseIssued ) { + if ( !isStarted() || pauseIssued2 ) { return false; } - pauseIssued = true; + pauseIssued2 = true; return finishLifecycleAction(waitForPausedCondition, 0); } private final Condition waitForPausedCondition = new Condition() { @Override public boolean eval() { // end waiting if stopped as well - return isStarted() && isAnimating; + return isStarted() && isAnimating2; } }; @Override public final synchronized boolean resume() { - if ( !isStarted() || !pauseIssued ) { + if ( !isStarted() || !pauseIssued2 ) { return false; } - pauseIssued = false; + pauseIssued2 = false; return finishLifecycleAction(waitForResumeCondition, 0); } private final Condition waitForResumeCondition = new Condition() { @Override public boolean eval() { // end waiting if stopped as well - return isStarted() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ; + return isStarted() && ( !drawablesEmpty && !isAnimating2 || drawablesEmpty && !pauseIssued2 ) ; } }; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index bc159ef5c..3d5935457 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -525,17 +525,12 @@ public abstract class AnimatorBase implements GLAnimatorControl { /** * Should be called in case of an uncaught exception * from within the animator thread, throws given exception if no handler has been installed. - * @return {@code true} if handled, otherwise {@code false}. In case of {@code false}, - * caller needs to propagate the exception. */ - protected final synchronized boolean handleUncaughtException(final UncaughtAnimatorException ue) { + protected final synchronized void handleUncaughtException(final UncaughtAnimatorException ue) { if( null != uncaughtExceptionHandler ) { try { uncaughtExceptionHandler.uncaughtException(this, ue.getGLAutoDrawable(), ue.getCause()); } catch (final Throwable t) { /* ignore intentionally */ } - return true; - } else { - return false; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 54d40f285..7abe987ac 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -240,7 +240,12 @@ public class FPSAnimator extends AnimatorBase { isAnimating = false; if( null != caughtException ) { flushGLRunnables = true; - throwCaughtException = !handleUncaughtException(caughtException); + if( null != uncaughtExceptionHandler ) { + handleUncaughtException(caughtException); + throwCaughtException = false; + } else { + throwCaughtException = true; + } } animThread = null; FPSAnimator.this.notifyAll(); diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java index 01db60b2e..a90a40e4d 100644 --- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java @@ -78,16 +78,17 @@ import com.jogamp.opengl.GLRendererQuirks; public interface GLFBODrawable extends GLDrawable { // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support - /** FBO Mode Bit: Use a {@link TextureAttachment} for the {@link #getColorbuffer(int) render colorbuffer} ({@link #FBOMODE_DEFAULT default}), see {@link #setFBOMode(int)}. */ + /** FBO Mode Bit: Use a {@link TextureAttachment} for the {@link #getColorbuffer(int) render colorbuffer}, see {@link #setFBOMode(int)}. */ public static final int FBOMODE_USE_TEXTURE = 1 << 0; /** - * FBO Mode Bit: Use a depth renderbuffer ({@link #FBOMODE_DEFAULT default}), see {@link #setFBOMode(int)}. - * @deprecated Use {@link GLCapabilities#setDepthBits(int)}! + * @deprecated Use {@link GLCapabilities#setDepthBits(int)}, this bit is w/o function now. */ public static final int FBOMODE_USE_DEPTH = 1 << 1; - /** FBO Default Mode Bit: {@link #FBOMODE_USE_TEXTURE}. */ - public static final int FBOMODE_DEFAULT = FBOMODE_USE_TEXTURE; + /** + * @deprecated Use dedicated values, e.g. {@link #FBOMODE_USE_TEXTURE}. + */ + public static final int FBOMODE_DEFAULT = FBOMODE_USE_TEXTURE | FBOMODE_USE_DEPTH; /** * @return true if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false. @@ -97,7 +98,7 @@ public interface GLFBODrawable extends GLDrawable { /** * Set the FBO mode bits used for FBO creation. *

- * See {@link #FBOMODE_DEFAULT} values. + * See {@link #FBOMODE_USE_TEXTURE}. *

*

* If {@link GLRendererQuirks#BuggyColorRenderbuffer} is set, @@ -206,8 +207,9 @@ public interface GLFBODrawable extends GLDrawable { *

*

* Depending on the {@link #setFBOMode(int) fbo mode} the resulting {@link Colorbuffer} - * is either a {@link TextureAttachment} ({@link #FBOMODE_DEFAULT default}) or a {@link ColorAttachment}, - * see {@link Colorbuffer#isTextureAttachment()}. + * is either a {@link TextureAttachment} if {@link #FBOMODE_USE_TEXTURE} is set, + * otherwise a {@link ColorAttachment}. + * See {@link Colorbuffer#isTextureAttachment()}. *

* @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names * @return the named {@link Colorbuffer} diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index fdd5aa5e9..cc8ebcac9 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -107,7 +107,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { final FBObject fbo = new FBObject(); fbos[idx] = fbo; - final boolean useDepth = depthBits > 0 || 0 != ( FBOMODE_USE_DEPTH & fboModeBits ); + final boolean useDepth = depthBits > 0; final boolean useStencil = stencilBits > 0; fbo.init(gl, width, height, samples); -- cgit v1.2.3