summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java83
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java21
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java2
6 files changed, 92 insertions, 42 deletions
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
index 809c6783d..075c8bfd8 100644
--- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
+++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
@@ -454,34 +454,69 @@ public class GLEmitter extends ProcAddressEmitter {
return (GLConfiguration) getConfig();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void endProcAddressTable() throws Exception {
PrintWriter w = tableWriter;
-
- w.println(" /**");
- w.println(" * This is a convenience method to get (by name) the native function");
- w.println(" * pointer for a given function. It lets you avoid having to");
- w.println(" * manually compute the "" + PROCADDRESS_VAR_PREFIX + " + ");
- w.println(" * <functionName>" member variable name and look it up via");
- w.println(" * reflection; it also will throw an exception if you try to get the");
- w.println(" * address of an unknown function, or one that is statically linked");
- w.println(" * and therefore does not have a function pointer in this table.");
- w.println(" *");
- w.println(" * @throws RuntimeException if the function pointer was not found in");
- w.println(" * this table, either because the function was unknown or because");
- w.println(" * it was statically linked.");
- w.println(" */");
- w.println(" public long getAddressFor(String functionNameUsr) {");
- w.println(" String functionNameBase = "+GLNameResolver.class.getName()+".normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLNameResolver.normalizeARB(functionNameUsr, true), true);");
- w.println(" String addressFieldNameBase = PROCADDRESS_VAR_PREFIX + functionNameBase;");
- w.println(" java.lang.reflect.Field addressField = null;");
- w.println(" int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);");
- w.println(" for(int i = 0; null==addressField && i < funcNamePermNum; i++) {");
- w.println(" String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);");
- w.println(" try {");
- w.println(" addressField = getClass().getField(addressFieldName);");
- w.println(" } catch (Exception e) { }");
+
+ w.println(" @Override");
+ w.println(" protected boolean isFunctionAvailableImpl(String functionNameUsr) throws IllegalArgumentException {");
+ w.println(" final String functionNameBase = "+GLNameResolver.class.getName()+".normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLNameResolver.normalizeARB(functionNameUsr, true), true);");
+ w.println(" final String addressFieldNameBase = \"" + PROCADDRESS_VAR_PREFIX + "\" + functionNameBase;");
+ w.println(" final int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);");
+ w.println(" final java.lang.reflect.Field addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.lang.reflect.Field>() {");
+ w.println(" public final java.lang.reflect.Field run() {");
+ w.println(" java.lang.reflect.Field addressField = null;");
+ w.println(" for(int i = 0; i < funcNamePermNum; i++) {");
+ w.println(" final String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);");
+ w.println(" try {");
+ w.println(" addressField = "+tableClassName+".class.getDeclaredField( addressFieldName );");
+ w.println(" addressField.setAccessible(true); // we need to read the protected value!");
+ w.println(" return addressField;");
+ w.println(" } catch (NoSuchFieldException ex) { }");
+ w.println(" }");
+ w.println(" return null;");
+ w.println(" } } );");
+ w.println();
+ w.println(" if(null==addressField) {");
+ w.println(" // The user is calling a bogus function or one which is not");
+ w.println(" // runtime linked");
+ w.println(" throw new RuntimeException(");
+ w.println(" \"WARNING: Address field query failed for \\\"\" + functionNameBase + \"\\\"/\\\"\" + functionNameUsr +");
+ w.println(" \"\\\"; it's either statically linked or address field is not a known \" +");
+ w.println(" \"function\");");
+ w.println(" } ");
+ w.println(" try {");
+ w.println(" return 0 != addressField.getLong(this);");
+ w.println(" } catch (Exception e) {");
+ w.println(" throw new RuntimeException(");
+ w.println(" \"WARNING: Address query failed for \\\"\" + functionNameBase + \"\\\"/\\\"\" + functionNameUsr +");
+ w.println(" \"\\\"; it's either statically linked or is not a known \" +");
+ w.println(" \"function\", e);");
w.println(" }");
+ w.println(" }");
+
+ w.println(" @Override");
+ w.println(" public long getAddressFor(String functionNameUsr) throws SecurityException, IllegalArgumentException {");
+ w.println(" SecurityUtil.checkAllLinkPermission();");
+ w.println(" final String functionNameBase = "+GLNameResolver.class.getName()+".normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLNameResolver.normalizeARB(functionNameUsr, true), true);");
+ w.println(" final String addressFieldNameBase = \"" + PROCADDRESS_VAR_PREFIX + "\" + functionNameBase;");
+ w.println(" final int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);");
+ w.println(" final java.lang.reflect.Field addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.lang.reflect.Field>() {");
+ w.println(" public final java.lang.reflect.Field run() {");
+ w.println(" java.lang.reflect.Field addressField = null;");
+ w.println(" for(int i = 0; i < funcNamePermNum; i++) {");
+ w.println(" final String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);");
+ w.println(" try {");
+ w.println(" addressField = "+tableClassName+".class.getDeclaredField( addressFieldName );");
+ w.println(" addressField.setAccessible(true); // we need to read the protected value!");
+ w.println(" return addressField;");
+ w.println(" } catch (NoSuchFieldException ex) { }");
+ w.println(" }");
+ w.println(" return null;");
+ w.println(" } } );");
w.println();
w.println(" if(null==addressField) {");
w.println(" // The user is calling a bogus function or one which is not");
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 36893f5ec..9fe74ee97 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -73,7 +73,13 @@ public class GLRendererQuirks {
* <p>
* Mesa >= 9.0 (?), Intel driver, OpenGL 3.1 compatibility context is not compliant:
* <pre>
- * GL_RENDERER: Mesa DRI Intel(R) Sandybridge Desktop
+ * GL_RENDERER: 'Mesa .* Intel(R) Sandybridge Desktop'
+ * </pre>
+ * </p>
+ * <p>
+ * Mesa >= 9.0 (?), AMD driver, OpenGL 3.1 core and compatibility context is not compliant:
+ * <pre>
+ * GL_RENDERER: 'Gallium 0.4 on AMD RS880'
* </pre>
* </p>
*/
diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
index d160eccff..ca4846939 100644
--- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
@@ -39,8 +39,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
- private static List<String> glueLibNames;
+public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
+ private static final List<String> glueLibNames;
static {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
@@ -69,11 +69,16 @@ public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
/** Make Cg symbols available to CgGL */
@Override
- public boolean shallLinkGlobal() { return true; }
+ public final boolean shallLinkGlobal() { return true; }
- /** default **/
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Returns <code>false</code>.
+ * </p>
+ */
@Override
- public boolean shallLookupGlobal() { return false; }
+ public final boolean shallLookupGlobal() { return false; }
/** Tool has none **/
@Override
@@ -88,12 +93,12 @@ public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
}
@Override
- public boolean useToolGetProcAdressFirst(String funcName) {
+ public final boolean useToolGetProcAdressFirst(String funcName) {
return false;
}
@Override
- public List<List<String>> getToolLibNames() {
+ public final List<List<String>> getToolLibNames() {
final List<List<String>> libsList = new ArrayList<List<String>>();
final List<String> libsCg = new ArrayList<String>();
libsCg.add("Cg");
@@ -112,7 +117,7 @@ public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
}
@Override
- public RunnableExecutor getLibLoaderExecutor() {
+ public final RunnableExecutor getLibLoaderExecutor() {
return DynamicLibraryBundle.getDefaultRunnableExecutor();
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
index 26d299663..8de178e49 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java
@@ -165,6 +165,6 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl {
};
public boolean blockUntilDone(Thread thread) {
- return ((Thread.currentThread() != thread) && !EventQueue.isDispatchThread());
+ return Thread.currentThread() != thread && !EventQueue.isDispatchThread();
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
index 837fc84bd..ef92100ad 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
@@ -115,6 +115,10 @@ public abstract class AnimatorBase implements GLAnimatorControl {
drawablesEmpty = true;
}
+ private static final boolean useAWTAnimatorImpl(int modeBits) {
+ return 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz;
+ }
+
/**
* Initializes implementation details post setup,
* invoked at {@link #add(GLAutoDrawable)}, {@link #start()}, ..
@@ -125,9 +129,9 @@ public abstract class AnimatorBase implements GLAnimatorControl {
*
* @throws GLException if Animator is {@link #isStarted()}
*/
- protected void initImpl(boolean force) {
+ protected synchronized void initImpl(boolean force) {
if( force || null == impl ) {
- if( 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz ) {
+ if( useAWTAnimatorImpl( modeBits ) ) {
try {
impl = (AnimatorImpl) awtAnimatorImplClazz.newInstance();
baseName = getBaseName("AWT");
@@ -150,20 +154,20 @@ public abstract class AnimatorBase implements GLAnimatorControl {
* @param enable
* @param bitValues
*
- * @throws GLException if Animator is {@link #isStarted()}
+ * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change
* @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD
*/
public synchronized void setModeBits(boolean enable, int bitValues) throws GLException {
- if( isStarted() ) {
- throw new GLException("Animator already started");
- }
final int _oldModeBits = modeBits;
if(enable) {
modeBits |= bitValues;
} else {
modeBits &= ~bitValues;
}
- if( _oldModeBits != modeBits ) {
+ if( useAWTAnimatorImpl( _oldModeBits ) != useAWTAnimatorImpl( modeBits ) ) {
+ if( isStarted() ) {
+ throw new GLException("Animator already started");
+ }
initImpl(true);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
index 23b0845ee..bbd2951b9 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java
@@ -61,6 +61,6 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl {
}
public boolean blockUntilDone(Thread thread) {
- return (Thread.currentThread() != thread);
+ return Thread.currentThread() != thread;
}
}