From 53ba4a2b3639a3746218693ea588159e5c6d07c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 1 Dec 2011 16:48:45 +0100 Subject: GLDrawableFactory: Implementations lifecycle is handled via constructor/destroy() --- .../jogamp/opengl/egl/EGLDrawableFactory.java | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/egl') diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 4a1a4ccf5..fe4adb564 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -50,10 +50,9 @@ import java.util.HashMap; import java.util.List; public class EGLDrawableFactory extends GLDrawableFactoryImpl { - private static final GLDynamicLookupHelper eglES1DynamicLookupHelper; - private static final GLDynamicLookupHelper eglES2DynamicLookupHelper; - - static { + public EGLDrawableFactory() { + super(); + // Register our GraphicsConfigurationFactory implementations // The act of constructing them causes them to be registered EGLGraphicsConfigurationFactory.registerFactory(); @@ -94,13 +93,33 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { 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(); + } } - public EGLDrawableFactory() { - super(); - defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + protected final void destroy() { + if(null != sharedMap) { + sharedMap.clear(); + sharedMap = null; + } + defaultDevice = null; + if(null != eglES1DynamicLookupHelper) { + eglES1DynamicLookupHelper.destroy(); + eglES1DynamicLookupHelper = null; + } + if(null != eglES2DynamicLookupHelper) { + eglES2DynamicLookupHelper.destroy(); + eglES2DynamicLookupHelper = null; + } } + private GLDynamicLookupHelper eglES1DynamicLookupHelper; + private GLDynamicLookupHelper eglES2DynamicLookupHelper; + private HashMap/**/ sharedMap; + private EGLGraphicsDevice defaultDevice; + static class SharedResource { private EGLGraphicsDevice device; // private EGLDrawable drawable; @@ -125,8 +144,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final boolean wasES1ContextAvailable() { return wasES1ContextCreated; } final boolean wasES2ContextAvailable() { return wasES2ContextCreated; } } - HashMap/**/ sharedMap = new HashMap(); - EGLGraphicsDevice defaultDevice; public final AbstractGraphicsDevice getDefaultDevice() { return defaultDevice; @@ -243,8 +260,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } - protected final void shutdownInstance() {} - protected List getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) { return EGLGraphicsConfigurationFactory.getAvailableCapabilities(this, device); } -- cgit v1.2.3