Date: Tue, 24 Sep 2013 23:13:16 +0200
Subject: Bug 816: Fix OSX CALayer 'quirks' for AWT 1.7.0_40 - See JAWTUtil
JAWT_OSX_CALAYER_QUIRK_SIZE and JAWT_OSX_CALAYER_QUIRK_POSITION.
- Provide quirk bits for OSX CALayer depending on used JVM/AWT
and act accordingly.
- TestBug816OSXCALayerPosAWT: Add resize by frame
---
.../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 76 ++++++++++-
.../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 14 +-
.../jogamp/nativewindow/macosx/OSXUtil.java | 26 ++--
.../native/macosx/NativeWindowProtocols.h | 21 ++-
src/nativewindow/native/macosx/OSXmisc.m | 143 +++++++++++++--------
5 files changed, 205 insertions(+), 75 deletions(-)
(limited to 'src/nativewindow')
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index 1f5d33746..b663f90b7 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -68,7 +68,7 @@ public class JAWTUtil {
public static final VersionNumber JAWT_MacOSXCALayerMinVersion = new VersionNumber(10,6,4);
/** OSX JAWT CALayer required with Java >= 1.7.0 (implies OS X >= 10.7 */
- public static final VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion = new VersionNumber(1,7,0);
+ public static final VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion = Platform.Version17;
// See whether we're running in headless mode
private static final boolean headlessMode;
@@ -98,18 +98,84 @@ public class JAWTUtil {
* Returns true if this platform's JAWT implementation supports offscreen layer.
*/
public static boolean isOffscreenLayerSupported() {
- return Platform.OS_TYPE == Platform.OSType.MACOS &&
- Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0;
+ return Platform.OS_TYPE == Platform.OSType.MACOS &&
+ Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0;
}
/**
* Returns true if this platform's JAWT implementation requires using offscreen layer.
*/
public static boolean isOffscreenLayerRequired() {
- return Platform.OS_TYPE == Platform.OSType.MACOS &&
- Platform.JAVA_VERSION_NUMBER.compareTo(JAWT_MacOSXCALayerRequiredForJavaVersion)>=0;
+ return Platform.OS_TYPE == Platform.OSType.MACOS &&
+ Platform.JAVA_VERSION_NUMBER.compareTo(JAWT_MacOSXCALayerRequiredForJavaVersion)>=0;
}
+ /**
+ * CALayer size needs to be set using the AWT component size.
+ *
+ * As of today, we have to overwrite the CALayer size
+ * w/ the AWT component one since programmatic resize leads to differences.
+ *
+ *
+ * Hence this flag is always enabled.
+ *
+ *
+ * Sync w/ NativeWindowProtocols.h
+ *
+ */
+ public static final int JAWT_OSX_CALAYER_QUIRK_SIZE = 1 << 0;
+
+ /**
+ * CALayer position needs to be set to zero.
+ *
+ * Normally we have to set the root-calayer's position to 0/0
+ * and leave client-calayer's position in it's desired place.
+ * With pre AWT 1.7.0_40, the client-calayer's position has to
+ * be set to zero as well.
+ *
+ *
+ * Further more a re-layout seems to be required in this case,
+ * i.e. a programmatic forced resize +1 and it's inverted resize -1.
+ *
+ *
+ * Hence this flag is enabled w/ AWT < 1.7.0_40.
+ *
+ *
+ * Sync w/ NativeWindowProtocols.h
+ *
+ */
+ public static final int JAWT_OSX_CALAYER_QUIRK_POSITION = 1 << 1;
+
+ /**
+ * Returns bitfield of required JAWT OSX CALayer quirks to mediate AWT impl. bugs.
+ *
+ * Returns zero, if platform is not {@link Platform.OSType#MACOS}
+ * or not supporting CALayer, i.e. OSX < 10.6.4.
+ *
+ *
+ * Otherwise includes
+ *
+ * - {@link #JAWT_OSX_CALAYER_QUIRK_SIZE} (always)
+ * - {@link #JAWT_OSX_CALAYER_QUIRK_POSITION} if JVM < 1.7.0_40
+ *
+ *