summaryrefslogtreecommitdiffstats
path: root/make
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-29 15:10:48 +0200
committerSven Gothel <[email protected]>2011-10-29 15:10:48 +0200
commit6a770d1ec80a656db62feb8100e3fe58800e79af (patch)
treeb20ea684417f6945b30426782e1442382ec1afb8 /make
parentbc826eb2e216ce82a5e6bc61403e4eff2f338380 (diff)
MacOsX/JAWT_SurfaceLayers/CALayers: Kick off / JAWT_getAWT() CALAYER version support.
Diffstat (limited to 'make')
-rw-r--r--make/config/nativewindow/jawt-CustomJavaCode.java39
-rw-r--r--make/config/nativewindow/jawt-common.cfg2
-rw-r--r--make/config/nativewindow/jawt-macosx.cfg5
-rw-r--r--make/stub_includes/jni/macosx/jawt_md.h20
4 files changed, 61 insertions, 5 deletions
diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java
index 3223a74b1..23da6b3b9 100644
--- a/make/config/nativewindow/jawt-CustomJavaCode.java
+++ b/make/config/nativewindow/jawt-CustomJavaCode.java
@@ -1,4 +1,24 @@
-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 static volatile JAWT jawt = null;
+private static int jawt_version_flags = 0;
+
+private int jawt_version_cached = 0;
+
+public final int getVersionCached() {
+ return jawt_version_cached;
+}
+
+public static void setJAWTVersionFlags(int versionFlags) {
+ synchronized (JAWT.class) {
+ if (jawt != null) {
+ throw new RuntimeException("JAWT already instantiated");
+ }
+ jawt_version_flags = versionFlags;
+ }
+}
/** Helper routine for all users to call to access the JAWT. */
public static JAWT getJAWT() {
@@ -9,14 +29,25 @@ public static JAWT getJAWT() {
// 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() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
JAWT j = JAWT.create();
- j.setVersion(JAWTFactory.JAWT_VERSION_1_4);
+ if( 0 != ( jawt_version_flags & JAWT_MACOSX_USE_CALAYER ) ) {
+ j.setVersion(jawt_version_flags);
+ if (JAWTFactory.JAWT_GetAWT(j)) {
+ jawt = j;
+ jawt.jawt_version_cached = jawt.getVersion();
+ return null;
+ }
+ jawt_version_flags &= ~JAWT_MACOSX_USE_CALAYER;
+ System.err.println("MacOSX "+Platform.OS_VERSION_NUMBER+" >= "+JAWT_MacOSXCALayerMinVersion+": Failed to use JAWT_MACOSX_USE_CALAYER");
+ }
+ j.setVersion(jawt_version_flags);
if (!JAWTFactory.JAWT_GetAWT(j)) {
- throw new RuntimeException("Unable to initialize JAWT");
+ throw new RuntimeException("Unable to initialize JAWT: 0x"+Integer.toHexString(jawt_version_flags));
}
jawt = j;
+ jawt.jawt_version_cached = jawt.getVersion();
return null;
}
});
diff --git a/make/config/nativewindow/jawt-common.cfg b/make/config/nativewindow/jawt-common.cfg
index d633c47d6..55f3f368b 100644
--- a/make/config/nativewindow/jawt-common.cfg
+++ b/make/config/nativewindow/jawt-common.cfg
@@ -22,5 +22,7 @@ CustomCCode #include <jawt.h>
import java.security.*
import jogamp.nativewindow.jawt.*
+import com.jogamp.common.os.Platform
+import com.jogamp.common.util.VersionNumber
IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java
diff --git a/make/config/nativewindow/jawt-macosx.cfg b/make/config/nativewindow/jawt-macosx.cfg
index c41367f4a..20260f693 100644
--- a/make/config/nativewindow/jawt-macosx.cfg
+++ b/make/config/nativewindow/jawt-macosx.cfg
@@ -5,6 +5,7 @@ NativeOutputDir gensrc/native/MacOSX
Opaque long void *
Opaque long NSView *
+Opaque long CALayer *
CustomCCode #include <inttypes.h>
CustomCCode #include </usr/include/machine/types.h>
@@ -12,3 +13,7 @@ CustomCCode #include </usr/include/machine/types.h>
StructPackage JAWT_MacOSXDrawingSurfaceInfo jogamp.nativewindow.jawt.macosx
EmitStruct JAWT_MacOSXDrawingSurfaceInfo
Implements JAWT_MacOSXDrawingSurfaceInfo JAWT_PlatformInfo
+
+StructPackage JAWT_SurfaceLayers jogamp.nativewindow.jawt.macosx
+EmitStruct JAWT_SurfaceLayers
+Implements JAWT_SurfaceLayers JAWT_PlatformInfo
diff --git a/make/stub_includes/jni/macosx/jawt_md.h b/make/stub_includes/jni/macosx/jawt_md.h
index aca47f66e..3a371af0d 100644
--- a/make/stub_includes/jni/macosx/jawt_md.h
+++ b/make/stub_includes/jni/macosx/jawt_md.h
@@ -9,17 +9,35 @@
#include <jawt.h>
#include <AppKit/NSView.h>
+#include <QuartzCore/CALayer.h>
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * JAWT_DrawingSurfaceInfo.getPlatformInfo()
+ *
+ * Only if not JAWT_SurfaceLayers, see below!
+ */
typedef struct JAWT_MacOSXDrawingSurfaceInfo
{
- NSView *cocoaViewRef; // the view is guaranteed to be valid only for the duration of Component.paint method
+ /** the view is guaranteed to be valid only for the duration of Component.paint method */
+ NSView *cocoaViewRef;
}
JAWT_MacOSXDrawingSurfaceInfo;
+/**
+ * JAWT_DrawingSurfaceInfo.getPlatformInfo()
+ *
+ * >= 10.6.4 if JAWT_MACOSX_USE_CALAYER is set in JAWT version
+ */
+typedef struct JAWT_SurfaceLayers
+{
+ CALayer *layer;
+}
+JAWT_SurfaceLayers;
+
#ifdef __cplusplus
}
#endif