From c4328086d4523ea063c0b88cc1cbd935ee70fdfa Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Jun 2009 13:36:23 +0000 Subject: - Removed useless GLX synchronized hacks in X11GLXGraphicsConfiguration - Multithreading / Locking .. It turns out that there exist platforms with a buggy thread safe OpenGL/GLX/.. implementation. E.g. Linux x86_64, NV 185.18.14 where 1/6 attempts of the test case java -Djava.awt.headless=true demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2 will result in: C [libGL.so.1+0x5c08a] glXGetFBConfigAttrib+0x40a [error occurred during error reporting (printing native stack), id 0xb] Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j com.sun.opengl.impl.x11.glx.GLX.glXGetFBConfigAttrib1(JJILjava/lang/Object;I)I+0 j com.sun.opengl.impl.x11.glx.GLX.glXGetFBConfigAttrib(JJI[II)I+67 j com.sun.opengl.impl.x11.glx.X11GLXGraphicsConfiguration.glXGetFBConfig(JJI[II)I+24 In these cases, you can set the system property nativewindow.locking=true to always use the generic reentrance capable LockingNativeWindowFactory implementation as a last resort. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1992 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../media/nativewindow/NativeWindowFactory.java | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src/nativewindow/classes/javax') diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index d12c43230..e1e8970f4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -127,11 +127,12 @@ public abstract class NativeWindowFactory { } catch (Exception e) { } } - boolean toolkitLockDisabled = Boolean.getBoolean("java.awt.headless"); - - if( !toolkitLockDisabled && TYPE_X11.equals(nativeWindowingTypeCustom) ) { - NativeWindowFactory _factory = null; + boolean toolkitLockForced = Boolean.getBoolean("nativewindow.locking"); + boolean awtToolkitLockDisabled = Boolean.getBoolean("java.awt.headless"); + NativeWindowFactory _factory = null; + + if( !awtToolkitLockDisabled && null!=componentClass && TYPE_X11.equals(nativeWindowingTypeCustom) ) { // There are certain operations that may be done by // user-level native code which must share the display // connection with the underlying window toolkit. In JOGL, @@ -177,17 +178,23 @@ public abstract class NativeWindowFactory { // toolkits like Newt even when running on Java SE when // the AWT is available. - if (componentClass != null) { - try { - Constructor factoryConstructor = - NWReflection.getConstructor("com.sun.nativewindow.impl.x11.awt.X11AWTNativeWindowFactory", new Class[] {}); - _factory = (NativeWindowFactory) factoryConstructor.newInstance(null); - } catch (Exception e) { } - } + try { + Constructor factoryConstructor = + NWReflection.getConstructor("com.sun.nativewindow.impl.x11.awt.X11AWTNativeWindowFactory", new Class[] {}); + _factory = (NativeWindowFactory) factoryConstructor.newInstance(null); + } catch (Exception e) { } + } - if (null !=_factory) { - factory = _factory; - } + if (toolkitLockForced && null==_factory) { + try { + Constructor factoryConstructor = + NWReflection.getConstructor("com.sun.nativewindow.impl.LockingNativeWindowFactory", new Class[] {}); + _factory = (NativeWindowFactory) factoryConstructor.newInstance(null); + } catch (Exception e) { } + } + + if (null !=_factory) { + factory = _factory; } if(null!=componentClass) { @@ -195,8 +202,10 @@ public abstract class NativeWindowFactory { registerFactory(componentClass, factory); } defaultFactory = factory; + if(DEBUG) { - System.err.println("NativeWindowFactory defaultFactory "+factory); + System.err.println("NativeWindowFactory toolkitLockForced "+toolkitLockForced+ + ", awtToolkitLockDisabled "+awtToolkitLockDisabled+", defaultFactory "+factory); } } -- cgit v1.2.3