Top Description Fields Constructors Methods
com.jogamp.nativewindow

public abstract Class NativeWindowFactory

extends Object
Class Inheritance
Known Direct Subclasses
jogamp.nativewindow.NativeWindowFactoryImpl
Imports
java.io.File, java.lang.reflect.Method, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .Collections, .HashMap, .List, .Map, com.jogamp.nativewindow.util.PointImmutable, jogamp.common.os.PlatformPropsImpl, jogamp.nativewindow.Debug, .NativeWindowFactoryImpl, .ToolkitProperties, .ResourceToolkitLock, .WrappedWindow, jogamp.nativewindow.macosx.OSXUtil, jogamp.nativewindow.windows.GDIUtil, jogamp.nativewindow.x11.X11Lib, .X11Util, com.jogamp.common.os.Platform, com.jogamp.common.util.InterruptSource, .PropertyAccess, .ReflectionUtil, com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos, com.jogamp.nativewindow.awt.AWTGraphicsDevice, .AWTGraphicsScreen, com.jogamp.nativewindow.egl.EGLGraphicsDevice, com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice, com.jogamp.nativewindow.windows.WindowsGraphicsDevice, com.jogamp.nativewindow.x11.X11GraphicsDevice, .X11GraphicsScreen

Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeWindow interface, which provides a platform-independent mechanism of accessing the information required to perform operations like hardware-accelerated rendering using the OpenGL API.

FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation

Field Summary

Modifier and TypeField and Description
private static final List<Runnable>
protected static final boolean
private static NativeWindowFactory
private static boolean
private static final String
private static boolean
private static boolean
private static volatile boolean
private static final String
private static ToolkitLock
private static Class<?>
private static final String
private static final String
private static final String
private static Map<Class<?>, NativeWindowFactory>
private static boolean
public static final String
TYPE_ANDROID

Android/EGL type, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_AWT

Generic AWT type, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_BCM_VC_IV

Broadcom VC IV/EGL type, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_DEFAULT

Generic DEFAULT type, where platform implementation don't care, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_EGL

OpenKODE/EGL type, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_MACOSX

Mac OS X type, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_WINDOWS

Microsoft Windows type, as retrieved with getNativeWindowType(boolean).

public static final String
TYPE_X11

X11 type, as retrieved with getNativeWindowType(boolean).

private static final String

Constructor Summary

AccessConstructor and Description
protected
NativeWindowFactory()

Creates a new NativeWindowFactory instance.

Method Summary

Modifier and TypeMethod and Description
private static String
public static void
addCustomShutdownHook(final boolean
if true add runnable at the start, otherwise at the end
head
,
final Runnable
runnable to be added.
runnable
)

Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance.

public static AbstractGraphicsDevice
createDevice(final String displayConnection, final boolean own)

Creates a native device type, following getNativeWindowType(true).

public static AbstractGraphicsDevice
createDevice(final String nwt, final String displayConnection, final boolean own)

Creates a native device type, following the given native-window-type.

public static AbstractGraphicsScreen

Returns:

newly created AbstractGraphicsScreen matching device's native type
createScreen
(final AbstractGraphicsDevice device, int
-1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen
screen
)

public static NativeWindow
createWrappedWindow(final AbstractGraphicsScreen aScreen, final long surfaceHandle, final long windowHandle, final UpstreamWindowHookMutableSizePos hook)

Creates a wrapped NativeWindow with given native handles and AbstractGraphicsScreen.

public static ToolkitLock
getAWTToolkitLock()

Returns the AWT ToolkitLock (JAWT based) if isAWTAvailable, otherwise null.

public static String
public static String
public static NativeWindowFactory
getDefaultFactory()

Gets the default NativeWindowFactory.

public static ToolkitLock
getDefaultToolkitLock()

Provides the system default ToolkitLock for the default system windowing type.

public static ToolkitLock
getDefaultToolkitLock(final String type)

Provides the default ToolkitLock for type.

public static ToolkitLock
getDefaultToolkitLock(final String type, final long deviceHandle)

Provides the default ToolkitLock for type and deviceHandle.

public static NativeWindowFactory
getFactory(final Class<?> windowClass)

