Jogamp
Findbugs.not-written.null: Fix referencing non-written fields (never written or due...
authorSven Gothel <sgothel@jausoft.com>
Tue, 8 Jul 2014 08:47:41 +0000 (10:47 +0200)
committerSven Gothel <sgothel@jausoft.com>
Tue, 8 Jul 2014 08:47:41 +0000 (10:47 +0200)
- AWT TextRenderer: Add throw new InternalError("fontRenderContext never initialized!"); FIXME!
- GLContextImpl.hasFBOImpl(): Fix serious NPE issue if extCache is null
- GLDrawableFactoryImpl.createOffscreenDrawableImpl(..):
  - Fix NPE issue w/ null drawable
  - Fix resetting GammaRamp by ensuring originalGammaRamp will be set at 1st setGammaRamp(..)

- AndroidGLMediaPlayerAPI14: Fix NPE: Use already resolved local referenced
- EGLDrawableFactory: Fix NPE: Only operate on non null surface!
- ALAudioSink.dequeueBuffer(..): Only resolve releasedBuffer elements if not null
-

src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
src/jogl/classes/jogamp/opengl/GLContextImpl.java
src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java
src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java

index 660d3bc..1c9eace 100644 (file)
@@ -1582,7 +1582,7 @@ public class TextRenderer {
 
     class GlyphProducer {
         final int undefined = -2;
-        FontRenderContext fontRenderContext;
+        FontRenderContext fontRenderContext = null; // FIXME: Never initialized!
         List<Glyph> glyphsOutput = new ArrayList<Glyph>();
         HashMap<String, GlyphVector> fullGlyphVectorCache = new HashMap<String, GlyphVector>();
         HashMap<Character, GlyphMetrics> glyphMetricsCache = new HashMap<Character, GlyphMetrics>();
@@ -1675,6 +1675,9 @@ public class TextRenderer {
 
             // Have to do this the hard / uncached way
             singleUnicode[0] = unicodeID;
+            if( null == fontRenderContext ) { // FIXME: Never initialized!
+                throw new InternalError("fontRenderContext never initialized!");
+            }
             final GlyphVector gv = font.createGlyphVector(fontRenderContext,
                                                                     singleUnicode);
             return gv.getGlyphMetrics(0).getAdvance();
index 9d2d21c..ec834e0 100644 (file)
@@ -413,7 +413,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
         final AWTGraphicsConfiguration config = chooseGraphicsConfiguration( (GLCapabilitiesImmutable)awtConfig.getChosenCapabilities(),
                                                                        (GLCapabilitiesImmutable)awtConfig.getRequestedCapabilities(),
                                                                        chooser, gc.getDevice());
-        final GraphicsConfiguration compatible = (null!=config)?config.getAWTGraphicsConfiguration():null;
+        final GraphicsConfiguration compatible = config.getAWTGraphicsConfiguration();
         final boolean equalCaps = config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities());
         if(DEBUG) {
             System.err.println(getThreadName()+": Info:");
@@ -1513,7 +1513,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
         }
     }
 
-    if (config == null) {
+    if ( null == config ) {
       throw new GLException("Error: Couldn't fetch AWTGraphicsConfiguration");
     }
 
index 8f75e71..4da8684 100644 (file)
@@ -281,11 +281,6 @@ public class VBORegion2PVBAAES2  extends GLRegion {
 
     @Override
     protected void updateImpl(final GL2ES2 gl) {
-        if(null == indicesFbo) {
-            if(Region.DEBUG_INSTANCE) {
-                System.err.println("VBORegion2PVBAAES2 Create: " + this);
-            }
-        }
         // seal buffers
         indicesBuffer.seal(gl, true);
         indicesBuffer.enableBuffer(gl, false);
index 5671334..832a797 100644 (file)
@@ -177,7 +177,7 @@ public abstract class GLContextImpl extends GLContext {
       glRendererLowerCase = glRenderer;
       glVersion = glVendor;
 
-      if (boundFBOTarget != null) { // <init>
+      if ( null != boundFBOTarget ) { // <init>: boundFBOTarget is not written yet
           boundFBOTarget[0] = 0; // draw
           boundFBOTarget[1] = 0; // read
       }
@@ -1939,19 +1939,20 @@ public abstract class GLContextImpl extends GLContext {
   }
 
   private static final boolean hasFBOImpl(final int major, final int ctp, final ExtensionAvailabilityCache extCache) {
-    return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) ||   // ES >= 2.0
+    return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) ||                           // ES >= 2.0
 
-           major >= 3 ||                                                 // any >= 3.0 GL ctx (core, compat and ES)
+           major >= 3 ||                                                              // any >= 3.0 GL ctx (core, compat and ES)
 
            ( null != extCache &&
+             (
+               extCache.isExtensionAvailable(GLExtensions.ARB_ES2_compatibility)  ||  // ES 2.0 compatible
 
-               extCache.isExtensionAvailable(GLExtensions.ARB_ES2_compatibility)  ||         // ES 2.0 compatible
+               extCache.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) ||  // ARB_framebuffer_object
 
-               extCache.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) ||         // ARB_framebuffer_object
+               extCache.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) ||  // EXT_framebuffer_object
 
-               extCache.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) ||         // EXT_framebuffer_object
-
-               extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ;        // OES_framebuffer_object excluded
+               extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object)     // OES_framebuffer_object
+             ) );
   }
 
   private final void removeCachedVersion(final int major, final int minor, int ctxProfileBits) {
index fd8052b..1aca29d 100644 (file)
@@ -272,11 +272,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
     final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested);
     final GLDrawableImpl drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser,
                                                                  new UpstreamSurfaceHookMutableSize(width, height) ) );
