From a0177c8a1048683e5d43f4712f8f9e37091d4e85 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 4 Mar 2012 23:05:28 +0100 Subject: NEWT/GLWindow.display(): No explicit surface locking/unlocking for GLDrawableHelper.invokeGL(..) - it's done implicit at makeCurrent()/release() The explicit locking takes away the locking result, eg. SURFACE_CHANGED, which is required to update the delegated drawable handles (e.g.: EGL surface handle). With the followup fix of EGLDrawable.updateHandle()'s recreate EGL surface, an EGL 'wrapper' can work on Windows (eg. ANGLE). --- src/jogl/classes/javax/media/opengl/GLContext.java | 17 ++++++++++++++--- src/jogl/classes/jogamp/opengl/GLDrawableHelper.java | 7 +++++-- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 9 +++++++-- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 9 ++------- 4 files changed, 28 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 53b63cc0d..c039112c1 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -175,7 +175,7 @@ public abstract class GLContext { /** * Makes this GLContext current on the calling thread. - * + *

* There are two return values that indicate success and one that * indicates failure. A return value of CONTEXT_CURRENT_NEW * indicates that that context has been made current, and that @@ -185,15 +185,22 @@ public abstract class GLContext { * this case, the application may wish to initialize the state. A * return value of CONTEXT_CURRENT indicates that the context has * been made currrent, with its previous state restored. - * + *

+ *

* If the context could not be made current (for example, because * the underlying drawable has not ben realized on the display) , * a value of CONTEXT_NOT_CURRENT is returned. - * + *

+ *

* If the context is in use by another thread at the time of the * call, then if isSynchronized() is true the call will * block. If isSynchronized() is false, an exception will be * thrown and the context will remain current on the other thread. + *

+ *

+ * The drawable's surface is being locked at entry + * and unlocked at {@link #release()} + *

* * @return CONTEXT_CURRENT if the context was successfully made current * @return CONTEXT_CURRENT_NEW if the context was successfully made @@ -210,6 +217,10 @@ public abstract class GLContext { /** * Releases control of this GLContext from the current thread. + *

+ * The drawable's surface is being unlocked at exit, + * assumed to be locked by {@link #makeCurrent()}. + *

* * @throws GLException if the context had not previously been made * current on the current thread diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 509839f55..c992b3cb2 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -335,8 +335,11 @@ public class GLDrawableHelper { desired goal is to be able to implement GLAutoDrawable's in terms of the GLContext's public APIs, and putting it into a separate class helps ensure that we don't inadvertently use private - methods of the GLContext or its implementing classes.
- *
+ methods of the GLContext or its implementing classes. +

+ Note: Locking of the surface is implicit done by {@link GLContext#makeCurrent()}, + where unlocking is performed by the latter {@link GLContext#release()}. +

* * @param drawable * @param context diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index 02a94f31c..ba64127d4 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -135,7 +135,12 @@ public abstract class GLDrawableImpl implements GLDrawable { protected void destroyHandle() {} /** called with locked surface @ setRealized(true) or @ lockSurface(..) when surface changed */ - protected void updateHandle() {} + protected void updateHandle() { + if(DEBUG) { + System.err.println(getThreadName() + ": updateHandle: "+getClass().getSimpleName()+": "+this); + Thread.dumpStack(); + } + } public long getHandle() { return surface.getSurfaceHandle(); @@ -148,7 +153,7 @@ public abstract class GLDrawableImpl implements GLDrawable { public final synchronized void setRealized(boolean realizedArg) { if ( realized != realizedArg ) { if(DEBUG) { - System.err.println(getThreadName() + ": setRealized: "+getClass().getName()+" "+realized+" -> "+realizedArg); + System.err.println(getThreadName() + ": setRealized: "+getClass().getSimpleName()+" "+realized+" -> "+realizedArg); } realized = realizedArg; AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice(); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index c0d79a5d4..156e479fd 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -555,13 +555,8 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } if( null != context ) { // TODO: Check memory sync - if( NativeSurface.LOCK_SURFACE_NOT_READY < lockSurface() ) { - try { - helper.invokeGL(drawable, context, displayAction, initAction); - } finally { - unlockSurface(); - } - } + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(drawable, context, displayAction, initAction); } } -- cgit v1.2.3