Returns the appropriate NativeWindowFactory to handle window objects of the given type.

public static PointImmutable

Returns:

top-left client-area position in window units

FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation

getLocationOnScreen
(final NativeWindow nw)

public static NativeWindow
getNativeWindow(final Object winObj, final AbstractGraphicsConfiguration config)

Converts the given window object and it's AbstractGraphicsConfiguration into a NativeWindow which can be operated upon by a custom toolkit, e.g. com.jogamp.opengl.GLDrawableFactory.

protected abstract NativeWindow
getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config)

Performs the conversion from a toolkit's window object to a NativeWindow.

public static String

Returns:

the native window type, e.g. TYPE_X11, which is canonical via String#intern(). Hence String#equals(Object) and == produce the same result.
getNativeWindowType
(final boolean
if false return the native value, if true return a custom value if set, otherwise fallback to the native value.
useCustom
)

public static ToolkitLock
public static OffscreenLayerSurface
getOffscreenLayerSurface(final NativeSurface
The surface to query.
surface
,
final boolean ifEnabled)

Returns the OffscreenLayerSurface instance of this NativeSurface.

private static final boolean
public static synchronized void
initSingleton()

Static one time initialization of this factory.

private static void
public static boolean

Returns:

true if not headless, AWT Component and NativeWindow's AWT part available
isAWTAvailable
()

public static synchronized boolean
isInitialized()

Returns true if initSingleton() has been called w/o subsequent shutdown(boolean).

public static final boolean
isJVMShuttingDown()

Returns true if the JVM is shutting down, otherwise false.

public static boolean
isNativeVisualIDValidForProcessing(final int visualID)

Returns true if the given visualID is valid for further processing, i.e. OpenGL usage, otherwise return false.

protected static void
registerFactory(final Class<?> windowClass, final NativeWindowFactory factory)

Registers a NativeWindowFactory handling window objects of the given class.

public static boolean

Returns:

true if the underlying toolkit requires locking, otherwise false.
requiresToolkitLock
()

public static void
setDefaultFactory(final NativeWindowFactory factory)

Sets the default NativeWindowFactory.

public static synchronized void
shutdown(final boolean _isJVMShuttingDown)

Cleanup resources at JVM shutdown

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

customShutdownHooksback to summary
private static final List<Runnable> customShutdownHooks
DEBUGback to summary
protected static final boolean DEBUG
defaultFactoryback to summary
private static NativeWindowFactory defaultFactory
desktopHasThreadingIssuesback to summary
private static boolean desktopHasThreadingIssues
GDIClassNameback to summary
private static final String GDIClassName

jogamp.nativewindow.windows.GDIUtil implements ToolkitProperties.

initializedback to summary
private static boolean initialized
isAWTAvailableback to summary
private static boolean isAWTAvailable
isJVMShuttingDownback to summary
private static volatile boolean isJVMShuttingDown
JAWTUtilClassNameback to summary
private static final String JAWTUtilClassName
jawtUtilJAWTToolkitLockback to summary
private static ToolkitLock jawtUtilJAWTToolkitLock
nativeWindowClassback to summary
private static Class<?> nativeWindowClass
nativeWindowingTypeCustomback to summary
private static final String nativeWindowingTypeCustom
nativeWindowingTypePureback to summary
private static final String nativeWindowingTypePure
OSXUtilClassNameback to summary
private static final String OSXUtilClassName

jogamp.nativewindow.macosx.OSXUtil implements ToolkitProperties.

registeredFactoriesback to summary
private static Map<Class<?>, NativeWindowFactory> registeredFactories
requiresToolkitLockback to summary
private static boolean requiresToolkitLock
TYPE_ANDROIDback to summary
public static final String TYPE_ANDROID

Android/EGL type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_AWTback to summary
public static final String TYPE_AWT

Generic AWT type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_BCM_VC_IVback to summary
public static final String TYPE_BCM_VC_IV

Broadcom VC IV/EGL type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_DEFAULTback to summary
public static final String TYPE_DEFAULT

Generic DEFAULT type, where platform implementation don't care, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_EGLback to summary
public static final String TYPE_EGL

