aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-22 07:40:23 +0100
committerSven Gothel <[email protected]>2011-02-22 07:40:23 +0100
commitbb3d3743b4800d006457c767a00436b9308da75d (patch)
treefd687329fbcb7a53eab9aa1d9735f9eac7c6d22e /src/newt
parentbff7e97c2f22673bb0457765696fb867d3e4f69d (diff)
NativeWindow ProxySurface Abstraction and lock/unlock Surface cleanup
- ProxySurface -> abstract javax.media.nativewindow.ProxySurface, implemented by jogamp.nativewindow.WrappedSurface, just wrapping surface handle jogamp.nativewindow.windows.GDISurface, using HWND and get/release HDC on lock/unlock - Unifying NativeSurface's lockSurface/unlockSurface implementations - NEWT's WindowImpl - NativeWindow's ProxySurface, WrappedWindow, GDIWindow and JAWTWindow - wingdi/GDI: Add 'WindowFromDC' and 'GetClientRect' to GDI
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java39
-rw-r--r--src/newt/classes/jogamp/newt/windows/WindowsWindow.java14
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() {