diff options
-rwxr-xr-x | make/scripts/java-win64-dbg.bat | 4 | ||||
-rwxr-xr-x | make/scripts/tests-x64.bat | 4 | ||||
-rwxr-xr-x | make/scripts/tests.sh | 3 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java | 8 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java | 181 |
5 files changed, 112 insertions, 88 deletions
diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 0dd922dde..48653d907 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -39,8 +39,8 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL"
REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet"
REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch"
-REM set D_ARGS="-Dnewt.debug.Window"
-set D_ARGS="-Dnewt.debug.Window.KeyEvent"
+set D_ARGS="-Dnewt.debug.Window"
+REM set D_ARGS="-Dnewt.debug.Window.KeyEvent"
REM set D_ARGS="-Dnewt.debug.Window.MouseEvent"
REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display"
diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 237770488..7d1380287 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -47,10 +47,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScroll REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a10be0db9..2974658a8 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -177,7 +177,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -317,6 +317,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 85cb655d7..9a1632130 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -47,7 +47,7 @@ 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.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.VisualIDHolder; @@ -151,11 +151,15 @@ public class AWTCanvas extends Canvas { } } - public NativeSurface getNativeSurface() { + public NativeWindow getNativeWindow() { final JAWTWindow _jawtWindow = jawtWindow; return (null != _jawtWindow) ? _jawtWindow : null; } + public boolean isOffscreenLayerSurfaceEnabled() { + return null != jawtWindow ? jawtWindow.isOffscreenLayerSurfaceEnabled() : false; + } + public void removeNotify() { try { dispose(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index cc678e4ef..c45a5ae3b 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -41,11 +41,14 @@ import java.awt.Frame; import java.awt.Insets; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Point; +import jogamp.nativewindow.awt.AWTMisc; import jogamp.newt.WindowImpl; +import com.jogamp.common.os.Platform; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; @@ -71,25 +74,26 @@ public class WindowDriver extends WindowImpl { public WindowDriver(Container container) { super(); - this.container = container; + this.awtContainer = container; if(container instanceof Frame) { - frame = (Frame) container; + awtFrame = (Frame) container; } } private boolean owningFrame; - private Container container = null; - private Frame frame = null; // same instance as container, just for impl. convenience - private AWTCanvas canvas; + private Container awtContainer = null; + /** same instance as container, just for impl. convenience */ + private Frame awtFrame = null; + private AWTCanvas awtCanvas; protected void requestFocusImpl(boolean reparented) { - container.requestFocus(); + awtContainer.requestFocus(); } @Override protected void setTitleImpl(final String title) { - if (frame != null) { - frame.setTitle(title); + if (awtFrame != null) { + awtFrame.setTitle(title); } } @@ -98,65 +102,66 @@ public class WindowDriver extends WindowImpl { throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); } - if(null==container) { - frame = new Frame(); - container = frame; + if(null==awtContainer) { + awtFrame = new Frame(); + awtContainer = awtFrame; owningFrame=true; } else { owningFrame=false; - defineSize(container.getWidth(), container.getHeight()); - definePosition(container.getX(), container.getY()); + defineSize(awtContainer.getWidth(), awtContainer.getHeight()); + definePosition(awtContainer.getX(), awtContainer.getY()); } - if(null!=frame) { - frame.setTitle(getTitle()); + if(null!=awtFrame) { + awtFrame.setTitle(getTitle()); } - container.setLayout(new BorderLayout()); + awtContainer.setLayout(new BorderLayout()); - if( null == canvas ) { - canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); + if( null == awtCanvas ) { + awtCanvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); // canvas.addComponentListener(listener); - container.add(canvas, BorderLayout.CENTER); + awtContainer.add(awtCanvas, 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 + new AWTMouseAdapter(this).addTo(awtCanvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(awtCanvas); // 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 + new AWTWindowAdapter(new LocalWindowListener(), this).addTo(awtCanvas); // fwd all AWT Window events to here } reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); // throws exception if failed .. - final NativeSurface ns = canvas.getNativeSurface(); - if( null != ns ) { - setGraphicsConfiguration( canvas.getAWTGraphicsConfiguration() ); - setWindowHandle( ns.getSurfaceHandle() ); + final NativeWindow nw = awtCanvas.getNativeWindow(); + if( null != nw ) { + setGraphicsConfiguration( awtCanvas.getAWTGraphicsConfiguration() ); + setWindowHandle( nw.getWindowHandle() ); } } protected void closeNativeImpl() { setWindowHandle(0); - if(null!=container) { - container.setVisible(false); - container.remove(canvas); - container.setEnabled(false); - canvas.setEnabled(false); - canvas = null; + if(null!=awtContainer) { + awtContainer.setVisible(false); + awtContainer.remove(awtCanvas); + awtContainer.setEnabled(false); + awtCanvas.setEnabled(false); } - if(owningFrame && null!=frame) { - frame.dispose(); + if(owningFrame && null!=awtFrame) { + awtFrame.dispose(); owningFrame=false; - frame = null; } + awtCanvas = null; + awtFrame = null; + awtContainer = null; } @Override public boolean hasDeviceChanged() { - boolean res = canvas.hasDeviceChanged(); + boolean res = awtCanvas.hasDeviceChanged(); if(res) { - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + final AWTGraphicsConfiguration cfg = awtCanvas.getAWTGraphicsConfiguration(); if (null == cfg) { throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this); } @@ -172,21 +177,54 @@ public class WindowDriver extends WindowImpl { } protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { - Insets contInsets = container.getInsets(); + Insets contInsets = awtContainer.getInsets(); insets.setLeftWidth(contInsets.left); insets.setRightWidth(contInsets.right); insets.setTopHeight(contInsets.top); insets.setBottomHeight(contInsets.bottom); } + private void setCanvasSizeImpl(int width, int height) { + final Dimension szClient = new Dimension(width, height); + final java.awt.Window awtWindow = AWTMisc.getWindow(awtCanvas); + final Container c= null != awtWindow ? awtWindow : awtContainer; + awtCanvas.setMinimumSize(szClient); + awtCanvas.setPreferredSize(szClient); + if(DEBUG_IMPLEMENTATION) { + final Insets insets = c.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + System.err.println(getThreadName()+": AWTWindow setCanvasSize: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + awtCanvas.setSize(szClient); + awtCanvas.invalidate(); + if(null != awtWindow) { + awtWindow.pack(); + } else { + awtContainer.validate(); + } + } + private void setFrameSizeImpl(int width, int height) { + final Insets insets = awtContainer.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + if(DEBUG_IMPLEMENTATION) { + final Dimension szClient = new Dimension(width, height); + System.err.println(getThreadName()+": AWTWindow setFrameSize: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + awtContainer.setSize(szContainer); + awtCanvas.invalidate(); + awtContainer.validate(); + } + 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()); + if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=awtFrame) { + if(!awtContainer.isDisplayable()) { + awtFrame.setUndecorated(isUndecorated()); } else { if(DEBUG_IMPLEMENTATION) { System.err.println(getThreadName()+": AWTWindow can't undecorate already created frame"); @@ -196,48 +234,29 @@ public class WindowDriver extends WindowImpl { 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 + setCanvasSizeImpl(width, height); + awtContainer.setVisible( true ); } else { - container.setVisible( false ); + awtContainer.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); - if(DEBUG_IMPLEMENTATION) { - final Dimension szClient = new Dimension(width, height); - System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } else if( awtCanvas.getWidth() != width || awtCanvas.getHeight() != height ) { + if( Platform.OSType.MACOS == Platform.getOSType() && awtCanvas.isOffscreenLayerSurfaceEnabled() ) { + setFrameSizeImpl(width, height); + } else { + setCanvasSizeImpl(width, height); } - container.setSize(szContainer); - container.validate(); - defineSize(width, height); // we are on AWT-EDT .. change values immediately } + defineSize(width, height); // we are on AWT-EDT .. change values immediately - if( container.getX() != x || container.getY() != y ) { - container.setLocation(x, y); + if( awtContainer.getX() != x || awtContainer.getY() != y ) { + awtContainer.setLocation(x, y); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { if( !hasDeviceChanged() ) { // oops ?? - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + final AWTGraphicsConfiguration cfg = awtCanvas.getAWTGraphicsConfiguration(); if(null == cfg) { throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this); } @@ -251,30 +270,30 @@ public class WindowDriver extends WindowImpl { } protected Point getLocationOnScreenImpl(int x, int y) { - java.awt.Point ap = canvas.getLocationOnScreen(); + java.awt.Point ap = awtCanvas.getLocationOnScreen(); ap.translate(x, y); return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); } @Override public NativeSurface getWrappedSurface() { - return ( null != canvas ) ? canvas.getNativeSurface() : null; + return ( null != awtCanvas ) ? awtCanvas.getNativeWindow() : null; } class LocalWindowListener implements com.jogamp.newt.event.WindowListener { @Override public void windowMoved(com.jogamp.newt.event.WindowEvent e) { - if(null!=container) { - WindowDriver.this.positionChanged(false, container.getX(), container.getY()); + if(null!=awtContainer) { + WindowDriver.this.positionChanged(false, awtContainer.getX(), awtContainer.getY()); } } @Override public void windowResized(com.jogamp.newt.event.WindowEvent e) { - if(null!=canvas) { + if(null!=awtCanvas) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window Resized: "+canvas); + System.err.println("Window Resized: "+awtCanvas); } - WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), true); + WindowDriver.this.sizeChanged(false, awtCanvas.getWidth(), awtCanvas.getHeight(), true); WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } } @@ -296,9 +315,9 @@ public class WindowDriver extends WindowImpl { } @Override public void windowRepaint(WindowUpdateEvent e) { - if(null!=canvas) { + if(null!=awtCanvas) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window Repaint: "+canvas); + System.err.println("Window Repaint: "+awtCanvas); } WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } |