Class NativeWindowFactory
- java.lang.Object
-
- com.jogamp.nativewindow.NativeWindowFactory
-
public abstract class NativeWindowFactory extends Object
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to theNativeWindow
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
Fields Modifier and Type Field Description static String
TYPE_ANDROID
Android/EGL type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_AWT
Generic AWT type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_BCM_VC_IV
Broadcom VC IV/EGL type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_DEFAULT
Generic DEFAULT type, where platform implementation don't care, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_DRM_GBM
DRM/GBM type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_EGL
OpenKODE/EGL type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_IOS
iOS type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_MACOSX
Mac OS X type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_WAYLAND
Wayland/EGL type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_WINDOWS
Microsoft Windows type, as retrieved withgetNativeWindowType(boolean)
.static String
TYPE_X11
X11 type, as retrieved withgetNativeWindowType(boolean)
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addCustomShutdownHook(boolean head, Runnable runnable)
Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance.static AbstractGraphicsDevice
createDevice(String displayConnection, boolean own)
Creates a native device type, followinggetNativeWindowType(true)
.static AbstractGraphicsDevice
createDevice(String nwt, String displayConnection, boolean own)
Creates a native device type, following the givennative-window-type
.static AbstractGraphicsScreen
createScreen(AbstractGraphicsDevice device, int screen)
static NativeWindow
createWrappedWindow(AbstractGraphicsScreen aScreen, long surfaceHandle, long windowHandle, UpstreamWindowHookMutableSizePos hook)
Creates a wrappedNativeWindow
with given native handles andAbstractGraphicsScreen
.static ToolkitLock
getAWTToolkitLock()
Returns the AWTToolkitLock
(JAWT based) ifisAWTAvailable
, otherwise null.static String
getDefaultDisplayConnection()
static String
getDefaultDisplayConnection(String nwt)
static NativeWindowFactory
getDefaultFactory()
Gets the default NativeWindowFactory.static ToolkitLock
getDefaultToolkitLock()
Provides the system defaultToolkitLock
for the default system windowing type.static ToolkitLock
getDefaultToolkitLock(String type)
Provides the defaultToolkitLock
fortype
.static ToolkitLock
getDefaultToolkitLock(String type, long deviceHandle)
static NativeWindowFactory
getFactory(Class<?> windowClass)
Returns the appropriate NativeWindowFactory to handle window objects of the given type.static Point
getLocationOnScreen(NativeWindow nw)
static NativeWindow
getNativeWindow(Object winObj, AbstractGraphicsConfiguration config)
Converts the given window object and it'sAbstractGraphicsConfiguration
into aNativeWindow
which can be operated upon by a custom toolkit, e.g.static String
getNativeWindowType(boolean useCustom)
static ToolkitLock
getNullToolkitLock()
static OffscreenLayerSurface
getOffscreenLayerSurface(NativeSurface surface, boolean ifEnabled)
Returns theOffscreenLayerSurface
instance of thisNativeSurface
.static void
initSingleton()
Static one time initialization of this factory.
This initialization method must be called once by the program or utilizing modules!static boolean
isAWTAvailable()
static boolean
isInitialized()
Returns true ifinitSingleton()
has been called w/o subsequentshutdown(boolean)
.static boolean
isJVMShuttingDown()
Returns true if the JVM is shutting down, otherwise false.static boolean
isNativeVisualIDValidForProcessing(int visualID)
Returns true if the given visualID is valid for further processing, i.e.static boolean
requiresToolkitLock()
static void
setDefaultFactory(NativeWindowFactory factory)
Sets the default NativeWindowFactory.static void
shutdown(boolean _isJVMShuttingDown)
Cleanup resources at JVM shutdown
-
-
-
Field Detail
-
TYPE_WAYLAND
public static final String TYPE_WAYLAND
Wayland/EGL type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_DRM_GBM
public static final String TYPE_DRM_GBM
DRM/GBM type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_EGL
public static final String TYPE_EGL
OpenKODE/EGL type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_WINDOWS
public static final String TYPE_WINDOWS
Microsoft Windows type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_X11
public static final String TYPE_X11
X11 type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_BCM_VC_IV
public static final String TYPE_BCM_VC_IV
Broadcom VC IV/EGL type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_ANDROID
public static final String TYPE_ANDROID
Android/EGL type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_MACOSX
public static final String TYPE_MACOSX
Mac OS X type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_IOS
public static final String TYPE_IOS
iOS type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_AWT
public static final String TYPE_AWT
Generic AWT type, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
TYPE_DEFAULT
public static final String TYPE_DEFAULT
Generic DEFAULT type, where platform implementation don't care, as retrieved withgetNativeWindowType(boolean)
. String is canonical viaString.intern()
.- See Also:
- Constant Field Values
-
-
Method Detail
-
isJVMShuttingDown
public static final boolean isJVMShuttingDown()
Returns true if the JVM is shutting down, otherwise false.
-
addCustomShutdownHook
public static void addCustomShutdownHook(boolean head, Runnable runnable)
Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance.- Parameters:
head
- if true add runnable at the start, otherwise at the endrunnable
- runnable to be added.
-
shutdown
public static void shutdown(boolean _isJVMShuttingDown)
Cleanup resources at JVM shutdown
-
isInitialized
public static boolean isInitialized()
Returns true ifinitSingleton()
has been called w/o subsequentshutdown(boolean)
.
-
initSingleton
public static void initSingleton()
Static one time initialization of this factory.
This initialization method must be called once by the program or utilizing modules!
-
requiresToolkitLock
public static boolean requiresToolkitLock()
- Returns:
- true if the underlying toolkit requires locking, otherwise false.
-
isAWTAvailable
public static boolean isAWTAvailable()
- Returns:
- true if not headless, AWT Component and NativeWindow's AWT part available
-
getNativeWindowType
public static String getNativeWindowType(boolean useCustom)
- Parameters:
useCustom
- if false return the native value, if true return a custom value if set, otherwise fallback to the native value.- Returns:
- the native window type, e.g.
TYPE_X11
, which is canonical viaString.intern()
. HenceString.equals(Object)
and==
produce the same result.
-
setDefaultFactory
public static void setDefaultFactory(NativeWindowFactory factory)
Sets the default NativeWindowFactory.
-
getDefaultFactory
public static NativeWindowFactory getDefaultFactory()
Gets the default NativeWindowFactory.
-
getAWTToolkitLock
public static ToolkitLock getAWTToolkitLock()
Returns the AWTToolkitLock
(JAWT based) ifisAWTAvailable
, otherwise null.The JAWT based
ToolkitLock
also locks the global lock, which matters if the latter is required.
-
getNullToolkitLock
public static ToolkitLock getNullToolkitLock()
-
getDefaultToolkitLock
public static ToolkitLock getDefaultToolkitLock()
Provides the system defaultToolkitLock
for the default system windowing type.
-
getDefaultToolkitLock
public static ToolkitLock getDefaultToolkitLock(String type)
Provides the defaultToolkitLock
fortype
.- JAWT
ToolkitLock
if required andtype
is ofTYPE_AWT
and AWT available, -
ResourceToolkitLock
if required, otherwise -
NullToolkitLock
- JAWT
-
getDefaultToolkitLock
public static ToolkitLock getDefaultToolkitLock(String type, long deviceHandle)
Provides the defaultToolkitLock
fortype
anddeviceHandle
.- JAWT
ToolkitLock
if required andtype
is ofTYPE_AWT
and AWT available, -
ResourceToolkitLock
if required, otherwise -
NullToolkitLock
- JAWT
-
createScreen
public static AbstractGraphicsScreen createScreen(AbstractGraphicsDevice device, int screen)
- Parameters:
device
-screen
- -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen- Returns:
- newly created AbstractGraphicsScreen matching device's native type
-
getFactory
public static NativeWindowFactory getFactory(Class<?> windowClass) throws IllegalArgumentException
Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might beNativeWindow
, 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 likeComponent
.- Throws:
IllegalArgumentException
-
getNativeWindow
public static NativeWindow getNativeWindow(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException, NativeWindowException
Converts the given window object and it'sAbstractGraphicsConfiguration
into aNativeWindow
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 utilizeGraphicsConfigurationFactory
to construct a properAbstractGraphicsConfiguration
.
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.- Throws:
IllegalArgumentException
- if the given window object could not be handled by any of the registered NativeWindowFactory instancesNativeWindowException
- See Also:
com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
-
getOffscreenLayerSurface
public static OffscreenLayerSurface getOffscreenLayerSurface(NativeSurface surface, boolean ifEnabled)
Returns theOffscreenLayerSurface
instance of thisNativeSurface
.In case this surface is a
NativeWindow
, we traverse from the given surface up to root until an implementation ofOffscreenLayerSurface
is found. In caseifEnabled
is true, the surface must also implementOffscreenLayerOption
whereOffscreenLayerOption.isOffscreenLayerSurfaceEnabled()
istrue
.- Parameters:
surface
- The surface to query.ifEnabled
- If true, only return the enabledOffscreenLayerSurface
, seeOffscreenLayerOption.isOffscreenLayerSurfaceEnabled()
.- Returns:
-
isNativeVisualIDValidForProcessing
public static boolean isNativeVisualIDValidForProcessing(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
-
getDefaultDisplayConnection
public static String getDefaultDisplayConnection()
-
createDevice
public static AbstractGraphicsDevice createDevice(String displayConnection, boolean own)
Creates a native device type, followinggetNativeWindowType(true)
.The device will be opened if
own
is true, otherwise no native handle will ever be acquired.
-
createDevice
public static AbstractGraphicsDevice createDevice(String nwt, String displayConnection, boolean own)
Creates a native device type, following the givennative-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
-
createWrappedWindow
public static NativeWindow createWrappedWindow(AbstractGraphicsScreen aScreen, long surfaceHandle, long windowHandle, UpstreamWindowHookMutableSizePos hook)
Creates a wrappedNativeWindow
with given native handles andAbstractGraphicsScreen
.The given
UpstreamWindowHookMutableSizePos
maybe used to reflect resizes and repositioning of the native window.The
AbstractGraphicsScreen
may be created viacreateScreen(AbstractGraphicsDevice, int)
.The
AbstractGraphicsScreen
may have an underlying openAbstractGraphicsDevice
or a simple dummy instance, seecreateDevice(String, boolean)
.
-
getLocationOnScreen
public static Point getLocationOnScreen(NativeWindow nw)
- Parameters:
nw
-- Returns:
- top-left client-area position in window units
FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation
-
-