From 3fb76fcef1e6dd552ec0f677af67baf3186a1434 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Jun 2014 15:57:53 +0200 Subject: Bug 741 HiDPI: Simplify ScalableSurface [set|get]SurfaceScale(..) spec, which also fixed JAWTWindow getSurfaceScale() issue on Windows Let setSurfaceScale(..) return the validated requested values and getSurfaceScale(..) always the current values. This removes complication and solves a bug w/ JAWTWindow on Windows, where we used 'drawable' as an indicator for 'previous locked' state. The latter is not true since on Windows 'drawable' is set to null in unlock, getWindowHandle() should be taken instead. --- .../classes/jogamp/nativewindow/SurfaceScaleUtils.java | 2 +- .../classes/jogamp/nativewindow/WrappedSurface.java | 10 +++++++--- .../jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 7 ++++--- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/nativewindow/classes/jogamp') diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java index 22e67ecff..4586812e1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java @@ -95,7 +95,7 @@ public class SurfaceScaleUtils { * Validate the given requested pixelScale value pair, i.e. clip it to the * limits of {@link ScalableSurface#AUTOMAX_PIXELSCALE} and {@link #getPlatformMaxPixelScale(int[])} *

- * To be used by {@link ScalableSurface#setSurfaceScale(int[])} implementations. + * To be used by {@link ScalableSurface#setSurfaceScale(int[], int[])} implementations. *

* * @param result int[2] storage for result diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java index 1a8772988..96862cbd6 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -104,7 +104,7 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface /** * {@inheritDoc} *

- * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly. + * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[], int[]) given pixelScale} directly. *

*/ @Override @@ -117,7 +117,7 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface /** * {@inheritDoc} *

- * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly. + * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[], int[]) given pixelScale} directly. *

*/ @Override @@ -147,9 +147,13 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface *

*/ @Override - public final void setSurfaceScale(final int[] pixelScale) { + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { hasPixelScale[0] = pixelScale[0]; hasPixelScale[1] = pixelScale[1]; + if( null != result ) { + System.arraycopy(hasPixelScale, 0, result, 0, 2); + } + return result; } @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 3d88049b2..695fdac88 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -114,9 +114,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } @Override - public void setSurfaceScale(final int[] pixelScale) { - super.setSurfaceScale(pixelScale); - if( 0 != drawable ) { // locked at least once ! + public int[] setSurfaceScale(final int[] result, final int[] pixelScale) { + super.setSurfaceScale(result, pixelScale); + if( 0 != getWindowHandle() ) { // locked at least once ! final int hadPixelScaleX = getPixelScaleX(); updatePixelScale(); @@ -132,6 +132,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { }); } } + return result; } @Override -- cgit v1.2.3