public abstract class JAWTWindow extends Object implements NativeWindow, OffscreenLayerSurface, OffscreenLayerOption
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
Modifier and Type | Method and Description |
---|---|
void |
addSurfaceUpdatedListener(int index,
SurfaceUpdatedListener l)
Inserts the given
SurfaceUpdatedListener at the
specified position in the list. |
void |
addSurfaceUpdatedListener(SurfaceUpdatedListener l)
Appends the given
SurfaceUpdatedListener to the end of the list. |
void |
attachSurfaceLayer(long layerHandle)
Attach the offscreen layer to this offscreen layer surface.
|
void |
destroy()
Destroys this window incl.
|
void |
detachSurfaceLayer()
Detaches a previously attached offscreen layer from this offscreen layer surface.
|
long |
getAttachedSurfaceLayer()
Returns the attached surface layer or null if none is attached.
|
Component |
getAWTComponent() |
RectangleImmutable |
getBounds() |
long |
getDisplayHandle()
Convenience: Get display handle from
AbstractGraphicsConfiguration .
|
AbstractGraphicsConfiguration |
getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
|
int |
getHeight()
Returns the height of the client area excluding insets (window decorations).
|
InsetsImmutable |
getInsets()
Returns the insets defined as the width and height of the window decoration
on the left, right, top and bottom.
Insets are zero if the window is undecorated, including child windows. |
jogamp.nativewindow.jawt.JAWT |
getJAWT()
Returns the underlying JAWT instance created @
lockSurface() . |
Point |
getLocationOnScreen(Point storage)
Returns the current position of the top-left corner
of the client area in screen coordinates.
|
RecursiveLock |
getLock()
Returns the recursive lock object of this surface, which synchronizes multithreaded access.
|
NativeWindow |
getParent() |
AWTGraphicsConfiguration |
getPrivateGraphicsConfiguration() |
int |
getScreenIndex()
Convenience: Get display handle from
AbstractGraphicsConfiguration .
|
boolean |
getShallUseOffscreenLayer()
Returns the property set by
OffscreenLayerOption.setShallUseOffscreenLayer(boolean) . |
long |
getSurfaceHandle()
Returns the handle to the surface for this NativeSurface.
|
Thread |
getSurfaceLockOwner()
Return the locking owner's Thread, or null if not locked.
|
int |
getWidth()
Returns the width of the client area excluding insets (window decorations).
|
long |
getWindowHandle()
Returns the window handle for this NativeWindow.
|
int |
getX() |
int |
getY() |
boolean |
hasFocus()
Returns true if this native window owns the focus, otherwise false.
|
boolean |
isApplet()
Returns true if the AWT component is parented to an
Applet ,
otherwise false. |
boolean |
isOffscreenLayerSurfaceEnabled()
Returns true if this instance uses an offscreen layer, otherwise false.
|
boolean |
isSurfaceLayerAttached()
Returns true if a surface layer is attached, otherwise false.
|
boolean |
isSurfaceLockedByOtherThread()
Query if surface is locked by another thread, i.e.
|
int |
lockSurface()
Lock the surface of this native window.
|
void |
removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
Remove the specified
SurfaceUpdatedListener from the list. |
void |
setChosenCapabilities(CapabilitiesImmutable caps)
Sets the capabilities of this instance, allowing upstream API's to refine it, i.e.
|
void |
setShallUseOffscreenLayer(boolean v)
Request an offscreen layer, if supported.
|
boolean |
surfaceSwap()
Provide a mechanism to utilize custom (pre-) swap surface
code.
|
void |
surfaceUpdated(Object updater,
NativeSurface ns,
long when)
Notification of a surface update event, eg.
|
String |
toString() |
void |
unlockSurface()
Unlock the surface of this native window
Shall not modify the surface handle, see
NativeSurface.lockSurface() |
public final RectangleImmutable getBounds()
public final InsetsImmutable getInsets()
NativeWindow
Insets are available only after the native window has been created,
ie. the native window has been made visible.
The top-level window area's top-left corner is located at
getX() - getInsets().The top-level window size isgetLeftWidth()
getY() - getInsets().getTopHeight()
getWidth() + getInsets().getTotalWidth()
getHeight() + getInsets().getTotalHeight()
getInsets
in interface NativeWindow
public final Component getAWTComponent()
public final boolean isApplet()
Applet
,
otherwise false. This information is valid only after lockSurface()
.public final jogamp.nativewindow.jawt.JAWT getJAWT()
lockSurface()
.public void setShallUseOffscreenLayer(boolean v)
OffscreenLayerOption
Shall be called before the first NativeSurface.lockSurface()
,
and hence before realization.
setShallUseOffscreenLayer
in interface OffscreenLayerOption
OffscreenLayerOption.getShallUseOffscreenLayer()
,
OffscreenLayerOption.isOffscreenLayerSurfaceEnabled()
public final boolean getShallUseOffscreenLayer()
OffscreenLayerOption
OffscreenLayerOption.setShallUseOffscreenLayer(boolean)
.getShallUseOffscreenLayer
in interface OffscreenLayerOption
public final boolean isOffscreenLayerSurfaceEnabled()
OffscreenLayerOption
This instance is an offscreen layer, if setShallUseOffscreenLayer(true)
has been called before it's realization and first lock and the underlying implementation supports it.
NativeSurface.lockSurface()
.isOffscreenLayerSurfaceEnabled
in interface OffscreenLayerOption
OffscreenLayerOption.setShallUseOffscreenLayer(boolean)
public final void attachSurfaceLayer(long layerHandle) throws NativeWindowException
OffscreenLayerSurface
Implementation may realize all required resources at this point.
attachSurfaceLayer
in interface OffscreenLayerSurface
NativeWindowException
- if #isOffscreenLayerSurfaceEnabled()
== false#isOffscreenLayerSurfaceEnabled()
public final void detachSurfaceLayer() throws NativeWindowException
OffscreenLayerSurface
detachSurfaceLayer
in interface OffscreenLayerSurface
NativeWindowException
- if #isOffscreenLayerSurfaceEnabled()
== false
or no surface layer is attached.OffscreenLayerSurface.attachSurfaceLayer(long)
,
#isOffscreenLayerSurfaceEnabled()
public final long getAttachedSurfaceLayer()
OffscreenLayerSurface
getAttachedSurfaceLayer
in interface OffscreenLayerSurface
public final boolean isSurfaceLayerAttached()
OffscreenLayerSurface
isSurfaceLayerAttached
in interface OffscreenLayerSurface
public final void setChosenCapabilities(CapabilitiesImmutable caps)
OffscreenLayerSurface
setChosenCapabilities
in interface OffscreenLayerSurface
public final RecursiveLock getLock()
OffscreenLayerSurface
getLock
in interface OffscreenLayerSurface
public void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
NativeSurface
SurfaceUpdatedListener
to the end of the list.addSurfaceUpdatedListener
in interface NativeSurface
public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException
NativeSurface
SurfaceUpdatedListener
at the
specified position in the list.addSurfaceUpdatedListener
in interface NativeSurface
index
- Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l
- The listener object to be insertedIndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
NativeSurface
SurfaceUpdatedListener
from the list.removeSurfaceUpdatedListener
in interface NativeSurface
public void surfaceUpdated(Object updater, NativeSurface ns, long when)
SurfaceUpdatedListener
surfaceUpdated
in interface SurfaceUpdatedListener
updater
- is the caller object who updated the surface,
e.g. a JOGL GLDrawable.ns
- the updated NativeSurfacewhen
- the time in ms, when the surface was updatedpublic final int lockSurface() throws NativeWindowException, RuntimeException
NativeSurface
The surface handle shall be valid after a successfull call,
ie return a value other than NativeSurface.LOCK_SURFACE_UNLOCKED
and NativeSurface.LOCK_SURFACE_NOT_READY
,
which is
boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();
The caller may need to take care of the result NativeSurface.LOCK_SURFACE_CHANGED
,
where the surface handle is valid but has changed.
This call is blocking until the surface has been locked or a timeout is reached. The latter will throw a runtime exception.
This call allows recursion from the same thread.
The implementation may want to aquire the
application level RecursiveLock
first before proceeding with a native surface lock.
The implementation shall also invoke AbstractGraphicsDevice.lock()
for the initial lock (recursive count zero).
lockSurface
in interface NativeSurface
NativeSurface.LOCK_SUCCESS
, NativeSurface.LOCK_SURFACE_CHANGED
or NativeSurface.LOCK_SURFACE_NOT_READY
.NativeWindowException
- if native locking failed, maybe platform relatedRuntimeException
- after timeout when waiting for the surface lockRecursiveLock
public final void unlockSurface()
NativeSurface
NativeSurface.lockSurface()
The implementation shall also invoke AbstractGraphicsDevice.unlock()
for the final unlock (recursive count zero).
The implementation shall be fail safe, i.e. tolerant in case the native resources are already released / unlocked. In this case the implementation shall simply ignore the call.
unlockSurface
in interface NativeSurface
NativeSurface.lockSurface()
,
RecursiveLock
public final boolean isSurfaceLockedByOtherThread()
NativeSurface
final Thread o = getSurfaceLockOwner(); if( null != o && Thread.currentThread() != o ) { .. }
isSurfaceLockedByOtherThread
in interface NativeSurface
public final Thread getSurfaceLockOwner()
NativeSurface
getSurfaceLockOwner
in interface NativeSurface
public boolean surfaceSwap()
NativeSurface
The implementation may itself apply the swapping, in which case true shall be returned.
surfaceSwap
in interface NativeSurface
public long getSurfaceHandle()
NativeSurface
The surface handle should be set/update by NativeSurface.lockSurface()
,
where NativeSurface.unlockSurface()
is not allowed to modify it.
After NativeSurface.unlockSurface()
it is no more guaranteed
that the surface handle is still valid.
The surface handle shall reflect the platform one
for all drawable surface operations, e.g. opengl, swap-buffer.
On X11 this returns an entity of type Window,
since there is no differentiation of surface and window there.
On Microsoft Windows this returns an entity of type HDC.
getSurfaceHandle
in interface NativeSurface
public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration()
public final AbstractGraphicsConfiguration getGraphicsConfiguration()
NativeSurface
In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
this method shall return the native AbstractGraphicsConfiguration
via AbstractGraphicsConfiguration.getNativeGraphicsConfiguration()
.
getGraphicsConfiguration
in interface NativeSurface
AbstractGraphicsConfiguration.getNativeGraphicsConfiguration()
,
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
public final long getDisplayHandle()
NativeSurface
getDisplayHandle
in interface NativeSurface
public final int getScreenIndex()
NativeSurface
getScreenIndex
in interface NativeSurface
public final int getWidth()
NativeSurface
getWidth
in interface NativeSurface
public final int getHeight()
NativeSurface
getHeight
in interface NativeSurface
public void destroy()
NativeWindow
destroy
in interface NativeWindow
public final NativeWindow getParent()
getParent
in interface NativeWindow
public long getWindowHandle()
NativeWindow
The window handle shall reflect the platform one for all window related operations, e.g. open, close, resize.
On X11 this returns an entity of type Window.
On Microsoft Windows this returns an entity of type HWND.
getWindowHandle
in interface NativeWindow
public final int getX()
getX
in interface NativeWindow
NativeWindow.getInsets()
public final int getY()
getY
in interface NativeWindow
NativeWindow.getInsets()
public Point getLocationOnScreen(Point storage)
Since the position reflects the client area, it does not include the insets.
This JAWT default implementation is currently still using
a blocking implementation. It first attempts to retrieve the location
via a native implementation. If this fails, it tries the blocking AWT implementation.
If the latter fails due to an external AWT tree-lock, the non block
implementation getLocationOnScreenNonBlocking(Point, Component)
is being used.
The latter simply traverse up to the AWT component tree and sums the rel. position.
We have to determine whether the latter is good enough for all cases,
currently only OS X utilizes the non blocking method per default.
getLocationOnScreen
in interface NativeWindow
storage
- if not null,
Point.translate(javax.media.nativewindow.util.Point)
the passed Point
by this location on the screen and return it.public boolean hasFocus()
NativeWindow
hasFocus
in interface NativeWindow
Copyright 2010 JogAmp Community.