diff options
author | Sven Gothel <sgothel@jausoft.com> | 2011-12-17 21:56:59 +0100 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2011-12-17 21:56:59 +0100 |
commit | ae099e6623cf973193647495a27bcd4b25230c4a (patch) | |
tree | e240495279b69030570a16dea994e7c8c52d1add /src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m | |
parent | b5492631bbcfe23f9a6a292bfc5f53c7a7b8caec (diff) |
MaxOSXWindowSystemInterface: deleteContext / releaseNSOpenGLLayer:
- release on main-thread doesn't wait anymore
- use recursive lock
Diffstat (limited to 'src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m')
-rw-r--r-- | src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m | 33 |
1 files changed, 24 insertions, 9 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]; } |