summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-05-29 14:42:28 +0000
committerKenneth Russel <[email protected]>2006-05-29 14:42:28 +0000
commit2ebf1e32197d7236ff820c542e22ec78e700bdc1 (patch)
tree3822d5acba6ac0cbaac2139e57653736de95d4bb
parent27279cd88a1b57d59ca1d8bf2fcc343ed17288b8 (diff)
Fixed Issue 220: Gears demo throws exceptions with -Dsun.java2d.opengl=true
On non-X11 platforms, removed workaround in Threading class which treats both the EDT and the QFT as viable threads upon which to execute OpenGL work. Deadlock issues remain on X11 threads when causing OpenGL contexts associated with heavyweight widgets to be made current on the QFT. On Windows the QFT is now used for all OpenGL work when the Java2D/JOGL bridge is active. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@786 232f8b59-042b-4e1e-8c03-345bb8c30851
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/Java2D.java2
-rw-r--r--src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java3
-rw-r--r--src/classes/javax/media/opengl/GLJPanel.java4
-rwxr-xr-xsrc/classes/javax/media/opengl/Threading.java59
4 files changed, 37 insertions, 31 deletions
diff --git a/src/classes/com/sun/opengl/impl/Java2D.java b/src/classes/com/sun/opengl/impl/Java2D.java
index 3d14f3003..de3d477e3 100755
--- a/src/classes/com/sun/opengl/impl/Java2D.java
+++ b/src/classes/com/sun/opengl/impl/Java2D.java
@@ -412,11 +412,13 @@ public class Java2D {
// similar rather than keeping one share context in a global
// variable.
initializedJ2DFBOShareContext = true;
+ System.err.println("Starting initialization of J2D FBO share context");
invokeWithOGLSharedContextCurrent(gc, new Runnable() {
public void run() {
j2dFBOShareContext = GLDrawableFactory.getFactory().createExternalGLContext();
}
});
+ System.err.println("Ending initialization of J2D FBO share context");
}
}
}
diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java
index a78c3baf0..7a4b73351 100644
--- a/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java
+++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java
@@ -121,6 +121,9 @@ public class WindowsGLContext extends GLContextImpl {
if (hglrc == 0) {
throw new GLException("Unable to create OpenGL context for device context " + toHexString(drawable.getHDC()));
}
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getHDC()) + ", not yet sharing");
+ }
// Windows can set up sharing of display lists after creation time
WindowsGLContext other = (WindowsGLContext) GLContextShareSet.getShareContext(this);
long hglrc2 = 0;
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java
index a6a8b608d..b4b6b2c52 100644
--- a/src/classes/javax/media/opengl/GLJPanel.java
+++ b/src/classes/javax/media/opengl/GLJPanel.java
@@ -136,10 +136,6 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
private int[] alignment = new int[1];
// Implementation using Java2D OpenGL pipeline's back buffer
- private static boolean swingBufferPerWindow =
- Debug.isPropertyDefined("swing.bufferPerWindow") ?
- Debug.getBooleanProperty("swing.bufferPerWindow") :
- true;
private boolean oglPipelineEnabled =
Java2D.isOGLPipelineActive() &&
!Debug.isPropertyDefined("jogl.gljpanel.noogl");
diff --git a/src/classes/javax/media/opengl/Threading.java b/src/classes/javax/media/opengl/Threading.java
index 896e945d8..d3712c4c5 100755
--- a/src/classes/javax/media/opengl/Threading.java
+++ b/src/classes/javax/media/opengl/Threading.java
@@ -125,6 +125,9 @@ public class Threading {
private static final int AWT = 1;
private static final int WORKER = 2;
private static int mode;
+ // We need to know whether we're running on X11 platforms to change
+ // our behavior when the Java2D/JOGL bridge is active
+ private static boolean isX11;
static {
AccessController.doPrivileged(new PrivilegedAction() {
@@ -138,7 +141,9 @@ public class Threading {
// while holding the AWT lock. The optimization of
// makeCurrent / release calls isn't worth these stability
// problems.
- boolean isWindows = System.getProperty("os.name").startsWith("Windows");
+ String osName = System.getProperty("os.name");
+ boolean isWindows = osName.startsWith("Windows");
+ isX11 = !(isWindows || osName.startsWith("Mac OS"));
// int defaultMode = (isWindows ? WORKER : AWT);
int defaultMode = AWT;
mode = defaultMode;
@@ -205,24 +210,22 @@ public class Threading {
case AWT:
if (Java2D.isOGLPipelineActive()) {
// FIXME: ideally only the QFT would be considered to be the
- // "OpenGL thread", but we can not currently run all of JOGL's
- // OpenGL work on that thread. For now, run the GLJPanel's
- // Java2D/JOGL bridge on the QFT but everything else on the
- // EDT, except when we're already on the QFT.
+ // "OpenGL thread", but we can not currently run all of
+ // JOGL's OpenGL work on that thread. See the FIXME in
+ // invokeOnOpenGLThread.
return (Java2D.isQueueFlusherThread() ||
- EventQueue.isDispatchThread());
+ (isX11 && EventQueue.isDispatchThread()));
} else {
return EventQueue.isDispatchThread();
}
case WORKER:
if (Java2D.isOGLPipelineActive()) {
// FIXME: ideally only the QFT would be considered to be the
- // "OpenGL thread", but we can not currently run all of JOGL's
- // OpenGL work on that thread. For now, run the GLJPanel's
- // Java2D/JOGL bridge on the QFT but everything else on the
- // worker thread, except when we're already on the QFT.
+ // "OpenGL thread", but we can not currently run all of
+ // JOGL's OpenGL work on that thread. See the FIXME in
+ // invokeOnOpenGLThread.
return (Java2D.isQueueFlusherThread() ||
- GLWorkerThread.isWorkerThread());
+ (isX11 && GLWorkerThread.isWorkerThread()));
} else {
return GLWorkerThread.isWorkerThread();
}
@@ -252,22 +255,24 @@ public class Threading {
switch (mode) {
case AWT:
// FIXME: ideally should run all OpenGL work on the Java2D QFT
- // thread when it's enabled, but there are issues with this when
- // the GLJPanel is not using the Java2D bridge; would like to run
- // its OpenGL work on the QFT, but do the image drawing from the
- // EDT. Other issues still remain with the GLCanvas as well.
-
- // if (Java2D.isOGLPipelineActive()) {
- // Java2D.invokeWithOGLContextCurrent(null, r);
- // } else {
- try {
- EventQueue.invokeAndWait(r);
- } catch (InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (InterruptedException e) {
- throw new GLException(e);
- }
- // }
+ // thread when it's enabled, but unfortunately there are
+ // deadlock issues on X11 platforms when making our
+ // heavyweight OpenGL contexts current on the QFT because we
+ // perform the JAWT lock inside the makeCurrent()
+ // 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() && !isX11) {
+ Java2D.invokeWithOGLContextCurrent(null, r);
+ } else {
+ try {
+ EventQueue.invokeAndWait(r);
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (InterruptedException e) {
+ throw new GLException(e);
+ }
+ }
break;
case WORKER: