diff options
Diffstat (limited to 'src/nativewindow/classes')
83 files changed, 1183 insertions, 1090 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java index 22c95f3dd..c98bf5436 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java @@ -29,11 +29,11 @@ public class DelegatedUpstreamSurfaceHookMutableSize extends UpstreamSurfaceHook upstream.destroy(s); } } - + @Override public String toString() { - return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]"; + return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]"; } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java index 85e24582c..1557f4e51 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java @@ -42,13 +42,13 @@ public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurf @Override public final int getHeight(ProxySurface s) { return surface.getHeight(); - } - + } + @Override public String toString() { - final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil"; + final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil"; return getClass().getSimpleName()+"["+upstream+", "+us_s+"]"; } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java index eaad513aa..8b8ccb191 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java @@ -41,10 +41,10 @@ public class MutableGraphicsConfiguration extends DefaultGraphicsConfiguration { public void setChosenCapabilities(CapabilitiesImmutable caps) { super.setChosenCapabilities(caps); } - + @Override public void setScreen(AbstractGraphicsScreen screen) { super.setScreen(screen); } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java index 29f4964c0..a8dd9165c 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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 com.jogamp.nativewindow; import com.jogamp.common.GlueGenVersion; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java index 29c540ac4..5838c7a56 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java @@ -18,9 +18,9 @@ public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.Mutab @Override public final void setSize(int width, int height) { this.width = width; - this.height = height; + this.height = height; } - + @Override public final int getWidth(ProxySurface s) { return width; @@ -35,11 +35,11 @@ public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.Mutab @Override public void destroy(ProxySurface s) { /* nop */ } - + @Override public String toString() { - return getClass().getSimpleName()+"[ "+ width + "x" + height + "]"; + return getClass().getSimpleName()+"[ "+ width + "x" + height + "]"; } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java index 7e3d30a47..aa9b876dd 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -57,7 +57,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple private GraphicsConfiguration config; AbstractGraphicsConfiguration encapsulated; - public AWTGraphicsConfiguration(AWTGraphicsScreen screen, + public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, GraphicsConfiguration config, AbstractGraphicsConfiguration encapsulated) { super(screen, capsChosen, capsRequested); @@ -71,9 +71,9 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple this.config = config; this.encapsulated=null; } - + /** - * @param capsChosen if null, <code>capsRequested</code> is copied and aligned + * @param capsChosen if null, <code>capsRequested</code> is copied and aligned * with the graphics {@link Capabilities} of the AWT Component to produce the chosen {@link Capabilities}. * Otherwise the <code>capsChosen</code> is used. * @param capsRequested if null, default {@link Capabilities} are used, otherwise the given values. @@ -81,7 +81,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) { final GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration(); if(null==awtGfxConfig) { - throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp); + throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp); } final GraphicsDevice awtGraphicsDevice = awtGfxConfig.getDevice(); if(null==awtGraphicsDevice) { @@ -109,10 +109,11 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple } // open access to superclass method + @Override public void setChosenCapabilities(CapabilitiesImmutable capsChosen) { super.setChosenCapabilities(capsChosen); } - + @Override public Object clone() { return super.clone(); @@ -171,7 +172,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple public String toString() { return getClass().getSimpleName()+"[" + getScreen() + ",\n\tchosen " + capabilitiesChosen+ - ",\n\trequested " + capabilitiesRequested+ + ",\n\trequested " + capabilitiesRequested+ ",\n\t" + config + ",\n\tencapsulated "+encapsulated+"]"; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java index 635e6d263..a7fa53577 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java index f4ee06e28..83d6efa75 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -87,6 +87,7 @@ public class AWTGraphicsScreen extends DefaultGraphicsScreen implements Cloneabl return new AWTGraphicsScreen(AWTGraphicsDevice.createDefault()); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java index e5290aee1..44163fc73 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -69,15 +69,15 @@ import jogamp.nativewindow.awt.AWTMisc; } finally { ctx.releasePrint(); } - * + * * </pre> * </p> */ public interface AWTPrintLifecycle { public static final int DEFAULT_PRINT_TILE_SIZE = 1024; - - + + /** * Shall be called before {@link PrinterJob#print()}. * <p> @@ -85,12 +85,12 @@ public interface AWTPrintLifecycle { * </p> * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples * @param tileWidth custom tile width for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param tileHeight custom tile height for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight); - + /** * Shall be called after {@link PrinterJob#print()}. * <p> @@ -111,11 +111,11 @@ public interface AWTPrintLifecycle { * <p> * See <a href="#usage">Usage</a>. * </p> - * + * * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @return the context @@ -139,7 +139,7 @@ public interface AWTPrintLifecycle { * @return count of performed actions of last {@link #setupPrint(Container, double, double, int, int, int) setupPrint(..)} or {@link #releasePrint()}. */ public int getCount() { return count; } - + private final Container cont; private final double scaleMatX; private final double scaleMatY; @@ -147,7 +147,7 @@ public interface AWTPrintLifecycle { private final int tileWidth; private final int tileHeight; private int count; - + private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { @Override public void run(Component c) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java index e499ff705..27275c6e0 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java @@ -78,7 +78,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { /** * Adds this closing listener to the components Window if exist and only one time. * <p> - * If the closing listener is already added, and {@link IllegalStateException} is thrown. + * If the closing listener is already added, and {@link IllegalStateException} is thrown. * </p> * * @return true if added, otherwise false. @@ -119,6 +119,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { * otherwise return the AWT/Swing close operation value translated to * a {@link WindowClosingProtocol} value . */ + @Override public final WindowClosingMode getDefaultCloseOperation() { synchronized(closingListenerLock) { if(defaultCloseOperationSetByUser) { @@ -129,6 +130,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { return AWTMisc.getNWClosingOperation(comp); } + @Override public final WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { synchronized(closingListenerLock) { final WindowClosingMode _op = defaultCloseOperation; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java index 7a7a771d6..c02fc0a04 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -45,29 +45,29 @@ import com.jogamp.common.nio.Buffers; * {@link DataBuffer} specialization using NIO direct buffer of type {@link DataBuffer#TYPE_INT} as storage. */ public final class DirectDataBufferInt extends DataBuffer { - + public static class DirectWritableRaster extends WritableRaster { protected DirectWritableRaster(SampleModel sampleModel, DirectDataBufferInt dataBuffer, Point origin) { super(sampleModel, dataBuffer, origin); } } - + public static class BufferedImageInt extends BufferedImage { final int customImageType; public BufferedImageInt (int customImageType, ColorModel cm, WritableRaster raster, Hashtable<?,?> properties) { super(cm, raster, false /* isRasterPremultiplied */, properties); - this.customImageType = customImageType; + this.customImageType = customImageType; } - + /** - * @return one of the custom image-type values {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, - * {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, + * @return one of the custom image-type values {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, + * {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, * {@link BufferedImage#TYPE_INT_RGB TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}. */ public int getCustomType() { return customImageType; } - + @Override public String toString() { return new String("BufferedImageInt@"+Integer.toHexString(hashCode()) @@ -75,26 +75,26 @@ public final class DirectDataBufferInt extends DataBuffer { +" "+getColorModel()+" "+getRaster()); } } - + /** - * Creates a {@link BufferedImageInt} using a {@link DirectColorModel direct color model} in {@link ColorSpace#CS_sRGB sRGB color space}.<br> + * Creates a {@link BufferedImageInt} using a {@link DirectColorModel direct color model} in {@link ColorSpace#CS_sRGB sRGB color space}.<br> * It uses a {@link DirectWritableRaster} utilizing {@link DirectDataBufferInt} storage. * <p> - * Note that due to using the custom storage type {@link DirectDataBufferInt}, the resulting + * Note that due to using the custom storage type {@link DirectDataBufferInt}, the resulting * {@link BufferedImage}'s {@link BufferedImage#getType() image-type} is of {@link BufferedImage#TYPE_CUSTOM TYPE_CUSTOM}. * We are not able to change this detail, since the AWT image implementation associates the {@link BufferedImage#getType() image-type} * with a build-in storage-type. * Use {@link BufferedImageInt#getCustomType()} to retrieve the custom image-type, which will return the <code>imageType</code> - * value passed here. + * value passed here. * </p> - * + * * @param width * @param height - * @param imageType one of {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, + * @param imageType one of {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, * {@link BufferedImage#TYPE_INT_RGB TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}. * @param location origin, if <code>null</code> 0/0 is assumed. * @param properties <code>Hashtable</code> of - * <code>String</code>/<code>Object</code> pairs. Used for {@link BufferedImage#getProperty(String)} etc. + * <code>String</code>/<code>Object</code> pairs. Used for {@link BufferedImage#getProperty(String)} etc. * @return */ public static BufferedImageInt createBufferedImage(int width, int height, int imageType, Point location, Hashtable<?,?> properties) { @@ -150,30 +150,30 @@ public final class DirectDataBufferInt extends DataBuffer { bandMasks[0] = rmask; bandMasks[1] = gmask; bandMasks[2] = bmask; - + final DirectDataBufferInt dataBuffer = new DirectDataBufferInt(width*height); if( null == location ) { location = new Point(0,0); } - final SinglePixelPackedSampleModel sppsm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), + final SinglePixelPackedSampleModel sppsm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), width, height, width /* scanLineStride */, bandMasks); // IntegerComponentRasters must haveinteger DataBuffers: // final WritableRaster raster = new IntegerInterleavedRaster(sppsm, dataBuffer, location); // Not public: // final WritableRaster raster = new SunWritableRaster(sppsm, dataBuffer, location); final WritableRaster raster = new DirectWritableRaster(sppsm, dataBuffer, location); - + return new BufferedImageInt(imageType, colorModel, raster, properties); } - + /** Default data bank. */ private IntBuffer data; /** All data banks */ private IntBuffer bankdata[]; - + /** - * Constructs an nio integer-based {@link DataBuffer} with a single bank + * Constructs an nio integer-based {@link DataBuffer} with a single bank * and the specified size. * * @param size The size of the {@link DataBuffer}. @@ -222,17 +222,17 @@ public final class DirectDataBufferInt extends DataBuffer { /** * Returns the default (first) int data array in {@link DataBuffer}. - * + * * @return The first integer data array. */ public IntBuffer getData() { return data; } - /** - * Returns the data array for the specified bank. - * - * @param bank The bank whose data array you want to get. + /** + * Returns the data array for the specified bank. + * + * @param bank The bank whose data array you want to get. * @return The data array for the specified bank. */ public IntBuffer getData(int bank) { @@ -241,25 +241,27 @@ public final class DirectDataBufferInt extends DataBuffer { /** * Returns the requested data array element from the first (default) bank. - * + * * @param i The data array element you want to get. * @return The requested data array element as an integer. * @see #setElem(int, int) * @see #setElem(int, int, int) */ + @Override public int getElem(int i) { return data.get(i+offset); } /** * Returns the requested data array element from the specified bank. - * + * * @param bank The bank from which you want to get a data array element. * @param i The data array element you want to get. * @return The requested data array element as an integer. * @see #setElem(int, int) * @see #setElem(int, int, int) */ + @Override public int getElem(int bank, int i) { return bankdata[bank].get(i+offsets[bank]); } @@ -273,6 +275,7 @@ public final class DirectDataBufferInt extends DataBuffer { * @see #getElem(int) * @see #getElem(int, int) */ + @Override public void setElem(int i, int val) { data.put(i+offset, val); } @@ -286,6 +289,7 @@ public final class DirectDataBufferInt extends DataBuffer { * @see #getElem(int) * @see #getElem(int, int) */ + @Override public void setElem(int bank, int i, int val) { bankdata[bank].put(i+offsets[bank], val); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 38a46f214..49b2daeae 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -123,7 +123,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private boolean localVisibility = component.isVisible(); private boolean globalVisibility = localVisibility; private boolean visibilityPropagation = false; - + private String s(ComponentEvent e) { return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ " ** COMP "+e.getComponent()+Platform.getNewline()+ @@ -164,7 +164,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public void componentHidden(ComponentEvent e) { + public void componentHidden(ComponentEvent e) { if(DEBUG) { System.err.println("JAWTWindow.componentHidden: "+s(e)); } @@ -174,7 +174,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, @Override public void hierarchyChanged(HierarchyEvent e) { final long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); + final java.awt.Component changed = e.getChanged(); if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { final boolean displayable = changed.isDisplayable(); final boolean resetLocalVisibility = changed == component && !displayable && localVisibility != component.isVisible(); @@ -220,7 +220,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println("JAWTWindow.invalidate() - "+Thread.currentThread().getName()); if( isSurfaceLayerAttached() ) { - System.err.println("OffscreenSurfaceLayer still attached: 0x"+Long.toHexString(offscreenSurfaceLayer)); + System.err.println("OffscreenSurfaceLayer still attached: 0x"+Long.toHexString(offscreenSurfaceLayer)); } // Thread.dumpStack(); } @@ -237,14 +237,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected final boolean updateBounds(JAWT_Rectangle jawtBounds) { final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); final boolean changed = !bounds.equals(jb); - + if(changed) { if(DEBUG) { System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); // Thread.dumpStack(); } bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); - + if(component instanceof Container) { final java.awt.Insets contInsets = ((Container)component).getInsets(); insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); @@ -279,7 +279,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // // OffscreenLayerOption // - + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; @@ -316,9 +316,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * Layout the offscreen layer according to the implementing class's constraints. * <p> * This method allows triggering a re-layout of the offscreen surface - * in case the implementation requires it. + * in case the implementation requires it. * </p> - * <p> + * <p> * Call this method if any parent or ancestor's layout has been changed, * which could affects the layout of this surface. * </p> @@ -326,14 +326,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) {} - + private final void layoutSurfaceLayerIfEnabled(boolean visible) throws NativeWindowException { if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) { layoutSurfaceLayerImpl(offscreenSurfaceLayer, visible); } } - - + + @Override public final void detachSurfaceLayer() throws NativeWindowException { if( 0 == offscreenSurfaceLayer) { @@ -351,35 +351,35 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } }; - /** + /** * @param detachNotify Runnable to be called before native detachment */ protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { throw new UnsupportedOperationException("offscreen layer not supported"); } - + @Override public final long getAttachedSurfaceLayer() { return offscreenSurfaceLayer; } - + @Override public final boolean isSurfaceLayerAttached() { return 0 != offscreenSurfaceLayer; } - + @Override public final void setChosenCapabilities(CapabilitiesImmutable caps) { ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); - getPrivateGraphicsConfiguration().setChosenCapabilities(caps); + getPrivateGraphicsConfiguration().setChosenCapabilities(caps); } - + @Override public final RecursiveLock getLock() { return surfaceLock; } - + // // SurfaceUpdateListener // @@ -527,7 +527,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } - + @Override public final long getDisplayHandle() { return getGraphicsConfiguration().getScreen().getDevice().getHandle(); @@ -545,7 +545,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, @Override public final int getHeight() { - return component.getHeight(); + return component.getHeight(); } // @@ -647,10 +647,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract Point getLocationOnScreenNativeImpl(int x, int y); protected static Component getLocationOnScreenNonBlocking(Point storage, Component comp) { - final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG + final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG Component last = null; while(null != comp) { - final int dx = comp.getX(); + final int dx = comp.getX(); final int dy = comp.getY(); if( DEBUG ) { final java.awt.Insets ins = AWTMisc.getInsets(comp, false); @@ -674,7 +674,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } return last; } - + @Override public boolean hasFocus() { return component.hasFocus(); @@ -693,7 +693,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } return sb; } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -715,7 +715,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return sb.toString(); } - + protected final String toHexString(long l) { return "0x"+Long.toHexString(l); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index fb6d39b2f..c83814907 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -45,7 +45,7 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * <p> * FIXME: This shall be removed when relocated EGL to the nativewindow package, * since then it can be utilized directly. - * </p> + * </p> */ public interface EGLDisplayLifecycleCallback { /** @@ -55,14 +55,14 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * @return the initialized EGL display ID, or <code>0</code> if not successful */ public long eglGetAndInitDisplay(long[] nativeDisplayID); - + /** * Implementation should issue an <code>EGL.eglTerminate(eglDisplayHandle)</code> call. * @param eglDisplayHandle */ void eglTerminate(long eglDisplayHandle); } - + /** * Note that this is not an open connection, ie no native display handle exist. * This constructor exist to setup a default device connection/unit.<br> @@ -78,9 +78,9 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl this.nativeDisplayID[0] = nativeDisplayID; this.eglLifecycleCallback = eglLifecycleCallback; } - + public long getNativeDisplayID() { return nativeDisplayID[0]; } - + @Override public Object clone() { return super.clone(); @@ -100,7 +100,7 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return false; } - + @Override public boolean close() { if(null != eglLifecycleCallback && 0 != handle) { @@ -111,11 +111,11 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return super.close(); } - + @Override public boolean isHandleOwner() { return null != eglLifecycleCallback; - } + } @Override public void clearHandleOwner() { eglLifecycleCallback = null; @@ -126,9 +126,9 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } @Override protected Object setHandleOwnership(Object newOwnership) { - final EGLDisplayLifecycleCallback oldOwnership = eglLifecycleCallback; + final EGLDisplayLifecycleCallback oldOwnership = eglLifecycleCallback; eglLifecycleCallback = (EGLDisplayLifecycleCallback) newOwnership; return oldOwnership; - } + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java index 0dc788c17..99ca006fa 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -43,6 +43,7 @@ public class MacOSXGraphicsDevice extends DefaultGraphicsDevice implements Clone super(NativeWindowFactory.TYPE_MACOSX, AbstractGraphicsDevice.DEFAULT_CONNECTION, unitID); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 5c4fd82d2..361d61c65 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -54,28 +54,28 @@ import jogamp.nativewindow.x11.X11Lib; public class SWTAccessor { private static final boolean DEBUG = true; - + private static final Field swt_control_handle; private static final boolean swt_uses_long_handles; - - private static Object swt_osx_init = new Object(); + + private static Object swt_osx_init = new Object(); private static Field swt_osx_control_view = null; private static Field swt_osx_view_id = null; - + private static final String nwt; private static final boolean isOSX; private static final boolean isWindows; private static final boolean isX11; private static final boolean isX11GTK; - + // X11/GTK, Windows/GDI, .. private static final String str_handle = "handle"; - + // OSX/Cocoa private static final String str_osx_view = "view"; // OSX private static final String str_osx_id = "id"; // OSX // static final String str_NSView = "org.eclipse.swt.internal.cocoa.NSView"; - + private static final Method swt_control_internal_new_GC; private static final Method swt_control_internal_dispose_GC; private static final String str_internal_new_GC = "internal_new_GC"; @@ -85,18 +85,18 @@ public class SWTAccessor { public static final Class<?> OS_gtk_class; private static final String str_OS_gtk_version = "GTK_VERSION"; public static final VersionNumber OS_gtk_version; - + private static final Method OS_gtk_widget_realize; private static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3) private static final Method OS_GTK_WIDGET_WINDOW; private static final Method OS_gtk_widget_get_window; private static final Method OS_gdk_x11_drawable_get_xdisplay; private static final Method OS_gdk_x11_display_get_xdisplay; - private static final Method OS_gdk_window_get_display; - private static final Method OS_gdk_x11_drawable_get_xid; + private static final Method OS_gdk_window_get_display; + private static final Method OS_gdk_x11_drawable_get_xid; private static final Method OS_gdk_x11_window_get_xid; private static final Method OS_gdk_window_set_back_pixmap; - + private static final String str_gtk_widget_realize = "gtk_widget_realize"; private static final String str_gtk_widget_unrealize = "gtk_widget_unrealize"; private static final String str_GTK_WIDGET_WINDOW = "GTK_WIDGET_WINDOW"; @@ -107,11 +107,11 @@ public class SWTAccessor { private static final String str_gdk_x11_drawable_get_xid = "gdk_x11_drawable_get_xid"; private static final String str_gdk_x11_window_get_xid = "gdk_x11_window_get_xid"; private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap"; - + private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0); private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0); private static final VersionNumber GTK_VERSION_3_0_0 = new VersionNumber(3, 0, 0); - + private static VersionNumber GTK_VERSION(int version) { // return (major << 16) + (minor << 8) + micro; final int micro = ( version ) & 0x0f; @@ -119,20 +119,21 @@ public class SWTAccessor { final int major = ( version >> 16 ) & 0x0f; return new VersionNumber(major, minor, micro); } - + static { AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. return null; } } ); - + nwt = NativeWindowFactory.getNativeWindowType(false); isOSX = NativeWindowFactory.TYPE_MACOSX == nwt; isWindows = NativeWindowFactory.TYPE_WINDOWS == nwt; isX11 = NativeWindowFactory.TYPE_X11 == nwt; - - Field f = null; + + Field f = null; if( !isOSX ) { try { f = Control.class.getField(str_handle); @@ -141,7 +142,7 @@ public class SWTAccessor { } } swt_control_handle = f; // maybe null ! - + boolean ulh; if (null != swt_control_handle) { ulh = swt_control_handle.getGenericType().toString().equals(long.class.toString()); @@ -151,7 +152,7 @@ public class SWTAccessor { swt_uses_long_handles = ulh; // System.err.println("SWT long handles: " + swt_uses_long_handles); // System.err.println("Platform 64bit: "+Platform.is64Bit()); - + Method m=null; try { m = ReflectionUtil.getMethod(Control.class, str_internal_new_GC, new Class[] { GCData.class }); @@ -159,12 +160,12 @@ public class SWTAccessor { throw new NativeWindowException(ex); } swt_control_internal_new_GC = m; - + try { if(swt_uses_long_handles) { - m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { long.class, GCData.class }); + m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { long.class, GCData.class }); } else { - m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { int.class, GCData.class }); + m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { int.class, GCData.class }); } } catch (NoSuchMethodException ex) { throw new NativeWindowException(ex); @@ -181,7 +182,7 @@ public class SWTAccessor { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); Field field_OS_gtk_version = c.getField(str_OS_gtk_version); _gtk_version = GTK_VERSION(field_OS_gtk_version.getInt(null)); - m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); + m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); if (_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { m4 = c.getDeclaredMethod(str_gtk_widget_get_window, handleType); } else { @@ -189,9 +190,9 @@ public class SWTAccessor { } if (_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { m6 = c.getDeclaredMethod(str_gdk_x11_display_get_xdisplay, handleType); - m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); + m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); } else { - m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); + m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); } if (_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { m9 = c.getDeclaredMethod(str_gdk_x11_window_get_xid, handleType); @@ -200,7 +201,7 @@ public class SWTAccessor { } ma = c.getDeclaredMethod(str_gdk_window_set_back_pixmap, handleType, handleType, boolean.class); } catch (Exception ex) { throw new NativeWindowException(ex); } - // optional + // optional try { m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType); } catch (Exception ex) { } @@ -213,33 +214,33 @@ public class SWTAccessor { OS_gtk_widget_get_window = m4; OS_gdk_x11_drawable_get_xdisplay = m5; OS_gdk_x11_display_get_xdisplay = m6; - OS_gdk_window_get_display = m7; + OS_gdk_window_get_display = m7; OS_gdk_x11_drawable_get_xid = m8; OS_gdk_x11_window_get_xid = m9; OS_gdk_window_set_back_pixmap = ma; - + isX11GTK = isX11 && null != OS_gtk_class; - + if(DEBUG) { System.err.println("SWTAccessor.<init>: GTK Version: "+OS_gtk_version); } } - + private static Number getIntOrLong(long arg) { if(swt_uses_long_handles) { return new Long(arg); } return new Integer((int) arg); } - - private static void callStaticMethodL2V(Method m, long arg) { + + private static void callStaticMethodL2V(Method m, long arg) { ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); } - - private static void callStaticMethodLLZ2V(Method m, long arg0, long arg1, boolean arg3) { + + private static void callStaticMethodLLZ2V(Method m, long arg0, long arg1, boolean arg3) { ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg0), getIntOrLong(arg1), Boolean.valueOf(arg3) }); } - + private static long callStaticMethodL2L(Method m, long arg) { Object o = ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); if(o instanceof Number) { @@ -252,18 +253,18 @@ public class SWTAccessor { // // Public properties // - + public static boolean isUsingLongHandles() { return swt_uses_long_handles; } public static boolean useX11GTK() { return isX11GTK; } public static VersionNumber GTK_VERSION() { return OS_gtk_version; } - + // // Common GTK // - + public static long gdk_widget_get_window(long handle) { final long window; if (OS_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { @@ -276,7 +277,7 @@ public class SWTAccessor { } return window; } - + public static long gdk_window_get_xdisplay(long window) { final long xdisplay; if (OS_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { @@ -293,7 +294,7 @@ public class SWTAccessor { } return xdisplay; } - + public static long gdk_window_get_xwindow(long window) { final long xWindow; if (OS_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { @@ -306,15 +307,15 @@ public class SWTAccessor { } return xWindow; } - + public static void gdk_window_set_back_pixmap(long window, long pixmap, boolean parent_relative) { callStaticMethodLLZ2V(OS_gdk_window_set_back_pixmap, window, pixmap, parent_relative); } - + // // Common any toolkit // - + /** * @param swtControl the SWT Control to retrieve the native widget-handle from * @return the native widget-handle @@ -335,9 +336,9 @@ public class SWTAccessor { } } catch (Exception ex) { throw new NativeWindowException(ex); - } + } } - } else { + } else { try { h = swt_control_handle.getLong(swtControl); } catch (Exception ex) { @@ -350,31 +351,32 @@ public class SWTAccessor { return h; } - public static void setRealized(final Control swtControl, final boolean realize) - throws NativeWindowException + public static void setRealized(final Control swtControl, final boolean realize) + throws NativeWindowException { if(!realize && swtControl.isDisposed()) { return; } final long handle = getHandle(swtControl); - + if(null != OS_gtk_class) { invoke(true, new Runnable() { + @Override public void run() { if(realize) { callStaticMethodL2V(OS_gtk_widget_realize, handle); } else if(null != OS_gtk_widget_unrealize) { callStaticMethodL2V(OS_gtk_widget_unrealize, handle); - } + } } }); } } - + /** * @param swtControl the SWT Control to retrieve the native device handle from * @return the AbstractGraphicsDevice w/ the native device handle - * @throws NativeWindowException if the widget handle is null + * @throws NativeWindowException if the widget handle is null * @throws UnsupportedOperationException if the windowing system is not supported */ public static AbstractGraphicsDevice getDevice(Control swtControl) throws NativeWindowException, UnsupportedOperationException { @@ -391,7 +393,7 @@ public class SWTAccessor { } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } - + /** * @param device * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen @@ -400,7 +402,7 @@ public class SWTAccessor { public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { return NativeWindowFactory.createScreen(device, screen); } - + public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { if( isX11 ) { return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); @@ -408,32 +410,33 @@ public class SWTAccessor { if( isWindows || isOSX ) { return VisualIDHolder.VID_UNDEFINED; } - throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); + throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } - + /** * @param swtControl the SWT Control to retrieve the native window handle from * @return the native window handle - * @throws NativeWindowException if the widget handle is null + * @throws NativeWindowException if the widget handle is null * @throws UnsupportedOperationException if the windowing system is not supported */ public static long getWindowHandle(Control swtControl) throws NativeWindowException, UnsupportedOperationException { - final long handle = getHandle(swtControl); + final long handle = getHandle(swtControl); if(0 == handle) { throw new NativeWindowException("Null SWT handle of SWT control "+swtControl); } if( isX11GTK ) { - return gdk_window_get_xwindow( gdk_widget_get_window( handle ) ); + return gdk_window_get_xwindow( gdk_widget_get_window( handle ) ); } if( isWindows || isOSX ) { return handle; } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } - + public static long newGC(final Control swtControl, final GCData gcData) { final Object[] o = new Object[1]; invoke(true, new Runnable() { + @Override public void run() { o[0] = ReflectionUtil.callMethod(swtControl, swt_control_internal_new_GC, new Object[] { gcData }); } @@ -444,9 +447,10 @@ public class SWTAccessor { throw new InternalError("SWT internal_new_GC did not return int or long but "+o[0].getClass()); } } - + public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) { invoke(true, new Runnable() { + @Override public void run() { if(swt_uses_long_handles) { ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Long(gc), gcData }); @@ -456,7 +460,7 @@ public class SWTAccessor { } }); } - + /** * Runs the specified action in an SWT compatible thread, which is: * <ul> @@ -468,7 +472,7 @@ public class SWTAccessor { * <li>Linux, Windows, .. * <ul> * <li>Current thread.</li> - * </ul></li> + * </ul></li> * </ul> * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() @@ -479,9 +483,9 @@ public class SWTAccessor { OSXUtil.RunOnMainThread(wait, runnable); } else { runnable.run(); - } + } } - + /** * Runs the specified action on the SWT UI thread. * <p> @@ -492,56 +496,56 @@ public class SWTAccessor { public static void invoke(org.eclipse.swt.widgets.Display display, boolean wait, Runnable runnable) { if( display.isDisposed() || Thread.currentThread() == display.getThread() ) { invoke(wait, runnable); - } else if( wait ) { + } else if( wait ) { display.syncExec(runnable); } else { display.asyncExec(runnable); } } - + // // Specific X11 GTK ChildWindow - Using plain X11 native parenting (works well) // - + public static long createCompatibleX11ChildWindow(AbstractGraphicsScreen screen, Control swtControl, int visualID, int width, int height) { final long handle = getHandle(swtControl); final long parentWindow = gdk_widget_get_window( handle ); gdk_window_set_back_pixmap (parentWindow, 0, false); - + final long x11ParentHandle = gdk_window_get_xwindow(parentWindow); final long x11WindowHandle = X11Lib.CreateWindow(x11ParentHandle, screen.getDevice().getHandle(), screen.getIndex(), visualID, width, height, true, true); - + return x11WindowHandle; } - + public static void resizeX11Window(AbstractGraphicsDevice device, Rectangle clientArea, long x11Window) { - X11Lib.SetWindowPosSize(device.getHandle(), x11Window, clientArea.x, clientArea.y, clientArea.width, clientArea.height); + X11Lib.SetWindowPosSize(device.getHandle(), x11Window, clientArea.x, clientArea.y, clientArea.width, clientArea.height); } public static void destroyX11Window(AbstractGraphicsDevice device, long x11Window) { X11Lib.DestroyWindow(device.getHandle(), x11Window); } - + // // Specific X11 SWT/GTK ChildWindow - Using SWT/GTK native parenting (buggy - sporadic resize flickering, sporadic drop of rendering) // // FIXME: Need to use reflection for 32bit access as well ! // - + // public static final int GDK_WA_TYPE_HINT = 1 << 9; // public static final int GDK_WA_VISUAL = 1 << 6; - + public static long createCompatibleGDKChildWindow(Control swtControl, int visualID, int width, int height) { return 0; /** final long handle = SWTAccessor.getHandle(swtControl); final long parentWindow = gdk_widget_get_window( handle ); - + final long screen = OS.gdk_screen_get_default (); final long gdkvisual = OS.gdk_x11_screen_lookup_visual (screen, visualID); - + final GdkWindowAttr attrs = new GdkWindowAttr(); attrs.width = width > 0 ? width : 1; - attrs.height = height > 0 ? height : 1; + attrs.height = height > 0 ? height : 1; attrs.event_mask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK | OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | @@ -550,16 +554,16 @@ public class SWTAccessor { OS.GDK_POINTER_MOTION_HINT_MASK; attrs.window_type = OS.GDK_WINDOW_CHILD; attrs.visual = gdkvisual; - + final long childWindow = OS.gdk_window_new (parentWindow, attrs, OS.GDK_WA_VISUAL|GDK_WA_TYPE_HINT); OS.gdk_window_set_user_data (childWindow, handle); OS.gdk_window_set_back_pixmap (parentWindow, 0, false); - + OS.gdk_window_show (childWindow); OS.gdk_flush(); return childWindow; */ } - + public static void showGDKWindow(long gdkWindow) { /* OS.gdk_window_show (gdkWindow); OS.gdk_flush(); */ @@ -576,8 +580,8 @@ public class SWTAccessor { OS.gdk_window_resize (gdkWindow, clientArea.width, clientArea.height); OS.gdk_flush(); */ } - + public static void destroyGDKWindow(long gdkWindow) { // OS.gdk_window_destroy (gdkWindow); - } + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java index 5cabdf150..643982715 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -34,7 +34,7 @@ package com.jogamp.nativewindow.windows; import javax.media.nativewindow.*; -/** +/** * Encapsulates a graphics device on Windows platforms.<br> */ public class WindowsGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { @@ -47,6 +47,7 @@ public class WindowsGraphicsDevice extends DefaultGraphicsDevice implements Clon super(NativeWindowFactory.TYPE_WINDOWS, connection, unitID); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java index 0d2914c7d..120c86584 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -48,7 +48,7 @@ import jogamp.nativewindow.x11.XVisualInfo; public class X11GraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { private XVisualInfo info; - public X11GraphicsConfiguration(X11GraphicsScreen screen, + public X11GraphicsConfiguration(X11GraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, XVisualInfo info) { super(screen, capsChosen, capsRequested); @@ -71,12 +71,12 @@ public class X11GraphicsConfiguration extends MutableGraphicsConfiguration imple final public int getXVisualID() { return (null!=info)?(int)info.getVisualid():0; } - + @Override public String toString() { return getClass().getSimpleName()+"["+getScreen()+", visualID 0x" + Long.toHexString(getXVisualID()) + ",\n\tchosen " + capabilitiesChosen+ - ",\n\trequested " + capabilitiesRequested+ + ",\n\trequested " + capabilitiesRequested+ "]"; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index e630e012e..40d212df3 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -87,12 +87,12 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl handleOwner = owner; isXineramaEnabled = X11Util.XineramaIsEnabled(this); } - + private static int getDefaultScreenImpl(long dpy) { return X11Lib.DefaultScreen(dpy); } - + /** * Returns the default screen number as referenced by the display connection, i.e. 'somewhere:0.1' -> 1 * <p> @@ -110,7 +110,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return ds; } - + public int getDefaultVisualID() { final long display = getHandle(); if(0==display) { @@ -118,11 +118,11 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return X11Lib.DefaultVisualID(display, getDefaultScreenImpl(display)); } - + public final boolean isXineramaEnabled() { return isXineramaEnabled; } - + @Override public Object clone() { return super.clone(); @@ -142,7 +142,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return false; } - + @Override public boolean close() { if(handleOwner && 0 != handle) { @@ -153,11 +153,11 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return super.close(); } - + @Override public boolean isHandleOwner() { return handleOwner; - } + } @Override public void clearHandleOwner() { handleOwner = false; @@ -168,8 +168,8 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } @Override protected Object setHandleOwnership(Object newOwnership) { - final Boolean oldOwnership = Boolean.valueOf(handleOwner); + final Boolean oldOwnership = Boolean.valueOf(handleOwner); handleOwner = ((Boolean) newOwnership).booleanValue(); return oldOwnership; - } + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 2ec66290a..700937829 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -62,7 +62,8 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl // It still could be an AWT hold handle .. return X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } - + + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java index 4e45113d4..48f72e574 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -44,7 +44,7 @@ package javax.media.nativewindow; pixel format in a toolkit-independent manner. */ public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable { public Object clone(); - + /** * Return the screen this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index ed305d49e..31b64269f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -47,7 +47,7 @@ import jogamp.nativewindow.Debug; */ public interface AbstractGraphicsDevice extends Cloneable { public static final boolean DEBUG = Debug.debug("GraphicsDevice"); - + /** Dummy connection value for a default connection where no native support for multiple devices is available */ public static String DEFAULT_CONNECTION = "decon"; @@ -58,7 +58,7 @@ public interface AbstractGraphicsDevice extends Cloneable { public static int DEFAULT_UNIT = 0; public Object clone(); - + /** * Returns the type of the underlying subsystem, ie * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, .. @@ -96,7 +96,7 @@ public interface AbstractGraphicsDevice extends Cloneable { * The unique ID may be used as a key for semantic device mapping. * </p> * <p> - * The returned string object reference is unique using {@link String#intern()} + * The returned string object reference is unique using {@link String#intern()} * and hence can be used as a key itself. * </p> */ @@ -114,29 +114,29 @@ public interface AbstractGraphicsDevice extends Cloneable { */ public void lock(); - /** + /** * Optionally unlocking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#unlock()}. * The lock implementation must be recursive. - * + * * @throws RuntimeException in case the lock is not acquired by this thread. */ public void unlock(); /** - * @throws RuntimeException if current thread does not hold the lock + * @throws RuntimeException if current thread does not hold the lock */ public void validateLocked() throws RuntimeException; - - /** + + /** * Optionally [re]opening the device if handle is <code>null</code>. * <p> * The default implementation is a <code>NOP</code>. * </p> * <p> - * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} - * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} * issue the native open operation in case handle is <code>null</code>. - * </p> + * </p> * * @return true if the handle was <code>null</code> and opening was successful, otherwise false. */ @@ -148,19 +148,19 @@ public interface AbstractGraphicsDevice extends Cloneable { * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to <code>null</code>. * </p> * <p> - * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} - * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}. - * </p> + * </p> * * @return true if the handle was not <code>null</code> and closing was successful, otherwise false. */ public boolean close(); - + /** * @return <code>true</code> if instance owns the handle to issue {@link #close()}, otherwise <code>false</code>. */ public boolean isHandleOwner(); - + public void clearHandleOwner(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java index acb98073b..da8f12f3e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -45,7 +45,7 @@ package javax.media.nativewindow; public interface AbstractGraphicsScreen extends Cloneable { public Object clone(); - + /** * Return the device this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java index f2a8e2394..9eed887b5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java +++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java @@ -61,7 +61,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { // Switch for on- or offscreen private boolean onscreen = true; - + // offscreen bitmap mode private boolean isBitmap = false; @@ -74,7 +74,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { public Object cloneMutable() { return clone(); } - + @Override public Object clone() { try { @@ -85,7 +85,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } /** - * Copies all {@link Capabilities} values + * Copies all {@link Capabilities} values * from <code>source</code> into this instance. * @return this instance */ @@ -103,7 +103,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { transparentValueAlpha = other.getTransparentAlphaValue(); return this; } - + @Override public int hashCode() { // 31 * x == (x << 5) - x @@ -150,15 +150,15 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { **/ @Override public int compareTo(final CapabilitiesImmutable caps) { - /** + /** if ( ! ( o instanceof CapabilitiesImmutable ) ) { Class<?> c = (null != o) ? o.getClass() : null ; throw new ClassCastException("Not a CapabilitiesImmutable object, but " + c); } final CapabilitiesImmutable caps = (CapabilitiesImmutable) o; */ - + final int rgba = redBits * greenBits * blueBits * ( alphaBits + 1 ); - + final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * ( caps.getAlphaBits() + 1 ); if(rgba > xrgba) { @@ -222,17 +222,17 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { return alphaBits; } - /** + /** * Sets the number of bits requested for the color buffer's alpha * component. On some systems only the color depth, which is the * sum of the red, green, and blue bits, is considered. * <p> - * <b>Note:</b> If alpha bits are <code>zero</code>, they are set to <code>one</code> + * <b>Note:</b> If alpha bits are <code>zero</code>, they are set to <code>one</code> * by {@link #setBackgroundOpaque(boolean)} and it's OpenGL specialization <code>GLCapabilities::setSampleBuffers(boolean)</code>.<br/> * Ensure to call this method after the above to ensure a <code>zero</code> value.</br> * The above automated settings takes into account, that the user calls this method to <i>request</i> alpha bits, * not to <i>reflect</i> a current state. Nevertheless if this is the case - call it at last. - * </p> + * </p> */ public void setAlphaBits(int alphaBits) { this.alphaBits = alphaBits; @@ -271,7 +271,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { * Defaults to true. * </p> * <p> - * If requesting an offscreen surface without further selection of it's mode, + * If requesting an offscreen surface without further selection of it's mode, * e.g. FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}, * the implementation will choose the best available offscreen mode. * </p> @@ -304,12 +304,12 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } isBitmap = enable; } - + @Override public boolean isBitmap() { - return isBitmap; + return isBitmap; } - + @Override public final int getTransparentRedValue() { return transparentValueRed; } @@ -354,7 +354,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { public StringBuilder toString(StringBuilder sink) { return toString(sink, true); } - + /** Returns a textual representation of this Capabilities object. */ @Override @@ -365,7 +365,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { msg.append("]"); return msg.toString(); } - + /** Return a textual representation of this object's on/off screen state. Use the given StringBuilder [optional]. */ protected StringBuilder onoffScreenToString(StringBuilder sink) { if(null == sink) { @@ -381,19 +381,19 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } else if(onscreen) { sink.append("."); // no additional off-screen modes besides on-screen } else { - sink.append("auto-cfg"); // auto-config off-screen mode + sink.append("auto-cfg"); // auto-config off-screen mode } - sink.append("]"); - + sink.append("]"); + return sink; } - + /** Element separator */ protected static final String ESEP = "/"; /** Component separator */ protected static final String CSEP = ", "; - - protected StringBuilder toString(StringBuilder sink, boolean withOnOffScreen) { + + protected StringBuilder toString(StringBuilder sink, boolean withOnOffScreen) { if(null == sink) { sink = new StringBuilder(); } @@ -409,6 +409,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } return sink; } - + protected final String toHexString(int val) { return Integer.toHexString(val); } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java index e1fdf4938..1f4db7997 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -58,7 +58,7 @@ public interface CapabilitiesChooser { not necessarily required, that the chooser select that entry. <P> <em>Note:</em> this method is called automatically by the - {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method + {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method when an instance of this class is passed in to it. It should generally not be invoked by users directly, unless it is desired to delegate the diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java index 85659f286..c496a1535 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java @@ -70,12 +70,12 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C * Returns whether an opaque or translucent surface is requested, supported or chosen. * <p> * Default is true, i.e. opaque. - * </p> + * </p> */ boolean isBackgroundOpaque(); /** - * Returns whether an on- or offscreen surface is requested, available or chosen. + * Returns whether an on- or offscreen surface is requested, available or chosen. * <p> * Default is true, i.e. onscreen. * </p> @@ -83,7 +83,7 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C * Mind that an capabilities intance w/ <i>available</i> semantics * may show onscreen, but also the offscreen modes FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}. * This is valid, since one native configuration maybe used for either functionality. - * </p> + * </p> */ boolean isOnscreen(); @@ -97,7 +97,7 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C * </p> */ boolean isBitmap(); - + /** * Gets the transparent red value for the frame buffer configuration. This * value is undefined if; equals true. diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java index 4f07bca9b..77cbe2995 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -66,16 +66,17 @@ import jogamp.nativewindow.Debug; */ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { - private static final boolean DEBUG; + private static final boolean DEBUG; static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true); } - + private final static int NO_SCORE = -9999999; private final static int COLOR_MISMATCH_PENALTY_SCALE = 36; - + + @Override public int chooseCapabilities(final CapabilitiesImmutable desired, final List<? extends CapabilitiesImmutable> available, final int windowSystemRecommendedChoice) { @@ -112,7 +113,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { if (desired.isOnscreen() && !cur.isOnscreen()) { continue; // requested onscreen, but n/a } - + int score = 0; // Compute difference in color depth score += (COLOR_MISMATCH_PENALTY_SCALE * @@ -132,7 +133,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { System.err.println(" ]"); } - // Ready to select. Choose score closest to 0. + // Ready to select. Choose score closest to 0. int scoreClosestToZero = NO_SCORE; int chosenIndex = -1; for (int i = 0; i < availnum; i++) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java index 6b23172e1..42d7f3a23 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -36,12 +36,12 @@ import jogamp.nativewindow.Debug; public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration { protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration"); - + private AbstractGraphicsScreen screen; protected CapabilitiesImmutable capabilitiesChosen; protected CapabilitiesImmutable capabilitiesRequested; - public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen, + public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) { if(null == screen) { throw new IllegalArgumentException("Null screen"); @@ -69,18 +69,22 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics } } + @Override final public AbstractGraphicsScreen getScreen() { return screen; } + @Override final public CapabilitiesImmutable getChosenCapabilities() { return capabilitiesChosen; } + @Override final public CapabilitiesImmutable getRequestedCapabilities() { return capabilitiesRequested; } + @Override public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() { return this; } @@ -89,7 +93,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics final public int getVisualID(VIDType type) throws NativeWindowException { return capabilitiesChosen.getVisualID(type); } - + /** * Set the capabilities to a new value. * @@ -119,7 +123,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics public String toString() { return getClass().getSimpleName()+"[" + screen + ",\n\tchosen " + capabilitiesChosen+ - ",\n\trequested " + capabilitiesRequested+ + ",\n\trequested " + capabilitiesRequested+ "]"; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 0bf5c2937..d74954a0d 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -140,8 +140,8 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice public final void validateLocked() throws RuntimeException { toolkitLock.validateLocked(); } - - /** + + /** * {@inheritDoc} * <p> * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}. @@ -154,7 +154,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice public final void unlock() { toolkitLock.unlock(); } - + @Override public boolean open() { return false; @@ -174,11 +174,11 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice public boolean isHandleOwner() { return false; } - + @Override - public void clearHandleOwner() { + public void clearHandleOwner() { } - + @Override public String toString() { return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]"; @@ -193,14 +193,14 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice handle = newHandle; return oldHandle; } - + protected Object getHandleOwnership() { return null; } protected Object setHandleOwnership(Object newOwnership) { return null; } - + public static final void swapDeviceHandleAndOwnership(final DefaultGraphicsDevice aDevice1, final DefaultGraphicsDevice aDevice2) { aDevice1.lock(); try { @@ -219,7 +219,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice aDevice1.unlock(); } } - + /** * Set the internal ToolkitLock, which is used within the * {@link #lock()} and {@link #unlock()} implementation. @@ -228,7 +228,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * The current ToolkitLock is being locked/unlocked while swapping the reference, * ensuring no concurrent access can occur during the swap. * </p> - * + * * @param locker the ToolkitLock, if null, {@link jogamp.nativewindow.NullToolkitLock} is being used * @return the previous ToolkitLock instance */ @@ -253,8 +253,8 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice return toolkitLock; } - /** - * Returns a unique String object using {@link String#intern()} for the given arguments, + /** + * Returns a unique String object using {@link String#intern()} for the given arguments, * which object reference itself can be used as a key. */ protected static String getUniqueID(String type, String connection, int unitID) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java index 9fa58c7a3..4bd548916 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -54,10 +54,12 @@ public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen } } + @Override public AbstractGraphicsDevice getDevice() { return device; } - + + @Override public int getIndex() { return idx; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index 9694f2491..c09e6eaa4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -48,7 +48,7 @@ import java.util.Set; /** * Provides the mechanism by which the graphics configuration for a - * window can be chosen before the window is created. The graphics + * window can be chosen before the window is created. The graphics * configuration decides parameters related to hardware accelerated rendering such * as the OpenGL pixel format. <br> * On some window systems (EGL/OpenKODE and X11 in particular) it is necessary to @@ -69,21 +69,23 @@ public abstract class GraphicsConfigurationFactory { public final Class<?> deviceType; public final Class<?> capsType; private final int hash32; - + public DeviceCapsType(Class<?> deviceType, Class<?> capsType) { this.deviceType = deviceType; this.capsType = capsType; - + // 31 * x == (x << 5) - x int hash32 = 31 + deviceType.hashCode(); hash32 = ((hash32 << 5) - hash32) + capsType.hashCode(); this.hash32 = hash32; } - + + @Override public final int hashCode() { return hash32; } - + + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof DeviceCapsType) { @@ -92,18 +94,18 @@ public abstract class GraphicsConfigurationFactory { } return false; } - + @Override public final String toString() { return "DeviceCapsType["+deviceType.getName()+", "+capsType.getName()+"]"; } - + } - + private static final Map<DeviceCapsType, GraphicsConfigurationFactory> registeredFactories; - private static final DeviceCapsType defaultDeviceCapsType; + private static final DeviceCapsType defaultDeviceCapsType; static boolean initialized = false; - + static { DEBUG = Debug.debug("GraphicsConfiguration"); if(DEBUG) { @@ -113,7 +115,7 @@ public abstract class GraphicsConfigurationFactory { registeredFactories = Collections.synchronizedMap(new HashMap<DeviceCapsType, GraphicsConfigurationFactory>()); defaultDeviceCapsType = new DeviceCapsType(AbstractGraphicsDevice.class, CapabilitiesImmutable.class); } - + public static synchronized void initSingleton() { if(!initialized) { initialized = true; @@ -121,31 +123,31 @@ public abstract class GraphicsConfigurationFactory { if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.initSingleton()"); } - + // Register the default no-op factory for arbitrary // AbstractGraphicsDevice implementations, including // AWTGraphicsDevice instances -- the OpenGL binding will take // care of handling AWTGraphicsDevices on X11 platforms (as // well as X11GraphicsDevices in non-AWT situations) registerFactory(defaultDeviceCapsType.deviceType, defaultDeviceCapsType.capsType, new DefaultGraphicsConfigurationFactoryImpl()); - + if (NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true)) { try { - ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory", - "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); + ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory", + "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); } catch (Exception e) { throw new RuntimeException(e); } if(NativeWindowFactory.isAWTAvailable()) { try { - ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory", - "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); + ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory", + "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); } catch (Exception e) { /* n/a */ } } } } } - + public static synchronized void shutdown() { if(initialized) { initialized = false; @@ -155,7 +157,7 @@ public abstract class GraphicsConfigurationFactory { registeredFactories.clear(); } } - + protected static String getThreadName() { return Thread.currentThread().getName(); } @@ -176,10 +178,10 @@ public abstract class GraphicsConfigurationFactory { /** * Returns the graphics configuration factory for use with the * given device and capability. - * + * * @see #getFactory(Class, Class) */ - public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device, CapabilitiesImmutable caps) { + public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device, CapabilitiesImmutable caps) { if (device == null) { throw new IllegalArgumentException("null device"); } @@ -195,7 +197,7 @@ public abstract class GraphicsConfigurationFactory { * <p> * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only. * </p> - * + * * <p> * Pseudo code for finding a suitable factory is: * <pre> @@ -211,7 +213,7 @@ public abstract class GraphicsConfigurationFactory { * @param deviceType the minimum capabilities class type accepted, must implement or extend {@link AbstractGraphicsDevice} * @param capabilitiesType the minimum capabilities class type accepted, must implement or extend {@link CapabilitiesImmutable} * - * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or + * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or * capabilitiesType does not implement {@link CapabilitiesImmutable} */ public static GraphicsConfigurationFactory getFactory(Class<?> deviceType, Class<?> capabilitiesType) @@ -228,12 +230,12 @@ public abstract class GraphicsConfigurationFactory { System.err.println("GraphicsConfigurationFactory.getFactory: "+deviceType.getName()+", "+capabilitiesType.getName()); dumpFactories(); } - - final List<Class<?>> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false); + + final List<Class<?>> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false); if(DEBUG) { System.err.println("GraphicsConfigurationFactory.getFactory() deviceTypes: " + deviceTypes); } - final List<Class<?>> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true); + final List<Class<?>> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true); if(DEBUG) { System.err.println("GraphicsConfigurationFactory.getFactory() capabilitiesTypes: " + capabilitiesTypes); } @@ -259,7 +261,7 @@ public abstract class GraphicsConfigurationFactory { return factory; } private static ArrayList<Class<?>> getAllAssignableClassesFrom(Class<?> superClassOrInterface, Class<?> fromClass, boolean interfacesOnly) { - // Using a todo list avoiding a recursive loop! + // Using a todo list avoiding a recursive loop! final ArrayList<Class<?>> inspectClasses = new ArrayList<Class<?>>(); final ArrayList<Class<?>> resolvedInterfaces = new ArrayList<Class<?>>(); inspectClasses.add(fromClass); @@ -277,7 +279,7 @@ public abstract class GraphicsConfigurationFactory { } } types.addAll(Arrays.asList(fromClass.getInterfaces())); - + for(int i=0; i<types.size(); i++) { final Class<?> iface = types.get(i); if( superClassOrInterface.isAssignableFrom(iface) && !resolvedInterfaces.contains(iface) ) { @@ -302,20 +304,20 @@ public abstract class GraphicsConfigurationFactory { } } - /** + /** * Registers a GraphicsConfigurationFactory handling * the given graphics device and capability class. * <p> * This does not need to be called by end users, only implementors of new * GraphicsConfigurationFactory subclasses. * </p> - * + * * <p> * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only. - * </p> - * + * </p> + * * <p>See {@link #getFactory(Class, Class)} for a description of the find algorithm.</p> - * + * * @param deviceType the minimum capabilities class type accepted, must implement or extend interface {@link AbstractGraphicsDevice} * @param capabilitiesType the minimum capabilities class type accepted, must extend interface {@link CapabilitiesImmutable} * @return the previous registered factory, or null if none @@ -329,7 +331,7 @@ public abstract class GraphicsConfigurationFactory { } if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) { throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable"); - } + } final DeviceCapsType dct = new DeviceCapsType(abstractGraphicsDeviceImplementor, capabilitiesType); final GraphicsConfigurationFactory prevFactory; if(null == factory) { @@ -352,7 +354,7 @@ public abstract class GraphicsConfigurationFactory { * <P> Selects a graphics configuration on the specified graphics * device compatible with the supplied {@link Capabilities}. Some * platforms (e.g.: X11, EGL, KD) require the graphics configuration - * to be specified when the native window is created. + * to be specified when the native window is created. * These architectures have seperated their device, screen, window and drawable * context and hence are capable of quering the capabilities for each screen. * A fully established window is not required.</P> @@ -360,7 +362,7 @@ public abstract class GraphicsConfigurationFactory { * <P>Other platforms (e.g. Windows, MacOSX) don't offer the mentioned seperation * and hence need a fully established window and it's drawable. * Here the validation of the capabilities is performed later. - * In this case, the AbstractGraphicsConfiguration implementation + * In this case, the AbstractGraphicsConfiguration implementation * must allow an overwrite of the Capabilites, for example * {@link DefaultGraphicsConfiguration#setChosenCapabilities DefaultGraphicsConfiguration.setChosenCapabilities(..)}. * </P> @@ -385,7 +387,7 @@ public abstract class GraphicsConfigurationFactory { * @param capsRequested the original requested capabilities * @param chooser the choosing implementation * @param screen the referring Screen - * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system. + * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system. * @return the complete GraphicsConfiguration * * @throws IllegalArgumentException if the data type of the passed diff --git a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java index ff53c8109..a0db11ad9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java @@ -31,12 +31,12 @@ package javax.media.nativewindow; /** * Provides a {@link NativeSurface} with a mutable <code>surfaceHandle</code> * via {@link #setSurfaceHandle(long)}. - * + * * @see NativeSurface */ public interface MutableSurface extends NativeSurface { - /** + /** * Sets the surface handle which is created outside of this implementation. */ public void setSurfaceHandle(long surfaceHandle); diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index a89caec76..a755b1812 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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; /** Provides low-level information required for @@ -54,10 +54,10 @@ public interface NativeSurface extends SurfaceUpdatedListener { * <p> * The surface handle shall be valid after a successfull call, * ie return a value other than {@link #LOCK_SURFACE_UNLOCKED} and {@link #LOCK_SURFACE_NOT_READY}, - * which is - * <pre> - * boolean ok = LOCK_SURFACE_NOT_READY < lockSurface(); - * </pre> + * which is + * <pre> + * boolean ok = LOCK_SURFACE_NOT_READY < lockSurface(); + * </pre> * </p> * <p> * The caller may need to take care of the result {@link #LOCK_SURFACE_CHANGED}, @@ -71,7 +71,7 @@ public interface NativeSurface extends SurfaceUpdatedListener { * This call allows recursion from the same thread. * </p> * <p> - * The implementation may want to aquire the + * The implementation may want to aquire the * application level {@link com.jogamp.common.util.locks.RecursiveLock} * first before proceeding with a native surface lock. * </p> @@ -115,7 +115,7 @@ public interface NativeSurface extends SurfaceUpdatedListener { * </pre> */ public boolean isSurfaceLockedByOtherThread(); - + /** * Return the locking owner's Thread, or null if not locked. */ @@ -123,15 +123,15 @@ public interface NativeSurface extends SurfaceUpdatedListener { /** * Provide a mechanism to utilize custom (pre-) swap surface - * code. This method is called before the render toolkit (e.g. JOGL) + * code. This method is called before the render toolkit (e.g. JOGL) * swaps the buffer/surface if double buffering is enabled. - * <p> + * <p> * The implementation may itself apply the swapping, * in which case true shall be returned. * </p> * * @return true if this method completed swapping the surface, - * otherwise false, in which case eg the GLDrawable + * otherwise false, in which case eg the GLDrawable * implementation has to swap the code. */ public boolean surfaceSwap(); @@ -153,13 +153,13 @@ public interface NativeSurface extends SurfaceUpdatedListener { /** Remove the specified {@link SurfaceUpdatedListener} from the list. */ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l); - + /** * Returns the handle to the surface for this NativeSurface. <P> - * + * * The surface handle should be set/update by {@link #lockSurface()}, * where {@link #unlockSurface()} is not allowed to modify it. - * After {@link #unlockSurface()} it is no more guaranteed + * After {@link #unlockSurface()} it is no more guaranteed * that the surface handle is still valid. * * The surface handle shall reflect the platform one @@ -195,16 +195,16 @@ public interface NativeSurface extends SurfaceUpdatedListener { public AbstractGraphicsConfiguration getGraphicsConfiguration(); /** - * Convenience: Get display handle from + * Convenience: Get display handle from * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice */ public long getDisplayHandle(); /** - * Convenience: Get display handle from + * Convenience: Get display handle from * AbstractGraphicsConfiguration . AbstractGraphicsScreen */ public int getScreenIndex(); - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java index 593c1e7d6..0943c8c09 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 07d1008b4..6962ce505 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -90,13 +90,13 @@ public abstract class NativeWindowFactory { private static final String nativeWindowingTypePure; // canonical String via String.intern() private static final String nativeWindowingTypeCustom; // canonical String via String.intern() - + private static NativeWindowFactory defaultFactory; private static Map<Class<?>, NativeWindowFactory> registeredFactories; - + private static Class<?> nativeWindowClass; private static boolean isAWTAvailable; - + private static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ; /** {@link jogamp.nativewindow.x11.X11Util} implements {@link ToolkitProperties}. */ private static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util"; @@ -104,16 +104,16 @@ public abstract class NativeWindowFactory { private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil"; /** {@link jogamp.nativewindow.windows.GDIUtil} implements {@link ToolkitProperties}. */ private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil"; - + private static ToolkitLock jawtUtilJAWTToolkitLock; - + private static boolean requiresToolkitLock; private static boolean desktopHasThreadingIssues; // Shutdown hook mechanism for the factory private static volatile boolean isJVMShuttingDown = false; private static final List<Runnable> customShutdownHooks = new ArrayList<Runnable>(); - + /** Creates a new NativeWindowFactory instance. End users do not need to call this method. */ protected NativeWindowFactory() { @@ -123,6 +123,7 @@ public abstract class NativeWindowFactory { return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { private final File vcliblocation = new File( "/opt/vc/lib/libbcm_host.so"); + @Override public Boolean run() { if ( vcliblocation.isFile() ) { return Boolean.TRUE; @@ -139,10 +140,10 @@ public abstract class NativeWindowFactory { case MACOS: return TYPE_MACOSX; case WINDOWS: - return TYPE_WINDOWS; + return TYPE_WINDOWS; case OPENKODE: return TYPE_EGL; - + case LINUX: case FREEBSD: case SUNOS: @@ -158,26 +159,28 @@ public abstract class NativeWindowFactory { static { final boolean[] _DEBUG = new boolean[] { false }; final String[] _tmp = new String[] { null }; - + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { Platform.initSingleton(); // last resort .. _DEBUG[0] = Debug.debug("NativeWindow"); _tmp[0] = Debug.getProperty("nativewindow.ws.name", true); Runtime.getRuntime().addShutdownHook( new Thread(new Runnable() { + @Override public void run() { NativeWindowFactory.shutdown(true); - } }, "NativeWindowFactory_ShutdownHook" ) ) ; + } }, "NativeWindowFactory_ShutdownHook" ) ) ; return null; } } ) ; - + DEBUG = _DEBUG[0]; if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - Info: NativeWindowFactory.<init>"); // Thread.dumpStack(); } - + // Gather the windowing TK first nativeWindowingTypePure = _getNativeWindowingType(); if(null==_tmp[0] || _tmp[0].length()==0) { @@ -202,23 +205,23 @@ public abstract class NativeWindowFactory { } if( null != clazzName ) { ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl ); - + final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); requiresToolkitLock = res1.booleanValue(); final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "hasThreadingIssues", null, null, cl); desktopHasThreadingIssues = res2.booleanValue(); - } else { + } else { requiresToolkitLock = false; desktopHasThreadingIssues = false; } } - /** Returns true if the JVM is shutting down, otherwise false. */ + /** Returns true if the JVM is shutting down, otherwise false. */ public static final boolean isJVMShuttingDown() { return isJVMShuttingDown; } - - /** + + /** * Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance. - * + * * @param head if true add runnable at the start, otherwise at the end * @param runnable runnable to be added. */ @@ -234,7 +237,7 @@ public abstract class NativeWindowFactory { } } - /** + /** * Cleanup resources at JVM shutdown */ public static synchronized void shutdown(boolean _isJVMShuttingDown) { @@ -246,14 +249,14 @@ public abstract class NativeWindowFactory { final int cshCount = customShutdownHooks.size(); for(int i=0; i < cshCount; i++) { try { - if( DEBUG ) { + if( DEBUG ) { System.err.println("NativeWindowFactory.shutdown - customShutdownHook #"+(i+1)+"/"+cshCount); } customShutdownHooks.get(i).run(); } catch(Throwable t) { System.err.println("NativeWindowFactory.shutdown: Catched "+t.getClass().getName()+" during customShutdownHook #"+(i+1)+"/"+cshCount); - if( DEBUG ) { - t.printStackTrace(); + if( DEBUG ) { + t.printStackTrace(); } } } @@ -262,7 +265,7 @@ public abstract class NativeWindowFactory { if(DEBUG) { System.err.println("NativeWindowFactory.shutdown(): Post customShutdownHook"); } - + if(initialized) { initialized = false; if(null != registeredFactories) { @@ -271,14 +274,14 @@ public abstract class NativeWindowFactory { } GraphicsConfigurationFactory.shutdown(); } - + shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown // SharedResourceToolkitLock.shutdown(DEBUG); // not used yet if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown); } } - + private static void shutdownNativeImpl(final ClassLoader cl) { final String clazzName; if( TYPE_X11 == nativeWindowingTypePure ) { @@ -292,11 +295,11 @@ public abstract class NativeWindowFactory { } if( null != clazzName ) { ReflectionUtil.callStaticMethod(clazzName, "shutdown", null, null, cl ); - } + } } - + /** Returns true if {@link #initSingleton()} has been called w/o subsequent {@link #shutdown(boolean)}. */ - public static synchronized boolean isInitialized() { return initialized; } + public static synchronized boolean isInitialized() { return initialized; } /** * Static one time initialization of this factory.<br> @@ -316,8 +319,9 @@ public abstract class NativeWindowFactory { if( Platform.AWT_AVAILABLE && ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) { - + Method[] jawtUtilMethods = AccessController.doPrivileged(new PrivilegedAction<Method[]>() { + @Override public Method[] run() { try { Class<?> _jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader()); @@ -327,7 +331,7 @@ public abstract class NativeWindowFactory { jawtUtilInitMethod.setAccessible(true); Method jawtUtilGetJAWTToolkitLockMethod = _jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{}); jawtUtilGetJAWTToolkitLockMethod.setAccessible(true); - return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod }; + return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod }; } catch (Exception e) { if(DEBUG) { e.printStackTrace(); @@ -340,7 +344,7 @@ public abstract class NativeWindowFactory { final Method jawtUtilInitMethod = jawtUtilMethods[0]; final Method jawtUtilIsHeadlessMethod = jawtUtilMethods[1]; final Method jawtUtilGetJAWTToolkitLockMethod = jawtUtilMethods[2]; - + ReflectionUtil.callMethod(null, jawtUtilInitMethod); Object resO = ReflectionUtil.callMethod(null, jawtUtilIsHeadlessMethod); @@ -351,21 +355,21 @@ public abstract class NativeWindowFactory { } else { throw new RuntimeException("JAWTUtil.isHeadlessMode() didn't return a Boolean"); } - resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod); + resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod); if(resO instanceof ToolkitLock) { jawtUtilJAWTToolkitLock = (ToolkitLock) resO; } else { throw new RuntimeException("JAWTUtil.getJAWTToolkitLock() didn't return a ToolkitLock"); - } + } } } - + // X11 initialization after possible AWT initialization // This is performed post AWT initialization, allowing AWT to complete the same, - // which may have been triggered before NativeWindow initialization. - // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..). + // which may have been triggered before NativeWindow initialization. + // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..). initSingletonNativeImpl(cl); - + registeredFactories = Collections.synchronizedMap(new HashMap<Class<?>, NativeWindowFactory>()); // register our default factory -> NativeWindow @@ -373,17 +377,17 @@ public abstract class NativeWindowFactory { nativeWindowClass = javax.media.nativewindow.NativeWindow.class; registerFactory(nativeWindowClass, factory); defaultFactory = factory; - + if ( isAWTAvailable ) { // register either our default factory or (if exist) the X11/AWT one -> AWT Component registerFactory(ReflectionUtil.getClass(ReflectionUtil.AWTNames.ComponentClass, false, cl), factory); } - + if(DEBUG) { System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", desktopHasThreadingIssues "+desktopHasThreadingIssues); System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory); } - + GraphicsConfigurationFactory.initSingleton(); } } @@ -392,20 +396,20 @@ public abstract class NativeWindowFactory { public static boolean requiresToolkitLock() { return requiresToolkitLock; } - + /** @return true if not headless, AWT Component and NativeWindow's AWT part available */ public static boolean isAWTAvailable() { return isAWTAvailable; } /** * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value. - * @return the native window type, e.g. {@link #TYPE_X11}, which is canonical via {@link String#intern()}. + * @return the native window type, e.g. {@link #TYPE_X11}, which is canonical via {@link String#intern()}. * Hence {@link String#equals(Object)} and <code>==</code> produce the same result. */ public static String getNativeWindowType(boolean useCustom) { return useCustom?nativeWindowingTypeCustom:nativeWindowingTypePure; } - /** Don't know if we shall add this factory here .. + /** Don't know if we shall add this factory here .. public static AbstractGraphicsDevice createGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker) { if(TYPE_EGL == type) { return new @@ -427,13 +431,13 @@ public abstract class NativeWindowFactory { return defaultFactory; } - /** + /** * Returns the AWT {@link ToolkitLock} (JAWT based) if {@link #isAWTAvailable}, otherwise null. * <p> * The JAWT based {@link ToolkitLock} also locks the global lock, * which matters if the latter is required. - * </p> - */ + * </p> + */ public static ToolkitLock getAWTToolkitLock() { return jawtUtilJAWTToolkitLock; } @@ -441,7 +445,7 @@ public abstract class NativeWindowFactory { public static ToolkitLock getNullToolkitLock() { return NativeWindowFactoryImpl.getNullToolkitLock(); } - + /** * Provides the system default {@link ToolkitLock} for the default system windowing type. * @see #getNativeWindowType(boolean) @@ -486,7 +490,7 @@ public abstract class NativeWindowFactory { } return NativeWindowFactoryImpl.getNullToolkitLock(); } - + /** * @param device * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen @@ -510,7 +514,7 @@ public abstract class NativeWindowFactory { } return new DefaultGraphicsScreen(device, screen); } - + /** Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be {@link NativeWindow NativeWindow}, in which case the client has @@ -543,7 +547,7 @@ public abstract class NativeWindowFactory { } /** Converts the given window object and it's - {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a + {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a {@link NativeWindow NativeWindow} which can be operated upon by a custom toolkit, e.g. {@link javax.media.opengl.GLDrawableFactory javax.media.opengl.GLDrawableFactory}.<br> The object may be a component for a particular window toolkit, such as an AWT @@ -554,7 +558,7 @@ public abstract class NativeWindowFactory { NativeWindowFactory is responsible for handling objects from a particular window toolkit. The built-in NativeWindowFactory handles NativeWindow instances as well as AWT Components.<br> - + @throws IllegalArgumentException if the given window object could not be handled by any of the registered NativeWindowFactory instances @@ -573,22 +577,22 @@ public abstract class NativeWindowFactory { NativeWindow. Implementors of concrete NativeWindowFactory subclasses should override this method. */ protected abstract NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException; - + /** * Returns the {@link OffscreenLayerSurface} instance of this {@link NativeSurface}. * <p> - * In case this surface is a {@link NativeWindow}, we traverse from the given surface + * In case this surface is a {@link NativeWindow}, we traverse from the given surface * 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>. + * 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 OffscreenLayerOption#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 || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null; @@ -601,12 +605,12 @@ public abstract class NativeWindowFactory { final OffscreenLayerSurface ols = (OffscreenLayerSurface) nw; return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null; } - nw = nw.getParent(); + nw = nw.getParent(); } } - return null; + return null; } - + /** * Returns true if the given visualID is valid for further processing, i.e. OpenGL usage, * otherwise return false. @@ -619,8 +623,8 @@ public abstract class NativeWindowFactory { * </p> */ public static boolean isNativeVisualIDValidForProcessing(int visualID) { - return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) || + return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) || VisualIDHolder.VID_UNDEFINED != visualID ; } - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java index 12d30b3cd..11496899a 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java @@ -32,30 +32,30 @@ package javax.media.nativewindow; * 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() + * @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) + * + * @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 1826008ad..8681422ef 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -33,36 +33,36 @@ import com.jogamp.common.util.locks.RecursiveLock; * Interface specifying the offscreen layer surface protocol. */ public interface OffscreenLayerSurface { - /** + /** * Attach the offscreen layer to this offscreen layer surface. * <p> * Implementation may realize all required resources at this point. * </p> - * + * * @see #isOffscreenLayerSurfaceEnabled() * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException; - - /** + + /** * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) * @see #isOffscreenLayerSurfaceEnabled() - * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false * or no surface layer is attached. */ public void detachSurfaceLayer() throws NativeWindowException; - + /** Returns the attached surface layer or null if none is attached. */ public long getAttachedSurfaceLayer(); - + /** Returns true if a surface layer is attached, otherwise false. */ public boolean isSurfaceLayerAttached(); - + /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */ public void setChosenCapabilities(CapabilitiesImmutable caps); - - /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */ + + /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */ public RecursiveLock getLock(); - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 15a8738c5..0af2bdaf9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -33,44 +33,44 @@ import jogamp.nativewindow.Debug; /** * Provides a mutable {@link NativeSurface}, i.e. {@link MutableSurface}, while allowing an * {@link UpstreamSurfaceHook} to influence the lifecycle and information. - * + * * @see UpstreamSurfaceHook * @see MutableSurface * @see NativeSurface */ -public interface ProxySurface extends MutableSurface { +public interface ProxySurface extends MutableSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); - - /** + + /** * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's surface handle * @see #addUpstreamOptionBits(int) * @see #clearUpstreamOptionBits(int) * @see #getUpstreamOptionBits() - */ + */ public static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE = 1 << 6; - - /** + + /** * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's {@link AbstractGraphicsDevice}. * @see #addUpstreamOptionBits(int) * @see #clearUpstreamOptionBits(int) * @see #getUpstreamOptionBits() - */ + */ public static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE = 1 << 7; - - /** + + /** * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete. * @see #addUpstreamOptionBits(int) * @see #clearUpstreamOptionBits(int) * @see #getUpstreamOptionBits() - */ + */ public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8; /** Allow redefining the AbstractGraphicsConfiguration */ - public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg); + public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg); /** * Return the upstream {@link NativeSurface} if used, otherwise <code>null</code>. - * <p> + * <p> * An upstream {@link NativeSurface} may backup this {@link ProxySurface} instance's representation, * e.g. via a {@link #setUpstreamSurfaceHook(UpstreamSurfaceHook) set} {@link UpstreamSurfaceHook}. * </p> @@ -80,47 +80,48 @@ public interface ProxySurface extends MutableSurface { * </p> */ public NativeSurface getUpstreamSurface(); - + /** Returns the {@link UpstreamSurfaceHook} if {@link #setUpstreamSurfaceHook(UpstreamSurfaceHook) set}, otherwise <code>null</code>. */ public UpstreamSurfaceHook getUpstreamSurfaceHook(); - + /** * Sets the {@link UpstreamSurfaceHook} and returns the previous value. */ public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook); - - /** - * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions + + /** + * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions * {@link UpstreamSurfaceHook#create(ProxySurface)} and {@link UpstreamSurfaceHook#destroy(ProxySurface)}. * <p> * Use this for small code blocks where the native resources shall not change, * i.e. resizing a derived (OpenGL) drawable. - * </p> + * </p> */ public void enableUpstreamSurfaceHookLifecycle(boolean enable); - - /** + + /** * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set. - */ + */ public void createNotify(); - - /** + + /** * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all proxy surface/window handles shall be cleared. - */ + */ public void destroyNotify(); - + public StringBuilder getUpstreamOptionBits(StringBuilder sink); public int getUpstreamOptionBits(); - + /** Returns <code>true</code> if the give bit-mask <code>v</code> is set in this instance upstream-option-bits, otherwise <code>false</code>.*/ public boolean containsUpstreamOptionBits(int v); - + /** Add the given bit-mask to this instance upstream-option-bits using bit-or w/ <code>v</code>.*/ public void addUpstreamOptionBits(int v); - + /** Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ <code>~v</code>*/ public void clearUpstreamOptionBits(int v); - + public StringBuilder toString(StringBuilder sink); + @Override public String toString(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java index 0912b5afe..de65a3031 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java +++ b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package javax.media.nativewindow; diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java index eccfcfa4f..017b996d7 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java @@ -53,26 +53,26 @@ public interface ToolkitLock { * @throws RuntimeException in case of a timeout */ public void lock(); - + /** * Release the lock. * * @throws RuntimeException in case the lock is not acquired by this thread. */ public void unlock(); - + /** - * @throws RuntimeException if current thread does not hold the lock + * @throws RuntimeException if current thread does not hold the lock */ public void validateLocked() throws RuntimeException; - - /** + + /** * Dispose this instance. - * <p> + * <p> * Shall be called when instance is no more required. * </p> * This allows implementations sharing a lock via resources - * to decrease the reference counter. + * to decrease the reference counter. */ public void dispose(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java index 6fe2e5364..f08a6c938 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java +++ b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java @@ -28,24 +28,24 @@ package javax.media.nativewindow; -/** - * Interface allowing upstream caller to pass lifecycle actions and size info - * to a {@link ProxySurface} instance. - */ +/** + * Interface allowing upstream caller to pass lifecycle actions and size info + * to a {@link ProxySurface} instance. + */ public interface UpstreamSurfaceHook { /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ public void create(ProxySurface s); /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ public void destroy(ProxySurface s); - /** Returns the width of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + /** Returns the width of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ public int getWidth(ProxySurface s); - /** Returns the height of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + /** Returns the height of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ public int getHeight(ProxySurface s); - + /** - * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize. - */ + * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize. + */ public interface MutableSize extends UpstreamSurfaceHook { public void setSize(int width, int height); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java index 4f3d3ff00..4ed79b1dc 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java +++ b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java @@ -38,7 +38,7 @@ import java.util.Comparator; * </p> */ public interface VisualIDHolder { - + public enum VIDType { // Generic Values INTRINSIC(0), NATIVE(1), @@ -47,19 +47,19 @@ public interface VisualIDHolder { // X11 Values X11_XVISUAL(20), X11_FBCONFIG(21), // Windows Values - WIN32_PFD(30); - + WIN32_PFD(30); + public final int id; VIDType(int id){ this.id = id; } - } - + } + /** * Returns the native visual ID of the given <code>type</code> * if supported, or {@link #VID_UNDEFINED} if not supported. - * <p> + * <p> * Depending on the native windowing system, <code>type</code> is handled as follows: * <ul> * <li>X11 throws NativeWindowException on <code>EGL_CONFIG</code>, <code>WIN32_PFD</code> @@ -76,7 +76,7 @@ public interface VisualIDHolder { * <li><code>X11_XVISUAL</code>: <i>X11 XVisual ID</i></li> * <li><code>X11_FBCONFIG</code>: <i>X11 FBConfig ID</i> or <code>VID_UNDEFINED</code></li> * </ul></li> - * <li>Windows/GL throws NativeWindowException on <code>EGL_CONFIG</code>, <code>X11_XVISUAL</code>, <code>X11_FBCONFIG</code> + * <li>Windows/GL throws NativeWindowException on <code>EGL_CONFIG</code>, <code>X11_XVISUAL</code>, <code>X11_FBCONFIG</code> * <ul> * <li><code>INTRINSIC</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li> * <li><code>NATIVE</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li> @@ -91,35 +91,36 @@ public interface VisualIDHolder { * </ul> * </p> * Note: <code>INTRINSIC</code> and <code>NATIVE</code> are always handled, - * but may result in {@link #VID_UNDEFINED}. The latter is true if - * the native value are actually undefined or the corresponding object is not + * but may result in {@link #VID_UNDEFINED}. The latter is true if + * the native value are actually undefined or the corresponding object is not * mapped to a native visual object. - * + * * @throws NativeWindowException if <code>type</code> is neither * <code>INTRINSIC</code> nor <code>NATIVE</code> - * and does not match the native implementation. + * and does not match the native implementation. */ int getVisualID(VIDType type) throws NativeWindowException ; - - /** + + /** * {@link #getVisualID(VIDType)} result indicating an undefined value, * which could be cause by an unsupported query. * <p> * We assume the const value <code>0</code> doesn't reflect a valid native visual ID * and is interpreted as <i>no value</i> on all platforms. * This is currently true for Android, X11 and Windows. - * </p> + * </p> */ static final int VID_UNDEFINED = 0; - + /** Comparing {@link VIDType#NATIVE} */ public static class VIDComparator implements Comparator<VisualIDHolder> { private VIDType type; - + public VIDComparator(VIDType type) { this.type = type; } - + + @Override public int compare(VisualIDHolder vid1, VisualIDHolder vid2) { final int id1 = vid1.getVisualID(type); final int id2 = vid2.getVisualID(type); @@ -131,5 +132,5 @@ public interface VisualIDHolder { } return 0; } - } + } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java index 02f68f442..8570b78da 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java +++ b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java @@ -37,7 +37,7 @@ package javax.media.nativewindow; * this protocol default behavior {@link WindowClosingMode#DISPOSE_ON_CLOSE DISPOSE_ON_CLOSE} shall be used.</p> */ public interface WindowClosingProtocol { - + /** * Window closing mode if triggered by toolkit close operation. */ @@ -47,7 +47,7 @@ public interface WindowClosingProtocol { * This is the default behavior within an AWT environment. */ DO_NOTHING_ON_CLOSE, - + /** * Dispose resources on native window close operation.<br> * This is the default behavior in case no underlying toolkit defines otherwise. diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 17b4930c5..b8dc53c83 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -4,14 +4,14 @@ * * 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 @@ -21,12 +21,12 @@ * 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.util; public class Dimension implements Cloneable, DimensionImmutable { @@ -45,10 +45,12 @@ public class Dimension implements Cloneable, DimensionImmutable { this.height=height; } + @Override public Object cloneMutable() { return clone(); } - + + @Override public Object clone() { try { return super.clone(); @@ -92,7 +94,7 @@ public class Dimension implements Cloneable, DimensionImmutable { public int compareTo(final DimensionImmutable d) { final int tsq = width*height; final int xsq = d.getWidth()*d.getHeight(); - + if(tsq > xsq) { return 1; } else if(tsq < xsq) { @@ -100,13 +102,13 @@ public class Dimension implements Cloneable, DimensionImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Dimension) { Dimension p = (Dimension)obj; - return height == p.height && + return height == p.height && width == p.width ; } return false; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index 22bd3f48b..e6cacf4ff 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -46,12 +46,12 @@ public interface DimensionImmutable extends WriteCloneable, Comparable<Dimension /** * <p> * Compares square of size. - * </p> + * </p> * {@inheritDoc} */ @Override public int compareTo(final DimensionImmutable d); - + /** * Checks whether two dimensions objects are equal. Two instances * of <code>DimensionReadOnly</code> are equal if two components @@ -59,8 +59,10 @@ public interface DimensionImmutable extends WriteCloneable, Comparable<Dimension * @return <code>true</code> if the two dimensions are equal; * otherwise <code>false</code>. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index 942c12c2b..c84359dcd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -3,14 +3,14 @@ * * 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 @@ -20,18 +20,18 @@ * 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.util; public class Insets implements Cloneable, InsetsImmutable { static final InsetsImmutable zeroInsets = new Insets(); public static final InsetsImmutable getZero() { return zeroInsets; } - + int l, r, t, b; public Insets() { @@ -44,11 +44,13 @@ public class Insets implements Cloneable, InsetsImmutable { this.t=top; this.b=bottom; } - + + @Override public Object cloneMutable() { return clone(); } - + + @Override protected Object clone() { try { return super.clone(); @@ -77,7 +79,7 @@ public class Insets implements Cloneable, InsetsImmutable { public final void setRightWidth(int right) { r = right; } public final void setTopHeight(int top) { t = top; } public final void setBottomHeight(int bottom) { b = bottom; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -99,6 +101,7 @@ public class Insets implements Cloneable, InsetsImmutable { return sum3 * (sum3 + 1)/2 + val2; } + @Override public String toString() { return new String("[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]"); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java index 075641ede..8256068cd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java @@ -41,13 +41,13 @@ public interface InsetsImmutable extends WriteCloneable { /** @return total width, ie. <code>left_width + right_width</code> */ int getTotalWidth(); - + /** @return top inset height */ int getTopHeight(); /** @return bottom inset height */ int getBottomHeight(); - + /** @return total height, ie. <code>top_height + bottom_height</code> */ int getTotalHeight(); @@ -59,8 +59,10 @@ public interface InsetsImmutable extends WriteCloneable { * @return <code>true</code> if the two Insets are equal; * otherwise <code>false</code>. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 4c233bb16..57c6fb716 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -42,10 +42,12 @@ public class Point implements Cloneable, PointImmutable { this(0, 0); } + @Override public Object cloneMutable() { return clone(); } - + + @Override public Object clone() { try { return super.clone(); @@ -58,7 +60,7 @@ public class Point implements Cloneable, PointImmutable { public int compareTo(final PointImmutable d) { final int sq = x*y; final int xsq = d.getX()*d.getY(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -66,7 +68,7 @@ public class Point implements Cloneable, PointImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -95,6 +97,7 @@ public class Point implements Cloneable, PointImmutable { return hash; } + @Override public String toString() { return new String( x + " / " + y ); } @@ -120,5 +123,5 @@ public class Point implements Cloneable, PointImmutable { y *= sy ; return this; } - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index b00329bb5..08c628cc1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -41,12 +41,12 @@ public interface PointImmutable extends WriteCloneable, Comparable<PointImmutabl /** * <p> * Compares the square of the position. - * </p> + * </p> * {@inheritDoc} */ @Override public int compareTo(final PointImmutable d); - + /** * Checks whether two points objects are equal. Two instances * of <code>PointReadOnly</code> are equal if the two components @@ -54,8 +54,10 @@ public interface PointImmutable extends WriteCloneable, Comparable<PointImmutabl * @return <code>true</code> if the two points are equal; * otherwise <code>false</code>. */ + @Override public boolean equals(Object obj); + @Override public int hashCode(); - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index bbbfa2932..8dc8f4562 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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.util; import java.util.List; @@ -46,11 +46,13 @@ public class Rectangle implements Cloneable, RectangleImmutable { this.width=width; this.height=height; } - + + @Override public Object cloneMutable() { return clone(); } - + + @Override protected Object clone() { try { return super.clone(); @@ -67,7 +69,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { public final int getWidth() { return width; } @Override public final int getHeight() { return height; } - + public final void set(int x, int y, int width, int height) { this.x = x; this.y = y; @@ -89,7 +91,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { final int y1 = Math.min(y, ry1); final int x2 = Math.max(x + width, rx2); final int y2 = Math.max(y + height, ry2); - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); } /** * Calculates the union of the given rectangles, stores it in this instance and returns this instance. @@ -109,7 +111,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { set(x1, y1, x2 - x1, y2 - y1); return this; } - + @Override public final RectangleImmutable intersection(RectangleImmutable r) { return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); @@ -144,13 +146,13 @@ public class Rectangle implements Cloneable, RectangleImmutable { final float sqT = (float) ( width*height ); return sqI / sqT; } - + @Override public int compareTo(final RectangleImmutable d) { { final int sq = width*height; final int xsq = d.getWidth()*d.getHeight(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -160,7 +162,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { { final int sq = x*y; final int xsq = d.getX()*d.getY(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -169,7 +171,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -191,6 +193,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { return sum3 * (sum3 + 1)/2 + val2; } + @Override public String toString() { return new String("[ "+x+" / "+y+" "+width+" x "+height+" ]"); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index 440d9e000..7ca92ff53 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -49,7 +49,7 @@ public interface RectangleImmutable extends WriteCloneable, Comparable<Rectangle RectangleImmutable intersection(RectangleImmutable r); /** Returns the intersection of this rectangleand the given coordinates. */ RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2); - /** + /** * Returns the coverage of given rectangle w/ this this one, i.e. between <code>0.0</code> and <code>1.0</code>. * <p> * Coverage is computed by: @@ -57,19 +57,19 @@ public interface RectangleImmutable extends WriteCloneable, Comparable<Rectangle * isect = this.intersection(r); * coverage = area( isect ) / area( this ) ; * </pre> - * </p> + * </p> */ float coverage(RectangleImmutable r); - + /** * <p> * Compares square of size 1st, if equal the square of position. - * </p> + * </p> * {@inheritDoc} */ @Override public int compareTo(final RectangleImmutable d); - + /** * Checks whether two rect objects are equal. Two instances * of <code>Rectangle</code> are equal if the four integer values @@ -78,8 +78,10 @@ public interface RectangleImmutable extends WriteCloneable, Comparable<Rectangle * @return <code>true</code> if the two rectangles are equal; * otherwise <code>false</code>. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 3084816a5..f1749dfa6 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -4,14 +4,14 @@ * * 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 @@ -21,15 +21,15 @@ * 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.util; -/** +/** * Immutable SurfaceSize Class, consisting of it's read only components:<br> * <ul> * <li>{@link javax.media.nativewindow.util.DimensionImmutable} size in pixels</li> @@ -56,6 +56,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { return bitsPerPixel; } + @Override public final String toString() { return new String("[ "+resolution+" x "+bitsPerPixel+" bpp ]"); } @@ -63,7 +64,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { /** * <p> * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel. - * </p> + * </p> * {@inheritDoc} */ @Override @@ -72,7 +73,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { if( 0 != rres ) { return rres; } - final int xbpp = ssz.getBitsPerPixel(); + final int xbpp = ssz.getBitsPerPixel(); if(bitsPerPixel > xbpp) { return 1; } else if(bitsPerPixel < xbpp) { @@ -80,7 +81,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { } return 0; } - + /** * Checks whether two size objects are equal. Two instances * of <code>SurfaceSize</code> are equal if the two components @@ -89,6 +90,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { * @return <code>true</code> if the two dimensions are equal; * otherwise <code>false</code>. */ + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof SurfaceSize) { @@ -99,6 +101,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { return false; } + @Override public final int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + getResolution().hashCode(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index c5e316364..b7197dbca 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -51,9 +51,10 @@ public class Debug extends PropertyAccess { // Some common properties private static final boolean verbose; private static final boolean debugAll; - + static { AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { PropertyAccess.addTrustedPrefix("nativewindow."); return null; diff --git a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java index 52e9c8308..8fb819251 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -36,6 +36,7 @@ package jogamp.nativewindow; import javax.media.nativewindow.*; public class DefaultGraphicsConfigurationFactoryImpl extends GraphicsConfigurationFactory { + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) { return new DefaultGraphicsConfiguration(screen, capsChosen, capsRequested); diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java index c9f830811..cadef9bf1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java @@ -36,20 +36,20 @@ import com.jogamp.common.util.locks.RecursiveLock; /** * Implementing a global recursive {@link javax.media.nativewindow.ToolkitLock}. * <p> - * This is the last resort for unstable driver where multiple X11 display connections + * This is the last resort for unstable driver where multiple X11 display connections * to the same connection name are not treated thread safe within the GL/X11 driver. * </p> */ public class GlobalToolkitLock implements ToolkitLock { private static final RecursiveLock globalLock = LockFactory.createRecursiveLock(); private static GlobalToolkitLock singleton = new GlobalToolkitLock(); - + public static final GlobalToolkitLock getSingleton() { return singleton; } - + private GlobalToolkitLock() { } - + @Override public final void lock() { globalLock.lock(); @@ -61,17 +61,18 @@ public class GlobalToolkitLock implements ToolkitLock { if(TRACE_LOCK) { System.err.println("GlobalToolkitLock.unlock()"); } globalLock.unlock(); // implicit lock validation } - + @Override public final void validateLocked() throws RuntimeException { globalLock.validateLocked(); } - + @Override public final void dispose() { // nop } - + + @Override public String toString() { return "GlobalToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+globalLock.isOwner(Thread.currentThread())+", "+globalLock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 1a106b1b9..e7eb13756 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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 jogamp.nativewindow; @@ -36,9 +36,10 @@ import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; -public class NWJNILibLoader extends JNILibLoaderBase { +public class NWJNILibLoader extends JNILibLoaderBase { public static boolean loadNativeWindow(final String ossuffix) { return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + @Override public Boolean run() { Platform.initSingleton(); final String libName = "nativewindow_"+ossuffix ; diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index a3a66b7f1..22ac3bd94 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -48,9 +48,10 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { public static ToolkitLock getNullToolkitLock() { return nullToolkitLock; } - + // This subclass of NativeWindowFactory handles the case of // NativeWindows being passed in + @Override protected NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException { if (winObj instanceof NativeWindow) { // Use the NativeWindow directly @@ -69,7 +70,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { winObj.getClass().getName() + " is unsupported; expected " + "javax.media.nativewindow.NativeWindow or "+AWTNames.ComponentClass); } - + private Constructor<?> nativeWindowConstructor = null; private NativeWindow getAWTNativeWindow(Object winObj, AbstractGraphicsConfiguration config) { @@ -93,7 +94,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { } nativeWindowConstructor = ReflectionUtil.getConstructor( - windowClassName, new Class[] { Object.class, AbstractGraphicsConfiguration.class }, + windowClassName, new Class[] { Object.class, AbstractGraphicsConfiguration.class }, getClass().getClassLoader()); } catch (Exception e) { throw new IllegalArgumentException(e); diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index 5fc5fe376..bda20522c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -38,7 +38,7 @@ import javax.media.nativewindow.ToolkitLock; public class NullToolkitLock implements ToolkitLock { /** Singleton via {@link NativeWindowFactoryImpl#getNullToolkitLock()} */ protected NullToolkitLock() { } - + @Override public final void lock() { if(TRACE_LOCK) { @@ -51,21 +51,22 @@ public class NullToolkitLock implements ToolkitLock { public final void unlock() { if(TRACE_LOCK) { System.err.println("NullToolkitLock.unlock()"); } } - + @Override public final void validateLocked() throws RuntimeException { if( NativeWindowFactory.requiresToolkitLock() ) { throw new RuntimeException("NullToolkitLock does not lock, but locking is required."); } } - + @Override public final void dispose() { // nop } - + + @Override public String toString() { return "NullToolkitLock[]"; } - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java index 56e342793..097fffead 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -40,7 +40,7 @@ import javax.media.nativewindow.UpstreamSurfaceHook; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -public abstract class ProxySurfaceImpl implements ProxySurface { +public abstract class ProxySurfaceImpl implements ProxySurface { private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); private AbstractGraphicsConfiguration config; // control access due to delegation private UpstreamSurfaceHook upstream; @@ -70,15 +70,15 @@ public abstract class ProxySurfaceImpl implements ProxySurface { this.upstreamSurfaceHookLifecycleEnabled = true; if(ownsDevice) { addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); - } + } } @Override public NativeSurface getUpstreamSurface() { return null; } - + @Override public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } - + @Override public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook) { if(null == hook) { @@ -86,14 +86,14 @@ public abstract class ProxySurfaceImpl implements ProxySurface { } upstream = hook; } - + @Override public final void enableUpstreamSurfaceHookLifecycle(boolean enable) { upstreamSurfaceHookLifecycleEnabled = enable; } - + @Override - public void createNotify() { + public void createNotify() { if(upstreamSurfaceHookLifecycleEnabled) { upstream.create(this); } @@ -113,15 +113,15 @@ public abstract class ProxySurfaceImpl implements ProxySurface { } this.surfaceHandle_old = 0; } - - /** + + /** * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. - * @see #destroyNotify() + * @see #destroyNotify() */ protected void invalidateImpl() { - throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); + throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); } - + protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { return config; } @@ -140,7 +140,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { public final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { config = cfg; } - + @Override public final int getScreenIndex() { return getGraphicsConfiguration().getScreen().getIndex(); @@ -151,7 +151,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { @Override public abstract void setSurfaceHandle(long surfaceHandle); - + @Override public final int getWidth() { return upstream.getWidth(this); @@ -252,7 +252,8 @@ public abstract class ProxySurfaceImpl implements ProxySurface { public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } - + + @Override public final StringBuilder getUpstreamOptionBits(StringBuilder sink) { if(null == sink) { sink = new StringBuilder(); @@ -284,21 +285,21 @@ public abstract class ProxySurfaceImpl implements ProxySurface { sink.append(" ]"); return sink; } - + @Override public final int getUpstreamOptionBits() { return implBitfield; } - + @Override public final boolean containsUpstreamOptionBits(int v) { return v == ( implBitfield & v ) ; } - + @Override public final void addUpstreamOptionBits(int v) { implBitfield |= v; } - + @Override public final void clearUpstreamOptionBits(int v) { implBitfield &= ~v; } - + @Override public StringBuilder toString(StringBuilder sink) { if(null == sink) { @@ -315,7 +316,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { // append("\n, upstreamSurface "+getUpstreamSurface()); return sink; } - + @Override public String toString() { StringBuilder msg = new StringBuilder(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java index 5b79de0b8..f1efb8133 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -50,7 +50,7 @@ public class ResourceToolkitLock implements ToolkitLock { private ResourceToolkitLock() { this.lock = LockFactory.createRecursiveLock(); } - + @Override public final void lock() { lock.lock(); @@ -62,17 +62,18 @@ public class ResourceToolkitLock implements ToolkitLock { if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.unlock()"); } lock.unlock(); // implicit lock validation } - + @Override public final void validateLocked() throws RuntimeException { lock.validateLocked(); } - + @Override public final void dispose() { // nop } - + + @Override public String toString() { return "ResourceToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java index 94d12e6fc..7b74e1f1f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -54,8 +54,8 @@ public class SharedResourceToolkitLock implements ToolkitLock { handle2Lock = new LongObjectHashMap(); handle2Lock.setKeyNotFoundValue(null); } - - /** + + /** * @return number of unclosed EGL Displays.<br> */ public static int shutdown(boolean verbose) { @@ -70,7 +70,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { } return handle2Lock.size(); } - + public static void dumpOpenDisplayConnections() { System.err.println("SharedResourceToolkitLock: Open ResourceToolkitLock's: "+handle2Lock.size()); int i=0; @@ -79,7 +79,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { System.err.println("SharedResourceToolkitLock: Open["+i+"]: "+e.value); } } - + public static final SharedResourceToolkitLock get(long handle) { SharedResourceToolkitLock res; synchronized(handle2Lock) { @@ -106,8 +106,8 @@ public class SharedResourceToolkitLock implements ToolkitLock { this.handle = handle; this.refCount = 0; } - - + + @Override public final void lock() { lock.lock(); @@ -119,12 +119,12 @@ public class SharedResourceToolkitLock implements ToolkitLock { if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.unlock()"); } lock.unlock(); } - + @Override public final void validateLocked() throws RuntimeException { lock.validateLocked(); } - + @Override public final void dispose() { if(0 < refCount) { // volatile OK @@ -141,7 +141,8 @@ public class SharedResourceToolkitLock implements ToolkitLock { if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * NULL *: "+this); } } } - + + @Override public String toString() { return "SharedResourceToolkitLock[refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index 4f68c6945..1e83232bb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -39,27 +39,27 @@ public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { // // Management Utils - // + // public int size() { return surfaceUpdatedListeners.size(); } public SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); } - + // // Implementation of NativeSurface SurfaceUpdatedListener methods - // - + // + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { addSurfaceUpdatedListener(-1, l); } - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { if(l == null) { return; } synchronized(surfaceUpdatedListenersLock) { - if(0>index) { - index = surfaceUpdatedListeners.size(); + if(0>index) { + index = surfaceUpdatedListeners.size(); } surfaceUpdatedListeners.add(index, l); } @@ -74,6 +74,7 @@ public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { } } + @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { synchronized(surfaceUpdatedListenersLock) { for(int i = 0; i < surfaceUpdatedListeners.size(); i++ ) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java index ed23def8f..47b3e63fa 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java @@ -8,14 +8,14 @@ import javax.media.nativewindow.NativeWindowFactory; * Implementation requires to provide static methods: * <pre> public static void initSingleton() {} - + public static void shutdown() {} - + public static boolean requiresToolkitLock() {} - + public static boolean hasThreadingIssues() {} * </pre> - * Above static methods are invoked by {@link NativeWindowFactory#initSingleton()}, + * Above static methods are invoked by {@link NativeWindowFactory#initSingleton()}, * or {@link NativeWindowFactory#shutdown()} via reflection. * </p> */ @@ -25,23 +25,23 @@ public interface ToolkitProperties { * Called by {@link NativeWindowFactory#initSingleton()} */ // void initSingleton(); - - /** + + /** * Cleanup resources. * <p> * Called by {@link NativeWindowFactory#shutdown()} * </p> */ // void shutdown(); - + /** * Called by {@link NativeWindowFactory#initSingleton()} */ // boolean requiresToolkitLock(); - + /** * Called by {@link NativeWindowFactory#initSingleton()} */ - // boolean hasThreadingIssues(); - + // boolean hasThreadingIssues(); + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java index c94f249a1..f622db8cc 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -37,7 +37,7 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; /** * Generic Surface implementation which wraps an existing window handle. - * + * * @see ProxySurface */ public class WrappedSurface extends ProxySurfaceImpl { @@ -46,7 +46,7 @@ public class WrappedSurface extends ProxySurfaceImpl { /** * Utilizes a {@link UpstreamSurfaceHook.MutableSize} to hold the size information, * which is being passed to the {@link ProxySurface} instance. - * + * * @param cfg the {@link AbstractGraphicsConfiguration} to be used * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined * @param initialWidth @@ -59,7 +59,7 @@ public class WrappedSurface extends ProxySurfaceImpl { super(cfg, new UpstreamSurfaceHookMutableSize(initialWidth, initialHeight), ownsDevice); surfaceHandle=handle; } - + /** * @param cfg the {@link AbstractGraphicsConfiguration} to be used * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined @@ -74,7 +74,7 @@ public class WrappedSurface extends ProxySurfaceImpl { } @Override - protected void invalidateImpl() { + protected void invalidateImpl() { surfaceHandle = 0; } @@ -87,7 +87,7 @@ public class WrappedSurface extends ProxySurfaceImpl { public final void setSurfaceHandle(long surfaceHandle) { this.surfaceHandle=surfaceHandle; } - + @Override protected final int lockSurfaceImpl() { return LOCK_SUCCESS; diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 23c48d20e..0fa5006cc 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -71,19 +71,19 @@ public class AWTMisc { } return (Container) c; } - + /** * Return insets of the component w/o traversing up to parent, * i.e. trying Window and JComponent. * <p> - * Exception is JRootPane. + * Exception is JRootPane. * Return it's parent's Window component's insets if available, * otherwise return JRootPane's insets.<br> - * This is due to <i>experience</i> that <i>some</i> JRootPane's + * This is due to <i>experience</i> that <i>some</i> JRootPane's * do not expose valid insets value. * </p> * @param topLevelOnly if true only returns insets of top-level components, i.e. Window and JRootPanel, - * otherwise for JComponent as well. + * otherwise for JComponent as well. */ public static Insets getInsets(Component c, boolean topLevelOnly) { if( c instanceof Window ) { @@ -108,7 +108,7 @@ public class AWTMisc { */ public void run(Component c); } - + public static int performAction(Container c, Class<?> cType, ComponentAction action) { int count = 0; final int cc = c.getComponentCount(); @@ -128,18 +128,18 @@ public class AWTMisc { } return count; } - + /** * Traverse to the next forward or backward component using the * container's FocusTraversalPolicy. - * - * @param comp the assumed current focuse component + * + * @param comp the assumed current focuse component * @param forward if true, returns the next focus component, otherwise the previous one. * @return */ public static Component getNextFocus(Component comp, boolean forward) { Container focusContainer = comp.getFocusCycleRootAncestor(); - while ( focusContainer != null && + while ( focusContainer != null && ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) { comp = focusContainer; @@ -155,7 +155,7 @@ public class AWTMisc { } return next; } - + /** * Issue this when your non AWT toolkit gains focus to clear AWT menu path */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java index f579da217..a5da41424 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -47,15 +47,16 @@ import java.awt.Toolkit; import java.security.AccessController; import java.security.PrivilegedAction; -public class JAWTJNILibLoader extends NWJNILibLoader { +public class JAWTJNILibLoader extends NWJNILibLoader { static { AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { // Make sure that awt.dll is loaded before loading jawt.dll. Otherwise // a Dialog with "awt.dll not found" might pop up. // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4481947. Toolkit.getDefaultToolkit(); - + // Must pre-load JAWT on all non-Mac platforms to // ensure references from jogl_awt shared object // will succeed since JAWT shared object isn't in @@ -74,9 +75,9 @@ public class JAWTJNILibLoader extends NWJNILibLoader { } }); } - + public static void initSingleton() { - // just exist to ensure static init has been run + // just exist to ensure static init has been run } - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 844b17469..5a1d915ce 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. @@ -63,13 +63,13 @@ public class JAWTUtil { /** OSX JAWT version option to use CALayer */ public static final int JAWT_MACOSX_USE_CALAYER = 0x80000000; - + /** OSX JAWT CALayer availability on Mac OS X >= 10.6 Update 4 (recommended) */ public static final VersionNumber JAWT_MacOSXCALayerMinVersion = new VersionNumber(10,6,4); - + /** OSX JAWT CALayer required with Java >= 1.7.0 (implies OS X >= 10.7 */ public static final VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion = Platform.Version17; - + // See whether we're running in headless mode private static final boolean headlessMode; private static final JAWT jawtLockObject; @@ -81,27 +81,27 @@ public class JAWTUtil { private static final Method sunToolkitAWTLockMethod; private static final Method sunToolkitAWTUnlockMethod; private static final boolean hasSunToolkitAWTLock; - + private static final RecursiveLock jawtLock; private static final ToolkitLock jawtToolkitLock; private static class PrivilegedDataBlob1 { PrivilegedDataBlob1() { ok = false; - } + } Method sunToolkitAWTLockMethod; Method sunToolkitAWTUnlockMethod; boolean ok; } - + /** * Returns true if this platform's JAWT implementation supports offscreen layer. */ public static boolean isOffscreenLayerSupported() { return Platform.OS_TYPE == Platform.OSType.MACOS && - Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0; + Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0; } - + /** * Returns true if this platform's JAWT implementation requires using offscreen layer. */ @@ -109,8 +109,8 @@ public class JAWTUtil { return Platform.OS_TYPE == Platform.OSType.MACOS && Platform.JAVA_VERSION_NUMBER.compareTo(JAWT_MacOSXCALayerRequiredForJavaVersion)>=0; } - - /** + + /** * CALayer size needs to be set using the AWT component size. * <p> * AWT's super-calayer, i.e. the AWT's own component CALayer, @@ -120,13 +120,13 @@ public class JAWTUtil { * <p> * As of today, this flag is enabled for all known AWT versions. * </p> - * <p> + * <p> * Sync w/ NativeWindowProtocols.h - * </p> + * </p> */ public static final int JAWT_OSX_CALAYER_QUIRK_SIZE = 1 << 0; - - /** + + /** * CALayer position needs to be set to zero. * <p> * AWT's super-calayer, i.e. the AWT's own component CALayer, @@ -137,19 +137,19 @@ public class JAWTUtil { * </p> * <p> * Further more a re-layout seems to be required in this case, - * i.e. a programmatic forced resize +1 and it's inverted resize -1. + * i.e. a programmatic forced resize +1 and it's inverted resize -1. * </p> * <p> - * This flag is enabled w/ AWT < 1.7.0_40. + * This flag is enabled w/ AWT < 1.7.0_40. * </p> - * <p> + * <p> * Sync w/ NativeWindowProtocols.h - * </p> + * </p> */ public static final int JAWT_OSX_CALAYER_QUIRK_POSITION = 1 << 1; - - /** - * CALayer position needs to be derived from AWT position + + /** + * CALayer position needs to be derived from AWT position * in relation to super CALayer. * <p> * AWT's super-calayer, i.e. the AWT top-container's CALayer, @@ -165,7 +165,7 @@ public class JAWTUtil { * </p> * <p> * The super-calayer lies within the AWT top-container client space (content). - * </p> + * </p> * <p> * Component's location in super-calayer: * <pre> @@ -188,12 +188,12 @@ public class JAWTUtil { * <p> * As of today, this flag is enabled for w/ AWT >= 1.7.0_40. * </p> - * <p> + * <p> * Sync w/ NativeWindowProtocols.h - * </p> + * </p> */ public static final int JAWT_OSX_CALAYER_QUIRK_LAYOUT = 1 << 2; - + /** * Returns bitfield of required JAWT OSX CALayer quirks to mediate AWT impl. bugs. * <p> @@ -211,12 +211,12 @@ public class JAWTUtil { */ public static int getOSXCALayerQuirks() { int res = 0; - if( Platform.OS_TYPE == Platform.OSType.MACOS && + if( Platform.OS_TYPE == Platform.OSType.MACOS && Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0 ) { - + /** Knowing impl. all expose the SIZE bug */ res |= JAWT_OSX_CALAYER_QUIRK_SIZE; - + final int c = Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version17); if( c < 0 || c == 0 && Platform.JAVA_VERSION_UPDATE < 40 ) { res |= JAWT_OSX_CALAYER_QUIRK_POSITION; @@ -226,20 +226,20 @@ public class JAWTUtil { } return res; } - + /** * @param useOffscreenLayerIfAvailable * @return */ public static JAWT getJAWT(boolean useOffscreenLayerIfAvailable) { - final int jawt_version_flags = JAWTFactory.JAWT_VERSION_1_4; + final int jawt_version_flags = JAWTFactory.JAWT_VERSION_1_4; JAWT jawt = JAWT.create(); - + // default queries boolean tryOffscreenLayer; boolean tryOnscreen; int jawt_version_flags_offscreen = jawt_version_flags; - + if(isOffscreenLayerRequired()) { if(Platform.OS_TYPE == Platform.OSType.MACOS) { if(Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0) { @@ -263,11 +263,11 @@ public class JAWTUtil { } else { tryOffscreenLayer = false; tryOnscreen = true; - } + } if(DEBUG) { System.err.println("JAWTUtil.getJAWT(tryOffscreenLayer "+tryOffscreenLayer+", tryOnscreen "+tryOnscreen+")"); } - + StringBuilder errsb = new StringBuilder(); if(tryOffscreenLayer) { errsb.append("Offscreen 0x").append(Integer.toHexString(jawt_version_flags_offscreen)); @@ -282,15 +282,15 @@ public class JAWTUtil { errsb.append("Onscreen 0x").append(Integer.toHexString(jawt_version_flags)); if( JAWT.getJAWT(jawt, jawt_version_flags) ) { return jawt; - } + } } throw new RuntimeException("Unable to initialize JAWT, trials: "+errsb.toString()); } - + public static boolean isJAWTUsingOffscreenLayer(JAWT jawt) { return 0 != ( jawt.getCachedVersion() & JAWTUtil.JAWT_MACOSX_USE_CALAYER ); } - + static { if(DEBUG) { System.err.println("JAWTUtil initialization (JAWT/JNI/..."); @@ -319,10 +319,11 @@ public class JAWTUtil { isQueueFlusherThread = m; j2dExist = ok; - PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction<Object>() { + PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { PrivilegedDataBlob1 d = new PrivilegedDataBlob1(); - try { + try { final Class<?> sunToolkitClass = Class.forName("sun.awt.SunToolkit"); d.sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[]{}); d.sunToolkitAWTLockMethod.setAccessible(true); @@ -337,7 +338,7 @@ public class JAWTUtil { }); sunToolkitAWTLockMethod = pdb1.sunToolkitAWTLockMethod; sunToolkitAWTUnlockMethod = pdb1.sunToolkitAWTUnlockMethod; - + boolean _hasSunToolkitAWTLock = false; if ( pdb1.ok ) { try { @@ -351,10 +352,12 @@ public class JAWTUtil { // hasSunToolkitAWTLock = false; jawtLock = LockFactory.createRecursiveLock(); - jawtToolkitLock = new ToolkitLock() { + jawtToolkitLock = new ToolkitLock() { + @Override public final void lock() { JAWTUtil.lockToolkit(); - } + } + @Override public final void unlock() { JAWTUtil.unlockToolkit(); } @@ -380,6 +383,7 @@ public class JAWTUtil { } else { final ArrayList<Map<?,?>> desktophintsBucket = new ArrayList<Map<?,?>>(1); EventQueue.invokeAndWait(new Runnable() { + @Override public void run() { Map<?,?> _desktophints = (Map<?,?>)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); if(null!=_desktophints) { @@ -411,11 +415,11 @@ public class JAWTUtil { public static void initSingleton() { // just exist to ensure static init has been run } - + /** * Called by {@link NativeWindowFactory#shutdown()} */ - public static void shutdown() { + public static void shutdown() { } public static boolean hasJava2D() { @@ -443,7 +447,7 @@ public class JAWTUtil { * which just uses AWT's global ReentrantLock. * </p> * <p> - * AWT locking is wrapped through a recursive lock object. + * AWT locking is wrapped through a recursive lock object. * </p> */ public static void lockToolkit() throws NativeWindowException { @@ -471,11 +475,11 @@ public class JAWTUtil { * which just uses AWT's global ReentrantLock. * </p> * <p> - * AWT unlocking is wrapped through a recursive lock object. + * AWT unlocking is wrapped through a recursive lock object. * </p> */ public static void unlockToolkit() { - jawtLock.validateLocked(); + jawtLock.validateLocked(); if(ToolkitLock.TRACE_LOCK) { System.err.println("JAWTUtil-ToolkitLock.unlock(): "+jawtLock); } if( 1 == jawtLock.getHoldCount() ) { if(!headlessMode && !isJava2DQueueFlusherThread()) { @@ -492,14 +496,14 @@ public class JAWTUtil { } jawtLock.unlock(); } - + public static final void validateLocked() throws RuntimeException { jawtLock.validateLocked(); - } + } public static ToolkitLock getJAWTToolkitLock() { return jawtToolkitLock; } - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java index 40d7b8032..4f12d1925 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index b712f6a1a..600aa6cb2 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -88,6 +88,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.DestroyNSWindow(windowHandle); } OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { if( 0 != rootSurfaceLayer ) { if( 0 != jawtSurfaceLayersHandle) { @@ -102,10 +103,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } windowHandle=0; } - + @Override protected void attachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. // Determine p0: components location on screen w/o insets. @@ -119,7 +121,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if( null != outterInsets ) { p1.translate(-outterInsets.left, -outterInsets.top); } - + if( DEBUG ) { final java.awt.Point pA0 = component.getLocationOnScreen(); final Point pA1 = new Point(pA0.x, pA0.y); @@ -133,7 +135,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks()); } } ); } - + @Override protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) { final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks(); @@ -149,7 +151,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if( null != outterInsets ) { p1.translate(-outterInsets.left, -outterInsets.top); } - + if( DEBUG ) { final java.awt.Point pA0 = component.getLocationOnScreen(); final Point pA1 = new Point(pA0.x, pA0.y); @@ -163,26 +165,28 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks); } - + @Override protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { detachNotify.run(); OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle); } } ); } - + @Override public final long getWindowHandle() { return windowHandle; } - + @Override public final long getSurfaceHandle() { return offscreenSurfaceDrawableSet ? offscreenSurfaceDrawable : drawable /* super.getSurfaceHandle() */ ; } - + + @Override public void setSurfaceHandle(long surfaceHandle) { if( !isOffscreenLayerSurfaceEnabled() ) { throw new java.lang.UnsupportedOperationException("Not using CALAYER"); @@ -194,11 +198,13 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { this.offscreenSurfaceDrawableSet = true; } + @Override protected JAWT fetchJAWTImpl() throws NativeWindowException { // use offscreen if supported and [ applet or requested ] return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet()); } - + + @Override protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SURFACE_NOT_READY; ds = getJAWT().GetDrawingSurface(component); @@ -223,6 +229,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } if (firstLock) { AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { dsi = ds.GetDrawingSurfaceInfo(); return null; @@ -247,7 +254,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { return NativeWindow.LOCK_SURFACE_NOT_READY; } drawable = macosxdsi.getCocoaViewRef(); - + if (drawable == 0) { unlockSurfaceImpl(); return NativeWindow.LOCK_SURFACE_NOT_READY; @@ -259,9 +266,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { /** * Only create a fake invisible NSWindow for the drawable handle * to please frameworks requiring such (eg. NEWT). - * - * The actual surface/ca-layer shall be created/attached - * by the upper framework (JOGL) since they require more information. + * + * The actual surface/ca-layer shall be created/attached + * by the upper framework (JOGL) since they require more information. */ String errMsg = null; if(0 == drawable) { @@ -284,12 +291,13 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(null == errMsg) { jawtSurfaceLayersHandle = GetJAWTSurfaceLayersHandle0(dsi.getBuffer()); OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { String errMsg = null; - if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { + if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayer) { - errMsg = "Could not create root CALayer"; + errMsg = "Could not create root CALayer"; } else { try { SetJAWTRootSurfaceLayer0(jawtSurfaceLayersHandle, rootSurfaceLayer); @@ -318,10 +326,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } ret = NativeWindow.LOCK_SUCCESS; } - + return ret; } - + + @Override protected void unlockSurfaceImpl() throws NativeWindowException { if(null!=ds) { if (null!=dsi) { @@ -340,7 +349,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { System.err.println("MaxOSXJAWTWindow: 0x"+Integer.toHexString(this.hashCode())+" - thread: "+Thread.currentThread().getName()); dumpJAWTInfo(); } - + /** * {@inheritDoc} * <p> @@ -350,9 +359,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { * .. * ds = getJAWT().GetDrawingSurface(component); * due to a SIGSEGV. - * + * * Hence we have some threading / sync issues with the native JAWT implementation. - * </p> + * </p> */ @Override public Point getLocationOnScreen(Point storage) { @@ -361,36 +370,37 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } getLocationOnScreenNonBlocking(storage, component); return storage; - } + } + @Override protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } - - + + private static native long GetJAWTSurfaceLayersHandle0(Buffer jawtDrawingSurfaceInfoBuffer); - - /** + + /** * Set the given root CALayer in the JAWT surface - */ + */ private static native void SetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long caLayer); - - /** + + /** * Unset the given root CALayer in the JAWT surface, passing the NIO DrawingSurfaceInfo buffer - */ + */ private static native void UnsetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long caLayer); - + // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private long jawtSurfaceLayersHandle; - + private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; - + private volatile long rootSurfaceLayer = 0; // attached to the JAWT_SurfaceLayer - + private long windowHandle = 0; private long offscreenSurfaceDrawable = 0; private boolean offscreenSurfaceDrawableSet = false; - + // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java index 74dabb67f..8b9dfabfd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -65,6 +65,7 @@ public class Win32SunJDKReflection { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { try { win32GraphicsDeviceClass = Class.forName("sun.awt.Win32GraphicsDevice"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java index 905a313d5..54bdb34f6 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -60,14 +60,17 @@ public class WindowsJAWTWindow extends JAWTWindow { super(comp, config); } + @Override protected void invalidateNative() { windowHandle = 0; } + @Override protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } - + + @Override protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SUCCESS; ds = getJAWT().GetDrawingSurface(component); @@ -110,6 +113,7 @@ public class WindowsJAWTWindow extends JAWTWindow { return ret; } + @Override protected void unlockSurfaceImpl() throws NativeWindowException { drawable = 0; // invalid HDC if(null!=ds) { @@ -131,6 +135,7 @@ public class WindowsJAWTWindow extends JAWTWindow { return windowHandle; } + @Override protected Point getLocationOnScreenNativeImpl(int x, int y) { return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 2e5dc7fb5..4599b9021 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. @@ -57,12 +57,15 @@ public class X11JAWTWindow extends JAWTWindow { super(comp, config); } + @Override protected void invalidateNative() { } + @Override protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } - + + @Override protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SUCCESS; ds = getJAWT().GetDrawingSurface(component); @@ -104,6 +107,7 @@ public class X11JAWTWindow extends JAWTWindow { return ret; } + @Override protected void unlockSurfaceImpl() throws NativeWindowException { if(null!=ds) { if (null!=dsi) { @@ -119,15 +123,16 @@ public class X11JAWTWindow extends JAWTWindow { x11dsi = null; } + @Override protected Point getLocationOnScreenNativeImpl(int x, int y) { // surface is locked and hence the device return X11Lib.GetRelativeLocation(getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); } - + // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_X11DrawingSurfaceInfo x11dsi; - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java index 27e0a5e50..b2c3a931b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -65,6 +65,7 @@ public class X11SunJDKReflection { static { AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override public Object run() { try { x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java index de3206c0c..b71af1042 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java @@ -9,12 +9,12 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { long nsWindow; - + /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ @@ -22,7 +22,7 @@ public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize super(width, height); nsWindow = 0; } - + @Override public final void create(ProxySurface s) { if(0 == nsWindow && 0 == s.getSurfaceHandle()) { @@ -35,11 +35,11 @@ public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize throw new NativeWindowException("Error NS view 0"); } s.setSurfaceHandle(nsView); - s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } - + @Override public final void destroy(ProxySurface s) { if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 0d498fa54..bac07b85a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -41,9 +41,9 @@ import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.ToolkitProperties; public class OSXUtil implements ToolkitProperties { - private static boolean isInit = false; + private static boolean isInit = false; private static final boolean DEBUG = Debug.debug("OSXUtil"); - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -56,10 +56,10 @@ public class OSXUtil implements ToolkitProperties { if(!NWJNILibLoader.loadNativeWindow("macosx")) { throw new NativeWindowException("NativeWindow MacOSX native library load error."); } - + if( !initIDs0() ) { throw new NativeWindowException("MacOSX: Could not initialized native stub"); - } + } isInit = true; } } @@ -69,27 +69,27 @@ public class OSXUtil implements ToolkitProperties { * @see ToolkitProperties */ public static void shutdown() { } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static boolean requiresToolkitLock() { return false; } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static final boolean hasThreadingIssues() { return false; } - + public static boolean isNSView(long object) { return 0 != object ? isNSView0(object) : false; } - + public static boolean isNSWindow(long object) { return 0 != object ? isNSWindow0(object) : false; } - + /** * In case the <code>windowOrView</code> is top-level, * you shall set <code>topLevel</code> to true where @@ -108,7 +108,7 @@ public class OSXUtil implements ToolkitProperties { * @param src_y * @return the client position */ - public static Point GetLocationOnScreen(long windowOrView, boolean topLevel, int src_x, int src_y) { + public static Point GetLocationOnScreen(long windowOrView, boolean topLevel, int src_x, int src_y) { final Point los = (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); if(topLevel) { // top-level position -> client window position @@ -117,11 +117,11 @@ public class OSXUtil implements ToolkitProperties { } return los; } - + public static Insets GetInsets(long windowOrView) { return (Insets) GetInsets0(windowOrView); } - + public static long CreateNSWindow(int x, int y, int width, int height) { return CreateNSWindow0(x, y, width, height); } @@ -134,11 +134,11 @@ public class OSXUtil implements ToolkitProperties { public static long GetNSWindow(long nsView) { return GetNSWindow0(nsView); } - - /** + + /** * Create a CALayer suitable to act as a root CALayer. * @see #DestroyCALayer(long) - * @see #AddCASublayer(long, long) + * @see #AddCASublayer(long, long) */ public static long CreateCALayer(final int width, final int height) { final long l = CreateCALayer0(width, height); @@ -147,8 +147,8 @@ public class OSXUtil implements ToolkitProperties { } return l; } - - /** + + /** * Attach a sub CALayer to the root CALayer * <p> * Method will trigger a <code>display</code> @@ -156,7 +156,7 @@ public class OSXUtil implements ToolkitProperties { * </p> * <p> * Hence it is important that related resources are not locked <i>if</i> - * they will be used for creation. + * they will be used for creation. * </p> * @param caLayerQuirks TODO * @see #CreateCALayer(int, int) @@ -171,18 +171,18 @@ public class OSXUtil implements ToolkitProperties { } AddCASublayer0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks); } - - /** + + /** * Fix root and sub CALayer position to 0/0 and size * <p> * If the sub CALayer implements the Objective-C NativeWindow protocol NWDedicatedSize (e.g. JOGL's MyNSOpenGLLayer), - * the dedicated size is passed to the layer, which propagates it appropriately. + * the dedicated size is passed to the layer, which propagates it appropriately. * </p> * <p> * On OSX/Java7 our root CALayer's frame position and size gets corrupted by its NSView, * hence we have created the NWDedicatedSize protocol. * </p> - * + * * @param rootCALayer the root surface layer, maybe null. * @param subCALayer the client surface layer, maybe null. * @param visible TODO @@ -196,8 +196,8 @@ public class OSXUtil implements ToolkitProperties { } FixCALayerLayout0(rootCALayer, subCALayer, visible, x, y, width, height, caLayerQuirks); } - - /** + + /** * Detach a sub CALayer from the root CALayer. */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { @@ -209,11 +209,11 @@ public class OSXUtil implements ToolkitProperties { } RemoveCASublayer0(rootCALayer, subCALayer); } - - /** + + /** * Destroy a CALayer. * @see #CreateCALayer(int, int) - */ + */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); @@ -223,13 +223,13 @@ public class OSXUtil implements ToolkitProperties { } DestroyCALayer0(caLayer); } - + /** * Run on OSX UI main thread. - * <p> + * <p> * 'waitUntilDone' is implemented on Java site via lock/wait on {@link RunnableTask} to not freeze OSX main thread. * </p> - * + * * @param waitUntilDone * @param runnable */ @@ -238,10 +238,10 @@ public class OSXUtil implements ToolkitProperties { runnable.run(); // don't leave the JVM } else { // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, - // otherwise we may freeze the OSX main thread. + // otherwise we may freeze the OSX main thread. Throwable throwable = null; final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); + final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { RunOnMainThread0(rt); if( waitUntilDone ) { @@ -260,7 +260,7 @@ public class OSXUtil implements ToolkitProperties { } } } - + /** * Run later on .. * @param onMain if true, run on main-thread, otherwise on the current OSX thread. @@ -270,20 +270,20 @@ public class OSXUtil implements ToolkitProperties { public static void RunLater(boolean onMain, Runnable runnable, int delay) { RunLater0(onMain, new RunnableTask( runnable, null, true, System.err ), delay); } - - private static Runnable _nop = new Runnable() { public void run() {}; }; - - /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an <i>NOP</i> runnable, while waiting until done. */ + + private static Runnable _nop = new Runnable() { @Override public void run() {}; }; + + /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an <i>NOP</i> runnable, while waiting until done. */ public static void WaitUntilFinish() { RunOnMainThread(true, _nop); } - + /** * Run on OSX UI main thread. - * <p> + * <p> * 'waitUntilDone' is implemented on Java site via lock/wait on {@link FunctionTask} to not freeze OSX main thread. * </p> - * + * * @param waitUntilDone * @param func */ @@ -292,10 +292,10 @@ public class OSXUtil implements ToolkitProperties { return func.eval(args); // don't leave the JVM } else { // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, - // otherwise we may freeze the OSX main thread. + // otherwise we may freeze the OSX main thread. Throwable throwable = null; final Object sync = new Object(); - final FunctionTask<R,A> rt = new FunctionTask<R,A>( func, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); + final FunctionTask<R,A> rt = new FunctionTask<R,A>( func, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { rt.setArgs(args); RunOnMainThread0(rt); @@ -316,20 +316,20 @@ public class OSXUtil implements ToolkitProperties { return rt.getResult(); } } - + public static boolean IsMainThread() { return IsMainThread0(); } - + /** Returns the screen refresh rate in Hz. If unavailable, returns 60Hz. */ public static int GetScreenRefreshRate(int scrn_idx) { return GetScreenRefreshRate0(scrn_idx); } - + /*** private static boolean isAWTEDTMainThreadInit = false; private static boolean isAWTEDTMainThread; - + public synchronized static boolean isAWTEDTMainThread() { if(!isAWTEDTMainThreadInit) { isAWTEDTMainThreadInit = true; @@ -343,10 +343,10 @@ public class OSXUtil implements ToolkitProperties { } else { isAWTEDTMainThread = false; } - } + } return isAWTEDTMainThread; } */ - + private static native boolean initIDs0(); private static native boolean isNSView0(long object); private static native boolean isNSWindow0(long object); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java index aa5f3dac5..e5de43c0a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java @@ -9,31 +9,31 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ public GDIDummyUpstreamSurfaceHook(int width, int height) { super(width, height); } - + @Override public final void create(ProxySurface s) { final GDISurface ms = (GDISurface)s; - if(0 == ms.getWindowHandle()) { + if(0 == ms.getWindowHandle()) { final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, 64, 64); if(0 == windowHandle) { throw new NativeWindowException("Error windowHandle 0, werr: "+GDI.GetLastError()); - } + } ms.setWindowHandle(windowHandle); - ms.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + ms.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } - + @Override public final void destroy(ProxySurface s) { final GDISurface ms = (GDISurface)s; @@ -46,5 +46,5 @@ public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize ms.setWindowHandle(0); ms.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } - } + } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index cc9c9853b..3e07b2a9e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -43,7 +43,7 @@ import jogamp.nativewindow.windows.GDI; * allowing the use of HDC via lockSurface()/unlockSurface() protocol. * The latter will get and release the HDC. * The size via getWidth()/getHeight() is invalid. - * + * * @see ProxySurface */ public class GDISurface extends ProxySurfaceImpl { @@ -65,20 +65,20 @@ public class GDISurface extends ProxySurfaceImpl { } @Override - protected void invalidateImpl() { + protected void invalidateImpl() { if(0 != surfaceHandle) { throw new NativeWindowException("didn't release surface Handle: "+this); } windowHandle = 0; // surfaceHandle = 0; } - + /** * {@inheritDoc} * <p> - * Actually the window handle (HWND), since the surfaceHandle (HDC) is derived + * Actually the window handle (HWND), since the surfaceHandle (HDC) is derived * from it at {@link #lockSurface()}. - * </p> + * </p> */ @Override public final void setSurfaceHandle(long surfaceHandle) { @@ -86,7 +86,7 @@ public class GDISurface extends ProxySurfaceImpl { } /** - * Sets the window handle (HWND). + * Sets the window handle (HWND). */ public final void setWindowHandle(long windowHandle) { this.windowHandle = windowHandle; @@ -118,7 +118,7 @@ public class GDISurface extends ProxySurfaceImpl { final protected void unlockSurfaceImpl() { if (0 != surfaceHandle) { if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) { - throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName()); + throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName()); } surfaceHandle=0; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index 00741a328..db61b1efd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -37,11 +37,11 @@ import jogamp.nativewindow.ToolkitProperties; public class GDIUtil implements ToolkitProperties { private static final boolean DEBUG = Debug.debug("GDIUtil"); - + private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ; private static RegisteredClassFactory dummyWindowClassFactory; private static boolean isInit = false; - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -59,42 +59,42 @@ public class GDIUtil implements ToolkitProperties { if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); } - dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); isInit = true; } } } } - + /** * Called by {@link NativeWindowFactory#shutdown()} * @see ToolkitProperties */ - public static void shutdown() { + public static void shutdown() { } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static boolean requiresToolkitLock() { return false; } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static final boolean hasThreadingIssues() { return false; } - + private static RegisteredClass dummyWindowClass = null; private static Object dummyWindowSync = new Object(); - + public static long CreateDummyWindow(int x, int y, int width, int height) { synchronized(dummyWindowSync) { dummyWindowClass = dummyWindowClassFactory.getSharedClass(); return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); } } - + public static boolean DestroyDummyWindow(long hwnd) { boolean res; synchronized(dummyWindowSync) { @@ -106,27 +106,27 @@ public class GDIUtil implements ToolkitProperties { } return res; } - + public static Point GetRelativeLocation(long src_win, long dest_win, int src_x, int src_y) { return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y); } - + public static boolean IsUndecorated(long win) { return IsUndecorated0(win); } - + public static boolean IsChild(long win) { return IsChild0(win); } - + public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); public static native boolean DestroyWindowClass(long hInstance, String className); - + private static native boolean initIDs0(); - private static native long getDummyWndProc0(); + private static native long getDummyWndProc0(); private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y); private static native boolean IsChild0(long win); private static native boolean IsUndecorated0(long win); - - static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); + + static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java index 949f5d06d..976693e3a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java @@ -39,7 +39,7 @@ public class RegisteredClass { /** Application handle, same as {@link RegisteredClassFactory#getHInstance()}. */ public final long getHInstance() { return hInstance; } - + /** Unique Window Class Name */ public final String getName() { return className; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index 0280b0df7..e033a9f66 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -34,9 +34,9 @@ import javax.media.nativewindow.NativeWindowException; public class RegisteredClassFactory { private static final boolean DEBUG = Debug.debug("RegisteredClass"); - private static final ArrayList<RegisteredClassFactory> registeredFactories; + private static final ArrayList<RegisteredClassFactory> registeredFactories; private static final long hInstance; - + static { hInstance = GDI.GetApplicationHandle(); if( 0 == hInstance ) { @@ -44,7 +44,7 @@ public class RegisteredClassFactory { } registeredFactories = new ArrayList<RegisteredClassFactory>(); } - + private String classBaseName; private long wndProc; @@ -52,9 +52,9 @@ public class RegisteredClassFactory { private int classIter = 0; private int sharedRefCount = 0; private final Object sync = new Object(); - + /** - * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. + * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. */ public static void shutdownSharedClasses() { synchronized(registeredFactories) { @@ -65,7 +65,7 @@ public class RegisteredClassFactory { GDIUtil.DestroyWindowClass(rcf.sharedClass.getHInstance(), rcf.sharedClass.getName()); rcf.sharedClass = null; rcf.sharedRefCount = 0; - rcf.classIter = 0; + rcf.classIter = 0; if(DEBUG) { System.err.println("RegisteredClassFactory #"+j+"/"+registeredFactories.size()+" shutdownSharedClasses : "+rcf.sharedClass); } @@ -74,7 +74,7 @@ public class RegisteredClassFactory { } } } - + /** Application handle. */ public static long getHInstance() { return hInstance; } @@ -94,7 +94,7 @@ public class RegisteredClassFactory { } String clazzName = null; boolean registered = false; - final int classIterMark = classIter - 1; + final int classIterMark = classIter - 1; while ( !registered && classIterMark != classIter ) { // Retry with next clazz name, this could happen if more than one JVM is running clazzName = classBaseName + classIter; diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java index 827862002..2c8ef642c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -14,17 +14,17 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ public X11DummyUpstreamSurfaceHook(int width, int height) { super(width, height); } - + @Override public final void create(ProxySurface s) { final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) s.getGraphicsConfiguration(); @@ -42,14 +42,14 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize throw new NativeWindowException("Creating dummy window failed w/ "+cfg); } s.setSurfaceHandle(windowHandle); - s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } finally { device.unlock(); } } - + @Override public final void destroy(ProxySurface s) { if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { @@ -59,7 +59,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize } device.lock(); try { - X11Lib.DestroyWindow(device.getHandle(), s.getSurfaceHandle()); + X11Lib.DestroyWindow(device.getHandle(), s.getSurfaceHandle()); s.setSurfaceHandle(0); s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } finally { diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java index b11dd1df1..6258632cd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -47,10 +47,11 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory { public static void registerFactory() { GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, CapabilitiesImmutable.class, new X11GraphicsConfigurationFactory()); - } + } private X11GraphicsConfigurationFactory() { } - + + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) throws IllegalArgumentException, NativeWindowException { @@ -109,7 +110,7 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor XVisualInfo best=null; int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits(); for (int i = 0; vinfos!=null && i < num[0]; i++) { - if ( best == null || + if ( best == null || best.getDepth() < vinfos[i].getDepth() ) { best = vinfos[i]; diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 78e432b7f..2576c7db1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -54,16 +54,16 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice; */ public class X11Util implements ToolkitProperties { public static final boolean DEBUG = Debug.debug("X11Util"); - - /** + + /** * See Bug 515 - https://jogamp.org/bugzilla/show_bug.cgi?id=515 - * <p> + * <p> * It is observed that ATI X11 drivers, eg. - * <ul> + * <ul> * <li>fglrx 8.78.6,</li> * <li>fglrx 11.08/8.881 and </li> * <li>fglrx 11.11/8.911</li> - * </ul> + * </ul> * are quite sensitive to multiple Display connections. * </p> * <p> @@ -81,11 +81,11 @@ public class X11Util implements ToolkitProperties { * </p> * <p> * With ATI X11 drivers all connections must be closed at JVM shutdown, - * otherwise a SIGSEGV (after JVM safepoint) will be caused. + * otherwise a SIGSEGV (after JVM safepoint) will be caused. * </p> */ public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG", true); - + /** See {@link #ATI_HAS_XCLOSEDISPLAY_BUG}. */ public static final boolean HAS_XCLOSEDISPLAY_BUG = Debug.isPropertyDefined("nativewindow.debug.X11Util.HAS_XCLOSEDISPLAY_BUG", true); @@ -105,7 +105,7 @@ public class X11Util implements ToolkitProperties { private static final Object setX11ErrorHandlerLock = new Object(); private static final String X11_EXTENSION_ATIFGLRXDRI = "ATIFGLRXDRI"; private static final String X11_EXTENSION_ATIFGLEXTENSION = "ATIFGLEXTENSION"; - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -121,15 +121,15 @@ public class X11Util implements ToolkitProperties { if(!NWJNILibLoader.loadNativeWindow("x11")) { throw new NativeWindowException("NativeWindow X11 native library load error."); } - + final boolean isInitOK = initialize0( XERROR_STACKDUMP ); - + final boolean hasX11_EXTENSION_ATIFGLRXDRI, hasX11_EXTENSION_ATIFGLEXTENSION; final long dpy = X11Lib.XOpenDisplay(PropertyAccess.getProperty("nativewindow.x11.display.default", true)); if(0 != dpy) { if(XSYNC_ENABLED) { X11Lib.XSynchronize(dpy, true); - } + } try { nullDisplayName = X11Lib.XDisplayString(dpy); hasX11_EXTENSION_ATIFGLRXDRI = X11Lib.QueryExtension(dpy, X11_EXTENSION_ATIFGLRXDRI); @@ -147,7 +147,7 @@ public class X11Util implements ToolkitProperties { if ( !markAllDisplaysUnclosable ) { markAllDisplaysUnclosable = ( ATI_HAS_XCLOSEDISPLAY_BUG && isATIFGLRX ) || HAS_XCLOSEDISPLAY_BUG; } - + if(DEBUG) { System.err.println("X11Util.initSingleton(): OK "+isInitOK+"]"+ ",\n\t X11 Display(NULL) <"+nullDisplayName+">"+ @@ -164,17 +164,17 @@ public class X11Util implements ToolkitProperties { } } } - + // not exactly thread safe, but good enough for our purpose, // which is to tag a NamedDisplay uncloseable after creation. - private static Object globalLock = new Object(); + private static Object globalLock = new Object(); private static LongObjectHashMap openDisplayMap = new LongObjectHashMap(); // handle -> name private static List<NamedDisplay> openDisplayList = new ArrayList<NamedDisplay>(); // open, no close attempt private static List<NamedDisplay> reusableDisplayList = new ArrayList<NamedDisplay>(); // close attempt, marked uncloseable, for reuse private static List<NamedDisplay> pendingDisplayList = new ArrayList<NamedDisplay>(); // all open (close attempt or reusable) in creation order private static final HashMap<String /* displayName */, Boolean> displayXineramaEnabledMap = new HashMap<String, Boolean>(); - - /** + + /** * Cleanup resources. * <p> * Called by {@link NativeWindowFactory#shutdown()} @@ -184,7 +184,7 @@ public class X11Util implements ToolkitProperties { public static void shutdown() { if(isInit) { synchronized(X11Util.class) { - if(isInit) { + if(isInit) { final boolean isJVMShuttingDown = NativeWindowFactory.isJVMShuttingDown() ; if( DEBUG || ( ( openDisplayMap.size() > 0 || reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0 ) && @@ -207,9 +207,9 @@ public class X11Util implements ToolkitProperties { } } } - - // Only at JVM shutdown time, since AWT impl. seems to - // dislike closing of X11 Display's (w/ ATI driver). + + // Only at JVM shutdown time, since AWT impl. seems to + // dislike closing of X11 Display's (w/ ATI driver). if( isJVMShuttingDown ) { synchronized(globalLock) { isInit = false; @@ -226,7 +226,7 @@ public class X11Util implements ToolkitProperties { } } } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -234,15 +234,15 @@ public class X11Util implements ToolkitProperties { public static final boolean requiresToolkitLock() { return true; // JAWT locking: yes, instead of native X11 locking w use a recursive lock per display connection. } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static final boolean hasThreadingIssues() { - return hasThreadingIssues; // JOGL impl. may utilize special locking "somewhere" + return hasThreadingIssues; // JOGL impl. may utilize special locking "somewhere" } - + public static void setX11ErrorHandler(boolean onoff, boolean quiet) { synchronized(setX11ErrorHandlerLock) { setX11ErrorHandler0(onoff, quiet); @@ -271,7 +271,7 @@ public class X11Util implements ToolkitProperties { public static boolean getMarkAllDisplaysUnclosable() { return markAllDisplaysUnclosable; } - + private X11Util() {} public static class NamedDisplay { @@ -300,10 +300,12 @@ public class X11Util implements ToolkitProperties { } } + @Override public final int hashCode() { return hash32; } - + + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if(obj instanceof NamedDisplay) { @@ -311,10 +313,10 @@ public class X11Util implements ToolkitProperties { } return false; } - + public final void addRef() { refCount++; } public final void removeRef() { refCount--; } - + public final String getName() { return name; } public final long getHandle() { return handle; } public final int getRefCount() { return refCount; } @@ -365,7 +367,7 @@ public class X11Util implements ToolkitProperties { return openDisplayList.size(); } } - + public static void dumpOpenDisplayConnections() { synchronized(globalLock) { System.err.println("X11Util: Open X11 Display Connections: "+openDisplayList.size()); @@ -381,7 +383,7 @@ public class X11Util implements ToolkitProperties { } } } - + public static int getReusableDisplayConnectionNumber() { synchronized(globalLock) { return reusableDisplayList.size(); @@ -439,7 +441,7 @@ public class X11Util implements ToolkitProperties { NamedDisplay namedDpy = null; name = validateDisplayName(name); boolean reused = false; - + synchronized(globalLock) { for(int i=0; i<reusableDisplayList.size(); i++) { if(reusableDisplayList.get(i).getName().equals(name)) { @@ -484,7 +486,7 @@ public class X11Util implements ToolkitProperties { X11Util.dumpPendingDisplayConnections(); throw new RuntimeException("X11Util.Display: Display(0x"+Long.toHexString(handle)+") Mapping error: "+namedDpy+". Thread "+Thread.currentThread().getName()); } - + namedDpy.removeRef(); if(!openDisplayList.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); } @@ -497,13 +499,13 @@ public class X11Util implements ToolkitProperties { pendingDisplayList.remove(namedDpy); } else { // for reuse - X11Lib.XSync(namedDpy.getHandle(), true); // flush output buffer and discard all events + X11Lib.XSync(namedDpy.getHandle(), true); // flush output buffer and discard all events reusableDisplayList.add(namedDpy); } if(DEBUG) { System.err.println("X11Util.Display: Closed (real: "+(!namedDpy.isUncloseable())+") "+namedDpy+". Thread "+Thread.currentThread().getName()); - } + } } } @@ -513,7 +515,7 @@ public class X11Util implements ToolkitProperties { } } - /** + /** * @return If name is null, it returns the previous queried NULL display name, * otherwise the name. */ public static String validateDisplayName(String name) { @@ -537,7 +539,7 @@ public class X11Util implements ToolkitProperties { long handle = X11Lib.XOpenDisplay(arg0); if(XSYNC_ENABLED && 0 != handle) { X11Lib.XSynchronize(handle, true); - } + } if(TRACE_DISPLAY_LIFECYCLE) { System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle)); // Thread.dumpStack(); @@ -557,13 +559,13 @@ public class X11Util implements ToolkitProperties { System.err.println("X11Util: Catched Exception:"); ex.printStackTrace(); } - return res; + return res; } static volatile boolean XineramaFetched = false; static long XineramaLibHandle = 0; static long XineramaQueryFunc = 0; - + public static boolean XineramaIsEnabled(X11GraphicsDevice device) { if(null == device) { throw new IllegalArgumentException("X11 Display device is NULL"); @@ -573,9 +575,9 @@ public class X11Util implements ToolkitProperties { return XineramaIsEnabled(device.getHandle()); } finally { device.unlock(); - } + } } - + public static boolean XineramaIsEnabled(long displayHandle) { if( 0 == displayHandle ) { throw new IllegalArgumentException("X11 Display handle is NULL"); @@ -616,10 +618,10 @@ public class X11Util implements ToolkitProperties { } return res; } - + private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - + private static native boolean initialize0(boolean debug); private static native void shutdown0(); private static native void setX11ErrorHandler0(boolean onoff, boolean quiet); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index b152f0f97..062040232 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 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: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -59,16 +59,17 @@ import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFactory { - + public static void registerFactory() { GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, CapabilitiesImmutable.class, new X11AWTGraphicsConfigurationFactory()); - } + } private X11AWTGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) { throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects"); @@ -79,16 +80,16 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, (AWTGraphicsScreen)absScreen, nativeVisualID); } - + public static AWTGraphicsConfiguration chooseGraphicsConfigurationStatic( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AWTGraphicsScreen awtScreen, int nativeVisualID) { if(DEBUG) { System.err.println("X11AWTGraphicsConfigurationFactory: got "+awtScreen); } - + final GraphicsDevice device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice(); - + final long displayHandleAWT = X11SunJDKReflection.graphicsDeviceGetDisplay(device); final long displayHandle; final boolean owner; @@ -101,8 +102,8 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac } else { /** * Using the AWT display handle works fine with NVidia. - * However we experienced different results w/ AMD drivers, - * some work, but some behave erratic. + * However we experienced different results w/ AMD drivers, + * some work, but some behave erratic. * I.e. hangs in XQueryExtension(..) via X11GraphicsScreen. */ final String displayName = X11Lib.XDisplayString(displayHandleAWT); @@ -113,13 +114,13 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac } } // Global JAWT lock required - No X11 resource locking due to private display connection - final ToolkitLock lock = NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT); - final X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, lock, owner); + final ToolkitLock lock = NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT); + final X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, lock, owner); final X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex()); if(DEBUG) { System.err.println("X11AWTGraphicsConfigurationFactory: made "+x11Screen); } - + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device, capsChosen); AbstractGraphicsConfiguration aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen, nativeVisualID); if (aConfig == null) { @@ -129,7 +130,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac System.err.println("X11AWTGraphicsConfigurationFactory: chosen config: "+aConfig); // Thread.dumpStack(); } - + // // Match the X11/GL Visual with AWT: // - choose a config AWT agnostic and then @@ -137,7 +138,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac // // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer, // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify(). - // + // final GraphicsConfiguration[] configs = device.getConfigurations(); int visualID = aConfig.getVisualID(VIDType.NATIVE); if(VisualIDHolder.VID_UNDEFINED != visualID) { |