diff options
author | Sven Gothel <[email protected]> | 2013-02-16 03:55:22 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-16 03:55:22 +0100 |
commit | a94ff9252df66c303f48489c3e8926104941465c (patch) | |
tree | 1269a332e763c40ac97b1f137523e3ced3f6aaaa /make/config/jogl | |
parent | d178475967536f4d1e58fd6e0be49b03fe4cd4b7 (diff) |
Fix Bug 691 (part-3): NSOpenGLLayer::openGLContextForPixelFormat(..) on main-thread deadlock'ed due to locked shared context
NSOpenGLLayer::openGLContextForPixelFormat(..) is performed on main-thread at 1st NSOpenGLLayer display method.
This happened irregulary, i.e. sometimes (T0) right after NSOpenGLLayer creation and attachSurfaceLayer()/AddCASublayer(..),
sometimes later (T1).
NSOpenGLLayer::openGLContextForPixelFormat(..) uses the passed shared user context.
The shared user context is locked at NSOpenGLLayer's creation (T0) and if performed at this early time
the call deadlocks due to pthread_mutex wait for the shared user context.
This fix performs NSOpenGLLayer creation and layer attachment while the shared user context
is kept unlocked and enforces NSOpenGLLayer display and hence NSOpenGLLayer::openGLContextForPixelFormat(..).
Added CGL.setNSOpenGLLayerEnabled(..) to enable/disable NSOpenGLLayer - currently not used.
- Passed AddRemove tests for GLCanvas/Swing and GLWindow/NewtCanvasAWT w/ 100 loops on Java6 and Java7 on OSX.
- Passed Instruments Leaks test w/ 10 loops on Java6 and Java7
Diffstat (limited to 'make/config/jogl')
-rw-r--r-- | make/config/jogl/cgl-macosx-CustomJavaCode.java | 22 | ||||
-rw-r--r-- | make/config/jogl/cgl-macosx.cfg | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/make/config/jogl/cgl-macosx-CustomJavaCode.java b/make/config/jogl/cgl-macosx-CustomJavaCode.java index b9a37d0c6..d32e0ae8f 100644 --- a/make/config/jogl/cgl-macosx-CustomJavaCode.java +++ b/make/config/jogl/cgl-macosx-CustomJavaCode.java @@ -1,6 +1,14 @@ /** * Creates the NSOpenGLLayer for FBO/PBuffer w/ optional GL3 shader program on Main-Thread + * <p> + * It is mandatory that the shared context handle <code>ctx</code> + * is not locked while calling this method. + * </p> + * <p> + * The NSOpenGLLayer starts in enabled mode, + * you may enable/disable it via {@link #setNSOpenGLLayerEnabled(long, boolean)}. + * </p> */ public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgramName, final long fmt, final long p, final int texID, final boolean opaque, final int texWidth, final int texHeight) { @@ -11,6 +19,20 @@ public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgra } /** + * Enable or disable NSOpenGLLayer. + * + * <p> + * If disabled, the NSOpenGLLayer will not be displayed, i.e. rendered. + * </p> + */ +public static void setNSOpenGLLayerEnabled(final long nsOpenGLLayer, final boolean enable) { + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + setNSOpenGLLayerEnabledImpl(nsOpenGLLayer, enable); + } } ); +} + +/** * Releases the NSOpenGLLayer on Main-Thread */ public static void releaseNSOpenGLLayer(final long nsOpenGLLayer) { diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg index 98123f605..edb5bfbbf 100644 --- a/make/config/jogl/cgl-macosx.cfg +++ b/make/config/jogl/cgl-macosx.cfg @@ -35,8 +35,10 @@ CustomCCode #include </usr/include/machine/types.h> CustomCCode #include "macosx-window-system.h" AccessControl createNSOpenGLLayerImpl PRIVATE +AccessControl setNSOpenGLLayerEnabledImpl PRIVATE AccessControl releaseNSOpenGLLayerImpl PRIVATE RenameJavaMethod createNSOpenGLLayer createNSOpenGLLayerImpl +RenameJavaMethod setNSOpenGLLayerEnabled setNSOpenGLLayerEnabledImpl RenameJavaMethod releaseNSOpenGLLayer releaseNSOpenGLLayerImpl IncludeAs CustomJavaCode CGL cgl-macosx-CustomJavaCode.java |