summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-25 03:29:53 +0200
committerSven Gothel <[email protected]>2012-03-25 03:29:53 +0200
commit3ed491213f8f7f05d7b9866b50d764370d8ff5f6 (patch)
tree07ea2547be486eb50db9d79a19f6e0c4dfa4dc70 /src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java
parent45a42f7c7f7fce4e6c7eb495591c438bdf0170a2 (diff)
Enhance and generalize AWT Threading* implementation; Minor changes ..
Threading*: - add invoke(..) generalizing the Therading decision GLCanvas: - remove 'manual' Threading decision, simply call Threading.invoke(..) - use anonymous Runnable instances - remove drawable lock, drawable is volatile instead GLJPanel: - remove 'manual' Threading decision, simply call Threading.invoke(..) - use anonymous Runnable instances - DEBUG: Use getThreadName() prefix GLContextImpl: - Remove GLWorkerThread idle command on makeCurrent(), no holding of context in worker thread while idle. - DEBUG: Use getThreadName() prefix X11GLXContext: - DEBUG: Use getThreadName() prefix TODO: Validate whether it's OK for GLCanvas and GLJPanel to set Threading.Mode.MT as the default mode!
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java
index 901146fc4..73b7d197d 100644
--- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java
+++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java
@@ -40,18 +40,24 @@
package jogamp.opengl.awt;
-import javax.media.opengl.*;
-
import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;
-import jogamp.opengl.*;
+import javax.media.opengl.GLException;
+
+import jogamp.opengl.GLWorkerThread;
+import jogamp.opengl.ThreadingImpl;
+import jogamp.opengl.ToolkitThreadingPlugin;
-public class AWTThreadingPlugin implements ThreadingPlugin {
+public class AWTThreadingPlugin implements ToolkitThreadingPlugin {
public AWTThreadingPlugin() {}
- public boolean isOpenGLThread() throws GLException {
+ public final boolean isToolkitThread() throws GLException {
+ return EventQueue.isDispatchThread();
+ }
+
+ public final boolean isOpenGLThread() throws GLException {
switch (ThreadingImpl.getMode()) {
case ST_AWT:
// FIXME: See the FIXME below in 'invokeOnOpenGLThread'
@@ -76,7 +82,7 @@ public class AWTThreadingPlugin implements ThreadingPlugin {
}
}
- public void invokeOnOpenGLThread(Runnable r) throws GLException {
+ public final void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException {
switch (ThreadingImpl.getMode()) {
case ST_AWT:
// FIXME: ideally should run all OpenGL work on the Java2D QFT
@@ -87,11 +93,19 @@ public class AWTThreadingPlugin implements ThreadingPlugin {
// implementation, which attempts to grab the AWT lock on the
// QFT which is not allowed. For now, on X11 platforms,
// continue to perform this work on the EDT.
- if (Java2D.isOGLPipelineActive() && !ThreadingImpl.isX11()) {
- Java2D.invokeWithOGLContextCurrent(null, r);
+ if (wait && Java2D.isOGLPipelineActive() && !ThreadingImpl.isX11()) {
+ if(wait) {
+ Java2D.invokeWithOGLContextCurrent(null, r);
+ } else {
+
+ }
} else {
try {
- EventQueue.invokeAndWait(r);
+ if(wait) {
+ EventQueue.invokeAndWait(r);
+ } else {
+ EventQueue.invokeLater(r);
+ }
} catch (InvocationTargetException e) {
throw new GLException(e.getTargetException());
} catch (InterruptedException e) {
@@ -101,14 +115,7 @@ public class AWTThreadingPlugin implements ThreadingPlugin {
break;
case ST_WORKER:
- GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking
- try {
- GLWorkerThread.invokeAndWait(r);
- } catch (InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (InterruptedException e) {
- throw new GLException(e);
- }
+ ThreadingImpl.invokeOnWorkerThread(wait, r);
break;
default: