summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-11-21 07:33:19 +0100
committerSven Gothel <[email protected]>2019-11-21 07:33:19 +0100
commit9b52db212f8749b61e4cf775fe3244b94c5ae41c (patch)
tree74f1d9d9921c6a2acb668ea679a365a9e892400d /src/newt/classes/jogamp
parent10d3ba66b725fb44dc2c646c9ddc9816a4d72777 (diff)
Bug 1156: EGL-GBM: Cleanup Code & Replace Newt GBM implementation
GBM driver is now under egl/gbm subpackage and has been replaced by bcm_vc_iv boilerplate. Native code is reentrant capable and cleaned up. TODO: EGLDisplayUtil work with SharedResourceRunner
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java113
-rw-r--r--src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java121
-rw-r--r--src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java233
-rw-r--r--src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java62
-rw-r--r--src/newt/classes/jogamp/newt/driver/gbm/ScreenDriver.java88
-rw-r--r--src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java120
6 files changed, 467 insertions, 270 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java
new file mode 100644
index 000000000..e83e8e2a7
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2019 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.newt.driver.egl.gbm;
+
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
+import com.jogamp.opengl.GLProfile;
+
+import jogamp.newt.DisplayImpl;
+import jogamp.newt.NEWTJNILibLoader;
+import jogamp.opengl.egl.EGLDisplayUtil;
+
+public class DisplayDriver extends DisplayImpl {
+
+ static {
+ NEWTJNILibLoader.loadNEWT();
+ GLProfile.initSingleton();
+
+ if (!DisplayDriver.initIDs()) {
+ throw new NativeWindowException("Failed to initialize egl.gbm Display jmethodIDs");
+ }
+ if (!ScreenDriver.initIDs()) {
+ throw new NativeWindowException("Failed to initialize egl.gbm Screen jmethodIDs");
+ }
+ if (!WindowDriver.initIDs()) {
+ throw new NativeWindowException("Failed to initialize egl.gbm Window jmethodIDs");
+ }
+ drmHandle = initDrm();
+ }
+
+ static void validateDrm() {
+ if( 0 == drmHandle ) {
+ throw new NativeWindowException("Failed to initialize egl.gbm DRM handle");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ validateDrm();
+ }
+
+ private static void shutdownHook() {
+ freeDrm(drmHandle);
+ }
+
+ public DisplayDriver() {
+ gbmHandle = 0;
+ }
+
+ @Override
+ protected void createNativeImpl() {
+ validateDrm();
+ gbmHandle = OpenGBMDisplay0(drmHandle);
+ aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(gbmHandle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+ aDevice.open();
+ }
+
+ @Override
+ protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) {
+ aDevice.close();
+ CloseGBMDisplay0(gbmHandle);
+ gbmHandle = 0;
+ }
+
+ /* pp */ static final long getDrmHandle() { validateDrm(); return drmHandle; }
+ /* pp */ final long getGBMHandle() { return gbmHandle; }
+
+ @Override
+ protected void dispatchMessagesNative() {
+ DispatchMessages0();
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ private static native boolean initIDs();
+ private static native long initDrm();
+ private static native void freeDrm(long drmHandle);
+
+ private static native long OpenGBMDisplay0(long drmHandle);
+ private static native void CloseGBMDisplay0(long gbmHandle);
+
+ private static native void DispatchMessages0();
+
+ private static final long drmHandle;
+ private long gbmHandle;
+}
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
new file mode 100644
index 000000000..2ff7ab299
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2019 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.newt.driver.egl.gbm;
+
+import com.jogamp.nativewindow.DefaultGraphicsScreen;
+import com.jogamp.nativewindow.util.Rectangle;
+import com.jogamp.newt.MonitorDevice;
+import com.jogamp.newt.MonitorMode;
+import jogamp.newt.MonitorModeProps;
+import jogamp.newt.ScreenImpl;
+
+public class ScreenDriver extends ScreenImpl {
+ static {
+ DisplayDriver.initSingleton();
+ }
+
+ public ScreenDriver() {
+ }
+
+ @Override
+ protected void createNativeImpl() {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx);
+ initNative( DisplayDriver.getDrmHandle() );
+ }
+
+ @Override
+ protected void closeNativeImpl() { }
+
+ @Override
+ protected int validateScreenIndex(final int idx) {
+ return 0; // only one screen available
+ }
+
+ @Override
+ protected void collectNativeMonitorModesAndDevicesImpl(final MonitorModeProps.Cache cache) {
+ int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ];
+ int i = 0;
+ props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL;
+ props[i++] = cachedWidth; // width
+ props[i++] = cachedHeight; // height
+ props[i++] = ScreenImpl.default_sm_bpp; // FIXME
+ props[i++] = cachedVRrefresh * 100;
+ props[i++] = 0; // flags
+ props[i++] = 0; // mode_idx
+ props[i++] = 0; // rotation
+ final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0);
+
+ props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES];
+ i = 0;
+ props[i++] = props.length;
+ props[i++] = 0; // crt_idx
+ props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
+ props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
+ props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ props[i++] = 0; // rotated viewport x pixel-units
+ props[i++] = 0; // rotated viewport y pixel-units
+ props[i++] = cachedWidth; // rotated viewport width pixel-units
+ props[i++] = cachedHeight; // rotated viewport height pixel-units
+ props[i++] = 0; // rotated viewport x window-units
+ props[i++] = 0; // rotated viewport y window-units
+ props[i++] = cachedWidth; // rotated viewport width window-units
+ props[i++] = cachedHeight; // rotated viewport height window-units
+ MonitorModeProps.streamInMonitorDevice(cache, this, currentMode, null, cache.monitorModes, props, 0, null);
+ }
+
+ @Override
+ protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) {
+ return monitor.getSupportedModes().get(0);
+ }
+
+ @Override
+ protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) {
+ return false;
+ }
+
+ @Override
+ protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) {
+ viewport.set(0, 0, cachedWidth, cachedHeight);
+ viewportInWindowUnits.set(viewport);
+ }
+
+ /** Called from {@link #initNative(long)}. */
+ protected void notifyScreenMode(final int width, final int height, final int vrefresh) {
+ cachedWidth = width; // write to static field intended
+ cachedHeight = height; // write to static field intended
+ cachedVRrefresh = vrefresh;
+ }
+
+ private static int cachedWidth = 0;
+ private static int cachedHeight = 0;
+ private static int cachedVRrefresh = 0;
+
+ protected static native boolean initIDs();
+ protected native void initNative(long drmHandle);
+}
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java
new file mode 100644
index 000000000..41f1bc359
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java
@@ -0,0 +1,233 @@
+/**
+ * Copyright 2019 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.newt.driver.egl.gbm;
+
+import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
+import com.jogamp.nativewindow.Capabilities;
+import com.jogamp.nativewindow.GraphicsConfigurationFactory;
+import com.jogamp.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.VisualIDHolder;
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
+import com.jogamp.nativewindow.util.Point;
+import com.jogamp.nativewindow.util.Rectangle;
+import com.jogamp.nativewindow.util.RectangleImmutable;
+
+import jogamp.newt.WindowImpl;
+import jogamp.newt.driver.linux.LinuxEventDeviceTracker;
+import jogamp.newt.driver.linux.LinuxMouseTracker;
+
+public class WindowDriver extends WindowImpl {
+
+ static {
+ DisplayDriver.initSingleton();
+ }
+
+ public WindowDriver() {
+ linuxMouseTracker = LinuxMouseTracker.getSingleton();
+ linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton();
+
+ windowHandleClose = 0;
+ }
+
+ /**
+ * Clamp given rectangle to given screen bounds.
+ *
+ * @param screen
+ * @param rect the {@link RectangleImmutable} in pixel units
+ * @param definePosSize if {@code true} issue {@link #definePosition(int, int)} and {@link #defineSize(int, int)}
+ * if either has changed.
+ * @return If position or size has been clamped a new {@link RectangleImmutable} instance w/ clamped values
+ * will be returned, otherwise the given {@code rect} is returned.
+ */
+ private RectangleImmutable clampRect(final ScreenDriver screen, final RectangleImmutable rect, final boolean definePosSize) {
+ int x = rect.getX();
+ int y = rect.getY();
+ int w = rect.getWidth();
+ int h = rect.getHeight();
+ final int s_w = screen.getWidth();
+ final int s_h = screen.getHeight();
+ boolean modPos = false;
+ boolean modSize = false;
+ if( 0 > x ) {
+ x = 0;
+ modPos = true;
+ }
+ if( 0 > y ) {
+ y = 0;
+ modPos = true;
+ }
+ if( s_w < x + w ) {
+ if( 0 < x ) {
+ x = 0;
+ modPos = true;
+ }
+ if( s_w < w ) {
+ w = s_w;
+ modSize = true;
+ }
+ }
+ if( s_h < y + h ) {
+ if( 0 < y ) {
+ y = 0;
+ modPos = true;
+ }
+ if( s_h < h ) {
+ h = s_h;
+ modSize = true;
+ }
+ }
+ if( modPos || modSize ) {
+ if( definePosSize ) {
+ if( modPos ) {
+ definePosition(x, y);
+ }
+ if( modSize ) {
+ defineSize(w, h);
+ }
+ }
+ return new Rectangle(x, y, w, h);
+ } else {
+ return rect;
+ }
+ }
+
+ @Override
+ protected boolean canCreateNativeImpl() {
+ // clamp if required incl. redefinition of position and size
+ clampRect((ScreenDriver) getScreen(), new Rectangle(getX(), getY(), getWidth(), getHeight()), true);
+ return true; // default: always able to be created
+ }
+
+ @Override
+ protected void createNativeImpl() {
+ if (0 != getParentWindowHandle()) {
+ throw new RuntimeException("Window parenting not supported (yet)");
+ }
+
+ final ScreenDriver screen = (ScreenDriver) getScreen();
+ final DisplayDriver display = (DisplayDriver) screen.getDisplay();
+
+ // Create own screen/device resource instance allowing independent ownership,
+ // while still utilizing shared EGL resources.
+ final AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
+ // final AbstractGraphicsDevice aDevice = display.getGraphicsDevice();
+ // final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice();
+
+ final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED);
+ if (null == cfg) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ final Capabilities chosenCaps = (Capabilities) cfg.getChosenCapabilities();
+ // FIXME: Pass along opaque flag, since EGL doesn't determine it
+ if(capsRequested.isBackgroundOpaque() != chosenCaps.isBackgroundOpaque()) {
+ chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque());
+ }
+ setGraphicsConfiguration(cfg);
+ final long nativeWindowHandle = CreateWindow0(DisplayDriver.getDrmHandle(), display.getGBMHandle(),
+ getX(), getY(), getWidth(), getHeight(),
+ chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits());
+ if (nativeWindowHandle == 0) {
+ throw new NativeWindowException("Error creating egl window: "+cfg);
+ }
+ setWindowHandle(nativeWindowHandle);
+ if (0 == getWindowHandle()) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ windowHandleClose = nativeWindowHandle;
+
+ addWindowListener(linuxEventDeviceTracker);
+ addWindowListener(linuxMouseTracker);
+ focusChanged(false, true);
+ }
+
+ @Override
+ protected void closeNativeImpl() {
+ final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
+ final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice();
+
+ removeWindowListener(linuxMouseTracker);
+ removeWindowListener(linuxEventDeviceTracker);
+
+ if( 0 != windowHandleClose ) {
+ CloseWindow0(display.getGBMHandle(), windowHandleClose);
+ windowHandleClose = 0;
+ }
+
+ eglDevice.close();
+ }
+
+
+ @Override
+ protected void requestFocusImpl(final boolean reparented) {
+ focusChanged(false, true);
+ }
+
+ @Override
+ protected final int getSupportedReconfigMaskImpl() {
+ return minimumReconfigStateMask
+ // | STATE_MASK_UNDECORATED
+ // | STATE_MASK_ALWAYSONTOP
+ // | STATE_MASK_ALWAYSONBOTTOM
+ // | STATE_MASK_STICKY
+ // | STATE_MASK_RESIZABLE
+ // | STATE_MASK_MAXIMIZED_VERT
+ // | STATE_MASK_MAXIMIZED_HORZ
+ // | STATE_MASK_POINTERVISIBLE
+ // | STATE_MASK_POINTERCONFINED
+ ;
+ }
+
+ @Override
+ protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) {
+ final RectangleImmutable rect = clampRect((ScreenDriver) getScreen(), new Rectangle(x, y, width, height), false);
+ // reconfigure0 will issue position/size changed events if required
+ reconfigure0(getWindowHandle(), rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), flags);
+
+ return true;
+ }
+
+ @Override
+ protected Point getLocationOnScreenImpl(final int x, final int y) {
+ return new Point(x,y);
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ private final LinuxMouseTracker linuxMouseTracker;
+ private final LinuxEventDeviceTracker linuxEventDeviceTracker;
+ private long windowHandleClose;
+
+ protected static native boolean initIDs();
+ private native long CreateWindow0(long drmHandle, long gbmHandle, int x, int y, int width, int height, boolean opaque, int alphaBits);
+ private native void CloseWindow0(long gbmDisplay, long eglWindowHandle);
+ private native void reconfigure0(long eglWindowHandle, int x, int y, int width, int height, int flags);
+
+}
diff --git a/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java
deleted file mode 100644
index 00a1ca384..000000000
--- a/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java
+++ /dev/null
@@ -1,62 +0,0 @@
-//Copyright 2015 Erik De Rijcke
-//
-//Licensed under the Apache License,Version2.0(the"License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
-//
-//http://www.apache.org/licenses/LICENSE-2.0
-//
-//Unless required by applicable law or agreed to in writing,software
-//distributed under the License is distributed on an"AS IS"BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
-package jogamp.newt.driver.gbm;
-
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
-import jogamp.newt.DisplayImpl;
-import jogamp.newt.NEWTJNILibLoader;
-import jogamp.opengl.egl.EGLDisplayUtil;
-
-public class DisplayDriver extends DisplayImpl {
-
- static {
- NEWTJNILibLoader.loadNEWT();
- }
-
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
- @Override
- protected void createNativeImpl() {
- final EGLGraphicsDevice eglGraphicsDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(initGbm(), AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- eglGraphicsDevice.open();
-
- this.aDevice = eglGraphicsDevice;
- }
-
- private native long initGbm();
-// {
-//
-//
-// }
-
- @Override
- protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) {
- //DrmLibrary.INSTANCE.drmModeFreeConnector(this.connector);
- aDevice.close();
- destroyDisplay();
- //GbmLibrary.INSTANCE.gbm_device_destroy(dev);
- //CLibrary.INSTANCE.close(this.fd);
- }
-
- private native void destroyDisplay();
-
- @Override
- protected void dispatchMessagesNative() {
- //NA
- }
-}
diff --git a/src/newt/classes/jogamp/newt/driver/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/gbm/ScreenDriver.java
deleted file mode 100644
index 0066d42e4..000000000
--- a/src/newt/classes/jogamp/newt/driver/gbm/ScreenDriver.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package jogamp.newt.driver.gbm;
-
-import com.jogamp.nativewindow.DefaultGraphicsScreen;
-import com.jogamp.newt.MonitorDevice;
-import com.jogamp.newt.MonitorMode;
-import jogamp.newt.MonitorModeProps;
-import jogamp.newt.ScreenImpl;
-
-public class ScreenDriver extends ScreenImpl {
-
-
- @Override
- protected void createNativeImpl() {
- this.aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(),
- this.screen_idx);
- }
-
- @Override
- protected void closeNativeImpl() {
- }
-
- @Override
- protected int validateScreenIndex(final int idx) {
- return 0;
- }
-
- @Override
- protected void collectNativeMonitorModesAndDevicesImpl(final MonitorModeProps.Cache cache) {
-// DisplayDriver display = (DisplayDriver) getDisplay();
-// final drmModeConnector connector = display.getConnector();
-// final drmModeEncoder encoder = display.getEncoder();
-// //TODO collect info from init method
-// int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL];
-// int i = 0;
-// props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL;
-// props[i++] = connector.modes.hdisplay; // width
-// props[i++] = connector.modes.vdisplay; // height
-// props[i++] = ScreenImpl.default_sm_bpp; // FIXME
-// props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME
-// props[i++] = connector.modes.flags; // flags
-// props[i++] = 0; // mode_idx
-// props[i++] = 0; // rotation
-// final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null,
-// cache,
-// props,
-// 0);
-//
-// props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES];
-// i = 0;
-// props[i++] = props.length;
-// props[i++] = encoder.crtc_id; // crt_idx
-// props[i++] = 0; // is-clone
-// props[i++] = 1; // is-primary
-// props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
-// props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
-// props[i++] = 0; // rotated viewport x pixel-units
-// props[i++] = 0; // rotated viewport y pixel-units
-// props[i++] = connector.modes.hdisplay; // rotated viewport width pixel-units
-// props[i++] = connector.modes.vdisplay; // rotated viewport height pixel-units
-// props[i++] = 0; // rotated viewport x window-units
-// props[i++] = 0; // rotated viewport y window-units
-// props[i++] = connector.modes.hdisplay; // rotated viewport width window-units
-// props[i++] = connector.modes.vdisplay; // rotated viewport height window-units
-// MonitorModeProps.streamInMonitorDevice(cache,
-// this,
-// currentMode,
-// null,
-// cache.monitorModes,
-// props,
-// 0,
-// null);
- }
-
- @Override
- protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) {
- //TODO collect info from init method
-
- return null;
- }
-
- @Override
- protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor,
- final MonitorMode mode) {
- //TODO collect info from init method
-
- return false;
- }
-}
diff --git a/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java
deleted file mode 100644
index f4e86ed00..000000000
--- a/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java
+++ /dev/null
@@ -1,120 +0,0 @@
-//Copyright 2015 Erik De Rijcke
-//
-//Licensed under the Apache License,Version2.0(the"License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
-//
-//http://www.apache.org/licenses/LICENSE-2.0
-//
-//Unless required by applicable law or agreed to in writing,software
-//distributed under the License is distributed on an"AS IS"BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
-package jogamp.newt.driver.gbm;
-
-import com.jogamp.nativewindow.*;
-import com.jogamp.nativewindow.util.Insets;
-import com.jogamp.nativewindow.util.Point;
-import jogamp.newt.WindowImpl;
-import jogamp.newt.driver.linux.LinuxEventDeviceTracker;
-import jogamp.newt.driver.linux.LinuxMouseTracker;
-
-public class WindowDriver extends WindowImpl {
-
- private final LinuxMouseTracker linuxMouseTracker;
- private final LinuxEventDeviceTracker linuxEventDeviceTracker;
-
- public WindowDriver() {
- this.linuxMouseTracker = LinuxMouseTracker.getSingleton();
- this.linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton();
- }
-
-
- @Override
- protected final int getSupportedReconfigMaskImpl() {
- return minimumReconfigStateMask;
- }
-
- @Override
- protected void createNativeImpl() {
- if (0 != getParentWindowHandle()) {
- throw new RuntimeException("Window parenting not supported (yet)");
- }
-
- final ScreenDriver screen = (ScreenDriver) getScreen();
- final DisplayDriver display = (DisplayDriver) screen.getDisplay();
-
- // Create own screen/device resource instance allowing independent ownership,
- // while still utilizing shared EGL resources.
- final AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
- final AbstractGraphicsDevice aDevice = display.getGraphicsDevice();
- final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(aDevice, aScreen.getIndex());
-
- final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration(
- capsRequested, capsRequested, capabilitiesChooser, eglScreen, VisualIDHolder.VID_UNDEFINED);
- if (null == cfg) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- final Capabilities chosenCaps = (Capabilities) cfg.getChosenCapabilities();
- // FIXME: Pass along opaque flag, since EGL doesn't determine it
- if(capsRequested.isBackgroundOpaque() != chosenCaps.isBackgroundOpaque()) {
- chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque());
- }
- setGraphicsConfiguration(cfg);
- long nativeWindowHandle = createSurface();
- if (nativeWindowHandle == 0) {
- throw new NativeWindowException("Error creating egl window: "+cfg);
- }
- setWindowHandle(nativeWindowHandle);
- if (0 == getWindowHandle()) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
-
- addWindowListener(linuxEventDeviceTracker);
- addWindowListener(linuxMouseTracker);
- focusChanged(false, true);
- }
-
- private native long createSurface();
- //{
- // surface = GbmLibrary.INSTANCE.gbm_surface_create(dev,
-// mode.hdisplay, mode.vdisplay,
-// GbmLibrary.Constants.GBM_FORMAT_XRGB8888,
-// GBM_BO.GBM_BO_USE_SCANOUT | GBM_BO.GBM_BO_USE_RENDERING);
-// if (surface == null) {
-// throw new NativeWindowException("failed to create gbm surface");
-// }
-//
-// return 0;
- //}
-
- @Override
- protected void closeNativeImpl() {
- removeWindowListener(this.linuxMouseTracker);
- removeWindowListener(this.linuxEventDeviceTracker);
- }
-
- @Override
- protected void requestFocusImpl(final boolean force) {
- focusChanged(false,
- true);
- }
-
- @Override
- protected boolean reconfigureWindowImpl(final int x,
- final int y,
- final int width,
- final int height,
- final int flags) {
- return false;
- }
-
- @Override
- protected Point getLocationOnScreenImpl(final int x,
- final int y) {
- return new Point(x,
- y);
- }
-
-}