Top Fields Constructors Methods
jogamp.nativewindow

public abstract Class ProxySurfaceImpl

extends Object
implements ProxySurface
Class Inheritance
All Implemented Interfaces
com.jogamp.nativewindow.ProxySurface, com.jogamp.nativewindow.MutableSurface, com.jogamp.nativewindow.NativeSurface, com.jogamp.nativewindow.SurfaceUpdatedListener
Known Direct Subclasses
jogamp.nativewindow.WrappedSurface, jogamp.nativewindow.windows.GDISurface
Imports
java.io.PrintStream, com.jogamp.nativewindow.AbstractGraphicsConfiguration, .AbstractGraphicsDevice, .NativeSurface, .NativeWindowException, .ProxySurface, .SurfaceUpdatedListener, .UpstreamSurfaceHook, com.jogamp.common.util.locks.LockFactory, .RecursiveLock

Field Summary

Modifier and TypeField and Description
private AbstractGraphicsConfiguration
private int
private long
private final RecursiveLock
private final SurfaceUpdatedHelper
private UpstreamSurfaceHook
private boolean

Constructor Summary

AccessConstructor and Description
protected
ProxySurfaceImpl(final AbstractGraphicsConfiguration cfg, final UpstreamSurfaceHook
the UpstreamSurfaceHook to be used
upstream
,
final boolean
true if this ProxySurface instance owns the AbstractGraphicsConfiguration's AbstractGraphicsDevice, otherwise false. Owning the device implies closing it at destroyNotify().
ownsDevice
)

Method Summary

Modifier and TypeMethod and Description
public void
public void
addSurfaceUpdatedListener(final int
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().
index
,
final SurfaceUpdatedListener
The listener object to be inserted
l
)

Implements com.jogamp.nativewindow.NativeSurface.addSurfaceUpdatedListener.

Inserts the given SurfaceUpdatedListener at the specified position in the list.
public final void
addUpstreamOptionBits(final int v)

Implements com.jogamp.nativewindow.ProxySurface.addUpstreamOptionBits.

Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.
public final void
clearUpstreamOptionBits(final int v)

Implements com.jogamp.nativewindow.ProxySurface.clearUpstreamOptionBits.

Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v
public final boolean
containsUpstreamOptionBits(final int v)

Implements com.jogamp.nativewindow.ProxySurface.containsUpstreamOptionBits.

Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.
public void
createNotify()

Implements com.jogamp.nativewindow.ProxySurface.createNotify.

UpstreamSurfaceHook#create(ProxySurface) is being issued and the proxy surface/window handles shall be set.
public void
destroyNotify()

Implements com.jogamp.nativewindow.ProxySurface.destroyNotify.

UpstreamSurfaceHook#destroy(ProxySurface) is being issued and all proxy surface/window handles shall be cleared.
public static void
private static void
dumpHierarchy(final PrintStream out, final NativeSurface s, String indentation)

public final void
public final long
getDisplayHandle()

Implements com.jogamp.nativewindow.NativeSurface.getDisplayHandle.

Convenience: Get display handle from AbstractGraphicsConfiguration .
public final AbstractGraphicsConfiguration
getGraphicsConfiguration()

Implements com.jogamp.nativewindow.NativeSurface.getGraphicsConfiguration.

Returns the graphics configuration corresponding to this window.
public final int
getScreenIndex()

Implements com.jogamp.nativewindow.NativeSurface.getScreenIndex.

Convenience: Get display handle from AbstractGraphicsConfiguration .
public abstract long
getSurfaceHandle()

Redeclares com.jogamp.nativewindow.NativeSurface.getSurfaceHandle.

Returns the handle to the surface for this NativeSurface.
public final int
getSurfaceHeight()

Implements com.jogamp.nativewindow.NativeSurface.getSurfaceHeight.

Returns the height of the client area excluding insets (window decorations) in pixel units.
public final Thread
getSurfaceLockOwner()

Implements com.jogamp.nativewindow.NativeSurface.getSurfaceLockOwner.

Return the locking owner's Thread, or null if not locked.
public final int
getSurfaceWidth()

