diff options
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 38 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java | 37 |
2 files changed, 34 insertions, 41 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 3ec54ca78..c8f758165 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -51,7 +51,6 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Point; -import com.jogamp.common.util.Function; import com.jogamp.nativewindow.awt.JAWTWindow; import jogamp.nativewindow.jawt.JAWT; @@ -90,8 +89,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { JAWT_DrawingSurfaceInfo dsi = null; try { dsi = ds.GetDrawingSurfaceInfo(); - if(! UnsetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle)) { + try { + UnsetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle); + } catch (Exception e) { System.err.println("Error clearing JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle)); + e.printStackTrace(); } } finally { if ( null != dsi ) { @@ -245,8 +247,12 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayerHandle) { errMsg = "Could not create root CALayer"; - } else if(!SetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle)) { - errMsg = "Could not set JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle); + } else { + try { + SetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle); + } catch(Exception e) { + errMsg = "Could not set JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle)+", cause: "+e.getMessage(); + } } } } @@ -307,22 +313,22 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } - private static boolean SetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { - return OSXUtil.RunOnMainThread(true, new Function<Boolean, Object>() { - public Boolean eval(Object... args) { - return Boolean.valueOf( SetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer) ); - } } ).booleanValue(); + /** + * Set the given root CALayer in the JAWT surface + */ + private static void SetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { + SetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer); } - private static boolean UnsetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { - return OSXUtil.RunOnMainThread(true, new Function<Boolean, Object>() { - public Boolean eval(Object... args) { - return Boolean.valueOf( UnsetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer) ); - } } ).booleanValue(); + /** + * Unset the given root CALayer in the JAWT surface + */ + private static void UnsetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { + UnsetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer); } - private static native boolean SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); - private static native boolean UnsetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + private static native void SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + private static native void 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 aa44e2d64..59b42c249 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -137,26 +137,23 @@ public class OSXUtil implements ToolkitProperties { } /** - * Create a CALayer suitable to act as a root CALayer on the main-thread. + * Create a CALayer suitable to act as a root CALayer. * @see #DestroyCALayer(long) * @see #AddCASublayer(long, long) */ public static long CreateCALayer(final int x, final int y, final int width, final int height) { - return OSXUtil.RunOnMainThread(true, new Function<Long, Object>() { - public Long eval(Object... args) { - return Long.valueOf( CreateCALayer0(x, y, width, height) ); - } } ).longValue(); + return CreateCALayer0(x, y, width, height); } /** - * Attach a sub CALayer to the root CALayer on the main-thread w/ blocking. + * Attach a sub CALayer to the root CALayer on the main-thread w/o blocking. * <p> * Method will trigger a <code>display</code> * call to the CALayer hierarchy to enforce resource creation if required, e.g. an NSOpenGLContext. * </p> * <p> - * It is mandatory that any related resources, e.g. a shared NSOpenGLContext, - * are not locked while calling this method. + * Hence it is important that related resources are not locked <i>if</i> + * they will be used for creation. * </p> * @see #CreateCALayer(int, int, int, int) * @see #RemoveCASublayer(long, long) @@ -165,7 +162,7 @@ public class OSXUtil implements ToolkitProperties { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } - RunOnMainThread(true, new Runnable() { + RunOnMainThread(false, new Runnable() { public void run() { AddCASublayer0(rootCALayer, subCALayer); } @@ -173,7 +170,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Fix root and sub CALayer position to 0/0 and size on the main-thread w/o blocking. + * Fix root and sub CALayer position to 0/0 and size * <p> * If the sub CALayer implements the Objective-C NativeWindow protocol NWDedicatedSize (e.g. JOGL's MyNSOpenGLLayer), * the dedicated size is passed to the layer, which propagates it appropriately. @@ -192,38 +189,28 @@ public class OSXUtil implements ToolkitProperties { if( 0==rootCALayer && 0==subCALayer ) { return; } - RunOnMainThread(false, new Runnable() { - public void run() { - FixCALayerLayout0(rootCALayer, subCALayer, width, height); - } - }); + FixCALayerLayout0(rootCALayer, subCALayer, width, height); } /** - * Detach a sub CALayer from the root CALayer on the main-thread w/ blocking. + * Detach a sub CALayer from the root CALayer */ 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)); } - RunOnMainThread(true, new Runnable() { - public void run() { - RemoveCASublayer0(rootCALayer, subCALayer); - } } ); + RemoveCASublayer0(rootCALayer, subCALayer); } /** - * Destroy a CALayer on the main-thread w/ blocking. + * Destroy a CALayer * @see #CreateCALayer(int, int, int, int) */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); } - RunOnMainThread(true, new Runnable() { - public void run() { - DestroyCALayer0(caLayer); - } } ); + DestroyCALayer0(caLayer); } /** |