OpenKODE/EGL type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_MACOSXback to summary
public static final String TYPE_MACOSX

Mac OS X type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_WINDOWSback to summary
public static final String TYPE_WINDOWS

Microsoft Windows type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

TYPE_X11back to summary
public static final String TYPE_X11

X11 type, as retrieved with getNativeWindowType(boolean). String is canonical via String#intern().

X11UtilClassNameback to summary
private static final String X11UtilClassName

jogamp.nativewindow.x11.X11Util implements ToolkitProperties.

Constructor Detail

NativeWindowFactoryback to summary
protected NativeWindowFactory()

Creates a new NativeWindowFactory instance. End users do not need to call this method.

Method Detail

_getNativeWindowingTypeback to summary
private static String _getNativeWindowingType()
addCustomShutdownHookback to summary
public static void addCustomShutdownHook(final boolean head, final Runnable runnable)

Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance.

Parameters
head:boolean

if true add runnable at the start, otherwise at the end

runnable:Runnable

runnable to be added.

createDeviceback to summary
public static AbstractGraphicsDevice createDevice(final String displayConnection, final boolean own)

Creates a native device type, following getNativeWindowType(true).

The device will be opened if own is true, otherwise no native handle will ever be acquired.

createDeviceback to summary
public static AbstractGraphicsDevice createDevice(final String nwt, final String displayConnection, final boolean own)

Creates a native device type, following the given native-window-type.

The device will be opened if own is true, otherwise no native handle will ever be acquired.

FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation

createScreenback to summary
public static AbstractGraphicsScreen createScreen(final AbstractGraphicsDevice device, int screen)
Parameters
screen:int

-1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen

Returns:AbstractGraphicsScreen

newly created AbstractGraphicsScreen matching device's native type

createWrappedWindowback to summary
public static NativeWindow createWrappedWindow(final AbstractGraphicsScreen aScreen, final long surfaceHandle, final long windowHandle, final UpstreamWindowHookMutableSizePos hook)

Creates a wrapped NativeWindow with given native handles and AbstractGraphicsScreen.

The given UpstreamWindowHookMutableSizePos maybe used to reflect resizes and repositioning of the native window.

The AbstractGraphicsScreen may be created via createScreen(AbstractGraphicsDevice, int).

The AbstractGraphicsScreen may have an underlying open AbstractGraphicsDevice or a simple dummy instance, see createDevice(String, boolean).

getAWTToolkitLockback to summary
public static ToolkitLock getAWTToolkitLock()

Returns the AWT ToolkitLock (JAWT based) if isAWTAvailable, otherwise null.

The JAWT based ToolkitLock also locks the global lock, which matters if the latter is required.

getDefaultDisplayConnectionback to summary
public static String getDefaultDisplayConnection()
getDefaultDisplayConnectionback to summary
public static String getDefaultDisplayConnection(final String nwt)
getDefaultFactoryback to summary
public static NativeWindowFactory getDefaultFactory()

Gets the default NativeWindowFactory.

getDefaultToolkitLockback to summary
public static ToolkitLock getDefaultToolkitLock()

Provides the system default ToolkitLock for the default system windowing type.

See Also
getNativeWindowType(boolean), getDefaultToolkitLock(java.lang.String)
getDefaultToolkitLockback to summary
public static ToolkitLock getDefaultToolkitLock(final String type)

Provides the default ToolkitLock for type.

getDefaultToolkitLockback to summary
public static ToolkitLock getDefaultToolkitLock(final String type, final long deviceHandle)

Provides the default ToolkitLock for type and deviceHandle.

getFactoryback to summary
public static NativeWindowFactory getFactory(final Class<?> windowClass) throws IllegalArgumentException

Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be NativeWindow, in which case the client has already assumed the responsibility of creating a compatible NativeWindow implementation, or it might be that of a toolkit class like Component.

getLocationOnScreenback to summary
public static PointImmutable getLocationOnScreen(final NativeWindow nw)
Returns:PointImmutable

top-left client-area position in window units

FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation

getNativeWindowback to summary
public static NativeWindow getNativeWindow(final Object winObj, final AbstractGraphicsConfiguration config) throws IllegalArgumentException, NativeWindowException

