public class DefaultGraphicsDevice extends Object implements Cloneable, AbstractGraphicsDevice
DEBUG, DEFAULT_CONNECTION, DEFAULT_UNIT, EXTERNAL_CONNECTION| Constructor and Description |
|---|
DefaultGraphicsDevice(String type,
String connection,
int unitID)
Create an instance with the system default
ToolkitLock,
gathered via NativeWindowFactory.getDefaultToolkitLock(String). |
DefaultGraphicsDevice(String type,
String connection,
int unitID,
long handle)
Create an instance with the system default
ToolkitLock. |
DefaultGraphicsDevice(String type,
String connection,
int unitID,
long handle,
ToolkitLock locker)
Create an instance with the given
ToolkitLock instance, or null ToolkitLock if null. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearHandleOwner() |
Object |
clone() |
boolean |
close()
Optionally closing the device if handle is not
null. |
String |
getConnection()
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. On X11 for example, the connection string should be as the following example. :0.0 for a local connection
remote.host.net:0.0 for a remote connection
To support multiple local device, see AbstractGraphicsDevice.getUnitID(). |
long |
getHandle()
Returns the native handle of the underlying native device,
if such thing exist.
|
ToolkitLock |
getToolkitLock() |
String |
getType()
Returns the type of the underlying subsystem, ie
NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
|
String |
getUniqueID()
|
int |
getUnitID()
Returns the graphics device
unit ID.The unit ID support multiple graphics device configurations
on a local machine.To support remote device, see AbstractGraphicsDevice.getConnection(). |
boolean |
isHandleOwner() |
void |
lock()
Optionally locking the device, utilizing eg
ToolkitLock.lock(). |
boolean |
open()
Optionally [re]opening the device if handle is
null. |
static void |
swapDeviceHandleAndOwnership(DefaultGraphicsDevice aDevice1,
DefaultGraphicsDevice aDevice2) |
String |
toString() |
void |
unlock()
Optionally unlocking the device, utilizing eg
ToolkitLock.unlock(). |
void |
validateLocked() |
public DefaultGraphicsDevice(String type, String connection, int unitID)
ToolkitLock,
gathered via NativeWindowFactory.getDefaultToolkitLock(String).type - public DefaultGraphicsDevice(String type, String connection, int unitID, long handle)
ToolkitLock.
gathered via NativeWindowFactory.getDefaultToolkitLock(String, long).type - handle - public DefaultGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker)
ToolkitLock instance, or null ToolkitLock if null.type - handle - locker - if null, a non blocking null lock is used.public Object clone()
clone in interface AbstractGraphicsDeviceclone in class Objectpublic final String getType()
AbstractGraphicsDevicegetType in interface AbstractGraphicsDevicepublic final String getConnection()
AbstractGraphicsDevice:0.0 for a local connectionremote.host.net:0.0 for a remote connectionAbstractGraphicsDevice.getUnitID().getConnection in interface AbstractGraphicsDevicepublic final int getUnitID()
AbstractGraphicsDeviceunit ID.unit ID support multiple graphics device configurations
on a local machine.AbstractGraphicsDevice.getConnection().getUnitID in interface AbstractGraphicsDevicepublic final String getUniqueID()
AbstractGraphicsDevicetype,
connection and unitID as 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.
getUniqueID in interface AbstractGraphicsDevicepublic final long getHandle()
AbstractGraphicsDevicegetHandle in interface AbstractGraphicsDevicepublic final void lock()
ToolkitLock.lock().
The lock implementation must be recursive.
Locking is perfomed via delegation to ToolkitLock.lock(), ToolkitLock.unlock().
lock in interface AbstractGraphicsDeviceDefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long),
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)public final void validateLocked()
throws RuntimeException
validateLocked in interface AbstractGraphicsDeviceRuntimeException - if current thread does not hold the lockpublic final void unlock()
ToolkitLock.unlock().
The lock implementation must be recursive.
Locking is perfomed via delegation to ToolkitLock.lock(), ToolkitLock.unlock().
unlock in interface AbstractGraphicsDeviceDefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long),
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)public boolean open()
AbstractGraphicsDevicenull.
The default implementation is a NOP.
Example implementations like X11GraphicsDevice
or com.jogamp.nativewindow.egl.EGLGraphicsDevice
issue the native open operation in case handle is null.
open in interface AbstractGraphicsDevicenull and opening was successful, otherwise false.public boolean close()
AbstractGraphicsDevicenull.
The default implementation dispose it's ToolkitLock and sets the handle to null.
Example implementations like X11GraphicsDevice
or com.jogamp.nativewindow.egl.EGLGraphicsDevice
issue the native close operation or skip it depending on the handles's ownership.
close in interface AbstractGraphicsDevicenull and closing was successful, otherwise false.public boolean isHandleOwner()
isHandleOwner in interface AbstractGraphicsDevicetrue if instance owns the handle to issue AbstractGraphicsDevice.close(), otherwise false.public void clearHandleOwner()
clearHandleOwner in interface AbstractGraphicsDevicepublic static final void swapDeviceHandleAndOwnership(DefaultGraphicsDevice aDevice1, DefaultGraphicsDevice aDevice2)
public final ToolkitLock getToolkitLock()
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long),
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)Copyright 2010 JogAmp Community.