aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-22 14:21:29 +0100
committerSven Gothel <[email protected]>2011-02-22 14:21:29 +0100
commite587f2a724c79d50118f717cc29fba78cad0feeb (patch)
tree06e2a661139f477a387c4d2835d9359fa7f0399f /src
parent1411387d54bc5d946bd3528f97c9a2a15dd2f9de (diff)
NativeWindow NativeSurface lock/unlock Surface cleanup ; NEWT WindowImpl lock/unlock Surface fix
- Rename lock to surfaceLock to determine it's use - NEWT's WindowImpl windowLock usage is not sufficient for lock/unlock surface. Using distinguished surfaceLock for proper recursion count on lock/unlock surface.
Diffstat (limited to 'src')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java35
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java20
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java8
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java43
4 files changed, 57 insertions, 49 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index 386ba32f4..038580ce0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -31,7 +31,7 @@ package javax.media.nativewindow;
import com.jogamp.common.util.locks.RecursiveLock;
public abstract class ProxySurface implements NativeSurface {
- protected RecursiveLock recurLock = new RecursiveLock();
+ protected RecursiveLock surfaceLock = new RecursiveLock();
protected AbstractGraphicsConfiguration config;
protected long displayHandle;
protected int height;
@@ -44,14 +44,9 @@ public abstract class ProxySurface implements NativeSurface {
displayHandle=cfg.getScreen().getDevice().getHandle();
}
- public final void invalidate() {
- recurLock.lock();
- try {
- displayHandle = 0;
- invalidateImpl();
- } finally {
- recurLock.unlock();
- }
+ void invalidate() {
+ displayHandle = 0;
+ invalidateImpl();
}
protected abstract void invalidateImpl();
@@ -90,8 +85,8 @@ public abstract class ProxySurface implements NativeSurface {
}
public int lockSurface() throws NativeWindowException {
- recurLock.lock();
- int res = recurLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
+ surfaceLock.lock();
+ int res = surfaceLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
if ( LOCK_SURFACE_NOT_READY == res ) {
try {
@@ -106,7 +101,7 @@ public abstract class ProxySurface implements NativeSurface {
}
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
- recurLock.unlock();
+ surfaceLock.unlock();
}
}
}
@@ -114,9 +109,9 @@ public abstract class ProxySurface implements NativeSurface {
}
public final void unlockSurface() {
- recurLock.validateLocked();
+ surfaceLock.validateLocked();
- if (recurLock.getRecursionCount() == 0) {
+ if (surfaceLock.getRecursionCount() == 0) {
final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
try {
unlockSurfaceImpl();
@@ -124,7 +119,7 @@ public abstract class ProxySurface implements NativeSurface {
adevice.unlock();
}
}
- recurLock.unlock();
+ surfaceLock.unlock();
}
protected abstract int lockSurfaceImpl();
@@ -132,23 +127,23 @@ public abstract class ProxySurface implements NativeSurface {
protected abstract void unlockSurfaceImpl() ;
public final void validateSurfaceLocked() {
- recurLock.validateLocked();
+ surfaceLock.validateLocked();
}
public final boolean isSurfaceLocked() {
- return recurLock.isLocked();
+ return surfaceLock.isLocked();
}
public final boolean isSurfaceLockedByOtherThread() {
- return recurLock.isLockedByOtherThread();
+ return surfaceLock.isLockedByOtherThread();
}
public final Thread getSurfaceLockOwner() {
- return recurLock.getOwner();
+ return surfaceLock.getOwner();
}
public final int getSurfaceRecursionCount() {
- return recurLock.getRecursionCount();
+ return surfaceLock.getRecursionCount();
}
public abstract String toString();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index 0f7f1ee62..781882f08 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -107,13 +107,13 @@ public abstract class JAWTWindow implements NativeWindow {
// NativeSurface
//
- private RecursiveLock recurLock = new RecursiveLock();
+ private RecursiveLock surfaceLock = new RecursiveLock();
protected abstract int lockSurfaceImpl() throws NativeWindowException;
public final int lockSurface() throws NativeWindowException {
- recurLock.lock();
- int res = recurLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
+ surfaceLock.lock();
+ int res = surfaceLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
if ( LOCK_SURFACE_NOT_READY == res ) {
try {
@@ -128,7 +128,7 @@ public abstract class JAWTWindow implements NativeWindow {
}
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
- recurLock.unlock();
+ surfaceLock.unlock();
}
}
}
@@ -138,9 +138,9 @@ public abstract class JAWTWindow implements NativeWindow {
protected abstract void unlockSurfaceImpl() throws NativeWindowException;
public final void unlockSurface() {
- recurLock.validateLocked();
+ surfaceLock.validateLocked();
- if (recurLock.getRecursionCount() == 0) {
+ if (surfaceLock.getRecursionCount() == 0) {
final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
try {
unlockSurfaceImpl();
@@ -148,19 +148,19 @@ public abstract class JAWTWindow implements NativeWindow {
adevice.unlock();
}
}
- recurLock.unlock();
+ surfaceLock.unlock();
}
public final boolean isSurfaceLockedByOtherThread() {
- return recurLock.isLockedByOtherThread();
+ return surfaceLock.isLockedByOtherThread();
}
public final boolean isSurfaceLocked() {
- return recurLock.isLocked();
+ return surfaceLock.isLocked();
}
public final Thread getSurfaceLockOwner() {
- return recurLock.getOwner();
+ return surfaceLock.getOwner();
}
public final boolean surfaceSwap() {
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index f3fab7bce..fee188768 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -76,14 +76,14 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
((WindowImpl)this.window).setHandleDestroyNotify(false);
window.addWindowListener(new WindowAdapter() {
public void windowRepaint(WindowUpdateEvent e) {
- if( !GLWindow.this.window.isSurfaceLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
+ if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
display();
}
}
public void windowResized(WindowEvent e) {
sendReshape = true;
- if( !GLWindow.this.window.isSurfaceLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
+ if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
display();
}
}
@@ -99,8 +99,8 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
if(isPaused) {
ctrl.resume();
}
- } else if (GLWindow.this.window.isSurfaceLockedByOtherThread()) {
- // Surface is locked by another thread
+ } else if (GLWindow.this.window.isWindowLockedByOtherThread()) {
+ // Window is locked by another thread
// Flag that destroy should be performed on the next
// attempt to display.
sendDestroy = true;
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index b0991b748..815fd705e 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -73,7 +73,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
{
public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true);
- private RecursiveLock windowLock = new RecursiveLock();
+ private RecursiveLock windowLock = new RecursiveLock(); // Window instance wide lock
+ private RecursiveLock surfaceLock = new RecursiveLock(); // Surface only lock
private long windowHandle;
private ScreenImpl screen;
private boolean screenReferenceAdded = false;
@@ -464,7 +465,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
public final int lockSurface() {
windowLock.lock();
- int res = windowLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
+ surfaceLock.lock();
+ int res = surfaceLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS;
if ( LOCK_SURFACE_NOT_READY == res ) {
try {
@@ -481,6 +483,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
+ surfaceLock.unlock();
windowLock.unlock();
}
}
@@ -489,9 +492,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public final void unlockSurface() {
+ surfaceLock.validateLocked();
windowLock.validateLocked();
- if (windowLock.getRecursionCount() == 0) {
+ if (surfaceLock.getRecursionCount() == 0) {
final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
try {
unlockSurfaceImpl();
@@ -499,21 +503,34 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
adevice.unlock();
}
}
+ surfaceLock.unlock();
windowLock.unlock();
}
- public final boolean isSurfaceLockedByOtherThread() {
+ public final boolean isWindowLockedByOtherThread() {
return windowLock.isLockedByOtherThread();
}
- public final boolean isSurfaceLocked() {
+ public final boolean isWindowLocked() {
return windowLock.isLocked();
}
- public final Thread getSurfaceLockOwner() {
+ public final Thread getWindowLockOwner() {
return windowLock.getOwner();
}
+ public final boolean isSurfaceLockedByOtherThread() {
+ return surfaceLock.isLockedByOtherThread();
+ }
+
+ public final boolean isSurfaceLocked() {
+ return surfaceLock.isLocked();
+ }
+
+ public final Thread getSurfaceLockOwner() {
+ return surfaceLock.getOwner();
+ }
+
public long getSurfaceHandle() {
return windowHandle; // default: return window handle
}
@@ -1372,7 +1389,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
"\n, ParentWindow "+parentWindow+
"\n, ParentWindowHandle "+toHexString(parentWindowHandle)+
"\n, WindowHandle "+toHexString(getWindowHandle())+
- "\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt "+isSurfaceLockedByOtherThread()+")"+
+ "\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+isWindowLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+
"\n, Pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
"\n, Visible "+isVisible()+
"\n, Undecorated "+undecorated+
@@ -1650,8 +1667,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
switch(e.getEventType()) {
// special repaint treatment
case WindowEvent.EVENT_WINDOW_REPAINT:
- // queue repaint event in case surface is locked, ie in operation
- if( isSurfaceLocked() ) {
+ // queue repaint event in case window is locked, ie in operation
+ if( isWindowLocked() ) {
// make sure only one repaint event is queued
if(!repaintQueued) {
repaintQueued=true;
@@ -1669,8 +1686,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// common treatment
case WindowEvent.EVENT_WINDOW_RESIZED:
- // queue event in case surface is locked, ie in operation
- if( isSurfaceLocked() ) {
+ // queue event in case window is locked, ie in operation
+ if( isWindowLocked() ) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.consumeEvent: queued "+e);
// Exception ee = new Exception("Window.windowRepaint: "+e);
@@ -2165,10 +2182,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
- protected int getWindowLockRecursionCount() {
- return windowLock.getRecursionCount();
- }
-
//
// Reflection helper ..
//