diff options
author | Sven Gothel <[email protected]> | 2011-11-26 18:33:20 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-11-26 18:33:20 +0100 |
commit | 78121938f8b432617bbb9f8e3e259ff1ffa9442e (patch) | |
tree | e4207c4eadde332f85e9b9e43e4c7cfeb2aa3338 /src | |
parent | e3c6a30ade94862a344c86dc0b733716c6fa27f5 (diff) |
Revert some changes: X11Screen/RANDR, X11Util (XInitThreads/XLockDisplay), NEWT XDisplay Locking
Revert X11Screen RANDR commit 8cecd0c2963d982aa119cbb07698e56b9c271188,
ie. use default 'render' display connection, best results on Ubuntu, Solaris, CentOS (no failures).
Revert X11Util (XInitThreads/XLockDisplay) rational logic, commit 0314be79a7a93931a74fe4322bc78e699d7741e9,
X11Util.HAS_XLOCKDISPLAY_BUG:=true and X11Util.XINITTHREADS_ALWAYS_ENABLED:=true.
Which enables always utilizing XInitThreads() either before or after AWT initialization,
as well as disable all XLockDisplay/XUnlockDisplay locks.
Rever NEWT XDisplay X11 basic Locking commit 50100b85ce5fde48788efbc2211b26fb9d7c9dfd,
ie use null locking if X11Util.HAS_XLOCKDISPLAY_BUG and X11Util.XINITTHREADS_ALWAYS_ENABLED.
Diffstat (limited to 'src')
4 files changed, 36 insertions, 11 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index adc946f70..9bc8ca9e4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -195,9 +195,10 @@ public abstract class NativeWindowFactory { final ClassLoader cl = NativeWindowFactory.class.getClassLoader(); - // X11 initialization before possible AWT initialization - initNativeImpl(firstUIActionOnProcess, cl); - + if(firstUIActionOnProcess) { + // X11 initialization before possible AWT initialization + initNativeImpl(true, cl); + } isAWTAvailable = false; // may be set to true below if( !Debug.getBooleanProperty("java.awt.headless", true, acc) && @@ -229,6 +230,10 @@ public abstract class NativeWindowFactory { } } } + if(!firstUIActionOnProcess) { + // X11 initialization after possible AWT initialization + initNativeImpl(false, cl); + } registeredFactories = Collections.synchronizedMap(new HashMap<Class<?>, NativeWindowFactory>()); // register our default factory -> NativeWindow diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 94a47d0f7..bc43a9a97 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -73,8 +73,12 @@ public class X11Util { * </p> */ public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = true; + + /** Value is <code>true</code>, best 'stable' results if always using XInitThreads(). */ + public static final boolean XINITTHREADS_ALWAYS_ENABLED = true; - // public static final boolean HAS_XLOCKDISPLAY_BUG = false; + /** Value is <code>true</code>, best 'stable' results if not using XLockDisplay/XUnlockDisplay at all. */ + public static final boolean HAS_XLOCKDISPLAY_BUG = true; private static final boolean DEBUG = Debug.debug("X11Util"); private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.getBooleanProperty("nativewindow.debug.X11Util.TraceDisplayLifecycle", true, AccessController.getContext()); @@ -89,15 +93,19 @@ public class X11Util { private static Object setX11ErrorHandlerLock = new Object(); + @SuppressWarnings("unused") public static synchronized void initSingleton(final boolean firstX11ActionOnProcess) { if(!isInit) { NWJNILibLoader.loadNativeWindow("x11"); - isX11LockAvailable = initialize0( firstX11ActionOnProcess ) /* && !HAS_XLOCKDISPLAY_BUG */ ; + final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess; + final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess ); + isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ; if(DEBUG) { System.err.println("X11Util firstX11ActionOnProcess: "+firstX11ActionOnProcess+ ", requiresX11Lock "+requiresX11Lock+ + ", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+ ", isX11LockAvailable "+isX11LockAvailable); // Thread.dumpStack(); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java index 227dd7439..b3bc6e475 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java @@ -36,6 +36,7 @@ package jogamp.newt.driver.x11; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.x11.X11GraphicsDevice; import jogamp.nativewindow.x11.X11Util; @@ -70,11 +71,18 @@ public class X11Display extends DisplayImpl { /** * {@inheritDoc} - * + * * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. - * Since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}, - * we have to supply it w/ basic locking, implicit to the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}. + * <p> + * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, + * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. + * </p> + * <p> + * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, + * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. + * </p> */ + @SuppressWarnings("unused") protected void createNativeImpl() { long handle = X11Util.openDisplay(name); if( 0 == handle ) { @@ -97,7 +105,11 @@ public class X11Display extends DisplayImpl { } // see API doc above! - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); + if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); + } else { + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); + } } protected void closeNativeImpl() { diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java index aec24e316..d4eac9b07 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java @@ -258,8 +258,8 @@ public class X11Screen extends ScreenImpl { // Internals only // private final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) { - // return display.runWithLockedDisplayHandle(action); - return runWithTempDisplayHandle(action); + return display.runWithLockedDisplayHandle(action); + // return runWithTempDisplayHandle(action); // return runWithoutLock(action); } |