aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java6
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java8
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java11
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java4
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java5
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java9
8 files changed, 26 insertions, 21 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 3437358de..3815189ef 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -278,7 +278,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
@Override
- public final int lockSurface() throws NativeWindowException {
+ public final int lockSurface() throws NativeWindowException, RuntimeException {
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
@@ -322,7 +322,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
if (surfaceLock.getHoldCount() == 1) {
final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
try {
- unlockSurfaceImpl();
+ if(null != jawt) {
+ unlockSurfaceImpl();
+ }
} finally {
adevice.unlock();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index c58b34b18..cec7d4ec3 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -83,10 +83,11 @@ public interface NativeSurface extends SurfaceUpdatedListener {
* @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
*
* @throws RuntimeException after timeout when waiting for the surface lock
+ * @throws NativeWindowException if native locking failed, maybe platform related
*
* @see com.jogamp.common.util.locks.RecursiveLock
*/
- public int lockSurface();
+ public int lockSurface() throws NativeWindowException, RuntimeException;
/**
* Unlock the surface of this native window
@@ -96,12 +97,13 @@ public interface NativeSurface extends SurfaceUpdatedListener {
* The implementation shall also invoke {@link AbstractGraphicsDevice#unlock()}
* for the final unlock (recursive count zero).<P>
*
- * @throws RuntimeException if surface is not locked
+ * The implementation shall be fail safe, i.e. tolerant in case the native resources
+ * are already released / unlocked. In this case the implementation shall simply ignore the call.
*
* @see #lockSurface
* @see com.jogamp.common.util.locks.RecursiveLock
*/
- public void unlockSurface() throws NativeWindowException ;
+ public void unlockSurface();
/**
* Query if surface is locked by another thread, i.e. not the current one.
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index c8cd78d82..1dabc3dcd 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -123,7 +123,7 @@ public abstract class ProxySurface implements NativeSurface {
}
@Override
- public int lockSurface() throws NativeWindowException {
+ public int lockSurface() throws NativeWindowException, RuntimeException {
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
index 4da48bdae..c24f64b32 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
@@ -74,13 +74,12 @@ public class GDISurface extends ProxySurface {
@Override
final protected void unlockSurfaceImpl() {
- if (0 == surfaceHandle) {
- throw new InternalError("surface not acquired: "+this+", thread: "+Thread.currentThread().getName());
- }
- if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) {
- throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName());
+ if (0 != surfaceHandle) {
+ if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) {
+ throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName());
+ }
+ surfaceHandle=0;
}
- surfaceHandle=0;
}
@Override
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index b94bc0f27..bff1efcb5 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -995,12 +995,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
//
@Override
- public final int lockSurface() {
+ public final int lockSurface() throws NativeWindowException, RuntimeException {
return window.lockSurface();
}
@Override
- public final void unlockSurface() throws NativeWindowException {
+ public final void unlockSurface() {
window.unlockSurface();
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 34f248121..45745e89c 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -563,7 +563,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
//
@Override
- public final int lockSurface() {
+ public final int lockSurface() throws NativeWindowException, RuntimeException {
windowLock.lock();
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
index b45c60e69..942994c13 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
@@ -104,7 +104,10 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
@Override
protected void unlockSurfaceImpl() {
if(!isOffscreenInstance) {
- unlockSurface0(getWindowHandle());
+ final long h = getWindowHandle();
+ if(0 != h) {
+ unlockSurface0(h);
+ }
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
index a30aa133c..5e636d982 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
@@ -87,12 +87,11 @@ public class WindowsWindow extends WindowImpl {
@Override
protected void unlockSurfaceImpl() {
- if (0 == hdc) {
- throw new InternalError("surface not acquired");
+ if (0 != hdc) {
+ GDI.ReleaseDC(getWindowHandle(), hdc);
+ hdc_old = hdc;
+ hdc=0;
}
- GDI.ReleaseDC(getWindowHandle(), hdc);
- hdc_old = hdc;
- hdc=0;
}
@Override