diff options
author | Sven Gothel <[email protected]> | 2012-06-30 05:14:34 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-06-30 05:14:34 +0200 |
commit | 9a7c8896fe38ebcd42ed5238b09a7a36d46db9dc (patch) | |
tree | d3ffa573aaa3a6d9e3f4232a960e17581b5e19ee /src/nativewindow/classes | |
parent | c50fca1b5df9ec3b76fada4dd5dd307bdece531a (diff) |
Fix Bug #589 (JAWT Offscreen-Layer resize) and Offscreen-Layer setSwapInterval() deadlock; Reuse JAWT instance; Cleanup
- Fixes
- OSXUtil.CreateCALayer*(..): Pass layer target size (if known).
This fixes Bug #589
- MacOSXWindowSystemInterface-pbuffer.m:
- ALL: displayLink NULL check
- setSwapInterval(..): lock only for variable setting,
could deadlock when start/stop CVDisplayLink
- JAWTWindow.destroy(): use 'surfaceLock' instead of 'synchronized'
- Cleanup / Performance
- JAWTWindow.lockSurface(): Reuse JAWT instance
- MacOSXJAWTWindow: AttachJAWTSurfaceLayer0(..) -> SetJAWTRootSurfaceLayer0(..)
Reflects semantic better.
- DEBUG
- JAWTWindow.updateBounds(..) notify of bounds change
Diffstat (limited to 'src/nativewindow/classes')
3 files changed, 28 insertions, 14 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 3815189ef..cffe495f7 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -135,6 +135,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract void invalidateNative(); protected final void updateBounds(JAWT_Rectangle jawtBounds) { + if(DEBUG) { + final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); + if(!bounds.equals(jb)) { + System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); + Thread.dumpStack(); + } + } bounds.setX(jawtBounds.getX()); bounds.setY(jawtBounds.getY()); bounds.setWidth(jawtBounds.getWidth()); @@ -186,7 +193,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } try { if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle)); + System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); } finally { @@ -288,8 +295,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); adevice.lock(); try { - jawt = fetchJAWTImpl(); - isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt); + if(null == jawt) { // no need to re-fetch for each frame + jawt = fetchJAWTImpl(); + isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt); + } res = lockSurfaceImpl(); if(LOCK_SUCCESS == res && drawable_old != drawable) { res = LOCK_SURFACE_CHANGED; @@ -386,9 +395,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // @Override - public synchronized void destroy() { - invalidate(); - component = null; // don't dispose the AWT component, since we are merely an immutable uplink + public void destroy() { + surfaceLock.lock(); + try { + invalidate(); + component = null; // don't dispose the AWT component, since we are merely an immutable uplink + } finally { + surfaceLock.unlock(); + } } @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 0ca5cd297..42fd08df1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -207,20 +207,20 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); } if(0 == rootSurfaceLayerHandle) { - rootSurfaceLayerHandle = OSXUtil.CreateCALayer(); + rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayerHandle) { OSXUtil.DestroyNSWindow(drawable); drawable = 0; unlockSurfaceImpl(); throw new NativeWindowException("Could not create root CALayer: "+this); } - if(!AttachJAWTSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { + if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; OSXUtil.DestroyNSWindow(drawable); drawable = 0; unlockSurfaceImpl(); - throw new NativeWindowException("Could not attach JAWT surfaceLayerHandle: "+this); + throw new NativeWindowException("Could not set JAWT rootSurfaceLayerHandle: "+this); } } ret = NativeWindow.LOCK_SUCCESS; @@ -267,8 +267,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } - private static native boolean AttachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); - // private static native boolean DetachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + private static native boolean SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + // private static native boolean UnsetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 3ca76a84a..94f949ea3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -77,8 +77,8 @@ public class OSXUtil { DestroyNSWindow0(nsWindow); } - public static long CreateCALayer() { - return CreateCALayer0(); + public static long CreateCALayer(int x, int y, int width, int height) { + return CreateCALayer0(x, y, width, height); } public static void AddCASublayer(long rootCALayer, long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -117,7 +117,7 @@ public class OSXUtil { private static native void DestroyNSView0(long nsView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); - private static native long CreateCALayer0(); + private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); |