Class DefaultGraphicsDevice
- java.lang.Object
-
- com.jogamp.nativewindow.DefaultGraphicsDevice
-
- All Implemented Interfaces:
AbstractGraphicsDevice,Cloneable
- Direct Known Subclasses:
AWTGraphicsDevice,EGLGraphicsDevice,IOSGraphicsDevice,MacOSXGraphicsDevice,WindowsGraphicsDevice,X11GraphicsDevice
public class DefaultGraphicsDevice extends Object implements Cloneable, AbstractGraphicsDevice
-
-
Field Summary
-
Fields inherited from interface com.jogamp.nativewindow.AbstractGraphicsDevice
DEBUG, DEFAULT_CONNECTION, DEFAULT_UNIT, EXTERNAL_CONNECTION
-
-
Constructor Summary
Constructors Constructor Description DefaultGraphicsDevice(String type, String connection, int unitID)Create an instance with the system defaultToolkitLock, gathered viaNativeWindowFactory.getDefaultToolkitLock(String).DefaultGraphicsDevice(String type, String connection, int unitID, long handle)Create an instance with the system defaultToolkitLock.DefaultGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker)Create an instance with the givenToolkitLockinstance, or nullToolkitLockif null.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearHandleOwner()Objectclone()booleanclose()Optionally closing the device if handle is notnull.StringgetConnection()Returns the semantic GraphicsDevice connection.
On platforms supporting remote devices, eg via tcp/ip network, the implementation shall return a unique name for each remote address.static StringgetDefaultDisplayConnection()Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection().static StringgetDefaultDisplayConnection(String type)Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection(String).longgetHandle()Returns the native handle of the underlying native device, if such thing exist.ToolkitLockgetToolkitLock()StringgetType()Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..StringgetUniqueID()intgetUnitID()Returns the graphics deviceunit ID.
Theunit IDsupport multiple graphics device configurations on a local machine.
To support remote device, seeAbstractGraphicsDevice.getConnection().booleanisHandleOwner()voidlock()Optionally locking the device, utilizing egToolkitLock.lock().booleanopen()Optionally [re]opening the device if handle isnull.static voidswapHandleAndOwnership(DefaultGraphicsDevice a, DefaultGraphicsDevice b)StringtoString()voidunlock()Optionally unlocking the device, utilizing egToolkitLock.unlock().voidvalidateLocked()
-
-
-
Constructor Detail
-
DefaultGraphicsDevice
public DefaultGraphicsDevice(String type, String connection, int unitID)
Create an instance with the system defaultToolkitLock, gathered viaNativeWindowFactory.getDefaultToolkitLock(String).- Parameters:
type-
-
DefaultGraphicsDevice
public DefaultGraphicsDevice(String type, String connection, int unitID, long handle)
Create an instance with the system defaultToolkitLock. gathered viaNativeWindowFactory.getDefaultToolkitLock(String).- Parameters:
type-handle-
-
DefaultGraphicsDevice
public DefaultGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker)
Create an instance with the givenToolkitLockinstance, or nullToolkitLockif null.- Parameters:
type-handle-locker- if null, a non blocking null lock is used.
-
-
Method Detail
-
getDefaultDisplayConnection
public static String getDefaultDisplayConnection()
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection().- Parameters:
type-
-
getDefaultDisplayConnection
public static String getDefaultDisplayConnection(String type)
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection(String).- Parameters:
type-
-
clone
public Object clone()
- Specified by:
clonein interfaceAbstractGraphicsDevice
-
getType
public final String getType()
Description copied from interface:AbstractGraphicsDeviceReturns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..- Specified by:
getTypein interfaceAbstractGraphicsDevice
-
getConnection
public final String getConnection()
Description copied from interface:AbstractGraphicsDeviceReturns the semantic GraphicsDevice connection.
On platforms supporting remote devices, eg via tcp/ip network, the implementation shall return a unique name for each remote address.For
X11GraphicsDevice, the connection string should be as the follows:0.0for a local connectionremote.host.net:0.0for a remote connection
AbstractGraphicsDevice.getUnitID().- Specified by:
getConnectionin interfaceAbstractGraphicsDevice
-
getUnitID
public final int getUnitID()
Description copied from interface:AbstractGraphicsDeviceReturns the graphics deviceunit ID.
Theunit IDsupport multiple graphics device configurations on a local machine.
To support remote device, seeAbstractGraphicsDevice.getConnection().- Specified by:
getUnitIDin interfaceAbstractGraphicsDevice- Returns:
-
getUniqueID
public final String getUniqueID()
Description copied from interface:AbstractGraphicsDeviceReturns a unique ID object of this device usingtype,connectionandunitIDas it's key components.The unique ID does not reflect the instance of the device, hence the handle is not included. The unique ID may be used as a key for semantic device mapping.
The returned string object reference is unique using
String.intern()and hence can be used as a key itself.- Specified by:
getUniqueIDin interfaceAbstractGraphicsDevice
-
getHandle
public final long getHandle()
Description copied from interface:AbstractGraphicsDeviceReturns the native handle of the underlying native device, if such thing exist.- Specified by:
getHandlein interfaceAbstractGraphicsDevice
-
lock
public final void lock()
Optionally locking the device, utilizing egToolkitLock.lock(). The lock implementation must be recursive.Locking is perfomed via delegation to
ToolkitLock.lock(),ToolkitLock.unlock().- Specified by:
lockin interfaceAbstractGraphicsDevice- See Also:
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long),DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
-
validateLocked
public final void validateLocked() throws RuntimeException- Specified by:
validateLockedin interfaceAbstractGraphicsDevice- Throws:
RuntimeException- if current thread does not hold the lock
-
unlock
public final void unlock()
Optionally unlocking the device, utilizing egToolkitLock.unlock(). The lock implementation must be recursive.Locking is perfomed via delegation to
ToolkitLock.lock(),ToolkitLock.unlock().- Specified by:
unlockin interfaceAbstractGraphicsDevice- See Also:
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long),DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
-
open
public boolean open()
Description copied from interface:AbstractGraphicsDeviceOptionally [re]opening the device if handle isnull.The default implementation is a
NOP.Example implementations like
X11GraphicsDeviceorEGLGraphicsDeviceissue the native open operation in case handle isnull.- Specified by:
openin interfaceAbstractGraphicsDevice- Returns:
- true if the handle was
nulland opening was successful, otherwise false.
-
close
public boolean close()
Description copied from interface:AbstractGraphicsDeviceOptionally closing the device if handle is notnull.The default implementation
disposeit'sToolkitLockand sets the handle tonull.Example implementations like
X11GraphicsDeviceorEGLGraphicsDeviceissue the native close operation or skip it depending on thehandles's ownership.- Specified by:
closein interfaceAbstractGraphicsDevice- Returns:
- true if the handle was not
nulland closing was successful, otherwise false.
-
isHandleOwner
public final boolean isHandleOwner()
- Specified by:
isHandleOwnerin interfaceAbstractGraphicsDevice- Returns:
trueif instance owns the handle to issueAbstractGraphicsDevice.close(), otherwisefalse.
-
clearHandleOwner
public final void clearHandleOwner()
- Specified by:
clearHandleOwnerin interfaceAbstractGraphicsDevice
-
swapHandleAndOwnership
public static final void swapHandleAndOwnership(DefaultGraphicsDevice a, DefaultGraphicsDevice b)
-
getToolkitLock
public final ToolkitLock getToolkitLock()
- Returns:
- the used ToolkitLock
- See Also:
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long),DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
-
-