diff options
author | Sven Gothel <[email protected]> | 2014-06-08 15:57:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-08 15:57:53 +0200 |
commit | 3fb76fcef1e6dd552ec0f677af67baf3186a1434 (patch) | |
tree | 00ff910246e857cf53d56f58f79e1c38896b912d /src | |
parent | 2571ed0b5ef14155d204540d38b564a7d4cd47b6 (diff) |
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.
Diffstat (limited to 'src')
16 files changed, 93 insertions, 71 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index bdd12dfea..e95491f6b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -663,12 +663,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public final void setSurfaceScale(final int[] pixelScale) { + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } if( isRealized() ) { final ScalableSurface ns = jawtWindow; if( null != ns ) { - ns.setSurfaceScale(reqPixelScale); + ns.setSurfaceScale(result, reqPixelScale); final int hadPixelScaleX = hasPixelScale[0]; final int hadPixelScaleY = hasPixelScale[1]; ns.getSurfaceScale(hasPixelScale); @@ -678,24 +681,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } } + return result; } @Override public final int[] getSurfaceScale(final int[] result) { - final ScalableSurface ns = jawtWindow; - if( null != ns ) { - return ns.getSurfaceScale(result); - } else { - System.arraycopy(reqPixelScale, 0, result, 0, 2); - return result; - } + System.arraycopy(hasPixelScale, 0, result, 0, 2); + return result; } private void createJAWTDrawableAndContext() { if ( !Beans.isDesignTime() ) { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - jawtWindow.setSurfaceScale(reqPixelScale); + jawtWindow.setSurfaceScale(null, reqPixelScale); jawtWindow.lockSurface(); try { drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 18de5a791..2f3cead4f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -559,13 +559,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final void updateWrappedSurfaceScale(final GLDrawable d) { final NativeSurface s = d.getNativeSurface(); if( s instanceof WrappedSurface ) { - ((WrappedSurface)s).setSurfaceScale( hasPixelScale ); + ((WrappedSurface)s).setSurfaceScale(null, hasPixelScale); } } @Override - public final void setSurfaceScale(final int[] pixelScale) { // HiDPI support + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { // HiDPI support SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } final Backend b = backend; if ( isInitialized && null != b ) { final int[] pixelScaleInt; @@ -582,11 +585,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing display(); } } + return result; } @Override public final int[] getSurfaceScale(final int[] result) { - System.arraycopy(isInitialized ? hasPixelScale : reqPixelScale, 0, result, 0, 2); + System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index efe9409ac..d235a2a29 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -277,14 +277,17 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * </p> */ @Override - public void setSurfaceScale(final int[] pixelScale) { + public int[] setSurfaceScale(final int[] result, final int[] pixelScale) { SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } + return result; } @Override public final int[] getSurfaceScale(final int[] result) { - // 0 != drawable -> locked at least once ! - System.arraycopy(0 != drawable ? hasPixelScale : reqPixelScale, 0, result, 0, 2); + 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 024f22bc9..f6101034b 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[])}. + * see {@link #setSurfaceScale(int[], int[])}. */ public interface ScalableSurface { /** Setting surface-pixel-scale of {@value}, results in same pixel- and window-units. */ @@ -39,7 +39,8 @@ public interface ScalableSurface { public static final int AUTOMAX_PIXELSCALE = 0; /** - * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface}. + * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface} + * and return the validated requested value, see below. * <p> * Default pixel scale request for both directions is {@link #AUTOMAX_PIXELSCALE}. * </p> @@ -49,31 +50,24 @@ public interface ScalableSurface { * </p> * <p> * The <i>requested</i> pixel scale will be validated against platform limits before native scale-setup, - * i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or the platform maximum. + * i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or clipped to the platform maximum. * </p> * <p> * The actual <i>realized</i> pixel scale values of the {@link NativeSurface} * can be queried via {@link #getSurfaceScale(int[])} or * computed via <code>surface.{@link NativeSurface#convertToPixelUnits(int[]) convertToPixelUnits}(new int[] { 1, 1 })</code> * </p> - * + * @param result int[2] storage for the result, maybe null * @param pixelScale <i>requested</i> 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 */ - public void setSurfaceScale(final int[] pixelScale); + public int[] setSurfaceScale(final int[] result, final int[] pixelScale); /** - * Returns the pixel scale of the associated {@link NativeSurface}. - * <p> - * In case the {@link NativeSurface} is not yet realized, method returns the - * requested pixel scale as validated via {@link #setSurfaceScale(int[])} - * if called earlier or the implementation default, usually {@link #AUTOMAX_PIXELSCALE}. - * </p> - * <p> - * In case the {@link NativeSurface} is already realized, method returns the - * actual used pixel scale. - * </p> + * Returns the current pixel scale of the associated {@link NativeSurface}. + * * @param result int[2] storage for the result - * @return the passed storage for chaining + * @return the passed storage containing the current pixelSize for chaining */ public int[] getSurfaceScale(final int[] result); } 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[])} * <p> - * To be used by {@link ScalableSurface#setSurfaceScale(int[])} implementations. + * To be used by {@link ScalableSurface#setSurfaceScale(int[], int[])} implementations. * </p> * * @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} * <p> - * {@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. * </p> */ @Override @@ -117,7 +117,7 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface /** * {@inheritDoc} * <p> - * {@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. * </p> */ @Override @@ -147,9 +147,13 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface * </p> */ @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 diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index baaa69e8e..f5e4ff43f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -865,7 +865,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } newtChild.setVisible(false); newtChild.setSize(w, h); - jawtWindow.setSurfaceScale(newtChild.getSurfaceScale(new int[2])); + jawtWindow.setSurfaceScale(null, newtChild.getSurfaceScale(new int[2])); newtChild.reparentWindow(jawtWindow, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); newtChild.addSurfaceUpdatedListener(jawtWindow); if( jawtWindow.isOffscreenLayerSurfaceEnabled() && diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 6610bd74f..ae99b7465 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -404,8 +404,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public final void setSurfaceScale(final int[] pixelScale) { - window.setSurfaceScale(pixelScale); + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { + return window.setSurfaceScale(result, pixelScale); } @Override diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index f02b9740d..d68a1dfd4 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1968,13 +1968,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setSurfaceScale(final int[] pixelScale) { + public int[] setSurfaceScale(final int[] result, final int[] pixelScale) { SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG_IMPLEMENTATION ? getClass().getSimpleName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } + return result; } @Override public final int[] getSurfaceScale(final int[] result) { - System.arraycopy(isNativeValid() ? hasPixelScale : reqPixelScale, 0, result, 0, 2); + System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index d01a2f21f..e3c4e3b87 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -146,7 +146,7 @@ public class AWTCanvas extends Canvas { { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); // trigger initialization cycle - jawtWindow.setSurfaceScale( upstreamScale.getReqPixelScale() ); + jawtWindow.setSurfaceScale(null, upstreamScale.getReqPixelScale() ); jawtWindow.lockSurface(); upstreamScale.setHasPixelScale(jawtWindow.getSurfaceScale(new int[2])); jawtWindow.unlockSurface(); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 0fa4739a3..07d31acfd 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -135,8 +135,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - public final void setSurfaceScale(final int[] pixelScale) { + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } final int[] resPixelScale; if( isNativeValid() ) { @@ -144,7 +147,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final NativeWindow pWin = getParent(); if( pWin instanceof ScalableSurface ) { final ScalableSurface sSurf = (ScalableSurface)pWin; - sSurf.setSurfaceScale(reqPixelScale); + sSurf.setSurfaceScale(result, reqPixelScale); final int[] pPixelScale = sSurf.getSurfaceScale(new int[2]); updatePixelScale(true /* sendEvent */, true /* defer */, pPixelScale[0]); // HiDPI: uniformPixelScale } else { @@ -172,6 +175,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl reqPixelScale[0]+"x"+reqPixelScale[1]+" (validated) -> "+ resPixelScale[0]+"x"+resPixelScale[1]+" (result) - realized "+isNativeValid()); } + return result; } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 3dbfeed8f..374c06514 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -84,7 +84,7 @@ public class TestGearsES2AWT extends UITestCase { static boolean forceES2 = false; static boolean forceGL3 = false; - static boolean mainRun = false; + static boolean manualTest = false; static boolean shallUseOffscreenFBOLayer = false; static boolean shallUseOffscreenPBufferLayer = false; static boolean useMSAA = false; @@ -170,7 +170,7 @@ public class TestGearsES2AWT extends UITestCase { final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height)); - glCanvas.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glCanvas.setSurfaceScale(new int[2], reqSurfacePixelScale); frame.setLocation(xpos, ypos); switch( frameLayout) { @@ -261,11 +261,12 @@ public class TestGearsES2AWT extends UITestCase { reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; } System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]); - glCanvas.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glCanvas.setSurfaceScale(new int[2], reqSurfacePixelScale); final int[] hasSurfacePixelScale0 = glCanvas.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glCanvas.getSurfaceScale(new int[2]); System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+ reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, glCanvas, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -288,6 +289,7 @@ public class TestGearsES2AWT extends UITestCase { final int[] hasSurfacePixelScale0 = glCanvas.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glCanvas.getSurfaceScale(new int[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, glCanvas, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -379,7 +381,7 @@ public class TestGearsES2AWT extends UITestCase { @Test public void test02_GLES2() throws InterruptedException, InvocationTargetException { - if(mainRun) return; + if(manualTest) return; if( !GLProfile.isAvailable(GLProfile.GLES2) ) { System.err.println("GLES2 n/a"); @@ -392,7 +394,7 @@ public class TestGearsES2AWT extends UITestCase { @Test public void test03_GL3() throws InterruptedException, InvocationTargetException { - if(mainRun) return; + if(manualTest) return; if( !GLProfile.isAvailable(GLProfile.GL3) ) { System.err.println("GL3 n/a"); @@ -405,7 +407,7 @@ public class TestGearsES2AWT extends UITestCase { @Test public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException { - if( mainRun ) return; + if( manualTest ) return; reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE; reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE; @@ -418,7 +420,6 @@ public class TestGearsES2AWT extends UITestCase { boolean waitForKey = false; int rw=-1, rh=-1; - mainRun = true; for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { i++; @@ -482,6 +483,8 @@ public class TestGearsES2AWT extends UITestCase { shutdownDisposeFrame = false; } else if(args[i].equals("-shutdownSystemExit")) { shutdownSystemExit = true; + } else if(args[i].equals("-manual")) { + manualTest = true; } } if( 0 < rw && 0 < rh ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java index cfd099062..244cd8c04 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java @@ -124,7 +124,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { glJPanel.setMinimumSize(wsize); glJPanel.setPreferredSize(wsize); glJPanel.setSize(wsize); - glJPanel.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glJPanel.setSurfaceScale(new int[2], reqSurfacePixelScale); if( caps.isBitmap() || caps.getGLProfile().isGL2() ) { final Gears gears = new Gears(swapInterval); gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); @@ -172,6 +172,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { final int[] hasSurfacePixelScale0 = glJPanel.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glJPanel.getSurfaceScale(new int[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, glJPanel, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -201,11 +202,12 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; } System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]); - glJPanel.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glJPanel.setSurfaceScale(new int[2], reqSurfacePixelScale); final int[] hasSurfacePixelScale0 = glJPanel.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glJPanel.getSurfaceScale(new int[2]); System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+ reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, glJPanel, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index b916e21d6..458536d0f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -102,7 +102,7 @@ public class TestGearsES2NEWT extends UITestCase { static boolean forceES3 = false; static boolean forceGL3 = false; static boolean forceGL2 = false; - static boolean mainRun = false; + static boolean manualTest = false; static boolean exclusiveContext = false; static boolean useAnimator = true; static boolean useMappedBuffers = false; @@ -130,7 +130,7 @@ public class TestGearsES2NEWT extends UITestCase { Screen screen = NewtFactory.createScreen(dpy, screenIdx); final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); - glWindow.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale); glWindow.setSize(wsize.getWidth(), wsize.getHeight()); if(null != wpos) { glWindow.setPosition(wpos.getX(), wpos.getY()); @@ -355,11 +355,12 @@ public class TestGearsES2NEWT extends UITestCase { reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; } System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]); - glWindow.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale); final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]); System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+ reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(glWindow, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -438,6 +439,7 @@ public class TestGearsES2NEWT extends UITestCase { final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(glWindow, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -524,7 +526,7 @@ public class TestGearsES2NEWT extends UITestCase { @Test public void test02_GLES2() throws InterruptedException { - if(mainRun) return; + if(manualTest) return; if( !GLProfile.isAvailable(GLProfile.GLES2) ) { System.err.println("GLES2 n/a"); @@ -537,7 +539,7 @@ public class TestGearsES2NEWT extends UITestCase { @Test public void test03_GL3() throws InterruptedException { - if(mainRun) return; + if(manualTest) return; if( !GLProfile.isAvailable(GLProfile.GL3) ) { System.err.println("GL3 n/a"); @@ -550,7 +552,7 @@ public class TestGearsES2NEWT extends UITestCase { @Test public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException { - if( mainRun ) return; + if( manualTest ) return; reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE; reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE; @@ -560,8 +562,6 @@ public class TestGearsES2NEWT extends UITestCase { } public static void main(String args[]) throws IOException { - mainRun = true; - int x=0, y=0, w=640, h=480, rw=-1, rh=-1; boolean usePos = false; @@ -645,6 +645,8 @@ public class TestGearsES2NEWT extends UITestCase { } else if(args[i].equals("-sysExit")) { i++; sysExit = SysExit.valueOf(args[i]); + } else if(args[i].equals("-manual")) { + manualTest = true; } } wsize = new Dimension(w, h); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index d3e695659..22c1bc4d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -99,7 +99,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { static boolean shallUseOffscreenFBOLayer = false; static boolean forceES2 = false; static boolean forceGL3 = false; - static boolean mainRun = false; + static boolean manualTest = false; static boolean exclusiveContext = false; static boolean useAnimator = true; @@ -191,7 +191,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { Screen screen = NewtFactory.createScreen(dpy, screenIdx); final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); - glWindow.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); if ( shallUseOffscreenFBOLayer ) { @@ -314,11 +314,12 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; } System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]); - glWindow.setSurfaceScale(reqSurfacePixelScale); + final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale); final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]); System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+ reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, newtCanvasAWT, glWindow, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -357,6 +358,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ + valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, newtCanvasAWT, glWindow, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); @@ -416,7 +418,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { @Test public void test02GL3() throws InterruptedException, InvocationTargetException { - if(mainRun) return; + if(manualTest) return; if( !GLProfile.isAvailable(GLProfile.GL3) ) { System.err.println("GL3 n/a"); @@ -429,7 +431,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { @Test public void test99_PixelScale1_DefaultNorm() throws InterruptedException, InvocationTargetException { - if( mainRun ) return; + if( manualTest ) return; reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE; reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE; @@ -439,8 +441,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { } public static void main(String args[]) throws IOException { - mainRun = true; - int x=0, y=0, w=640, h=480; int rw=-1, rh=-1; boolean usePos = false; @@ -512,6 +512,8 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { loops = MiscUtils.atoi(args[i], 1); } else if(args[i].equals("-loop-shutdown")) { loop_shutdown = true; + } else if(args[i].equals("-manual")) { + manualTest = true; } } wsize = new Dimension(w, h); |