From 58153310faa4089417037e67e06c0812908cecd2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Jun 2014 18:04:51 +0200 Subject: Bug 741 HiDPI: Simplify ScalableSurface (2): Add request pixelScale API entry, fixed NewtCanvasAWT use-case We require the requested pixelScale in NewtCanvasAWT if the NEWT window (child) is not yet realized, so the JAWTWindow can receive the request, since realized/current pixelScale is still 1. Remove return value (requested pixel scale): - public int[] setSurfaceScale(final int[] result, final int[] pixelScale); + public void setSurfaceScale(final int[] pixelScale); Add API hook to query requested pixel scale: + int[] getRequestedSurfaceScale(final int[] result); Unique name for get[Current]*: - public int[] getSurfaceScale(final int[] result); + public int[] getCurrentSurfaceScale(final int[] result); --- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 12 ++++++----- .../javax/media/nativewindow/ScalableSurface.java | 24 ++++++++++++++-------- .../jogamp/nativewindow/SurfaceScaleUtils.java | 2 +- .../jogamp/nativewindow/WrappedSurface.java | 16 ++++++++------- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 5 ++--- 5 files changed, 34 insertions(+), 25 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index d235a2a29..1cc8fdb01 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -277,16 +277,18 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, *

*/ @Override - public int[] setSurfaceScale(final int[] result, final int[] pixelScale) { + public void setSurfaceScale(final int[] pixelScale) { SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null); - if( null != result ) { - System.arraycopy(reqPixelScale, 0, result, 0, 2); - } + } + + @Override + public final int[] getRequestedSurfaceScale(final int[] result) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); return result; } @Override - public final int[] getSurfaceScale(final int[] result) { + public final int[] getCurrentSurfaceScale(final int[] result) { System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java index f6101034b..de6ba51d7 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java @@ -30,7 +30,7 @@ package javax.media.nativewindow; /** * Adding mutable surface pixel scale property to implementing class, usually to a {@link NativeSurface} implementation, - * see {@link #setSurfaceScale(int[], int[])}. + * see {@link #setSurfaceScale(int[])}. */ public interface ScalableSurface { /** Setting surface-pixel-scale of {@value}, results in same pixel- and window-units. */ @@ -39,8 +39,7 @@ public interface ScalableSurface { public static final int AUTOMAX_PIXELSCALE = 0; /** - * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface} - * and return the validated requested value, see below. + * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface}. *

* Default pixel scale request for both directions is {@link #AUTOMAX_PIXELSCALE}. *

@@ -51,17 +50,24 @@ public interface ScalableSurface { *

* The requested pixel scale will be validated against platform limits before native scale-setup, * i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or clipped to the platform maximum. + * It can be queried via {@link #getRequestedSurfaceScale(int[])}. *

*

* The actual realized pixel scale values of the {@link NativeSurface} - * can be queried via {@link #getSurfaceScale(int[])} or + * can be queried via {@link #getCurrentSurfaceScale(int[])} or * computed via surface.{@link NativeSurface#convertToPixelUnits(int[]) convertToPixelUnits}(new int[] { 1, 1 }) *

- * @param result int[2] storage for the result, maybe null - * @param pixelScale requested surface pixel scale int[2] values for x- and y-direction. - * @return the passed storage containing the validated requested pixelSize for chaining, if storage is not null + * @param pixelScale requested surface pixel scale int[2] values for x- and y-direction. */ - public int[] setSurfaceScale(final int[] result, final int[] pixelScale); + public void setSurfaceScale(final int[] pixelScale); + + /** + * Returns the requested pixel scale of the associated {@link NativeSurface}. + * + * @param result int[2] storage for the result + * @return the passed storage containing the requested pixelSize for chaining + */ + int[] getRequestedSurfaceScale(final int[] result); /** * Returns the current pixel scale of the associated {@link NativeSurface}. @@ -69,6 +75,6 @@ public interface ScalableSurface { * @param result int[2] storage for the result * @return the passed storage containing the current pixelSize for chaining */ - public int[] getSurfaceScale(final int[] result); + public int[] getCurrentSurfaceScale(final int[] result); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java index 4586812e1..22e67ecff 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[], int[])} implementations. + * To be used by {@link ScalableSurface#setSurfaceScale(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 96862cbd6..8f9379130 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[], int[]) given pixelScale} directly. + * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(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[], int[]) given pixelScale} directly. + * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly. *

*/ @Override @@ -147,17 +147,19 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface *

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