aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-21 07:38:04 +0200
committerSven Gothel <[email protected]>2013-06-21 07:38:04 +0200
commit7ae47a845c625b9677b5879831d87a14d8e57311 (patch)
tree87c04cbd72a3f5d0ee31a1fbe8c0de046d696548
parent889ba9488ca07b59fdcc378642a2dc20676d69a3 (diff)
GL*ProcAddressTable: Fix regressions: getField(..) -> getDeclaredField(..), incl. access check; Move getAddressFor() from ctx -> private dbg-handler (sec); FFMPEGMediaPlayer: Missed fetching func-ptr 'glTexSubImage2D'.
-rw-r--r--make/scripts/tests.sh7
-rw-r--r--src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java31
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java16
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java1
5 files changed, 44 insertions, 29 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index b44b7f8ff..46d7876d3 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -139,7 +139,8 @@ function jrun() {
#D_ARGS="-Dnewt.test.Screen.disableRandR13"
#D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen"
#D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator"
- D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil"
+ #D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil"
+ #D_ARGS="-Djogl.debug.GLContext -Djogamp.debug.NativeLibrary -Djogamp.debug.JNILibLoader -Djogl.debug.DebugGL -Djogl.debug.GLDebugMessageHandler"
#D_ARGS="-Dnewt.debug.MainThread"
#D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch"
@@ -306,7 +307,7 @@ function testawtswt() {
# av demos
#
#testnoawt jogamp.opengl.openal.av.ALDummyUsage $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $*
#
@@ -315,7 +316,7 @@ function testawtswt() {
#testnoawt com.jogamp.nativewindow.NativeWindowVersion $*
#testnoawt com.jogamp.opengl.JoglVersion $*
#testnoawt com.jogamp.newt.NewtVersion $*
-testnoawt com.jogamp.newt.opengl.GLWindow $*
+#testnoawt com.jogamp.newt.opengl.GLWindow $*
#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $*
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
index 356482581..7c49b62d7 100644
--- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
+++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java
@@ -39,7 +39,6 @@
*/
package com.jogamp.gluegen.opengl;
-import com.jogamp.common.util.SecurityUtil;
import com.jogamp.gluegen.ConstantDefinition;
import com.jogamp.gluegen.FunctionEmitter;
import com.jogamp.gluegen.GlueEmitterControls;
@@ -461,7 +460,7 @@ public class GLEmitter extends ProcAddressEmitter {
@Override
protected void endProcAddressTable() throws Exception {
PrintWriter w = tableWriter;
-
+
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);");
@@ -470,9 +469,17 @@ public class GLEmitter extends ProcAddressEmitter {
w.println(" int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);");
w.println(" for(int i = 0; null==addressField && i < funcNamePermNum; i++) {");
w.println(" final String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);");
- w.println(" try {");
- w.println(" addressField = getClass().getField(addressFieldName);");
- w.println(" } catch (Exception e) { }");
+ w.println(" addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.lang.reflect.Field>() {");
+ w.println(" public java.lang.reflect.Field run() {");
+ w.println(" try {");
+ w.println(" final java.lang.reflect.Field 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(" return null;");
+ w.println(" }");
+ w.println(" }");
+ w.println(" } );");
w.println(" }");
w.println();
w.println(" if(null==addressField) {");
@@ -502,9 +509,17 @@ public class GLEmitter extends ProcAddressEmitter {
w.println(" int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);");
w.println(" for(int i = 0; null==addressField && i < funcNamePermNum; i++) {");
w.println(" final String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);");
- w.println(" try {");
- w.println(" addressField = getClass().getField(addressFieldName);");
- w.println(" } catch (Exception e) { }");
+ w.println(" addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.lang.reflect.Field>() {");
+ w.println(" public java.lang.reflect.Field run() {");
+ w.println(" try {");
+ w.println(" final java.lang.reflect.Field 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(" return null;");
+ w.println(" }");
+ w.println(" }");
+ w.println(" } );");
w.println(" }");
w.println();
w.println(" if(null==addressField) {");
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 4ab051028..6254b6f44 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1155,22 +1155,6 @@ public abstract class GLContextImpl extends GLContext {
} );
}
- /**
- * Catches IllegalArgumentException and returns 0 if functionName is n/a,
- * otherwise the ProcAddressTable's field value.
- */
- /* pp */ final long getAddressFor(final ProcAddressTable table, final String functionName) {
- return AccessController.doPrivileged(new PrivilegedAction<Long>() {
- public Long run() {
- try {
- return Long.valueOf( table.getAddressFor(functionName) );
- } catch (IllegalArgumentException iae) {
- return Long.valueOf(0);
- }
- }
- } ).longValue();
- }
-
private final boolean initGLRendererAndGLVersionStrings() {
final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper();
final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString");
diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
index 392b5db28..4c7f414ca 100644
--- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
+++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
@@ -27,6 +27,8 @@
*/
package jogamp.opengl;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import javax.media.nativewindow.NativeWindowException;
@@ -105,6 +107,18 @@ public class GLDebugMessageHandler {
}
}
+ private final long getAddressFor(final ProcAddressTable table, final String functionName) {
+ return AccessController.doPrivileged(new PrivilegedAction<Long>() {
+ public Long run() {
+ try {
+ return Long.valueOf( table.getAddressFor(functionName) );
+ } catch (IllegalArgumentException iae) {
+ return Long.valueOf(0);
+ }
+ }
+ } ).longValue();
+ }
+
public void init() {
ctx.validateCurrent();
if( isAvailable()) {
@@ -149,10 +163,10 @@ public class GLDebugMessageHandler {
if( ctx.isGL4() ) {
switch(extType) {
case EXT_ARB:
- glDebugMessageCallbackProcAddress = ctx.getAddressFor(procAddressTable, "glDebugMessageCallbackARB");
+ glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackARB");
break;
case EXT_AMD:
- glDebugMessageCallbackProcAddress = ctx.getAddressFor(procAddressTable, "glDebugMessageCallbackAMD");
+ glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackAMD");
break;
}
} else {
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index 0c578f97f..a4178967c 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -202,6 +202,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl {
setTextureType(GL.GL_UNSIGNED_BYTE);
final GLContextImpl ctx = (GLContextImpl)gl.getContext();
final ProcAddressTable pt = ctx.getGLProcAddressTable();
+ procAddrGLTexSubImage2D = getAddressFor(pt, "glTexSubImage2D");
if( 0 == procAddrGLTexSubImage2D ) {
throw new InternalError("glTexSubImage2D n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion());
}