aboutsummaryrefslogtreecommitdiffstats
path: root/make/config/nativewindow
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-03-17 20:41:40 +0000
committerKenneth Russel <[email protected]>2009-03-17 20:41:40 +0000
commit9a44770462cc3e10af1eee66a75e708bd540fce9 (patch)
tree18d907e45445e4121928d4b1a592428f17ca065f /make/config/nativewindow
parent3ad5bf195cec28d7578ee417f9425a871ce7ef57 (diff)
Continue moving javax.media.nwi -> javax.media.nativewindow
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1881 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'make/config/nativewindow')
-rwxr-xr-xmake/config/nativewindow/jawt-CustomJavaCode.java27
-rwxr-xr-xmake/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java38
-rw-r--r--make/config/nativewindow/jawt-macosx.cfg30
-rw-r--r--make/config/nativewindow/jawt-win32.cfg30
-rw-r--r--make/config/nativewindow/jawt-x11.cfg30
-rwxr-xr-xmake/config/nativewindow/x11-CustomCCode.c82
-rw-r--r--make/config/nativewindow/x11-lib.cfg43
7 files changed, 280 insertions, 0 deletions
diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java
new file mode 100755
index 000000000..f1ef91075
--- /dev/null
+++ b/make/config/nativewindow/jawt-CustomJavaCode.java
@@ -0,0 +1,27 @@
+private static volatile JAWT jawt;
+
+/** Helper routine for all users to call to access the JAWT. */
+public static JAWT getJAWT() {
+ if (jawt == null) {
+ synchronized (JAWT.class) {
+ if (jawt == null) {
+ JAWTNativeLibLoader.loadAWTImpl();
+ // 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.version(JAWTFactory.JAWT_VERSION_1_4);
+ if (!JAWTFactory.JAWT_GetAWT(j)) {
+ throw new RuntimeException("Unable to initialize JAWT");
+ }
+ jawt = j;
+ return null;
+ }
+ });
+ }
+ }
+ }
+ return jawt;
+}
diff --git a/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java b/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
new file mode 100755
index 000000000..1cc13e7d8
--- /dev/null
+++ b/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
@@ -0,0 +1,38 @@
+public JAWT_PlatformInfo platformInfo() {
+ return newPlatformInfo(platformInfo0(getBuffer()));
+}
+
+private native ByteBuffer platformInfo0(Buffer jthis0);
+
+private static java.lang.reflect.Method platformInfoFactoryMethod;
+
+private static JAWT_PlatformInfo newPlatformInfo(ByteBuffer buf) {
+ if (platformInfoFactoryMethod == null) {
+ String osName = (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("os.name").toLowerCase();
+ }
+ });
+ try {
+ Class factoryClass;
+ if (osName.startsWith("wind")) {
+ factoryClass = Class.forName("com.sun.nwi.impl.jawt.windows.JAWT_Win32DrawingSurfaceInfo");
+ } else if (osName.startsWith("mac os x")) {
+ factoryClass = Class.forName("com.sun.nwi.impl.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo");
+ } else {
+ // Assume Linux, Solaris, etc. Should probably test for these explicitly.
+ factoryClass = Class.forName("com.sun.nwi.impl.jawt.x11.JAWT_X11DrawingSurfaceInfo");
+ }
+ platformInfoFactoryMethod = factoryClass.getMethod("create",
+ new Class[] { ByteBuffer.class });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ try {
+ return (JAWT_PlatformInfo)
+ platformInfoFactoryMethod.invoke(null, new Object[] { buf });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+}
diff --git a/make/config/nativewindow/jawt-macosx.cfg b/make/config/nativewindow/jawt-macosx.cfg
new file mode 100644
index 000000000..57cceb6a1
--- /dev/null
+++ b/make/config/nativewindow/jawt-macosx.cfg
@@ -0,0 +1,30 @@
+# This .cfg file is used to generate the interface to the JAWT, which
+# is used by the MacOSXOnscreenGLContext.
+Style AllStatic
+Package com.sun.nwi.impl.jawt
+JavaClass JAWTFactory
+JavaOutputDir gensrc/classes
+NativeOutputDir gensrc/native/MacOSX
+
+HierarchicalNativeOutput false
+
+Opaque boolean jboolean
+Opaque long void *
+Opaque long NSView *
+
+IgnoreField JAWT GetComponent
+IgnoreField JAWT_DrawingSurfaceInfo platformInfo
+
+IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java
+
+CustomCCode #include <inttypes.h>
+CustomCCode #include <jawt.h>
+CustomCCode #include </usr/include/machine/types.h>
+
+import java.security.*
+import com.sun.nwi.impl.jawt.*
+StructPackage JAWT_MacOSXDrawingSurfaceInfo com.sun.nwi.impl.jawt.macosx
+EmitStruct JAWT_MacOSXDrawingSurfaceInfo
+Implements JAWT_MacOSXDrawingSurfaceInfo JAWT_PlatformInfo
+
+IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java
diff --git a/make/config/nativewindow/jawt-win32.cfg b/make/config/nativewindow/jawt-win32.cfg
new file mode 100644
index 000000000..74aef8f75
--- /dev/null
+++ b/make/config/nativewindow/jawt-win32.cfg
@@ -0,0 +1,30 @@
+# This .cfg file is used to generate the interface to the JAWT, which
+# is used by the WindowsOnscreenGLContext.
+Style AllStatic
+Package com.sun.nwi.impl.jawt
+JavaClass JAWTFactory
+JavaOutputDir gensrc/classes
+NativeOutputDir gensrc/native/Windows
+
+HierarchicalNativeOutput false
+
+Opaque boolean jboolean
+Opaque long HDC
+
+IgnoreField JAWT GetComponent
+IgnoreField JAWT_DrawingSurfaceInfo platformInfo
+IgnoreField JAWT_Win32DrawingSurfaceInfo null
+IgnoreField JAWT_Win32DrawingSurfaceInfo hpalette
+
+IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java
+
+CustomCCode #include <jawt.h>
+Include ../intptr.cfg
+
+import java.security.*
+import com.sun.nwi.impl.jawt.*
+StructPackage JAWT_Win32DrawingSurfaceInfo com.sun.nwi.impl.jawt.windows
+EmitStruct JAWT_Win32DrawingSurfaceInfo
+Implements JAWT_Win32DrawingSurfaceInfo JAWT_PlatformInfo
+
+IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java
diff --git a/make/config/nativewindow/jawt-x11.cfg b/make/config/nativewindow/jawt-x11.cfg
new file mode 100644
index 000000000..fdcf16bdb
--- /dev/null
+++ b/make/config/nativewindow/jawt-x11.cfg
@@ -0,0 +1,30 @@
+# This .cfg file is used to generate the interface to the JAWT, which
+# is used by the X11OnscreenGLContext.
+Style AllStatic
+Package com.sun.nwi.impl.jawt
+JavaClass JAWTFactory
+JavaOutputDir gensrc/classes
+NativeOutputDir gensrc/native/X11
+
+HierarchicalNativeOutput false
+
+Opaque boolean jboolean
+Opaque long Drawable
+Opaque long Display *
+
+IgnoreField JAWT GetComponent
+IgnoreField JAWT_DrawingSurfaceInfo platformInfo
+IgnoreField JAWT_X11DrawingSurfaceInfo GetAWTColor
+
+IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java
+
+CustomCCode #include <inttypes.h>
+CustomCCode #include <jawt.h>
+
+import java.security.*
+import com.sun.nwi.impl.jawt.*
+StructPackage JAWT_X11DrawingSurfaceInfo com.sun.nwi.impl.jawt.x11
+EmitStruct JAWT_X11DrawingSurfaceInfo
+Implements JAWT_X11DrawingSurfaceInfo JAWT_PlatformInfo
+
+IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java
diff --git a/make/config/nativewindow/x11-CustomCCode.c b/make/config/nativewindow/x11-CustomCCode.c
new file mode 100755
index 000000000..793327c72
--- /dev/null
+++ b/make/config/nativewindow/x11-CustomCCode.c
@@ -0,0 +1,82 @@
+#include <inttypes.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+/* Linux headers don't work properly */
+#define __USE_GNU
+#include <dlfcn.h>
+#undef __USE_GNU
+
+/* Current versions of Solaris don't expose the XF86 extensions,
+ although with the recent transition to Xorg this will probably
+ happen in an upcoming release */
+#if !defined(__sun) && !defined(_HPUX)
+#include <X11/extensions/xf86vmode.h>
+#else
+/* Need to provide stubs for these */
+Bool XF86VidModeGetGammaRampSize(
+ Display *display,
+ int screen,
+ int* size)
+{
+ return False;
+}
+
+Bool XF86VidModeGetGammaRamp(
+ Display *display,
+ int screen,
+ int size,
+ unsigned short *red_array,
+ unsigned short *green_array,
+ unsigned short *blue_array) {
+ return False;
+}
+Bool XF86VidModeSetGammaRamp(
+ Display *display,
+ int screen,
+ int size,
+ unsigned short *red_array,
+ unsigned short *green_array,
+ unsigned short *blue_array) {
+ return False;
+}
+#endif
+
+/* HP-UX doesn't define RTLD_DEFAULT. */
+#if defined(_HPUX) && !defined(RTLD_DEFAULT)
+#define RTLD_DEFAULT NULL
+#endif
+
+/* Need to expose DefaultScreen and RootWindow macros to Java */
+JNIEXPORT jlong JNICALL
+Java_com_sun_nwi_impl_x11_X11Lib_DefaultScreen(JNIEnv *env, jclass _unused, jlong display) {
+ return DefaultScreen((Display*) (intptr_t) display);
+}
+JNIEXPORT jlong JNICALL
+Java_com_sun_nwi_impl_x11_X11Lib_RootWindow(JNIEnv *env, jclass _unused, jlong display, jint screen) {
+ return RootWindow((Display*) (intptr_t) display, screen);
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_sun_nwi_impl_x11_X11Lib_dlopen(JNIEnv *env, jclass _unused, jstring name) {
+ const jbyte* chars;
+ void* res;
+ chars = (*env)->GetStringUTFChars(env, name, NULL);
+ res = dlopen(chars, RTLD_LAZY | RTLD_GLOBAL);
+ (*env)->ReleaseStringUTFChars(env, name, chars);
+ return (jlong) ((intptr_t) res);
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_sun_nwi_impl_x11_X11Lib_dlsym(JNIEnv *env, jclass _unused, jstring name) {
+ const jbyte* chars;
+ void* res;
+ chars = (*env)->GetStringUTFChars(env, name, NULL);
+ res = dlsym(RTLD_DEFAULT, chars);
+ (*env)->ReleaseStringUTFChars(env, name, chars);
+ return (jlong) ((intptr_t) res);
+}
+
+/* Need to pull this in as we don't have a stub header for it */
+extern Bool XineramaEnabled(Display* display);
+
diff --git a/make/config/nativewindow/x11-lib.cfg b/make/config/nativewindow/x11-lib.cfg
new file mode 100644
index 000000000..1448e7783
--- /dev/null
+++ b/make/config/nativewindow/x11-lib.cfg
@@ -0,0 +1,43 @@
+# This .cfg file is used to generate the interface to the GLX routines
+# used internally by the X11GLContext implementation.
+Package com.sun.nwi.impl.x11
+JavaClass X11Lib
+Style allstatic
+
+HierarchicalNativeOutput false
+
+JavaOutputDir gensrc/classes
+NativeOutputDir gensrc/native/X11
+
+# Imports needed by all glue code
+Import java.nio.*
+Import java.util.*
+
+# XID needs to be treated as a long for 32/64 bit compatibility
+Opaque long XID
+
+Opaque long Display *
+Opaque boolean Bool
+Opaque long GLXFBConfig
+
+CustomJavaCode X11Lib public static native long dlopen(String name);
+CustomJavaCode X11Lib public static native long dlsym(String name);
+
+IncludeAs CustomCCode x11-CustomCCode.c
+
+ArgumentIsString XOpenDisplay 0
+
+# Need to expose DefaultScreen and RootWindow macros to Java
+CustomJavaCode X11Lib public static native int DefaultScreen(long display);
+CustomJavaCode X11Lib public static native long RootWindow(long display, int screen);
+
+# Get returned array's capacity from XGetVisualInfo to be correct
+TemporaryCVariableDeclaration XGetVisualInfo int count;
+TemporaryCVariableAssignment XGetVisualInfo count = _ptr3[0];
+ReturnValueCapacity XGetVisualInfo count * sizeof(XVisualInfo)
+
+# Helper routine to make the ReturnedArrayLength expression below work correctly
+CustomJavaCode X11Lib private static int getFirstElement(IntBuffer buf) { return buf.get(buf.position()); }
+CustomJavaCode X11Lib private static int getFirstElement(int[] arr, int offset) { return arr[offset]; }
+ReturnedArrayLength XGetVisualInfo getFirstElement({3})
+