Top Description Inners Fields Constructors Methods
jogamp.opengl.egl

public Class EGLDisplayUtil

extends Object
Class Inheritance
Imports
java.nio.IntBuffer, java.util.Iterator, com.jogamp.nativewindow.AbstractGraphicsDevice, .NativeSurface, .NativeWindowFactory, .ToolkitLock, com.jogamp.opengl.GLException, jogamp.opengl.Debug, com.jogamp.common.ExceptionUtils, com.jogamp.common.nio.Buffers, com.jogamp.common.util.LongObjectHashMap, com.jogamp.nativewindow.egl.EGLGraphicsDevice, com.jogamp.opengl.egl.EGL

This implementation provides recursive calls to EGL#eglInitialize(long, IntBuffer, IntBuffer) and EGL#eglTerminate(long), where eglInitialize(..) is issued only for the 1st call per eglDisplay and eglTerminate(..) is issued only for the last call.

This class is required, due to implementation bugs within EGL where EGL#eglTerminate(long) does not mark the resource for deletion when still in use, bug releases them immediately.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final IntBuffer
private static final IntBuffer
private static final boolean
private static final EGLGraphicsDevice.EGLDisplayLifecycleCallback
private static final LongObjectHashMap
private static EGLDisplayUtil.EGLDisplayRef
private static boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
public static EGLGraphicsDevice

Returns:

an uninitialized EGLGraphicsDevice
eglCreateEGLGraphicsDevice
(final long nativeDisplayID, final String connection, final int unitID)

Returns an uninitialized EGLGraphicsDevice.

public static EGLGraphicsDevice

Returns:

an uninitialized EGLGraphicsDevice
eglCreateEGLGraphicsDevice
(final AbstractGraphicsDevice aDevice)

Returns an uninitialized EGLGraphicsDevice.

public static EGLGraphicsDevice

Returns:

an uninitialized EGLGraphicsDevice
eglCreateEGLGraphicsDevice
(final NativeSurface surface)

Returns an uninitialized EGLGraphicsDevice.

private static synchronized long
eglGetDisplay(final long nativeDisplay_id)

private static synchronized int
eglGetDisplayAndInitialize(final long nativeDisplayID, final long[]
array of size 1 holding return value if successful, otherwise EGL#EGL_NO_DISPLAY.
eglDisplay
,
final int[]
array of size 1 holding the EGL error value as retrieved by EGL#eglGetError() if not successful.
eglErr
,
final int[] major, final int[] minor)

private static synchronized long

Returns:

the initialized EGL display ID
eglGetDisplayAndInitialize
(final long[]
in/out array of size 1, passing the requested nativeVisualID, may return a different revised nativeVisualID handle
nativeDisplayID
,
final int[] major, final int[] minor)

Attempts to eglGetDisplayAndInitialize(long, long[], int[], IntBuffer, IntBuffer) with given nativeDisplayID.

private static synchronized boolean

Returns:

true if the eglDisplay is valid and it's reference counter becomes one and EGL#eglInitialize(long, IntBuffer, IntBuffer) was successful, otherwise false
eglInitialize
(final long eglDisplay, final int[] major, final int[] minor)

private static synchronized boolean

Returns:

true if the eglDisplay is valid and it's reference counter becomes zero and EGL#eglTerminate(long) was successful, otherwise false
eglTerminate
(final long
the EGL display handle
eglDisplay
)

pack-priv static synchronized void
setSingletonEGLDisplayOnly(final boolean v)

public static int

Returns:

number of unclosed EGL Displays.
shutdown
(final boolean verbose)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_eglMajorVersionback to summary
private static final IntBuffer _eglMajorVersion
_eglMinorVersionback to summary
private static final IntBuffer _eglMinorVersion
DEBUGback to summary
private static final boolean DEBUG
eglLifecycleCallbackback to summary
private static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback
openEGLDisplaysback to summary
private static final LongObjectHashMap openEGLDisplays
singletonEGLDisplayback to summary
private static EGLDisplayUtil.EGLDisplayRef singletonEGLDisplay
useSingletonEGLDisplayback to summary
private static boolean useSingletonEGLDisplay

Constructor Detail

EGLDisplayUtilback to summary
public EGLDisplayUtil()

Method Detail

dumpOpenDisplayConnectionsback to summary
public static void dumpOpenDisplayConnections()
eglCreateEGLGraphicsDeviceback to summary
public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(final long nativeDisplayID, final String connection, final int unitID)

Returns an uninitialized EGLGraphicsDevice. User needs to issue EGLGraphicsDevice#open() before usage.

Using eglGetDisplayAndInitialize(long[]) for the EGLGraphicsDevice#open() implementation and eglTerminate(long) for EGLGraphicsDevice#close().

Using the default ToolkitLock, via NativeWindowFactory#getDefaultToolkitLock(String, long).

Returns:EGLGraphicsDevice

an uninitialized EGLGraphicsDevice

eglCreateEGLGraphicsDeviceback to summary
public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(final AbstractGraphicsDevice aDevice)

Returns an uninitialized EGLGraphicsDevice. User needs to issue EGLGraphicsDevice#open() before usage.

Using eglGetDisplayAndInitialize(long[]) for the EGLGraphicsDevice#open() implementation and eglTerminate(long) for EGLGraphicsDevice#close().

