aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java40
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java13
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java5
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java8
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java3
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java10
9 files changed, 32 insertions, 53 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
index 1cc796086..7be747ff5 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
@@ -210,7 +210,7 @@ public class SWTAccessor {
if( null != OS_gtk_class ) {
long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle);
long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle);
- return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false);
+ return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false /* owner */);
}
final String nwt = NativeWindowFactory.getNativeWindowType(false);
if( NativeWindowFactory.TYPE_WINDOWS == nwt ) {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index 1962bcd09..006ee4c97 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -42,6 +42,7 @@ import java.util.HashMap;
import java.util.Map;
import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.GlobalToolkitLock;
import jogamp.nativewindow.NativeWindowFactoryImpl;
import jogamp.nativewindow.ToolkitProperties;
import jogamp.nativewindow.ResourceToolkitLock;
@@ -102,7 +103,7 @@ public abstract class NativeWindowFactory {
private static ToolkitLock jawtUtilJAWTToolkitLock;
private static boolean requiresToolkitLock;
- private static boolean requiresGlobalToolkitLock;
+ private static boolean desktopHasThreadingIssues;
private static volatile boolean isJVMShuttingDown = false;
@@ -183,15 +184,11 @@ public abstract class NativeWindowFactory {
final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl);
requiresToolkitLock = res1.booleanValue();
- if(requiresToolkitLock) {
- final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresGlobalToolkitLock", null, null, cl);
- requiresGlobalToolkitLock = res2.booleanValue();
- } else {
- requiresGlobalToolkitLock = false;
- }
+ final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "hasThreadingIssues", null, null, cl);
+ desktopHasThreadingIssues = res2.booleanValue();
} else {
requiresToolkitLock = false;
- requiresGlobalToolkitLock = false;
+ desktopHasThreadingIssues = false;
}
}
@@ -293,7 +290,7 @@ public abstract class NativeWindowFactory {
}
if(DEBUG) {
- System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", requiresGlobalToolkitLock "+requiresGlobalToolkitLock);
+ System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", desktopHasThreadingIssues "+desktopHasThreadingIssues);
System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory);
}
@@ -329,11 +326,6 @@ public abstract class NativeWindowFactory {
return requiresToolkitLock;
}
- /** @return true if the underlying toolkit requires global locking, otherwise false. */
- public static boolean requiresGlobalToolkitLock() {
- return requiresGlobalToolkitLock;
- }
-
/** @return true if not headless, AWT Component and NativeWindow's AWT part available */
public static boolean isAWTAvailable() { return isAWTAvailable; }
@@ -382,12 +374,16 @@ public abstract class NativeWindowFactory {
public static ToolkitLock getNullToolkitLock() {
return NativeWindowFactoryImpl.getNullToolkitLock();
}
-
- public static ToolkitLock getGlobalToolkitLock() {
- return NativeWindowFactoryImpl.getGlobalToolkitLock();
- }
/**
+ * Ony call this for small code segments for desktop w/ threading issues.
+ * @return {@link GlobalToolkitLock} if desktop has threading issues, otherwise {@link #getNullToolkitLock()}
+ */
+ public static ToolkitLock getGlobalToolkitLockIfRequired() {
+ return desktopHasThreadingIssues ? GlobalToolkitLock.getSingleton() : getNullToolkitLock();
+ }
+
+ /**
* Provides the system default {@link ToolkitLock} for the default system windowing type.
* @see #getNativeWindowType(boolean)
* @see #getDefaultToolkitLock(java.lang.String)
@@ -400,7 +396,6 @@ public abstract class NativeWindowFactory {
* Provides the default {@link ToolkitLock} for <code>type</code>.
* <ul>
* <li> JAWT {@link ToolkitLock} if required and <code>type</code> is of {@link #TYPE_AWT} and AWT available,</li>
- * <li> {@link jogamp.nativewindow.GlobalToolkitLock} if required, otherwise</li>
* <li> {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise</li>
* <li> {@link jogamp.nativewindow.NullToolkitLock} </li>
* </ul>
@@ -410,9 +405,6 @@ public abstract class NativeWindowFactory {
if( TYPE_AWT == type && isAWTAvailable() ) {
return getAWTToolkitLock();
}
- if( requiresGlobalToolkitLock ) {
- return NativeWindowFactoryImpl.getGlobalToolkitLock();
- }
return ResourceToolkitLock.create();
}
return NativeWindowFactoryImpl.getNullToolkitLock();
@@ -422,7 +414,6 @@ public abstract class NativeWindowFactory {
* Provides the default {@link ToolkitLock} for <code>type</code> and <code>deviceHandle</code>.
* <ul>
* <li> JAWT {@link ToolkitLock} if required and <code>type</code> is of {@link #TYPE_AWT} and AWT available,</li>
- * <li> {@link jogamp.nativewindow.GlobalToolkitLock} if required, otherwise</li>
* <li> {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise</li>
* <li> {@link jogamp.nativewindow.NullToolkitLock} </li>
* </ul>
@@ -432,9 +423,6 @@ public abstract class NativeWindowFactory {
if( TYPE_AWT == type && isAWTAvailable() ) {
return getAWTToolkitLock();
}
- if( requiresGlobalToolkitLock ) {
- return NativeWindowFactoryImpl.getGlobalToolkitLock();
- }
return ResourceToolkitLock.create();
}
return NativeWindowFactoryImpl.getNullToolkitLock();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java
index 0c2a1e43f..c9f830811 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java
@@ -36,16 +36,19 @@ import com.jogamp.common.util.locks.RecursiveLock;
/**
* Implementing a global recursive {@link javax.media.nativewindow.ToolkitLock}.
* <p>
- * This is the last resort for unstable driver, e.g. proprietary ATI/X11 12.8 and 12.9,
- * where multiple X11 display connections to the same connection name are not treated
- * thread safe within the GL/X11 driver.
+ * This is the last resort for unstable driver where multiple X11 display connections
+ * to the same connection name are not treated thread safe within the GL/X11 driver.
* </p>
*/
public class GlobalToolkitLock implements ToolkitLock {
private static final RecursiveLock globalLock = LockFactory.createRecursiveLock();
+ private static GlobalToolkitLock singleton = new GlobalToolkitLock();
- /** Singleton via {@link NativeWindowFactoryImpl#getGlobalToolkitLock()} */
- protected GlobalToolkitLock() { }
+ public static final GlobalToolkitLock getSingleton() {
+ return singleton;
+ }
+
+ private GlobalToolkitLock() { }
@Override
public final void lock() {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java
index c35cede77..a3a66b7f1 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java
@@ -44,16 +44,11 @@ import com.jogamp.common.util.ReflectionUtil.AWTNames;
public class NativeWindowFactoryImpl extends NativeWindowFactory {
private static final ToolkitLock nullToolkitLock = new NullToolkitLock();
- private static final ToolkitLock globalToolkitLock = new GlobalToolkitLock();
public static ToolkitLock getNullToolkitLock() {
return nullToolkitLock;
}
- public static ToolkitLock getGlobalToolkitLock() {
- return globalToolkitLock;
- }
-
// This subclass of NativeWindowFactory handles the case of
// NativeWindows being passed in
protected NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java
index 2062d1f58..ed23def8f 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java
@@ -13,15 +13,11 @@ import javax.media.nativewindow.NativeWindowFactory;
public static boolean requiresToolkitLock() {}
- public static boolean requiresGlobalToolkitLock() {}
+ public static boolean hasThreadingIssues() {}
* </pre>
* Above static methods are invoked by {@link NativeWindowFactory#initSingleton()},
* or {@link NativeWindowFactory#shutdown()} via reflection.
* </p>
- * <p>
- * If <code>requiresGlobalToolkitLock() == true</code>, then
- * <code>requiresToolkitLock() == true</code> shall be valid as well.
- * </p>
*/
public interface ToolkitProperties {
@@ -46,6 +42,6 @@ public interface ToolkitProperties {
/**
* Called by {@link NativeWindowFactory#initSingleton()}
*/
- // boolean requiresGlobalToolkitLock();
+ // boolean hasThreadingIssues();
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index 67c64a95c..349da8ee6 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -237,18 +237,15 @@ public class JAWTUtil {
jawtToolkitLock = new ToolkitLock() {
public final void lock() {
- NativeWindowFactory.getGlobalToolkitLock().lock();
JAWTUtil.lockToolkit();
if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.lock()"); }
}
public final void unlock() {
if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.unlock()"); }
JAWTUtil.unlockToolkit();
- NativeWindowFactory.getGlobalToolkitLock().unlock();
}
@Override
public final void validateLocked() throws RuntimeException {
- NativeWindowFactory.getGlobalToolkitLock().validateLocked();
JAWTUtil.validateLocked();
}
public final void dispose() {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 481cbbe39..a195f137e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -76,7 +76,7 @@ public class OSXUtil implements ToolkitProperties {
* Called by {@link NativeWindowFactory#initSingleton()}
* @see ToolkitProperties
*/
- public static final boolean requiresGlobalToolkitLock() { return false; }
+ public static final boolean hasThreadingIssues() { return false; }
public static boolean isNSView(long object) {
return isNSView0(object);
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
index 4408a0903..2f4e18359 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
@@ -84,7 +84,7 @@ public class GDIUtil implements ToolkitProperties {
* Called by {@link NativeWindowFactory#initSingleton()}
* @see ToolkitProperties
*/
- public static final boolean requiresGlobalToolkitLock() { return false; }
+ public static final boolean hasThreadingIssues() { return false; }
private static RegisteredClass dummyWindowClass = null;
private static Object dummyWindowSync = new Object();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
index 103995a8d..c771cd67a 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -95,7 +95,7 @@ public class X11Util implements ToolkitProperties {
private static String nullDisplayName = null;
private static volatile boolean isInit = false;
private static boolean markAllDisplaysUnclosable = false; // ATI/AMD X11 driver issues
- private static boolean requiresGlobalToolkitLock = false; // ATI/AMD X11 driver issues
+ private static boolean hasThreadingIssues = false; // ATI/AMD X11 driver issues
private static Object setX11ErrorHandlerLock = new Object();
private static final String X11_EXTENSION_ATIFGLRXDRI = "ATIFGLRXDRI";
@@ -137,7 +137,7 @@ public class X11Util implements ToolkitProperties {
hasX11_EXTENSION_ATIFGLRXDRI = false;
hasX11_EXTENSION_ATIFGLEXTENSION = false;
}
- requiresGlobalToolkitLock = ATI_HAS_MULTITHREADING_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
+ hasThreadingIssues = ATI_HAS_MULTITHREADING_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
markAllDisplaysUnclosable = ATI_HAS_XCLOSEDISPLAY_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION );
if(DEBUG) {
@@ -147,7 +147,7 @@ public class X11Util implements ToolkitProperties {
",\n\t X11_EXTENSION_ATIFGLRXDRI " + hasX11_EXTENSION_ATIFGLRXDRI+
",\n\t X11_EXTENSION_ATIFGLEXTENSION " + hasX11_EXTENSION_ATIFGLEXTENSION+
",\n\t requiresToolkitLock "+requiresToolkitLock()+
- ",\n\t requiresGlobalToolkitLock "+requiresGlobalToolkitLock()+
+ ",\n\t hasThreadingIssues "+hasThreadingIssues()+
",\n\t markAllDisplaysUnclosable "+getMarkAllDisplaysUnclosable()
);
// Thread.dumpStack();
@@ -228,8 +228,8 @@ public class X11Util implements ToolkitProperties {
* Called by {@link NativeWindowFactory#initSingleton()}
* @see ToolkitProperties
*/
- public static final boolean requiresGlobalToolkitLock() {
- return requiresGlobalToolkitLock; // JAWT locking: yes, instead of native X11 locking w use a global lock.
+ public static final boolean hasThreadingIssues() {
+ return hasThreadingIssues; // JOGL impl. may utilize special locking "somewhere"
}
public static void setX11ErrorHandler(boolean onoff, boolean quiet) {