From 9b52db212f8749b61e4cf775fe3244b94c5ae41c Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Thu, 21 Nov 2019 07:33:19 +0100
Subject: 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
---
 .../jogamp/newt/driver/egl/gbm/DisplayDriver.java  | 113 ++++++++++
 .../jogamp/newt/driver/egl/gbm/ScreenDriver.java   | 121 +++++++++++
 .../jogamp/newt/driver/egl/gbm/WindowDriver.java   | 233 ++++++++++++++++++++
 .../jogamp/newt/driver/gbm/DisplayDriver.java      |  62 ------
 .../jogamp/newt/driver/gbm/ScreenDriver.java       |  88 --------
 .../jogamp/newt/driver/gbm/WindowDriver.java       | 120 -----------
 src/newt/native/bcm_vc_iv.c                        |   4 -
 src/newt/native/egl_gbm.c                          | 237 +++++++++++++++++++++
 src/newt/native/gbm.c                              | 147 -------------
 9 files changed, 704 insertions(+), 421 deletions(-)
 create mode 100644 src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java
 create mode 100644 src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
 create mode 100644 src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java
 delete mode 100644 src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java
 delete mode 100644 src/newt/classes/jogamp/newt/driver/gbm/ScreenDriver.java
 delete mode 100644 src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java
 create mode 100644 src/newt/native/egl_gbm.c
 delete mode 100644 src/newt/native/gbm.c

