From 7deccdaa76305b7acae9dfc7a15f974387c6cd1a Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sat, 17 Apr 2010 22:40:12 +0200 Subject: DRIHack.driHackNeeded is now initialized once in the static initializer (not in every begin() call). --- .../classes/com/jogamp/opengl/impl/DRIHack.java | 44 +++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java b/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java index e845ef160..7e81d194b 100755 --- a/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java @@ -40,6 +40,7 @@ package com.jogamp.opengl.impl; import com.jogamp.common.os.NativeLibrary; +import com.jogamp.common.os.Platform; import java.io.*; import java.security.*; @@ -76,27 +77,31 @@ import java.security.*; */ public class DRIHack { + private static final boolean DEBUG = Debug.debug("DRIHack"); private static boolean driHackNeeded; private static NativeLibrary oglLib; - public static void begin() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String os = Debug.getProperty("os.name", false).toLowerCase(); - // Do DRI hack on all Linux distributions for best robustness - driHackNeeded = - (os.startsWith("linux") || - new File("/usr/lib/dri").exists() || - new File("/usr/X11R6/lib/modules/dri").exists()); - // Allow manual overriding for now as a workaround for - // problems seen in some situations -- needs more investigation - if (Debug.getProperty("jogl.drihack.disable", true) != null) { + static { + // Allow manual overriding for now as a workaround for + // problems seen in some situations -- needs more investigation + if (Debug.getProperty("jogl.drihack.disable", true) != null) { driHackNeeded = false; - } - return null; + } else { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + String os = Platform.getOS().toLowerCase(); + // Do DRI hack on all Linux distributions for best robustness + driHackNeeded = os.startsWith("linux") + || new File("/usr/lib/dri").exists() + || new File("/usr/X11R6/lib/modules/dri").exists(); + return null; + } + }); } - }); + } + + public static void begin() { if (driHackNeeded) { if (DEBUG) { @@ -106,12 +111,17 @@ public class DRIHack { // Try a few different variants for best robustness // In theory probably only the first is necessary oglLib = NativeLibrary.open("libGL.so.1", null); - if (DEBUG && oglLib != null) System.err.println(" Found libGL.so.1"); + if (DEBUG && oglLib != null) { + System.err.println(" Found libGL.so.1"); + } if (oglLib == null) { oglLib = NativeLibrary.open("/usr/lib/libGL.so.1", null); - if (DEBUG && oglLib != null) System.err.println(" Found /usr/lib/libGL.so.1"); + if (DEBUG && oglLib != null) { + System.err.println(" Found /usr/lib/libGL.so.1"); + } } } + } public static void end() { -- cgit v1.2.3