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/nativewindow/classes/javax/media | |
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/nativewindow/classes/javax/media')
3 files changed, 71 insertions, 9 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index aa0851bcf..c69b18b30 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -528,24 +528,28 @@ public abstract class NativeWindowFactory { * Returns the {@link OffscreenLayerSurface} instance of this {@link NativeSurface}. * <p> * In case this surface is a {@link NativeWindow}, we traverse from the given surface - * up to root until a {@link OffscreenLayerSurface} is found. + * up to root until an implementation of {@link OffscreenLayerSurface} is found. + * In case <code>ifEnabled</code> is true, the surface must also implement {@link OffscreenLayerOption} + * where {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()} is <code>true</code>. * </p> * * @param surface The surface to query. - * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerSurface#isOffscreenLayerSurfaceEnabled()}. + * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()}. * @return */ public static OffscreenLayerSurface getOffscreenLayerSurface(NativeSurface surface, boolean ifEnabled) { - if(surface instanceof OffscreenLayerSurface) { + if(surface instanceof OffscreenLayerSurface && + ( !ifEnabled || surface instanceof OffscreenLayerOption ) ) { final OffscreenLayerSurface ols = (OffscreenLayerSurface) surface; - return ( !ifEnabled || ols.isOffscreenLayerSurfaceEnabled() ) ? ols : null; + return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null; } if(surface instanceof NativeWindow) { NativeWindow nw = ((NativeWindow) surface).getParent(); while(null != nw) { - if(nw instanceof OffscreenLayerSurface) { + if(nw instanceof OffscreenLayerSurface && + ( !ifEnabled || nw instanceof OffscreenLayerOption ) ) { final OffscreenLayerSurface ols = (OffscreenLayerSurface) nw; - return ( !ifEnabled || ols.isOffscreenLayerSurfaceEnabled() ) ? ols : null; + return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null; } nw = nw.getParent(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java new file mode 100644 index 000000000..12d30b3cd --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java @@ -0,0 +1,61 @@ +/** + * Copyright 2011 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 javax.media.nativewindow; + +/** + * Handling requests for using an {@link OffscreenLayerSurface} + * within the implementation. + */ +public interface OffscreenLayerOption { + /** + * Request an offscreen layer, if supported. + * <p> + * Shall be called before the first {@link NativeWindow#lockSurface()}, + * and hence before realization. + * </p> + * + * @see #getShallUseOffscreenLayer() + * @see #isOffscreenLayerSurfaceEnabled() + */ + public void setShallUseOffscreenLayer(boolean v); + + /** Returns the property set by {@link #setShallUseOffscreenLayer(boolean)}. */ + public boolean getShallUseOffscreenLayer(); + + /** + * Returns true if this instance uses an offscreen layer, otherwise false. + * <p> + * This instance is an offscreen layer, if {@link #setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * has been called before it's realization and first lock and the underlying implementation supports it. + * </p> + * The return value is undefined before issuing the first {@link NativeWindow#lockSurface()}. + * + * @see #setShallUseOffscreenLayer(boolean) + */ + public boolean isOffscreenLayerSurfaceEnabled(); +}
\ No newline at end of file diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index 82ae0f39e..dd36509ba 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -31,9 +31,6 @@ package javax.media.nativewindow; * Interface specifying the offscreen layer surface protocol. */ public interface OffscreenLayerSurface { - /** Returns true if this instance uses an offscreen layer, otherwise false. */ - public boolean isOffscreenLayerSurfaceEnabled(); - /** * Attach the offscreen layer to this offscreen layer surface. * @see #isOffscreenLayerSurfaceEnabled() |