Class GLEventListenerState
- java.lang.Object
-
- com.jogamp.opengl.GLEventListenerState
-
public class GLEventListenerState extends Object
GLEventListenerState is holdingGLAutoDrawablecomponents crucial to relocating all itsGLEventListenerw/ their operatingGLContext, etc. The components are:GLContext- All
GLEventListener, incl. their init state GLAnimatorControlAbstractGraphicsDevicefor compatibility check and preserving the native device handle incl. ownership
A GLEventListenerState instance can be created while components are
moved fromaGLAutoDrawableto the new instance, which gainsownershipof the moved components.A GLEventListenerState instance's components can be
moved toaGLAutoDrawable, while loosingownershipof the moved components.
-
-
Field Summary
Fields Modifier and Type Field Description GLAnimatorControlanimbooleananimStartedGLCapabilitiesImmutablecapsGLContextcontextAbstractGraphicsDevicedeviceGLEventListener[]listenersboolean[]listenersInitbooleanproxyOwnsUpstreamDeviceAbstractGraphicsDeviceupstreamDevice
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Last resort to destroy and loose ownershipRunnablegetUnlockSurfaceOp()Returns aRunnableunlockingan eventually lockedNativeSurface, seemoveFrom(GLAutoDrawable, boolean)andmoveTo(GLAutoDrawable, Runnable).booleanisOwner()Returnstrue, if this instance is the current owner of the components, otherwisefalse.intlistenerCount()static GLEventListenerStatemoveFrom(GLAutoDrawable src)Moves all GLEventListenerState components from the givenGLAutoDrawableto a newly created instance.static GLEventListenerStatemoveFrom(GLAutoDrawable src, boolean keepLocked)Moves all GLEventListenerState components from the givenGLAutoDrawableto a newly created instance.voidmoveTo(GLAutoDrawable dest)Moves all GLEventListenerState components to the givenGLAutoDrawablefrom this instance, while loosingownership.voidmoveTo(GLAutoDrawable dest, Runnable destUnlockOperation)Moves all GLEventListenerState components to the givenGLAutoDrawablefrom this instance, while loosingownership.
-
-
-
Field Detail
-
upstreamDevice
public final AbstractGraphicsDevice upstreamDevice
-
proxyOwnsUpstreamDevice
public final boolean proxyOwnsUpstreamDevice
-
device
public final AbstractGraphicsDevice device
-
caps
public final GLCapabilitiesImmutable caps
-
context
public final GLContext context
-
listeners
public final GLEventListener[] listeners
-
listenersInit
public final boolean[] listenersInit
-
anim
public final GLAnimatorControl anim
-
animStarted
public final boolean animStarted
-
-
Method Detail
-
isOwner
public final boolean isOwner()
Returnstrue, if this instance is the current owner of the components, otherwisefalse.Ownership is lost if
moveTo(GLAutoDrawable)is being called successfully and all components are transferred to the newGLAutoDrawable.
-
listenerCount
public final int listenerCount()
-
getUnlockSurfaceOp
public Runnable getUnlockSurfaceOp()
Returns aRunnableunlockingan eventually lockedNativeSurface, seemoveFrom(GLAutoDrawable, boolean)andmoveTo(GLAutoDrawable, Runnable).
-
destroy
public void destroy()
Last resort to destroy and loose ownership
-
moveFrom
public static GLEventListenerState moveFrom(GLAutoDrawable src)
Moves all GLEventListenerState components from the givenGLAutoDrawableto a newly created instance.Note that all components are removed from the
GLAutoDrawable, i.e. theGLContext, allGLEventListener.If the
GLAutoDrawablewas added to aGLAnimatorControl, it is removed and theGLAnimatorControladded to the GLEventListenerState.The returned GLEventListenerState instance is the
owner of the components.Locking is performed on the
auto-drawable'supstream-lockandsurface. See GLAutoDrawable Locking.- Parameters:
src-GLAutoDrawablesource to move components from- Returns:
- new GLEventListenerState instance
owningmoved components. - See Also:
moveTo(GLAutoDrawable)
-
moveFrom
public static GLEventListenerState moveFrom(GLAutoDrawable src, boolean keepLocked)
Moves all GLEventListenerState components from the givenGLAutoDrawableto a newly created instance.Note that all components are removed from the
GLAutoDrawable, i.e. theGLContext, allGLEventListener.If the
GLAutoDrawablewas added to aGLAnimatorControl, it is removed and theGLAnimatorControladded to the GLEventListenerState.The returned GLEventListenerState instance is the
owner of the components.Locking is performed on the
auto-drawable'supstream-lockandsurface, which is not released ifkeepLockedistrue. See GLAutoDrawable Locking.keepLockedmay be utilized if swapping a context between drawables and to ensure atomicity of operation. Here, thegetUnlockSurfaceOp()shall be passed tomoveTo(GLAutoDrawable, Runnable). SeeGLDrawableUtil.swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable).- Parameters:
src-GLAutoDrawablesource to move components fromkeepLocked- keepupstream-lockandsurfacelocked, see above- Returns:
- new GLEventListenerState instance
owningmoved components. - See Also:
moveTo(GLAutoDrawable, Runnable)
-
moveTo
public final void moveTo(GLAutoDrawable dest) throws GLException
Moves all GLEventListenerState components to the givenGLAutoDrawablefrom this instance, while loosingownership.If the previous
GLAutoDrawablewas removed from aGLAnimatorControlby previousmoveFrom(GLAutoDrawable), the givenGLAutoDrawableis added to the cachedGLAnimatorControl. This operation is skipped, if the givenGLAutoDrawableis already added to aGLAnimatorControlinstance.Locking is performed on the
auto-drawable'supstream-lockandsurface. See GLAutoDrawable Locking.Note: After this operation, the GLEventListenerState reference should be released.
- Parameters:
dest-GLAutoDrawabledestination to move GLEventListenerState components to- Throws:
GLException- if a realized surface could not be locked.GLException- if this preservedAbstractGraphicsDeviceis incompatible w/ the given destination one.- See Also:
moveFrom(GLAutoDrawable),isOwner()
-
moveTo
public final void moveTo(GLAutoDrawable dest, Runnable destUnlockOperation) throws GLException
Moves all GLEventListenerState components to the givenGLAutoDrawablefrom this instance, while loosingownership.If the previous
GLAutoDrawablewas removed from aGLAnimatorControlby previousmoveFrom(GLAutoDrawable, boolean), the givenGLAutoDrawableis added to the cachedGLAnimatorControl. This operation is skipped, if the givenGLAutoDrawableis already added to aGLAnimatorControlinstance.Locking is performed on the
auto-drawable'supstream-lockandsurface. See GLAutoDrawable Locking.If the
GLAutoDrawabledesthas been kept locked bymoveFrom(GLAutoDrawable, boolean), it'sgetUnlockSurfaceOp()shall be passed here todestUnlockOperationto be unlocked.Note: After this operation, the GLEventListenerState reference should be released.
- Parameters:
dest-GLAutoDrawabledestination to move GLEventListenerState components todestUnlockOperation- optional unlock operation fordest, seemoveFrom(GLAutoDrawable, boolean).- Throws:
GLException- if a realized surface could not be locked.GLException- if this preservedAbstractGraphicsDeviceis incompatible w/ the given destination one.- See Also:
moveFrom(GLAutoDrawable, boolean),isOwner()
-
-