aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java76
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java33
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java2
4 files changed, 85 insertions, 30 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index c31b76401..05200324d 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -477,12 +477,12 @@ public abstract class GLContext {
public abstract GL setGL(GL gl);
/**
- * Returns the native GL context handle
+ * Returns the underlying native OpenGL context handle
*/
public final long getHandle() { return contextHandle; }
/**
- * Indicates whether the underlying OpenGL context has been created.
+ * Indicates whether the underlying native OpenGL context has been created.
*/
public final boolean isCreated() {
return 0 != contextHandle;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
index 1f6f49f88..f2efb0479 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
@@ -38,7 +38,7 @@ import javax.media.opengl.GLException;
import jogamp.opengl.Debug;
-import com.jogamp.common.util.LongIntHashMap;
+import com.jogamp.common.util.LongObjectHashMap;
import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
/**
@@ -54,11 +54,26 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
public class EGLDisplayUtil {
protected static final boolean DEBUG = Debug.debug("EGLDisplayUtil");
- static LongIntHashMap eglDisplayCounter;
+ private static class DpyCounter {
+ final long eglDisplay;
+ final Throwable createdStack;
+ int refCount;
+
+ private DpyCounter(long eglDisplay) {
+ this.eglDisplay = eglDisplay;
+ this.refCount = 0;
+ this.createdStack = DEBUG ? new Throwable() : null;
+ }
+
+ public String toString() {
+ return "EGLDisplay[0x"+Long.toHexString(eglDisplay)+": refCnt "+refCount+"]";
+ }
+ }
+ static final LongObjectHashMap eglDisplayCounter;
static {
- eglDisplayCounter = new LongIntHashMap();
- eglDisplayCounter.setKeyNotFoundValue(0);
+ eglDisplayCounter = new LongObjectHashMap();
+ eglDisplayCounter.setKeyNotFoundValue(null);
}
/**
@@ -80,9 +95,13 @@ public class EGLDisplayUtil {
public static void dumpOpenDisplayConnections() {
System.err.println("EGLDisplayUtil: Open EGL Display Connections: "+eglDisplayCounter.size());
int i=0;
- for(Iterator<LongIntHashMap.Entry> iter = eglDisplayCounter.iterator(); iter.hasNext(); i++) {
- final LongIntHashMap.Entry e = iter.next();
- System.err.println("EGLDisplayUtil: Open["+i+"]: 0x"+Long.toHexString(e.key)+": refCnt "+e.value);
+ for(Iterator<LongObjectHashMap.Entry> iter = eglDisplayCounter.iterator(); iter.hasNext(); i++) {
+ final LongObjectHashMap.Entry e = iter.next();
+ final DpyCounter v = (DpyCounter) e.value;
+ System.err.println("EGLDisplayUtil: Open["+i+"]: 0x"+Long.toHexString(e.key)+": "+v);
+ if(null != v.createdStack) {
+ v.createdStack.printStackTrace();
+ }
}
}
@@ -108,18 +127,32 @@ public class EGLDisplayUtil {
if( EGL.EGL_NO_DISPLAY == eglDisplay) {
return false;
}
- final boolean res;
- final int refCnt = eglDisplayCounter.get(eglDisplay) + 1; // 0 + 1 = 1 -> 1st init
+ final int refCnt;
+ final DpyCounter d;
+ {
+ DpyCounter _d = (DpyCounter) eglDisplayCounter.get(eglDisplay);
+ if(null == _d) {
+ _d = new DpyCounter(eglDisplay);
+ refCnt = 1; // 1st init
+ } else {
+ refCnt = _d.refCount + 1;
+ }
+ d = _d;
+ }
+ final boolean res;
if(1==refCnt) { // only initialize once
res = EGL.eglInitialize(eglDisplay, major, minor);
} else {
res = true;
- }
- if(res) { // map if successfully initialized, only
- eglDisplayCounter.put(eglDisplay, refCnt);
+ }
+ if(res) { // update refCount and map if successfully initialized, only
+ d.refCount = refCnt;
+ if(1 == refCnt) {
+ eglDisplayCounter.put(eglDisplay, d);
+ }
}
if(DEBUG) {
- System.err.println("EGLDisplayUtil.eglInitialize2("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+" = "+res);
+ System.err.println("EGLDisplayUtil.eglInitialize("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+", "+d+" = "+res);
// Thread.dumpStack();
}
return res;
@@ -186,13 +219,24 @@ public class EGLDisplayUtil {
return false;
}
final boolean res;
- final int refCnt = eglDisplayCounter.get(eglDisplay) - 1; // 1 - 1 = 0 -> final terminate
- if(0==refCnt) { // no terminate if still in use or already terminated
+ final int refCnt;
+ final DpyCounter d;
+ {
+ DpyCounter _d = (DpyCounter) eglDisplayCounter.get(eglDisplay);
+ if(null == _d) {
+ _d = null;
+ refCnt = -1; // n/a
+ } else {
+ refCnt = _d.refCount - 1; // 1 - 1 = 0 -> final terminate
+ }
+ d = _d;
+ }
+ if( 0 == refCnt ) { // no terminate if still in use or already terminated
res = EGL.eglTerminate(eglDisplay);
eglDisplayCounter.remove(eglDisplay);
} else {
if(0 < refCnt) { // no negative refCount
- eglDisplayCounter.put(eglDisplay, refCnt);
+ d.refCount = refCnt;
}
res = true;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index d65f8c231..99b629d1a 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -315,13 +315,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected abstract int lockSurfaceImpl() throws NativeWindowException;
protected void dumpJAWTInfo() {
- if(null != jawt) {
- System.err.println("JAWT version: 0x"+Integer.toHexString(jawt.getCachedVersion())+
- ", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(jawt)+
- ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets);
- } else {
- System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets);
- }
+ System.err.println(jawt2String(null).toString());
// Thread.dumpStack();
}
@@ -555,15 +549,32 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
return component.hasFocus();
}
+ protected StringBuilder jawt2String(StringBuilder sb) {
+ if( null == sb ) {
+ sb = new StringBuilder();
+ }
+ if(null != jawt) {
+ sb.append("JAWT version: 0x").append(Integer.toHexString(jawt.getCachedVersion())).
+ append(", CA_LAYER: ").append(JAWTUtil.isJAWTUsingOffscreenLayer(jawt)).
+ append(", isLayeredSurface ").append(isOffscreenLayerSurfaceEnabled()).append(", bounds ").append(bounds).append(", insets ").append(insets);
+ } else {
+ sb.append("JAWT n/a, bounds ").append(bounds).append(", insets ").append(insets);
+ }
+ return sb;
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("JAWT-Window["+
- "windowHandle "+toHexString(getWindowHandle())+
+ sb.append("JAWT-Window[");
+ jawt2String(sb);
+ sb.append( ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface+
+ ", attachedSurfaceLayer "+toHexString(getAttachedSurfaceLayer())+
+ ", windowHandle "+toHexString(getWindowHandle())+
", surfaceHandle "+toHexString(getSurfaceHandle())+
- ", bounds "+bounds+", insets "+insets+
- ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface);
+ ", bounds "+bounds+", insets "+insets
+ );
if(null!=component) {
sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+component.isVisible());
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 3c10859bf..9d5a878c6 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -416,7 +416,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
}
}
- if( ( removeNotify || windowClosing ) && null!=jawtWindow) {
+ if( ( removeNotify || windowClosing ) && null!=jawtWindow ) {
NewtFactoryAWT.destroyNativeWindow(jawtWindow);
jawtWindow=null;
}