From 098398c2a9145447da5314eed9792b3738c2d515 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Jan 2012 06:31:17 +0100 Subject: GLContext*/GLDrawableHelper: Fix consistency of recursive makeCurrent()/release()/destroy() calls ; Enable context switch tracing ; GLCanvas: proper AbstractGraphicsDevice destruction GLContext*/GLDrawableHelper: Fix consistency of recursive makeCurrent()/release()/destroy() calls Utilizing volatile and lock.tryLock(0) for lockConsiderFailFast(), reducing redundant synchronization and using RecursiveLock implicit sync. GLContext 'early-out' is the case where the thread already holds the context, ie. context is already current and the native makeCurrent is skipped. makeCurrent()'s 'early-out' w/o incr. the recursive lock of GLContext and it's NativeSurface could lead to asymetry in lock/unlock count with release()/destroy() calls. The 1st release actually released the native ctx already. Properly utilize recursive lock/unlock in all cases and impl. 'early-out' after locking. Following the above in GLDrawableHelper.invokeGL()'s 'early-out' case as well, ie calling makeCurrent()/release() symmetrical. Introduce GLDrawableHelper.disposeGL(), which issues dispose on all GLEventListeners within a current context and issued context destruction directly. This simplifies GLAutodrawable's destroy/dispose calls and ensures that the above sequence of events happens atomically (lock is being hold until destruction). Enable context switch tracing If property 'jogl.debug.GLContext.TraceSwitch' is defined, trace context switch. GLCanvas: proper AbstractGraphicsDevice destruction --- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/newt/classes/com/jogamp') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index d03a475ee..1a15a9664 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -355,14 +355,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // Hide methods here .. protected class GLLifecycleHook implements WindowImpl.LifecycleHook { - private class DisposeAction implements Runnable { - public final void run() { - // Lock: Covered by DestroyAction .. - helper.dispose(GLWindow.this); - } - } - DisposeAction disposeAction = new DisposeAction(); - public synchronized void destroyActionPreLock() { // nop } @@ -380,11 +372,10 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. try { - helper.invokeGL(drawable, context, disposeAction, null); + helper.disposeGL(GLWindow.this, drawable, context, null); } catch (GLException gle) { gle.printStackTrace(); } - context.destroy(); } drawable.setRealized(false); } -- cgit v1.2.3