summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-26 15:49:59 +0100
committerSven Gothel <[email protected]>2011-11-26 15:49:59 +0100
commite02a1460018c7f32d7851dfdea41db551543122c (patch)
tree0df2ddc120868f808bdd730d48848287ef27457d /src
parent6fe980308f6042f7a3077b724d28f4c3719ba331 (diff)
OSX GLLayer (native): Remove CALayer add/remove/swap sublayer animation; Fix DestroyNSWindow0
The CALayer animations (add/remove/swap) confused somewhat rendering (layer position) and even triggered a deallocation sometimes.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m15
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m35
2 files changed, 28 insertions, 22 deletions
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
index 47f679fac..34bf213ab 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
@@ -97,6 +97,11 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
pthread_mutex_init(&renderLock, NULL); // fast non-recursive
pthread_cond_init(&renderSignal, NULL); // no attribute
+ // no animations for add/remove/swap sublayers etc
+ [self removeAnimationForKey: kCAOnOrderIn];
+ [self removeAnimationForKey: kCAOnOrderOut];
+ [self removeAnimationForKey: kCATransition];
+
pbuffer = p;
[pbuffer retain];
@@ -201,6 +206,8 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
- (void)dealloc
{
DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]);
+ // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]);
+
[self disableAnimation];
[self deallocTex];
pthread_cond_destroy(&renderSignal);
@@ -229,7 +236,6 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
{
[context makeCurrentContext];
- // FIXME ?? [context update];
/**
* v-sync doesn't works w/ NSOpenGLLayer's context .. well :(
@@ -261,13 +267,6 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
CGRect lRect = [self frame];
DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p frame0: %lf/%lf %lfx%lf\n",
self, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
- if(lRect.origin.x<0 || lRect.origin.y<0) {
- lRect.origin.x = 0;
- lRect.origin.y = 0;
- [self setFrame: lRect];
- DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p frame*: %lf/%lf %lfx%lf\n",
- self, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
- }
}
glBindTexture(textureTarget, textureID);
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index d7a2feff3..58e8b256d 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -40,7 +40,7 @@
#include <jawt_md.h>
#import <JavaNativeFoundation.h>
-// #define VERBOSE 1
+#define VERBOSE 1
//
#ifdef VERBOSE
// #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__)
@@ -202,10 +202,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0
[myWindow setOpaque: NO];
[myWindow setBackgroundColor: [NSColor clearColor]];
- // force surface creation
- // [myView lockFocus];
- // [myView unlockFocus];
-
[pool release];
return (jlong) ((intptr_t) myWindow);
@@ -221,13 +217,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSWindow* mWin = (NSWindow*) ((intptr_t) nsWindow);
- NSView* mView = [mWin contentView];
- if(NULL!=mView) {
- [mWin setContentView: nil];
- [mView release];
- }
- [mWin orderOut: mWin];
[mWin close]; // performs release!
[pool release];
}
@@ -245,6 +235,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0
// CALayer* layer = [[CALayer alloc] init];
CALayer* layer = [CALayer layer];
+ // no animations for add/remove/swap sublayers etc
+ [layer removeAnimationForKey: kCAOnOrderIn];
+ [layer removeAnimationForKey: kCAOnOrderOut];
+ [layer removeAnimationForKey: kCATransition];
+
// initial dummy size !
CGRect lRect = [layer frame];
lRect.origin.x = 0;
@@ -272,11 +267,23 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer);
CGRect lRectRoot = [rootLayer frame];
- // simple 1:1 layout !
- [subLayer setFrame:lRectRoot];
- DBG_PRINT("CALayer::AddCASublayer0.0: %p . %p %lf/%lf %lfx%lf (refcnt %d)\n",
+ DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n",
+ rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height);
+ if(lRectRoot.origin.x<0 || lRectRoot.origin.y<0) {
+ lRectRoot.origin.x = 0;
+ lRectRoot.origin.y = 0;
+ [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+ [rootLayer setFrame: lRectRoot];
+ }];
+ DBG_PRINT("CALayer::AddCASublayer0.1: Origin %p frame*: %lf/%lf %lfx%lf\n",
+ rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height);
+ }
+ DBG_PRINT("CALayer::AddCASublayer0.2: %p . %p %lf/%lf %lfx%lf (refcnt %d)\n",
rootLayer, subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]);
+
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+ // simple 1:1 layout !
+ [subLayer setFrame:lRectRoot];
[rootLayer addSublayer:subLayer];
}];
DBG_PRINT("CALayer::AddCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);