diff options
author | Erik De Rijcke <[email protected]> | 2015-05-10 22:06:27 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-11-21 03:44:24 +0100 |
commit | df599b1c9b08da7335b2c6036c1c9f308ec56387 (patch) | |
tree | 5e2044bfda07efbc1b2edf3d1b422286fc35aa2d /src/newt/classes | |
parent | e1d767a4063d2503f9099d24a570664f6acd1a34 (diff) |
add native gbm implementation for drm and gbm initialization.
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java | 134 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java | 4 |
2 files changed, 4 insertions, 134 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java index 0e43536c6..00a1ca384 100644 --- a/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/gbm/DisplayDriver.java @@ -14,9 +14,7 @@ package jogamp.newt.driver.gbm; import com.jogamp.nativewindow.AbstractGraphicsDevice; -import com.jogamp.nativewindow.NativeWindowException; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; -import com.jogamp.opengl.GLDrawableFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; import jogamp.opengl.egl.EGLDisplayUtil; @@ -25,42 +23,8 @@ public class DisplayDriver extends DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); - - if (!DisplayDriver.initIDs()) { - throw new NativeWindowException("Failed to initialize gbm Display jmethodIDs"); - } -// if (!ScreenDriver.initIDs()) { -// throw new NativeWindowException("Failed to initialize gbm Screen jmethodIDs"); -// } -// if (!WindowDriver.initIDs()) { -// throw new NativeWindowException("Failed to initialize gbm Window jmethodIDs"); -// } - } - - protected static native boolean initIDs(); - - private long dev; - private long surface; - - private int fd; - private long mode; - - static { - NEWTJNILibLoader.loadNEWT(); - GLDrawableFactory.initSingleton(); } - //private final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglDisplayLifecycleCallback; - private long connector; - private long encoder; - - public long getConnector() { - return connector; - } - - public long getEncoder() { - return encoder; - } public static void initSingleton() { // just exist to ensure static init has been run @@ -68,115 +32,25 @@ public class DisplayDriver extends DisplayImpl { @Override protected void createNativeImpl() { - final EGLGraphicsDevice eglGraphicsDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(dev, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + final EGLGraphicsDevice eglGraphicsDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(initGbm(), AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); eglGraphicsDevice.open(); this.aDevice = eglGraphicsDevice; } - private native void initGbm(); + private native long initGbm(); // { // // // } - public long getSurface() { - return surface; - } - - private native void init(); -// { -// -// String[] modules = { -// "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "msm" -// }; -// drmModeRes resources; -// connector = null; -// encoder = null; -// -// for (int i = 0; i < modules.length; i++) { -// if(DEBUG){ -// System.out.println(String.format("trying to load module %s...", modules[i])); -// } -// fd = DrmLibrary.INSTANCE.drmOpen(modules[i], null); -// if (fd < 0) { -// throw new NativeWindowException("Can not open drm device."); -// } else { -// break; -// } -// } -// -// if (fd < 0) { -// throw new NativeWindowException("could not open drm device"); -// } -// -// resources = DrmLibrary.INSTANCE.drmModeGetResources(fd); -// if (resources == null) { -// throw new NativeWindowException("drmModeGetResources failed"); -// } -// -// /* find a connected connector: */ -// for (int i = 0; i < resources.count_connectors; i++) { -// connector = DrmLibrary.INSTANCE.drmModeGetConnector(fd, resources.connectors.getInt(i)); -// if (connector.connection == drmModeConnection.DRM_MODE_CONNECTED) { -// /* it's connected, let's use this! */ -// break; -// } -// DrmLibrary.INSTANCE.drmModeFreeConnector(connector); -// connector = null; -// } -// -// if (connector == null) { -// /* we could be fancy and listen for hotplug events and wait for -// * a connector.. -// */ -// throw new NativeWindowException("no connected connector!"); -// } -// -// /* find highest resolution mode: */ -// drmModeModeInfo[] drmModeModeInfos = (drmModeModeInfo[]) connector.modes.toArray(connector.count_modes); -// for (int i = 0, area = 0; i < drmModeModeInfos.length; i++) { -// drmModeModeInfo current_mode = drmModeModeInfos[i]; -// int current_area = current_mode.hdisplay * current_mode.vdisplay; -// if (current_area > area) { -// mode = current_mode; -// area = current_area; -// } -// } -// -// if (mode == null) { -// throw new NativeWindowException("could not find mode!"); -// } -// -// /* find encoder: */ -// for (int i = 0; i < resources.count_encoders; i++) { -// encoder = DrmLibrary.INSTANCE.drmModeGetEncoder(fd, resources.encoders.getInt(i)); -// if (encoder.encoder_id == connector.encoder_id) { -// break; -// } -// DrmLibrary.INSTANCE.drmModeFreeEncoder(encoder); -// encoder = null; -// } -// -// if (encoder == null) { -// throw new NativeWindowException("no encoder!"); -// } -// -// final int crtc_id = encoder.crtc_id; -// final int connector_id = connector.connector_id; -// -// dev = GbmLibrary.INSTANCE.gbm_create_device(fd); -// } - @Override protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { //DrmLibrary.INSTANCE.drmModeFreeConnector(this.connector); aDevice.close(); destroyDisplay(); //GbmLibrary.INSTANCE.gbm_device_destroy(dev); - this.dev = 0; //CLibrary.INSTANCE.close(this.fd); - this.fd = 0; } private native void destroyDisplay(); @@ -185,8 +59,4 @@ public class DisplayDriver extends DisplayImpl { protected void dispatchMessagesNative() { //NA } - - public long getGbmDevice() { - return dev; - } } diff --git a/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java index 9c5803e1a..cbada076c 100644 --- a/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/gbm/WindowDriver.java @@ -56,7 +56,7 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - long nativeWindowHandle = createSurface(display.getGbmDevice()); + long nativeWindowHandle = createSurface(); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } @@ -70,7 +70,7 @@ public class WindowDriver extends WindowImpl { focusChanged(false, true); } - private native long createSurface(final long gbmDevice); + private native long createSurface(); //{ // surface = GbmLibrary.INSTANCE.gbm_surface_create(dev, // mode.hdisplay, mode.vdisplay, |