diff options
author | Sven Gothel <[email protected]> | 2012-01-19 05:52:21 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-01-19 05:52:21 +0100 |
commit | 8a2c18cf210ee6465e00f88cecd3ef109421ff1d (patch) | |
tree | 02e8aa842d4c7f49a8c4041f83ff05c9846a0141 /src/nativewindow/classes/jogamp | |
parent | 249351d96e22999db2ac83ad60eaa5c5c6120bd7 (diff) |
NativeWindow/OSX: Fix Offscreen CALayer SIGSEGV @ Shutdown (Cleanup referencing)
- allocate CALayer w/ invoking init:
[[CALayer alloc] init]
- attach CALayer to JAWTSurfaceLayer w/o autorelease:
surfaceLayers.layer = layer; // already incr. retain count
- destroy CALayer @ JAWTWindow destroy
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java | 14 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 25 |
2 files changed, 20 insertions, 19 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java index be697b3e0..aa09fc798 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java @@ -70,6 +70,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected Component component; private AWTGraphicsConfiguration config; // control access due to delegation private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); // lifetime: valid after lock but may change with each 1st lock, purges after invalidate private boolean isApplet; @@ -230,8 +231,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // NativeSurface // - private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); - private void determineIfApplet() { Component c = component; while(!isApplet && null != c) { @@ -252,6 +251,17 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract JAWT fetchJAWTImpl() throws NativeWindowException; protected abstract int lockSurfaceImpl() throws NativeWindowException; + protected void dumpJAWTInfo() { + if(null != jawt) { + System.err.println("JAWT version: 0x"+Integer.toHexString(jawt.getCachedVersion())+ + ", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(jawt)+ + ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets); + } else { + System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets); + } + // Thread.dumpStack(); + } + public final int lockSurface() throws NativeWindowException { surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index ab2986fbe..0435d4116 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -71,6 +71,10 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { protected void invalidateNative() { surfaceHandle=0; if(isOffscreenLayerSurfaceEnabled()) { + if(0 != rootSurfaceLayerHandle) { + OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); + rootSurfaceLayerHandle = 0; + } if(0 != drawable) { OSXUtil.DestroyNSWindow(drawable); drawable = 0; @@ -208,7 +212,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { unlockSurfaceImpl(); throw new NativeWindowException("Could not create root CALayer: "+this); } - if(!AttachJAWTSurfaceLayer(dsi, rootSurfaceLayerHandle)) { + if(!AttachJAWTSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; OSXUtil.DestroyNSWindow(drawable); @@ -239,14 +243,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { private void dumpInfo() { System.err.println("MaxOSXJAWTWindow: 0x"+Integer.toHexString(this.hashCode())+" - thread: "+Thread.currentThread().getName()); - if(null != getJAWT()) { - System.err.println("JAWT version: 0x"+Integer.toHexString(getJAWT().getCachedVersion())+ - ", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(getJAWT())+ - ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets); - } else { - System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets); - } - // Thread.dumpStack(); + dumpJAWTInfo(); } /** @@ -268,14 +265,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } - private static boolean AttachJAWTSurfaceLayer(JAWT_DrawingSurfaceInfo dsi, long caLayer) { - if(0==caLayer) { - throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); - } - return AttachJAWTSurfaceLayer0(dsi.getBuffer(), caLayer); - } - private static native boolean AttachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + // private static native boolean DetachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; @@ -284,7 +275,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; - private long rootSurfaceLayerHandle = 0; // is autoreleased, once it is attached to the JAWT_SurfaceLayer + private long rootSurfaceLayerHandle = 0; // attached to the JAWT_SurfaceLayer private long surfaceHandle = 0; private int sscWidth, sscHeight; |