aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-11-05 05:02:38 +0100
committerSven Gothel <[email protected]>2012-11-05 05:02:38 +0100
commit8c78f80f205345fe43ec2639e648421ef0134e57 (patch)
tree9498900879ceba4718938d57774b19c6d41e54e5 /src/jogl/classes/jogamp/opengl
parent3a00361952120f8127a3014623de703ac696e036 (diff)
GLAutoDrawable: Refine API change of commit c002e04f848116922a1ed7bd96ead54961649bbd
As suggested by Julien Gouesse, align 'enqueue(..)' method w/ 'invoke(..)': - public void enqueue(GLRunnable glRunnable); + public boolean invoke(boolean wait, List<GLRunnable> glRunnables);
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java47
2 files changed, 49 insertions, 3 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
index 09a754279..7bcd37ecd 100644
--- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
+++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
@@ -29,6 +29,7 @@
package jogamp.opengl;
import java.io.PrintStream;
+import java.util.List;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
@@ -412,8 +413,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter {
}
@Override
- public final void enqueue(GLRunnable glRunnable) {
- helper.enqueue(glRunnable);
+ public boolean invoke(final boolean wait, final List<GLRunnable> glRunnables) {
+ return helper.invoke(this, wait, glRunnables);
}
@Override
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index d891ae810..be63c9278 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -41,6 +41,7 @@
package jogamp.opengl;
import java.util.ArrayList;
+import java.util.List;
import java.util.HashSet;
import javax.media.nativewindow.NativeSurface;
@@ -691,9 +692,9 @@ public class GLDrawableHelper {
return false;
}
- Throwable throwable = null;
GLRunnableTask rTask = null;
Object rTaskLock = new Object();
+ Throwable throwable = null;
synchronized(rTaskLock) {
final boolean deferred;
synchronized(glRunnablesLock) {
@@ -724,6 +725,50 @@ public class GLDrawableHelper {
}
return true;
}
+
+ public final boolean invoke(GLAutoDrawable drawable, boolean wait, List<GLRunnable> newGLRunnables) {
+ if( null == newGLRunnables || newGLRunnables.size() == 0 || null == drawable ||
+ wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) {
+ return false;
+ }
+
+ final int count = newGLRunnables.size();
+ GLRunnableTask rTask = null;
+ Object rTaskLock = new Object();
+ Throwable throwable = null;
+ synchronized(rTaskLock) {
+ final boolean deferred;
+ synchronized(glRunnablesLock) {
+ deferred = isAnimatorAnimatingOnOtherThread();
+ if(!deferred) {
+ wait = false; // don't wait if exec immediatly
+ }
+ for(int i=0; i<count-1; i++) {
+ glRunnables.add( new GLRunnableTask(newGLRunnables.get(i), null, false) );
+ }
+ rTask = new GLRunnableTask(newGLRunnables.get(count-1),
+ wait ? rTaskLock : null,
+ wait /* catch Exceptions if waiting for result */);
+ glRunnables.add(rTask);
+ }
+ if( !deferred ) {
+ drawable.display();
+ } else if( wait ) {
+ try {
+ rTaskLock.wait(); // free lock, allow execution of rTask
+ } catch (InterruptedException ie) {
+ throwable = ie;
+ }
+ if(null==throwable) {
+ throwable = rTask.getThrowable();
+ }
+ if(null!=throwable) {
+ throw new RuntimeException(throwable);
+ }
+ }
+ }
+ return true;
+ }
public final void enqueue(GLRunnable glRunnable) {
if( null == glRunnable) {