From ce969bd565b0a6e72632630c88c4135d0410bf0f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 1 Oct 2014 00:36:09 +0200 Subject: Bug 1081: Fix GLJPanel Regression: Honor pre-init reshape-size at initializeBackendImpl() Commit 84f367a73c5b16dcebfd877e82e1c2cb90ae74ce removed utilization of reshape-size in case panel-size is valid, even if a reshape event happened in between: - addNotify - paintComponent initializeBackendImpl() includes now uses reshape-size IFF handleReshape is set. Before it was using reshape-size only if panel-size was invalid. TestAWT03GLJPanelRecreate01 covers this issue. --- .../classes/javax/media/opengl/awt/GLJPanel.java | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/jogl') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 126513ec7..01e13e545 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -78,6 +78,7 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLFBODrawable; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.GLSharedContextSetter; @@ -540,12 +541,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing _lock.lock(); try { if( !isInitialized ) { - handleReshape = false; initializeBackendImpl(); } if (!isInitialized || printActive) { - return; + return; } // NOTE: must do this when the context is not current as it may @@ -554,13 +554,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // current if( !printActive ) { if ( handleReshape ) { - handleReshape = false; - sendReshape = handleReshape(); + handleReshape = false; + sendReshape = handleReshape(); } if( isShowing ) { - updater.setGraphics(g); - backend.doPaintComponent(g); + updater.setGraphics(g); + backend.doPaintComponent(g); } } } finally { @@ -1295,23 +1295,24 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private boolean initializeBackendImpl() { synchronized(initSync) { if( !isInitialized ) { - if ( 0 >= panelWidth || 0 >= panelHeight ) { - // See whether we have a non-zero size yet and can go ahead with - // initialization - if (0 >= reshapeWidth || 0 >= reshapeHeight ) { - return false; - } - + if( handleReshape ) { + panelWidth = reshapeWidth; + panelHeight = reshapeHeight; + handleReshape = false; if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " + + System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend.1: " + panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr() + " -> " + reshapeWidth+"x"+reshapeHeight+" @ scale "+getPixelScaleStr()); } - // Pull down reshapeWidth and reshapeHeight into panelWidth and - // panelHeight eagerly in order to complete initialization, and - // force a reshape later - panelWidth = reshapeWidth; - panelHeight = reshapeHeight; + } else { + if (DEBUG) { + System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend.0: " + + panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr()); + } + } + + if ( 0 >= panelWidth || 0 >= panelHeight ) { + return false; } if ( null == backend ) { -- cgit v1.2.3