public class GLEventListenerState extends Object
GLAutoDrawable
components crucial
to relocating all its GLEventListener
w/ their operating GLContext
, etc.
The components are:
GLContext
GLEventListener
, incl. their init stateGLAnimatorControl
AbstractGraphicsDevice
for compatibility check and preserving the native device handle incl. ownership
A GLEventListenerState instance can be created while components are moved from
a GLAutoDrawable
to the new instance, which gains ownership
of the moved components.
A GLEventListenerState instance's components can be moved to
a GLAutoDrawable
,
while loosing ownership
of the moved components.
Modifier and Type | Field and Description |
---|---|
GLAnimatorControl |
anim |
boolean |
animStarted |
GLCapabilitiesImmutable |
caps |
GLContext |
context |
AbstractGraphicsDevice |
device |
GLEventListener[] |
listeners |
boolean[] |
listenersInit |
boolean |
proxyOwnsUpstreamDevice |
AbstractGraphicsDevice |
upstreamDevice |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Last resort to destroy and loose ownership
|
Runnable |
getUnlockSurfaceOp()
Returns a
Runnable unlocking an eventually locked NativeSurface ,
see moveFrom(GLAutoDrawable, boolean) and moveTo(GLAutoDrawable, Runnable) . |
boolean |
isOwner()
Returns
true , if this instance is the current owner of the components,
otherwise false . |
int |
listenerCount() |
static GLEventListenerState |
moveFrom(GLAutoDrawable src)
Moves all GLEventListenerState components from the given
GLAutoDrawable
to a newly created instance. |
static GLEventListenerState |
moveFrom(GLAutoDrawable src,
boolean keepLocked)
Moves all GLEventListenerState components from the given
GLAutoDrawable
to a newly created instance. |
void |
moveTo(GLAutoDrawable dest)
Moves all GLEventListenerState components to the given
GLAutoDrawable
from this instance, while loosing ownership . |
void |
moveTo(GLAutoDrawable dest,
Runnable destUnlockOperation)
Moves all GLEventListenerState components to the given
GLAutoDrawable
from this instance, while loosing ownership . |
public final AbstractGraphicsDevice upstreamDevice
public final boolean proxyOwnsUpstreamDevice
public final AbstractGraphicsDevice device
public final GLCapabilitiesImmutable caps
public final GLContext context
public final GLEventListener[] listeners
public final boolean[] listenersInit
public final GLAnimatorControl anim
public final boolean animStarted
public final boolean isOwner()
true
, if this instance is the current owner of the components,
otherwise false
.
Ownership is lost if moveTo(GLAutoDrawable)
is being called successfully
and all components are transferred to the new GLAutoDrawable
.
public final int listenerCount()
public Runnable getUnlockSurfaceOp()
Runnable
unlocking
an eventually locked NativeSurface
,
see moveFrom(GLAutoDrawable, boolean)
and moveTo(GLAutoDrawable, Runnable)
.public void destroy()
public static GLEventListenerState moveFrom(GLAutoDrawable src)
GLAutoDrawable
to a newly created instance.
Note that all components are removed from the GLAutoDrawable
,
i.e. the GLContext
, all GLEventListener
.
If the GLAutoDrawable
was added to a GLAnimatorControl
, it is removed
and the GLAnimatorControl
added to the GLEventListenerState.
The returned GLEventListenerState instance is the owner of the components
.
Locking is performed on the auto-drawable's
upstream-lock
and surface
.
See GLAutoDrawable Locking.
src
- GLAutoDrawable
source to move components fromowning
moved components.moveTo(GLAutoDrawable)
public static GLEventListenerState moveFrom(GLAutoDrawable src, boolean keepLocked)
GLAutoDrawable
to a newly created instance.
Note that all components are removed from the GLAutoDrawable
,
i.e. the GLContext
, all GLEventListener
.
If the GLAutoDrawable
was added to a GLAnimatorControl
, it is removed
and the GLAnimatorControl
added to the GLEventListenerState.
The returned GLEventListenerState instance is the owner of the components
.
Locking is performed on the auto-drawable's
upstream-lock
and surface
,
which is not released if keepLocked
is true
.
See GLAutoDrawable Locking.
keepLocked
may be utilized if swapping a context between drawables
and to ensure atomicity of operation.
Here, the getUnlockSurfaceOp()
shall be passed to moveTo(GLAutoDrawable, Runnable)
.
See GLDrawableUtil.swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)
.
src
- GLAutoDrawable
source to move components fromkeepLocked
- keep upstream-lock
and surface
locked, see aboveowning
moved components.moveTo(GLAutoDrawable, Runnable)
public final void moveTo(GLAutoDrawable dest) throws GLException
GLAutoDrawable
from this instance, while loosing ownership
.
If the previous GLAutoDrawable
was removed from a GLAnimatorControl
by previous moveFrom(GLAutoDrawable)
,
the given GLAutoDrawable
is added to the cached GLAnimatorControl
.
This operation is skipped, if the given GLAutoDrawable
is already added to a GLAnimatorControl
instance.
Locking is performed on the auto-drawable's
upstream-lock
and surface
.
See GLAutoDrawable Locking.
Note: After this operation, the GLEventListenerState reference should be released.
dest
- GLAutoDrawable
destination to move GLEventListenerState components toGLException
- if a realized surface could not be locked.GLException
- if this preserved AbstractGraphicsDevice
is incompatible w/ the given destination one.
moveFrom(GLAutoDrawable)
,
isOwner()
public final void moveTo(GLAutoDrawable dest, Runnable destUnlockOperation) throws GLException
GLAutoDrawable
from this instance, while loosing ownership
.
If the previous GLAutoDrawable
was removed from a GLAnimatorControl
by previous moveFrom(GLAutoDrawable, boolean)
,
the given GLAutoDrawable
is added to the cached GLAnimatorControl
.
This operation is skipped, if the given GLAutoDrawable
is already added to a GLAnimatorControl
instance.
Locking is performed on the auto-drawable's
upstream-lock
and surface
.
See GLAutoDrawable Locking.
If the GLAutoDrawable
dest
has been kept locked by moveFrom(GLAutoDrawable, boolean)
,
it's getUnlockSurfaceOp()
shall be passed here to destUnlockOperation
to be unlocked.
Note: After this operation, the GLEventListenerState reference should be released.
dest
- GLAutoDrawable
destination to move GLEventListenerState components todestUnlockOperation
- optional unlock operation for dest
, see moveFrom(GLAutoDrawable, boolean)
.GLException
- if a realized surface could not be locked.GLException
- if this preserved AbstractGraphicsDevice
is incompatible w/ the given destination one.
moveFrom(GLAutoDrawable, boolean)
,
isOwner()
Copyright 2010 JogAmp Community.