(limited to 'src/newt')

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);
-    }
-
-}
diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c
index dc753157e..9e6a41a1d 100644
--- a/src/newt/native/bcm_vc_iv.c
+++ b/src/newt/native/bcm_vc_iv.c
@@ -299,10 +299,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_MovePoint
 JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initIDs
   (JNIEnv *env, jclass clazz)
 {
-    uint32_t screen_width;
-    uint32_t screen_height;
-    int32_t success = 0;
-
     setScreenSizeID = (*env)->GetMethodID(env, clazz, "setScreenSize", "(II)V");
     if (setScreenSizeID == NULL) {
         DBG_PRINT( "BCM.Screen initIDs FALSE\n" );
diff --git a/src/newt/native/egl_gbm.c b/src/newt/native/egl_gbm.c
new file mode 100644
index 000000000..87a402eed
--- /dev/null
+++ b/src/newt/native/egl_gbm.c
@@ -0,0 +1,237 @@
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include "jogamp_newt_driver_egl_gbm_DisplayDriver.h"
+#include "jogamp_newt_driver_egl_gbm_ScreenDriver.h"
+#include "jogamp_newt_driver_egl_gbm_WindowDriver.h"
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include <gbm.h>
+
+// #define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+    #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) 
+#else
+    #define DBG_PRINT(...)
+#endif
+
+typedef struct {
+    int fd; // drmClose
+    drmModeRes *resources; // drmModeFreeResources
+    drmModeConnector *connector; // drmModeFreeConnector
+    drmModeEncoder *encoder; // drmModeFreeEncoder
+    drmModeModeInfo *current_mode;
+} DRM_HANDLE;
+
+typedef struct {
+    struct gbm_bo *bo;
+    uint32_t fb_id;
+} DRM_GBM_FB;
+
+static jmethodID notifyScreenModeID = NULL;
+
+/**
+ * Display
+ */
+
+static void freeDrm(DRM_HANDLE *drm) {
+    if( NULL != drm ) {
+        if( NULL != drm->encoder ) {
+            drmModeFreeEncoder(drm->encoder);
+            drm->encoder = NULL;
+        }
+        if( NULL != drm->connector ) {
+            drmModeFreeConnector(drm->connector);
+            drm->connector = NULL;
+        }
+        if( NULL != drm->resources ) {
+            drmModeFreeResources(drm->resources);
+            drm->resources = NULL;
+        }
+        if( 0 != drm->fd ) {
+            drmClose(drm->fd);
+            drm->fd = 0;
+        }
+        free(drm);
+    }
+}
+
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_initIDs
+  (JNIEnv *env, jclass clazz)
+{
+    DBG_PRINT( "EGL_GBM.Display initIDs ok\n" );
+    return JNI_TRUE;
+}
+
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_initDrm
+  (JNIEnv *env, jclass clazz)
+{
+    static const char *modules[] = {
+            "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "msm"
+    };
+    int i, area;
+    DRM_HANDLE *drm = calloc(1, sizeof(DRM_HANDLE));
+
+    for (i = 0; i < 6 /* ARRAY_SIZE(modules) */; i++) {
+        printf("trying to load module %s...", modules[i]);
+        drm->fd = drmOpen(modules[i], NULL);
+        if (drm->fd < 0) {
+            printf("failed.\n");
+        } else {
+            printf("success.\n");
+            break;
+        }
+    }
+
+    if (drm->fd < 0) {
+        printf("could not open drm device\n");
+        goto error;
+    }
+
+    drm->resources = drmModeGetResources(drm->fd);
+    if ( NULL == drm->resources ) {
+        printf("drmModeGetResources failed: %s\n", strerror(errno));
+        goto error;
+    }
+
+    /* find a connected connector: */
+    for (i = 0; i < drm->resources->count_connectors; i++) {
+        drm->connector = drmModeGetConnector(drm->fd, drm->resources->connectors[i]);
+        if (drm->connector->connection == DRM_MODE_CONNECTED) {
+            /* it's connected, let's use this! */
+            break;
+        }
+        /* we could be fancy and listen for hotplug events and wait for
+         * a connector..
+         */
+        printf("no connected connector!\n");
+        goto error;
+    }
+
+    /* find highest resolution mode: */
+    for (i = 0, area = 0; i < drm->connector->count_modes; i++) {
+        drmModeModeInfo *current_mode = &drm->connector->modes[i];
+        int current_area = current_mode->hdisplay * current_mode->vdisplay;
+        if (current_area > area) {
+            drm->current_mode = current_mode;
+            area = current_area;
+        }
+    }
+
+    if ( NULL == drm->current_mode ) {
+        printf("could not find mode!\n");
+        goto error;
+    }
+
+    /* find encoder: */
+    for (i = 0; i < drm->resources->count_encoders; i++) {
+        drm->encoder = drmModeGetEncoder(drm->fd, drm->resources->encoders[i]);
+        if (drm->encoder->encoder_id == drm->connector->encoder_id) {
+            break;
+        }
+        printf("no encoder!\n");
+        goto error;
+    }
+
+    // drm->crtc_id = encoder->crtc_id;
+    // drm->connector_id = connector->connector_id;
+    return (jlong) (intptr_t) drm;
+
+error:
+    freeDrm(drm);
+    return 0;
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_freeDrm
+  (JNIEnv *env, jclass clazz, jlong jdrm) {
+    freeDrm( (DRM_HANDLE*) (intptr_t) jdrm );
+}
+
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_OpenGBMDisplay0
+  (JNIEnv *env, jclass clazz, jlong jdrm)
+{
+    DRM_HANDLE *drm = (DRM_HANDLE*) (intptr_t) jdrm;
+    struct gbm_device * dev = gbm_create_device(drm->fd);
+    return (jlong) (intptr_t) dev;
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_CloseGBMDisplay0
+  (JNIEnv *env, jclass clazz, jlong jgbm)
+{
+    struct gbm_device * dev = (struct gbm_device *) (intptr_t) jgbm;
+    gbm_device_destroy(dev);
+}
+
+/**
+ * Screen
+ */
+JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_ScreenDriver_initIDs
+  (JNIEnv *env, jclass clazz)
+{
+    notifyScreenModeID = (*env)->GetMethodID(env, clazz, "notifyScreenMode", "(III)V");
+    if (notifyScreenModeID == NULL) {
+        DBG_PRINT( "EGL_GBM.Screen initIDs FALSE\n" );
+        return JNI_FALSE;
+    }
+    DBG_PRINT( "EGL_GBM.Screen initIDs ok\n" );
+    return JNI_TRUE;
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_egl_gbm_ScreenDriver_initNative
+  (JNIEnv *env, jobject obj, jlong jdrm)
+{
+    DRM_HANDLE *drm = (DRM_HANDLE*) (intptr_t) jdrm;
+    uint32_t screen_width = 0;
+    uint32_t screen_height = 0;
+    uint32_t screen_vrefresh = 0;
+    int32_t success = 0;
+
+    if( NULL != drm ) {
+        /**
+        connector.modes.hdisplay; // width
+        connector.modes.vdisplay; // height
+        connector.modes.flags; // flags
+        encoder.crtc_id; // crt_idx
+        */
+        screen_width = drm->current_mode->hdisplay;
+        screen_height = drm->current_mode->vdisplay;
+        screen_vrefresh = drm->current_mode->vrefresh;
+
+        DBG_PRINT( "EGL_GBM.Screen initNative ok %dx%d @ %d\n", screen_width, screen_height, screen_vrefresh );
+        (*env)->CallVoidMethod(env, obj, notifyScreenModeID, (jint) screen_width, (jint) screen_height, (jint) screen_vrefresh);
+    } else {
+        DBG_PRINT( "BCM.Screen initNative failed\n" );
+    }
+}
+
+/**
+ * Window
+ */
+
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_CreateWindow0
+  (JNIEnv *env, jobject obj, jlong jdrm, jlong jgbm, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits)
+{
+    DRM_HANDLE *drm = (DRM_HANDLE*) (intptr_t) jdrm;
+    struct gbm_device *dev = (struct gbm_device *) (intptr_t) jgbm;
+
+    struct gbm_surface *surface = gbm_surface_create(dev,
+              drm->current_mode->hdisplay, drm->current_mode->vdisplay,
+              opaque ? GBM_FORMAT_XRGB8888 : GBM_BO_FORMAT_ARGB8888,
+              GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+    if ( NULL == surface ) {
+        printf("failed to create gbm surface\n");
+        return -1;
+    }
+    return (jlong) (intptr_t) surface;
+}
+
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_CloseWindow0
+  (JNIEnv *env, jobject obj, jlong display, jlong window)
+{
+    struct gbm_surface *surface = (struct gbm_surface *) (intptr_t) window;
+    gbm_surface_destroy(surface);
+}
+
diff --git a/src/newt/native/gbm.c b/src/newt/native/gbm.c
deleted file mode 100644
index 927faa47e..000000000
--- a/src/newt/native/gbm.c
+++ /dev/null
@@ -1,147 +0,0 @@
-#include <errno.h>
-#include <string.h>
-
-#include "jogamp_newt_driver_gbm_DisplayDriver.h"
-#include "jogamp_newt_driver_gbm_ScreenDriver.h"
-#include "jogamp_newt_driver_gbm_WindowDriver.h"
-
-#include <xf86drm.h>
-#include <xf86drmMode.h>
-#include <gbm.h>
-
-static struct {
-	struct gbm_device *dev;
-	struct gbm_surface *surface;
-} gbm;
-
-static struct {
-	int fd;
-	drmModeModeInfo *mode;
-	uint32_t crtc_id;
-	uint32_t connector_id;
-} drm;
-
-struct drm_fb {
-	struct gbm_bo *bo;
-	uint32_t fb_id;
-};
-
-/*
- * Class:     jogamp_newt_driver_gbm_DisplayDriver
- * Method:    initGbm
- * Signature: (J)V
- */
-JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_gbm_DisplayDriver_initGbm
-  (JNIEnv *env, jobject this){
-	static const char *modules[] = {
-			"i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "msm"
-	};
-	drmModeRes *resources;
-	drmModeConnector *connector = NULL;
-	drmModeEncoder *encoder = NULL;
-	int i, area;
-
-	for (i = 0; i < 6 /* ARRAY_SIZE(modules) */; i++) {
-		printf("trying to load module %s...", modules[i]);
-		drm.fd = drmOpen(modules[i], NULL);
-		if (drm.fd < 0) {
-			printf("failed.\n");
-		} else {
-			printf("success.\n");
-			break;
-		}
-	}
-
-	if (drm.fd < 0) {
-		printf("could not open drm device\n");
-		return -1;
-	}
-
-	resources = drmModeGetResources(drm.fd);
-	if (!resources) {
-		printf("drmModeGetResources failed: %s\n", strerror(errno));
-		return -1;
-	}
-
-	/* find a connected connector: */
-	for (i = 0; i < resources->count_connectors; i++) {
-		connector = drmModeGetConnector(drm.fd, resources->connectors[i]);
-		if (connector->connection == DRM_MODE_CONNECTED) {
-			/* it's connected, let's use this! */
-			break;
-		}
-		drmModeFreeConnector(connector);
-		connector = NULL;
-	}
-
-	if (!connector) {
-		/* we could be fancy and listen for hotplug events and wait for
-		 * a connector..
-		 */
-		printf("no connected connector!\n");
-		return -1;
-	}
-
-	/* find highest resolution mode: */
-	for (i = 0, area = 0; i < connector->count_modes; i++) {
-		drmModeModeInfo *current_mode = &connector->modes[i];
-		int current_area = current_mode->hdisplay * current_mode->vdisplay;
-		if (current_area > area) {
-			drm.mode = current_mode;
-			area = current_area;
-		}
-	}
-
-	if (!drm.mode) {
-		printf("could not find mode!\n");
-		return -1;
-	}
-
-	/* find encoder: */
-	for (i = 0; i < resources->count_encoders; i++) {
-		encoder = drmModeGetEncoder(drm.fd, resources->encoders[i]);
-		if (encoder->encoder_id == connector->encoder_id)
-			break;
-		drmModeFreeEncoder(encoder);
-		encoder = NULL;
-	}
-
-	if (!encoder) {
-		printf("no encoder!\n");
-		return -1;
-	}
-
-	drm.crtc_id = encoder->crtc_id;
-	drm.connector_id = connector->connector_id;
-
-	gbm.dev = gbm_create_device(drm.fd);
-
-	return gbm.dev;
-  }
-
-/*
- * Class:     jogamp_newt_driver_gbm_DisplayDriver
- * Method:    destroyDisplay
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_jogamp_newt_driver_gbm_DisplayDriver_destroyDisplay
-  (JNIEnv *env, jobject this){
-  }
-
-/*
- * Class:     jogamp_newt_driver_gbm_WindowDriver
- * Method:    createSurface
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_gbm_WindowDriver_createSurface
-  (JNIEnv *env, jobject this){
-      	gbm.surface = gbm_surface_create(gbm.dev,
-      			drm.mode->hdisplay, drm.mode->vdisplay,
-      			GBM_FORMAT_XRGB8888,
-      			GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
-      	if (!gbm.surface) {
-      		printf("failed to create gbm surface\n");
-      		return -1;
-      	}
-      	return gbm.surface;
-  }
-- 
cgit v1.2.3