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 givenToolkitLock
instance, or nullToolkitLock
if null.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearHandleOwner()
Object
clone()
boolean
close()
Optionally closing the device if handle is notnull
.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 connectionremote.host.net:0.0
for a remote connection To support multiple local device, seeAbstractGraphicsDevice.getUnitID()
.static String
getDefaultDisplayConnection()
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection()
.static String
getDefaultDisplayConnection(String type)
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection(String)
.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 deviceunit ID
.
Theunit ID
support multiple graphics device configurations on a local machine.
To support remote device, seeAbstractGraphicsDevice.getConnection()
.boolean
isHandleOwner()
void
lock()
Optionally locking the device, utilizing egToolkitLock.lock()
.boolean
open()
Optionally [re]opening the device if handle isnull
.static void
swapDeviceHandleAndOwnership(DefaultGraphicsDevice aDevice1, DefaultGraphicsDevice aDevice2)
String
toString()
void
unlock()
Optionally unlocking the device, utilizing egToolkitLock.unlock()
.void
validateLocked()
-
-
-
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, long)
.- Parameters:
type
-handle
-
-
DefaultGraphicsDevice
public DefaultGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker)
Create an instance with the givenToolkitLock
instance, or nullToolkitLock
if 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:
clone
in interfaceAbstractGraphicsDevice
-
getType
public final String getType()
Description copied from interface:AbstractGraphicsDevice
Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..- Specified by:
getType
in interfaceAbstractGraphicsDevice
-
getConnection
public final String getConnection()
Description copied from interface:AbstractGraphicsDevice
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 connectionremote.host.net:0.0
for a remote connection
AbstractGraphicsDevice.getUnitID()
.- Specified by:
getConnection
in interfaceAbstractGraphicsDevice
-
getUnitID
public final int getUnitID()
Description copied from interface:AbstractGraphicsDevice
Returns the graphics deviceunit ID
.
Theunit ID
support multiple graphics device configurations on a local machine.
To support remote device, seeAbstractGraphicsDevice.getConnection()
.- Specified by:
getUnitID
in interfaceAbstractGraphicsDevice
- Returns:
-
getUniqueID
public final String getUniqueID()
Description copied from interface:AbstractGraphicsDevice
Returns a unique ID object of this device usingtype
,connection
andunitID
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.- Specified by:
getUniqueID
in interfaceAbstractGraphicsDevice
-
getHandle
public final long getHandle()
Description copied from interface:AbstractGraphicsDevice
Returns the native handle of the underlying native device, if such thing exist.- Specified by:
getHandle
in 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:
lock
in 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:
validateLocked
in 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:
unlock
in 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:AbstractGraphicsDevice
Optionally [re]opening the device if handle isnull
.The default implementation is a
NOP
.Example implementations like
X11GraphicsDevice
orEGLGraphicsDevice
issue the native open operation in case handle isnull
.- Specified by:
open
in interfaceAbstractGraphicsDevice
- Returns:
- true if the handle was
null
and opening was successful, otherwise false.
-
close
public boolean close()
Description copied from interface:AbstractGraphicsDevice
Optionally closing the device if handle is notnull
.The default implementation
dispose
it'sToolkitLock
and sets the handle tonull
.Example implementations like
X11GraphicsDevice
orEGLGraphicsDevice
issue the native close operation or skip it depending on thehandles's ownership
.- Specified by:
close
in interfaceAbstractGraphicsDevice
- Returns:
- true if the handle was not
null
and closing was successful, otherwise false.
-
isHandleOwner
public boolean isHandleOwner()
- Specified by:
isHandleOwner
in interfaceAbstractGraphicsDevice
- Returns:
true
if instance owns the handle to issueAbstractGraphicsDevice.close()
, otherwisefalse
.
-
clearHandleOwner
public void clearHandleOwner()
- Specified by:
clearHandleOwner
in interfaceAbstractGraphicsDevice
-
swapDeviceHandleAndOwnership
public static final void swapDeviceHandleAndOwnership(DefaultGraphicsDevice aDevice1, DefaultGraphicsDevice aDevice2)
-
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)
-
-