summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-17 21:56:59 +0100
committerSven Gothel <[email protected]>2011-12-17 21:56:59 +0100
commitae099e6623cf973193647495a27bcd4b25230c4a (patch)
treee240495279b69030570a16dea994e7c8c52d1add /src
parentb5492631bbcfe23f9a6a292bfc5f53c7a7b8caec (diff)
MaxOSXWindowSystemInterface: deleteContext / releaseNSOpenGLLayer:
- release on main-thread doesn't wait anymore - use recursive lock
Diffstat (limited to 'src')
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m33
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.m2
2 files changed, 25 insertions, 10 deletions
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
index 34bf213ab..fe896cc53 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
@@ -55,6 +55,8 @@
- (void)deallocTex;
- (void)disableAnimation;
+- (void)releaseLayer;
+- (void)dealloc;
- (int)getSwapInterval;
- (void)setSwapInterval:(int)interval;
- (void)tick;
@@ -94,7 +96,10 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
texWidth: (int) _texWidth
texHeight: (int) _texHeight;
{
- pthread_mutex_init(&renderLock, NULL); // fast non-recursive
+ pthread_mutexattr_t renderLockAttr;
+ pthread_mutexattr_init(&renderLockAttr);
+ pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&renderLock, &renderLockAttr); // recursive
pthread_cond_init(&renderSignal, NULL); // no attribute
// no animations for add/remove/swap sublayers etc
@@ -203,6 +208,17 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
pthread_mutex_unlock(&renderLock);
}
+- (void)releaseLayer
+{
+ DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]);
+ pthread_mutex_lock(&renderLock);
+ [self disableAnimation];
+ [self deallocTex];
+ [self release];
+ DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]);
+ pthread_mutex_unlock(&renderLock);
+}
+
- (void)dealloc
{
DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]);
@@ -450,16 +466,15 @@ void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) {
void releaseNSOpenGLLayer(NSOpenGLLayer* layer) {
MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p (refcnt %d)\n", l, (int)[l retainCount]);
+ DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l);
- [l performSelectorOnMainThread:@selector(disableAnimation) withObject:nil waitUntilDone:YES];
- // [l disableAnimation];
-
- [l performSelectorOnMainThread:@selector(deallocTex) withObject:nil waitUntilDone:YES];
- // [l deallocTex];
+ if ( [NSThread isMainThread] == YES ) {
+ [l releaseLayer];
+ } else {
+ [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO];
+ }
- [l release];
- DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p (refcnt %d)\n", l, (int)[l retainCount]);
+ DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l);
[pool release];
}
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
index 8c04f1774..b5979d53e 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -603,7 +603,7 @@ Bool deleteContext(NSOpenGLContext* ctx, Bool releaseOnMainThread) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[ctx clearDrawable];
if(releaseOnMainThread && NO == [NSThread isMainThread]) {
- [ctx performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:YES];
+ [ctx performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
} else {
// would hangs for ~10s for 1 of a shared context set or offscreen context, set releaseOnMainThread=true !
[ctx release];