diff options
Diffstat (limited to 'src/test/com/jogamp')
11 files changed, 115 insertions, 140 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index 685e3bd86..db838fe07 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.media.nativewindow.util.Dimension; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAnimatorControl; @@ -672,7 +671,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { dpiH = surfacePixelsPerMM[1]*25.4f; System.err.println("Monitor detected: "+mm); System.err.println("Monitor dpi: "+monitorDpiH); - System.err.println("Surface scale: native "+new Dimension(upWin.getNativeSurfaceScale(new int[2]))+", current "+new Dimension(upWin.getCurrentSurfaceScale(new int[2]))); + System.err.println("Surface scale: native "+Arrays.toString(upWin.getMaximumSurfaceScale(new float[2]))+", current "+Arrays.toString(upWin.getCurrentSurfaceScale(new float[2]))); System.err.println("Surface dpi: "+dpiH); } else { System.err.println("Using default DPI of "+dpiH); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java index 274fbea2a..f70f178f3 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java @@ -30,7 +30,7 @@ public class GPUUISceneNewtCanvasAWTDemo { static boolean GraphMSAAMode = false; static float GraphAutoMode = GPUUISceneGLListener0A.DefaultNoAADPIThreshold; - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; static void setComponentSize(final Component comp, final DimensionImmutable new_sz) { try { @@ -91,7 +91,7 @@ public class GPUUISceneNewtCanvasAWTDemo { y = MiscUtils.atoi(args[i], y); } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-es2")) { @@ -151,10 +151,10 @@ public class GPUUISceneNewtCanvasAWTDemo { window.setSize(width, height); window.setTitle("GraphUI Newt/AWT Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); window.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); final GPUUISceneGLListener0A sceneGLListener = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(GraphAutoMode, DEBUG, TRACE) : - new GPUUISceneGLListener0A(rmode, DEBUG, TRACE); + new GPUUISceneGLListener0A(rmode, DEBUG, TRACE); window.addGLEventListener(sceneGLListener); sceneGLListener.attachInputListenerTo(window); @@ -180,7 +180,7 @@ public class GPUUISceneNewtCanvasAWTDemo { frame.setVisible(true); } }); - final int[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java index 16d56a041..29705d35b 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java @@ -20,7 +20,7 @@ public class GPUUISceneNewtDemo { static boolean GraphMSAAMode = false; static float GraphAutoMode = GPUUISceneGLListener0A.DefaultNoAADPIThreshold; - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; public static void main(final String[] args) { int width = 800, height = 400; @@ -66,7 +66,7 @@ public class GPUUISceneNewtDemo { y = MiscUtils.atoi(args[i], y); } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-es2")) { @@ -126,7 +126,7 @@ public class GPUUISceneNewtDemo { window.setSize(width, height); window.setTitle("GraphUI Newt Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); window.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); final GPUUISceneGLListener0A sceneGLListener = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(GraphAutoMode, DEBUG, TRACE) : new GPUUISceneGLListener0A(rmode, DEBUG, TRACE); @@ -145,7 +145,7 @@ public class GPUUISceneNewtDemo { }); window.setVisible(true); - final int[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java index b074297e2..032cf4fe7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java @@ -40,6 +40,8 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.Label; +import jogamp.nativewindow.SurfaceScaleUtils; + import org.junit.Assert; import org.junit.Assume; import org.junit.Before; @@ -178,8 +180,8 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase { } private void assertSize(final Dimension expSize) { - final int[] scale = { 1, 1 }; - glComp.getNativeSurfaceScale(scale); + final float[] scale = { 1f, 1f }; + glComp.getMaximumSurfaceScale(scale); final Dimension hasSize = glComp.getSize(null); @@ -188,8 +190,8 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase { Assert.assertTrue("AWT Size.height mismatch: expected "+expSize+", has "+hasSize, Math.abs(expSize.height-hasSize.height) <= sizeEps); - final int expSurfWidth = expSize.width * scale[0]; - final int expSurfHeight = expSize.height * scale[0]; + final int expSurfWidth = SurfaceScaleUtils.scale(expSize.width, scale[0]); + final int expSurfHeight = SurfaceScaleUtils.scale(expSize.height, scale[0]); final int hasSurfWidth = glComp.getSurfaceWidth(); final int hasSurfHeight = glComp.getSurfaceHeight(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java index b2d487784..c4d9633b3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java @@ -41,6 +41,8 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import java.awt.BorderLayout; import java.awt.Dimension; +import jogamp.nativewindow.SurfaceScaleUtils; + import org.junit.Assert; import org.junit.Assume; import org.junit.Before; @@ -179,8 +181,8 @@ public class TestAWT03GLJPanelRecreate01 extends UITestCase { } private void assertSize(final Dimension expSize) { - final int[] scale = { 1, 1 }; - glComp.getNativeSurfaceScale(scale); + final float[] scale = { 1f, 1f }; + glComp.getMaximumSurfaceScale(scale); final Dimension hasSize = glComp.getSize(null); @@ -189,8 +191,8 @@ public class TestAWT03GLJPanelRecreate01 extends UITestCase { Assert.assertTrue("AWT Size.height mismatch: expected "+expSize+", has "+hasSize, Math.abs(expSize.height-hasSize.height) <= sizeEps); - final int expSurfWidth = expSize.width * scale[0]; - final int expSurfHeight = expSize.height * scale[0]; + final int expSurfWidth = SurfaceScaleUtils.scale(expSize.width, scale[0]); + final int expSurfHeight = SurfaceScaleUtils.scale(expSize.height, scale[0]); final int hasSurfWidth = glComp.getSurfaceWidth(); final int hasSurfHeight = glComp.getSurfaceHeight(); 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 d8c4341a8..6d682bb2c 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 @@ -55,8 +55,6 @@ import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Frame; import java.awt.TextArea; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -80,7 +78,7 @@ public class TestGearsES2AWT extends UITestCase { static int xpos = 10, ypos = 10; static FrameLayout frameLayout = FrameLayout.None; static ResizeBy resizeBy = ResizeBy.Component; - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; static boolean forceES2 = false; static boolean forceGL3 = false; @@ -171,7 +169,7 @@ public class TestGearsES2AWT extends UITestCase { Assert.assertNotNull(glCanvas); setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height)); glCanvas.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new float[2]); frame.setLocation(xpos, ypos); switch( frameLayout) { @@ -215,29 +213,23 @@ public class TestGearsES2AWT extends UITestCase { } setTitle(frame, glCanvas, caps); - frame.addComponentListener(new ComponentListener() { - @Override - public void componentResized(final ComponentEvent e) { - setTitle(frame, glCanvas, caps); - } - - @Override - public void componentMoved(final ComponentEvent e) { - setTitle(frame, glCanvas, caps); - } - - @Override - public void componentShown(final ComponentEvent e) { } - - @Override - public void componentHidden(final ComponentEvent e) { } - }); - final GearsES2 demo = new GearsES2(swapInterval); glCanvas.addGLEventListener(demo); final SnapshotGLEventListener snap = new SnapshotGLEventListener(); glCanvas.addGLEventListener(snap); + glCanvas.addGLEventListener(new GLEventListener() { + @Override + public void init(final GLAutoDrawable drawable) { } + @Override + public void dispose(final GLAutoDrawable drawable) { } + @Override + public void display(final GLAutoDrawable drawable) { } + @Override + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { + setTitle(frame, glCanvas, caps); + } + }); final Animator animator = useAnimator ? new Animator(glCanvas) : null; if( useAnimator && exclusiveContext ) { @@ -254,24 +246,22 @@ public class TestGearsES2AWT extends UITestCase { return; } if(e.getKeyChar()=='x') { - final int[] hadSurfacePixelScale = glCanvas.getCurrentSurfaceScale(new int[2]); - final int[] reqSurfacePixelScale; + final float[] hadSurfacePixelScale = glCanvas.getCurrentSurfaceScale(new float[2]); + final float[] reqSurfacePixelScale; if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) { - reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; } else { - reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; + reqSurfacePixelScale = new float[] { 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.getRequestedSurfaceScale(new int[2]); - final int[] hasSurfacePixelScale0 = glCanvas.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new float[2]); + final float[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new float[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); } } }; new AWTKeyAdapter(kl, glCanvas).addTo(glCanvas); @@ -288,13 +278,11 @@ public class TestGearsES2AWT extends UITestCase { Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); - final int[] hasSurfacePixelScale0 = glCanvas.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new float[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); if( useAnimator ) { animator.start(); @@ -446,7 +434,7 @@ public class TestGearsES2AWT extends UITestCase { rh = MiscUtils.atoi(args[i], rh); } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-layout")) { 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 340816a13..0f2b89128 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 @@ -33,11 +33,8 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.DisplayMode; import java.awt.GraphicsDevice; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; import java.lang.reflect.InvocationTargetException; -import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ScalableSurface; import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; @@ -50,8 +47,6 @@ import javax.media.opengl.awt.GLJPanel; import javax.swing.JFrame; import javax.swing.SwingUtilities; -import jogamp.common.os.PlatformPropsImpl; - import org.junit.AfterClass; import org.junit.Assert; import org.junit.Assume; @@ -60,8 +55,13 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; -import com.jogamp.common.os.Platform; +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; @@ -90,7 +90,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { static boolean manualTest = false; static boolean skipGLOrientationVerticalFlip = false; static int xpos = 10, ypos = 10; - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; @BeforeClass public static void initClass() { @@ -139,7 +139,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { glJPanel.setPreferredSize(wsize); glJPanel.setSize(wsize); glJPanel.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new float[2]); if( caps.isBitmap() || caps.getGLProfile().isGL2() ) { final Gears gears = new Gears(swapInterval); gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); @@ -162,29 +162,10 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { setTitle(frame, glJPanel, caps); } - }); setTitle(frame, glJPanel, caps); frame.setLocation(xpos, ypos); - frame.addComponentListener(new ComponentListener() { - @Override - public void componentResized(final ComponentEvent e) { - setTitle(frame, glJPanel, caps); - } - - @Override - public void componentMoved(final ComponentEvent e) { - setTitle(frame, glJPanel, caps); - } - - @Override - public void componentShown(final ComponentEvent e) { } - - @Override - public void componentHidden(final ComponentEvent e) { } - }); - final FPSAnimator animator = useAnimator ? new FPSAnimator(glJPanel, 60) : null; SwingUtilities.invokeAndWait(new Runnable() { @@ -197,13 +178,11 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel, true)); - final int[] hasSurfacePixelScale0 = glJPanel.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glJPanel.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = glJPanel.getCurrentSurfaceScale(new float[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); if( useAnimator ) { animator.setUpdateFPSFrames(60, System.err); @@ -231,31 +210,44 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { System.err.printf("GetPixelScale: NW Screen: %s%n", glJPanel.getNativeSurface().getGraphicsConfiguration().getScreen()); System.err.printf("GetPixelScale: Panel Bounds: %s window-units%n", r.toString()); System.err.printf("GetPixelScale: Panel Resolution: %d x %d pixel-units%n", glJPanel.getSurfaceWidth(), glJPanel.getSurfaceHeight()); - if( Platform.OSType.MACOS == PlatformPropsImpl.OS_TYPE ) { - final int[] screenIndexOut = { 0 }; - final double pixelScale = jogamp.nativewindow.macosx.OSXUtil.GetPixelScale(r, screenIndexOut); - System.err.printf("GetPixelScale: PixelScale %f on screen-idx %d%n", pixelScale, screenIndexOut[0]); + { + final Display dpy = NewtFactory.createDisplay(null); + final Screen screen = NewtFactory.createScreen(dpy, 0); + screen.addReference(); + final MonitorModeListener sml = new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(final MonitorEvent me) { + } + @Override + public void monitorModeChanged(final MonitorEvent me, final boolean success) { + } + }; + screen.addMonitorModeListener(sml); + try { + final MonitorDevice md = screen.getMainMonitor(r); + System.err.printf("GetPixelScale: %s%n", md.toString()); + } finally { + screen.removeReference(); + } } System.err.println(); } else if(e.getKeyChar()=='x') { - final int[] hadSurfacePixelScale = glJPanel.getCurrentSurfaceScale(new int[2]); - final int[] reqSurfacePixelScale; + final float[] hadSurfacePixelScale = glJPanel.getCurrentSurfaceScale(new float[2]); + final float[] reqSurfacePixelScale; if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) { - reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; } else { - reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; + reqSurfacePixelScale = new float[] { 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.getRequestedSurfaceScale(new int[2]); - final int[] hasSurfacePixelScale0 = glJPanel.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glJPanel.getCurrentSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new float[2]); + final float[] hasSurfacePixelScale1 = glJPanel.getCurrentSurfaceScale(new float[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); } else if(e.getKeyChar()=='m') { final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities(); final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile()); @@ -520,7 +512,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { rh = MiscUtils.atoi(args[i], rh); } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-userVFlip")) { 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 eb2536639..3aa1519ab 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 @@ -85,7 +85,7 @@ public class TestGearsES2NEWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; static DimensionImmutable wsize, rwsize=null; - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; static long duration = 500; // ms static boolean opaque = true; @@ -137,7 +137,7 @@ public class TestGearsES2NEWT extends UITestCase { final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); glWindow.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); glWindow.setSize(wsize.getWidth(), wsize.getHeight()); if(null != wpos) { glWindow.setPosition(wpos.getX(), wpos.getY()); @@ -392,24 +392,22 @@ public class TestGearsES2NEWT extends UITestCase { glWindow.setExclusiveContextThread(t); } }.start(); } else if(e.getKeyChar()=='x') { - final int[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]); - final int[] reqSurfacePixelScale; + final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]); + final float[] reqSurfacePixelScale; if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) { - reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; } else { - reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; + reqSurfacePixelScale = new float[] { 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.getRequestedSurfaceScale(new int[2]); - final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); + final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[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)"); + 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); } } }); @@ -482,13 +480,11 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets()); - final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[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); snap.setMakeSnapshot(); @@ -669,7 +665,7 @@ public class TestGearsES2NEWT extends UITestCase { usePos = true; } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-rwidth")) { 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 2dca3ad5e..7af6fd109 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 @@ -86,7 +86,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { static DimensionImmutable wsize, rwsize = null; static FrameLayout frameLayout = FrameLayout.None; static ResizeBy resizeBy = ResizeBy.Component; - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; static long duration = 500; // ms static boolean opaque = true; @@ -195,7 +195,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); glWindow.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); if ( shallUseOffscreenFBOLayer ) { @@ -309,24 +309,22 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { return; } if(e.getKeyChar()=='x') { - final int[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]); - final int[] reqSurfacePixelScale; + final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]); + final float[] reqSurfacePixelScale; if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) { - reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; } else { - reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; + reqSurfacePixelScale = new float[] { 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.getRequestedSurfaceScale(new int[2]); - final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); + final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[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); } } } ); @@ -359,13 +357,11 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets()); - final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 }); - final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[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); if( null != rwsize ) { Thread.sleep(500); // 500ms delay @@ -503,7 +499,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { usePos = true; } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-screen")) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java index e20bbef2d..db3f81701 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java @@ -63,7 +63,7 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestRulerNEWT01 extends UITestCase { static long durationPerTest = 500; // ms - static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + static float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; static boolean manualTest = false; private void setTitle(final Window win) { @@ -77,7 +77,7 @@ public class TestRulerNEWT01 extends UITestCase { final GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getGL2ES2())); Assert.assertNotNull(glWindow); glWindow.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); glWindow.setSize(640, 480); glWindow.addGLEventListener(new GLEventListener() { @@ -183,19 +183,19 @@ public class TestRulerNEWT01 extends UITestCase { return; } if(e.getKeyChar()=='x') { - final int[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]); - final int[] reqSurfacePixelScale; + final float[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]); + final float[] reqSurfacePixelScale; if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) { - reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; } else { - reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; + reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; } System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]); snap.setMakeSnapshot(); glWindow.setSurfaceScale(reqSurfacePixelScale); - final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]); - final int[] hasSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]); - final int[] nativeSurfacePixelScale = glWindow.getNativeSurfaceScale(new int[2]); + final float[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new float[2]); + final float[] hasSurfacePixelScale = glWindow.getCurrentSurfaceScale(new float[2]); + final float[] nativeSurfacePixelScale = glWindow.getMaximumSurfaceScale(new float[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) -> "+ @@ -208,7 +208,7 @@ public class TestRulerNEWT01 extends UITestCase { glWindow.setVisible(true); - final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]); + final float[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new float[2]); System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+ valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); @@ -243,7 +243,7 @@ public class TestRulerNEWT01 extends UITestCase { durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest); } else if(args[i].equals("-pixelScale")) { i++; - final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]); + final float pS = MiscUtils.atof(args[i], reqSurfacePixelScale[0]); reqSurfacePixelScale[0] = pS; reqSurfacePixelScale[1] = pS; } else if(args[i].equals("-manual")) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java index 860560658..059b890e3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java @@ -112,12 +112,12 @@ public class TestScreenMode00aNEWT extends UITestCase { final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); final ArrayHashSet<MonitorMode> supportedModes = new ArrayHashSet<MonitorMode>(); supportedModes.add(modeOut); - final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, viewport, modeOut, supportedModes); + final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, modeOut, null, viewport, viewport, supportedModes); System.err.println("01 out : "+monOut); cache.monitorDevices.add(monOut); { final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); - final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); + final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(cache, null, null, props, 0, null); System.err.println("01 in : "+monIn); Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); |