Implements com.jogamp.nativewindow.NativeSurface.getSurfaceWidth.

Returns the width of the client area excluding insets (window decorations) in pixel units.
public final StringBuilder
public final int
public final NativeSurface
getUpstreamSurface()

Implements com.jogamp.nativewindow.ProxySurface.getUpstreamSurface.

Returns the optional upstream NativeSurface if used by implementation, otherwise null.
public final UpstreamSurfaceHook
protected void
invalidateImpl()

Must be overridden by implementations allowing having a UpstreamSurfaceHook being passed.

public final boolean
isSurfaceLockedByOtherThread()

Implements com.jogamp.nativewindow.NativeSurface.isSurfaceLockedByOtherThread.

Query if surface is locked by another thread, i.e. not the current one.
public int
lockSurface()

Implements com.jogamp.nativewindow.NativeSurface.lockSurface.

Lock the surface of this native window.
protected abstract int
public void
public final void
setGraphicsConfiguration(final AbstractGraphicsConfiguration cfg)

Implements com.jogamp.nativewindow.ProxySurface.setGraphicsConfiguration.

Allow redefining the AbstractGraphicsConfiguration
public abstract void
setSurfaceHandle(long surfaceHandle)

Redeclares com.jogamp.nativewindow.MutableSurface.setSurfaceHandle.

Sets the surface handle which is created outside of this implementation.
public void
public boolean
surfaceSwap()

Implements com.jogamp.nativewindow.NativeSurface.surfaceSwap.

Provide a mechanism to utilize custom (pre-) swap surface code.
public void
surfaceUpdated(final Object
is the caller object who updated the surface, e.g. a JOGL GLDrawable.
updater
,
final NativeSurface
the updated NativeSurface
ns
,
final long
the time in ms, when the surface was updated
when
)

Implements com.jogamp.nativewindow.SurfaceUpdatedListener.surfaceUpdated.

Notification of a surface update event, eg.
public StringBuilder
public String
toString()

Overrides java.lang.Object.toString.

Implements com.jogamp.nativewindow.ProxySurface.toString.

Returns a string representation of the object.
public final void
unlockSurface()

Implements com.jogamp.nativewindow.NativeSurface.unlockSurface.

Unlock the surface of this native window Shall not modify the surface handle, see lockSurface()

The implementation shall also invoke AbstractGraphicsDevice#unlock() for the final unlock (recursive count zero).

protected abstract void
public final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

configback to summary
private AbstractGraphicsConfiguration config
implBitfieldback to summary
private int implBitfield
surfaceHandle_oldback to summary
private long surfaceHandle_old
surfaceLockback to summary
private final RecursiveLock surfaceLock
surfaceUpdatedHelperback to summary
private final SurfaceUpdatedHelper surfaceUpdatedHelper
upstreamback to summary
private UpstreamSurfaceHook upstream
upstreamSurfaceHookLifecycleEnabledback to summary
private boolean upstreamSurfaceHookLifecycleEnabled

Constructor Detail

ProxySurfaceImplback to summary
protected ProxySurfaceImpl(final AbstractGraphicsConfiguration cfg, final UpstreamSurfaceHook upstream, final boolean ownsDevice)
Parameters
cfg:AbstractGraphicsConfiguration

the AbstractGraphicsConfiguration to be used

upstream:UpstreamSurfaceHook

the UpstreamSurfaceHook to be used

ownsDevice:boolean

true if this ProxySurface instance owns the AbstractGraphicsConfiguration's AbstractGraphicsDevice, otherwise false. Owning the device implies closing it at destroyNotify().

Method Detail

addSurfaceUpdatedListenerback to summary
public void addSurfaceUpdatedListener(final SurfaceUpdatedListener l)

Implements com.jogamp.nativewindow.NativeSurface.addSurfaceUpdatedListener.

Doc from com.jogamp.nativewindow.NativeSurface.addSurfaceUpdatedListener.

Appends the given SurfaceUpdatedListener to the end of the list.

Annotations
@Override
addSurfaceUpdatedListenerback to summary
public void addSurfaceUpdatedListener(final int index, final SurfaceUpdatedListener l) throws IndexOutOfBoundsException

