Top Fields Constructors Methods
com.jogamp.nativewindow

public Class DefaultGraphicsDevice

extends Object
implements Cloneable, AbstractGraphicsDevice
Class Inheritance
All Implemented Interfaces
com.jogamp.nativewindow.AbstractGraphicsDevice, java.lang.Cloneable
Known Direct Subclasses
com.jogamp.nativewindow.awt.AWTGraphicsDevice, com.jogamp.nativewindow.egl.EGLGraphicsDevice, com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice, com.jogamp.nativewindow.windows.WindowsGraphicsDevice, com.jogamp.nativewindow.x11.X11GraphicsDevice
Imports
jogamp.nativewindow.NativeWindowFactoryImpl

Field Summary

Modifier and TypeField and Description
protected final String
protected long
private static final String
protected ToolkitLock
private final String
protected final String
protected final int

Constructor Summary

AccessConstructor and Description
public
DefaultGraphicsDevice(final String type, final String connection, final int unitID)

Create an instance with the system default ToolkitLock, gathered via NativeWindowFactory#getDefaultToolkitLock(String).

public
DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle)

Create an instance with the system default ToolkitLock.

public
DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle, final ToolkitLock
if null, a non blocking null lock is used.
locker
)

Create an instance with the given ToolkitLock instance, or null ToolkitLock if null.

Method Summary

Modifier and TypeMethod and Description
public void
public Object
clone()

Overrides java.lang.Object.clone.

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.clone.

Creates and returns a copy of this object.
public boolean
close()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.close.

Optionally closing the device if handle is not null.
public final String
getConnection()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getConnection.

Returns the semantic GraphicsDevice connection.
public static String
getDefaultDisplayConnection()

Return the default display connection for the given windowing toolkit type gathered via NativeWindowFactory#getDefaultDisplayConnection().

public static String
getDefaultDisplayConnection(final String type)

Return the default display connection for the given windowing toolkit type gathered via NativeWindowFactory#getDefaultDisplayConnection(String).

public final long
getHandle()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getHandle.

Returns the native handle of the underlying native device, if such thing exist.
protected Object
public final ToolkitLock

Returns:

the used ToolkitLock
getToolkitLock
()

public final String
getType()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getType.

Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
public final String
getUniqueID()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getUniqueID.

Returns a unique ID object of this device using type, connection and unitID as it's key components.
private static String
getUniqueID(final String type, final String connection, final int unitID)

Returns a unique String object using String#intern() for the given arguments, which object reference itself can be used as a key.

public final int
getUnitID()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getUnitID.

Returns the graphics device unit ID.
public boolean
public final void
public boolean
open()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.open.

Optionally [re]opening the device if handle is null.
protected final long
setHandle(final long newHandle)

Set the native handle of the underlying native device and return the previous one.

protected Object
setHandleOwnership(final Object newOwnership)

protected ToolkitLock

Returns:

the previous ToolkitLock instance
setToolkitLock
(final ToolkitLock
the ToolkitLock, if null, jogamp.nativewindow.NullToolkitLock is being used
locker
)

Set the internal ToolkitLock, which is used within the lock() and unlock() implementation.

public static final void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final void
public final void
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

connectionback to summary
protected final String connection
handleback to summary
protected long handle
separatorback to summary
private static final String separator
toolkitLockback to summary
protected ToolkitLock toolkitLock
typeback to summary
private final String type
uniqueIDback to summary
protected final String uniqueID
unitIDback to summary
protected final int unitID

Constructor Detail

DefaultGraphicsDeviceback to summary
public DefaultGraphicsDevice(final String type, final String connection, final int unitID)

Create an instance with the system default ToolkitLock, gathered via NativeWindowFactory#getDefaultToolkitLock(String).

DefaultGraphicsDeviceback to summary
public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle)

Create an instance with the system default ToolkitLock. gathered via NativeWindowFactory#getDefaultToolkitLock(String, long).

DefaultGraphicsDeviceback to summary
public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle, final ToolkitLock locker)

Create an instance with the given ToolkitLock instance, or null ToolkitLock if null.

Parameters
locker:ToolkitLock

if null, a non blocking null lock is used.

Method Detail

clearHandleOwnerback to summary
public void clearHandleOwner()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.clearHandleOwner.

Annotations
@Override
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
closeback to summary
public boolean close()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.close.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.close.

Optionally closing the device if handle is not null.

The default implementation dispose it's ToolkitLock and sets the handle to null.

