diff options
author | Sven Gothel <[email protected]> | 2013-02-20 21:51:40 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-20 21:51:40 +0100 |
commit | 14b278536e6f8de2ee6254796b89bd27d5419b72 (patch) | |
tree | 0f4ec76f215cbba178eb6732c1f2a9363df9d6d5 /src/jogl | |
parent | cf3ecdb670c0dfecd1394d5b9d5d5588c1bf71f3 (diff) |
OSX/Java7/CALayer + JAWT: Partially Fix AWT/NEWT CALayer 'out of sight' bug, where our CALayer is moved out of the visible area
- same erroneous behavior for GLCanvas and NewtCanvasAWT
- sized-frame: Set framesize and validate() it
- sized-component: Set component preferred size and call frame.pack()
- added workaround 'OffscreenLayerSurface.layoutSurfaceLayer()' to fix CALayer size, which snaps for:
- OK initial size before setVisible: sized-frame and sized-component
- OK resize w/ sized-frame
- OK manual frame resize
- Invisible: w/ sized-component after setVisible()
++
- CALayer-Sublayer (GL) has additional retain/release when added/removed
to be on safe side.
Diffstat (limited to 'src/jogl')
3 files changed, 21 insertions, 7 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c9069f9ce..dc4fe955c 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -702,6 +702,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + jawtWindow.layoutSurfaceLayer(); + } } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 37aca0cd7..9e0174595 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -713,6 +713,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } } + backingLayerHost.layoutSurfaceLayer(); } else { lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 55c4ad053..b965accab 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -114,6 +114,7 @@ extern GLboolean glIsVertexArray (GLuint array); - (void)dealloc { CGLContextObj cglCtx = [self CGLContextObj]; + DBG_PRINT("MyNSOpenGLContext::dealloc.0 %p (refcnt %d) - CGL-Ctx %p\n", self, (int)[self retainCount], cglCtx); [self clearDrawable]; if( NULL != cglCtx ) { @@ -537,7 +538,6 @@ static const GLfloat gl_verts[] = { { DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); - [self disableAnimation]; pthread_mutex_lock(&renderLock); [self deallocPBuffer]; @@ -555,13 +555,23 @@ static const GLfloat gl_verts[] = { - (void)resizeWithOldSuperlayerSize:(CGSize)size { - CGRect lRectS = [[self superlayer] bounds]; - - DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lf/%lf %lfx%lf (refcnt %d)\n", - self, texWidth, texHeight, size.width, size.height, lRectS.origin.x, lRectS.origin.y, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); + CALayer * superL = [self superlayer]; + CGRect lRectSFrame = [superL frame]; + + DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d -> size: %lfx%lf ; Super Frame[%lf/%lf %lfx%lf] (refcnt %d)\n", + self, texWidth, texHeight, size.width, size.height, + lRectSFrame.origin.x, lRectSFrame.origin.y, lRectSFrame.size.width, lRectSFrame.size.height, + (int)[self retainCount]); + + // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! + if( lRectSFrame.origin.x!=0 || lRectSFrame.origin.y!=0 ) { + lRectSFrame.origin.x = 0; + lRectSFrame.origin.y = 0; + [superL setPosition: lRectSFrame.origin]; + } - newTexWidth = lRectS.size.width; - newTexHeight = lRectS.size.height; + newTexWidth = lRectSFrame.size.width; + newTexHeight = lRectSFrame.size.height; shallDraw = [self isGLSourceValid]; SYNC_PRINT("<SZ %dx%d>", newTexWidth, newTexHeight); |