summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-08 15:57:53 +0200
committerSven Gothel <[email protected]>2014-06-08 15:57:53 +0200
commit3fb76fcef1e6dd552ec0f677af67baf3186a1434 (patch)
tree00ff910246e857cf53d56f58f79e1c38896b912d /src/test/com
parent2571ed0b5ef14155d204540d38b564a7d4cd47b6 (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/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java17
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java16
4 files changed, 33 insertions, 24 deletions
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);