diff options
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 60 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java | 25 |
2 files changed, 42 insertions, 43 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 758105713..d11d24664 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -74,13 +74,16 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { System.err.println("MacOSXJAWTWindow.invalidateNative(): osh-enabled "+isOffscreenLayerSurfaceEnabled()+ ", osh-set "+offscreenSurfaceHandleSet+ ", osh "+toHexString(offscreenSurfaceHandle)+ - ", rsh "+toHexString(rootSurfaceLayerHandle)+ - ", wh "+toHexString(windowHandle)); + ", rsh "+toHexString(rootSurfaceLayer)+ + ", wh "+toHexString(windowHandle)+" - "+Thread.currentThread().getName()); } offscreenSurfaceHandle=0; offscreenSurfaceHandleSet=false; if( isOffscreenLayerSurfaceEnabled() ) { - if(0 != rootSurfaceLayerHandle) { + if(0 != windowHandle) { + OSXUtil.DestroyNSWindow(windowHandle); + } + if(0 != rootSurfaceLayer) { final JAWT jawt = getJAWT(); if( null != jawt ) { final JAWT_DrawingSurface ds = jawt.GetDrawingSurface(component); @@ -90,9 +93,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { try { dsi = ds.GetDrawingSurfaceInfo(); try { - UnsetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle); + UnsetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayer); } catch (Exception e) { - System.err.println("Error clearing JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle)); + System.err.println("Error clearing JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayer)); e.printStackTrace(); } } finally { @@ -105,19 +108,15 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { jawt.FreeDrawingSurface(ds); } } - OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); - - rootSurfaceLayerHandle = 0; - } - if(0 != windowHandle) { - OSXUtil.DestroyNSWindow(windowHandle); + OSXUtil.DestroyCALayer(rootSurfaceLayer); + rootSurfaceLayer = 0; } } windowHandle=0; } - + protected void attachSurfaceLayerImpl(final long layerHandle) { - OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle, getWidth(), getHeight()); + OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, getWidth(), getHeight()); } protected void layoutSurfaceLayerImpl() { @@ -127,11 +126,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(DEBUG) { System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h); } - OSXUtil.FixCALayerLayout(rootSurfaceLayerHandle, osl, w, h); + OSXUtil.FixCALayerLayout(rootSurfaceLayer, osl, w, h); } protected void detachSurfaceLayerImpl(final long layerHandle) { - OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle); + OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle); } @Override @@ -243,23 +242,23 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } } if(null == errMsg) { - if(0 == rootSurfaceLayerHandle) { - rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); - if(0 == rootSurfaceLayerHandle) { + if(0 == rootSurfaceLayer) { + rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); + if(0 == rootSurfaceLayer) { errMsg = "Could not create root CALayer"; } else { try { - SetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle); + SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayer); } catch(Exception e) { - errMsg = "Could not set JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle)+", cause: "+e.getMessage(); + errMsg = "Could not set JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayer)+", cause: "+e.getMessage(); } } } } if(null != errMsg) { - if(0 != rootSurfaceLayerHandle) { - OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); - rootSurfaceLayerHandle = 0; + if(0 != rootSurfaceLayer) { + OSXUtil.DestroyCALayer(rootSurfaceLayer); + rootSurfaceLayer = 0; } if(0 != windowHandle) { OSXUtil.DestroyNSWindow(windowHandle); @@ -316,18 +315,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { /** * Set the given root CALayer in the JAWT surface */ - private static void SetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { - SetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer); - } - + private static native void SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + /** - * Unset the given root CALayer in the JAWT surface + * Unset the given root CALayer in the JAWT surface, passing the NIO DrawingSurfaceInfo buffer */ - private static void UnsetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { - UnsetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer); - } - - private static native void SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); private static native void UnsetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); // Variables for lockSurface/unlockSurface @@ -337,7 +329,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; - private long rootSurfaceLayerHandle = 0; // attached to the JAWT_SurfaceLayer + private long rootSurfaceLayer = 0; // attached to the JAWT_SurfaceLayer private long windowHandle = 0; private long offscreenSurfaceHandle = 0; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 1563a5a8b..703c3d972 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -83,11 +83,11 @@ public class OSXUtil implements ToolkitProperties { public static final boolean hasThreadingIssues() { return false; } public static boolean isNSView(long object) { - return isNSView0(object); + return 0 != object ? isNSView0(object) : false; } public static boolean isNSWindow(long object) { - return isNSWindow0(object); + return 0 != object ? isNSWindow0(object) : false; } /** @@ -164,8 +164,7 @@ public class OSXUtil implements ToolkitProperties { } RunOnMainThread(false, new Runnable() { public void run() { - AddCASublayer0(rootCALayer, subCALayer); - FixCALayerLayout0(rootCALayer, subCALayer, width, height); + AddCASublayer0(rootCALayer, subCALayer, width, height); } }); } @@ -194,24 +193,32 @@ public class OSXUtil implements ToolkitProperties { } /** - * Detach a sub CALayer from the root CALayer + * Detach a sub CALayer from the root CALayer on the main-thread w/o blocking. */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } - RemoveCASublayer0(rootCALayer, subCALayer); + RunOnMainThread(false, new Runnable() { + public void run() { + RemoveCASublayer0(rootCALayer, subCALayer); + } + }); } /** - * Destroy a CALayer + * Destroy a CALayer on main-thread w/o blocking. * @see #CreateCALayer(int, int, int, int) */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); } - DestroyCALayer0(caLayer); + RunOnMainThread(false, new Runnable() { + public void run() { + DestroyCALayer0(caLayer); + } + }); } /** @@ -337,7 +344,7 @@ public class OSXUtil implements ToolkitProperties { private static native long GetNSView0(long nsWindow); private static native long GetNSWindow0(long nsView); 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 AddCASublayer0(long rootCALayer, long subCALayer, int width, int height); private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int width, int height); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); |