Example implementations like com.jogamp.nativewindow.x11.X11GraphicsDevice or com.jogamp.nativewindow.egl.EGLGraphicsDevice issue the native close operation or skip it depending on the handles's ownership.

Returns:boolean

true if the handle was not null and closing was successful, otherwise false.

Annotations
@Override
getConnectionback to summary
public final String getConnection()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getConnection.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.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 getUnitID().
Annotations
@Override
getDefaultDisplayConnectionback to summary
public static String getDefaultDisplayConnection()

Return the default display connection for the given windowing toolkit type gathered via NativeWindowFactory#getDefaultDisplayConnection().

getDefaultDisplayConnectionback to summary
public static String getDefaultDisplayConnection(final String type)

Return the default display connection for the given windowing toolkit type gathered via NativeWindowFactory#getDefaultDisplayConnection(String).

getHandleback to summary
public final long getHandle()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getHandle.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.getHandle.

Returns the native handle of the underlying native device, if such thing exist.

Annotations
@Override
getHandleOwnershipback to summary
protected Object getHandleOwnership()
getToolkitLockback to summary
public final ToolkitLock getToolkitLock()
Returns:ToolkitLock

the used ToolkitLock

See Also
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long), DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
getTypeback to summary
public final String getType()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getType.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.getType.

Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..

Annotations
@Override
getUniqueIDback to summary
public final String getUniqueID()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getUniqueID.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.getUniqueID.

Returns a unique ID object of this device using 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.

Annotations
@Override
getUniqueIDback to summary
private static String getUniqueID(final String type, final String connection, final int unitID)

Returns a unique String object using String#intern() for the given arguments, which object reference itself can be used as a key.

getUnitIDback to summary
public final int getUnitID()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.getUnitID.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.getUnitID.

Returns the graphics device unit ID.
The unit ID support multiple graphics device configurations on a local machine.
To support remote device, see getConnection().

Annotations
@Override
isHandleOwnerback to summary
public boolean isHandleOwner()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.isHandleOwner.

Returns:boolean

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.isHandleOwner.

true if instance owns the handle to issue close(), otherwise false.

Annotations
@Override
lockback to summary
public final void lock()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.lock.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.lock.

Optionally locking the device, utilizing eg com.jogamp.nativewindow.ToolkitLock#lock(). The lock implementation must be recursive.

Locking is perfomed via delegation to ToolkitLock#lock(), ToolkitLock#unlock().

Annotations
@Override
See Also
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long), DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
openback to summary
public boolean open()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.open.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.open.

Optionally [re]opening the device if handle is null.

The default implementation is a NOP.

Example implementations like com.jogamp.nativewindow.x11.X11GraphicsDevice or com.jogamp.nativewindow.egl.EGLGraphicsDevice issue the native open operation in case handle is null.

Returns:boolean

true if the handle was null and opening was successful, otherwise false.

Annotations
@Override
setHandleback to summary
protected final long setHandle(final long newHandle)

Set the native handle of the underlying native device and return the previous one.

setHandleOwnershipback to summary
protected Object setHandleOwnership(final Object newOwnership)
setToolkitLockback to summary
protected ToolkitLock setToolkitLock(final ToolkitLock locker)

Set the internal ToolkitLock, which is used within the lock() and unlock() implementation.

The current ToolkitLock is being locked/unlocked while swapping the reference, ensuring no concurrent access can occur during the swap.

Parameters
locker:ToolkitLock

the ToolkitLock, if null, jogamp.nativewindow.NullToolkitLock is being used

Returns:ToolkitLock

the previous ToolkitLock instance

swapDeviceHandleAndOwnershipback to summary
public static final void swapDeviceHandleAndOwnership(final DefaultGraphicsDevice aDevice1, final DefaultGraphicsDevice aDevice2)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
unlockback to summary
public final void unlock()

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.unlock.

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.unlock.

Optionally unlocking the device, utilizing eg com.jogamp.nativewindow.ToolkitLock#unlock(). The lock implementation must be recursive.

Locking is perfomed via delegation to ToolkitLock#lock(), ToolkitLock#unlock().

Annotations
@Override
See Also
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long), DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
validateLockedback to summary
public final void validateLocked() throws RuntimeException

Implements com.jogamp.nativewindow.AbstractGraphicsDevice.validateLocked.

Annotations
@Override
Exceptions
RuntimeException:

Doc from com.jogamp.nativewindow.AbstractGraphicsDevice.validateLocked.

if current thread does not hold the lock