summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-10-29 03:58:33 +0200
committerSven Gothel <[email protected]>2010-10-29 03:58:33 +0200
commit7e606ef39fa9d73cc7306cc0027989bc7704708d (patch)
tree9dad08525d8bc33195194a010dc31f3ea4a267c8 /src/jogl/classes/javax/media/opengl
parent27530775e22bd04242a91a8f12f8c6c930c398b9 (diff)
Proper X11 Display Closing
X11Util: Removed TLS semantics, since TLS name -> dpy mapping is erroneous at this point. Added lists for open connections (for optional later shutdown). AbstractGraphicsDevice interface and implementations: Adding 'close()' method allowing native implementations the ability to close the native resource, ie X11GraphicsDevice. This becomes necessary for 'on the fly' created X11 Display connections, ie in X11AWTGLXGraphicsConfigurationFactory, which enables closing. Utilize 'close' call in use cases: GLCanvas, GLJPanel and AWTCanvas. Remove active X11 Display creation in X11JAWTWindow, as a last resort, use the X11SunJDKReflection method. Used for reference only, not active rendering etc, mostly for on the fly AWT parenting in NewtFactoryAWT. However, these 'on the fly' references are erroneous and should be remodelled, ie passice and active X11GraphicsDevice's ..
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java58
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java40
2 files changed, 68 insertions, 30 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index c165a4833..d2a20f467 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -49,6 +49,7 @@ import com.jogamp.opengl.impl.*;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
+import java.awt.EventQueue;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
@@ -328,6 +329,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
// Workaround for termination issues with applets --
// sun.applet.AppletPanel should probably be performing the
// remove() call on the EDT rather than on its own thread
+ // Hint: User should run remove from EDT.
if (ThreadingImpl.isAWTMode() &&
Thread.holdsLock(getTreeLock())) {
// The user really should not be invoking remove() from this
@@ -347,6 +349,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
animator.resume();
}
}
+ if(!regenerate) {
+ disposeAbstractGraphicsDeviceAction.run();
+ }
if(DEBUG) {
System.err.println("dispose("+regenerate+") - stop");
@@ -401,6 +406,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
<B>Overrides:</B>
<DL><DD><CODE>addNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void addNotify() {
+ if(DEBUG) {
+ Exception ex1 = new Exception(Thread.currentThread().getName()+" - Info: addNotify - start");
+ ex1.printStackTrace();
+ }
super.addNotify();
if (!Beans.isDesignTime()) {
disableBackgroundErase();
@@ -419,8 +428,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
try {
awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
if(DEBUG) {
- Exception e = new Exception("Info: Created Config: "+awtConfig);
- e.printStackTrace();
+ System.err.println(Thread.currentThread().getName()+" - Created Config: "+awtConfig);
}
if(null!=awtConfig) {
// update ..
@@ -444,21 +452,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
if(DEBUG) {
- System.err.println("Created Drawable: "+drawable);
+ System.err.println(Thread.currentThread().getName()+" - Created Drawable: "+drawable);
}
}
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - Info: addNotify - end");
+ }
}
- /** Overridden to track when this component is removed from a
+ /** <p>Overridden to track when this component is removed from a
container. Subclasses which override this method must call
super.removeNotify() in their removeNotify() method in order to
- function properly. <P>
-
+ function properly. </p>
+ <p>User shall not call this method outside of EDT, read the AWT/Swing specs
+ about this.</p>
<B>Overrides:</B>
<DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void removeNotify() {
if(DEBUG) {
- Exception ex1 = new Exception("Info: removeNotify - start");
+ Exception ex1 = new Exception(Thread.currentThread().getName()+" - Info: removeNotify - start");
ex1.printStackTrace();
}
@@ -473,7 +485,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
if(DEBUG) {
- System.err.println("Info: removeNotify - end");
+ System.err.println(Thread.currentThread().getName()+" - Info: removeNotify - end");
}
}
@@ -609,14 +621,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
- private boolean disposeRegenerate;
- private DisposeAction disposeAction = new DisposeAction(this);
-
class DisposeAction implements Runnable {
- private GLCanvas canvas;
- public DisposeAction(GLCanvas canvas) {
- this.canvas = canvas;
- }
public void run() {
drawableHelper.dispose(GLCanvas.this);
@@ -632,7 +637,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
if(disposeRegenerate) {
// recreate GLDrawable to reflect it's new graphics configuration
- drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(canvas, awtConfig));
+ drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(GLCanvas.this, awtConfig));
if(DEBUG) {
System.err.println("GLCanvas.dispose(true): new drawable: "+drawable);
}
@@ -643,6 +648,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
}
+ private boolean disposeRegenerate;
+ private DisposeAction disposeAction = new DisposeAction();
private DisposeOnEventDispatchThreadAction disposeOnEventDispatchThreadAction =
new DisposeOnEventDispatchThreadAction();
@@ -653,6 +660,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
+ class DisposeAbstractGraphicsDeviceAction implements Runnable {
+ public void run() {
+ AbstractGraphicsConfiguration aconfig = (null!=awtConfig) ? awtConfig.getNativeGraphicsConfiguration() : null;
+ AbstractGraphicsScreen ascreen = (null!=aconfig) ? aconfig.getScreen() : null;
+ AbstractGraphicsDevice adevice = (null!=ascreen) ? ascreen.getDevice() : null;
+ if(null!=adevice) {
+ String adeviceMsg=null;
+ if(DEBUG) {
+ adeviceMsg = adevice.toString();
+ }
+ boolean closed = adevice.close();
+ if(DEBUG) {
+ System.err.println("GLCanvas.dispose(false): closed GraphicsDevice: "+adeviceMsg+", result: "+closed);
+ }
+ }
+ }
+ }
+ DisposeAbstractGraphicsDeviceAction disposeAbstractGraphicsDeviceAction = new DisposeAbstractGraphicsDeviceAction();
+
class InitAction implements Runnable {
public void run() {
drawableHelper.init(GLCanvas.this);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 10aeefaf5..b9bbf71c2 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -631,22 +631,34 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
private DisposeAction disposeAction = new DisposeAction();
class DisposeAction implements Runnable {
- public void run() {
- updater.dispose(GLJPanel.this);
+ public void run() {
+ updater.dispose(GLJPanel.this);
- if(null!=disposeContext) {
- disposeContext.destroy();
- disposeContext=null;
- }
- if(null!=disposeDrawable) {
- disposeDrawable.setRealized(false);
- }
- if(disposeRegenerate && null!=disposeDrawable) {
- disposeDrawable.setRealized(true);
- disposeContext = (GLContextImpl) disposeDrawable.createContext(shareWith);
- disposeContext.setSynchronized(true);
+ if (null != disposeContext) {
+ disposeContext.destroy();
+ disposeContext = null;
+ }
+ if (null != disposeDrawable) {
+ disposeDrawable.setRealized(false);
+ }
+ if (null != disposeDrawable) {
+ if (disposeRegenerate) {
+ disposeDrawable.setRealized(true);
+ disposeContext = (GLContextImpl) disposeDrawable.createContext(shareWith);
+ disposeContext.setSynchronized(true);
+ } else {
+ AbstractGraphicsDevice adevice = disposeDrawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+ String adeviceMsg=null;
+ if(DEBUG) {
+ adeviceMsg = adevice.toString();
+ }
+ boolean closed = adevice.close();
+ if (DEBUG) {
+ System.err.println("GLJPanel.dispose(false): closed GraphicsDevice: " + adeviceMsg + ", result: " + closed);
+ }
+ }
+ }
}
- }
}
private DisposeOnEventDispatchThreadAction disposeOnEventDispatchThreadAction =