aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/awt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-12 07:27:55 +0100
committerSven Gothel <[email protected]>2014-01-12 07:27:55 +0100
commit071bdd6ce9f8c41ccecdbf8bc74f276ccd7ff651 (patch)
tree796192b477f64056079d05d4ddd0019af7dbdfd8 /src/jogl/classes/javax/media/opengl/awt
parentcf75fbde9f7081bb253eff2bb8f36a39992352e1 (diff)
Bug 937 - JAWTWindow: Unsatisfying Visibility Computation
Simplify JAWTComponentListener's HierarchyListener: - Don't interfere w/ Component's visibility anymore! This shall reduce sideeffects. Utilize 'isShowing' in each Component specialization, i.e. GLCanvas. - On SHOWING_CHANGED if a parent caused a change of the tracked components showing state, propagate it to the offscreen-layer! - Remove all other complicated states! GLCanvas, GLJPanel: - Instead of 'isVisible()' use 'showing state', since only the 'showing state' reflects 'true' visibility throughout the hierarchy. - Add HierarchyListener and track volatile showing state to be used instead of 'isVisible'. Using a cached showing state is more efficient than quering 'isShowing()' all the time! NewtCanvasAWT: - Use 'isShowing()' instead of 'isVisible(), see above
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java30
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java20
2 files changed, 33 insertions, 17 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 0bc002f8e..7ea216dd9 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -52,6 +52,8 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Rectangle2D;
import java.awt.EventQueue;
@@ -173,6 +175,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
private final GraphicsDevice device;
private boolean shallUseOffscreenLayer = false;
+ private volatile boolean isShowing;
+ private final HierarchyListener hierarchyListener = new HierarchyListener() {
+ @Override
+ public void hierarchyChanged(HierarchyEvent e) {
+ isShowing = GLCanvas.this.isShowing();
+ }
+ };
+
private final AWTWindowClosingProtocol awtWindowClosingProtocol =
new AWTWindowClosingProtocol(this, new Runnable() {
@Override
@@ -294,6 +304,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
helper.setSharedContext(null, shareWith);
}
this.device = device;
+
+ this.addHierarchyListener(hierarchyListener);
+ this.isShowing = isShowing();
}
@Override
@@ -524,7 +537,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
return; // not yet available ..
}
- if( isVisible() && !printActive ) {
+ if( isShowing && !printActive ) {
Threading.invoke(true, displayOnEDTAction, getTreeLock());
}
}
@@ -583,15 +596,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
}
- @Override
- public void setVisible(boolean b) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: setVisible("+b+")");
- Thread.dumpStack();
- }
- super.setVisible(b);
- }
-
/** Overridden to track when this component is added to a container.
Subclasses which override this method must call
super.addNotify() in their addNotify() method in order to
@@ -814,9 +818,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printActive = false;
return; // not yet available ..
}
- if( !isVisible() ) {
+ if( !isShowing ) {
if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable visible");
+ System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable valid, canvas not showing");
}
printActive = false;
return; // not yet available ..
@@ -1148,7 +1152,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
",\n\thandle 0x"+Long.toHexString(getHandle())+
",\n\tDrawable size "+dw+"x"+dh+
",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
- ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+
+ ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+", showing "+isShowing+
",\n\t"+awtConfig+"]";
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index a71b47c64..f7200186b 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -48,6 +48,8 @@ import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
@@ -265,6 +267,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK;
}
+ private volatile boolean isShowing;
+ private final HierarchyListener hierarchyListener = new HierarchyListener() {
+ @Override
+ public void hierarchyChanged(HierarchyEvent e) {
+ isShowing = GLJPanel.this.isShowing();
+ }
+ };
+
private final AWTWindowClosingProtocol awtWindowClosingProtocol =
new AWTWindowClosingProtocol(this, new Runnable() {
@Override
@@ -346,6 +356,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
helper.setSharedContext(null, shareWith);
}
this.setFocusable(true); // allow keyboard input!
+ this.addHierarchyListener(hierarchyListener);
+ this.isShowing = isShowing();
}
/**
@@ -418,7 +430,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public void display() {
- if( isVisible() ) {
+ if( isShowing ) {
if (EventQueue.isDispatchThread()) {
// Want display() to be synchronous, so call paintImmediately()
paintImmediately(0, 0, getWidth(), getHeight());
@@ -521,7 +533,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
sendReshape = handleReshape();
}
- if( isVisible() ) {
+ if( isShowing ) {
updater.setGraphics(g);
backend.doPaintComponent(g);
}
@@ -608,9 +620,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
printActive = false;
return; // not yet available ..
}
- if( !isVisible() ) {
+ if( !isShowing ) {
if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible");
+ System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable valid, panel not showing");
}
printActive = false;
return; // not yet available ..