aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-05 04:34:41 +0100
committerSven Gothel <[email protected]>2012-03-05 04:34:41 +0100
commit90c46b1ef1f199ceb63e85c85e9ebeb919d49c4a (patch)
treeded4b93e80eb39ff33c80638c10a531222c105a3 /src/nativewindow/classes
parent875042340b68137b584907c539b7b7ecc5c5b15c (diff)
Complete LOCK_SURFACE_CHANGED ; Introduce NativeVisualID (Daisy chaining *GraphicsConfiguration) ; ...
NativeVisualID: New interface for Capabilities implementations, allowing retrieval of the native 'visual id'. Impl. by WGL, X11 and EGL. JAWTWindow.lockSurface() - Detect surfaceHandle change an return LOCK_SURFACE_CHANGED (see: LOCK_SURFACE_CHANGED) EGLDrawable: - Impl. updateHandle() (see: LOCK_SURFACE_CHANGED) - use NativeVisualID for EGLGraphicsConfiguration selection to respect a native 'visual id' EGLContext.createContextImpl: Use NIO for attributes EGLDisplayUtil: Enhance eglGetDisplay w/ DEBUG code and NativeSurface / EGL_DEFAULT_DISPLAY variation EGL, XGL, WGL GraphicsConfiguration: - Don't set ALPHA_SIZE and STENCIL_SIZE if not requested in attribute list for context creation. - toString() shows proper identification, eg.: egl, x11, win32 .. EGLGraphicsConfigurationFactory: Daisy chain GraphicsConfigurationFactory for native device type (currently only X11). This allows choosing the EGLGraphicsConfiguration and hence native visual id based on EGL when invoked via the factory model (generic). In case EGLGraphicsConfigurationFactory is not suitable or doesn't produce a native visual id, it falls back the the original one. X11AWTGraphicsConfigurationFactory and X11Window: Use generic NativeVisualID which allows EGLGraphicsConfiguration implicit. *GraphicsConfiguration's DEBUG flag is pushed up to DefaultGraphicsConfiguration LOCK_SURFACE_CHANGED: - commit 006e9fe402a0a47b45fd2c4af51296aef895e8b5 - commit a0177c8a1048683e5d43f4712f8f9e37091d4e85 Impact: - Fixes EGL/GLES (wrapper/native) usage on X11, proper Xvisual selection w/ EGL - Fixes EGL/GLES (wrapper/native) usage on Windows, ANGLE works w/ NEWT and forced ES2
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java4
-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
4 files changed, 110 insertions, 16 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 3eb7a6c9a..15c9e6a36 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -32,7 +32,11 @@
package javax.media.nativewindow;
+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;
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);
}
}