Converts the given window object and it's AbstractGraphicsConfiguration into a NativeWindow which can be operated upon by a custom toolkit, e.g. com.jogamp.opengl.GLDrawableFactory.
The object may be a component for a particular window toolkit, such as an AWT Canvas. It may also be a NativeWindow object itself.
You shall utilize GraphicsConfigurationFactory to construct a proper AbstractGraphicsConfiguration.
The particular implementation of the NativeWindowFactory is responsible for handling objects from a particular window toolkit. The built-in NativeWindowFactory handles NativeWindow instances as well as AWT Components.

Exceptions
IllegalArgumentException:
if the given window object could not be handled by any of the registered NativeWindowFactory instances
See Also
com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
getNativeWindowImplback to summary
protected abstract NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException

Performs the conversion from a toolkit's window object to a NativeWindow. Implementors of concrete NativeWindowFactory subclasses should override this method.

getNativeWindowTypeback to summary
public static String getNativeWindowType(final boolean useCustom)
Parameters
useCustom:boolean

if false return the native value, if true return a custom value if set, otherwise fallback to the native value.

Returns:String

the native window type, e.g. TYPE_X11, which is canonical via String#intern(). Hence String#equals(Object) and == produce the same result.

getNullToolkitLockback to summary
public static ToolkitLock getNullToolkitLock()
getOffscreenLayerSurfaceback to summary
public static OffscreenLayerSurface getOffscreenLayerSurface(final NativeSurface surface, final boolean ifEnabled)

Returns the OffscreenLayerSurface instance of this NativeSurface.

In case this surface is a NativeWindow, we traverse from the given surface up to root until an implementation of OffscreenLayerSurface is found. In case ifEnabled is true, the surface must also implement OffscreenLayerOption where OffscreenLayerOption#isOffscreenLayerSurfaceEnabled() is true.

Parameters
surface:NativeSurface

The surface to query.

ifEnabled:boolean

If true, only return the enabled OffscreenLayerSurface, see OffscreenLayerOption#isOffscreenLayerSurfaceEnabled().

guessBroadcomVCIVback to summary
private static final boolean guessBroadcomVCIV()
initSingletonback to summary
public static synchronized void initSingleton()

Static one time initialization of this factory.
This initialization method must be called once by the program or utilizing modules!

initSingletonNativeImplback to summary
private static void initSingletonNativeImpl(final ClassLoader cl)
isAWTAvailableback to summary
public static boolean isAWTAvailable()
Returns:boolean

true if not headless, AWT Component and NativeWindow's AWT part available

isInitializedback to summary
public static synchronized boolean isInitialized()

Returns true if initSingleton() has been called w/o subsequent shutdown(boolean).

isJVMShuttingDownback to summary
public static final boolean isJVMShuttingDown()

Returns true if the JVM is shutting down, otherwise false.

isNativeVisualIDValidForProcessingback to summary
public static boolean isNativeVisualIDValidForProcessing(final int visualID)

Returns true if the given visualID is valid for further processing, i.e. OpenGL usage, otherwise return false.

On certain platforms, i.e. X11, a valid visualID is required at window creation. Other platforms may determine it later on, e.g. OSX and Windows.

If the visualID is VisualIDHolder#VID_UNDEFINED and the platform requires it at creation time (see above), it is not valid for further processing.

FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation

registerFactoryback to summary
protected static void registerFactory(final Class<?> windowClass, final NativeWindowFactory factory)

Registers a NativeWindowFactory handling window objects of the given class. This does not need to be called by end users, only implementors of new NativeWindowFactory subclasses.

requiresToolkitLockback to summary
public static boolean requiresToolkitLock()
Returns:boolean

true if the underlying toolkit requires locking, otherwise false.

setDefaultFactoryback to summary
public static void setDefaultFactory(final NativeWindowFactory factory)

Sets the default NativeWindowFactory.

shutdownback to summary
public static synchronized void shutdown(final boolean _isJVMShuttingDown)

Cleanup resources at JVM shutdown

shutdownNativeImplback to summary
private static void shutdownNativeImpl(final ClassLoader cl)