Implements com.jogamp.nativewindow.NativeSurface.addSurfaceUpdatedListener.

Doc from com.jogamp.nativewindow.NativeSurface.addSurfaceUpdatedListener.

Inserts the given SurfaceUpdatedListener at the specified position in the list.

Parameters
index:int

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:SurfaceUpdatedListener

The listener object to be inserted

Annotations
@Override
Exceptions
IndexOutOfBoundsException:
If the index is not within (0 <= index && index <= size()), or -1
addUpstreamOptionBitsback to summary
public final void addUpstreamOptionBits(final int v)

Implements com.jogamp.nativewindow.ProxySurface.addUpstreamOptionBits.

Doc from com.jogamp.nativewindow.ProxySurface.addUpstreamOptionBits.

Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.

Annotations
@Override
clearUpstreamOptionBitsback to summary
public final void clearUpstreamOptionBits(final int v)

Implements com.jogamp.nativewindow.ProxySurface.clearUpstreamOptionBits.

Doc from com.jogamp.nativewindow.ProxySurface.clearUpstreamOptionBits.

Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v

Annotations
@Override
containsUpstreamOptionBitsback to summary
public final boolean containsUpstreamOptionBits(final int v)

Implements com.jogamp.nativewindow.ProxySurface.containsUpstreamOptionBits.

Doc from com.jogamp.nativewindow.ProxySurface.containsUpstreamOptionBits.

Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.

Annotations
@Override
createNotifyback to summary
public void createNotify()

Implements com.jogamp.nativewindow.ProxySurface.createNotify.

Doc from com.jogamp.nativewindow.ProxySurface.createNotify.

UpstreamSurfaceHook#create(ProxySurface) is being issued and the proxy surface/window handles shall be set.

Annotations
@Override
destroyNotifyback to summary
public void destroyNotify()

Implements com.jogamp.nativewindow.ProxySurface.destroyNotify.

Doc from com.jogamp.nativewindow.ProxySurface.destroyNotify.

UpstreamSurfaceHook#destroy(ProxySurface) is being issued and all proxy surface/window handles shall be cleared.

Annotations
@Override
dumpHierarchyback to summary
public static void dumpHierarchy(final PrintStream out, final ProxySurface s)
dumpHierarchyback to summary
private static void dumpHierarchy(final PrintStream out, final NativeSurface s, String indentation)
enableUpstreamSurfaceHookLifecycleback to summary
public final void enableUpstreamSurfaceHookLifecycle(final boolean enable)

Implements com.jogamp.nativewindow.ProxySurface.enableUpstreamSurfaceHookLifecycle.

Doc from com.jogamp.nativewindow.ProxySurface.enableUpstreamSurfaceHookLifecycle.

Enables or disables the UpstreamSurfaceHook lifecycle functions UpstreamSurfaceHook#create(ProxySurface) and UpstreamSurfaceHook#destroy(ProxySurface).

Use this for small code blocks where the native resources shall not change, i.e. resizing a derived (OpenGL) drawable.

Annotations
@Override
getDisplayHandleback to summary
public final long getDisplayHandle()

Implements com.jogamp.nativewindow.NativeSurface.getDisplayHandle.

Doc from com.jogamp.nativewindow.NativeSurface.getDisplayHandle.

Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice

Annotations
@Override
getGraphicsConfigurationback to summary
public final AbstractGraphicsConfiguration getGraphicsConfiguration()

Implements com.jogamp.nativewindow.NativeSurface.getGraphicsConfiguration.

Doc from com.jogamp.nativewindow.NativeSurface.getGraphicsConfiguration.

Returns the graphics configuration corresponding to this window.

In case the implementation utilizes a delegation pattern to wrap abstract toolkits, this method shall return the native AbstractGraphicsConfiguration via AbstractGraphicsConfiguration#getNativeGraphicsConfiguration().

Annotations
@Override
getScreenIndexback to summary
public final int getScreenIndex()

Implements com.jogamp.nativewindow.NativeSurface.getScreenIndex.

Doc from com.jogamp.nativewindow.NativeSurface.getScreenIndex.

Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen

