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() --- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 77 ++++++++++++---------- 1 file changed, 44 insertions(+), 33 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/macosx') diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index ed7959ae8..4543424a6 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -72,43 +72,58 @@ import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { - private static final DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper; - - static { - DesktopGLDynamicLookupHelper tmp = null; - try { - tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo()); - } catch (GLException gle) { - if(DEBUG) { - gle.printStackTrace(); - } + public MacOSXCGLDrawableFactory() { + super(); + + DesktopGLDynamicLookupHelper tmp = null; + try { + tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo()); + } catch (GLException gle) { + if(DEBUG) { + gle.printStackTrace(); } - macOSXCGLDynamicLookupHelper = tmp; + } + macOSXCGLDynamicLookupHelper = tmp; + + if(null!=macOSXCGLDynamicLookupHelper) { /** FIXME ?? - if(null!=macOSXCGLDynamicLookupHelper) { - CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper); - } */ + CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper); + */ + + // Register our GraphicsConfigurationFactory implementations + // The act of constructing them causes them to be registered + MacOSXCGLGraphicsConfigurationFactory.registerFactory(); + if(GLProfile.isAWTAvailable()) { + try { + ReflectionUtil.callStaticMethod("jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory", + "registerFactory", null, null, getClass().getClassLoader()); + } catch (JogampRuntimeException jre) { /* n/a .. */ } + } + + defaultDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); + sharedMap = new HashMap(); + } + } + + protected final void destroy() { + if(null != sharedMap) { + sharedMap.clear(); + sharedMap = null; + } + defaultDevice = null; + if(null != macOSXCGLDynamicLookupHelper) { + macOSXCGLDynamicLookupHelper.destroy(); + macOSXCGLDynamicLookupHelper = null; + } } public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) { return macOSXCGLDynamicLookupHelper; } - public MacOSXCGLDrawableFactory() { - super(); - - // Register our GraphicsConfigurationFactory implementations - // The act of constructing them causes them to be registered - MacOSXCGLGraphicsConfigurationFactory.registerFactory(); - if(GLProfile.isAWTAvailable()) { - try { - ReflectionUtil.callStaticMethod("jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory", - "registerFactory", null, null, getClass().getClassLoader()); - } catch (JogampRuntimeException jre) { /* n/a .. */ } - } - - defaultDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); - } + private DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper; + private HashMap sharedMap = new HashMap(); + private MacOSXGraphicsDevice defaultDevice; static class SharedResource { // private MacOSXCGLDrawable drawable; @@ -136,8 +151,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { final boolean isRECTTextureAvailable() { return hasRECTTextures; } final boolean isAppletFloatPixelsAvailable() { return hasAppletFloatPixels; } } - HashMap sharedMap = new HashMap(); - MacOSXGraphicsDevice defaultDevice; public final AbstractGraphicsDevice getDefaultDevice() { return defaultDevice; @@ -259,8 +272,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { return null; } - protected final void shutdownInstance() {} - protected List getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) { return MacOSXCGLGraphicsConfiguration.getAvailableCapabilities(this, device); } -- cgit v1.2.3