aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2018-01-16 06:45:46 +0100
committerSven Gothel <[email protected]>2018-01-16 06:45:46 +0100
commit347271ffdd09153a2334fda593774d49050f84e0 (patch)
tree1a44a3401acfd2c9c44bef693db10ea14b3f323f
parentbd80d24b7b4322eacf806740df09801f18d05306 (diff)
Bug 1290: Expand query whether BCM IV is being used, exclude '/dev/dri/card0'rcpulled
Also refactor query to jogamp.nativewindow.BcmVCArtifacts
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java18
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java20
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/BcmVCArtifacts.java76
3 files changed, 87 insertions, 27 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
index 6b4a3ea99..038194d58 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
@@ -28,10 +28,11 @@
package jogamp.opengl.egl;
-import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import jogamp.nativewindow.BcmVCArtifacts;
+
/**
* <p>
* Covering ES3 and ES2.
@@ -42,21 +43,20 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl
super();
}
+
@Override
public final List<List<String>> getToolLibNames() {
- // Prefer libGLESv2.so over libGLESv2.so.2 for Broadcom graphics
- // when the VC4 DRM driver isn't present
- final File vcliblocation = new File(
- "/opt/vc/lib/libbcm_host.so");
- final File vc4modlocation = new File(
- "/sys/module/vc4");
- final boolean bcm_vc_iv_quirk = vcliblocation.isFile() && !vc4modlocation.isDirectory();
-
final List<List<String>> libsList = new ArrayList<List<String>>();
{
final List<String> libsGL = new ArrayList<String>();
+ /**
+ * Prefer libGLESv2.so over libGLESv2.so.2 for proprietary
+ * Broadcom graphics when the VC4 DRM Xorg driver isn't present
+ */
+ final boolean bcm_vc_iv_quirk = BcmVCArtifacts.guessVCIVUsed();
+
// ES3: This is the default lib name, according to the spec
libsGL.add("libGLESv3.so.3");
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
index 448c9d2bf..ebd498401 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
@@ -33,7 +33,6 @@
package com.jogamp.nativewindow;
-import java.io.File;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -46,6 +45,7 @@ import java.util.Map;
import com.jogamp.nativewindow.util.PointImmutable;
import jogamp.common.os.PlatformPropsImpl;
+import jogamp.nativewindow.BcmVCArtifacts;
import jogamp.nativewindow.Debug;
import jogamp.nativewindow.NativeWindowFactoryImpl;
import jogamp.nativewindow.ToolkitProperties;
@@ -136,22 +136,6 @@ public abstract class NativeWindowFactory {
protected NativeWindowFactory() {
}
- private static final boolean guessBroadcomVCIV() {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- private final File vcliblocation = new File(
- "/opt/vc/lib/libbcm_host.so");
- private final File vc4modlocation = new File(
- "/sys/module/vc4");
- @Override
- public Boolean run() {
- if ( vcliblocation.isFile() && !vc4modlocation.isDirectory() ) {
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- } ).booleanValue();
- }
-
private static String _getNativeWindowingType() {
switch(PlatformPropsImpl.OS_TYPE) {
case ANDROID:
@@ -168,7 +152,7 @@ public abstract class NativeWindowFactory {
case SUNOS:
case HPUX:
default:
- if( guessBroadcomVCIV() ) {
+ if( BcmVCArtifacts.guessVCIVUsed() ) {
return TYPE_BCM_VC_IV;
}
return TYPE_X11;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/BcmVCArtifacts.java b/src/nativewindow/classes/jogamp/nativewindow/BcmVCArtifacts.java
new file mode 100644
index 000000000..216c55a3a
--- /dev/null
+++ b/src/nativewindow/classes/jogamp/nativewindow/BcmVCArtifacts.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2018 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.nativewindow;
+
+import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Heuristics about Broadcom (BCM) VideoCore (VC) existence and usage
+ */
+public class BcmVCArtifacts {
+ static final boolean hasVCLib;
+ static final boolean hasVC4ModLocation;
+ static final boolean hasDriCard0File;
+
+ static {
+ final File vcLibLocation = new File(
+ "/opt/vc/lib/libbcm_host.so");
+ final File vc4ModLocation = new File(
+ "/sys/module/vc4");
+ final File driCard0Location = new File(
+ "/dev/dri/card0");
+ final boolean[] res = new boolean [3];
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
+ public Object run() {
+ res[0] = vcLibLocation.isFile();
+ res[1] = vc4ModLocation.isDirectory();
+ res[2] = driCard0Location.isFile();
+ return null;
+ } } );
+ hasVCLib = res[0];
+ hasVC4ModLocation = res[1];
+ hasDriCard0File = res[2];
+ }
+
+ /**
+ * @return True if proprietary BCM VC IV is probably being present
+ */
+ public static final boolean guessVCIVPresent() {
+ return hasVCLib;
+ }
+ /**
+ * @return True if proprietary BCM VC IV is probably being used and not Xorg drivers
+ */
+ public static final boolean guessVCIVUsed() {
+ return hasVCLib && !hasVC4ModLocation && !hasDriCard0File;
+ }
+}