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 givenToolkitLock
instance, or nullToolkitLock
if null. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clone()
boolean
close()
Optionally closing the device if handle is notnull
.final String
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
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection()
.static String
Return the default display connection for the given windowing toolkit type gathered viaNativeWindowFactory.getDefaultDisplayConnection(String)
.final long
Returns the native handle of the underlying native device, if such thing exist.final ToolkitLock
final String
getType()
Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..final String
final int
Returns the graphics deviceunit ID
.
Theunit ID
support multiple graphics device configurations on a local machine.
To support remote device, seeAbstractGraphicsDevice.getConnection()
.boolean
final void
lock()
Optionally locking the device, utilizing egToolkitLock.lock()
.boolean
open()
Optionally [re]opening the device if handle isnull
.static final void
swapDeviceHandleAndOwnership
(DefaultGraphicsDevice aDevice1, DefaultGraphicsDevice aDevice2) toString()
final void
unlock()
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 givenToolkitLock
instance, or nullToolkitLock
if 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:
clone
in interfaceAbstractGraphicsDevice
-
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
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
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
- 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
-
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)
-