Class DefaultGraphicsDevice
- All Implemented Interfaces:
AbstractGraphicsDevice,Cloneable
- Direct Known Subclasses:
AWTGraphicsDevice,EGLGraphicsDevice,MacOSXGraphicsDevice,WindowsGraphicsDevice,X11GraphicsDevice
-
Field Summary
Fields inherited from interface com.jogamp.nativewindow.AbstractGraphicsDevice
DEBUG, DEFAULT_CONNECTION, DEFAULT_UNIT, EXTERNAL_CONNECTION -
Constructor Summary
ConstructorsConstructorDescriptionDefaultGraphicsDevice(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
Modifier and TypeMethodDescriptionvoidclone()booleanclose()Optionally closing the device if handle is notnull.final StringReturns 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.
On X11 for example, the connection string should be as the following example.
:0.0for a local connectionremote.host.net:0.0for a remote connection To support multiple local device, seeAbstractGraphicsDevice.getUnitID().static StringReturn the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection().static StringReturn the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection(String).final longReturns the native handle of the underlying native device, if such thing exist.final ToolkitLockfinal StringgetType()Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..final Stringfinal intReturns the graphics deviceunit ID.
Theunit IDsupport multiple graphics device configurations on a local machine.
To support remote device, seeAbstractGraphicsDevice.getConnection().booleanfinal voidlock()Optionally locking the device, utilizing egToolkitLock.lock().booleanopen()Optionally [re]opening the device if handle isnull.static final voidswapDeviceHandleAndOwnership(DefaultGraphicsDevice aDevice1, DefaultGraphicsDevice aDevice2) toString()final voidunlock()Optionally unlocking the device, utilizing egToolkitLock.unlock().final void
-
Constructor Details
-
DefaultGraphicsDevice
Create an instance with the system defaultToolkitLock, gathered viaNativeWindowFactory.getDefaultToolkitLock(String).- Parameters:
type-
-
DefaultGraphicsDevice
Create an instance with the system defaultToolkitLock. gathered viaNativeWindowFactory.getDefaultToolkitLock(String, long).- 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 Details
-
getDefaultDisplayConnection
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection().- Parameters:
type-
-
getDefaultDisplayConnection
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection(String).- Parameters:
type-
-
clone
- Specified by:
clonein interfaceAbstractGraphicsDevice
-
getType
Description copied from interface:AbstractGraphicsDeviceReturns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..- Specified by:
getTypein interfaceAbstractGraphicsDevice
-
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.
On X11 for example, the connection string should be as the following example.
: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
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
- 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 boolean isHandleOwner()- Specified by:
isHandleOwnerin interfaceAbstractGraphicsDevice- Returns:
trueif instance owns the handle to issueAbstractGraphicsDevice.close(), otherwisefalse.
-
clearHandleOwner
public void clearHandleOwner()- Specified by:
clearHandleOwnerin interfaceAbstractGraphicsDevice
-
toString
-
swapDeviceHandleAndOwnership
public static final void swapDeviceHandleAndOwnership(DefaultGraphicsDevice aDevice1, DefaultGraphicsDevice aDevice2) -
getToolkitLock
- Returns:
- the used ToolkitLock
- See Also:
-
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
-