diff options
author | Sven Gothel <[email protected]> | 2011-12-17 21:53:48 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-12-17 21:53:48 +0100 |
commit | 8e0f3ad54b5aa8ef4d71e0b85f84a34be4987b5e (patch) | |
tree | 5ac1839053c5d5458e48d4646f1b19499fd752ec /src/newt/classes/com | |
parent | 47dc069104723f3d2e8d9ebdd700182e067163d0 (diff) |
New Interface 'OffscreenLayerOption', impl. by JAWTWindow (impl) and NewtCanvasAWT/GLCanvas (delegation) ; Fix GLCanvas OffscreenLayerSurface usage.
JAWTWindow.destroy():
- No more getGraphicsConfiguration().getScreen().getDevice().close() call,
since the configuration (hence the device) is passed @ creation and owned by the caller.
New Interface 'OffscreenLayerOption', impl. by JAWTWindow (impl) and NewtCanvasAWT/GLCanvas (delegation)
- Abstract offscreenLayer option to be delegated by using classes
- Allow offscreen testing of GLCanvas as well (like NewtCanvasAWT)
Fix GLCanvas OffscreenLayerSurface usage
- common 'createDrawableAndContext()' for context and drawable instance creation
- addNotify() calls createDrawableAndContext() after super.addNotify() to be able
to lock the surface (JAWTWindow) and hence to determine offscreen usage.
- reshape(...) issues recreation 'dispose(true)' in case of using an offscreen layer
- dispose() explicitly destroys the JAWTWindow
NewtCanvasAWT:
- explicitly close the device of the JAWTWindow (as GLCanvas does)
Tests:
com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT
com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 2506710f5..a71c6106d 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -42,6 +42,7 @@ import java.security.PrivilegedAction; import java.util.Set; import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.OffscreenLayerOption; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.awt.AWTWindowClosingProtocol; import javax.swing.MenuSelectionManager; @@ -66,7 +67,7 @@ import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; @SuppressWarnings("serial") -public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol { +public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption { public static final boolean DEBUG = Debug.debug("Window"); private JAWTWindow jawtWindow = null; @@ -115,28 +116,18 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto setNEWTChild(child); } - /** - * Request an JAWT offscreen layer if supported it. - * Shall be called before {@link #addNotify()} is issued, - * ie. before adding the component to the AWT tree and make it visible. - * - * @see #isOffscreenLayerSurface() - */ public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; } - /** - * Returns true if the underlying JAWT uses offscreen layering, - * otherwise false. This information is valid only after {@link #addNotify()} is issued, - * ie. before adding the component to the AWT tree and make it visible. - * - * @see #setShallUseOffscreenLayer(boolean) - */ - public boolean isOffscreenLayerSurface() { - return jawtWindow.isOffscreenLayerSurfaceEnabled(); + public final boolean getShallUseOffscreenLayer() { + return shallUseOffscreenLayer; } + public final boolean isOffscreenLayerSurfaceEnabled() { + return jawtWindow.isOffscreenLayerSurfaceEnabled(); + } + /** * Returns true if the AWT component is parented to an {@link java.applet.Applet}, * otherwise false. This information is valid only after {@link #addNotify()} is issued, @@ -404,7 +395,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setVisible(false); newtChild.reparentWindow(null); if(null != jawtWindow) { - jawtWindow.destroy(); + NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } } @@ -429,7 +420,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } configureNewtChild(false); if(null!=jawtWindow) { - jawtWindow.destroy(); + NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } newtChild.setVisible(false); @@ -440,7 +431,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto cont.remove(this); } } - } + } @Override public void paint(Graphics g) { |