diff options
Diffstat (limited to 'src/nativewindow/classes/jogamp')
4 files changed, 36 insertions, 23 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index a88ca678e..4435c4f8f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -77,20 +77,36 @@ public class JAWTUtil { boolean ok; } - public static boolean setJAWTVersionFlags(boolean useOffScreenLayerIfAvailable) { + /** + * Returns true if this platform's JAWT implementation supports + * or uses offscreen layer. + */ + public static boolean isOffscreenLayerSupported() { + return Platform.OS_TYPE == Platform.OSType.MACOS && + Platform.OS_VERSION_NUMBER.compareTo(JAWT.JAWT_MacOSXCALayerMinVersion) >= 0; + } + + /** + * + * FIXME: Need to get rid of the cached JAWT instance, + * in case we like to have dual usage of offscreenLayeredSurface and onscreen. + * This would be done implicit by using NEWT .. hence low prio. + * + * @param useOffscreenLayerIfAvailable + * @return + */ + public static boolean setCachedJAWTVersionFlags(boolean useOffscreenLayerIfAvailable) { if(JAWT.isJAWTInstantiated()) { return false; } // already instantiated - if(useOffScreenLayerIfAvailable && - Platform.OS_TYPE == Platform.OSType.MACOS && - Platform.OS_VERSION_NUMBER.compareTo(JAWT.JAWT_MacOSXCALayerMinVersion) >= 0) { + if(useOffscreenLayerIfAvailable && isOffscreenLayerSupported()) { JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4 | JAWT.JAWT_MACOSX_USE_CALAYER); return true; } JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4); - return !useOffScreenLayerIfAvailable; // n/a + return !useOffscreenLayerIfAvailable; // n/a } - public static boolean isJAWTVersionUsingOffscreenLayer() { + public static boolean isCachedJAWTUsingOffscreenLayer() { return 0 != ( JAWT.getJAWT().getVersionCached() & JAWT.JAWT_MACOSX_USE_CALAYER ); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java index 3f10fa983..151099f26 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java @@ -98,10 +98,7 @@ public abstract class JAWTWindow implements NativeWindow { windowObject = windowObject.getParent(); } if(isApplet) { - JAWTUtil.setJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true - } else { - // test - JAWTUtil.setJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true + JAWTUtil.setCachedJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true } validateNative(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index b75bb3f4d..5ac42e21b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -64,7 +64,7 @@ import jogamp.nativewindow.macosx.OSXUtil; public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { public MacOSXJAWTWindow(Object comp, AbstractGraphicsConfiguration config) { super(comp, config); - isOffscreenLayeredSurface = JAWTUtil.isJAWTVersionUsingOffscreenLayer(); + isOffscreenLayerSurface = JAWTUtil.isCachedJAWTUsingOffscreenLayer(); dumpInfo(); } @@ -73,22 +73,22 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { protected void invalidateNative() { surfaceHandle=0; - if(isOffscreenLayeredSurface && 0 == drawable) { + if(isOffscreenLayerSurface && 0 == drawable) { OSXUtil.DestroyNSWindow(drawable); drawable = 0; } } - public final boolean isLayeredSurface() { - return isOffscreenLayeredSurface; + public final boolean isOffscreenLayerSurface() { + return isOffscreenLayerSurface; } public long getSurfaceHandle() { - return isOffscreenLayeredSurface ? surfaceHandle : super.getSurfaceHandle() ; + return isOffscreenLayerSurface ? surfaceHandle : super.getSurfaceHandle() ; } public void setSurfaceHandle(long surfaceHandle) { - if( !isLayeredSurface() ) { + if( !isOffscreenLayerSurface() ) { throw new java.lang.UnsupportedOperationException("Not using CALAYER"); } if(DEBUG) { @@ -109,8 +109,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { return getSurfaceLayers().getLayer(); } */ - public void attachSurfaceLayer(long layerHandle) { - if( !isLayeredSurface() ) { + public void attachSurfaceLayer(final long layerHandle) { + if( !isOffscreenLayerSurface() ) { throw new NativeWindowException("Not using CALAYER"); } int lockRes = lockSurface(); @@ -121,7 +121,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { if(DEBUG) { System.err.println("MacOSXJAWTWindow.attachSurfaceLayer(): 0x"+Long.toHexString(layerHandle)); } - OSXUtil.AttachJAWTSurfaceLayer0(dsi, layerHandle); + OSXUtil.AttachJAWTSurfaceLayer(dsi, layerHandle); } finally { unlockSurface(); } @@ -179,7 +179,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { dumpInfo(); } firstLock = false; - if( !isOffscreenLayeredSurface ) { + if( !isOffscreenLayerSurface ) { macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo(); if (macosxdsi == null) { unlockSurfaceImpl(); @@ -258,7 +258,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { // System.err.println(this); System.err.println("JAWT version: 0x"+Integer.toHexString(JAWT.getJAWT().getVersionCached())+ ", CA_LAYER: "+ (0!=(JAWT.getJAWT().getVersionCached() & JAWT.JAWT_MACOSX_USE_CALAYER))+ - ", isLayeredSurface "+isLayeredSurface()); + ", isLayeredSurface "+isOffscreenLayerSurface()); if(null != dsi) { JAWT_Rectangle r = dsi.getBounds(); System.err.println("dsi bounds: "+r.getX()+"/"+r.getY()+" "+r.getWidth()+"x"+r.getHeight()); @@ -286,7 +286,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; // private JAWT_SurfaceLayers macosxsl; - final boolean isOffscreenLayeredSurface; + final boolean isOffscreenLayerSurface; long surfaceHandle = 0; // Workaround for instance of 4796548 diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 79ac24686..a07001def 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -51,7 +51,7 @@ public class OSXUtil { DestroyNSWindow0(nsWindow); } - public static boolean AttachJAWTSurfaceLayer0(JAWT_DrawingSurfaceInfo dsi, long caLayer) { + public static boolean AttachJAWTSurfaceLayer(JAWT_DrawingSurfaceInfo dsi, long caLayer) { return AttachJAWTSurfaceLayer0(dsi.getBuffer(), caLayer); } |