From de8a370258e60ad9bcf40cf8e6d239ecf306114e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 6 Nov 2013 15:30:50 +0100 Subject: Bug 894 - GLDrawableFactory* [dummy|offscreen] Surface creation w/ own device does _not_ require locking on global shared device. --- .../jogamp/opengl/GLDrawableFactoryImpl.java | 53 +++++++++------------- 1 file changed, 22 insertions(+), 31 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 cadf40f02..c914b5e10 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -270,16 +270,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); - GLDrawableImpl drawable = null; - device.lock(); - try { - drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, - new UpstreamSurfaceHookMutableSize(width, height) ) ); - if(null != drawable) { - drawable.setRealized(true); - } - } finally { - device.unlock(); + final GLDrawableImpl drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); + if(null != drawable) { + drawable.setRealized(true); } return new GLPbufferImpl( drawable, (GLContextImpl) drawable.createContext(shareWith) ); @@ -350,19 +344,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, this, device); - device.lock(); - try { - if( capsChosen.isFBO() ) { - // Use minimum GLCapabilities for the dummy surface w/ same profile - final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); - return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); - } - return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, - new UpstreamSurfaceHookMutableSize(width, height) ) ); - } finally { - device.unlock(); + if( capsChosen.isFBO() ) { + // Use minimum GLCapabilities for the dummy surface w/ same profile + final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); } + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); } @Override @@ -371,12 +360,16 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice); } - device.lock(); + if( !createNewDevice ) { + device.lock(); + } try { final ProxySurface dummySurface = createDummySurfaceImpl(device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64); return createOnscreenDrawableImpl(dummySurface); } finally { - device.unlock(); + if( !createNewDevice ) { + device.unlock(); + } } } @@ -398,7 +391,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * Lifecycle (destruction) of the TBD surface handle shall be handled by the caller. *

* @param device a valid platform dependent target device. - * @param createNewDevice if true a new device instance is created using device details, + * @param createNewDevice if true a new independent device instance is created using device details, * otherwise device instance is used as-is. * @param capsChosen * @param capsRequested @@ -418,6 +411,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. * It also allows creation of framebuffer objects which are used for rendering or using a shared GLContext w/o actually rendering to a usable framebuffer. *

+ *

+ * Creates a new independent device instance using deviceReq details. + *

* @param deviceReq which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param requestedCaps * @param chooser the custom chooser, may be null for default @@ -434,12 +430,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - device.lock(); - try { - return createDummySurfaceImpl(device, true, requestedCaps, requestedCaps, chooser, width, height); - } finally { - device.unlock(); - } + return createDummySurfaceImpl(device, true, requestedCaps, requestedCaps, chooser, width, height); } /** -- cgit v1.2.3