diff options
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 39 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/windows/WindowsWindow.java | 14 |
2 files changed, 30 insertions, 23 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 79679b7b3..b0991b748 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -463,36 +463,41 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // public final int lockSurface() { - int res = LOCK_SURFACE_NOT_READY; windowLock.lock(); + int res = windowLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; - if(isNativeValid()) { - AbstractGraphicsDevice adevice = screen.getDisplay().getGraphicsDevice(); - adevice.lock(); + if ( LOCK_SURFACE_NOT_READY == res ) { try { - res = lockSurfaceImpl(); + if( isNativeValid() ) { + final AbstractGraphicsDevice adevice = config.getScreen().getDevice(); + adevice.lock(); + try { + res = lockSurfaceImpl(); + } finally { + if (LOCK_SURFACE_NOT_READY >= res) { + adevice.unlock(); + } + } + } } finally { - if( LOCK_SURFACE_NOT_READY == res ) { - adevice.unlock(); + if (LOCK_SURFACE_NOT_READY >= res) { + windowLock.unlock(); } } } - if( LOCK_SURFACE_NOT_READY == res ) { - windowLock.unlock(); - } - return res; } public final void unlockSurface() { - // may throw RuntimeException if not locked windowLock.validateLocked(); - AbstractGraphicsDevice adevice = screen.getDisplay().getGraphicsDevice(); - try { - unlockSurfaceImpl(); - } finally { - adevice.unlock(); + if (windowLock.getRecursionCount() == 0) { + final AbstractGraphicsDevice adevice = config.getScreen().getDevice(); + try { + unlockSurfaceImpl(); + } finally { + adevice.unlock(); + } } windowLock.unlock(); } diff --git a/src/newt/classes/jogamp/newt/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/windows/WindowsWindow.java index d820be529..05d169c5e 100644 --- a/src/newt/classes/jogamp/newt/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/windows/WindowsWindow.java @@ -56,18 +56,20 @@ public class WindowsWindow extends WindowImpl { } protected int lockSurfaceImpl() { - if( 0 != getWindowHandle() && 0 == hdc ) { - hdc = GDI.GetDC(getWindowHandle()); - hmon = MonitorFromWindow0(getWindowHandle()); + if (0 != hdc) { + throw new InternalError("surface not released"); } + hdc = GDI.GetDC(getWindowHandle()); + hmon = MonitorFromWindow0(getWindowHandle()); return ( 0 != hdc ) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; } protected void unlockSurfaceImpl() { - if ( 0 != hdc && 0 != getWindowHandle() && getWindowLockRecursionCount() == 0) { - GDI.ReleaseDC(getWindowHandle(), hdc); - hdc=0; + if (0 == hdc) { + throw new InternalError("surface not acquired"); } + GDI.ReleaseDC(getWindowHandle(), hdc); + hdc=0; } public final long getSurfaceHandle() { |