aboutsummaryrefslogtreecommitdiffstats
path: root/make/config/nwi
diff options
context:
space:
mode:
Diffstat (limited to 'make/config/nwi')
-rwxr-xr-xmake/config/nwi/jawt-CustomJavaCode.java27
-rwxr-xr-xmake/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java38
-rw-r--r--make/config/nwi/jawt-macosx.cfg30
-rw-r--r--make/config/nwi/jawt-win32.cfg30
-rw-r--r--make/config/nwi/jawt-x11.cfg30
-rwxr-xr-xmake/config/nwi/x11-CustomCCode.c82
-rw-r--r--make/config/nwi/x11-lib.cfg43
7 files changed, 280 insertions, 0 deletions
diff --git a/make/config/nwi/jawt-CustomJavaCode.java b/make/config/nwi/jawt-CustomJavaCode.java
new file mode 100755
index 000000000..f1ef91075
--- /dev/null
+++ b/make/config/nwi/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/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java b/make/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java
new file mode 100755
index 000000000..1cc13e7d8
--- /dev/null
+++ b/make/config/nwi/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/nwi/jawt-macosx.cfg b/make/config/nwi/jawt-macosx.cfg
new file mode 100644
index 000000000..57cceb6a1
--- /dev/null
+++ b/make/config/nwi/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/nwi/jawt-win32.cfg b/make/config/nwi/jawt-win32.cfg
new file mode 100644
index 000000000..74aef8f75
--- /dev/null
+++ b/make/config/nwi/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/nwi/jawt-x11.cfg b/make/config/nwi/jawt-x11.cfg
new file mode 100644
index 000000000..fdcf16bdb
--- /dev/null
+++ b/make/config/nwi/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/nwi/x11-CustomCCode.c b/make/config/nwi/x11-CustomCCode.c
new file mode 100755
index 000000000..793327c72
--- /dev/null
+++ b/make/config/nwi/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/nwi/x11-lib.cfg b/make/config/nwi/x11-lib.cfg
new file mode 100644
index 000000000..1448e7783
--- /dev/null
+++ b/make/config/nwi/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})
+