Annotations
@Override
getSurfaceHandleback to summary
public abstract long getSurfaceHandle()

Redeclares com.jogamp.nativewindow.NativeSurface.getSurfaceHandle.

Doc from com.jogamp.nativewindow.NativeSurface.getSurfaceHandle.

Returns the handle to the surface for this NativeSurface.

The surface handle should be set/update by lockSurface(), where unlockSurface() is not allowed to modify it. After 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.

Annotations
@Override
getSurfaceHeightback to summary
public final int getSurfaceHeight()

Implements com.jogamp.nativewindow.NativeSurface.getSurfaceHeight.

Doc from com.jogamp.nativewindow.NativeSurface.getSurfaceHeight.

Returns the height of the client area excluding insets (window decorations) in pixel units.

Returns:int

height of the client area in pixel units

Annotations
@Override
getSurfaceLockOwnerback to summary
public final Thread getSurfaceLockOwner()

Implements com.jogamp.nativewindow.NativeSurface.getSurfaceLockOwner.

Doc from com.jogamp.nativewindow.NativeSurface.getSurfaceLockOwner.

Return the locking owner's Thread, or null if not locked.

Annotations
@Override
getSurfaceWidthback to summary
public final int getSurfaceWidth()

Implements com.jogamp.nativewindow.NativeSurface.getSurfaceWidth.

Doc from com.jogamp.nativewindow.NativeSurface.getSurfaceWidth.

Returns the width of the client area excluding insets (window decorations) in pixel units.

Returns:int

width of the client area in pixel units

Annotations
@Override
getUpstreamOptionBitsback to summary
public final StringBuilder getUpstreamOptionBits(StringBuilder sink)

Implements com.jogamp.nativewindow.ProxySurface.getUpstreamOptionBits.

Annotations
@Override
getUpstreamOptionBitsback to summary
public final int getUpstreamOptionBits()

Implements com.jogamp.nativewindow.ProxySurface.getUpstreamOptionBits.

Annotations
@Override
getUpstreamSurfaceback to summary
public final NativeSurface getUpstreamSurface()

Implements com.jogamp.nativewindow.ProxySurface.getUpstreamSurface.

Doc from com.jogamp.nativewindow.ProxySurface.getUpstreamSurface.

Returns the optional upstream NativeSurface if used by implementation, otherwise null.

The upstream NativeSurface is retrieved via the UpstreamSurfaceHook, i.e. UpstreamSurfaceHook#getUpstreamSurface().

One example is the JOGL EGLWrappedSurface, which might be backed up by a native platform NativeSurface (X11, WGL, CGL, ..).

Annotations
@Override
getUpstreamSurfaceHookback to summary
public final UpstreamSurfaceHook getUpstreamSurfaceHook()

Implements com.jogamp.nativewindow.ProxySurface.getUpstreamSurfaceHook.

Doc from com.jogamp.nativewindow.ProxySurface.getUpstreamSurfaceHook.

Returns the UpstreamSurfaceHook if set, otherwise null.

Annotations
@Override
invalidateImplback to summary
protected void invalidateImpl()

Must be overridden by implementations allowing having a UpstreamSurfaceHook being passed.

See Also
destroyNotify()
isSurfaceLockedByOtherThreadback to summary
public final boolean isSurfaceLockedByOtherThread()

Implements com.jogamp.nativewindow.NativeSurface.isSurfaceLockedByOtherThread.

Doc from com.jogamp.nativewindow.NativeSurface.isSurfaceLockedByOtherThread.

Query if surface is locked by another thread, i.e. not the current one.
Convenient shortcut for:

  final Thread o = getSurfaceLockOwner();
  if( null != o && Thread.currentThread() != o ) { .. }
Annotations
@Override
lockSurfaceback to summary
public int lockSurface() throws NativeWindowException, RuntimeException

Implements com.jogamp.nativewindow.NativeSurface.lockSurface.

Doc from com.jogamp.nativewindow.NativeSurface.lockSurface.

Lock the surface of this native window.

The surface handle shall be valid after a successfull call, ie return a value other than LOCK_SURFACE_UNLOCKED and LOCK_SURFACE_NOT_READY, which is

   boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();

