From c2e805f5cf9c209cfbd1a3082a347d9f3d58c9d5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 12 Nov 2010 03:29:06 +0100 Subject: AbstractGraphicsDevice ..: Add device/display connection attribute to support multi devices & displays. Currently only the X11 Display connection is implemented to support multiple device connections. Other platforms may follow. This allows correct mapping and caching of higher level resources, eg. ProcAddressTable, GL version mapping etc with respect to the display device. --- .../media/nativewindow/AbstractGraphicsDevice.java | 15 +++++++++++++++ .../media/nativewindow/DefaultGraphicsDevice.java | 20 ++++++++++++++------ .../media/nativewindow/DefaultGraphicsScreen.java | 6 +++--- .../media/nativewindow/awt/AWTGraphicsDevice.java | 4 ++-- .../media/nativewindow/egl/EGLGraphicsDevice.java | 2 +- .../nativewindow/macosx/MacOSXGraphicsDevice.java | 2 +- .../nativewindow/windows/WindowsGraphicsDevice.java | 2 +- .../media/nativewindow/x11/X11GraphicsDevice.java | 4 ++-- 8 files changed, 39 insertions(+), 16 deletions(-) (limited to 'src/nativewindow/classes/javax/media') diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 581df5163..c6911bac8 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -45,12 +45,27 @@ package javax.media.nativewindow; */ public interface AbstractGraphicsDevice extends Cloneable { + /** Dummy connection value for a default connection where no native support for multiple devices is available */ + public static String DEFAULT_CONNECTION = "decon"; + + /** Dummy connection value for an external connection where no native support for multiple devices is available */ + public static String EXTERNAL_CONNECTION = "excon"; + /** * Returns the type of the underlying subsystem, ie * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, .. */ public String getType(); + /** + * Returns the semantic GraphicsDevice connection.
+ * On platforms supporting multiple devices, local or network, + * the implementation shall return a unique name.
+ * On X11 for example, the DISPLAY connection string, + * eg. :0.0, could be returned.
+ */ + public String getConnection(); + /** * Returns the native handle of the underlying native device, * if such thing exist. diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 4e91eb2a7..f28d254ab 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -37,6 +37,7 @@ import com.jogamp.nativewindow.impl.NativeWindowFactoryImpl; public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice { private String type; + protected String connection; protected long handle; protected ToolkitLock toolkitLock; @@ -45,8 +46,9 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * gathered via {@link NativeWindowFactory#createDefaultToolkitLock()}. * @param type */ - public DefaultGraphicsDevice(String type) { + public DefaultGraphicsDevice(String type, String connection) { this.type = type; + this.connection = connection; this.handle = 0; setToolkitLock( NativeWindowFactory.getDefaultToolkitLock(type) ); } @@ -57,8 +59,9 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * @param type * @param handle */ - public DefaultGraphicsDevice(String type, long handle) { + public DefaultGraphicsDevice(String type, String connection, long handle) { this.type = type; + this.connection = connection; this.handle = handle; setToolkitLock( NativeWindowFactory.createDefaultToolkitLock(type, handle) ); } @@ -69,8 +72,9 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * @param handle * @param locker */ - public DefaultGraphicsDevice(String type, long handle, ToolkitLock locker) { + public DefaultGraphicsDevice(String type, String connection, long handle, ToolkitLock locker) { this.type = type; + this.connection = connection; this.handle = handle; setToolkitLock( locker ); } @@ -83,11 +87,15 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice } } - public String getType() { + public final String getType() { return type; } - public long getHandle() { + public final String getConnection() { + return connection; + } + + public final long getHandle() { return handle; } @@ -118,7 +126,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice } public String toString() { - return getClass().toString()+"[type "+getType()+", handle 0x"+Long.toHexString(getHandle())+"]"; + return getClass().toString()+"[type "+getType()+", connection "+getConnection()+", handle 0x"+Long.toHexString(getHandle())+"]"; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java index 0af32c9ec..893b0ddd2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java @@ -41,12 +41,12 @@ public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen this.idx = idx; } - public static AbstractGraphicsScreen createScreenDevice(int screenIdx) { - return new DefaultGraphicsScreen(new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT), screenIdx); + public static AbstractGraphicsScreen createScreenDevice(String connection,int screenIdx) { + return new DefaultGraphicsScreen(new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, connection), screenIdx); } public static AbstractGraphicsScreen createDefault() { - return createScreenDevice(0); + return createScreenDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, 0); } public Object clone() { diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java index e91261211..e1d7c84f1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java @@ -52,7 +52,7 @@ public class AWTGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl private String subType; protected AWTGraphicsDevice(GraphicsDevice device) { - super(NativeWindowFactory.TYPE_AWT); + super(NativeWindowFactory.TYPE_AWT, device.getIDstring()); this.device = device; this.subType = null; } @@ -90,7 +90,7 @@ public class AWTGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } public String toString() { - return getClass().toString()+"[type "+getType()+"[subType "+getSubType()+"], awtDevice "+device+", handle 0x"+Long.toHexString(getHandle())+"]"; + return getClass().toString()+"[type "+getType()+"[subType "+getSubType()+"], connection "+getConnection()+", awtDevice "+device+", handle 0x"+Long.toHexString(getHandle())+"]"; } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java index 49c337359..609003290 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java @@ -40,7 +40,7 @@ import javax.media.nativewindow.*; public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { /** Constructs a new EGLGraphicsDevice corresponding to the given EGL display handle. */ public EGLGraphicsDevice(long eglDisplay) { - super(NativeWindowFactory.TYPE_EGL, eglDisplay); + super(NativeWindowFactory.TYPE_EGL, AbstractGraphicsDevice.DEFAULT_CONNECTION, eglDisplay); } public Object clone() { diff --git a/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java index 3669ebd12..82b87eb29 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java @@ -40,7 +40,7 @@ import javax.media.nativewindow.*; public class MacOSXGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { /** Constructs a new MacOSXGraphicsDevice */ public MacOSXGraphicsDevice() { - super(NativeWindowFactory.TYPE_MACOSX); + super(NativeWindowFactory.TYPE_MACOSX, AbstractGraphicsDevice.DEFAULT_CONNECTION); } public Object clone() { diff --git a/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java index 69dde49af..666fc6196 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java @@ -40,7 +40,7 @@ import javax.media.nativewindow.*; public class WindowsGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { /** Constructs a new WindowsGraphicsDevice */ public WindowsGraphicsDevice() { - super(NativeWindowFactory.TYPE_WINDOWS); + super(NativeWindowFactory.TYPE_WINDOWS, AbstractGraphicsDevice.DEFAULT_CONNECTION); } public Object clone() { diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java index c60597661..a8e11efba 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java @@ -45,7 +45,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(java.lang.String, long)}. */ public X11GraphicsDevice(long display) { - super(NativeWindowFactory.TYPE_X11, display); + super(NativeWindowFactory.TYPE_X11, X11Util.XDisplayString(display), display); if(0==display) { throw new NativeWindowException("null display"); } @@ -56,7 +56,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking in NEWT */ public X11GraphicsDevice(long display, ToolkitLock locker) { - super(NativeWindowFactory.TYPE_X11, display, locker); + super(NativeWindowFactory.TYPE_X11, X11Util.XDisplayString(display), display, locker); if(0==display) { throw new NativeWindowException("null display"); } -- cgit v1.2.3