diff options
author | Sven Gothel <[email protected]> | 2023-01-22 01:25:24 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-01-22 01:25:24 +0100 |
commit | 470a0ff3a2efbe43404d5f80a403efb38005598a (patch) | |
tree | cefee0f2107b028fd337188f7ce2a9cba125d0f4 /src | |
parent | b8977465b2fb8452c2560a5d2561b2561472edf0 (diff) |
MacOS: JAWTWindow's OffscreeLayer: Show semantics in argument names and complete null checks in detachSurfaceLayerImpl(), setSurfaceScale()
Diffstat (limited to 'src')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java | 6 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 30 |
2 files changed, 19 insertions, 17 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 8ee1adc06..0c25b3e28 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -289,7 +289,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, maxPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE; hasPixelScaleChanged = false; } - protected abstract void invalidateNative(final long offscreenSurfaceLayer); + protected abstract void invalidateNative(final long _offscreenSurfaceLayer); /** * Set a new {@link AWTGraphicsConfiguration} instance, @@ -514,7 +514,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } } }; - protected void attachSurfaceLayerImpl(final long layerHandle) { + protected void attachSurfaceLayerImpl(final long _offscreenSurfaceLayer) { throw new UnsupportedOperationException("offscreen layer not supported"); } @@ -558,7 +558,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, /** * @param detachNotify Runnable to be called before native detachment */ - protected void detachSurfaceLayerImpl(final long layerHandle) { + protected void detachSurfaceLayerImpl(final long _offscreenSurfaceLayer) { throw new UnsupportedOperationException("offscreen layer not supported"); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 8848877d4..278ed8a00 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -125,11 +125,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { super.setSurfaceScale(pixelScale); if( 0 != getWindowHandle() && setReqPixelScale() ) { // locked at least once _and_ updated pixel-scale if( 0 != getAttachedSurfaceLayer() ) { - OSXUtil.RunOnMainThread(false, false, new Runnable() { + OSXUtil.RunOnMainThread(false /* wait */, false, new Runnable() { @Override public void run() { final long osl = getAttachedSurfaceLayer(); - if( 0 != osl ) { + if( 0 != rootSurfaceLayer && 0 != osl ) { OSXUtil.SetCALayerPixelScale(rootSurfaceLayer, osl, getPixelScaleX()); } } @@ -142,8 +142,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } @Override - protected void attachSurfaceLayerImpl(final long layerHandle) { - OSXUtil.RunOnMainThread(false, false /* kickNSApp */, new Runnable() { + protected void attachSurfaceLayerImpl(final long _offscreenSurfaceLayer) { + OSXUtil.RunOnMainThread(false /* wait */, false /* kickNSApp */, new Runnable() { @Override public void run() { // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. @@ -166,13 +166,13 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if( null != outterInsets ) { pA1.translate(-outterInsets.left, -outterInsets.top); } - System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+ + System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(_offscreenSurfaceLayer) + ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+ ", p0 "+p0+" -> "+p1+", bounds "+bounds); } else if( DEBUG ) { - System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds); + System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(_offscreenSurfaceLayer) + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds); } // HiDPI: uniform pixel scale - OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), getPixelScaleX(), JAWTUtil.getOSXCALayerQuirks()); + OSXUtil.AddCASublayer(rootSurfaceLayer, _offscreenSurfaceLayer, p1.getX(), p1.getY(), getWidth(), getHeight(), getPixelScaleX(), JAWTUtil.getOSXCALayerQuirks()); } } ); } @@ -218,12 +218,14 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } @Override - protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { - OSXUtil.RunOnMainThread(false, true /* kickNSApp */, new Runnable() { + protected void detachSurfaceLayerImpl(final long _offscreenSurfaceLayer) { + OSXUtil.RunOnMainThread(false /* wait */, true /* kickNSApp */, new Runnable() { @Override public void run() { - detachNotify.run(); - OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle, false); + if( 0 != rootSurfaceLayer && 0 != _offscreenSurfaceLayer ) { // Bug 1389 + // throws if null == rootSurfaceLayer + OSXUtil.RemoveCASublayer(rootSurfaceLayer, _offscreenSurfaceLayer, false); + } } }); } @@ -341,7 +343,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } if(null == errMsg) { jawtSurfaceLayersHandle = GetJAWTSurfaceLayersHandle0(dsi.getBuffer()); - OSXUtil.RunOnMainThread(false, false, new Runnable() { + OSXUtil.RunOnMainThread(false /* wait */, false, new Runnable() { @Override public void run() { String errMsg = null; @@ -431,12 +433,12 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { /** * Set the given root CALayer in the JAWT surface */ - private static native void SetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long caLayer); + private static native void SetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long rootCALayer); /** * Unset the given root CALayer in the JAWT surface, passing the NIO DrawingSurfaceInfo buffer */ - private static native void UnsetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long caLayer); + private static native void UnsetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long rootCALayer); // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; |