From 8e0f3ad54b5aa8ef4d71e0b85f84a34be4987b5e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 17 Dec 2011 21:53:48 +0100 Subject: 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 --- .../jogamp/nativewindow/jawt/JAWTWindow.java | 29 +++++++--------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'src/nativewindow/classes/jogamp') diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java index 938760801..6d2860374 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java @@ -48,6 +48,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.OffscreenLayerOption; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.awt.AWTGraphicsConfiguration; @@ -59,7 +60,7 @@ import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; -public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface { +public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, OffscreenLayerOption { protected static final boolean DEBUG = JAWTUtil.DEBUG; // user properties @@ -102,22 +103,18 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface this.isApplet = false; } - /** - * Request an JAWT offscreen layer if supported. - * Shall be called before {@link #lockSurface()}. - * - * @see #getShallUseOffscreenLayer() - * @see #isOffscreenLayerSurfaceEnabled() - */ public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; } - /** Returns the property set by {@link #setShallUseOffscreenLayer(boolean)}. */ public final boolean getShallUseOffscreenLayer() { return shallUseOffscreenLayer; } + public final boolean isOffscreenLayerSurfaceEnabled() { + return isOffscreenLayerSurface; + } + protected synchronized void invalidate() { invalidateNative(); jawt = null; @@ -165,14 +162,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface return jawt; } - /** - * {@inheritDoc} - * @see #setShallUseOffscreenLayer(boolean) - */ - public final boolean isOffscreenLayerSurfaceEnabled() { - return isOffscreenLayerSurface; - } - /** * {@inheritDoc} */ @@ -356,7 +345,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface public synchronized void destroy() { invalidate(); - getGraphicsConfiguration().getScreen().getDevice().close(); component = null; // don't dispose the AWT component, since we are merely an immutable uplink } @@ -454,14 +442,15 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface return component.hasFocus(); } - @Override + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("JAWT-Window["+ "windowHandle 0x"+Long.toHexString(getWindowHandle())+ ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ - ", bounds "+bounds+", insets "+insets); + ", bounds "+bounds+", insets "+insets+ + ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface); if(null!=component) { sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+component.isVisible()); -- cgit v1.2.3