From 224fab1b2c71464826594740022fdcbe278867dc Mon Sep 17 00:00:00 2001
From: Sven Gothel
* If resumed, all counters (time, frames, ..) are reset to zero.
*
- * @return false if if not started or not paused, otherwise true
+ * @return false if not started, not paused or unable to resume, otherwise true
*
* @see #pause()
* @see #isAnimating()
*/
boolean resume();
+ /**
+ * Adds a drawable to this animator's list of rendering drawables.
* Registers the usage of an animator, an {@link javax.media.opengl.GLAnimatorControl} implementation.
- * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not.
* This method shall be called by an animator implementation only,
+ * This allows the animator thread to become active, i.e. {@link #isAnimating()}==true,
+ * in case the first drawable is added and {@link #isStarted()} and not {@link #isPaused()}.
+ *
+ * @param drawable the drawable to be added
+ * @throws IllegalArgumentException if drawable was already added to this animator
+ */
+ void add(GLAutoDrawable drawable);
+
/**
* Removes a drawable from the animator's list of rendering drawables.
* This method should get called in case a drawable becomes invalid,
* and will not be recovered.
- * This allows the animator thread to become idle in case the last drawable
- * has reached it's end of life.
+ * This allows the animator thread to become idle, i.e. {@link #isAnimating()}==false,
+ * in case the last drawable has reached it's end of life.
*
- * @param drawable the to be removed drawable
+ * @param drawable the drawable to be removed
+ * @throws IllegalArgumentException if drawable was not added to this animator
*/
void remove(GLAutoDrawable drawable);
}
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
index 0f487f463..a7db3f3fd 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
@@ -311,13 +311,13 @@ public interface GLAutoDrawable extends GLDrawable {
public GLEventListener removeGLEventListener(GLEventListener listener);
/**
- *
+ * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not.
*
* e.g. {@link com.jogamp.opengl.util.Animator#add(javax.media.opengl.GLAutoDrawable)}, passing it's control implementation,
- * and {@link com.jogamp.opengl.util.Animator#remove(javax.media.opengl.GLAutoDrawable)}, passing null
.
+ * and {@link com.jogamp.opengl.util.Animator#remove(javax.media.opengl.GLAutoDrawable)}, passing null
.
+ *
* Impacts {@link #display()} and {@link #invoke(boolean, GLRunnable)} semantics.
setExclusiveContextThread(null)
has been called.
+ *
+ * Default non-exclusive behavior is requested via setExclusiveContextThread(null)
,
+ * which will cause the next call of {@link #display()} on the exclusive thread to
+ * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()}
+ * will return null
.
+ *
+ * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null)
+ * and may poll {@link #getExclusiveContextThread()} until it returns null
,
+ * while the exclusive thread is still running.
+ *
+ * Note: Setting a new exclusive thread without properly releasing a previous one + * will throw an GLException. + *
+ *+ * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *
+ *+ * One scenario could be to dedicate the context to the {@link GLAnimatorControl#getThread() animator thread} + * and spare redundant context switches, see {@link com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)}. + *
+ * @param t the exclusive thread to claim the context, ornull
for default operation.
+ * @return previous exclusive context thread
+ * @throws GLException If an exclusive thread is still active but a new one is attempted to be set
+ * @see com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)
+ */
+ public Thread setExclusiveContextThread(Thread t) throws GLException;
+
+ /**
+ * @see #setExclusiveContextThread(Thread)
+ */
+ public Thread getExclusiveContextThread();
+
/**
* Enqueues a one-shot {@link GLRunnable},
* which will be executed within the next {@link #display()} call
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 235003c38..461d481a8 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -276,6 +276,9 @@ public abstract class GLContext {
/**
* Makes this GLContext current on the calling thread.
* + * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported. + *
+ ** There are two return values that indicate success and one that * indicates failure. *
@@ -288,7 +291,7 @@ public abstract class GLContext { * ** A return value of {@link #CONTEXT_CURRENT} indicates that the context has - * been made currrent, with its previous state restored. + * been made current, with its previous state restored. *
** If the context could not be made current (for example, because @@ -320,6 +323,9 @@ public abstract class GLContext { /** * Releases control of this GLContext from the current thread. *
+ * Recursive call to {@link #release()} and hence {@link #makeCurrent()} are supported. + *
+ ** The drawable's surface is being unlocked at exit, * assumed to be locked by {@link #makeCurrent()}. *
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 2f7fef9be..2de86b545 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -741,6 +741,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 23dedaa66..664edb996 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -473,6 +473,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, getContext()); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); -- cgit v1.2.3