From 28b0df6c300494a2b54c07fdf43ef04f5f1b0073 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 8 Sep 2011 03:43:54 +0200 Subject: Destruction of GLAutoDrawable shall not remove them from AnimatorControl (due to recreation) ; NEWT/Window: Remove isValid() API entry - always true! Destruction of GLAutoDrawable shall not remove them from AnimatorControl (due to recreation) - Completes commit b65e1e76d413b70e5593173e6bd36d30675554a6 - WindowImpl: - volatile: windowHandle/visible fields (memeory sync critical) - destroy must set visible := false, to avoid immediate recreation via a display call of another thread, ie an animator. NEWT/Window: Remove isValid() API entry - always true! - NEWT/Window's can always be recreated. - redundancy in API is even worse than redundancy in impl. :) --- src/newt/classes/com/jogamp/newt/Window.java | 12 ++-------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 8 ++----- .../classes/com/jogamp/newt/opengl/GLWindow.java | 28 +++++++--------------- 3 files changed, 12 insertions(+), 36 deletions(-) (limited to 'src/newt/classes/com') diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index ac8311a9a..84f2f0294 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -54,18 +54,9 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // Lifecycle // - /** - * @return True if native window is valid, can be created or recovered. - * Otherwise false, ie this window is unrecoverable due to a destroy(true) call. - * - * @see #destroy(boolean) - * @see #setVisible(boolean) - */ - boolean isValid(); - /** * @return true if the native window handle is valid and ready to operate, ie - * if the native window has been created, otherwise false. + * if the native window has been created via {@link #setVisible(boolean) setVisible(true)}, otherwise false. * * @see #setVisible(boolean) * @see #destroy(boolean) @@ -102,6 +93,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Destroy the Window and it's children, incl. native destruction.
* The Window can be recreate via {@link #setVisible(boolean) setVisible(true)}. + *

Visibility is set to false.

*

* This method invokes {@link Screen#removeReference()} after it's own destruction,
* which will issue {@link Screen#destroy()} if the reference count becomes 0.
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 5c242d0e7..51a43d86c 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -159,16 +159,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( null != newtChild ) { if(attach) { awtAdapter = new AWTParentWindowAdapter(newtChild).addTo(this); - if(newtChild.isValid()) { - newtChild.addWindowListener(clearAWTMenusOnNewtFocus); - } + newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingProtocol.DO_NOTHING_ON_CLOSE); awtWindowClosingProtocol.addClosingListenerOneShot(); } else { - if(newtChild.isValid()) { - newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); - } + newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(null); newtChild.setDefaultCloseOperation(newtChildCloseOp); awtWindowClosingProtocol.removeClosingListener(); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 638e4a462..bde4373d1 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -66,7 +66,7 @@ import com.jogamp.opengl.JoglVersion; *

*/ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { - private WindowImpl window; + private final WindowImpl window; /** * Constructor. Do not call this directly -- use {@link #create()} instead. @@ -298,10 +298,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC window.setTopLevelSize(width, height); } - public final boolean isValid() { - return window.isValid(); - } - public final boolean isNativeValid() { return window.isNativeValid(); } @@ -511,28 +507,20 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } public void display() { - display(false); - } - - public void display(boolean forceReshape) { - if( null == window ) { return; } - - if(sendDestroy || ( null!=window && window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) ) { + if( !isNativeValid() || !isVisible() ) { return; } + + if(sendDestroy || ( window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) ) { sendDestroy=false; destroy(); return; } - - if( null == context && isVisible() && 0