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 AbstractGraphicsDevice
clone
in class Object
public final String getType()
AbstractGraphicsDevice
getType
in interface AbstractGraphicsDevice
public final String getConnection()
AbstractGraphicsDevice
:0.0
for a local connectionremote.host.net:0.0
for a remote connectionAbstractGraphicsDevice.getUnitID()
.getConnection
in interface AbstractGraphicsDevice
public final int getUnitID()
AbstractGraphicsDevice
unit ID
.unit ID
support multiple graphics device configurations
on a local machine.AbstractGraphicsDevice.getConnection()
.getUnitID
in interface AbstractGraphicsDevice
public final String getUniqueID()
AbstractGraphicsDevice
type
,
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 AbstractGraphicsDevice
public final long getHandle()
AbstractGraphicsDevice
getHandle
in interface AbstractGraphicsDevice
public final void lock()
ToolkitLock.lock()
.
The lock implementation must be recursive.
Locking is perfomed via delegation to ToolkitLock.lock()
, ToolkitLock.unlock()
.
lock
in interface AbstractGraphicsDevice
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
,
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
public final void validateLocked() throws RuntimeException
validateLocked
in interface AbstractGraphicsDevice
RuntimeException
- 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 AbstractGraphicsDevice
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
,
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
public boolean open()
AbstractGraphicsDevice
null
.
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 AbstractGraphicsDevice
null
and opening was successful, otherwise false.public boolean close()
AbstractGraphicsDevice
null
.
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 AbstractGraphicsDevice
null
and closing was successful, otherwise false.public boolean isHandleOwner()
isHandleOwner
in interface AbstractGraphicsDevice
true
if instance owns the handle to issue AbstractGraphicsDevice.close()
, otherwise false
.public void clearHandleOwner()
clearHandleOwner
in interface AbstractGraphicsDevice
public 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.