diff options
author | Sven Gothel <[email protected]> | 2015-09-15 07:54:07 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-09-15 07:54:07 +0200 |
commit | 9c23064a6df1e3ef66a715759ee801a80ef516bd (patch) | |
tree | 8d86a84d204ba418efda4f801213e9e1c2221a83 | |
parent | 68c8e39fa8d6e700f0a99241c1a01a435b7f6284 (diff) |
Bug 1211: Adopt changes to unit test from commit 68c8e39fa8d6e700f0a99241c1a01a435b7f6284
48 files changed, 167 insertions, 678 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index db5b42b03..bbb926bcc 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -470,7 +470,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.CrossFadePlayer $* @@ -630,7 +630,7 @@ function testawtswt() { #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.TestBug1211IRQ00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestBug1211IRQ00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index e4fabbbcc..eff2aae49 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -36,6 +36,7 @@ import com.jogamp.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -90,7 +91,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { public void mousePressed(final MouseEvent e) { if( e.getPointerCount() == 3 ) { Log.d(TAG, "MemoryHog"); - new Thread(new Runnable() { + new InterruptSource.Thread(null, new Runnable() { public void run() { final ArrayList<Buffer> buffers = new ArrayList<Buffer>(); while(true) { diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java index 89d28c08d..7430dcd38 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java @@ -27,7 +27,7 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.awt.GLCanvas; import com.jogamp.opengl.glu.GLU; - +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; @@ -98,7 +98,7 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable { } public void start() { - thread = new Thread(this, "Animation Thread"); + thread = new InterruptSource.Thread(null, this, "Animation Thread"); thread.start(); } diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java index 5019391ad..b31a5f410 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java @@ -27,7 +27,7 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.awt.GLCanvas; import com.jogamp.opengl.glu.GLU; - +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; @@ -100,7 +100,7 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable { } public void start() { - thread = new Thread(this, "Animation Thread"); + thread = new InterruptSource.Thread(null, this, "Animation Thread"); thread.start(); } diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java index 1228f1453..d0e4448cc 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java @@ -20,7 +20,8 @@ import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; - +import com.jogamp.common.util.InterruptSource; +import com.jogamp.junit.util.JunitTracer; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; @@ -82,7 +83,7 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable { public void start() { initDraw(); - thread = new Thread(this, "Animation Thread"); + thread = new InterruptSource.Thread(null, this, "Animation Thread"); thread.start(); } @@ -219,7 +220,7 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable { System.err.println("swapInterval "+SWAP_INTERVAL); System.err.println("exclusiveContext "+USE_ECT); if(waitForKey) { - UITestCase.waitForKey("Start"); + JunitTracer.waitForKey("Start"); } final GraphicsEnvironment environment = diff --git a/src/test/com/jogamp/opengl/test/bugs/Issue344Base.java b/src/test/com/jogamp/opengl/test/bugs/Issue344Base.java index 184a2ef0f..7532ca6db 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Issue344Base.java +++ b/src/test/com/jogamp/opengl/test/bugs/Issue344Base.java @@ -6,6 +6,7 @@ import java.awt.Frame; import java.awt.event.*; import java.awt.geom.*; +import com.jogamp.common.util.InterruptSource; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLAutoDrawable; @@ -49,7 +50,7 @@ public abstract class Issue344Base implements GLEventListener frame.setSize(512, 512); frame.addWindowListener(new WindowAdapter() { public void windowClosing(final WindowEvent e) { - new Thread(new Runnable() { + new InterruptSource.Thread(null, new Runnable() { public void run() { System.exit(0); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index 4bb72bbd2..3f5c5229e 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -16,6 +16,7 @@ import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.GLRunnable; import com.jogamp.common.net.Uri; +import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; @@ -354,7 +355,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(final MouseEvent e) { - new Thread() { + new InterruptSource.Thread() { public void run() { if( null != cDrawable ) { final GLAnimatorControl actrl = cDrawable.getAnimator(); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java index bdde61ad9..83fc6ca95 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java @@ -28,7 +28,7 @@ package com.jogamp.opengl.test.junit.graph.demos.ui; import com.jogamp.opengl.GL2ES2; - +import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Vertex.Factory; @@ -91,7 +91,7 @@ public class MediaPlayerButton extends TextureSeqButton { // FIXME: mPlayer.resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - new Thread() { + new InterruptSource.Thread() { public void run() { // loop for-ever .. mPlayer.seek(0); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java index 3379129dd..7a5b49168 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -28,6 +28,8 @@ package com.jogamp.opengl.test.junit.jogl.acore; +import com.jogamp.common.util.InterruptSource; +import com.jogamp.common.util.InterruptedRuntimeException; import com.jogamp.nativewindow.Capabilities; import com.jogamp.nativewindow.util.InsetsImmutable; import com.jogamp.opengl.GLCapabilities; @@ -194,11 +196,11 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { final String currentThreadName = Thread.currentThread().getName(); final Object syncDone = new Object(); final JOGLTask[] tasks = new JOGLTask[num]; - final Thread[] threads = new Thread[num]; + final InterruptSource.Thread[] threads = new InterruptSource.Thread[num]; int i; for(i=0; i<num; i++) { tasks[i] = new JOGLTask(syncDone, i, reuse); - threads[i] = new Thread(tasks[i], currentThreadName+"-jt"+i); + threads[i] = new InterruptSource.Thread(null, tasks[i], currentThreadName+"-jt"+i); } final long t0 = System.currentTimeMillis(); @@ -211,7 +213,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { try { syncDone.wait(500); } catch (final InterruptedException e) { - throw new RuntimeException(e); + throw new InterruptedRuntimeException(e); } System.err.println(i+": "+doneDump(tasks)); i++; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug1146GLContextDialogToolTipAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug1146GLContextDialogToolTipAWT.java index 42646c07e..a736a481a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug1146GLContextDialogToolTipAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug1146GLContextDialogToolTipAWT.java @@ -52,6 +52,7 @@ import org.junit.Test; import org.junit.runners.MethodSorters; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.InterruptSource; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLCapabilitiesImmutable; import com.jogamp.opengl.GLProfile; @@ -127,7 +128,7 @@ public class TestBug1146GLContextDialogToolTipAWT extends UITestCase { final String cancelButtonText = UIManager.getString("FileChooser.cancelButtonText",l); // launch robot action .. - new Thread() + new InterruptSource.Thread() { public void run() { @@ -161,7 +162,7 @@ public class TestBug1146GLContextDialogToolTipAWT extends UITestCase { // hover to 'approve' -> tool tip if( null != approveButtonPos ) { AWTRobotUtil.mouseMove(robot, approveButtonPos, MOVE_ITER, MOVE_DELAY); - Thread.sleep(TOOLTIP_WAIT); + java.lang.Thread.sleep(TOOLTIP_WAIT); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java index fd012e86f..a034f9c8a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java @@ -44,6 +44,7 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.common.util.InterruptSource; import com.jogamp.common.util.RunnableTask; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -83,7 +84,7 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); - new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); + new InterruptSource.Thread(null, rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); try { System.err.println("BB.2"); rTask.getSyncObject().wait(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java index f2e8b86af..d8900b44e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java @@ -32,6 +32,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.WindowEvent; @@ -114,7 +115,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { if( 3 == c ) { demo.setMSAA(4); } else if( 6 == c ) { - new Thread() { + new InterruptSource.Thread() { @Override public void run() { glWindow.setSize(dw+64, dh+64); @@ -124,14 +125,14 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { } else if( 12 == c ) { demo.setMSAA(0); } else if( 15 == c ) { - new Thread() { + new InterruptSource.Thread() { @Override public void run() { glWindow.setSize(dw+128, dh+128); } }.start(); } else if( 18 == c ) { c=0; - new Thread() { + new InterruptSource.Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); @@ -167,7 +168,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { } System.err.println("*** "+e); if(e.getKeyChar()=='f') { - new Thread() { + new InterruptSource.Thread() { public void run() { System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setFullscreen(!glWindow.isFullscreen()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java index 26d510a45..6c1e4b812 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -48,7 +48,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.GLFinishOnDisplay; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; - +import com.jogamp.common.util.InterruptSource; import com.jogamp.nativewindow.NativeSurface; import com.jogamp.nativewindow.SurfaceUpdatedListener; import com.jogamp.opengl.GL; @@ -192,7 +192,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { } if(9 == c) { c=0; - new Thread() { + new InterruptSource.Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java index 0586eef8e..1886d3d2a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java @@ -46,7 +46,7 @@ import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.jogl.demos.GLFinishOnDisplay; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; - +import com.jogamp.common.util.InterruptSource; import com.jogamp.nativewindow.NativeSurface; import com.jogamp.nativewindow.SurfaceUpdatedListener; import com.jogamp.opengl.GL; @@ -178,7 +178,7 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { } if(9 == c) { c=0; - new Thread() { + new InterruptSource.Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java index 1e78691c4..8d26ebb82 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java @@ -31,6 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; +import com.jogamp.common.util.InterruptSource; import com.jogamp.nativewindow.NativeSurface; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; @@ -194,8 +195,8 @@ public class TestGLContextSurfaceLockNEWT extends UITestCase { final Object sync = new Object(); final MyRunnable[] animTasks = new MyRunnable[animThreadCount]; final MyRunnable[] resizeTasks = new MyRunnable[animThreadCount]; - final Thread[] animThreads = new Thread[reszThreadCount]; - final Thread[] resizeThreads = new Thread[reszThreadCount]; + final InterruptSource.Thread[] animThreads = new InterruptSource.Thread[reszThreadCount]; + final InterruptSource.Thread[] resizeThreads = new InterruptSource.Thread[reszThreadCount]; System.err.println("animThreadCount "+animThreadCount+", frameCount "+frameCount); System.err.println("reszThreadCount "+reszThreadCount+", resizeCount "+resizeCount); @@ -204,12 +205,12 @@ public class TestGLContextSurfaceLockNEWT extends UITestCase { for(int i=0; i<animThreadCount; i++) { System.err.println("create anim task/thread "+i); animTasks[i] = new RudeAnimator(glWindow, frameCount, sync, i); - animThreads[i] = new Thread(animTasks[i], currentThreadName+"-anim"+i); + animThreads[i] = new InterruptSource.Thread(null, animTasks[i], currentThreadName+"-anim"+i); } for(int i=0; i<reszThreadCount; i++) { System.err.println("create resz task/thread "+i); resizeTasks[i] = new RudeResizer(glWindow, resizeCount, sync, i); - resizeThreads[i] = new Thread(resizeTasks[i], currentThreadName+"-resz"+i); + resizeThreads[i] = new InterruptSource.Thread(null, resizeTasks[i], currentThreadName+"-resz"+i); } myEventCounter.reset(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java index 65925c6b5..b052087a8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java @@ -49,6 +49,7 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.junit.util.JunitTracer; import com.jogamp.newt.Window; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; @@ -162,7 +163,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { } setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); frame1.setSize(frameSize0); setupFrameAndShow(frame1, newtCanvasAWT1); @@ -189,7 +190,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { end(animator1, frame1, glWindow1); if( waitForKey ) { - UITestCase.waitForKey("Continue"); + JunitTracer.waitForKey("Continue"); } } @@ -234,7 +235,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { } } if(waitForKey) { - UITestCase.waitForKey("Start"); + JunitTracer.waitForKey("Start"); } final String tstname = TestOffscreenLayer02NewtCanvasAWT.class.getName(); /* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java index aef64e4e9..ae9dac003 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java @@ -43,6 +43,7 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.common.util.InterruptSource; import com.jogamp.common.util.RunnableTask; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -82,7 +83,7 @@ public class TestPBufferDeadlockAWT extends UITestCase { System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); - new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); + new InterruptSource.Thread(null, rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); try { System.err.println("BB.2"); rTask.getSyncObject().wait(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedExternalContextAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedExternalContextAWT.java index 81489df17..0987b2978 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedExternalContextAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedExternalContextAWT.java @@ -14,6 +14,7 @@ import javax.swing.Timer; import org.junit.Test; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.InterruptSource; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.*; @@ -69,7 +70,7 @@ public class TestSharedExternalContextAWT { // which is suppose to lie outside of the JVM. // The thread is kept alive, since this detail // may be required for the OpenGL driver implementation. - final Thread thread = new Thread(runnable); + final Thread thread = new InterruptSource.Thread(null, runnable); thread.setDaemon(true); thread.start(); masterLatch.await(3, TimeUnit.SECONDS); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java index b30bb1192..4cdcbd10a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore.anim; import java.awt.BorderLayout; import java.awt.Dimension; +import com.jogamp.common.util.InterruptSource; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; @@ -85,10 +86,10 @@ public class Bug898AnimatorFromEDTAWT extends javax.swing.JFrame { lastTime = time; animator.pause(); System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.pause(): paused "+animator); - new Thread() { + new InterruptSource.Thread() { public void run() { try { - Thread.sleep(1000); + java.lang.Thread.sleep(1000); } catch (final InterruptedException e) { e.printStackTrace(); } @@ -98,9 +99,9 @@ public class Bug898AnimatorFromEDTAWT extends javax.swing.JFrame { final long td = System.currentTimeMillis() - lastTime; if (animator.isPaused()) { animator.resume(); //Doesn't work on v2.0.2 or higher - System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): animating "+animator); + System.out.println(java.lang.Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): animating "+animator); } else { - System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): Ooops - not paused! - animating "+animator); + System.out.println(java.lang.Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): Ooops - not paused! - animating "+animator); } } } ); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java index f3c2734b5..dfd2489e2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java @@ -28,6 +28,8 @@ package com.jogamp.opengl.test.junit.jogl.caps; +import com.jogamp.common.util.InterruptSource; +import com.jogamp.junit.util.JunitTracer; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; @@ -92,12 +94,12 @@ public class TestTranslucencyNEWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); } }.start(); } else if(e.getKeyChar()=='d') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); } }.start(); @@ -157,7 +159,7 @@ public class TestTranslucencyNEWT extends UITestCase { } } if( waitForKey ) { - UITestCase.waitForKey("main"); + JunitTracer.waitForKey("main"); } org.junit.runner.JUnitCore.main(TestTranslucencyNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java index 771748a33..432652701 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es1.newt; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; @@ -92,12 +93,12 @@ public class TestGearsES1NEWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); } }.start(); } else if(e.getKeyChar()=='d') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java index 9bf04a75f..769183e82 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es1.newt; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; @@ -90,12 +91,12 @@ public class TestRedSquareES1NEWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); } }.start(); } else if(e.getKeyChar()=='d') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java index b2ebc7068..cc4096672 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
import com.jogamp.common.net.Uri;
+import com.jogamp.common.util.InterruptSource;
import com.jogamp.opengl.util.av.AudioSink;
import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
@@ -73,7 +74,7 @@ public class CrossFadePlayer System.out.println("Duration: " + mp.getDuration() + "ms");
System.out.println("Volume: " + mp.getAudioVolume());
System.out.println("player.initGL()...");
- new Thread() {
+ new InterruptSource.Thread() {
public void run() {
try {
mp.initGL(null);
@@ -98,7 +99,7 @@ public class CrossFadePlayer stop = true;
} else {
System.err.println("Player State: EOS");
- new Thread() {
+ new InterruptSource.Thread() {
public void run() {
System.out.println("mp.setPlaySpeed(1f) returned: " + mp.setPlaySpeed(1f));
mp.seek(0);
@@ -112,7 +113,7 @@ public class CrossFadePlayer if( null != se ) {
se.printStackTrace();
}
- new Thread() {
+ new InterruptSource.Thread() {
public void run() {
System.out.println("terminating...");
stop = true;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 525995122..a8dede526 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -42,6 +42,7 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.common.net.Uri; +import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -116,7 +117,7 @@ public class MovieCube implements GLEventListener { resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - new Thread() { + new InterruptSource.Thread() { public void run() { // loop for-ever .. mPlayer.seek(0); @@ -599,7 +600,7 @@ public class MovieCube implements GLEventListener { if( null != se ) { se.printStackTrace(); } - new Thread() { + new InterruptSource.Thread() { public void run() { window.destroy(); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java index e936bf991..9b9073721 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java @@ -42,6 +42,7 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.net.Uri; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -800,7 +801,7 @@ public class MovieSBSStereo implements StereoGLEventListener { static class StereoGLMediaEventListener implements GLMediaEventListener { void destroyWindow(final Window window) { - new Thread() { + new InterruptSource.Thread() { public void run() { window.destroy(); } }.start(); @@ -846,7 +847,7 @@ public class MovieSBSStereo implements StereoGLEventListener { destroy = true; } else { System.err.println("MovieSimple State: EOS"); - new Thread() { + new InterruptSource.Thread() { public void run() { mp.setPlaySpeed(1f); mp.seek(0); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index ac5d29854..0676a5a82 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -47,6 +47,7 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.net.Uri; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -355,7 +356,7 @@ public class MovieSimple implements GLEventListener { resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - new Thread() { + new InterruptSource.Thread() { public void run() { // loop for-ever .. mPlayer.seek(0); @@ -807,7 +808,7 @@ public class MovieSimple implements GLEventListener { static class MyGLMediaEventListener implements GLMediaEventListener { void destroyWindow(final Window window) { - new Thread() { + new InterruptSource.Thread() { public void run() { window.destroy(); } }.start(); @@ -841,7 +842,7 @@ public class MovieSimple implements GLEventListener { /** * Kick off player w/o GLEventListener, i.e. for audio only. * - new Thread() { + new InterruptSource.Thread() { public void run() { try { mp.initGL(null); @@ -873,7 +874,7 @@ public class MovieSimple implements GLEventListener { } else { System.err.println("MovieSimple State: EOS"); if( loopEOS ) { - new Thread() { + new InterruptSource.Thread() { public void run() { mp.setPlaySpeed(1f); mp.seek(0); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java index 5ecda9e20..b389c9ac9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.TraceWindowAdapter; @@ -109,12 +110,12 @@ public class TestElektronenMultipliziererNEWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); } }.start(); } else if(e.getKeyChar()=='d') { - new Thread() { + new InterruptSource.Thread() { public void run() { f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index f0f23eb69..39e94effc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -40,12 +40,11 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.opengl.util.NEWTDemoListener; import com.jogamp.newt.util.EDTUtil; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.NEWTDemoListener; import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -172,12 +171,6 @@ public class TestGearsES2NEWT extends UITestCase { animator.setExclusiveContext(exclusiveContext); } - final QuitAdapter quitAdapter = new QuitAdapter(); - //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); - //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - glWindow.addWindowListener(new WindowAdapter() { public void windowResized(final WindowEvent e) { System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); @@ -196,6 +189,7 @@ public class TestGearsES2NEWT extends UITestCase { } final NEWTDemoListener newtDemoListener = new NEWTDemoListener(glWindow, pointerIcons); + newtDemoListener.quitAdapterEnable(true); glWindow.addKeyListener(newtDemoListener); glWindow.addMouseListener(newtDemoListener); @@ -231,7 +225,7 @@ public class TestGearsES2NEWT extends UITestCase { final EDTUtil edt = ((Window)upstream).getScreen().getDisplay().getEDTUtil(); System.err.println("EDT invokeAndWaitError: edt type "+edt.getClass().getName()); if( edt instanceof DefaultEDTUtil ) { - quitAdapter.doQuit(); + newtDemoListener.doQuit(); ((DefaultEDTUtil)edt).invokeAndWaitError(new Runnable() { public void run() { throw new RuntimeException("XXX Should never ever be seen! - "+Thread.currentThread()); @@ -279,7 +273,7 @@ public class TestGearsES2NEWT extends UITestCase { final long t0 = System.currentTimeMillis(); long t1 = t0; - while(!quitAdapter.shouldQuit() && t1-t0<duration) { + while(!newtDemoListener.shouldQuit() && t1-t0<duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); if( SysExit.testError == sysExit || SysExit.testExit == sysExit || SysExit.testEDTError == sysExit) { @@ -294,7 +288,7 @@ public class TestGearsES2NEWT extends UITestCase { final EDTUtil edt = glWindow.getScreen().getDisplay().getEDTUtil(); System.err.println("EDT invokeAndWaitError: edt type "+edt.getClass().getName()); if( edt instanceof DefaultEDTUtil ) { - quitAdapter.doQuit(); + newtDemoListener.doQuit(); ((DefaultEDTUtil)edt).invokeAndWaitError(new Runnable() { public void run() { throw new RuntimeException("XXX Should never ever be seen!"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 39d13f6a3..4e60c4e95 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -50,7 +50,6 @@ import com.jogamp.newt.opengl.GLWindow; 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.util.Animator; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -272,12 +271,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { animator.setExclusiveContext(exclusiveContext); } - final QuitAdapter quitAdapter = new QuitAdapter(); - //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); - //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - glWindow.addWindowListener(new WindowAdapter() { public void windowResized(final WindowEvent e) { System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); @@ -287,9 +280,11 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { } }); - final NewtAWTReparentingKeyAdapter newtDemoListener = new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter); + final NewtAWTReparentingKeyAdapter newtDemoListener = new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow); + newtDemoListener.quitAdapterEnable(true); glWindow.addKeyListener(newtDemoListener); glWindow.addMouseListener(newtDemoListener); + glWindow.addWindowListener(newtDemoListener); if( useAnimator ) { animator.add(glWindow); @@ -334,7 +329,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { final long t0 = System.currentTimeMillis(); long t1 = t0; - while(!quitAdapter.shouldQuit() && t1-t0<duration) { + while(!newtDemoListener.shouldQuit() && t1-t0<duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java index 8dcffc662..ee72e1e6f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java @@ -31,6 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import com.jogamp.common.util.InterruptSource; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.KeyAdapter; @@ -184,14 +185,12 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setFullscreen(!glWindow.isFullscreen()); System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setExclusiveContextThread(t); - } }.start(); + } } ); } } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java index d109c56cf..849fcb16d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2SimpleNEWT.java @@ -40,9 +40,9 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.opengl.util.NEWTDemoListener; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.NEWTDemoListener; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.PNGPixelRect; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java index 79c8cb39a..2c5b6028c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java @@ -87,15 +87,15 @@ public class TestLandscapeES2NEWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { glWindow.setFullscreen(!glWindow.isFullscreen()); - } }.start(); + } } ); } else if(e.getKeyChar()=='d') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { glWindow.setUndecorated(!glWindow.isUndecorated()); - } }.start(); + } } ); } } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java index 12ea6dbb3..f73eb67f9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java @@ -41,7 +41,6 @@ import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; 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.util.Animator; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; @@ -104,12 +103,6 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { animator.setExclusiveContext(exclusiveContext); } - final QuitAdapter quitAdapter = new QuitAdapter(); - //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); - //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - glWindow.addWindowListener(new WindowAdapter() { public void windowResized(final WindowEvent e) { System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()); @@ -119,7 +112,10 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { } }); - glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter)); + final NewtAWTReparentingKeyAdapter newtDemoListener = new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow); + newtDemoListener.quitAdapterEnable(true); + glWindow.addKeyListener(newtDemoListener); + glWindow.addWindowListener(newtDemoListener); if( useAnimator ) { animator.add(glWindow); @@ -143,7 +139,7 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { final long t0 = System.currentTimeMillis(); long t1 = t0; - while(!quitAdapter.shouldQuit() && t1-t0<duration) { + while(!newtDemoListener.shouldQuit() && t1-t0<duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java index e8e3741aa..976025c14 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java @@ -110,15 +110,15 @@ public class TestRedSquareES2NEWT extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { glWindow.setFullscreen(!glWindow.isFullscreen()); - } }.start(); + } } ); } else if(e.getKeyChar()=='d') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { glWindow.setUndecorated(!glWindow.isUndecorated()); - } }.start(); + } } ); } } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java index 17e50adc0..3422aa091 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java @@ -29,8 +29,8 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.newt; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.opengl.util.NEWTDemoListener; import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.test.junit.util.NEWTDemoListener; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java index aec728cad..eec31b064 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java @@ -198,14 +198,14 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setFullscreen(!glWindow.isFullscreen()); System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); - } }.start(); + } } ); } } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java index 0578492e2..fdd6d6458 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashFormComposite.java @@ -205,14 +205,14 @@ public class TestBug672NewtCanvasSWTSashFormComposite extends UITestCase { return; } if(e.getKeyChar()=='f') { - new Thread() { + glWindow.invokeOnNewThread(null, false, new Runnable() { public void run() { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setFullscreen(!glWindow.isFullscreen()); System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); - } }.start(); + } } ); } } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java index 9a422f411..22053483e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java @@ -50,7 +50,8 @@ import com.jogamp.opengl.GLCapabilities ; import com.jogamp.opengl.GLEventListener ; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; - +import com.jogamp.common.util.InterruptSource; +import com.jogamp.common.util.InterruptedRuntimeException; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.KeyAdapter; @@ -143,14 +144,13 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { //////////////////////////////////////////////////////////////////////////////// - static class ResizeThread extends Thread { + static class ResizeThread extends InterruptSource.Thread { volatile boolean shallStop = false; private final Shell _shell ; private int _n ; public ResizeThread( final Shell shell ) { - super(); _shell = shell ; } @@ -196,9 +196,9 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { display.asyncExec( resizeAction ); display.wake(); - Thread.sleep( 50L ) ; + java.lang.Thread.sleep( 50L ) ; } catch( final InterruptedException e ) { - break ; + throw new InterruptedRuntimeException(e); } } System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+_shell.isDisposed()); @@ -207,7 +207,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { //////////////////////////////////////////////////////////////////////////////// - static class KeyfireThread extends Thread + static class KeyfireThread extends InterruptSource.Thread { volatile boolean shallStop = false; Display _display; @@ -216,6 +216,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { public KeyfireThread(final Robot robot, final Display display) { + super(); _robot = robot; _display = display; } @@ -231,7 +232,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { AWTRobotUtil.waitForIdle(_robot); AWTRobotUtil.newtKeyPress(_n, _robot, true, KeyEvent.VK_0, 10); AWTRobotUtil.newtKeyPress(_n, _robot, false, KeyEvent.VK_0, 0); - Thread.sleep( 40L ) ; + java.lang.Thread.sleep( 40L ) ; _n++; if(!_display.isDisposed()) { _display.wake(); @@ -368,7 +369,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { } { - final Thread t = new Thread(new Runnable() { + final Thread t = new InterruptSource.Thread(null, new Runnable() { @Override public void run() { try { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java index 7072ed9ea..9b2e46d44 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java @@ -51,6 +51,7 @@ import com.jogamp.opengl.GLProfile; import jogamp.newt.swt.SWTEDTUtil; import jogamp.newt.swt.event.SWTNewtEventFactory; +import com.jogamp.common.util.InterruptSource; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.opengl.GLWindow ; @@ -110,7 +111,7 @@ public class TestSWTBug643AsyncExec extends UITestCase { //////////////////////////////////////////////////////////////////////////////// - static class AsyncExecEDTFeederThread extends Thread { + static class AsyncExecEDTFeederThread extends InterruptSource.Thread { volatile boolean shallStop = false; private final Display swtDisplay ; private final jogamp.newt.DisplayImpl newtDisplay; @@ -118,7 +119,6 @@ public class TestSWTBug643AsyncExec extends UITestCase { public AsyncExecEDTFeederThread( final Display swtDisplay, final com.jogamp.newt.Display newtDisplay ) { - super(); this.swtDisplay = swtDisplay ; this.newtDisplay = (jogamp.newt.DisplayImpl)newtDisplay; } @@ -152,7 +152,7 @@ public class TestSWTBug643AsyncExec extends UITestCase { // only perform async exec on valid and already running NEWT EDT! newtDisplay.runOnEDTIfAvail(false, newtAsyncAction); } - Thread.sleep( 50L ) ; + java.lang.Thread.sleep( 50L ) ; } catch( final InterruptedException e ) { break ; } @@ -275,7 +275,7 @@ public class TestSWTBug643AsyncExec extends UITestCase { } { - final Thread t = new Thread(new Runnable() { + final Thread t = new InterruptSource.Thread(null, new Runnable() { @Override public void run() { try { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java index 8339831a0..7fc14a609 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GLAutoDrawable; @@ -99,7 +100,7 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { c=0; snapshot(i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); dw_old = dw; - new Thread() { + new InterruptSource.Thread() { @Override public void run() { glWindow.setSize(2*dw, 2*dh); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestBug1211IRQ00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestBug1211IRQ00NEWT.java index 2f1f7d705..186c3a79a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestBug1211IRQ00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestBug1211IRQ00NEWT.java @@ -36,6 +36,8 @@ import org.junit.Test; import org.junit.runners.MethodSorters; import com.jogamp.common.ExceptionUtils; +import com.jogamp.common.util.InterruptSource; +import com.jogamp.common.util.SourcedInterruptedException; import com.jogamp.common.util.VersionUtil; import com.jogamp.junit.util.SingletonJunitCase; import com.jogamp.newt.opengl.GLWindow; @@ -85,49 +87,35 @@ public class TestBug1211IRQ00NEWT extends SingletonJunitCase { } } - @SuppressWarnings("serial") - static class MyInterruptedException extends InterruptedException { - public MyInterruptedException(final String message, final Throwable cause) { - super(message); - if( null != cause ) { - initCause(cause); - } - } - } - static class MyThread extends Thread implements Thread.UncaughtExceptionHandler { - volatile Throwable interruptCause = null; - volatile int interruptCounter = 0; + static class MyThread extends InterruptSource.Thread implements Thread.UncaughtExceptionHandler { volatile boolean myThreadStarted = false; volatile boolean myThreadStopped = false; public MyThread(final Runnable target, final String name) { - super(target, name); + super(null, target, name); setUncaughtExceptionHandler(this); } - public synchronized void clearInterruptCounter() { - interruptCounter = 0; - interruptCause = null; - } - public synchronized boolean interruptCalled() { return 0 < interruptCounter; } public static void testInterrupted1() throws InterruptedException { - if( Thread.interrupted() ) { - throw new InterruptedException(Thread.currentThread().getName()+".testInterrupted -> TRUE (silent interruption)"); + if( java.lang.Thread.interrupted() ) { + throw SourcedInterruptedException.wrap( + new InterruptedException(java.lang.Thread.currentThread().getName()+".testInterrupted -> TRUE (silent interruption)")); } } public synchronized void testInterrupted(final boolean ignore) throws InterruptedException { if( isInterrupted() ) { final boolean current; - if( this == Thread.currentThread() ) { - Thread.interrupted(); // clear! + if( this == java.lang.Thread.currentThread() ) { + java.lang.Thread.interrupted(); // clear! current = true; } else { current = false; } - final InterruptedException e = new MyInterruptedException(getName()+".testInterrupted -> TRUE (current "+current+", counter "+interruptCounter+")", - interruptCause); - interruptCause = null; - interruptCounter = 0; + final int counter = getInterruptCounter(false); + final Throwable source = getInterruptSource(true); + final InterruptedException e = new SourcedInterruptedException( + getName()+".testInterrupted -> TRUE (current "+current+", counter "+counter+")", + null, source); if( !ignore ) { throw e; } else { @@ -145,16 +133,9 @@ public class TestBug1211IRQ00NEWT extends SingletonJunitCase { myThreadStopped = true; } } - @Override - public synchronized void interrupt() { - interruptCounter++; - interruptCause = new Throwable(getName()+".interrupt() ************************************************* - count "+interruptCounter); - ExceptionUtils.dumpThrowable("causing", interruptCause); - super.interrupt(); - } @Override - public void uncaughtException(final Thread t, final Throwable e) { + public void uncaughtException(final java.lang.Thread t, final Throwable e) { System.err.println("UncaughtException on Thread "+t.getName()+": "+e.getMessage()); ExceptionUtils.dumpThrowable("UncaughtException", e); } @@ -200,7 +181,7 @@ public class TestBug1211IRQ00NEWT extends SingletonJunitCase { } System.err.println("test00.resize["+i+"]: "+ow+"x"+oh+" -> "+nw+"x"+nh); window1.setSize(nw, nh); - ok = !t.interruptCalled() && !t.isInterrupted() && edt.isRunning() && anim.isAnimating(); + ok = 0==t.getInterruptCounter(false) && !t.isInterrupted() && edt.isRunning() && anim.isAnimating(); t.testInterrupted(false); } } catch (final InterruptedException e) { @@ -215,7 +196,7 @@ public class TestBug1211IRQ00NEWT extends SingletonJunitCase { ExceptionUtils.dumpThrowable("InterruptedException-2", e); interrupt2 = true; } - Assert.assertFalse("interruptCalled()", t.interruptCalled()); + Assert.assertEquals("interruptCounter not zero", 0, t.getInterruptCounter(false)); Assert.assertFalse("interrupt() occured!", t.isInterrupted()); Assert.assertFalse("Interrupt-1 occured!", interrupt1); Assert.assertFalse("Interrupt-2 occured!", interrupt2); @@ -256,7 +237,7 @@ public class TestBug1211IRQ00NEWT extends SingletonJunitCase { ExceptionUtils.dumpThrowable("InterruptedException-2", e); interrupt2 = true; } - Assert.assertFalse("interruptCalled()", t.interruptCalled()); + Assert.assertEquals("interruptCounter not zero", 0, t.getInterruptCounter(false)); Assert.assertFalse("interrupt() occured!", t.isInterrupted()); Assert.assertFalse("Interrupt-1 occured!", interrupt1); Assert.assertFalse("Interrupt-2 occured!", interrupt2); @@ -279,7 +260,7 @@ public class TestBug1211IRQ00NEWT extends SingletonJunitCase { interruptInit0 = true; test = null; } - t.clearInterruptCounter(); + t.clearInterruptSource(); if( null != test ) { test.initTest(); test.subTest00(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 39c6c9f4d..5f88d1c6f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -40,6 +40,7 @@ import org.junit.FixMethodOrder; import org.junit.Test ; import org.junit.runners.MethodSorters; +import com.jogamp.common.util.InterruptSource; import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; @@ -344,20 +345,17 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } _testMouseListener.setModifierCheckEnabled( true ) ; - Throwable throwable = null; // final Object sync = new Object(); final RunnableTask rt = new RunnableTask( testAction, null, true, System.err ); try { // synchronized(sync) { - new Thread(rt, "Test-Thread").start(); + new InterruptSource.Thread(null, rt, "Test-Thread").start(); int i=0; - while( !rt.isExecuted() && null == throwable ) { + while( rt.isInQueue() ) { System.err.println("WAIT-till-done: eventDispatch() #"+i++); eventDispatch(); } - if(null==throwable) { - throwable = rt.getThrowable(); - } + final Throwable throwable = rt.getThrowable(); if(null!=throwable) { throw new RuntimeException(throwable); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus03KeyTraversalAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus03KeyTraversalAWT.java index cade05478..b9be0ad9a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus03KeyTraversalAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus03KeyTraversalAWT.java @@ -154,7 +154,7 @@ public class TestParentingFocus03KeyTraversalAWT extends UITestCase { final GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); glWindow1.addKeyListener(new KeyAdapter() { public void keyReleased(final KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index ae873eaf0..3bf13f063 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -29,21 +29,21 @@ package com.jogamp.opengl.test.junit.newt.parenting; import java.awt.Frame; +import com.jogamp.common.util.InterruptSource; import com.jogamp.nativewindow.CapabilitiesImmutable; import com.jogamp.nativewindow.util.InsetsImmutable; import com.jogamp.newt.Window; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.util.NEWTDemoListener; -import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.newt.opengl.util.NEWTDemoListener; public class NewtAWTReparentingKeyAdapter extends NEWTDemoListener { final Frame frame; final NewtCanvasAWT newtCanvasAWT; - public NewtAWTReparentingKeyAdapter(final Frame frame, final NewtCanvasAWT newtCanvasAWT, final GLWindow glWindow, final QuitAdapter quitAdapter) { - super(glWindow, quitAdapter, null); + public NewtAWTReparentingKeyAdapter(final Frame frame, final NewtCanvasAWT newtCanvasAWT, final GLWindow glWindow) { + super(glWindow, null); this.frame = frame; this.newtCanvasAWT = newtCanvasAWT; } @@ -64,9 +64,9 @@ public class NewtAWTReparentingKeyAdapter extends NEWTDemoListener { case KeyEvent.VK_R: e.setConsumed(true); quitAdapterOff(); - new Thread() { + new InterruptSource.Thread() { public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); + final java.lang.Thread t = glWindow.setExclusiveContextThread(null); if(glWindow.getParent()==null) { printlnState("[reparent pre - glWin to HOME]"); glWindow.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index b53da38d7..4af752eb4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -47,6 +47,7 @@ import javax.swing.WindowConstants; import com.jogamp.opengl.*; import com.jogamp.opengl.util.Animator; +import com.jogamp.common.util.InterruptSource; import com.jogamp.newt.*; import com.jogamp.newt.opengl.*; import com.jogamp.newt.awt.NewtCanvasAWT; @@ -140,7 +141,7 @@ public class TestParenting01cSwingAWT extends UITestCase { animator1.start(); final GLDisturbanceAction disturbanceAction = new GLDisturbanceAction(glWindow1); - new Thread(disturbanceAction).start(); + new InterruptSource.Thread(null, disturbanceAction).start(); disturbanceAction.waitUntilRunning(); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); @@ -274,7 +275,7 @@ public class TestParenting01cSwingAWT extends UITestCase { animator1.start(); final GLDisturbanceAction disturbanceAction = new GLDisturbanceAction(glWindow1); - new Thread(disturbanceAction).start(); + new InterruptSource.Thread(null, disturbanceAction).start(); disturbanceAction.waitUntilRunning(); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 723b84081..73d41aefd 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -88,7 +88,7 @@ public class TestParenting03AWT extends UITestCase { final GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); final GLAnimatorControl animator1 = new Animator(glWindow1); animator1.start(); @@ -104,7 +104,7 @@ public class TestParenting03AWT extends UITestCase { final GLEventListener demo2 = new GearsES2(1); setDemoFields(demo2, glWindow2, false); glWindow2.addGLEventListener(demo2); - glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2, null)); + glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2)); animator2 = new Animator(glWindow2); animator2.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java index 60f2f962c..bf656bb4d 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java +++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java @@ -42,6 +42,7 @@ import java.util.List; import com.jogamp.opengl.GLContext; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.InterruptSource; public class MiscUtils { public static boolean atob(final String str, final boolean def) { @@ -160,7 +161,7 @@ public class MiscUtils { return false; } - public static class StreamDump extends Thread { + public static class StreamDump extends InterruptSource.Thread { final InputStream is; final StringBuilder outString; final OutputStream outStream; diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java deleted file mode 100644 index 3e0b7c780..000000000 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java +++ /dev/null @@ -1,501 +0,0 @@ -/** - * Copyright 2015 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.util; - -import java.net.URLConnection; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.nativewindow.CapabilitiesImmutable; -import com.jogamp.nativewindow.ScalableSurface; -import com.jogamp.newt.Display; -import com.jogamp.newt.Display.PointerIcon; -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.FPSCounter; -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GLAnimatorControl; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.util.Gamma; -import com.jogamp.opengl.util.PNGPixelRect; - -import jogamp.newt.driver.PNGIcon; - -public class NEWTDemoListener extends MouseAdapter implements KeyListener { - protected final GLWindow glWindow; - protected final QuitAdapter quitAdapter; - final PointerIcon[] pointerIcons; - int pointerIconIdx = 0; - float gamma = 1f; - float brightness = 0f; - float contrast = 1f; - boolean confinedFixedCenter = false; - - public NEWTDemoListener(final GLWindow glWin, final QuitAdapter quitAdapter, final PointerIcon[] pointerIcons) { - this.glWindow = glWin; - this.quitAdapter = quitAdapter; - if( null != pointerIcons ) { - this.pointerIcons = pointerIcons; - } else { - this.pointerIcons = createPointerIcons(glWindow); - } - } - public NEWTDemoListener(final GLWindow glWin, final PointerIcon[] pointerIcons) { - this(glWin, null, pointerIcons); - } - public NEWTDemoListener(final GLWindow glWin) { - this(glWin, null, null); - } - - protected void printlnState(final String prelude) { - System.err.println(prelude+": "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()+", state "+glWindow.getStateMaskString()); - } - protected void printlnState(final String prelude, final String post) { - System.err.println(prelude+": "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()+", state "+glWindow.getStateMaskString()+", "+post); - } - protected void quitAdapterOff() { - if( null != quitAdapter ) { - quitAdapter.enable(false); - } - } - protected void quitAdapterOn() { - if( null != quitAdapter ) { - quitAdapter.clear(); - quitAdapter.enable(true); - } - } - - @Override - public void keyPressed(final KeyEvent e) { - if( e.isAutoRepeat() || e.isConsumed() ) { - return; - } - final int keySymbol = e.getKeySymbol(); - switch(keySymbol) { - case KeyEvent.VK_SPACE: - e.setConsumed(true); - new Thread() { - public void run() { - if(glWindow.getAnimator().isPaused()) { - glWindow.getAnimator().resume(); - } else { - glWindow.getAnimator().pause(); - } - } - }.run(); - break; - case KeyEvent.VK_A: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set alwaysontop pre]"); - glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); - printlnState("[set alwaysontop post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_B: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set alwaysonbottom pre]"); - glWindow.setAlwaysOnBottom(!glWindow.isAlwaysOnBottom()); - printlnState("[set alwaysonbottom post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_C: - e.setConsumed(true); - new Thread() { - public void run() { - if( null != pointerIcons ) { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set pointer-icon pre]"); - final PointerIcon currentPI = glWindow.getPointerIcon(); - final PointerIcon newPI; - if( pointerIconIdx >= pointerIcons.length ) { - newPI=null; - pointerIconIdx=0; - } else { - newPI=pointerIcons[pointerIconIdx++]; - } - glWindow.setPointerIcon( newPI ); - printlnState("[set pointer-icon post]", currentPI+" -> "+glWindow.getPointerIcon()); - glWindow.setExclusiveContextThread(t); - } - } }.start(); - break; - case KeyEvent.VK_D: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - // while( null != glWindow.getExclusiveContextThread() ) ; - printlnState("[set undecorated pre]"); - glWindow.setUndecorated(!glWindow.isUndecorated()); - printlnState("[set undecorated post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_F: - e.setConsumed(true); - quitAdapterOff(); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set fullscreen pre]"); - if( glWindow.isFullscreen() ) { - glWindow.setFullscreen( false ); - } else { - if( e.isAltDown() ) { - glWindow.setFullscreen( null ); - } else { - glWindow.setFullscreen( true ); - } - } - printlnState("[set fullscreen post]"); - glWindow.setExclusiveContextThread(t); - quitAdapterOn(); - } }.start(); - break; - case KeyEvent.VK_G: - e.setConsumed(true); - new Thread() { - public void run() { - final float newGamma = gamma + ( e.isShiftDown() ? -0.1f : 0.1f ); - System.err.println("[set gamma]: "+gamma+" -> "+newGamma); - if( Gamma.setDisplayGamma(glWindow, newGamma, brightness, contrast) ) { - gamma = newGamma; - } - } }.start(); - break; - case KeyEvent.VK_I: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set pointer-visible pre]"); - glWindow.setPointerVisible(!glWindow.isPointerVisible()); - printlnState("[set pointer-visible post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_J: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set pointer-confined pre]", "warp-center: "+e.isShiftDown()); - final boolean confine = !glWindow.isPointerConfined(); - glWindow.confinePointer(confine); - printlnState("[set pointer-confined post]", "warp-center: "+e.isShiftDown()); - if( e.isShiftDown() ) { - setConfinedFixedCenter(confine); - } else if( !confine ) { - setConfinedFixedCenter(false); - } - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_M: - e.setConsumed(true); - new Thread() { - public void run() { - // none: max-v - // alt: max-h - // shift: max-hv - // ctrl: max-off - final boolean horz, vert; - if( e.isControlDown() ) { - horz = false; - vert = false; - } else if( e.isShiftDown() ) { - final boolean bothMax = glWindow.isMaximizedHorz() && glWindow.isMaximizedVert(); - horz = !bothMax; - vert = !bothMax; - } else if( !e.isAltDown() ) { - horz = glWindow.isMaximizedHorz(); - vert = !glWindow.isMaximizedVert(); - } else if( e.isAltDown() ) { - horz = !glWindow.isMaximizedHorz(); - vert = glWindow.isMaximizedVert(); - } else { - vert = glWindow.isMaximizedVert(); - horz = glWindow.isMaximizedHorz(); - } - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set maximize pre]", "max[vert "+vert+", horz "+horz+"]"); - glWindow.setMaximized(horz, vert); - printlnState("[set maximize post]", "max[vert "+vert+", horz "+horz+"]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_P: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set position pre]"); - glWindow.setPosition(100, 100); - printlnState("[set position post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_R: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set resizable pre]"); - glWindow.setResizable(!glWindow.isResizable()); - printlnState("[set resizable post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_S: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set sticky pre]"); - glWindow.setSticky(!glWindow.isSticky()); - printlnState("[set sticky post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_V: - e.setConsumed(true); - if( e.isControlDown() ) { - glWindow.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - final int _i = gl.getSwapInterval(); - final int i; - switch(_i) { - case 0: i = -1; break; - case -1: i = 1; break; - case 1: i = 0; break; - default: i = 1; break; - } - gl.setSwapInterval(i); - - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - if(drawable instanceof FPSCounter) { - ((FPSCounter)drawable).resetFPSCounter(); - } - System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval()); - return true; - } - }); - } else { - new Thread() { - public void run() { - final boolean wasVisible = glWindow.isVisible(); - { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set visible pre]"); - glWindow.setVisible(!wasVisible); - printlnState("[set visible post]"); - glWindow.setExclusiveContextThread(t); - } - if( wasVisible && !e.isControlDown() ) { - try { - Thread.sleep(5000); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[reset visible pre]"); - glWindow.setVisible(true); - printlnState("[reset visible post]"); - glWindow.setExclusiveContextThread(t); - } - } }.start(); - } - break; - case KeyEvent.VK_W: - e.setConsumed(true); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - printlnState("[set pointer-pos pre]"); - glWindow.warpPointer(glWindow.getSurfaceWidth()/2, glWindow.getSurfaceHeight()/2); - printlnState("[set pointer-pos post]"); - glWindow.setExclusiveContextThread(t); - } }.start(); - break; - case KeyEvent.VK_X: - e.setConsumed(true); - final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]); - final float[] reqSurfacePixelScale; - if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) { - reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; - } else { - reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; - } - System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]); - glWindow.setSurfaceScale(reqSurfacePixelScale); - final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); - final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]); - System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+ - reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ - valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ - hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); - setTitle(); - } - } - @Override - public void keyReleased(final KeyEvent e) { } - - public void setConfinedFixedCenter(final boolean v) { - confinedFixedCenter = v; - } - @Override - public void mouseMoved(final MouseEvent e) { - if( e.isConfined() ) { - mouseCenterWarp(e); - } - } - @Override - public void mouseDragged(final MouseEvent e) { - if( e.isConfined() ) { - mouseCenterWarp(e); - } - } - @Override - public void mouseClicked(final MouseEvent e) { - if(e.getClickCount() == 2 && e.getPointerCount() == 1) { - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("setFullscreen: "+glWindow.isFullscreen()); - } - } - private void mouseCenterWarp(final MouseEvent e) { - if(e.isConfined() && confinedFixedCenter ) { - final int x=glWindow.getSurfaceWidth()/2; - final int y=glWindow.getSurfaceHeight()/2; - glWindow.warpPointer(x, y); - } - } - - public void setTitle() { - setTitle(glWindow); - } - public static void setTitle(final GLWindow win) { - final CapabilitiesImmutable chosenCaps = win.getChosenCapabilities(); - final CapabilitiesImmutable reqCaps = win.getRequestedCapabilities(); - final CapabilitiesImmutable caps = null != chosenCaps ? chosenCaps : reqCaps; - final String capsA = caps.isBackgroundOpaque() ? "opaque" : "transl"; - final float[] sDPI = win.getPixelsPerMM(new float[2]); - sDPI[0] *= 25.4f; - sDPI[1] *= 25.4f; - win.setTitle("GLWindow["+capsA+"], win: "+win.getBounds()+", pix: "+win.getSurfaceWidth()+"x"+win.getSurfaceHeight()+", sDPI "+sDPI[0]+" x "+sDPI[1]); - } - - public static PointerIcon[] createPointerIcons(final GLWindow glWindow) { - final PointerIcon[] pointerIcons = { null, null, null, null, null }; - { - final Display disp = glWindow.getScreen().getDisplay(); - disp.createNative(); - int idx = 0; - { - PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } ); - try { - _pointerIcon = disp.createPointerIcon(res, 8, 8); - System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString()); - } catch (final Exception e) { - e.printStackTrace(); - } - pointerIcons[idx] = _pointerIcon; - } - idx++; - { - PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } ); - try { - _pointerIcon = disp.createPointerIcon(res, 0, 0); - System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString()); - } catch (final Exception e) { - e.printStackTrace(); - } - pointerIcons[idx] = _pointerIcon; - } - idx++; - { - PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-red-alpha-64x64.png" } ); - try { - _pointerIcon = disp.createPointerIcon(res, 0, 0); - System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString()); - } catch (final Exception e) { - e.printStackTrace(); - } - pointerIcons[idx] = _pointerIcon; - } - idx++; - { - PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-blue-alpha-64x64.png" } ); - try { - _pointerIcon = disp.createPointerIcon(res, 0, 0); - System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString()); - } catch (final Exception e) { - e.printStackTrace(); - } - pointerIcons[idx] = _pointerIcon; - } - idx++; - if( PNGIcon.isAvailable() ) { - PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); - try { - final URLConnection urlConn = res.resolve(0); - final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); - System.err.printf("Create PointerIcon #%02d: %s%n", idx, image.toString()); - _pointerIcon = disp.createPointerIcon(image, 32, 0); - System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString()); - } catch (final Exception e) { - e.printStackTrace(); - } - pointerIcons[idx] = _pointerIcon; - } - idx++; - } - return pointerIcons; - } - -}
\ No newline at end of file |