aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-02 07:28:00 +0200
committerSven Gothel <[email protected]>2012-10-02 07:28:00 +0200
commit7c333e3e2574879465719ed968112b27255368d4 (patch)
treef9c81117469fe10d23c106bb46151a3451169e3f /src/nativewindow/classes/javax
parent0790108ca9c2a6a6d494e5017589fe083c518e23 (diff)
Relax Bug 613 workaround of commit 92398025abdabb2fdef0d78edd41e730991a6f94
Utilizing a GlobalToolkitLock in general to lock the display connection results in deadlock situations where locked surfaces signal other [offscreen] surfaces to render. We have to see whether we find a better solution, for now sporadic XCB assertion still happen. But it is preferrable to point to the root cause, then to jumping through hoops to complicate locking or even to deadlock. Locking: - X11GLXGraphicsConfigurationFactory add missing device locking in: - getAvailableCapabilities - chooseGraphicsConfigurationStatic - Newt/X11Window: Discard display events after window close. Relax ATI XCB/threading bug workaround: - ToolkitProperties: requiresGlobalToolkitLock() -> hasThreadingIssues() - NativeWindowFactory: Don't use GlobalToolkitLock in case of 'threadingIssues' the impact is too severe (see above) - NativeWindowFactory: Add getGlobalToolkitLockIfRequired(): To be used for small code blocks. If having 'threadingIssues' a GlobalToolkitLock is returned, otherwise NullToolkitLock. - X11GLXContext: [create/destroy]ContextARBImpl: Use 'NativeWindowFactory.getGlobalToolkitLockIfRequired()' for extra locking Misc Cleanup: - *DrawableFactory createMutableSurface: Also create new device if type is not suitable - *DrawableFactory createDummySurfaceImpl: Pass chosenCaps and use it (preserves orig. requested user caps)
Diffstat (limited to 'src/nativewindow/classes/javax')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java40
1 files changed, 14 insertions, 26 deletions
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();