aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java56
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java82
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java8
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java15
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java23
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java4
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java1
7 files changed, 109 insertions, 80 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
index 32e786a2b..a5ccec377 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
@@ -72,36 +72,38 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable {
public void swapBuffers() throws GLException {
boolean didLock = false;
- if (getNativeWindow().getSurfaceHandle() == 0) {
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
- }
+ try {
+ if (getNativeWindow().getSurfaceHandle() == 0) {
+ if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
+ return;
+ }
+ didLock = true;
+ }
- long startTime = 0;
- if (PROFILING) {
- startTime = System.currentTimeMillis();
- }
+ long startTime = 0;
+ if (PROFILING) {
+ startTime = System.currentTimeMillis();
+ }
- if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
- throw new GLException("Error swapping buffers");
- }
-
- if (PROFILING) {
- long endTime = System.currentTimeMillis();
- profilingSwapBuffersTime += (endTime - startTime);
- int ticks = PROFILING_TICKS;
- if (++profilingSwapBuffersTicks == ticks) {
- System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
- ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
- profilingSwapBuffersTime = 0;
- profilingSwapBuffersTicks = 0;
- }
- }
+ if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
+ throw new GLException("Error swapping buffers");
+ }
- if (didLock) {
- unlockSurface();
+ if (PROFILING) {
+ long endTime = System.currentTimeMillis();
+ profilingSwapBuffersTime += (endTime - startTime);
+ int ticks = PROFILING_TICKS;
+ if (++profilingSwapBuffersTicks == ticks) {
+ System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
+ ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
+ profilingSwapBuffersTime = 0;
+ profilingSwapBuffersTicks = 0;
+ }
+ }
+ } finally {
+ if (didLock) {
+ unlockSurface();
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index bb284d60f..661fa9fcb 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -212,13 +212,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
int[] size = new int[1];
lockToolkit();
- long display = X11Util.getDisplayConnection();
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
- unlockToolkit();
- if (!res)
- return 0;
+ try {
+ long display = X11Util.getDisplayConnection();
+ boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+ X11Lib.DefaultScreen(display),
+ size, 0);
+ if (!res) {
+ return 0;
+ }
+ } finally {
+ unlockToolkit();
+ }
gotGammaRampLength = true;
gammaRampLength = size[0];
return gammaRampLength;
@@ -232,15 +236,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
lockToolkit();
- long display = X11Util.getDisplayConnection();
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- unlockToolkit();
- return res;
+ try {
+ long display = X11Util.getDisplayConnection();
+ boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ rampData.length,
+ rampData, 0,
+ rampData, 0,
+ rampData, 0);
+ return res;
+ } finally {
+ unlockToolkit();
+ }
}
protected Buffer getGammaRamp() {
@@ -256,16 +263,20 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
lockToolkit();
- long display = X11Util.getDisplayConnection();
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- unlockToolkit();
- if (!res)
- return null;
+ try {
+ long display = X11Util.getDisplayConnection();
+ boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ if (!res) {
+ return null;
+ }
+ } finally {
+ unlockToolkit();
+ }
return rampData;
}
@@ -288,13 +299,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
lockToolkit();
- long display = X11Util.getDisplayConnection();
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- unlockToolkit();
+ try {
+ long display = X11Util.getDisplayConnection();
+ X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ } finally {
+ unlockToolkit();
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
index 6a42a53c4..b8f6cc7ef 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
@@ -62,19 +62,21 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
public void swapBuffers() throws GLException {
- getFactoryImpl().lockToolkit();
+ boolean didLock = false;
try {
if (component.getSurfaceHandle() == 0) {
if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
return;
}
+ didLock=true;
}
GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle());
} finally {
- unlockSurface();
- getFactoryImpl().unlockToolkit();
+ if(didLock) {
+ unlockSurface();
+ }
}
}
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
index 78a384e1f..fe49db0bc 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
@@ -51,20 +51,18 @@ public class JAWTUtil {
private static boolean headlessMode;
static {
- lockedToolkit = false;
lockedStack = null;
headlessMode = GraphicsEnvironment.isHeadless();
}
- private static boolean lockedToolkit;
private static Exception lockedStack;
public static synchronized void lockToolkit() throws NativeWindowException {
- if (lockedToolkit) {
+ if (null!=lockedStack) {
+ lockedStack.printStackTrace();
throw new NativeWindowException("Toolkit already locked");
}
- lockedToolkit = true;
- lockedStack = new Exception("JAWT - locked");
+ lockedStack = new Exception("JAWT - already locked by: ");
if (headlessMode) {
// Workaround for running (to some degree) in headless
@@ -77,7 +75,8 @@ public class JAWTUtil {
}
public static synchronized void unlockToolkit() {
- if (lockedToolkit) {
+ if (null!=lockedStack) {
+ lockedStack = null;
if (headlessMode) {
// Workaround for running (to some degree) in headless
// environments but still supporting rendering via pbuffers
@@ -86,13 +85,11 @@ public class JAWTUtil {
}
JAWT.getJAWT().Unlock();
- lockedToolkit = false;
- lockedStack = null;
}
}
public static boolean isToolkitLocked() {
- return lockedToolkit;
+ return null!=lockedStack;
}
public static Exception getLockedStack() {
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
index aa171f498..83e8e2266 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
@@ -44,7 +44,7 @@ import javax.media.nativewindow.*;
import com.sun.nativewindow.impl.*;
public abstract class JAWTWindow implements NativeWindow {
- protected static final boolean DEBUG = Debug.debug("NativeWindow");
+ protected static final boolean DEBUG = Debug.debug("JAWT");
// See whether we're running in headless mode
private static boolean headlessMode;
@@ -83,28 +83,39 @@ public abstract class JAWTWindow implements NativeWindow {
drawable= 0;
}
+ private Exception lockedStack = null;
+
public synchronized int lockSurface() throws NativeWindowException {
if(DEBUG) {
+ // Not that this is a hard criteria ..
+ // but it is not recommended locking both, JAWT and the surface
if(JAWTUtil.isToolkitLocked()) {
JAWTUtil.getLockedStack().printStackTrace();
throw new NativeWindowException("JAWT already locked - "+this);
}
}
- if (locked) {
+ if (null!=lockedStack) {
+ lockedStack.printStackTrace();
throw new NativeWindowException("Surface already locked - "+this);
}
- locked = true;
+ lockedStack = new Exception("JAWTWindow previous locked by:");
return LOCK_SUCCESS;
}
public synchronized void unlockSurface() {
- if (locked) {
- locked = false;
+ if (null!=lockedStack) {
+ lockedStack = null;
+ } else {
+ throw new RuntimeException("JAWTWindow not locked");
}
}
public synchronized boolean isSurfaceLocked() {
- return locked;
+ return null!=lockedStack;
+ }
+
+ public Exception getLockedStack() {
+ return lockedStack;
}
public long getDisplayHandle() {
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
index 1d6e8eea2..f53a048bf 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
@@ -115,7 +115,9 @@ public class X11JAWTWindow extends JAWTWindow {
}
public synchronized void unlockSurface() {
- if(!isSurfaceLocked()) return;
+ if(!isSurfaceLocked()) {
+ throw new RuntimeException("JAWTWindow not locked");
+ }
ds.FreeDrawingSurfaceInfo(dsi);
ds.Unlock();
JAWT.getJAWT().FreeDrawingSurface(ds);
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java
index 4102715ce..53b82ce08 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java
@@ -77,6 +77,7 @@ public class X11AWTNativeWindowFactory extends X11NativeWindowFactory {
}
owner = null;
JAWTUtil.unlockToolkit();
+ notifyAll();
}
};