summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java78
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java11
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java33
3 files changed, 106 insertions, 16 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
new file mode 100644
index 000000000..3451e28e8
--- /dev/null
+++ b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.nativewindow;
+
+/**
+ * Specifies query to the native capabilities identification.
+ * Semantics may differ depending on the native windowing system,
+ * see {@link #getVisualID(int)}.
+ */
+public interface NativeVisualID {
+
+ public enum NVIDType {
+ GEN_ID(0), NATIVE_ID(1),
+ EGL_ConfigID(2), EGL_NativeVisualID(3), X11_XVisualID(4), X11_FBConfigID(5), WIN32_PFDID(6);
+
+ public final int id;
+
+ NVIDType(int id){
+ this.id = id;
+ }
+ }
+
+ /**
+ * Returns the native identification of the given <code>type</code>.
+ * <p>
+ * Depending on the native windowing system, this might be
+ * <ul>
+ * <li>X11
+ * <ul>
+ * <li>GEN_ID: X11_XVisualID</li>
+ * <li>NATIVE_ID: X11_XVisualID</li>
+ * <li>X11_XVisualID</li>
+ * <li>X11FBConfigID</li>
+ * </ul></li>
+ * <li>Windows
+ * <ul>
+ * <li>GEN_ID: WIN32_PFDID</li>
+ * <li>NATIVE_ID: WIN32_PFDID</li>
+ * <li>WIN32_PFDID</li>
+ * </ul></li>
+ * <li>EGL
+ * <ul>
+ * <li>GEN_ID: EGL_ConfigID</li>
+ * <li>NATIVE_ID: EGL_NativeVisualID (X11_XVisualID, WIN32_PFDID, ..)</li>
+ * <li>EGL_ConfigID</li>
+ * <li>EGL_NativeVisualID</li>
+ * </ul></li>
+ * </ul>
+ * </p>
+ */
+ int getVisualID(NVIDType type);
+}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index aa09fc798..863b336fc 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -80,6 +80,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected Rectangle bounds;
protected Insets insets;
+ private long drawable_old;
+
/**
* Constructed by {@link jogamp.nativewindow.NativeWindowFactoryImpl#getNativeWindow(Object, AbstractGraphicsConfiguration)}
* via this platform's specialization (X11, OSX, Windows, ..).
@@ -121,6 +123,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
jawt = null;
isOffscreenLayerSurface = false;
drawable= 0;
+ drawable_old = 0;
bounds = new Rectangle();
insets = new Insets();
}
@@ -275,6 +278,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
jawt = fetchJAWTImpl();
isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt);
res = lockSurfaceImpl();
+ if(LOCK_SUCCESS == res && drawable_old != drawable) {
+ res = LOCK_SURFACE_CHANGED;
+ if(DEBUG) {
+ System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable));
+ // Thread.dumpStack();
+ }
+ }
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
adevice.unlock();
@@ -293,6 +303,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
public final void unlockSurface() {
surfaceLock.validateLocked();
+ drawable_old = drawable;
if (surfaceLock.getHoldCount() == 1) {
final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
index c83e549cb..5dc143559 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
@@ -48,10 +48,11 @@ import javax.media.nativewindow.ToolkitLock;
import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
import javax.media.nativewindow.awt.AWTGraphicsDevice;
import javax.media.nativewindow.awt.AWTGraphicsScreen;
-import javax.media.nativewindow.x11.X11GraphicsConfiguration;
import javax.media.nativewindow.x11.X11GraphicsDevice;
import javax.media.nativewindow.x11.X11GraphicsScreen;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.nativewindow.jawt.x11.X11SunJDKReflection;
import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.X11Util;
@@ -119,13 +120,13 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device);
- X11GraphicsConfiguration x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
- if (x11Config == null) {
+ AbstractGraphicsConfiguration aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
+ if (aConfig == null) {
throw new NativeWindowException("Unable to choose a GraphicsConfiguration (1): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
}
if(DEBUG) {
- System.err.println("X11AWTGraphicsConfigurationFactory: chosen x11Config: "+x11Config);
- Thread.dumpStack();
+ System.err.println("X11AWTGraphicsConfigurationFactory: chosen config: "+aConfig);
+ // Thread.dumpStack();
}
//
@@ -137,17 +138,17 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
// ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
//
final GraphicsConfiguration[] configs = device.getConfigurations();
- long visualID = x11Config.getVisualID();
+ int visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID);
for (int i = 0; i < configs.length; i++) {
GraphicsConfiguration gc = configs[i];
if (gc != null) {
if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) {
if(DEBUG) {
- System.err.println("Found matching AWT visual: 0x"+Long.toHexString(visualID) +" -> "+x11Config);
+ System.err.println("Found matching AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig);
}
return new AWTGraphicsConfiguration(awtScreen,
- x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
- gc, x11Config);
+ aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(),
+ gc, aConfig);
}
}
}
@@ -155,20 +156,20 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
// try again using an AWT Colormodel compatible configuration
GraphicsConfiguration gc = device.getDefaultConfiguration();
capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
- x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
- if (x11Config == null) {
+ aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
+ if (aConfig == null) {
throw new NativeWindowException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
}
- visualID = x11Config.getVisualID();
+ visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID);
for (int i = 0; i < configs.length; i++) {
gc = configs[i];
if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) {
if(DEBUG) {
- System.err.println("Found matching default AWT visual: 0x"+Long.toHexString(visualID) +" -> "+x11Config);
+ System.err.println("Found matching default AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig);
}
return new AWTGraphicsConfiguration(awtScreen,
- x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
- gc, x11Config);
+ aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(),
+ gc, aConfig);
}
}
@@ -180,7 +181,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
gc = device.getDefaultConfiguration();
- return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(), gc, x11Config);
+ return new AWTGraphicsConfiguration(awtScreen, aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), gc, aConfig);
}
}