aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-13 08:15:21 +0200
committerSven Gothel <[email protected]>2013-04-13 08:15:21 +0200
commit9d78ea65a6bf1064887bc7524c01a689a1fc2a5c (patch)
treefdd85fcce8cc5d55898b93ee13a25779b4cda215
parent5606dd12f8086b506f33030072af5095a5871f9c (diff)
NEWT/AWT: Fix 'AWT driver' to work w/ OSX CALayer ; WindowImpl: 'Object getWrappedWindow()' -> 'NativeSurface getWrappedSurface()'
WindowImpl: 'Object getWrappedWindow()' -> 'NativeSurface getWrappedSurface()' - AWT driver itself instantiates the JAWTWindow for eager initialization at createNative(). Fix 'AWT driver' to work w/ OSX CALayer - See above - size reconfig changed to ease OSX CALayer, i.e. set frame's size if already visible reducing CALayer artefacts.
-rwxr-xr-xmake/scripts/tests.sh6
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java14
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java10
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java42
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java101
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java68
7 files changed, 157 insertions, 86 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 35d669a47..a10be0db9 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -171,7 +171,7 @@ function jrun() {
#D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext"
#D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen"
#D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window"
- D_ARGS="-Dnewt.debug.Window.KeyEvent"
+ #D_ARGS="-Dnewt.debug.Window.KeyEvent"
#D_ARGS="-Dnewt.debug.Window.MouseEvent"
#D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent"
#D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all"
@@ -290,7 +290,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $*
-#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $*
+testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $*
@@ -370,7 +370,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $*
-testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $*
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index a6c655915..de62747be 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -40,7 +40,6 @@ import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.SurfaceUpdatedListener;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
@@ -472,17 +471,16 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
if( ( null != context ) ) {
throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this);
}
- final NativeWindow nw;
- if (window.getWrappedWindow() != null) {
- nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getPrivateGraphicsConfiguration());
- } else {
- nw = window;
+ final NativeSurface ns;
+ {
+ final NativeSurface wrapped_ns = window.getWrappedSurface();
+ ns = null != wrapped_ns ? wrapped_ns : window;
}
- final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) nw.getGraphicsConfiguration().getChosenCapabilities();
+ final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities();
if(null==factory) {
factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
}
- drawable = (GLDrawableImpl) factory.createGLDrawable(nw);
+ drawable = (GLDrawableImpl) factory.createGLDrawable(ns);
drawable.setRealized(true);
if( !GLWindow.this.pushGLEventListenerState() ) {
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 01a58a305..bfb450f68 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -1562,9 +1562,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return old;
}
- /** If this Window actually wraps one from another toolkit such as
- the AWT, this will return a non-null value. */
- public Object getWrappedWindow() {
+ /**
+ * If this Window actually wraps a {@link NativeSurface} from another instance or toolkit,
+ * it will return such reference. Otherwise returns null.
+ */
+ public NativeSurface getWrappedSurface() {
return null;
}
@@ -1598,7 +1600,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
"\n, Visible "+isVisible()+", focus "+hasFocus()+
"\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+
"\n, AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+
- "\n, WrappedWindow "+getWrappedWindow()+
+ "\n, WrappedSurface "+getWrappedSurface()+
"\n, ChildWindows "+childWindows.size());
sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedHelper.size()+" [");
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
index 17eb6a2fb..85cb655d7 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
@@ -47,13 +47,15 @@ import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.VisualIDHolder;
-
import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
+import com.jogamp.nativewindow.awt.JAWTWindow;
import com.jogamp.newt.Window;
@SuppressWarnings("serial")
@@ -61,17 +63,15 @@ public class AWTCanvas extends Canvas {
private GraphicsDevice device;
private GraphicsConfiguration chosen;
private AWTGraphicsConfiguration awtConfig;
-
- private WindowDriver newtWindowImpl;
+ private volatile JAWTWindow jawtWindow=null; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle
private CapabilitiesChooser chooser=null;
private CapabilitiesImmutable capabilities;
private boolean displayConfigChanged=false;
- public AWTCanvas(WindowDriver newtWindowImpl, CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) {
+ public AWTCanvas(CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) {
super();
- this.newtWindowImpl = newtWindowImpl;
if(null==capabilities) {
throw new NativeWindowException("Capabilities null");
}
@@ -89,7 +89,7 @@ public class AWTCanvas extends Canvas {
*/
@Override
public void update(Graphics g) {
- paint(g);
+ // paint(g);
}
/** Overridden to cause OpenGL rendering to be performed during
@@ -99,7 +99,6 @@ public class AWTCanvas extends Canvas {
*/
@Override
public void paint(Graphics g) {
- newtWindowImpl.windowRepaint(0, 0, getWidth(), getHeight());
}
public boolean hasDeviceChanged() {
@@ -120,8 +119,7 @@ public class AWTCanvas extends Canvas {
*/
awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, chooser, device);
if(Window.DEBUG_IMPLEMENTATION) {
- Exception e = new Exception("Info: Created Config: "+awtConfig);
- e.printStackTrace();
+ System.err.println(getThreadName()+": AWTCanvas.addNotify.0: Created Config: "+awtConfig);
}
if(null==awtConfig) {
throw new NativeWindowException("Error: NULL AWTGraphicsConfiguration");
@@ -137,12 +135,27 @@ public class AWTCanvas extends Canvas {
// after native peer is valid: Windows
disableBackgroundErase();
+ {
+ jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
+ // trigger initialization cycle
+ jawtWindow.lockSurface();
+ jawtWindow.unlockSurface();
+ }
+
GraphicsConfiguration gc = super.getGraphicsConfiguration();
if(null!=gc) {
device = gc.getDevice();
}
+ if(Window.DEBUG_IMPLEMENTATION) {
+ System.err.println(getThreadName()+": AWTCanvas.addNotify.X");
+ }
}
+ public NativeSurface getNativeSurface() {
+ final JAWTWindow _jawtWindow = jawtWindow;
+ return (null != _jawtWindow) ? _jawtWindow : null;
+ }
+
public void removeNotify() {
try {
dispose();
@@ -152,6 +165,13 @@ public class AWTCanvas extends Canvas {
}
private void dispose() {
+ if( null != jawtWindow ) {
+ jawtWindow.destroy();
+ if(Window.DEBUG_IMPLEMENTATION) {
+ System.err.println(getThreadName()+": AWTCanvas.disposeJAWTWindowAndAWTDeviceOnEDT(): post JAWTWindow: "+jawtWindow);
+ }
+ jawtWindow=null;
+ }
if(null != awtConfig) {
AbstractGraphicsDevice adevice = awtConfig.getNativeGraphicsConfiguration().getScreen().getDevice();
String adeviceMsg=null;
@@ -160,10 +180,12 @@ public class AWTCanvas extends Canvas {
}
boolean closed = adevice.close();
if(Window.DEBUG_IMPLEMENTATION) {
- System.err.println("AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed);
+ System.err.println(getThreadName()+": AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed);
}
}
}
+
+ private String getThreadName() { return Thread.currentThread().getName(); }
/**
* Overridden to choose a GraphicsConfiguration on a parent container's
diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java
index 0172309fb..cc678e4ef 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java
@@ -40,6 +40,7 @@ import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Insets;
+import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Point;
@@ -111,31 +112,38 @@ public class WindowDriver extends WindowImpl {
}
container.setLayout(new BorderLayout());
- canvas = new AWTCanvas(this, capsRequested, WindowDriver.this.capabilitiesChooser);
+ if( null == canvas ) {
+ canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser);
- // canvas.addComponentListener(listener);
- container.add(canvas, BorderLayout.CENTER);
+ // canvas.addComponentListener(listener);
+ container.add(canvas, BorderLayout.CENTER);
- // via EDT ..
- new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here
- new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here
+ // via EDT ..
+ new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here
+ new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here
- // direct w/o EDT
- new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here
+ // direct w/o EDT
+ new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here
+ }
reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true));
// throws exception if failed ..
- setWindowHandle(1); // just a marker ..
+ final NativeSurface ns = canvas.getNativeSurface();
+ if( null != ns ) {
+ setGraphicsConfiguration( canvas.getAWTGraphicsConfiguration() );
+ setWindowHandle( ns.getSurfaceHandle() );
+ }
}
protected void closeNativeImpl() {
- setWindowHandle(0); // just a marker ..
+ setWindowHandle(0);
if(null!=container) {
container.setVisible(false);
container.remove(canvas);
container.setEnabled(false);
canvas.setEnabled(false);
+ canvas = null;
}
if(owningFrame && null!=frame) {
frame.dispose();
@@ -172,6 +180,10 @@ public class WindowDriver extends WindowImpl {
}
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("AWTWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+
+ getReconfigureFlagsAsString(null, flags));
+ }
if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) {
if(!container.isDisplayable()) {
frame.setUndecorated(isUndecorated());
@@ -182,26 +194,44 @@ public class WindowDriver extends WindowImpl {
}
}
- final Dimension szClient = new Dimension(width, height);
- canvas.setMinimumSize(szClient);
- canvas.setPreferredSize(szClient);
- canvas.setSize(szClient);
- if(DEBUG_IMPLEMENTATION) {
+ if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
+ if( 0 != ( FLAG_IS_VISIBLE & flags) ) {
+ final Dimension szClient = new Dimension(width, height);
+ canvas.setMinimumSize(szClient);
+ canvas.setPreferredSize(szClient);
+ if(DEBUG_IMPLEMENTATION) {
+ final Insets insets = container.getInsets();
+ final Dimension szContainer = new Dimension(width + insets.left + insets.right,
+ height + insets.top + insets.bottom);
+ System.err.println(getThreadName()+": AWTWindow initial size: szClient "+szClient+", szCont "+szContainer+", insets "+insets);
+ }
+ canvas.setSize(szClient);
+ if(null != frame) {
+ frame.pack();
+ } else {
+ container.validate();
+ }
+ container.setVisible( true );
+ defineSize(width, height); // we are on AWT-EDT .. change values immediately
+ } else {
+ container.setVisible( false );
+ }
+ } else if( canvas.getWidth() != width || canvas.getHeight() != height ) {
final Insets insets = container.getInsets();
final Dimension szContainer = new Dimension(width + insets.left + insets.right,
height + insets.top + insets.bottom);
- System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets);
- }
-
- if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
- if(null != frame) {
- frame.pack();
+ if(DEBUG_IMPLEMENTATION) {
+ final Dimension szClient = new Dimension(width, height);
+ System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets);
}
- container.validate();
- container.setVisible(0 != ( FLAG_IS_VISIBLE & flags));
+ container.setSize(szContainer);
+ container.validate();
+ defineSize(width, height); // we are on AWT-EDT .. change values immediately
}
- container.setLocation(x, y);
+ if( container.getX() != x || container.getY() != y ) {
+ container.setLocation(x, y);
+ }
if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
if( 0 != ( FLAG_IS_VISIBLE & flags ) ) {
@@ -215,12 +245,6 @@ public class WindowDriver extends WindowImpl {
}
}
visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags));
- } else {
- container.invalidate();
- if(null != frame) {
- frame.pack();
- }
- container.validate();
}
return true;
@@ -233,8 +257,8 @@ public class WindowDriver extends WindowImpl {
}
@Override
- public Object getWrappedWindow() {
- return canvas;
+ public NativeSurface getWrappedSurface() {
+ return ( null != canvas ) ? canvas.getNativeSurface() : null;
}
class LocalWindowListener implements com.jogamp.newt.event.WindowListener {
@@ -247,7 +271,11 @@ public class WindowDriver extends WindowImpl {
@Override
public void windowResized(com.jogamp.newt.event.WindowEvent e) {
if(null!=canvas) {
- WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), false);
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("Window Resized: "+canvas);
+ }
+ WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), true);
+ WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight());
}
}
@Override
@@ -268,7 +296,12 @@ public class WindowDriver extends WindowImpl {
}
@Override
public void windowRepaint(WindowUpdateEvent e) {
- WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight());
+ if(null!=canvas) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("Window Repaint: "+canvas);
+ }
+ WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight());
+ }
}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 5e523c780..9bbbbce05 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -270,7 +270,7 @@ public class GearsES2 implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GLAnimatorControl anim = drawable.getAnimator();
if( verbose && ( null == anim || !anim.isAnimating() ) ) {
- System.err.println(Thread.currentThread()+" GearsES2.display"+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
+ System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
}
// Turn the gears' teeth
if(doRotate) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java
index cc20cc27e..0b907d5ee 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java
@@ -34,6 +34,7 @@ import javax.media.opengl.*;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
@@ -49,6 +50,9 @@ import org.junit.Test;
public class TestGearsNewtAWTWrapper extends UITestCase {
static GLProfile glp;
static int width, height;
+ static boolean useAnimator = true;
+ static boolean doResizeTest = true;
+ static long duration = 500; // ms
@BeforeClass
public static void initClass() {
@@ -73,39 +77,50 @@ public class TestGearsNewtAWTWrapper extends UITestCase {
glWindow.addGLEventListener(new GearsES2(1));
- Animator animator = new Animator(glWindow);
+ Animator animator = useAnimator ? new Animator(glWindow) : null;
QuitAdapter quitAdapter = new QuitAdapter();
glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
+ if( useAnimator ) {
+ animator.start();
+ }
+
int div = 3;
glWindow.setSize(width/div, height/div);
glWindow.setVisible(true);
- glWindow.display();
- Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(),
- AWTRobotUtil.waitForSize(glWindow, width/div, height/div));
-
- div = 2;
- glWindow.setSize(width/div, height/div);
- glWindow.display();
- Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(),
- AWTRobotUtil.waitForSize(glWindow, width/div, height/div));
-
- div = 1;
- glWindow.setSize(width/div, height/div);
- glWindow.display();
- Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(),
- AWTRobotUtil.waitForSize(glWindow, width/div, height/div));
-
- animator.setUpdateFPSFrames(1, null);
- animator.start();
+ if( doResizeTest ) {
+ glWindow.display();
+ Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(),
+ AWTRobotUtil.waitForSize(glWindow, width/div, height/div));
+ Thread.sleep(600);
+
+ div = 2;
+ glWindow.setSize(width/div, height/div);
+ glWindow.display();
+ Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(),
+ AWTRobotUtil.waitForSize(glWindow, width/div, height/div));
+ Thread.sleep(600);
+
+ div = 1;
+ glWindow.setSize(width/div, height/div);
+ glWindow.display();
+ Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(),
+ AWTRobotUtil.waitForSize(glWindow, width/div, height/div));
+ Thread.sleep(600);
+ }
- while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1-t0<duration) {
Thread.sleep(100);
+ t1 = System.currentTimeMillis();
}
- animator.stop();
+ if( useAnimator ) {
+ animator.stop();
+ }
glWindow.destroy();
}
@@ -115,17 +130,18 @@ public class TestGearsNewtAWTWrapper extends UITestCase {
runTestGL(caps);
}
- static long duration = 500; // ms
-
public static void main(String args[]) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
- try {
- duration = Integer.parseInt(args[i]);
- } catch (Exception ex) { ex.printStackTrace(); }
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-noanim")) {
+ useAnimator = false;
+ } else if(args[i].equals("-noresize")) {
+ doResizeTest = false;
}
}
+ System.err.println("useAnimator "+useAnimator);
org.junit.runner.JUnitCore.main(TestGearsNewtAWTWrapper.class.getName());
}
}