aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-01 21:40:12 +0100
committerSven Gothel <[email protected]>2011-12-01 21:40:12 +0100
commitb6aa455d21fbcfc256ae8f8f4d66493c17e23f4c (patch)
tree373c8a31d6ce9ac98cd290e8c6872ec6145f0c7e /src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
parent919aabb77250cb0e272dac228388592d08bf98f5 (diff)
New GLProfile.ShutdownType: SHARED_ONLY / COMPLETE - Enhance/Fix Lifecycle Management
- Leave Platform, .. TempJarCache untouched. - GLDrawableFactoryImpl*: Leave DynamicLibraryBundle(lib-binding) untouched, for NativeLibrary, JNILibLoaderBase (JNI libs), .. consistency. - SHARED_ONLY: shutdown shared GLDrawableFactoryImpl* resources and NativeWindowFactory - COMPLETE: additionally shutdown GLContext* Clear all cached GL/GLX proc-address and device/context mappings. - Use new "GLProfile.shutdown(GLProfile.ShutdownType.SHARED_ONLY)" in Applets - X11GLXDrawableFactory Shutdown: Uncomment close/destroy of shared resources. - JAWTWindow.destroy(): Close the delegated device. In case it's X11 this closes the exclusive opened X11 Display.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java77
1 files changed, 46 insertions, 31 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index fe4adb564..f6988a73f 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -39,6 +39,7 @@ package jogamp.opengl.egl;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.EGLGraphicsDevice;
import javax.media.opengl.*;
+import javax.media.opengl.GLProfile.ShutdownType;
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.*;
@@ -50,6 +51,9 @@ import java.util.HashMap;
import java.util.List;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
+ private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null;
+ private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null;
+
public EGLDrawableFactory() {
super();
@@ -68,55 +72,66 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// to a dynamic one, where there can be 2 instances
// for each ES profile with their own ProcAddressTable.
- GLDynamicLookupHelper tmp=null;
- try {
- tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo());
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
+ synchronized(EGLDrawableFactory.class) {
+ if(null==eglES1DynamicLookupHelper) {
+ GLDynamicLookupHelper tmp=null;
+ try {
+ tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ eglES1DynamicLookupHelper = tmp;
+ if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) {
+ EGL.resetProcAddressTable(eglES1DynamicLookupHelper);
+ }
}
}
- eglES1DynamicLookupHelper = tmp;
- if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) {
- EGL.resetProcAddressTable(eglES1DynamicLookupHelper);
- }
- tmp=null;
- try {
- tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo());
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
+ synchronized(EGLDrawableFactory.class) {
+ if(null==eglES2DynamicLookupHelper) {
+ GLDynamicLookupHelper tmp=null;
+ try {
+ tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ eglES2DynamicLookupHelper = tmp;
+ if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) {
+ EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
+ }
}
}
- eglES2DynamicLookupHelper = tmp;
- if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) {
- EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
- }
if(null != eglES1DynamicLookupHelper || null != eglES2DynamicLookupHelper) {
defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
sharedMap = new HashMap();
}
}
- protected final void destroy() {
+ protected final void destroy(ShutdownType shutdownType) {
if(null != sharedMap) {
sharedMap.clear();
sharedMap = null;
}
defaultDevice = null;
- if(null != eglES1DynamicLookupHelper) {
- eglES1DynamicLookupHelper.destroy();
- eglES1DynamicLookupHelper = null;
- }
- if(null != eglES2DynamicLookupHelper) {
- eglES2DynamicLookupHelper.destroy();
- eglES2DynamicLookupHelper = null;
- }
+ /**
+ * Pulling away the native library may cause havoc ..
+ *
+ if(ShutdownType.COMPLETE == shutdownType) {
+ if(null != eglES1DynamicLookupHelper) {
+ eglES1DynamicLookupHelper.destroy();
+ eglES1DynamicLookupHelper = null;
+ }
+ if(null != eglES2DynamicLookupHelper) {
+ eglES2DynamicLookupHelper.destroy();
+ eglES2DynamicLookupHelper = null;
+ }
+ } */
}
- private GLDynamicLookupHelper eglES1DynamicLookupHelper;
- private GLDynamicLookupHelper eglES2DynamicLookupHelper;
private HashMap/*<connection, SharedResource>*/ sharedMap;
private EGLGraphicsDevice defaultDevice;