From 36dc4f5ab6957a4078842c488afb51df2fdc0630 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 26 Apr 2013 05:38:24 +0200 Subject: Simplify GLDrawableFactory's SharedResource Query Methods; Move WindowsWGLDrawableFactory Quirks to GLRendererQuirks (NeedCurrCtx4ARBPixFmtQueries, NeedCurrCtx4ARBCreateContext); Bug 706: Confine NeedCurrCtx4ARBCreateContext to [Windows, ATI, driver < 12.102.3); Avoid possible NPE @ GLContext.getGLVendorVersionNumber() - Simplify GLDrawableFactory's SharedResource Query Methods - Moving common methods to GLDrawableFactory/GLDrawableFactoryImpl while reusing common methods to SharedResourceRunner.Resource. - All factories SharedResources impl. SharedResourceRunner.Resource. - Move WindowsWGLDrawableFactory Quirks to GLRendererQuirks (NeedCurrCtx4ARBPixFmtQueries, NeedCurrCtx4ARBCreateContext) - For better maintenance, move the mentioned quirks from the windows factory to our common place, being detected within GLContextImpl after each context creation. - Bug 706: Confine NeedCurrCtx4ARBCreateContext to [Windows, ATI, driver < 12.102.3) - Before we added this quirk if [Windows, ATI], however, we have hopes that the new drivers will suffice for all as tested successful on my test machine (AMD Radeon HD 6300M Series, amd_catalyst_13.5_mobility_beta2). - Avoid possible NPE @ GLContext.getGLVendorVersionNumber() - GLContext.getGLVendorVersionNumber() never returns 'null' but a zero version instance instead! - Add API doc. - Use mixed case names in GLContextImpl.setRendererQuirks(..). --- .../jogamp/opengl/GLDrawableFactoryImpl.java | 61 ++++++++++++++++------ 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java') diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 26b1975ba..06e856d41 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -80,30 +80,61 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { super(); } - @Override - public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) { - final GLContext ctx = getOrCreateSharedContextImpl(device); - if(null != ctx) { - return ctx.getRendererQuirks(); + /** + * Returns the shared resource mapped to the device {@link AbstractGraphicsDevice#getConnection()}, + * either a pre-existing or newly created, or null if creation failed or not supported.
+ * Creation of the shared resource is tried only once. + * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + */ + protected final SharedResourceRunner.Resource getOrCreateSharedResource(AbstractGraphicsDevice device) { + try { + device = validateDevice(device); + if( null != device) { + return getOrCreateSharedResourceImpl( device ); + } + } catch (GLException gle) { + if(DEBUG) { + System.err.println("Catched Exception on thread "+getThreadName()); + gle.printStackTrace(); + } } return null; } - + protected abstract SharedResourceRunner.Resource getOrCreateSharedResourceImpl(AbstractGraphicsDevice device); + /** * Returns the shared context mapped to the device {@link AbstractGraphicsDevice#getConnection()}, - * either a pre-existing or newly created, or null if creation failed or not supported.
+ * either a pre-existing or newly created, or null if creation failed or not supported.
* Creation of the shared context is tried only once. * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. */ public final GLContext getOrCreateSharedContext(AbstractGraphicsDevice device) { - device = validateDevice(device); - if(null!=device) { - return getOrCreateSharedContextImpl(device); + final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device ); + if(null!=sr) { + return sr.getContext(); + } + return null; + } + + @Override + protected final boolean createSharedResourceImpl(AbstractGraphicsDevice device) { + final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device ); + if(null!=sr) { + return sr.isValid(); + } + return false; + } + + @Override + public final GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) { + final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device ); + if(null!=sr) { + return sr.getRendererQuirks(); } return null; } - protected abstract GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device); /** * Returns the shared device mapped to the device {@link AbstractGraphicsDevice#getConnection()}, @@ -113,15 +144,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. */ protected final AbstractGraphicsDevice getOrCreateSharedDevice(AbstractGraphicsDevice device) { - device = validateDevice(device); - if( null != device) { - return getOrCreateSharedDeviceImpl(device); + final SharedResourceRunner.Resource sr = getOrCreateSharedResource( device ); + if(null!=sr) { + return sr.getDevice(); } return null; } - protected abstract AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device); - /** * Returns the GLDynamicLookupHelper * @param profile if EGL/ES, profile 1 refers to ES1 and 2 to ES2, -- cgit v1.2.3