summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-02 10:18:22 -0700
committerSven Gothel <[email protected]>2009-10-02 10:18:22 -0700
commit9fd3c095ce2117c3cb67169c97531cac78ab04c4 (patch)
treedd65dac2d4b406b7e47e92afee880d7e56cbebc5 /src
parentcd45d13bbd0ff1da3dac678a6461b5fdce2783c1 (diff)
NativeWindowFactory:
- If property 'nativewindow.ws.name' is set, use it as the custom windowing type returned by getNativeWindowType(true) NEWT: - Using NativeWindowFactory's property 'nativewindow.ws.name' as a package name for custom NEWT windowing imlementations, ie: -Dnativewindow.ws.name=com.sun.javafx.newt.intel.gdl -Dnativewindow.ws.name=com.sun.javafx.newt.broadcom.egl This allows far more flexibility to add custom impl. - Add Intel-GDL, define property 'useIntelGDL' to build the native part. Intel GDL is impl in the package 'com.sun.javafx.newt.intel.gdl' JOGL: - All impl. of 'createGLDrawable(..)', which were actually creating onscreen drawable only, were renamed to 'createOnscreenDrawable(..)'. - GLDrawableFactoryImpl impl. 'createGLDrawable(..)' now and dispatches to the actual create* methods in respect to the Capabilities, ie onscreen, pbuffer and offscreen. - GLDrawableFactory: - If using a native ES profile -> EGLDrawableFactory - If existing native OS factory -> Use that .. - Else -> Use EGLDrawableFactory, if available
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java42
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java2
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java3
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java13
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java10
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Display.java30
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/NewtFactory.java13
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Screen.java30
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java30
-rw-r--r--src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java104
-rw-r--r--src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java68
-rw-r--r--src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java135
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java)13
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java)9
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java)17
-rwxr-xr-xsrc/newt/native/BroadcomEGL.c16
-rw-r--r--src/newt/native/IntelGDL.c344
20 files changed, 798 insertions, 97 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 0d540647a..4597a5078 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -54,6 +54,45 @@ import java.lang.reflect.*;
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
+ //---------------------------------------------------------------------------
+ // Dispatching GLDrawable construction in respect to the NativeWindow Capabilities
+ //
+ public GLDrawable createGLDrawable(NativeWindow target) {
+ if (target == null) {
+ throw new IllegalArgumentException("Null target");
+ }
+ AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ target = NativeWindowFactory.getNativeWindow(target, config);
+ GLCapabilities caps = (GLCapabilities) target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ GLDrawable result = null;
+ if(caps.isOnscreen()) {
+ if(caps.isPBuffer()) {
+ throw new IllegalArgumentException("Onscreen target can't be PBuffer: "+caps);
+ }
+ result = createOnscreenDrawable(target);
+ } else {
+ if(caps.isPBuffer() && canCreateGLPbuffer()) {
+ // PBUFFER
+ result = createGLPbuffer(caps,
+ null /* GLCapabilitiesChooser */,
+ target.getWidth(),
+ target.getHeight(),
+ null /* shareContext */ ) ;
+
+ }
+ if(null==result) {
+ result = createOffscreenDrawable(caps,
+ null /* GLCapabilitiesChooser */,
+ target.getWidth(),
+ target.getHeight());
+ }
+ }
+ if(DEBUG) {
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable: "+result);
+ }
+ return result;
+ }
+
/** Creates a (typically software-accelerated) offscreen GLDrawable
used to implement the fallback rendering path of the
GLJPanel. */
@@ -62,6 +101,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
int width,
int height);
+ /** Creates a (typically hw-accelerated) onscreen GLDrawable. */
+ public abstract GLDrawableImpl createOnscreenDrawable(NativeWindow target);
+
protected GLDrawableFactoryImpl() {
super();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index aabc6f263..4265ee8fb 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -127,7 +127,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
eglConfig.updateGraphicsConfiguration();
}
} else {
- throw new GLException("EGLGraphicsConfiguration doesn't carry a EGLGraphicsDevice: "+aConfig);
+ throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
}
} else {
// create a new EGL config ..
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 7af45d683..cf466ef2c 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -61,8 +61,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
super();
}
- public GLDrawable createGLDrawable(NativeWindow target) {
- target = NativeWindowFactory.getNativeWindow(target, null);
+ public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
+ if (target == null) {
+ throw new IllegalArgumentException("Null target");
+ }
return new EGLOnscreenDrawable(this, target);
}
@@ -81,9 +83,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
- if (!canCreateGLPbuffer()) {
- throw new GLException("Pbuffer support not available with this EGL implementation");
- }
EGLPbufferDrawable pbufferDrawable = new EGLPbufferDrawable(this, capabilities, chooser,
initialWidth,
initialHeight);
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 7bcc4ca14..024b69629 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -62,12 +62,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
} catch (Throwable t) { }
}
- public GLDrawable createGLDrawable(NativeWindow target) {
+ public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- NativeWindowFactory factory = NativeWindowFactory.getFactory(target.getClass());
- target = NativeWindowFactory.getNativeWindow(target, null);
return new MacOSXOnscreenCGLDrawable(this, target);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 4d965e52b..4e02dfe92 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -71,11 +71,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
loadOpenGL32Library();
}
- public GLDrawable createGLDrawable(NativeWindow target) {
+ public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- target = NativeWindowFactory.getNativeWindow(target, null);
return new WindowsOnscreenWGLDrawable(this, target);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index acca5fe81..762ed5cac 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -65,11 +65,10 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
} catch (Throwable t) { }
}
- public GLDrawable createGLDrawable(NativeWindow target) {
+ public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- target = NativeWindowFactory.getNativeWindow(target, null);
return new X11OnscreenGLXDrawable(this, target);
}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 1a18a60f8..48a8fe9e0 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -126,7 +126,7 @@ public abstract class GLDrawableFactory {
} else {
// may use egl*Factory ..
if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - No Native OS Factory for: "+nativeOSType);
+ System.err.println("GLDrawableFactory.static - No native OS Factory for: "+nativeOSType+"; May use EGLDrawableFactory, if available." );
}
}
}
@@ -157,11 +157,16 @@ public abstract class GLDrawableFactory {
protected static GLDrawableFactory getFactoryImpl(String glProfileImplName) throws GLException {
if ( GLProfile.usesNativeGLES(glProfileImplName) ) {
- if(null==eglFactory) throw new GLException("GLDrawableFactory unavailable for EGL: "+glProfileImplName);
+ if(null==eglFactory) throw new GLException("EGLDrawableFactory unavailable: "+glProfileImplName);
return eglFactory;
}
- if(null==nativeOSFactory) throw new GLException("GLDrawableFactory unavailable for Native Platform "+nativeOSType);
- return nativeOSFactory;
+ if(null!=nativeOSFactory) {
+ return nativeOSFactory;
+ }
+ if(null!=eglFactory) {
+ return eglFactory;
+ }
+ throw new GLException("No native platform GLDrawableFactory, nor EGLDrawableFactory available: "+glProfileImplName);
}
/** Shuts down this GLDrawableFactory, releasing resources
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index cbd485649..0710bc24c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -85,7 +85,7 @@ public abstract class NativeWindowFactory {
} else if (osNameLowerCase.startsWith("wind")) {
return TYPE_WINDOWS;
} else if (osNameLowerCase.startsWith("mac os x") ||
- osNameLowerCase.startsWith("darwin")) {
+ osNameLowerCase.startsWith("darwin")) {
return TYPE_MACOSX;
} else if (osNameLowerCase.equals("awt")) {
return TYPE_AWT;
@@ -100,12 +100,14 @@ public abstract class NativeWindowFactory {
// Gather the windowing OS first
AccessControlContext acc = AccessController.getContext();
nativeOSNamePure = Debug.getProperty("os.name", false, acc);
+ nativeWindowingTypePure = _getNativeWindowingType(nativeOSNamePure.toLowerCase());
nativeOSNameCustom = Debug.getProperty("nativewindow.ws.name", true, acc);
if(null==nativeOSNameCustom||nativeOSNameCustom.length()==0) {
- nativeOSNameCustom = nativeOSNamePure;
+ nativeOSNameCustom = nativeOSNamePure;
+ nativeWindowingTypeCustom = nativeWindowingTypePure;
+ } else {
+ nativeWindowingTypeCustom = nativeOSNameCustom;
}
- nativeWindowingTypePure = _getNativeWindowingType(nativeOSNamePure.toLowerCase());
- nativeWindowingTypeCustom = _getNativeWindowingType(nativeOSNameCustom.toLowerCase());
registeredFactories = Collections.synchronizedMap(new HashMap());
diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/sun/javafx/newt/Display.java
index 38d0021ce..0be8aedbc 100755
--- a/src/newt/classes/com/sun/javafx/newt/Display.java
+++ b/src/newt/classes/com/sun/javafx/newt/Display.java
@@ -43,21 +43,21 @@ public abstract class Display implements Runnable {
private static Class getDisplayClass(String type)
throws ClassNotFoundException
{
- Class displayClass = null;
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.windows.WindowsDisplay");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.macosx.MacDisplay");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay");
- } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLDisplay");
- } else {
- throw new RuntimeException("Unknown display type \"" + type + "\"");
+ Class displayClass = NewtFactory.getCustomClass(type, "Display");
+ if(null==displayClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.windows.WindowsDisplay");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.macosx.MacDisplay");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay");
+ } else {
+ throw new RuntimeException("Unknown display type \"" + type + "\"");
+ }
}
return displayClass;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
index 2f719110d..c4180eb46 100755
--- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
+++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
@@ -39,8 +39,6 @@ import java.util.Iterator;
import com.sun.nativewindow.impl.jvm.JVMUtil;
public abstract class NewtFactory {
- public static final String TYPE_BROADCOM_EGL = "BroadcomEGL";
-
// Work-around for initialization order problems on Mac OS X
// between native Newt and (apparently) Fmod
static {
@@ -48,6 +46,17 @@ public abstract class NewtFactory {
Window.init(NativeWindowFactory.getNativeWindowType(true));
}
+ static Class getCustomClass(String packageName, String classBaseName) {
+ Class clazz = null;
+ if(packageName!=null || classBaseName!=null) {
+ String clazzName = packageName + "." + classBaseName ;
+ try {
+ clazz = Class.forName(clazzName);
+ } catch (Throwable t) {}
+ }
+ return clazz;
+ }
+
/**
* Create a Display entity, incl native creation
*/
diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/sun/javafx/newt/Screen.java
index 57ed34211..e347a69c2 100755
--- a/src/newt/classes/com/sun/javafx/newt/Screen.java
+++ b/src/newt/classes/com/sun/javafx/newt/Screen.java
@@ -43,21 +43,21 @@ public abstract class Screen {
private static Class getScreenClass(String type)
throws ClassNotFoundException
{
- Class screenClass = null;
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDScreen");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.windows.WindowsScreen");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.macosx.MacScreen");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen");
- } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLScreen");
- } else {
- throw new RuntimeException("Unknown window type \"" + type + "\"");
+ Class screenClass = NewtFactory.getCustomClass(type, "Screen");
+ if(null==screenClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDScreen");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.windows.WindowsScreen");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.macosx.MacScreen");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen");
+ } else {
+ throw new RuntimeException("Unknown window type \"" + type + "\"");
+ }
}
return screenClass;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 2b82cb887..8b78943d4 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -66,21 +66,21 @@ public abstract class Window implements NativeWindow
private static Class getWindowClass(String type)
throws ClassNotFoundException
{
- Class windowClass = null;
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDWindow");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.macosx.MacWindow");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow");
- } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLWindow");
- } else {
- throw new NativeWindowException("Unknown window type \"" + type + "\"");
+ Class windowClass = NewtFactory.getCustomClass(type, "Window");
+ if(null==windowClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDWindow");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.macosx.MacWindow");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow");
+ } else {
+ throw new NativeWindowException("Unknown window type \"" + type + "\"");
+ }
}
return windowClass;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java
new file mode 100644
index 000000000..b1f0ac6d2
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.intel.gdl;
+
+import com.sun.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+
+public class Display extends com.sun.javafx.newt.Display {
+ static int initCounter = 0;
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!Screen.initIDs()) {
+ throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs");
+ }
+ if (!Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize GDL Window jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public Display() {
+ }
+
+ protected void createNative() {
+ synchronized(Display.class) {
+ if(0==initCounter) {
+ displayHandle = CreateDisplay();
+ if(0==displayHandle) {
+ throw new NativeWindowException("Couldn't initialize GDL Display");
+ }
+ }
+ initCounter++;
+ }
+ aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, displayHandle);
+ }
+
+ protected void closeNative() {
+ if(0==displayHandle) {
+ throw new NativeWindowException("displayHandle null; initCnt "+initCounter);
+ }
+ synchronized(Display.class) {
+ if(initCounter>0) {
+ initCounter--;
+ if(0==initCounter) {
+ DestroyDisplay(displayHandle);
+ }
+ }
+ }
+ }
+
+ protected void dispatchMessages() {
+ if(0!=displayHandle) {
+ DispatchMessages(displayHandle, focusedWindow);
+ }
+ }
+
+ protected void setFocus(Window focus) {
+ focusedWindow = focus;
+ }
+
+ private long displayHandle = 0;
+ private Window focusedWindow = null;
+ private native long CreateDisplay();
+ private native void DestroyDisplay(long displayHandle);
+ private native void DispatchMessages(long displayHandle, Window focusedWindow);
+}
+
diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java
new file mode 100644
index 000000000..83d9074e2
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.intel.gdl;
+
+import com.sun.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+
+public class Screen extends com.sun.javafx.newt.Screen {
+
+ static {
+ Display.initSingleton();
+ }
+
+ public Screen() {
+ }
+
+ protected void createNative(int index) {
+ AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice();
+ GetScreenInfo(adevice.getHandle(), index);
+ aScreen = new DefaultGraphicsScreen(adevice, index);
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native void GetScreenInfo(long displayHandle, int screen_idx);
+
+ // called by GetScreenInfo() ..
+ private void screenCreated(int width, int height) {
+ setScreenSize(width, height);
+ }
+}
+
diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java
new file mode 100644
index 000000000..2c68a2054
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.intel.gdl;
+
+import javax.media.nativewindow.*;
+
+public class Window extends com.sun.javafx.newt.Window {
+ static {
+ Display.initSingleton();
+ }
+
+ public Window() {
+ }
+
+ static long nextWindowHandle = 1;
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new NativeWindowException("GDL Window does not support window parenting");
+ }
+ AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
+ AbstractGraphicsDevice aDevice = screen.getDisplay().getGraphicsDevice();
+
+ config = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration(caps, null, aScreen);
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+
+ synchronized(Window.class) {
+ windowHandle = nextWindowHandle++;
+ }
+ }
+
+ protected void closeNative() {
+ if(0!=surfaceHandle) {
+ synchronized(Window.class) {
+ CloseSurface(getDisplayHandle(), surfaceHandle);
+ }
+ surfaceHandle = 0;
+ ((Display)screen.getDisplay()).setFocus(null);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible) {
+ this.visible=visible;
+ if(visible && 0==surfaceHandle) {
+ synchronized(Window.class) {
+ AbstractGraphicsDevice aDevice = screen.getDisplay().getGraphicsDevice();
+ surfaceHandle = CreateSurface(aDevice.getHandle(), width, height);
+ }
+ if (surfaceHandle == 0) {
+ throw new NativeWindowException("Error creating window");
+ }
+ ((Display)screen.getDisplay()).setFocus(this);
+ }
+ }
+ }
+
+ public void setSize(int width, int height) {
+ if(0!=surfaceHandle) {
+ System.err.println("setSize "+width+"x"+height+" n/a in IntelGDL _after_ surface established");
+ } else {
+ Screen screen = (Screen) getScreen();
+ if(width>screen.getWidth() || height>screen.getHeight()) {
+ width=screen.getWidth();
+ height=screen.getHeight();
+ }
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in IntelGDL
+ System.err.println("setPosition n/a in IntelGDL");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // n/a in IntelGDL
+ System.err.println("setFullscreen n/a in IntelGDL");
+ return false;
+ }
+
+ public void requestFocus() {
+ ((Display)screen.getDisplay()).setFocus(this);
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateSurface(long displayHandle, int width, int height);
+ private native void CloseSurface(long displayHandle, long surfaceHandle);
+
+
+ private void updateSize(int width, int height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ private long surfaceHandle;
+}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java
index dbe126c91..debe9e9b9 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java
@@ -31,21 +31,20 @@
*
*/
-package com.sun.javafx.newt.opengl.broadcom;
+package com.sun.javafx.newt.opengl.broadcom.egl;
-import com.sun.javafx.newt.*;
import com.sun.javafx.newt.impl.*;
import com.sun.opengl.impl.egl.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
-public class BCEGLDisplay extends Display {
+public class Display extends com.sun.javafx.newt.Display {
static {
NativeLibLoader.loadNEWT();
- if (!BCEGLWindow.initIDs()) {
- throw new NativeWindowException("Failed to initialize BCEGLWindow jmethodIDs");
+ if (!Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs");
}
}
@@ -54,11 +53,11 @@ public class BCEGLDisplay extends Display {
}
- public BCEGLDisplay() {
+ public Display() {
}
protected void createNative() {
- long handle = CreateDisplay(BCEGLScreen.fixedWidth, BCEGLScreen.fixedHeight);
+ long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
if (handle == EGL.EGL_NO_DISPLAY) {
throw new NativeWindowException("BC EGL CreateDisplay failed");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java
index 165081cde..28f7211c3 100755
--- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java
@@ -31,20 +31,19 @@
*
*/
-package com.sun.javafx.newt.opengl.broadcom;
+package com.sun.javafx.newt.opengl.broadcom.egl;
-import com.sun.javafx.newt.*;
import com.sun.javafx.newt.impl.*;
import javax.media.nativewindow.*;
-public class BCEGLScreen extends Screen {
+public class Screen extends com.sun.javafx.newt.Screen {
static {
- BCEGLDisplay.initSingleton();
+ Display.initSingleton();
}
- public BCEGLScreen() {
+ public Screen() {
}
protected void createNative(int index) {
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java
index e3d7c2042..7d087416c 100755
--- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java
@@ -31,9 +31,8 @@
*
*/
-package com.sun.javafx.newt.opengl.broadcom;
+package com.sun.javafx.newt.opengl.broadcom.egl;
-import com.sun.javafx.newt.*;
import com.sun.javafx.newt.impl.*;
import com.sun.opengl.impl.egl.*;
import javax.media.nativewindow.*;
@@ -41,12 +40,12 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.nativewindow.NativeWindowException;
-public class BCEGLWindow extends Window {
+public class Window extends com.sun.javafx.newt.Window {
static {
- BCEGLDisplay.initSingleton();
+ Display.initSingleton();
}
- public BCEGLWindow() {
+ public Window() {
}
protected void createNative(long parentWindowHandle, Capabilities caps) {
@@ -88,10 +87,10 @@ public class BCEGLWindow extends Window {
void setSizeImpl(int width, int height) {
if(0!=windowHandle) {
// n/a in BroadcomEGL
- System.err.println("BCEGLWindow.setSizeImpl n/a in BroadcomEGL with realized window");
+ System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
} else {
if(DEBUG_IMPLEMENTATION) {
- Exception e = new Exception("BCEGLWindow.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ Exception e = new Exception("BCEGL Window.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
e.printStackTrace();
}
this.width = width;
@@ -130,7 +129,7 @@ public class BCEGLWindow extends Window {
private long realizeWindow(boolean chromaKey, int width, int height) {
if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGLWindow.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
+ System.out.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
}
long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
if (0 == handle) {
@@ -149,7 +148,7 @@ public class BCEGLWindow extends Window {
throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
}
if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGLWindow.windowCreated(): 0x"+Integer.toHexString(cfgID)+", "+width+"x"+height+", "+config);
+ System.out.println("BCEGL Window.windowCreated(): 0x"+Integer.toHexString(cfgID)+", "+width+"x"+height+", "+config);
}
}
diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c
index d529de667..55688f9d1 100755
--- a/src/newt/native/BroadcomEGL.c
+++ b/src/newt/native/BroadcomEGL.c
@@ -41,7 +41,7 @@
#include <stdio.h>
#include <string.h>
-#include "com_sun_javafx_newt_opengl_broadcom_BCEGLWindow.h"
+#include "com_sun_javafx_newt_opengl_broadcom_egl_Window.h"
#include "EventListener.h"
#include "MouseEvent.h"
@@ -72,7 +72,7 @@ static jmethodID windowCreatedID = NULL;
* Display
*/
-JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_DispatchMessages
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_DispatchMessages
(JNIEnv *env, jobject obj)
{
// FIXME: n/a
@@ -80,7 +80,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_Dis
(void) obj;
}
-JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_CreateDisplay
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_CreateDisplay
(JNIEnv *env, jobject obj, jint width, jint height)
{
(void) env;
@@ -94,7 +94,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_Cr
return (jlong) (intptr_t) dpy;
}
-JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_DestroyDisplay
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_DestroyDisplay
(JNIEnv *env, jobject obj, jlong display)
{
EGLDisplay dpy = (EGLDisplay)(intptr_t)display;
@@ -111,7 +111,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_Des
* Window
*/
-JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_initIDs
+JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_initIDs
(JNIEnv *env, jclass clazz)
{
windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V");
@@ -123,7 +123,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_
return JNI_TRUE;
}
-JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_CreateWindow
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_CreateWindow
(JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height)
{
EGLDisplay dpy = (EGLDisplay)(intptr_t)display;
@@ -167,7 +167,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Cre
return (jlong) (intptr_t) window;
}
-JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_CloseWindow
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_CloseWindow
(JNIEnv *env, jobject obj, jlong display, jlong window)
{
EGLDisplay dpy = (EGLDisplay) (intptr_t) display;
@@ -180,7 +180,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Clos
DBG_PRINT( "[CloseWindow] X\n");
}
-JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_SwapWindow
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_SwapWindow
(JNIEnv *env, jobject obj, jlong display, jlong window)
{
EGLDisplay dpy = (EGLDisplay) (intptr_t) display;
diff --git a/src/newt/native/IntelGDL.c b/src/newt/native/IntelGDL.c
new file mode 100644
index 000000000..44eccbc79
--- /dev/null
+++ b/src/newt/native/IntelGDL.c
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+#include <inttypes.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "com_sun_javafx_newt_intel_gdl_Display.h"
+#include "com_sun_javafx_newt_intel_gdl_Screen.h"
+#include "com_sun_javafx_newt_intel_gdl_Window.h"
+
+#include "EventListener.h"
+#include "MouseEvent.h"
+#include "KeyEvent.h"
+
+#include <gdl.h>
+#include <gdl_version.h>
+
+#define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+ #define DBG_PRINT(...) fprintf(stdout, "*** INTEL-GDL: " __VA_ARGS__)
+#else
+ #define DBG_PRINT(...)
+#endif
+
+static jmethodID screenCreatedID = NULL;
+static jmethodID updateSizeID = NULL;
+
+#define NUM_PLANES 5
+static jobject newtWindows[NUM_PLANES] = { NULL, NULL, NULL, NULL, NULL } ;
+static gdl_plane_id_t planes[NUM_PLANES] = { GDL_PLANE_ID_UPP_A, GDL_PLANE_ID_UPP_B, GDL_PLANE_ID_UPP_C, GDL_PLANE_ID_UPP_D, GDL_PLANE_ID_UPP_E };
+
+static int getWindowIdx(jobject win) {
+ int i;
+ for(i=0; i<NUM_PLANES && newtWindows[i]!=win; i++) ;
+ return (i<NUM_PLANES)?i:-1;
+}
+static int getPlaneIdx(gdl_plane_id_t plane) {
+ int i;
+ for(i=0; i<NUM_PLANES && planes[i]!=plane; i++) ;
+ return (i<NUM_PLANES)?i:-1;
+}
+
+static jobject getNewtWindow(gdl_plane_id_t plane) {
+ int idx = getPlaneIdx(plane);
+ if(idx>0) {
+ return newtWindows[idx];
+ }
+ return NULL;
+}
+static gdl_plane_id_t getPlane(jobject win) {
+ int idx = getWindowIdx(win);
+ if(idx>0) {
+ return planes[idx];
+ }
+ return GDL_PLANE_ID_UNDEFINED;
+}
+
+static gdl_plane_id_t allocPlane(JNIEnv *env, jobject newtWindow) {
+ int i = getWindowIdx(NULL);
+ if (i<NUM_PLANES) {
+ newtWindows[i] = (*env)->NewGlobalRef(env, newtWindow);
+ return planes[i];
+ }
+ return GDL_PLANE_ID_UNDEFINED;
+}
+static void freePlane(JNIEnv *env, gdl_plane_id_t plane) {
+ int i = getPlaneIdx(plane);
+ if (i<NUM_PLANES) {
+ if(NULL!=newtWindows[i]) {
+ (*env)->DeleteGlobalRef(env, newtWindows[i]);
+ newtWindows[i] = NULL;;
+ }
+ }
+}
+
+static void JNI_ThrowNew(JNIEnv *env, const char *throwable, const char* message) {
+ jclass throwableClass = (*env)->FindClass(env, throwable);
+ if (throwableClass == NULL) {
+ (*env)->FatalError(env, "Failed to load throwable class");
+ }
+
+ if ((*env)->ThrowNew(env, throwableClass, message) != 0) {
+ (*env)->FatalError(env, "Failed to throw throwable");
+ }
+}
+
+
+/**
+ * Display
+ */
+
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_DispatchMessages
+ (JNIEnv *env, jobject obj, jlong displayHandle, jobject focusedWindow)
+{
+ // FIXME: n/a
+ (void) env;
+ (void) obj;
+ (void) displayHandle;
+ /**
+ gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle;
+ jobject newtWin = getNewtWindow(plane);
+ if(NULL!=newtWin) {
+ // here we can dispatch messages .. etc
+ } */
+}
+
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_CreateDisplay
+ (JNIEnv *env, jobject obj)
+{
+ gdl_ret_t retval;
+ gdl_driver_info_t * p_driver_info = NULL;
+
+ (void) env;
+ (void) obj;
+
+ DBG_PRINT("[CreateDisplay]\n");
+
+ retval = gdl_init(0);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_init");
+ return (jlong)0;
+ }
+
+ p_driver_info = calloc(sizeof(gdl_driver_info_t), 1);
+ retval = gdl_get_driver_info(p_driver_info);
+ if (retval != GDL_SUCCESS) {
+ free(p_driver_info);
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_get_driver_info");
+ return (jlong)0;
+ }
+ DBG_PRINT("[gdl_get_driver_info: major %d minor %d vers %d build %d flags %x name %s size %d avail %d]\n",
+ p_driver_info->header_version_major, p_driver_info->header_version_minor,
+ p_driver_info->gdl_version, p_driver_info->build_tag, p_driver_info->flags,
+ p_driver_info->name, p_driver_info->mem_size, p_driver_info->mem_avail);
+
+
+ return (jlong) (intptr_t) p_driver_info;
+}
+
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_DestroyDisplay
+ (JNIEnv *env, jobject obj, jlong displayHandle)
+{
+ gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle;
+ (void) env;
+ (void) obj;
+
+ if(NULL!=p_driver_info) {
+ gdl_close();
+ free(p_driver_info);
+ }
+
+ DBG_PRINT("[DestroyDisplay] X\n");
+}
+
+/**
+ * Screen
+ */
+
+JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_intel_gdl_Screen_initIDs
+ (JNIEnv *env, jclass clazz)
+{
+ screenCreatedID = (*env)->GetMethodID(env, clazz, "screenCreated", "(II)V");
+ if (screenCreatedID == NULL) {
+ DBG_PRINT("initIDs failed\n" );
+ return JNI_FALSE;
+ }
+ DBG_PRINT("initIDs ok\n" );
+ return JNI_TRUE;
+}
+
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Screen_GetScreenInfo
+ (JNIEnv *env, jobject obj, jlong displayHandle, jint idx)
+{
+ gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle;
+ gdl_display_info_t display_info;
+ gdl_display_id_t id;
+ gdl_ret_t retval;
+
+ switch(idx) {
+ case 1:
+ id = GDL_DISPLAY_ID_1;
+ break;
+ default:
+ id = GDL_DISPLAY_ID_0;
+ }
+
+ retval = gdl_get_display_info(id, &display_info);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_get_display_info");
+ return;
+ }
+
+ DBG_PRINT("[gdl_get_display_info: width %d height %d]\n",
+ display_info.tvmode.width, display_info.tvmode.height);
+
+ (*env)->CallVoidMethod(env, obj, screenCreatedID, (jint)display_info.tvmode.width, (jint)display_info.tvmode.height);
+}
+
+/**
+ * Window
+ */
+
+JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_initIDs
+ (JNIEnv *env, jclass clazz)
+{
+ updateSizeID = (*env)->GetMethodID(env, clazz, "updateSize", "(II)V");
+ if (updateSizeID == NULL) {
+ DBG_PRINT("initIDs failed\n" );
+ return JNI_FALSE;
+ }
+ DBG_PRINT("initIDs ok\n" );
+ return JNI_TRUE;
+}
+
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CreateSurface
+ (JNIEnv *env, jobject obj, jlong displayHandle, jint width, jint height) {
+
+ gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle;
+ gdl_ret_t retval;
+ gdl_pixel_format_t pixelFormat = GDL_PF_ARGB_32;
+ gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB;
+ gdl_rectangle_t srcRect, dstRect;
+
+ (void) env;
+ (void) obj;
+
+ gdl_plane_id_t plane = allocPlane(env, obj);
+ if(plane == GDL_PLANE_ID_UNDEFINED) {
+ DBG_PRINT("CreateSurface failed, couldn't alloc plane\n" );
+ return 0;
+ }
+
+ DBG_PRINT("[CreateSurface: width %d height %d plane %d]\n", width, height, plane);
+
+ srcRect.origin.x = 0;
+ srcRect.origin.y = 0;
+ srcRect.width = width;
+ srcRect.height = height;
+
+ dstRect.origin.x = 0;
+ dstRect.origin.y = 0;
+ dstRect.width = width;
+ dstRect.height = height;
+
+ retval = gdl_plane_reset(plane);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_reset");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ retval = gdl_plane_config_begin(plane);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_config_begin");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ retval = gdl_plane_set_attr(GDL_PLANE_SRC_COLOR_SPACE, &colorSpace);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_set_attr color space");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ retval = gdl_plane_set_attr(GDL_PLANE_PIXEL_FORMAT, &pixelFormat);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_set_attr pixel format");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ retval = gdl_plane_set_attr(GDL_PLANE_DST_RECT, &dstRect);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_set_attr dstRect");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ retval = gdl_plane_set_attr(GDL_PLANE_SRC_RECT, &srcRect);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_set_attr srcRect");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ retval = gdl_plane_config_end(GDL_FALSE);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_config_end");
+ freePlane(env, plane);
+ return (jlong)0;
+ }
+
+ (*env)->CallVoidMethod(env, obj, updateSizeID, (jint)width, (jint)height);
+
+ DBG_PRINT("[CreateSurface] returning plane %d\n", plane);
+
+ return (jlong) (intptr_t) plane;
+}
+
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CloseSurface
+ (JNIEnv *env, jobject obj, jlong display, jlong surface)
+{
+ gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ;
+ freePlane(env, plane);
+
+ DBG_PRINT("[CloseSurface] plane %d\n", plane);
+}
+
+