diff options
author | Sven Gothel <[email protected]> | 2019-12-25 02:07:50 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-12-25 02:07:50 +0100 |
commit | b91c680fb93a03720ff9fcb39cf052cfe8d40e76 (patch) | |
tree | fb2b4bbd5817ca9523404984940f48c7a774cc35 | |
parent | 07de253dae77b39da944a946381bd6efec0066ba (diff) |
Bug 1156: Seperate DRM/GBM NEWT native library from main head NEWT native library
DRM/GBM is enabled for Linux in general.
Nativewindow's 'nativewindow_drm' DRM/GBM native library is already seperated.
NEWT get its 'newt_drm' DRM/GBM native library.
NEWT's main head native library is renamed from 'newt' -> 'newt_head'
and is earmarked for further seperation similar to Nativewindow's.
At least a 'newt_wayland' will probably followup when support is added.
Goal is to remove DRM/GBM dependency for Linux X11 operation
as well as removing X11 dependency for Linux DRM/GBM operation.
14 files changed, 80 insertions, 30 deletions
diff --git a/make/build-newt.xml b/make/build-newt.xml index b758d20c7..ec3d95134 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -526,6 +526,9 @@ <syslibset libs="Xi"/> <!--syslibset libs="xcb" /--> <!--syslibset libs="X11-xcb" /--> + </linker> + + <linker id="linker.cfg.linux.newt.drm" extends="linker.cfg.linux"> <syslibset libs="drm"/> <syslibset libs="gbm"/> </linker> @@ -537,6 +540,9 @@ <syslibset libs="Xi"/> <!--syslibset libs="xcb" /--> <!--syslibset libs="X11-xcb" /--> + </linker> + + <linker id="linker.cfg.linux.x86.newt.drm" extends="linker.cfg.linux.x86"> <syslibset libs="drm"/> <syslibset libs="gbm"/> </linker> @@ -548,6 +554,9 @@ <syslibset libs="Xi"/> <!--syslibset libs="xcb" /--> <!--syslibset libs="X11-xcb" /--> + </linker> + + <linker id="linker.cfg.linux.amd64.newt.drm" extends="linker.cfg.linux.amd64"> <syslibset libs="drm"/> <syslibset libs="gbm"/> </linker> @@ -557,6 +566,9 @@ <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xrandr" /> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xcursor" /> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xi" /> + </linker> + + <linker id="linker.cfg.linux.armv6.newt.drm" extends="linker.cfg.linux.armv6"> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="drm" /> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="gbm" /> </linker> @@ -566,6 +578,9 @@ <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xrandr" /> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xcursor" /> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xi" /> + </linker> + + <linker id="linker.cfg.linux.aarch64.newt.drm" extends="linker.cfg.linux.aarch64"> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="drm" /> <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="gbm" /> </linker> @@ -672,7 +687,7 @@ else="linker.cfg.linux.x86"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.x86.newt.drm"/> </target> <target name="c.configure.linux.amd64" if="isLinuxAMD64"> @@ -682,7 +697,7 @@ else="linker.cfg.linux.amd64"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.amd64.newt.drm"/> </target> <target name="c.configure.linux.armv6" if="isLinuxARMv6"> @@ -692,7 +707,7 @@ else="linker.cfg.linux.armv6"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.armv6.newt.drm"/> </target> <target name="c.configure.linux.aarch64" if="isLinuxARM64"> @@ -702,7 +717,7 @@ else="linker.cfg.linux.aarch64"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.aarch64.newt.drm"/> </target> <target name="c.configure.linux.hppa" if="isLinuxHppa"> @@ -712,7 +727,7 @@ else="linker.cfg.linux"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux.mips" if="isLinuxMips"> @@ -722,7 +737,7 @@ else="linker.cfg.linux"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux.mipsel" if="isLinuxMipsel"> @@ -732,7 +747,7 @@ else="linker.cfg.linux"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux.ppc" if="isLinuxPpc"> @@ -742,7 +757,7 @@ else="linker.cfg.linux"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux.s390" if="isLinuxs390"> @@ -752,7 +767,7 @@ else="linker.cfg.linux"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux.sparc" if="isLinuxSparc"> @@ -762,13 +777,14 @@ else="linker.cfg.linux"> <isset property="isX11" /> </condition> - <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux.ia64" if="isLinuxIA64"> <echo message="Linux.IA64" /> <property name="compiler.cfg.id" value="compiler.cfg.linux" /> <property name="linker.cfg.id.oswin" value="linker.cfg.linux.newt.x11" /> + <property name="linker.cfg.id.drm" value="linker.cfg.linux.newt.drm"/> </target> <target name="c.configure.linux" depends="c.configure.linux.x86,c.configure.linux.amd64,c.configure.linux.armv6,c.configure.linux.aarch64,c.configure.linux.hppa,c.configure.linux.mips,c.configure.linux.mipsel,c.configure.linux.ppc,c.configure.linux.s390,c.configure.linux.sparc,c.configure.linux.ia64,c.configure.x11" if="isLinux"/> @@ -870,7 +886,7 @@ <condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition> - <patternset id="c.src.files.newt"> + <patternset id="c.src.files.newt.head"> <include name="${rootrel.src.c}/JVM_JNI8.c" /> <include name="${rootrel.src.c}/NewtCommon.c" /> <!-- include name="${rootrel.src.c}/timespec.c" /--> <!-- currently used for X11 and OSX with special PERF DEBUG MODE--> @@ -892,6 +908,11 @@ <include name="${rootrel.src.c}/IntelGDL.c" if="setup.addNativeIntelGDL"/> <include name="${rootrel.src.c}/bcm_egl.c" if="setup.addNativeBroadcom"/> <include name="${rootrel.src.c}/bcm_vc_iv.c" if="setup.addNativeBroadcom"/> + </patternset> + + <patternset id="c.src.files.newt.drmgbm"> + <include name="${rootrel.src.c}/JVM_JNI8.c" /> + <include name="${rootrel.src.c}/NewtCommon.c" /> <include name="${rootrel.src.c}/drm_gbm.c" if="setup.addNativeDRMGBM"/> <include name="${rootrel.src.c}/drm_gbm_legacy.c" if="setup.addNativeDRMGBM"/> </patternset> @@ -978,11 +999,20 @@ </sequential> </macrodef> - <target name="c.build.newt.windowlib" unless="setup.nonatives"> + <target name="c.build.newt.windowlib.drmgbm" if="setup.addNativeDRMGBM"> + <echo message="Using compiler.cfg.id ${compiler.cfg.id}" /> + <echo message="Using linker.cfg.id.drm ${linker.cfg.id.drm}" /> + <c.build c.compiler.src.files="c.src.files.newt.drmgbm" + output.lib.name="newt_drm" + compiler.cfg.id="${compiler.cfg.id}" + linker.cfg.id="${linker.cfg.id.drm}"/> + </target> + + <target name="c.build.newt.windowlib.head" unless="setup.nonatives"> <echo message="Using compiler.cfg.id ${compiler.cfg.id}" /> <echo message="Using linker.cfg.id.oswin ${linker.cfg.id.oswin}" /> - <c.build c.compiler.src.files="c.src.files.newt" - output.lib.name="newt" + <c.build c.compiler.src.files="c.src.files.newt.head" + output.lib.name="newt_head" compiler.cfg.id="${compiler.cfg.id}" linker.cfg.id="${linker.cfg.id.oswin}"/> </target> @@ -992,7 +1022,7 @@ <msvc.manifest objdir="${obj.newt}" dllname="newt" /> </target> - <target name="c.build.newt.natives" depends="c.build.newt.windowlib" unless="setup.nonatives"> + <target name="c.build.newt.natives" depends="c.build.newt.windowlib.head, c.build.newt.windowlib.drmgbm" unless="setup.nonatives"> </target> <target name="c.build.newt" depends="c.configure,c.build.newt.natives"> diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4bb40aa03..3f82e43b1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -482,7 +482,7 @@ function testawtswt() { # # HiDPI # -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2SimpleNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* @@ -983,7 +983,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestCPUSourcingAPINEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index 05df63794..9372de26c 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -104,7 +104,7 @@ public class MainThread { static { NativeWindowFactory.initSingleton(); - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || PropertyAccess.getBooleanProperty("newt.MainThread.force", true); osType = Platform.getOSType(); diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java index 84e2167ee..fde3de222 100644 --- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java +++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java @@ -47,12 +47,32 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; public class NEWTJNILibLoader extends JNILibLoaderBase { - public static boolean loadNEWT() { + /** + * Loads the NEWT native library for the main head display, + * i.e. X11 for Unix, GDI for Windows .. and so forth. + */ + public static boolean loadNEWTHead() { return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { Platform.initSingleton(); - final String libName = "newt"; + final String libName = "newt_head"; + if( TempJarCache.isInitialized(true) && null == TempJarCache.findLibrary(libName) ) { + JNILibLoaderBase.addNativeJarLibsJoglCfg(new Class<?>[] { jogamp.nativewindow.Debug.class, jogamp.newt.Debug.class }); + } + return Boolean.valueOf(loadLibrary(libName, false, NEWTJNILibLoader.class.getClassLoader())); + } + }).booleanValue(); + } + /** + * Loads the NEWT native library for the drm/gbm display. + */ + public static boolean loadNEWTDrmGbm() { + return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + @Override + public Boolean run() { + Platform.initSingleton(); + final String libName = "newt_drm"; if( TempJarCache.isInitialized(true) && null == TempJarCache.findLibrary(libName) ) { JNILibLoaderBase.addNativeJarLibsJoglCfg(new Class<?>[] { jogamp.nativewindow.Debug.class, jogamp.newt.Debug.class }); } diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java index 216dccb2b..91a8d4dfe 100644 --- a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -37,7 +37,7 @@ import com.jogamp.opengl.egl.EGL; public class DisplayDriver extends jogamp.newt.DisplayImpl { static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if (!WindowDriver.initIDs0()) { throw new NativeWindowException("Failed to initialize Android NEWT Windowing library"); diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index cd801e59a..a65bd1e4c 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -45,7 +45,7 @@ import com.jogamp.opengl.egl.EGL; public class DisplayDriver extends jogamp.newt.DisplayImpl { static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if (!WindowDriver.initIDs()) { throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs"); diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 5e1e61407..8a29f96f6 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -52,7 +52,7 @@ public class DisplayDriver extends DisplayImpl { static final PNGPixelRect defaultPointerIconImage; static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); GLProfile.initSingleton(); if (!DisplayDriver.initIDs()) { diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java index ea42c27af..19e44b830 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java @@ -50,7 +50,7 @@ import jogamp.opengl.egl.EGLDisplayUtil; public class DisplayDriver extends DisplayImpl { static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTDrmGbm(); GLProfile.initSingleton(); if (!DisplayDriver.initIDs()) { diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index 33712e35d..b92c355ef 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -41,7 +41,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { static int initCounter = 0; static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if (!ScreenDriver.initIDs()) { throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); diff --git a/src/newt/classes/jogamp/newt/driver/ios/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/ios/DisplayDriver.java index d2bb6de02..e5572f6f6 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/DisplayDriver.java @@ -39,7 +39,7 @@ import jogamp.newt.NEWTJNILibLoader; public class DisplayDriver extends DisplayImpl { static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if(!initUIApplication0()) { throw new NativeWindowException("Failed to initialize native Application hook"); diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 6b28e94df..b704f8d40 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -45,7 +45,7 @@ import jogamp.opengl.egl.EGLDisplayUtil; public class DisplayDriver extends DisplayImpl { static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if (!WindowDriver.initIDs()) { throw new NativeWindowException("Failed to initialize kd.Window jmethodIDs"); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 94001f440..59d3f0e40 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -59,7 +59,7 @@ public class DisplayDriver extends DisplayImpl { private static final boolean USE_APPKIT_EDTUTIL; static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if(!initNSApplication0()) { throw new NativeWindowException("Failed to initialize native Application hook"); diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 0bd7c5b2a..e9581772a 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -60,7 +60,7 @@ public class DisplayDriver extends DisplayImpl { private static RegisteredClassFactory sharedClassFactory; static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); { final long[] _defaultIconHandle = { 0, 0 }; if( DisplayImpl.isPNGUtilAvailable() ) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 9d89ba085..e0fd20e2b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -50,7 +50,7 @@ import jogamp.newt.NEWTJNILibLoader; public class DisplayDriver extends DisplayImpl { static { - NEWTJNILibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWTHead(); if ( !initIDs0(X11Util.XERROR_STACKDUMP) ) { throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); |