public abstract class JAWTWindow extends Object implements NativeWindow, OffscreenLayerSurface, OffscreenLayerOption, ScalableSurface
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
AUTOMAX_PIXELSCALE, IDENTITY_PIXELSCALE
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.
|
int[] |
convertToPixelUnits(int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
|
int[] |
convertToWindowUnits(int[] pixelUnitsAndResult)
Converts the given pixel units into window units in place.
|
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() |
float[] |
getCurrentSurfaceScale(float[] result)
Returns the current pixel scale of the associated
NativeSurface . |
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) in window units.
|
InsetsImmutable |
getInsets()
Returns the insets defined as the width and height of the window decoration
on the left, right, top and bottom in window units.
|
jogamp.nativewindow.jawt.JAWT |
getJAWT()
Returns the underlying JAWT instance created @
lockSurface() . |
Point |
getLocationOnScreen(Point storage)
Returns the window's top-left client-area position in the screen.
|
RecursiveLock |
getLock()
Returns the recursive lock object of this surface, which synchronizes multithreaded access.
|
float[] |
getMaximumSurfaceScale(float[] result)
Returns the maximum pixel scale of the associated
NativeSurface . |
float[] |
getMinimumSurfaceScale(float[] result)
Returns the minimum pixel scale of the associated
NativeSurface . |
NativeSurface |
getNativeSurface()
Returns the associated
NativeSurface of this NativeSurfaceHolder . |
NativeWindow |
getParent() |
float[] |
getRequestedSurfaceScale(float[] result)
Returns the
requested pixel scale of the associated NativeSurface . |
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.
|
int |
getSurfaceHeight()
Returns the height of the client area excluding insets (window decorations) in pixel units.
|
Thread |
getSurfaceLockOwner()
Return the locking owner's Thread, or null if not locked.
|
int |
getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
|
int |
getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
|
long |
getWindowHandle()
Returns the window handle for this NativeWindow.
|
int |
getX()
Returns the x position of the top-left corner
of the client area relative to it's parent in window units.
|
int |
getY()
Returns the current y position of the top-left corner
of the client area relative to it's parent in window units.
|
boolean |
hasFocus()
Returns true if this native window owns the focus, otherwise false.
|
boolean |
hasPixelScaleChanged()
Returns and clears the
hasPixelScaleChanged flag, as set via lockSurface() . |
boolean |
hideCursor()
Optional method hiding the cursor in the corresponding on-screen surface/window, if exists.
|
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.
|
boolean |
setCursor(PixelRectangle pixelrect,
PointImmutable hotSpot)
Optional method setting cursor in the corresponding on-screen surface/window, if exists.
|
void |
setShallUseOffscreenLayer(boolean v)
Request an offscreen layer, if supported.
|
boolean |
setSurfaceScale(float[] pixelScale)
Request a pixel scale in x- and y-direction for the associated
NativeSurface ,
where size_in_pixel_units = pixel_scale * size_in_window_units . |
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() |
boolean |
updatePixelScale(boolean clearFlag)
Updates the minimum and maximum pixel-scale values
and returns
true if they were updated. |
public boolean setSurfaceScale(float[] pixelScale)
ScalableSurface
NativeSurface
,
where size_in_pixel_units = pixel_scale * size_in_window_units
.
Default pixel scale request for both directions is ScalableSurface.AUTOMAX_PIXELSCALE
.
In case platform only supports uniform pixel scale, i.e. one scale for both directions,
either ScalableSurface.AUTOMAX_PIXELSCALE
or the maximum requested pixel scale component is used.
The requested pixel scale will be validated against platform limits before native scale-setup,
i.e. clipped to ScalableSurface.IDENTITY_PIXELSCALE
if not supported or clipped to the platform maximum.
It can be queried via ScalableSurface.getRequestedSurfaceScale(float[])
.
The actual realized pixel scale values of the NativeSurface
can be queried via ScalableSurface.getCurrentSurfaceScale(float[])
or
computed via surface.
convertToPixelUnits
(new int[] { 1, 1 })
setSurfaceScale
in interface ScalableSurface
pixelScale
- requested surface pixel scale float[2] values for x- and y-direction.true
if the current pixel scale
has changed, otherwise false
.ScalableSurface.getRequestedSurfaceScale(float[])
public final float[] getRequestedSurfaceScale(float[] result)
ScalableSurface
requested
pixel scale of the associated NativeSurface
.getRequestedSurfaceScale
in interface ScalableSurface
result
- float[2] storage for the resultScalableSurface.setSurfaceScale(float[])
public final float[] getCurrentSurfaceScale(float[] result)
ScalableSurface
NativeSurface
.getCurrentSurfaceScale
in interface ScalableSurface
result
- float[2] storage for the resultpublic float[] getMinimumSurfaceScale(float[] result)
ScalableSurface
NativeSurface
.getMinimumSurfaceScale
in interface ScalableSurface
result
- float[2] storage for the resultpublic final float[] getMaximumSurfaceScale(float[] result)
ScalableSurface
NativeSurface
.
The maximum pixel scale maybe used to determine the proper dpi
value of the monitor displaying this NativeSurface
.
surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale, with PpMM == pixel per millimeter
getMaximumSurfaceScale
in interface ScalableSurface
result
- float[2] storage for the resultpublic final boolean updatePixelScale(boolean clearFlag)
true
if they were updated.clearFlag
- if true
, the hasPixelScaleChanged
flag will be clearedtrue
if values were updated, otherwise false
.hasPixelScaleChanged()
public final boolean hasPixelScaleChanged()
hasPixelScaleChanged
flag, as set via lockSurface()
.
hasPixelScaleChanged
is true
,
if the minimum
or maximum
pixel scale has changed.
User needs to set the current pixel scale
in this case
using the requested pixel scale
to update the surface pixel scale.
public final RectangleImmutable getBounds()
public final InsetsImmutable getInsets()
NativeWindow
Insets are zero if the window is undecorated, including child windows.
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
The top-level window size isNativeWindow.getX()
- getInsets().getLeftWidth()
NativeWindow.getY()
- getInsets().getTopHeight()
NativeWindow.getWidth()
+ getInsets().getTotalWidth()
NativeWindow.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 final boolean setCursor(PixelRectangle pixelrect, PointImmutable hotSpot)
OffscreenLayerSurface
setCursor
in interface OffscreenLayerSurface
pixelrect
- cursor pixels, maybe null for default cursorhotSpot
- maybe null for default cursorpublic final boolean hideCursor()
OffscreenLayerSurface
hideCursor
in interface OffscreenLayerSurface
public 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 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 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 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()
,
com.jogamp.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 getSurfaceWidth()
NativeSurface
getSurfaceWidth
in interface NativeSurface
NativeWindow.getWidth()
,
NativeSurface.convertToWindowUnits(int[])
public final int getSurfaceHeight()
NativeSurface
getSurfaceHeight
in interface NativeSurface
NativeWindow.getHeight()
,
NativeSurface.convertToWindowUnits(int[])
public final int[] convertToWindowUnits(int[] pixelUnitsAndResult)
NativeSurface
convertToWindowUnits
in interface NativeSurface
pixelUnitsAndResult
- int[2] storage holding the pixel units for the x- and y-coord to convert
and the resulting values.ScalableSurface
public final int[] convertToPixelUnits(int[] windowUnitsAndResult)
NativeSurface
convertToPixelUnits
in interface NativeSurface
windowUnitsAndResult
- int[2] storage holding the window units for the x- and y-coord to convert
and the resulting values.ScalableSurface
public final NativeSurface getNativeSurface()
NativeWindow
NativeSurface
of this NativeSurfaceHolder
.
Returns this instance, which is-a NativeSurface
.
getNativeSurface
in interface NativeSurfaceHolder
getNativeSurface
in interface NativeWindow
public final int getWidth()
NativeWindow
getWidth
in interface NativeWindow
NativeSurface.getSurfaceWidth()
public final int getHeight()
NativeWindow
getHeight
in interface NativeWindow
NativeSurface.getSurfaceHeight()
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()
NativeWindow
If no parent exist (top-level window), this coordinate equals the screen coordinate.
Since the position reflects the client area, it does not include the insets.
See Coordinate System.
getX
in interface NativeWindow
NativeWindow.getInsets()
,
NativeWindow.getLocationOnScreen(Point)
public final int getY()
NativeWindow
If no parent exist (top-level window), this coordinate equals the screen coordinate.
Since the position reflects the client area, it does not include the insets.
See Coordinate System.
getY
in interface NativeWindow
NativeWindow.getInsets()
,
NativeWindow.getLocationOnScreen(Point)
public Point getLocationOnScreen(Point storage)
If Point
is not null
, it is translated about the resulting screen position
and returned.
See Coordinate System.
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
- Optional Point
storage.
If not null, null
, it is translated about the resulting screen position
and returned.NativeWindow.getX()
,
NativeWindow.getY()
,
NativeWindow.getInsets()
public boolean hasFocus()
NativeWindow
hasFocus
in interface NativeWindow
Copyright 2010 JogAmp Community.