aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/sun/javafx
diff options
context:
space:
mode:
authorsg215889 <[email protected]>2009-07-27 19:25:33 -0700
committersg215889 <[email protected]>2009-07-27 19:25:33 -0700
commit8949675c20e3fc064d170b509391fadbdb970611 (patch)
treeb52aa71703fb3916ee97b03e72691b78d5569029 /src/newt/classes/com/sun/javafx
parent1b390d8cc911045e6cf8b581cc897b6da1f39f92 (diff)
Add Custom NativeWindow Type 'BroadcomEGL' (-Dnativewindow.ws.name=BroadcomEGL): 1st Draft of supporting broadcom's proprietary EGL mapping
Diffstat (limited to 'src/newt/classes/com/sun/javafx')
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Display.java7
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/NewtFactory.java5
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Screen.java2
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java2
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java)29
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java64
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java126
7 files changed, 212 insertions, 23 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/sun/javafx/newt/Display.java
index bdac08dab..04fdb0181 100755
--- a/src/newt/classes/com/sun/javafx/newt/Display.java
+++ b/src/newt/classes/com/sun/javafx/newt/Display.java
@@ -45,16 +45,15 @@ public abstract class Display implements Runnable {
{
Class displayClass = null;
if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- // displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay");
- displayClass = Class.forName("com.sun.javafx.newt.opengl.egl.EGLDisplay");
+ 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 + "\"");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
index b88e1e49e..dbae30a4b 100755
--- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
+++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
@@ -39,6 +39,8 @@ 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 {
@@ -50,7 +52,6 @@ public abstract class NewtFactory {
* Create a Display entity, incl native creation
*/
public static Display createDisplay(String name) {
- System.out.println("NewtFactory: NAME: " + name);
return Display.create(NativeWindowFactory.getNativeWindowType(true), name);
}
@@ -58,8 +59,6 @@ public abstract class NewtFactory {
* Create a Display entity using the given implementation type, incl native creation
*/
public static Display createDisplay(String type, String name) {
- System.out.println("NewtFactory: TYPE: " + type);
- System.out.println("NewtFactory: NAME: " + name);
return Display.create(type, name);
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/sun/javafx/newt/Screen.java
index 2566041a8..57ed34211 100755
--- a/src/newt/classes/com/sun/javafx/newt/Screen.java
+++ b/src/newt/classes/com/sun/javafx/newt/Screen.java
@@ -54,6 +54,8 @@ public abstract class Screen {
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 + "\"");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 36eafd32d..a1168d12d 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -74,6 +74,8 @@ public abstract class Window implements NativeWindow
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 + "\"");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java
index bebb7ccf2..abf9859c5 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java
@@ -31,7 +31,7 @@
*
*/
-package com.sun.javafx.newt.opengl.egl;
+package com.sun.javafx.newt.opengl.broadcom;
import com.sun.javafx.newt.*;
import com.sun.javafx.newt.impl.*;
@@ -39,12 +39,14 @@ import com.sun.opengl.impl.egl.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
-public class EGLDisplay extends Display {
+public class BCEGLDisplay extends Display {
static {
NativeLibLoader.loadNEWT();
- System.loadLibrary("EglUtil");
+ if (!BCEGLWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize BCEGLWindow jmethodIDs");
+ }
}
public static void initSingleton() {
@@ -52,27 +54,20 @@ public class EGLDisplay extends Display {
}
- public EGLDisplay() {
+ public BCEGLDisplay() {
}
protected void createNative() {
- try {
- int windowWidth = 1920, windowHeight = 1080;
- int width[] = { windowWidth };
- int height[] = { windowHeight };
- long eglDisplayHandle =
- EGL.EGLUtil_CreateDisplayByNative(windowWidth, windowHeight);
- long eglSurfaceHandle =
- EGL.EGLUtil_CreateWindowByNative(eglDisplayHandle, 1,
- width, 0, height, 0);
- } catch (Throwable th) {
- th.printStackTrace();
+ long handle = CreateDisplay(BCEGLScreen.fixedWidth, BCEGLScreen.fixedHeight);
+ if (handle == EGL.EGL_NO_DISPLAY) {
+ throw new NativeWindowException("BC EGL CreateDisplay failed");
}
+ aDevice = new EGLGraphicsDevice(handle);
}
protected void closeNative() {
if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
- EGL.eglTerminate(aDevice.getHandle());
+ DestroyDisplay(aDevice.getHandle());
}
}
@@ -80,6 +75,8 @@ public class EGLDisplay extends Display {
DispatchMessages();
}
+ private native long CreateDisplay(int width, int height);
+ private native void DestroyDisplay(long dpy);
private native void DispatchMessages();
}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java
new file mode 100755
index 000000000..165081cde
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java
@@ -0,0 +1,64 @@
+/*
+ * 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.opengl.broadcom;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+
+public class BCEGLScreen extends Screen {
+
+ static {
+ BCEGLDisplay.initSingleton();
+ }
+
+
+ public BCEGLScreen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ setScreenSize(fixedWidth, fixedHeight);
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ static final int fixedWidth = 1920;
+ static final int fixedHeight = 1080;
+}
+
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java
new file mode 100755
index 000000000..a91a91598
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java
@@ -0,0 +1,126 @@
+/*
+ * 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.opengl.broadcom;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.impl.*;
+import com.sun.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.nativewindow.NativeWindowException;
+
+public class BCEGLWindow extends Window {
+ static {
+ BCEGLDisplay.initSingleton();
+ }
+
+ public BCEGLWindow() {
+ }
+
+ protected void createNative(Capabilities caps) {
+ // just save the GLProfile here, create window later ..
+ glProfile = ((GLCapabilities)caps).getGLProfile();
+ }
+
+ protected void closeNative() {
+ if(0!=windowHandleClose) {
+ CloseWindow(getDisplayHandle(), windowHandleClose);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible) {
+ this.visible=visible;
+ if ( 0==windowHandle ) {
+ windowHandle = realizeWindow(true, width, height);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ }
+ clearEventMask();
+ }
+ }
+
+ public void setSize(int width, int height) {
+ if(0!=windowHandle) {
+ // n/a in BroadcomEGL
+ System.err.println("setSize n/a in BroadcomEGL with realized window");
+ } else {
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in BroadcomEGL
+ System.err.println("setPosition n/a in BroadcomEGL");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // n/a in BroadcomEGL
+ System.err.println("setFullscreen n/a in BroadcomEGL");
+ return false;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height);
+ private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle);
+
+
+ private long realizeWindow(boolean chromaKey, int width, int height) {
+ long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
+ if (0 == handle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ windowHandleClose = handle;
+ return handle;
+ }
+
+ private void windowCreated(int cfgID, int width, int height) {
+ this.width = width;
+ this.height = height;
+ config = EGLGraphicsConfiguration.create(glProfile, screen.getGraphicsScreen(), cfgID);
+ if (config == null) {
+ throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
+ }
+ }
+
+ private long windowHandleClose;
+ private GLProfile glProfile;
+}