+    final GLContextImpl ctx;
     if(null != drawable) {
         drawable.setRealized(true);
+        ctx = (GLContextImpl) drawable.createContext(shareWith);
+    } else {
+        ctx = null;
     }
-
-    return new GLPbufferImpl( drawable, (GLContextImpl) drawable.createContext(shareWith) );
+    return new GLPbufferImpl( drawable, ctx);
   }
 
   //---------------------------------------------------------------------------
@@ -607,7 +610,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
         rampEntry = 0.0f;
       gammaRamp[i] = rampEntry;
     }
-    needsGammaRampReset = true;
+    if( !needsGammaRampReset ) {
+        originalGammaRamp = getGammaRamp();
+        needsGammaRampReset = true;
+    }
     return setGammaRamp(gammaRamp);
   }
 
index 9aa1c88..ea23b52 100644 (file)
@@ -420,7 +420,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
                     // stex.getTransformMatrix(atex.getSTMatrix());
                 }
             }
-            nextFrame.setPTS( pts );
+            sTexFrame.setPTS( pts );
         }
         return pts;
     }
index c4ee4bf..887bc1b 100644 (file)
@@ -478,8 +478,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
                     downstreamSurface = createDummySurfaceImpl(defaultDevice, false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen
                     if( null != downstreamSurface ) {
                         downstreamSurface.createNotify();
+                        surface = downstreamSurface;
                     }
-                    surface = downstreamSurface;
                 } else {
                     // 3rd case fake creation of defaultDevice shared resource, no pbuffer available
                     final List<GLCapabilitiesImmutable> capsAnyL = getAvailableEGLConfigs(defaultDevice, reqCapsAny);
@@ -499,14 +499,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
                 upstreamSurface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window
                 if(null != upstreamSurface) {
                     upstreamSurface.createNotify();
+                    eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface);
+                    eglDevice.open();
+                    if( DEBUG ) {
+                        dumpEGLInfo("EGLDrawableFactory.mapAvailableEGLESConfig: ", eglDevice.getHandle());
+                    }
+                    hasPBuffer[0] = true;
+                    surface = upstreamSurface;
                 }
-                surface = upstreamSurface;
-                eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface);
-                eglDevice.open();
-                if( DEBUG ) {
-                    dumpEGLInfo("EGLDrawableFactory.mapAvailableEGLESConfig: ", eglDevice.getHandle());
-                }
-                hasPBuffer[0] = true;
             }
 
             if(null != surface) {
index 305899f..cc15f0c 100644 (file)
@@ -217,8 +217,18 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize {
 
     @Override
     public String toString() {
-        final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": 0x" + Long.toHexString(upstreamSurface.getSurfaceHandle()) ) : "nil";
-        return "EGLUpstreamSurfaceHook[ "+ upstreamSurface.getSurfaceWidth() + "x" + upstreamSurface.getSurfaceHeight() + ", " + us_s+ "]";
+        final String us_s;
+        final int sw, sh;
+        if( null != upstreamSurface ) {
+            us_s = upstreamSurface.getClass().getName() + ": 0x" + Long.toHexString(upstreamSurface.getSurfaceHandle());
+            sw = upstreamSurface.getSurfaceWidth();
+            sh = upstreamSurface.getSurfaceHeight();
+        } else {
+            us_s = "nil";
+            sw = -1;
+            sh = -1;
+        }
+        return "EGLUpstreamSurfaceHook[ "+ sw + "x" + sh + ", " + us_s+ "]";
     }
 
 }
index b6ffced..ac55fcf 100644 (file)
@@ -617,13 +617,13 @@ public class ALAudioSink implements AudioSink {
                             throw new InternalError("Buffer name mismatch: dequeued: "+buffers[i]+", released "+releasedBuffer+", "+this);
                         }
                     }
-                }
-                alBufferBytesQueued -= releasedBuffer.getByteSize();
-                if( !alFramesAvail.put(releasedBuffer) ) {
-                    throw new InternalError("Internal Error: "+this);
-                }
-                if(DEBUG_TRACE) {
-                    System.err.println("<< [al "+buffers[i]+", q "+releasedBuffer.alBuffer+"] <- "+shortString()+" @ "+getThreadName());
+                    alBufferBytesQueued -= releasedBuffer.getByteSize();
+                    if( !alFramesAvail.put(releasedBuffer) ) {
+                        throw new InternalError("Internal Error: "+this);
+                    }
+                    if(DEBUG_TRACE) {
+                        System.err.println("<< [al "+buffers[i]+", q "+releasedBuffer.alBuffer+"] <- "+shortString()+" @ "+getThreadName());
+                    }
                 }
             }
         }
index 4d5d972..af5590b 100644 (file)
@@ -83,9 +83,18 @@ public class SWTEDTUtil implements EDTUtil {
         synchronized(edtLock) {
             if( nedt.isRunning() ) {
                 final Thread curT = Thread.currentThread();
-                final Thread swtT = !swtDisposed ? swtDisplay.getThread() : null;
+                final String swtTName;
+                final Thread swtT;
+                if( !swtDisposed ) {
+                    swtT = swtDisplay.getThread();
+                    swtTName = swtT.getName();
+                } else {
+                    swtT = null;
+                    swtTName = null;
+                }
                 final boolean onSWTEDT = swtT == curT;
-                throw new IllegalStateException("EDT still running and not subject to stop. Curr "+curT.getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", SWT-EDT "+swtT.getName()+", on SWT-EDT "+onSWTEDT);
+                throw new IllegalStateException("EDT still running and not subject to stop. Curr "+curT.getName()+
+                        ", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", SWT-EDT "+swtTName+", on SWT-EDT "+onSWTEDT);
             }
             if(DEBUG) {
                 System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt+", swtDisposed (skipping) "+swtDisposed);
http://JogAmp.org git info: FAQ, tutorial and man pages.