diff options
4 files changed, 35 insertions, 15 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 78038500e..086a17362 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -380,6 +380,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void display() { if( !validateGLDrawable() ) { + if(DEBUG) { + System.err.println("Info: GLCanvas display - skipped GL render, drawable not valid yet"); + } return; // not yet available .. } maybeDoSingleThreadedWorkaround(displayOnEventDispatchThreadAction, @@ -740,11 +743,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - @Override + @Override public String toString() { - return "AWT-GLCanvas[ "+awtConfig+", "+((null!=drawable)?drawable.getClass().getName():"null-drawable")+"]"; + return "AWT-GLCanvas[Realized "+isRealized()+ + ",\n\t"+((null!=drawable)?drawable.getClass().getName():"null-drawable")+ + ",\n\tRealized "+isRealized()+ + ",\n\tFactory "+getFactory()+ + ",\n\thandle 0x"+Long.toHexString(getHandle())+ + ",\n\tDrawable size "+drawable.getWidth()+"x"+drawable.getHeight()+ + ",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + ",\n\tvisible "+isVisible()+ + ",\n\t"+awtConfig+"]"; } - + //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java index 61be51b8a..67f6fe4b8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java @@ -257,8 +257,9 @@ public abstract class JAWTWindow implements NativeWindow { } protected abstract Point getLocationOnScreenImpl(int x, int y); + @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("JAWT-Window["+ "windowHandle 0x"+Long.toHexString(getWindowHandle())+ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java index 9e0bebc9c..63f54e267 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java @@ -98,12 +98,10 @@ public class TestSharedContextListAWT extends UITestCase { SwingUtilities.invokeLater(new Runnable() { public void run() { frame.add(glCanvas); - frame.pack(); - frame.setSize(width, height); frame.setLocation(x, y); - frame.invalidate(); + frame.setSize(width, height); + frame.pack(); frame.setVisible(true); - frame.validate(); } }); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 40c1e0528..bbd53db9b 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -45,7 +45,7 @@ import javax.swing.JFrame; public class AWTRobotUtil { - public static int TIME_OUT = 2000; // 2s + public static int TIME_OUT = 1000; // 1s public static int ROBOT_DELAY = 50; // ms public static int POLL_DIVIDER = 20; // TO/20 @@ -354,16 +354,26 @@ public class AWTRobotUtil { */ public static boolean waitForRealized(Object obj, boolean realized) throws InterruptedException { int wait; - if(obj instanceof GLCanvas) { - GLCanvas comp = (GLCanvas) obj; - for (wait=0; wait<POLL_DIVIDER && realized != comp.isRealized(); wait++) { - Thread.sleep(TIME_OUT/POLL_DIVIDER); - } - } else if (obj instanceof Component) { + if (obj instanceof Component) { Component comp = (Component) obj; for (wait=0; wait<POLL_DIVIDER && realized != comp.isDisplayable(); wait++) { Thread.sleep(TIME_OUT/POLL_DIVIDER); } + // if GLCanvas, ensure it got also painted -> drawable.setRealized(true); + if(wait<POLL_DIVIDER && comp instanceof GLCanvas) { + GLCanvas glcanvas = (GLCanvas) comp; + for (wait=0; wait<POLL_DIVIDER && realized != glcanvas.isRealized(); wait++) { + Thread.sleep(TIME_OUT/POLL_DIVIDER); + } + if(wait>=POLL_DIVIDER) { + // for some reason GLCanvas hasn't been painted yet, force it! + System.err.println("XXX: FORCE REPAINT - canvas: "+glcanvas); + glcanvas.repaint(); + for (wait=0; wait<POLL_DIVIDER && realized != glcanvas.isRealized(); wait++) { + Thread.sleep(TIME_OUT/POLL_DIVIDER); + } + } + } } else if(obj instanceof com.jogamp.newt.Window) { com.jogamp.newt.Window win = (com.jogamp.newt.Window) obj; for (wait=0; wait<POLL_DIVIDER && realized != win.isNativeValid(); wait++) { |