summaryrefslogtreecommitdiffstats
path: root/make/config/nativewindow/jawt-CustomJavaCode.java
diff options
context:
space:
mode:
Diffstat (limited to 'make/config/nativewindow/jawt-CustomJavaCode.java')
-rw-r--r--make/config/nativewindow/jawt-CustomJavaCode.java57
1 files changed, 34 insertions, 23 deletions
diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java
index 3223a74b1..d3dc3845f 100644
--- a/make/config/nativewindow/jawt-CustomJavaCode.java
+++ b/make/config/nativewindow/jawt-CustomJavaCode.java
@@ -1,27 +1,38 @@
-private static volatile JAWT jawt;
+/** Available and recommended on Mac OS X >= 10.6 Update 4 */
+public static final int JAWT_MACOSX_USE_CALAYER = 0x80000000;
+public static final VersionNumber JAWT_MacOSXCALayerMinVersion = new VersionNumber(10,6,4);
+
+private int jawt_version_cached = 0;
+
+public final int getCachedVersion() {
+ return jawt_version_cached;
+}
/** Helper routine for all users to call to access the JAWT. */
-public static JAWT getJAWT() {
- if (jawt == null) {
- synchronized (JAWT.class) {
- if (jawt == null) {
- JAWTUtil.initSingleton();
- // Workaround for 4845371.
- // Make sure the first reference to the JNI GetDirectBufferAddress is done
- // from a privileged context so the VM's internal class lookups will succeed.
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- JAWT j = JAWT.create();
- j.setVersion(JAWTFactory.JAWT_VERSION_1_4);
- if (!JAWTFactory.JAWT_GetAWT(j)) {
- throw new RuntimeException("Unable to initialize JAWT");
+public static JAWT getJAWT(final int jawt_version_flags) {
+ JAWTUtil.initSingleton();
+ // Workaround for 4845371.
+ // Make sure the first reference to the JNI GetDirectBufferAddress is done
+ // from a privileged context so the VM's internal class lookups will succeed.
+ return AccessController.doPrivileged(new PrivilegedAction<JAWT>() {
+ public JAWT run() {
+ int jawt_version_flags_mod = jawt_version_flags;
+ JAWT jawt = JAWT.create();
+ if( 0 != ( jawt_version_flags_mod & JAWT_MACOSX_USE_CALAYER ) ) {
+ jawt.setVersion(jawt_version_flags_mod);
+ if (JAWTFactory.JAWT_GetAWT(jawt)) {
+ jawt.jawt_version_cached = jawt.getVersion();
+ return jawt;
}
- jawt = j;
- return null;
- }
- });
- }
- }
- }
- return jawt;
+ jawt_version_flags_mod &= ~JAWT_MACOSX_USE_CALAYER;
+ System.err.println("MacOSX "+Platform.OS_VERSION_NUMBER+" >= "+JAWT_MacOSXCALayerMinVersion+": Failed to use JAWT_MACOSX_USE_CALAYER");
+ }
+ jawt.setVersion(jawt_version_flags_mod);
+ if (!JAWTFactory.JAWT_GetAWT(jawt)) {
+ throw new RuntimeException("Unable to initialize JAWT: 0x"+Integer.toHexString(jawt_version_flags_mod));
+ }
+ jawt.jawt_version_cached = jawt.getVersion();
+ return jawt;
+ }
+ });
}