The caller may need to take care of the result 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 com.jogamp.common.util.locks.RecursiveLock first before proceeding with a native surface lock.

The implementation shall also invoke AbstractGraphicsDevice#lock() for the initial lock (recursive count zero).

Returns:int

LOCK_SUCCESS, LOCK_SURFACE_CHANGED or LOCK_SURFACE_NOT_READY.

Annotations
@Override
Exceptions
NativeWindowException:
if native locking failed, maybe platform related
RuntimeException:
after timeout when waiting for the surface lock
lockSurfaceImplback to summary
protected abstract int lockSurfaceImpl()
removeSurfaceUpdatedListenerback to summary
public void removeSurfaceUpdatedListener(final SurfaceUpdatedListener l)

Implements com.jogamp.nativewindow.NativeSurface.removeSurfaceUpdatedListener.

Doc from com.jogamp.nativewindow.NativeSurface.removeSurfaceUpdatedListener.

Remove the specified SurfaceUpdatedListener from the list.

Annotations
@Override
setGraphicsConfigurationback to summary
public final void setGraphicsConfiguration(final AbstractGraphicsConfiguration cfg)

Implements com.jogamp.nativewindow.ProxySurface.setGraphicsConfiguration.

Doc from com.jogamp.nativewindow.ProxySurface.setGraphicsConfiguration.

Allow redefining the AbstractGraphicsConfiguration

Annotations
@Override
setSurfaceHandleback to summary
public abstract void setSurfaceHandle(long surfaceHandle)

Redeclares com.jogamp.nativewindow.MutableSurface.setSurfaceHandle.

Doc from com.jogamp.nativewindow.MutableSurface.setSurfaceHandle.

Sets the surface handle which is created outside of this implementation.

Annotations
@Override
setUpstreamSurfaceHookback to summary
public void setUpstreamSurfaceHook(final UpstreamSurfaceHook hook)

Implements com.jogamp.nativewindow.ProxySurface.setUpstreamSurfaceHook.

Doc from com.jogamp.nativewindow.ProxySurface.setUpstreamSurfaceHook.

Overrides the UpstreamSurfaceHook.

Annotations
@Override
surfaceSwapback to summary
public boolean surfaceSwap()

Implements com.jogamp.nativewindow.NativeSurface.surfaceSwap.

Doc from com.jogamp.nativewindow.NativeSurface.surfaceSwap.

Provide a mechanism to utilize custom (pre-) swap surface code. This method is called before the render toolkit (e.g. JOGL) swaps the buffer/surface if double buffering is enabled.

The implementation may itself apply the swapping, in which case true shall be returned.

Returns:boolean

true if this method completed swapping the surface, otherwise false, in which case eg the GLDrawable implementation has to swap the code.

Annotations
@Override
surfaceUpdatedback to summary
public void surfaceUpdated(final Object updater, final NativeSurface ns, final long when)

Implements com.jogamp.nativewindow.SurfaceUpdatedListener.surfaceUpdated.

Doc from com.jogamp.nativewindow.SurfaceUpdatedListener.surfaceUpdated.

Notification of a surface update event, eg. after a swap buffer operation.

Parameters
updater:Object

is the caller object who updated the surface, e.g. a JOGL GLDrawable.

ns:NativeSurface

the updated NativeSurface

when:long

the time in ms, when the surface was updated

Annotations
@Override
toStringback to summary
public StringBuilder toString(StringBuilder sink)

Implements com.jogamp.nativewindow.ProxySurface.toString.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements com.jogamp.nativewindow.ProxySurface.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
unlockSurfaceback to summary
public final void unlockSurface()

Implements com.jogamp.nativewindow.NativeSurface.unlockSurface.

Doc from com.jogamp.nativewindow.NativeSurface.unlockSurface.

Unlock the surface of this native window Shall not modify the surface handle, see 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.

Annotations
@Override
unlockSurfaceImplback to summary
protected abstract void unlockSurfaceImpl()
validateSurfaceLockedback to summary
public final void validateSurfaceLocked()