aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java40
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java13
4 files changed, 44 insertions, 14 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 379d9cdfe..f86a6a347 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -799,8 +799,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
sendReshape = false; // clear reshape flag
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT);
- sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
- display();
}
private final Runnable releasePrintOnEDT = new Runnable() {
@Override
@@ -819,7 +817,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
printAnimator.add(GLCanvas.this);
printAnimator = null;
}
+ sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
printActive = false;
+ display();
}
};
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index c639da367..01270dd4f 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -434,14 +434,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// involve destroying the pbuffer (current context) and
// re-creating it -- tricky to do properly while the context is
// current
- if (handleReshape) {
- handleReshape = false;
- sendReshape = handleReshape();
- }
-
- if( isVisible() && !printActive ) {
- updater.setGraphics(g);
- backend.doPaintComponent(g);
+ if( !printActive ) {
+ if (handleReshape) {
+ handleReshape = false;
+ sendReshape = handleReshape();
+ }
+
+ if( isVisible() ) {
+ updater.setGraphics(g);
+ backend.doPaintComponent(g);
+ }
}
}
@@ -578,10 +580,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
sendReshape = false; // clear reshape flag
handleReshape = false; // ditto
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT);
- sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
- handleReshape = true; // ditto
- display();
}
+
private final Runnable releasePrintOnEDT = new Runnable() {
@Override
public void run() {
@@ -599,7 +599,22 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
printAnimator.add(GLJPanel.this);
printAnimator = null;
}
+
+ // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
+ final int awtWidth = GLJPanel.this.getWidth();
+ final int awtHeight= GLJPanel.this.getHeight();
+ if( panelWidth != awtWidth || panelHeight != awtHeight ) {
+ if ( true || DEBUG ) {
+ System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: reshape " +panelWidth+"x"+panelHeight + " -> " + awtWidth+"x"+awtHeight);
+ }
+ reshapeWidth = awtWidth;
+ reshapeHeight = awtHeight;
+ handleReshape = true; // complete resize, sendReshape will be set later
+ } else {
+ sendReshape = true; // only GL reshape
+ }
printActive = false;
+ display();
}
};
@@ -1415,6 +1430,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight);
}
}
+ if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) {
+ throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName());
+ }
final IntBuffer readBackInts;
if( !flipVertical || null != glslTextureRaster ) {
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index b069daacd..55f5f0533 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -546,7 +546,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
// sendReshape = false; // clear reshape flag
AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT);
newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
-
}
private final Runnable releasePrintOnEDT = new Runnable() {
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java
index 8393cf978..1ec748805 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java
@@ -177,6 +177,8 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
}
}
+ static final boolean resizeAfterSetupPrint = false;
+
private void doPrintImpl(final PrintableBase printable) {
final double scaleGLMatXY = 72.0 / printable.dpi;
System.err.println("PRINTable: "+printable.getClass().getSimpleName());
@@ -187,7 +189,18 @@ public abstract class TiledPrintingAWTBase extends UITestCase {
AWTEDTExecutor.singleton.invoke(true, new Runnable() {
public void run() {
try {
+ final int w = printable.cont.getWidth();
+ final int h = printable.cont.getHeight();
+ if( resizeAfterSetupPrint ) {
+ printable.cont.setSize(w+64, h+64);
+ printable.cont.validate();
+ }
printable.job.print();
+ if( resizeAfterSetupPrint ) {
+ printable.cont.repaint();
+ printable.cont.setSize(w, h);
+ printable.cont.validate();
+ }
} catch (PrinterException ex) {
ex.printStackTrace();
}