diff options
author | Sven Gothel <[email protected]> | 2014-01-12 07:27:55 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-12 07:27:55 +0100 |
commit | 071bdd6ce9f8c41ccecdbf8bc74f276ccd7ff651 (patch) | |
tree | 796192b477f64056079d05d4ddd0019af7dbdfd8 /src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | |
parent | cf75fbde9f7081bb253eff2bb8f36a39992352e1 (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/GLJPanel.java')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 20 |
1 files changed, 16 insertions, 4 deletions
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 .. |