Using the default ToolkitLock, via NativeWindowFactory#getDefaultToolkitLock(String, long).

Returns:EGLGraphicsDevice

an uninitialized EGLGraphicsDevice

eglCreateEGLGraphicsDeviceback to summary
public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(final NativeSurface surface)

Returns an uninitialized EGLGraphicsDevice. User needs to issue EGLGraphicsDevice#open() before usage.

Using eglGetDisplayAndInitialize(long[]) for the EGLGraphicsDevice#open() implementation and eglTerminate(long) for EGLGraphicsDevice#close().

Using the default ToolkitLock, via NativeWindowFactory#getDefaultToolkitLock(String, long).

Returns:EGLGraphicsDevice

an uninitialized EGLGraphicsDevice

eglGetDisplayback to summary
private static synchronized long eglGetDisplay(final long nativeDisplay_id)
eglGetDisplayAndInitializeback to summary
private static synchronized int eglGetDisplayAndInitialize(final long nativeDisplayID, final long[] eglDisplay, final int[] eglErr, final int[] major, final int[] minor)
Parameters
eglDisplay:long[]

array of size 1 holding return value if successful, otherwise EGL#EGL_NO_DISPLAY.

eglErr:int[]

array of size 1 holding the EGL error value as retrieved by EGL#eglGetError() if not successful.

Returns:int

EGL#EGL_SUCCESS if successful, otherwise EGL#EGL_BAD_DISPLAY if eglGetDisplay(long) failed or EGL#EGL_NOT_INITIALIZED if eglInitialize(long, IntBuffer, IntBuffer) failed.

See Also
eglGetDisplay(long), eglInitialize(long, IntBuffer, IntBuffer)
eglGetDisplayAndInitializeback to summary
private static synchronized long eglGetDisplayAndInitialize(final long[] nativeDisplayID, final int[] major, final int[] minor)

Attempts to eglGetDisplayAndInitialize(long, long[], int[], IntBuffer, IntBuffer) with given nativeDisplayID. If this fails, method retries with nativeDisplayID EGL#EGL_DEFAULT_DISPLAY - the fallback mechanism. The actual used nativeDisplayID is returned in it's in/out array.

Parameters
nativeDisplayID:long[]

in/out array of size 1, passing the requested nativeVisualID, may return a different revised nativeVisualID handle

Returns:long

the initialized EGL display ID

Exceptions
GLException:
eglInitializeback to summary
private static synchronized boolean eglInitialize(final long eglDisplay, final int[] major, final int[] minor)
Returns:boolean

true if the eglDisplay is valid and it's reference counter becomes one and EGL#eglInitialize(long, IntBuffer, IntBuffer) was successful, otherwise false

See Also
EGL#eglInitialize(long, IntBuffer, IntBuffer)
eglTerminateback to summary
private static synchronized boolean eglTerminate(final long eglDisplay)
Parameters
eglDisplay:long

the EGL display handle

Returns:boolean

true if the eglDisplay is valid and it's reference counter becomes zero and EGL#eglTerminate(long) was successful, otherwise false

setSingletonEGLDisplayOnlyback to summary
pack-priv static synchronized void setSingletonEGLDisplayOnly(final boolean v)
shutdownback to summary
public static int shutdown(final boolean verbose)
Returns:int

number of unclosed EGL Displays.

jogamp.opengl.egl back to summary

private Class EGLDisplayUtil.EGLDisplayRef

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final Throwable
pack-priv final long
pack-priv int

Constructor Summary

AccessConstructor and Description
private
EGLDisplayRef(final long eglDisplay)

Method Summary

Modifier and TypeMethod and Description
pack-priv static EGLDisplayUtil.EGLDisplayRef
closeOpened(final long eglDisplay, final boolean[] res)

Closes an already opened EGLDisplayRef.

pack-priv static EGLDisplayUtil.EGLDisplayRef
getOrCreateOpened(final long eglDisplay, final IntBuffer major, final IntBuffer minor)

Returns an already opened EGLDisplayRef or opens a new EGLDisplayRef.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

createdStackback to summary
pack-priv final Throwable createdStack
eglDisplayback to summary
pack-priv final long eglDisplay
initRefCountback to summary
pack-priv int initRefCount

Constructor Detail

EGLDisplayRefback to summary
private EGLDisplayRef(final long eglDisplay)

Method Detail

closeOpenedback to summary
pack-priv static EGLDisplayUtil.EGLDisplayRef closeOpened(final long eglDisplay, final boolean[] res)

Closes an already opened EGLDisplayRef.

Method decreases a reference counter and closes the EGLDisplayRef if it reaches zero.

An EGLDisplayRef is closed via EGL#eglTerminate(long).

getOrCreateOpenedback to summary
pack-priv static EGLDisplayUtil.EGLDisplayRef getOrCreateOpened(final long eglDisplay, final IntBuffer major, final IntBuffer minor)

Returns an already opened EGLDisplayRef or opens a new EGLDisplayRef.

Opened EGLDisplayRefs are mapped against their eglDisplay handle.

Method utilizes EGLDisplayRef's reference counter, i.e. increases it.

An EGLDisplayRef is opened via EGL#eglInitialize(long, IntBuffer, IntBuffer).

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