summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/scripts/tests.sh6
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.h2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java50
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java5
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m2
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java18
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorMode.java12
-rw-r--r--src/newt/classes/com/jogamp/newt/Screen.java31
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java25
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java31
-rw-r--r--src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java2
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java74
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/WindowDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java3
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java3
-rw-r--r--src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java20
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java5
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java20
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java26
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java77
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java141
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java81
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java40
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java54
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java81
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java99
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java96
28 files changed, 589 insertions, 451 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 13f5b08ea..97cd99850 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -217,7 +217,7 @@ function jrun() {
#D_ARGS="-Dnewt.debug.Window"
#D_ARGS="-Xprof"
#D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
- D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel"
+ #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Dnativewindow.awt.nohidpi"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.debug.GLJPanel.Viewport"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl"
@@ -358,7 +358,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
-testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestHiDPIBufferedImage01AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestHiDPIBufferedImage02AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
@@ -535,7 +535,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT
-#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $*
+testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $*
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.h b/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
index b2d7f9db8..138accb22 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
@@ -3,7 +3,7 @@
#import <OpenGL/CGLTypes.h>
#import <jni.h>
-#define VERBOSE_ON 1
+// #define VERBOSE_ON 1
#ifdef VERBOSE_ON
#define DBG_PRINT(...) NSLog(@ __VA_ARGS__)
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
index d0d8bfb13..57535c26e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
@@ -40,7 +40,7 @@ public class Rectangle implements Cloneable, RectangleImmutable {
this(0, 0, 0, 0);
}
- public Rectangle(int x, int y, int width, int height) {
+ public Rectangle(final int x, final int y, final int width, final int height) {
this.x=x;
this.y=y;
this.width=width;
@@ -70,16 +70,16 @@ public class Rectangle implements Cloneable, RectangleImmutable {
@Override
public final int getHeight() { return height; }
- public final void set(int x, int y, int width, int height) {
+ public final void set(final int x, final int y, final int width, final int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
- public final void setX(int x) { this.x = x; }
- public final void setY(int y) { this.y = y; }
- public final void setWidth(int width) { this.width = width; }
- public final void setHeight(int height) { this.height = height; }
+ public final void setX(final int x) { this.x = x; }
+ public final void setY(final int y) { this.y = y; }
+ public final void setWidth(final int width) { this.width = width; }
+ public final void setHeight(final int height) { this.height = height; }
@Override
public final RectangleImmutable union(final RectangleImmutable r) {
@@ -113,7 +113,7 @@ public class Rectangle implements Cloneable, RectangleImmutable {
}
@Override
- public final RectangleImmutable intersection(RectangleImmutable r) {
+ public final RectangleImmutable intersection(final RectangleImmutable r) {
return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight());
}
@Override
@@ -140,13 +140,43 @@ public class Rectangle implements Cloneable, RectangleImmutable {
return new Rectangle (ix, iy, iwidth, iheight);
}
@Override
- public final float coverage(RectangleImmutable r) {
+ public final float coverage(final RectangleImmutable r) {
final RectangleImmutable isect = intersection(r);
- final float sqI = (float) ( isect.getWidth()*isect.getHeight() );
- final float sqT = (float) ( width*height );
+ final float sqI = isect.getWidth()*isect.getHeight();
+ final float sqT = width*height;
return sqI / sqT;
}
+ /**
+ * Scale this instance's components,
+ * i.e. multiply them by the given scale factors.
+ * @param sx scale factor for x
+ * @param sy scale factor for y
+ * @return this instance for scaling
+ */
+ public final Rectangle scale(int sx, int sy) {
+ x *= sx ;
+ y *= sy ;
+ width *= sx ;
+ height *= sy ;
+ return this;
+ }
+
+ /**
+ * Inverse scale this instance's components,
+ * i.e. divide them by the given scale factors.
+ * @param sx inverse scale factor for x
+ * @param sy inverse scale factor for y
+ * @return this instance for scaling
+ */
+ public final Rectangle scaleInv(int sx, int sy) {
+ x /= sx ;
+ y /= sy ;
+ width /= sx ;
+ height /= sy ;
+ return this;
+ }
+
@Override
public int compareTo(final RectangleImmutable d) {
{
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
index 77619731f..6b4d2f19c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
@@ -32,7 +32,7 @@ package javax.media.nativewindow.util;
/**
* Immutable SurfaceSize Class, consisting of it's read only components:<br>
* <ul>
- * <li>{@link javax.media.nativewindow.util.DimensionImmutable} size in pixels</li>
+ * <li>{@link javax.media.nativewindow.util.DimensionImmutable size in pixels}</li>
* <li><code>bits per pixel</code></li>
* </ul>
*/
@@ -48,6 +48,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> {
this.bitsPerPixel=bitsPerPixel;
}
+ /** Returns the resolution in pixel units */
public final DimensionImmutable getResolution() {
return resolution;
}
@@ -58,7 +59,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> {
@Override
public final String toString() {
- return "[ "+resolution+" x "+bitsPerPixel+" bpp ]";
+ return "[ "+resolution+" pixels x "+bitsPerPixel+" bpp ]";
}
/**
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 15547ffee..0250bb7d1 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -41,7 +41,7 @@
#include <jawt_md.h>
-#define VERBOSE 1
+// #define VERBOSE 1
//
#ifdef VERBOSE
// #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__)
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
index 1198f7681..af0ce0146 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
@@ -170,7 +170,7 @@ public abstract class MonitorDevice {
/**
* Returns the {@link RectangleImmutable rectangular} portion
- * of the rotated virtual {@link Screen} size in screen/window units
+ * of the rotated virtual {@link Screen} size in pixel units
* represented by this monitor.
*/
public final RectangleImmutable getViewport() {
@@ -178,10 +178,12 @@ public abstract class MonitorDevice {
}
/**
- * Returns <code>true</code> if given screen coordinates in screen/window units
+ * Returns <code>true</code> if given screen coordinates in pixel units
* are contained by this {@link #getViewport() viewport}, otherwise <code>false</code>.
+ * @param x x-coord in pixel units
+ * @param y y-coord in pixel units
*/
- public final boolean contains(int x, int y) {
+ public final boolean contains(final int x, final int y) {
return x >= viewport.getX() &&
x < viewport.getX() + viewport.getWidth() &&
y >= viewport.getY() &&
@@ -189,7 +191,8 @@ public abstract class MonitorDevice {
}
/**
- * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between <code>0.0</code> and <code>1.0</code>.
+ * Returns the coverage of given rectangle in pixel units
+ * w/ this {@link #getViewport() viewport}, i.e. between <code>0.0</code> and <code>1.0</code>.
* <p>
* Coverage is computed by:
* <pre>
@@ -197,16 +200,17 @@ public abstract class MonitorDevice {
* coverage = area( isect ) / area( viewport ) ;
* </pre>
* </p>
+ * @param r {@link RectangleImmutable rectangle} in pixel units
*/
- public final float coverage(RectangleImmutable r) {
+ public final float coverage(final RectangleImmutable r) {
return viewport.coverage(r);
}
/**
- * Returns the union of the given monitor's {@link #getViewport() viewport}.
+ * Returns the union of the given monitor's {@link #getViewport() viewport} in pixel units.
* @param result storage for result, will be returned
* @param monitors given list of monitors
- * @return viewport representing the union of given monitor's viewport.
+ * @return viewport representing the union of given monitor's viewport in pixel units, i.e. result storage for chaining
*/
public static Rectangle unionOfViewports(final Rectangle result, final List<MonitorDevice> monitors) {
int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE;
diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java
index 9690f18db..ba21df22a 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorMode.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java
@@ -51,7 +51,7 @@ import com.jogamp.newt.util.MonitorModeUtil;
* <ul>
* <li>A List of all {@link MonitorDevice}s is accessible via {@link Screen#getMonitorDevices()}.</li>
* <li>The main monitor used by a windows is accessible via {@link Window#getMainMonitor()}.</li>
- * <li>The main monitor covering an arbitrary rectnagle is accessible via {@link Screen#getMainMonitor(RectangleImmutable)}.</li>
+ * <li>The main monitor covering an arbitrary rectangle is accessible via {@link Screen#getMainMonitor(RectangleImmutable)}.</li>
* </ul></li>
* <li>The current MonitorMode can be obtained via {@link MonitorDevice#getCurrentMode()}.</li>
* <li>The original MonitorMode can be obtained via {@link MonitorDevice#getOriginalMode()}.</li>
@@ -88,8 +88,8 @@ import com.jogamp.newt.util.MonitorModeUtil;
MonitorMode mmCurrent = monitor.queryCurrentMode();
MonitorMode mmOrig = monitor.getOriginalMode();
- // Target resolution
- Dimension res = new Dimension(800, 600);
+ // Target resolution in pixel units
+ DimensionImmutable res = new Dimension(800, 600);
// Target refresh rate shall be similar to current one ..
float freq = mmCurrent.getRefreshRate();
@@ -136,7 +136,7 @@ public class MonitorMode implements Comparable<MonitorMode> {
* </ul>
*/
public static class SizeAndRRate implements Comparable<SizeAndRRate> {
- /** Non rotated surface size */
+ /** Non rotated surface size in pixel units */
public final SurfaceSize surfaceSize;
/** Mode bitfield flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */
public final int flags;
@@ -349,7 +349,7 @@ public class MonitorMode implements Comparable<MonitorMode> {
return rotation;
}
- /** Returns the rotated screen width,
+ /** Returns the rotated screen width in pixel units,
* derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code>
* and <code>getRotation()</code>
*/
@@ -357,7 +357,7 @@ public class MonitorMode implements Comparable<MonitorMode> {
return getRotatedWH(true);
}
- /** Returns the rotated screen height,
+ /** Returns the rotated screen height in pixel units,
* derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code>
* and <code>getRotation()</code>
*/
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index 2a713c538..919b98b45 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -131,31 +131,42 @@ public abstract class Screen {
public abstract int getIndex();
/**
- * @return the x position of the virtual viewport's top-left origin in screen/window units.
+ * @return the x position of the virtual viewport's top-left origin in pixel units.
*/
public abstract int getX();
/**
- * @return the y position of the virtual viewport's top-left origin in screen/window units.
+ * @return the y position of the virtual viewport's top-left origin in pixel units.
*/
public abstract int getY();
/**
- * @return the <b>rotated</b> virtual viewport's width in screen/window units.
+ * @return the <b>rotated</b> virtual viewport's width in pixel units.
*/
public abstract int getWidth();
/**
- * @return the <b>rotated</b> virtual viewport's height in screen/window units.
+ * @return the <b>rotated</b> virtual viewport's height in pixel units.
*/
public abstract int getHeight();
/**
- * @return the <b>rotated</b> virtual viewport, i.e. origin and size in screen/window units.
+ * @return the <b>rotated</b> virtual viewport, i.e. origin and size in pixel units.
+ * @see #getViewportInWindowUnits(Window)
*/
public abstract RectangleImmutable getViewport();
/**
+ * Returns a newly created {@link Rectangle} containing the <b>rotated</b> virtual viewport
+ * in window units of the given {@link Window} instance.
+ * @return rotated viewport values, i.e. origin and size, in pixel units.
+ * @see #getViewport()
+ */
+ public final Rectangle getViewportInWindowUnits(final Window win) {
+ return win.convertToWindowUnits( (Rectangle) getViewport().cloneMutable() );
+ }
+
+ /**
* @return the associated Display
*/
public abstract Display getDisplay();
@@ -181,14 +192,14 @@ public abstract class Screen {
public abstract List<MonitorDevice> getMonitorDevices();
/**
- * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport}
- * {@link MonitorDevice#coverage(RectangleImmutable) covers} the given rectangle the most.
+ * Returns the {@link MonitorDevice} with the highest {@link MonitorDevice#getViewport() viewport}
+ * {@link MonitorDevice#coverage(RectangleImmutable) coverage} of the given rectangle in pixel units.
* <p>
* If no coverage is detected the first {@link MonitorDevice} is returned.
* </p>
- * @param r arbitrary rectangle in screen/window units
+ * @param r arbitrary rectangle in pixel units
*/
- public final MonitorDevice getMainMonitor(RectangleImmutable r) {
+ public final MonitorDevice getMainMonitor(final RectangleImmutable r) {
MonitorDevice res = null;
float maxCoverage = Float.MIN_VALUE;
final List<MonitorDevice> monitors = getMonitorDevices();
@@ -207,7 +218,7 @@ public abstract class Screen {
}
/**
- * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport} in screen/window units.
+ * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport} in pixel units.
* <p>
* Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()},
* however, some native toolkits may choose a different virtual screen area.
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index b733406e8..872d67087 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
/**
@@ -233,6 +234,18 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
//
/**
+ * Returns a newly created {@link Rectangle} containing window origin, {@link #getX()} & {@link #getY()},
+ * and size, {@link #getWidth()} & {@link #getHeight()}, in window units.
+ */
+ Rectangle getBounds();
+
+ /**
+ * Returns a newly created {@link Rectangle} containing the scaled window origin, {@link #getX()} & {@link #getY()},
+ * and size, {@link #getSurfaceWidth()} & {@link #getSurfaceHeight()}, in pixel units.
+ */
+ Rectangle getSurfaceBounds();
+
+ /**
* Sets the size of the window's client area in window units, excluding decorations.
*
* <p>
@@ -329,19 +342,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
/**
* Converts the given pixel units into window units <i>in place</i>.
- * @param pixelUnitsAndResult point storage holding the pixel units to convert
+ * @param pixelUnitsAndResult rectangle storage holding the pixel units to convert
* and the resulting conversion.
- * @return resulting point storage pixelUnitsAndResult for chaining holding the converted values
+ * @return resulting rectangle storage pixelUnitsAndResult for chaining holding the converted values
*/
- Point convertToWindowUnits(final Point pixelUnitsAndResult);
+ Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult);
/**
* Converts the given window units into pixel units <i>in place</i>.
- * @param windowUnitsAndResult point storage holding the window units to convert
+ * @param windowUnitsAndResult rectangle storage holding the window units to convert
* and the resulting conversion.
- * @return resulting point storage windowUnitsAndResult for chaining holding the converted values
+ * @return resulting rectangle storage windowUnitsAndResult for chaining holding the converted values
*/
- Point convertToPixelUnits(final Point windowUnitsAndResult);
+ Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult);
void setUndecorated(boolean value);
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 7ba4bddf0..ecd50aa5f 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.SurfaceUpdatedListener;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.opengl.FPSCounter;
import javax.media.opengl.GL;
import javax.media.opengl.GL3;
@@ -363,33 +364,43 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
- public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
- return window.convertToWindowUnits(pixelUnitsAndResult);
+ public final Rectangle getBounds() {
+ return window.getBounds();
}
@Override
- public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
- return window.convertToPixelUnits(windowUnitsAndResult);
+ public final int getSurfaceWidth() {
+ return window.getSurfaceWidth();
+ }
+
+ @Override
+ public final int getSurfaceHeight() {
+ return window.getSurfaceHeight();
}
@Override
- public final Point convertToWindowUnits(final Point pixelUnitsAndResult) {
+ public final Rectangle getSurfaceBounds() {
+ return window.getSurfaceBounds();
+ }
+
+ @Override
+ public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
return window.convertToWindowUnits(pixelUnitsAndResult);
}
@Override
- public final Point convertToPixelUnits(final Point windowUnitsAndResult) {
+ public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
return window.convertToPixelUnits(windowUnitsAndResult);
}
@Override
- public final int getSurfaceWidth() {
- return window.getSurfaceWidth();
+ public final Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult) {
+ return window.convertToWindowUnits(pixelUnitsAndResult);
}
@Override
- public final int getSurfaceHeight() {
- return window.getSurfaceHeight();
+ public final Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult) {
+ return window.convertToPixelUnits(windowUnitsAndResult);
}
@Override
diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java
index fdd7985fe..e019068f5 100644
--- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java
@@ -157,7 +157,7 @@ public class MonitorModeUtil {
/**
* @param monitorModes
- * @param resolution
+ * @param resolution in pixel units
* @return modes with nearest resolution, or matching ones. May return zero sized list for non.
*/
public static List<MonitorMode> filterByResolution(List<MonitorMode> monitorModes, DimensionImmutable resolution) {
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index b127426a8..6a5fc5de0 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -912,7 +912,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
@Override
public final MonitorDevice getMainMonitor() {
- return screen.getMainMonitor(new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight()));
+ return screen.getMainMonitor( getSurfaceBounds() );
}
/**
@@ -1071,8 +1071,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
@Override
public final void setSurfaceSize(final int pixelWidth, final int pixelHeight) {
- final int[] winSize = convertToWindowUnits(new int[]{pixelWidth, pixelHeight});
- setSize(winSize[0], winSize[1]);
+ // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology
+ setSize(pixelWidth * getPixelScaleX(), pixelHeight * getPixelScaleY());
}
@Override
public final void setTopLevelSize(final int width, final int height) {
@@ -1877,13 +1877,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
@Override
- public final int getSurfaceWidth() {
- return pixWidth;
+ public final int getX() {
+ return x;
}
@Override
- public final int getSurfaceHeight() {
- return pixHeight;
+ public final int getY() {
+ return y;
}
@Override
@@ -1897,6 +1897,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
@Override
+ public final Rectangle getBounds() {
+ return new Rectangle(x, y, winWidth, winHeight);
+ }
+
+ @Override
+ public final int getSurfaceWidth() {
+ return pixWidth;
+ }
+
+ @Override
+ public final int getSurfaceHeight() {
+ return pixHeight;
+ }
+
+ @Override
+ public final Rectangle getSurfaceBounds() {
+ // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology
+ return new Rectangle(x * getPixelScaleX(), y * getPixelScaleY(), pixWidth, pixHeight);
+ }
+
+ @Override
public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
pixelUnitsAndResult[0] /= getPixelScaleX();
pixelUnitsAndResult[1] /= getPixelScaleY();
@@ -1910,29 +1931,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return windowUnitsAndResult;
}
- @Override
- public final Point convertToWindowUnits(final Point pixelUnitsAndResult) {
+ protected final Point convertToWindowUnits(final Point pixelUnitsAndResult) {
return pixelUnitsAndResult.scaleInv(getPixelScaleX(), getPixelScaleY());
}
- @Override
- public final Point convertToPixelUnits(final Point windowUnitsAndResult) {
+ protected final Point convertToPixelUnits(final Point windowUnitsAndResult) {
return windowUnitsAndResult.scale(getPixelScaleX(), getPixelScaleY());
}
- protected int getPixelScaleX() { return 1; }
- protected int getPixelScaleY() { return 1; }
-
@Override
- public final int getX() {
- return x;
+ public final Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult) {
+ return pixelUnitsAndResult.scaleInv(getPixelScaleX(), getPixelScaleY());
}
@Override
- public final int getY() {
- return y;
+ public final Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult) {
+ return windowUnitsAndResult.scale(getPixelScaleX(), getPixelScaleY());
}
+ /** HiDPI: We currently base scaling of window units to pixel units on an integer scale factor per component. */
+ protected int getPixelScaleX() { return 1; }
+ /** HiDPI: We currently base scaling of window units to pixel units on an integer scale factor per component. */
+ protected int getPixelScaleY() { return 1; }
+
protected final boolean autoPosition() { return autoPosition; }
/** Sets the position fields {@link #x} and {@link #y} in window units to the given values and {@link #autoPosition} to false. */
@@ -1950,14 +1971,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* and {@link #pixWidth} and {@link #pixHeight} in pixel units according to {@link #convertToPixelUnits(int[])}.
*/
protected final void defineSize(int winWidth, int winHeight) {
- final int[] pixelSize = convertToPixelUnits(new int[] { winWidth, winHeight });
+ final int pixWidth = winWidth * getPixelScaleX(); // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology
+ final int pixHeight = winHeight * getPixelScaleY();
if(DEBUG_IMPLEMENTATION) {
System.err.println("defineSize: win["+this.winWidth+"x"+this.winHeight+" -> "+winWidth+"x"+winHeight+
- "], pixel["+this.pixWidth+"x"+this.pixHeight+" -> "+pixelSize[0]+"x"+pixelSize[1]+"]");
+ "], pixel["+this.pixWidth+"x"+this.pixHeight+" -> "+pixWidth+"x"+pixHeight+"]");
// Thread.dumpStack();
}
this.winWidth = winWidth; this.winHeight = winHeight;
- this.pixWidth = pixelSize[0]; this.pixHeight = pixelSize[0];
+ this.pixWidth = pixWidth; this.pixHeight = pixHeight;
}
@Override
@@ -2227,7 +2249,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
int x,y,w,h;
- final RectangleImmutable sviewport = screen.getViewport();
+ final RectangleImmutable sviewport = screen.getViewportInWindowUnits(WindowImpl.this);
final RectangleImmutable viewport;
final int fs_span_flag;
final boolean alwaysOnTopChange;
@@ -2240,7 +2262,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
fullscreenMonitors = getScreen().getMonitorDevices();
}
}
- viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors);
+ viewport = convertToWindowUnits(MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors));
if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) &&
( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) {
fs_span_flag = FLAG_IS_FULLSCREEN_SPAN;
@@ -2292,7 +2314,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window fs: "+_fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+
- ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+
+ ", virtl-screenSize: "+sviewport+" [wu], monitorsViewport "+viewport+" [wu]"+
", spanning "+(0!=fs_span_flag)+
", alwaysOnTop "+alwaysOnTop+(alwaysOnTopChange?"*":"")+
", wasVisible "+wasVisible+", tempInvisible "+tempInvisible+
@@ -2449,7 +2471,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if( !fullscreen && !fullscreenPaused ) {
// Simply move/resize window to fit in virtual screen if required
- final RectangleImmutable viewport = screen.getViewport();
+ final RectangleImmutable viewport = screen.getViewportInWindowUnits(WindowImpl.this);
if( viewport.getWidth() > 0 && viewport.getHeight() > 0 ) { // failsafe
final RectangleImmutable rect = new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight());
final RectangleImmutable isect = viewport.intersection(rect);
@@ -2475,7 +2497,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// If changed monitor is part of this fullscreen mode, reset size! (Bug 771)
final MonitorDevice md = me.getMonitor();
if( fullscreenMonitors.contains(md) ) {
- final RectangleImmutable viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors);
+ final RectangleImmutable viewport = convertToWindowUnits(MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors));
if(DEBUG_IMPLEMENTATION) {
final RectangleImmutable rect = new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight());
System.err.println("Window.monitorModeChanged: FS Monitor Match: Fit window "+rect+" into new viewport union "+viewport+", provoked by "+md);
diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
index 93ff0c1e0..7a571318b 100644
--- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
@@ -41,6 +41,7 @@ import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.VisualIDHolder;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
@@ -54,7 +55,6 @@ import jogamp.opengl.egl.EGL;
import jogamp.opengl.egl.EGLDisplayUtil;
import jogamp.opengl.egl.EGLGraphicsConfiguration;
import jogamp.opengl.egl.EGLGraphicsConfigurationFactory;
-
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -286,9 +286,10 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 {
if( isFullscreen() ) {
final MonitorDevice mainMonitor = getMainMonitor();
- final RectangleImmutable viewport = mainMonitor.getViewport();
- definePosition(viewport.getX(), viewport.getY());
- defineSize(viewport.getWidth(), viewport.getHeight());
+ final RectangleImmutable screenRect = mainMonitor.getViewport();
+ final RectangleImmutable winRect = this.convertToWindowUnits((Rectangle)screenRect.cloneMutable());
+ definePosition(winRect.getX(), winRect.getY());
+ defineSize(winRect.getWidth(), winRect.getHeight());
}
final boolean b;
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java
index be7e8fd07..4cbff69c1 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java
@@ -65,7 +65,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
setGraphicsConfiguration(cfg);
- setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
+ final int[] winSize = convertToWindowUnits(new int[] {getScreen().getWidth(), getScreen().getHeight()});
+ setSizeImpl(winSize[0], winSize[1]);
setWindowHandle(realizeWindow(true, getWindowWidth(), getWindowHeight()));
if (0 == getWindowHandle()) {
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java
index 7e15d0258..cf169f1c7 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java
@@ -67,7 +67,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl {
setWindowHandle(nextWindowHandle++); // just a marker
surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(),
- getX(), getY(), getWindowWidth(), getWindowHeight());
+ getX(), getY(), getSurfaceWidth(), getSurfaceHeight());
if (surfaceHandle == 0) {
throw new NativeWindowException("Error creating window");
}
@@ -89,6 +89,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl {
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
ScreenDriver screen = (ScreenDriver) getScreen();
+ // Note for GDL: window units == pixel units
if(width>screen.getWidth()) {
width=screen.getWidth();
}
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
index 9d7b8931b..3663ef0d4 100644
--- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
+++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java
@@ -36,6 +36,7 @@ import java.io.InputStream;
import jogamp.newt.WindowImpl;
+import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.WindowEvent;
@@ -178,13 +179,20 @@ public class LinuxMouseTracker implements WindowListener {
}
if(null != focusedWindow) {
- if( x >= focusedWindow.getScreen().getWidth() ) {
- x = focusedWindow.getScreen().getWidth() - 1;
- }
- if( y >= focusedWindow.getScreen().getHeight() ) {
- y = focusedWindow.getScreen().getHeight() - 1;
+ // Clip to Screen Size
+ {
+ final Screen focusedScreen = focusedWindow.getScreen();
+ final int sw = focusedScreen.getWidth();
+ final int sh = focusedScreen.getHeight();
+ if( x >= sw ) {
+ x = sw - 1;
+ }
+ if( y >= sh ) {
+ y = sh - 1;
+ }
}
- final int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY();
+ final int[] winScreenPos = focusedWindow.convertToPixelUnits(new int[] { focusedWindow.getX(), focusedWindow.getY() });
+ final int wx = x - winScreenPos[0], wy = y - winScreenPos[1];
if(old_x != x || old_y != y) {
// mouse moved
lastFocusedX = wx;
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index 541247efd..00f935f86 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -253,7 +253,8 @@ public class WindowDriver extends WindowImpl {
public void run() {
final Point p0 = convertToPixelUnits( getLocationOnScreenImpl(0, 0) );
res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine,
- p0.getX(), p0.getY(), p0.getX()+getSurfaceWidth(), p0.getY()+getSurfaceHeight()));
+ p0.getX(), p0.getY(),
+ p0.getX()+getSurfaceWidth(), p0.getY()+getSurfaceHeight()));
}
});
return res[0].booleanValue();
@@ -264,7 +265,7 @@ public class WindowDriver extends WindowImpl {
this.runOnEDTIfAvail(true, new Runnable() {
@Override
public void run() {
- final Point sPos = getLocationOnScreenImpl(x, y);
+ final Point sPos = convertToPixelUnits( getLocationOnScreenImpl(x, y) );
warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY());
}
});
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
index fc08301cb..5cbcb7380 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
@@ -33,6 +33,7 @@ import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.Arrays;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -46,7 +47,6 @@ import com.jogamp.newt.Window;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.av.GLMediaPlayer;
@@ -120,7 +120,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
{
final int padding = mPlayerHUD ? 32 : 0;
final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowMain.getDelegatedWindow()).getAndroidView();
- glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding);
+ glWindowMain.setSurfaceSize(scrn.getWidth()-padding, scrn.getHeight()-padding);
glWindowMain.setUndecorated(true);
// setContentView(getWindow(), glWindowMain);
viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowMain.getSurfaceWidth(), glWindowMain.getSurfaceHeight(), Gravity.BOTTOM|Gravity.RIGHT));
@@ -172,15 +172,13 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
public boolean run(GLAutoDrawable drawable) {
final GLMediaPlayer mPlayerSub;
final MovieSimple demoHUD;
- int x2 = scrn.getX();
- int y2 = scrn.getY();
- int w2 = scrn.getWidth()/3;
- int h2 = scrn.getHeight()/3;
+ final Rectangle windowBounds = scrn.getViewportInWindowUnits(glWindowHUD);
if(null != mPlayerShared) {
if(0 < mPlayerShared.getWidth() && mPlayerShared.getWidth()<scrn.getWidth()/2 &&
0 < mPlayerShared.getHeight() && mPlayerShared.getHeight()<scrn.getHeight()/2) {
- w2 = mPlayerShared.getWidth();
- h2 = mPlayerShared.getHeight();
+ final int[] wh = glWindowHUD.convertToWindowUnits(new int[]{mPlayerShared.getWidth(), mPlayerShared.getHeight()});
+ windowBounds.setWidth( wh[0] );
+ windowBounds.setHeight( wh[1] );
}
glWindowHUD.setSharedContext(glWindowMain.getContext());
demoHUD = new MovieSimple(mPlayerShared);
@@ -209,10 +207,10 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
});
demoHUD.initStream(streamLoc1, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0);
- glWindowHUD.setPosition(x2, y2);
- glWindowHUD.setSize(w2, h2);
+ glWindowHUD.setPosition(windowBounds.getX(), windowBounds.getY());
+ glWindowHUD.setSize(windowBounds.getWidth(), windowBounds.getHeight());
System.err.println("HUD: "+mPlayerHUD);
- System.err.println("HUD: "+w2+"x"+h2);
+ System.err.println("HUD: "+windowBounds);
glWindowHUD.addMouseListener(toFrontMouseListener);
viewGroup.post(new Runnable() {
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
index beaf60460..a07d3c97b 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -46,24 +46,24 @@ import android.util.Log;
public class NEWTGearsES2TransActivity extends NewtBaseActivity {
static String TAG = "NEWTGearsES2TransActivity";
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate - 0");
super.onCreate(savedInstanceState);
-
+
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES2));
caps.setBackgroundOpaque(false);
-
+
Log.d(TAG, "req caps: "+caps);
Screen screen = NewtFactory.createScreen(NewtFactory.createDisplay(null), 0);
screen.addReference();
GLWindow glWindow = GLWindow.create(screen, caps);
- glWindow.setSize(2*screen.getWidth()/3, 2*screen.getHeight()/3);
+ glWindow.setSurfaceSize(2*screen.getWidth()/3, 2*screen.getHeight()/3);
glWindow.setUndecorated(true);
setContentView(getWindow(), glWindow);
-
+
glWindow.addGLEventListener(new GearsES2(-1));
glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() {
@Override
@@ -75,14 +75,14 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity {
});
Animator animator = new Animator(glWindow);
// glWindow.setSkipContextReleaseThread(animator.getThread());
-
+
glWindow.setVisible(true);
-
+
animator.setUpdateFPSFrames(60, System.err);
animator.resetFPSCounter();
glWindow.resetFPSCounter();
-
+
screen.removeReference();
Log.d(TAG, "onCreate - X");
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java
index f1bc0ab7a..00001d8d2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore;
import javax.media.nativewindow.Capabilities;
@@ -55,44 +55,45 @@ import com.jogamp.opengl.util.Animator;
*/
public abstract class InitConcurrentBaseNEWT extends UITestCase {
- static final int demoSize = 128;
-
+ static final int demoWinSize = 128;
+
static long duration = 300; // ms
-
+
static InsetsImmutable insets = null;
- static int scrnHeight, scrnWidth;
static int num_x, num_y;
-
+
@BeforeClass
public static void initClass() {
Window dummyWindow = NewtFactory.createWindow(new Capabilities());
- dummyWindow.setSize(demoSize, demoSize);
+ dummyWindow.setSize(demoWinSize, demoWinSize);
dummyWindow.setVisible(true);
Assert.assertEquals(true, dummyWindow.isVisible());
Assert.assertEquals(true, dummyWindow.isNativeValid());
- insets = dummyWindow.getInsets();
- scrnHeight = dummyWindow.getScreen().getHeight();
- scrnWidth = dummyWindow.getScreen().getWidth();
- num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2;
- num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2;
+ insets = dummyWindow.getInsets();
+ final int scrnHeight = dummyWindow.getScreen().getHeight();
+ final int scrnWidth = dummyWindow.getScreen().getWidth();
+ final int[] demoScreenSize = dummyWindow.convertToPixelUnits(new int[] { demoWinSize, demoWinSize });
+ final int[] insetsScreenSize = dummyWindow.convertToPixelUnits(new int[] { insets.getTotalWidth(), insets.getTotalHeight() });
+ num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2;
+ num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2;
dummyWindow.destroy();
}
-
+
public class JOGLTask implements Runnable {
private final int id;
private final Object postSync;
private final boolean reuse;
private boolean done = false;
-
+
public JOGLTask(Object postSync, int id, boolean reuse) {
this.postSync = postSync;
this.id = id;
this.reuse = reuse;
}
public void run() {
- int x = ( id % num_x ) * ( demoSize + insets.getTotalHeight() );
- int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() );
-
+ int x = ( id % num_x ) * ( demoWinSize + insets.getTotalHeight() );
+ int y = ( (id / num_x) % num_y ) * ( demoWinSize + insets.getTotalHeight() );
+
System.err.println("JOGLTask "+id+": START: "+x+"/"+y+", reuse "+reuse+" - "+Thread.currentThread().getName());
final Display display = NewtFactory.createDisplay(null, reuse);
final Screen screen = NewtFactory.createScreen(display, 0);
@@ -100,25 +101,25 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
Assert.assertNotNull(glWindow);
glWindow.setTitle("Task "+id);
glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() );
-
+
glWindow.addGLEventListener(new ValidateLockListener());
glWindow.addGLEventListener(new GearsES2(0));
-
+
Animator animator = new Animator(glWindow);
-
- glWindow.setSize(demoSize, demoSize);
+
+ glWindow.setSize(demoWinSize, demoWinSize);
glWindow.setVisible(true);
animator.setUpdateFPSFrames(60, null);
-
+
System.err.println("JOGLTask "+id+": INITIALIZED: "+", "+display+" - "+Thread.currentThread().getName());
-
+
animator.start();
Assert.assertEquals(true, animator.isAnimating());
Assert.assertEquals(true, glWindow.isVisible());
Assert.assertEquals(true, glWindow.isNativeValid());
Assert.assertEquals(true, glWindow.isRealized());
System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName());
-
+
while(animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
try {
Thread.sleep(100);
@@ -126,10 +127,10 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
e.printStackTrace();
}
}
-
+
animator.stop();
glWindow.destroy();
-
+
System.err.println("JOGLTask "+id+": DONE/SYNC: "+Thread.currentThread().getName());
synchronized (postSync) {
done = true;
@@ -137,7 +138,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
postSync.notifyAll();
}
}
-
+
public boolean done() { return done; }
}
@@ -161,7 +162,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
sb.append("]");
return sb.toString();
}
-
+
protected static boolean isDead(Thread[] threads) {
for(int i=threads.length-1; i>=0; i--) {
if(threads[i].isAlive()) {
@@ -182,7 +183,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
sb.append("]");
return sb.toString();
}
-
+
protected void runJOGLTasks(int num, boolean reuse) throws InterruptedException {
System.err.println("InitConcurrentBaseNEWT "+num+" threads, reuse display: "+reuse);
final String currentThreadName = Thread.currentThread().getName();
@@ -194,8 +195,8 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
tasks[i] = new JOGLTask(syncDone, i, reuse);
threads[i] = new Thread(tasks[i], currentThreadName+"-jt"+i);
}
- final long t0 = System.currentTimeMillis();
-
+ final long t0 = System.currentTimeMillis();
+
for(i=0; i<num; i++) {
threads[i].start();
}
@@ -213,13 +214,13 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase {
}
final long t1 = System.currentTimeMillis();
System.err.println("total: "+(t1-t0)/1000.0+"s");
-
+
Assert.assertTrue("Tasks are incomplete. Complete: "+doneDump(tasks), done(tasks));
i=0;
while(i<30 && !isDead(threads)) {
Thread.sleep(100);
i++;
}
- Assert.assertTrue("Threads are still alive after 3s. Alive: "+isAliveDump(threads), isDead(threads));
- }
+ Assert.assertTrue("Threads are still alive after 3s. Alive: "+isAliveDump(threads), isDead(threads));
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java
index 4980e8562..f1a185c31 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore.ect;
import com.jogamp.newt.NewtFactory;
@@ -54,44 +54,45 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
/**
- * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase.
+ * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public abstract class ExclusiveContextBase00 extends UITestCase {
static boolean testExclusiveWithAWT = false;
- static final int durationParts = 9;
+ static final int durationParts = 9;
static long duration = 320 * durationParts; // ms ~ 20 frames
-
+
static boolean showFPS = false;
static int showFPSRate = 100;
-
- static final int demoSize = 128;
-
+
+ static final int demoWinSize = 128;
+
static InsetsImmutable insets = null;
- static int scrnHeight, scrnWidth;
static int num_x, num_y;
-
+
static int swapInterval = 0;
-
+
@BeforeClass
public static void initClass00() {
Window dummyWindow = NewtFactory.createWindow(new Capabilities());
- dummyWindow.setSize(demoSize, demoSize);
+ dummyWindow.setSize(demoWinSize, demoWinSize);
dummyWindow.setVisible(true);
Assert.assertEquals(true, dummyWindow.isVisible());
Assert.assertEquals(true, dummyWindow.isNativeValid());
- insets = dummyWindow.getInsets();
- scrnHeight = dummyWindow.getScreen().getHeight();
- scrnWidth = dummyWindow.getScreen().getWidth();
- num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2;
- num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2;
+ insets = dummyWindow.getInsets();
+ final int scrnHeight = dummyWindow.getScreen().getHeight();
+ final int scrnWidth = dummyWindow.getScreen().getWidth();
+ final int[] demoScreenSize = dummyWindow.convertToPixelUnits(new int[] { demoWinSize, demoWinSize });
+ final int[] insetsScreenSize = dummyWindow.convertToPixelUnits(new int[] { insets.getTotalWidth(), insets.getTotalHeight() });
+ num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2;
+ num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2;
dummyWindow.destroy();
}
@AfterClass
public static void releaseClass00() {
}
-
+
protected abstract boolean isAWTTestCase();
protected abstract Thread getAWTRenderThread();
protected abstract AnimatorBase createAnimator();
@@ -120,16 +121,16 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
}
final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount];
for(int i=0; i<drawableCount; i++) {
- final int x = ( i % num_x ) * ( demoSize + insets.getTotalHeight() ) + insets.getLeftWidth();
- final int y = ( (i / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ) + insets.getTopHeight();
-
- drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoSize, demoSize, caps);
+ final int x = ( i % num_x ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getLeftWidth();
+ final int y = ( (i / num_x) % num_y ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getTopHeight();
+
+ drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoWinSize, demoWinSize, caps);
Assert.assertNotNull(drawables[i]);
final GearsES2 demo = new GearsES2(swapInterval);
demo.setVerbose(false);
drawables[i].addGLEventListener(demo);
}
-
+
if( preAdd ) {
for(int i=0; i<drawableCount; i++) {
animator.add(drawables[i]);
@@ -144,10 +145,10 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
}
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
-
+
// Animator Start
Assert.assertTrue(animator.start());
-
+
Assert.assertTrue(animator.isStarted());
if( preAdd ) {
Assert.assertTrue(animator.isAnimating());
@@ -166,7 +167,7 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
Assert.assertTrue(animator.isAnimating());
}
Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
-
+
// After start, ExclusiveContextThread is set
{
final Thread ect = animator.getExclusiveContextThread();
@@ -178,14 +179,14 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
}
} else {
Assert.assertEquals(null, ect);
- }
+ }
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(ect, drawables[i].getExclusiveContextThread());
}
setGLAutoDrawableVisible(drawables);
}
animator.setUpdateFPSFrames(showFPSRate, showFPS ? System.err : null);
-
+
// Normal run ..
Thread.sleep(duration/durationParts); // 1
@@ -197,19 +198,19 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
Assert.assertEquals(awtRenderThread, ect);
} else {
Assert.assertEquals(animator.getThread(), ect);
- }
+ }
for(int i=0; i<drawableCount; i++) {
final Thread t = drawables[i].setExclusiveContextThread(null);
Assert.assertEquals(ect, t);
}
-
+
Thread.sleep(duration/durationParts); // 2
-
+
for(int i=0; i<drawableCount; i++) {
// poll until clearing drawable ECT is established
{
boolean ok = null == drawables[i].getExclusiveContextThread();
- int c = 0;
+ int c = 0;
while(!ok && c<5*50) { // 5*50*20 = 5s TO
Thread.sleep(20);
ok = null == drawables[i].getExclusiveContextThread();
@@ -223,10 +224,10 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
final Thread t = drawables[i].setExclusiveContextThread(ect);
Assert.assertEquals(null, t);
}
-
+
Thread.sleep(duration/durationParts); // 3
}
-
+
// Disable/Enable exclusive mode via Animator for all GLAutoDrawable
if(exclusive) {
final Thread ect = animator.getExclusiveContextThread();
@@ -234,31 +235,31 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
Assert.assertEquals(awtRenderThread, ect);
} else {
Assert.assertEquals(animator.getThread(), ect);
- }
-
+ }
+
Assert.assertEquals(true, animator.setExclusiveContext(false));
Assert.assertFalse(animator.isExclusiveContextEnabled());
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(null, drawables[i].getExclusiveContextThread());
}
-
+
Thread.sleep(duration/durationParts); // 4
-
+
Assert.assertEquals(null, animator.setExclusiveContext(ect));
Assert.assertTrue(animator.isExclusiveContextEnabled());
Assert.assertEquals(ect, animator.getExclusiveContextThread());
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(ect, drawables[i].getExclusiveContextThread());
}
-
+
Thread.sleep(duration/durationParts); // 5
- }
-
+ }
+
Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
Assert.assertTrue(animator.isStarted());
Assert.assertTrue(animator.isAnimating());
Assert.assertFalse(animator.isPaused());
-
+
// Animator Pause
Assert.assertTrue(animator.pause());
Assert.assertTrue(animator.isStarted());
@@ -277,9 +278,9 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
}
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(null, drawables[i].getExclusiveContextThread());
- }
+ }
Thread.sleep(duration/durationParts); // 6
-
+
// Animator Resume
Assert.assertTrue(animator.resume());
Assert.assertTrue(animator.isStarted());
@@ -295,32 +296,32 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
}
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(ect, drawables[i].getExclusiveContextThread());
- }
+ }
} else {
Assert.assertEquals(null, animator.getExclusiveContextThread());
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(null, drawables[i].getExclusiveContextThread());
- }
+ }
}
Thread.sleep(duration/durationParts); // 7
-
+
// Animator Stop #1
- Assert.assertTrue(animator.stop());
+ Assert.assertTrue(animator.stop());
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
- Assert.assertFalse(animator.isPaused());
+ Assert.assertFalse(animator.isPaused());
Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
Assert.assertEquals(null, animator.getExclusiveContextThread());
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(null, drawables[i].getExclusiveContextThread());
}
Thread.sleep(duration/durationParts); // 8
-
+
// Animator Re-Start
- Assert.assertTrue(animator.start());
+ Assert.assertTrue(animator.start());
Assert.assertTrue(animator.isStarted());
Assert.assertTrue(animator.isAnimating());
- Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
+ Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
// After start, ExclusiveContextThread is set
{
final Thread ect = animator.getExclusiveContextThread();
@@ -332,13 +333,13 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
}
} else {
Assert.assertEquals(null, ect);
- }
+ }
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(ect, drawables[i].getExclusiveContextThread());
}
}
Thread.sleep(duration/durationParts); // 9
-
+
// Remove all drawables .. while running!
for(int i=0; i<drawableCount; i++) {
final GLAutoDrawable drawable = drawables[i];
@@ -348,22 +349,22 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
Assert.assertTrue(animator.isStarted());
Assert.assertFalse(animator.isAnimating()); // no drawables in list!
} // !shortenTest
-
+
// Animator Stop #2
- Assert.assertTrue(animator.stop());
+ Assert.assertTrue(animator.stop());
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
- Assert.assertFalse(animator.isPaused());
+ Assert.assertFalse(animator.isPaused());
Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
Assert.assertEquals(null, animator.getExclusiveContextThread());
-
+
// Destroy GLWindows
for(int i=0; i<drawableCount; i++) {
destroyGLAutoDrawableVisible(drawables[i]);
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(drawables[i], false));
- }
- }
-
+ }
+ }
+
@Test
public void test01NormalPre_1Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
@@ -384,40 +385,40 @@ public abstract class ExclusiveContextBase00 extends UITestCase {
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 1 /* numWin */, true /* exclusive */, true /* preAdd */, false /* short */);
}
-
+
@Test
public void test04ExclPost_1Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 1 /* numWin */, true /* exclusive */, false /* preAdd */, true /* short */);
}
-
+
@Test
public void test05NormalPre_4Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 4 /* numWin */, false /* exclusive */, true /* preAdd */, false /* short */);
}
-
+
@Test
public void test06NormalPost_4Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 4 /* numWin */, false /* exclusive */, false /* preAdd */, true /* short */);
}
-
+
@Test
public void test07ExclPre_4Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 4 /* numWin */, true /* exclusive */, true /* preAdd */, false /* short */);
}
-
+
@Test
public void test08ExclPost_4Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 4 /* numWin */, true /* exclusive */, false /* preAdd */, true /* short */);
}
-
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java
index 516622796..b6d4c4e6b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.acore.ect;
import com.jogamp.newt.NewtFactory;
@@ -54,43 +54,44 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
/**
- * ExclusiveContextThread base implementation to test performance impact of the ExclusiveContext feature with AnimatorBase.
+ * ExclusiveContextThread base implementation to test performance impact of the ExclusiveContext feature with AnimatorBase.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public abstract class ExclusiveContextBase10 extends UITestCase {
static boolean testExclusiveWithAWT = false;
static long duration = 1400;
-
+
static boolean showFPS = true;
static int showFPSRate = 60;
-
- static final int demoSize = 128;
-
+
+ static final int demoWinSize = 128;
+
static InsetsImmutable insets = null;
- static int scrnHeight, scrnWidth;
static int num_x, num_y;
-
+
static int swapInterval = 0;
-
+
@BeforeClass
public static void initClass00() {
Window dummyWindow = NewtFactory.createWindow(new Capabilities());
- dummyWindow.setSize(demoSize, demoSize);
+ dummyWindow.setSize(demoWinSize, demoWinSize);
dummyWindow.setVisible(true);
Assert.assertEquals(true, dummyWindow.isVisible());
Assert.assertEquals(true, dummyWindow.isNativeValid());
- insets = dummyWindow.getInsets();
- scrnHeight = dummyWindow.getScreen().getHeight();
- scrnWidth = dummyWindow.getScreen().getWidth();
- num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2;
- num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2;
+ insets = dummyWindow.getInsets();
+ final int scrnHeight = dummyWindow.getScreen().getHeight();
+ final int scrnWidth = dummyWindow.getScreen().getWidth();
+ final int[] demoScreenSize = dummyWindow.convertToPixelUnits(new int[] { demoWinSize, demoWinSize });
+ final int[] insetsScreenSize = dummyWindow.convertToPixelUnits(new int[] { insets.getTotalWidth(), insets.getTotalHeight() });
+ num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2;
+ num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2;
dummyWindow.destroy();
}
@AfterClass
public static void releaseClass00() {
}
-
+
protected abstract boolean isAWTTestCase();
protected abstract Thread getAWTRenderThread();
protected abstract AnimatorBase createAnimator();
@@ -119,16 +120,16 @@ public abstract class ExclusiveContextBase10 extends UITestCase {
}
final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount];
for(int i=0; i<drawableCount; i++) {
- final int x = ( i % num_x ) * ( demoSize + insets.getTotalHeight() ) + insets.getLeftWidth();
- final int y = ( (i / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ) + insets.getTopHeight();
-
- drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoSize, demoSize, caps);
+ final int x = ( i % num_x ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getLeftWidth();
+ final int y = ( (i / num_x) % num_y ) * ( demoWinSize + insets.getTotalHeight() ) + insets.getTopHeight();
+
+ drawables[i] = createGLAutoDrawable("Win #"+i, x, y, demoWinSize, demoWinSize, caps);
Assert.assertNotNull(drawables[i]);
final GearsES2 demo = new GearsES2(swapInterval);
demo.setVerbose(false);
drawables[i].addGLEventListener(demo);
}
-
+
for(int i=0; i<drawableCount; i++) {
animator.add(drawables[i]);
}
@@ -141,14 +142,14 @@ public abstract class ExclusiveContextBase10 extends UITestCase {
}
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
-
+
// Animator Start
Assert.assertTrue(animator.start());
-
+
Assert.assertTrue(animator.isStarted());
Assert.assertTrue(animator.isAnimating());
Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
-
+
// After start, ExclusiveContextThread is set
{
final Thread ect = animator.getExclusiveContextThread();
@@ -160,32 +161,32 @@ public abstract class ExclusiveContextBase10 extends UITestCase {
}
} else {
Assert.assertEquals(null, ect);
- }
+ }
for(int i=0; i<drawableCount; i++) {
Assert.assertEquals(ect, drawables[i].getExclusiveContextThread());
}
setGLAutoDrawableVisible(drawables);
}
animator.setUpdateFPSFrames(showFPSRate, showFPS ? System.err : null);
-
+
// Normal run ..
Thread.sleep(duration);
-
+
// Animator Stop #2
- Assert.assertTrue(animator.stop());
+ Assert.assertTrue(animator.stop());
Assert.assertFalse(animator.isAnimating());
Assert.assertFalse(animator.isStarted());
- Assert.assertFalse(animator.isPaused());
+ Assert.assertFalse(animator.isPaused());
Assert.assertEquals(exclusive, animator.isExclusiveContextEnabled());
Assert.assertEquals(null, animator.getExclusiveContextThread());
-
+
// Destroy GLWindows
for(int i=0; i<drawableCount; i++) {
destroyGLAutoDrawableVisible(drawables[i]);
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(drawables[i], false));
- }
- }
-
+ }
+ }
+
@Test
public void test01Normal_1Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
@@ -199,18 +200,18 @@ public abstract class ExclusiveContextBase10 extends UITestCase {
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 1 /* numWin */, true /* exclusive */);
}
-
+
@Test
public void test05Normal_4Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 4 /* numWin */, false /* exclusive */);
}
-
+
@Test
public void test07Excl_4Win() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, 4 /* numWin */, true /* exclusive */);
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
index 2f5fb2606..22154ab58 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,27 +20,27 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.jogl.newt;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
-
import com.jogamp.opengl.test.junit.util.*;
import java.lang.reflect.InvocationTargetException;
import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.Animator;
import com.jogamp.newt.Screen;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.awt.NewtCanvasAWT;
@@ -57,6 +57,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+
import javax.media.opengl.GLEventListener;
import javax.swing.JButton;
import javax.swing.JFrame;
@@ -158,7 +159,7 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
colorPanel.setBackground(Color.white);
colorPanel.repaint();
}});
-
+
robot = new Robot();
robot.setAutoWaitForIdle(true);
@@ -167,12 +168,12 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
Thread.sleep(AWTRobotUtil.TIME_SLICE);
}
Assert.assertEquals(true, frame.isVisible());
-
+
System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.setup(): Before NativeWindow init");
-
+
NativeWindowFactory.initSingleton();
-
- AWTRobotUtil.clearAWTFocus(robot);
+
+ AWTRobotUtil.clearAWTFocus(robot);
AWTRobotUtil.toFrontAndRequestFocus(robot, frame);
AWTRobotUtil.requestFocus(robot, button);
@@ -198,7 +199,7 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.release(): End");
}
- protected void runTestGL(final Canvas canvas, GLAutoDrawable drawable)
+ protected void runTestGL(final Canvas canvas, GLAutoDrawable drawable)
throws AWTException, InterruptedException, InvocationTargetException {
Dimension size = new Dimension(400,400);
@@ -268,9 +269,10 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
win0.setSize(100,100);
win0.setVisible(true);
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(win0, true));
-
+
Screen screen = win0.getScreen();
- win0.setPosition(screen.getWidth()-150, 0);
+ final Rectangle screenBoundsInWinU = screen.getViewportInWindowUnits(win0);
+ win0.setPosition(screenBoundsInWinU.getX()-150, 0);
win0.addGLEventListener(new GearsES2());
Animator anim = new Animator(win0);
anim.start();
@@ -282,14 +284,14 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
win0.destroy();
Assert.assertEquals(true, AWTRobotUtil.waitForRealized(win0, false));
- Assert.assertEquals(false, win0.isNativeValid());
+ Assert.assertEquals(false, win0.isNativeValid());
Assert.assertEquals(true, anim.isAnimating()); // due to newtCanvasAWT/win1
newtCanvasAWT.destroy(); // destroys both newtCanvasAWT/win1
Assert.assertEquals(false, win1.isNativeValid());
Assert.assertEquals(false, win0.isNativeValid());
Assert.assertEquals(true, anim.isAnimating());
-
+
Assert.assertEquals(true, anim.stop());
Assert.assertEquals(false, anim.isAnimating());
@@ -321,10 +323,10 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
GLCanvas glCanvas = new GLCanvas(caps);
anim.add(glCanvas);
runTestGL(glCanvas, glCanvas);
-
+
anim.remove(glCanvas);
Assert.assertEquals(false, anim.isAnimating());
-
+
/**
win0.destroy();
Assert.assertEquals(true, anim.isAnimating());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
index 87cb6f05b..8c679d209 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle02NEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -34,11 +34,13 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.opengl.*;
import com.jogamp.newt.*;
import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
+
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
@@ -68,7 +70,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
//
// Create native windowing resources .. X11/Win/OSX
- //
+ //
GLWindow glWindow = GLWindow.create(caps);
glWindow.setUpdateFPSFrames(1, null);
@@ -147,7 +149,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
window.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
-
+
Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
@@ -195,7 +197,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
window.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
-
+
Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
@@ -239,7 +241,8 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
GLWindow window2 = createWindow(caps, width, height);
Assert.assertSame(screen, window2.getScreen());
Assert.assertSame(display, window2.getScreen().getDisplay());
- window2.setPosition(screen.getWidth()-width, 0);
+ final Rectangle screenBoundsInWinU = screen.getViewportInWindowUnits(window2);
+ window2.setPosition(screenBoundsInWinU.getWidth()-width, 0);
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
@@ -298,7 +301,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
// destruction ...
window1.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window1, false));
-
+
Assert.assertNotNull(window1.getScreen());
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
@@ -316,7 +319,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
window2.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window2, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
-
+
Assert.assertNotNull(window2.getScreen());
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());
@@ -331,12 +334,12 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
- // invalidate (again) ..
+ // invalidate (again) ..
window1.destroy();
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
- // invalidate (again) ..
+ // invalidate (again) ..
window2.destroy();
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java
index 86cb53319..6bad27384 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.newt;
@@ -35,12 +35,14 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.opengl.*;
import com.jogamp.opengl.util.Animator;
import com.jogamp.newt.*;
import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
+
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -67,7 +69,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
//
// Create native windowing resources .. X11/Win/OSX
- //
+ //
GLWindow glWindow;
if(null!=screen) {
Window window = NewtFactory.createWindow(screen, caps);
@@ -76,7 +78,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
} else {
glWindow = GLWindow.create(caps);
}
- glWindow.setUpdateFPSFrames(1, null);
+ glWindow.setUpdateFPSFrames(1, null);
Assert.assertNotNull(glWindow);
glWindow.setUndecorated(onscreen && undecorated);
@@ -96,9 +98,9 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
// System.out.println("Created: "+glWindow);
//
- // Create native OpenGL resources .. XGL/WGL/CGL ..
+ // Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
- //
+ //
GLCapabilitiesImmutable caps2 = glWindow.getChosenGLCapabilities();
Assert.assertNotNull(caps2);
Assert.assertTrue(caps2.getGreenBits()>=5);
@@ -121,18 +123,18 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
Assert.assertNotNull(caps);
GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */, true /* vsync */);
Animator animator = new Animator(window);
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(1, null);
Assert.assertTrue(animator.start());
while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) {
Thread.sleep(100);
}
- destroyWindow(window); // destroy - but still in animator
+ destroyWindow(window); // destroy - but still in animator
Assert.assertEquals(false, window.isNativeValid());
- Assert.assertEquals(false, window.isVisible());
+ Assert.assertEquals(false, window.isVisible());
Assert.assertEquals(true, animator.isAnimating());
Assert.assertEquals(false, animator.isPaused());
Assert.assertEquals(true, animator.isStarted());
-
+
animator.remove(window);
Thread.sleep(250); // give animator a chance to become paused
Assert.assertEquals(false, animator.isAnimating());
@@ -147,7 +149,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
Assert.assertNotNull(caps);
GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */, true /* vsync */);
Animator animator = new Animator();
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(1, null);
Assert.assertTrue(animator.start());
Thread.sleep(250); // give animator a chance to become paused
Assert.assertEquals(false, animator.isAnimating()); // zero drawables
@@ -185,10 +187,11 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
GLWindow window2 = createWindow(screen, caps, width-10, height-10, true /* onscreen */, false /* undecorated */, true /* vsync */);
Assert.assertNotNull(window2);
- window2.setPosition(screen.getWidth()-width, 0);
+ final Rectangle screenBoundsInWinU = screen.getViewportInWindowUnits(window2);
+ window2.setPosition(screenBoundsInWinU.getWidth()-width, 0);
Animator animator = new Animator();
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(1, null);
Assert.assertEquals(false, animator.isStarted());
Assert.assertEquals(false, animator.isAnimating()); // zero drawables
Assert.assertEquals(false, animator.isPaused()); // zero drawables, but not started
@@ -251,10 +254,11 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
Assert.assertNotNull(screen2);
GLWindow window2 = createWindow(screen2, caps, width-10, height-10, true /* onscreen */, false /* undecorated */, true /* vsync */);
Assert.assertNotNull(window2);
- window2.setPosition(screen2.getWidth()-width, 0);
+ final Rectangle screen2BoundsInWinU = screen2.getViewportInWindowUnits(window2);
+ window2.setPosition(screen2BoundsInWinU.getWidth()-width, 0);
Animator animator = new Animator();
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(1, null);
Assert.assertEquals(false, animator.isStarted());
Assert.assertEquals(false, animator.isAnimating());
Assert.assertEquals(false, animator.isPaused());
@@ -287,23 +291,23 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest+durationPerTest/10) {
Thread.sleep(100);
}
-
- Assert.assertEquals(true, animator.isStarted());
+
+ Assert.assertEquals(true, animator.isStarted());
Assert.assertEquals(true, animator.isAnimating());
Assert.assertEquals(false, animator.isPaused());
-
+
Assert.assertEquals(true, animator.pause());
-
- Assert.assertEquals(true, animator.isStarted());
+
+ Assert.assertEquals(true, animator.isStarted());
Assert.assertEquals(false, animator.isAnimating());
Assert.assertEquals(true, animator.isPaused());
Assert.assertEquals(true, animator.resume());
-
+
Assert.assertEquals(true, animator.isStarted());
Assert.assertEquals(true, animator.isAnimating());
Assert.assertEquals(false, animator.isPaused());
-
+
destroyWindow(window2);
animator.remove(window2);
Assert.assertEquals(true, animator.isStarted());
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
index 871012a28..ac5e7e53c 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,15 +20,16 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
+
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -54,7 +55,9 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import java.util.List;
+
import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
/**
@@ -64,7 +67,7 @@ import javax.media.nativewindow.util.RectangleImmutable;
public class TestScreenMode01bNEWT extends UITestCase {
static GLProfile glp;
static int width, height;
-
+
static long waitTimeShort = 2000;
static long duration = 6000;
@@ -80,14 +83,15 @@ public class TestScreenMode01bNEWT extends UITestCase {
public static void releaseClass() throws InterruptedException {
Thread.sleep(waitTimeShort);
}
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException {
+
+ static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int screenXPos, int screenYPos, int width, int height) throws InterruptedException {
Assert.assertNotNull(caps);
GLWindow window = GLWindow.create(screen, caps);
// Window window = NewtFactory.createWindow(screen, caps);
+ final int[] winPos = window.convertToWindowUnits(new int[] { screenXPos, screenYPos });
window.setTitle(name);
- window.setPosition(x, y);
+ window.setPosition(winPos[0], winPos[1]);
window.setSize(width, height);
window.addGLEventListener(new GearsES2());
Assert.assertNotNull(window);
@@ -100,10 +104,10 @@ public class TestScreenMode01bNEWT extends UITestCase {
static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
-
+
@Test
public void testScreenModeChangeSingleQ1() throws InterruptedException {
final Display display = NewtFactory.createDisplay(null); // local display
@@ -119,7 +123,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
-
+
@Test
public void testScreenModeChangeSingleQ2() throws InterruptedException {
final Display display = NewtFactory.createDisplay(null); // local display
@@ -139,24 +143,26 @@ public class TestScreenMode01bNEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
-
- void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException {
+
+ void testScreenModeChangeImpl(final Screen screen, int screenXPos, int screenYPos) throws InterruptedException {
Thread.sleep(waitTimeShort);
final GLCapabilities caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
final Display display = screen.getDisplay();
System.err.println("Test.0: Window screen: "+screen);
-
- System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport());
-
- GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height);
- Assert.assertNotNull(window0);
- System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport());
+
+ System.err.println("Test.0: Window bounds (pre): screenPos "+screenXPos+"/"+screenYPos+" [pixels], windowSize "+width+"x"+height+" [wu] within "+screen.getViewport()+" [pixels]");
+
+ GLWindow window0 = createWindow(screen, caps, "win0", screenXPos, screenYPos, width, height);
+ Assert.assertNotNull(window0);
+ Rectangle window0ScreenRect = window0.getSurfaceBounds();
+ System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]");
+ System.err.println("Test.0: Window screenRect: "+window0ScreenRect+" [pixels]");
final Animator anim = new Animator(window0);
anim.start();
-
+
List<MonitorMode> allMonitorModes = screen.getMonitorModes();
Assert.assertTrue(allMonitorModes.size()>0);
if(allMonitorModes.size()==1) {
@@ -168,7 +174,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
MonitorDevice monitor = window0.getMainMonitor();
System.err.println("Test.0: Window monitor: "+monitor);
-
+
List<MonitorMode> monitorModes = monitor.getSupportedModes();
Assert.assertTrue(monitorModes.size()>0);
if(monitorModes.size()==1) {
@@ -178,7 +184,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
return;
}
Assert.assertTrue(allMonitorModes.containsAll(monitorModes));
-
+
MonitorMode mmCurrent = monitor.getCurrentMode();
Assert.assertNotNull(mmCurrent);
MonitorMode mmOrig = monitor.getOriginalMode();
@@ -199,7 +205,7 @@ public class TestScreenMode01bNEWT extends UITestCase {
monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
Assert.assertNotNull(monitorModes);
Assert.assertTrue(monitorModes.size()>0);
-
+
monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
Assert.assertNotNull(monitorModes);
Assert.assertTrue(monitorModes.size()>0);
@@ -218,10 +224,14 @@ public class TestScreenMode01bNEWT extends UITestCase {
Assert.assertTrue(smOk);
}
- System.err.println("Test.1: Window screen: "+screen);
- System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport());
- System.err.println("Test.1: Window monitor: "+window0.getMainMonitor());
-
+ window0ScreenRect = window0.getSurfaceBounds();
+ System.err.println("Test.1: Screen : "+screen);
+ System.err.println("Test.1: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]");
+ System.err.println("Test.1: Window screenRect: "+window0ScreenRect+" [pixels]");
+ System.err.println("Test.1: Screen viewport : "+screen.getViewport()+" [pixels]");
+ System.err.println("Test.1: Window monitor : "+monitor.getViewport()+" [pixels]");
+ System.err.println("Test.1: Window main-mon : "+window0.getMainMonitor());
+
Thread.sleep(duration);
Assert.assertEquals(true,display.isNativeValid());
@@ -238,12 +248,15 @@ public class TestScreenMode01bNEWT extends UITestCase {
Assert.assertFalse(monitor.isModeChangedByUs());
Assert.assertEquals(mmOrig, mmCurrent);
Assert.assertTrue(smOk);
- }
-
- System.err.println("Test.2: Window screen: "+screen);
- System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport());
- System.err.println("Test.2: Window monitor: "+window0.getMainMonitor());
-
+ }
+
+ System.err.println("Test.2: Screen : "+screen);
+ System.err.println("Test.2: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]");
+ System.err.println("Test.2: Window screenRect: "+window0ScreenRect+" [pixels]");
+ System.err.println("Test.2: Screen viewport : "+screen.getViewport()+" [pixels]");
+ System.err.println("Test.2: Window monitor : "+monitor.getViewport()+" [pixels]");
+ System.err.println("Test.2: Window main-mon : "+window0.getMainMonitor());
+
Thread.sleep(duration);
anim.stop();
destroyWindow(window0);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java
index b4257e070..b48d582ed 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,15 +20,16 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
+
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -54,6 +55,7 @@ import com.jogamp.opengl.util.Animator;
import java.util.ArrayList;
import java.util.List;
+
import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
@@ -64,7 +66,7 @@ import javax.media.nativewindow.util.RectangleImmutable;
public class TestScreenMode01cNEWT extends UITestCase {
static GLProfile glp;
static int width, height;
-
+
static long waitTimeShort = 2000;
static long duration = 4000;
@@ -80,14 +82,15 @@ public class TestScreenMode01cNEWT extends UITestCase {
public static void releaseClass() throws InterruptedException {
Thread.sleep(waitTimeShort);
}
-
- static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException {
+
+ static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int screenXPos, int screenYPos, int width, int height) throws InterruptedException {
Assert.assertNotNull(caps);
GLWindow window = GLWindow.create(screen, caps);
// Window window = NewtFactory.createWindow(screen, caps);
+ final int[] winPos = window.convertToWindowUnits(new int[] { screenXPos, screenYPos });
window.setTitle(name);
- window.setPosition(x, y);
+ window.setPosition(winPos[0], winPos[1]);
window.setSize(width, height);
window.addGLEventListener(new GearsES2());
Assert.assertNotNull(window);
@@ -100,10 +103,10 @@ public class TestScreenMode01cNEWT extends UITestCase {
static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
-
+
@Test
public void testScreenFullscreenSingleQ1() throws InterruptedException {
final Display display = NewtFactory.createDisplay(null); // local display
@@ -116,17 +119,17 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null);
} finally {
screen.removeReference();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
-
+
@Test
public void testScreenFullscreenSingleQ2() throws InterruptedException {
final Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
Assert.assertNotNull(screen);
- screen.addReference(); // trigger creation
+ screen.addReference(); // trigger creation
try {
if( 2 > screen.getMonitorDevices().size() ) {
System.err.println("Test Disabled (1): Monitor count < 2: "+screen);
@@ -136,23 +139,23 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null);
} finally {
screen.removeReference();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
-
+
@Test
public void testScreenFullscreenSpanQ1Q2() throws InterruptedException {
final Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
Assert.assertNotNull(screen);
- screen.addReference(); // trigger creation
+ screen.addReference(); // trigger creation
try {
final int crtCount = screen.getMonitorDevices().size();
if( 2 >= crtCount ) {
System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen);
- return;
- }
+ return;
+ }
final ArrayList<MonitorDevice> monitors = new ArrayList<MonitorDevice>();
monitors.add(screen.getMonitorDevices().get(0)); // Q1
monitors.add(screen.getMonitorDevices().get(1)); // Q2
@@ -160,17 +163,17 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors);
} finally {
screen.removeReference();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
-
+
@Test
public void testScreenFullscreenSpanALL() throws InterruptedException {
final Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
Assert.assertNotNull(screen);
- screen.addReference(); // trigger creation
+ screen.addReference(); // trigger creation
try {
if( 2 > screen.getMonitorDevices().size() ) {
System.err.println("Test Disabled (3): Monitor count < 2: "+screen);
@@ -180,28 +183,32 @@ public class TestScreenMode01cNEWT extends UITestCase {
testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null);
} finally {
screen.removeReference();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
}
}
-
- void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List<MonitorDevice> monitors) throws InterruptedException {
+
+ void testScreenFullscreenImpl(final Screen screen, final int screenXPos, final int screenYPos,
+ final boolean spanAcrossMonitors, final List<MonitorDevice> monitors) throws InterruptedException {
Thread.sleep(waitTimeShort);
final GLCapabilities caps = new GLCapabilities(glp);
Assert.assertNotNull(caps);
final Display display = screen.getDisplay();
-
+
System.err.println("Test.0: Window screen: "+screen);
-
- System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport());
-
- GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height);
- Assert.assertNotNull(window0);
- System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport());
+
+ System.err.println("Test.0: Window bounds (pre): screenPos "+screenXPos+"/"+screenYPos+" [pixels], windowSize "+width+"x"+height+" [wu] within "+screen.getViewport()+" [pixels]");
+
+ GLWindow window0 = createWindow(screen, caps, "win0", screenXPos, screenYPos, width, height);
+ Assert.assertNotNull(window0);
+ Rectangle window0ScreenRect = window0.getSurfaceBounds();
+ System.err.println("Test.0: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]");
+ System.err.println("Test.0: Window screenRect: "+window0ScreenRect+" [pixels]");
+ System.err.println("Test.0: Screen viewport : "+screen.getViewport()+" [pixels]");
final Animator anim = new Animator(window0);
anim.start();
-
+
List<MonitorMode> allMonitorModes = screen.getMonitorModes();
Assert.assertTrue(allMonitorModes.size()>0);
@@ -214,29 +221,33 @@ public class TestScreenMode01cNEWT extends UITestCase {
}
monitor = window0.getMainMonitor();
- System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport());
- System.err.println("Test.1: Window monitor: "+monitor.getViewport());
- Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getSurfaceWidth(), window0.getSurfaceHeight());
+ window0ScreenRect = window0.getSurfaceBounds();
+ System.err.println("Test.1: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]");
+ System.err.println("Test.1: Window screenRect: "+window0ScreenRect+" [pixels]");
+ System.err.println("Test.1: Screen viewport : "+screen.getViewport()+" [pixels]");
+ System.err.println("Test.1: Window monitor : "+monitor.getViewport()+" [pixels]");
if( !spanAcrossMonitors ) {
- Assert.assertEquals(monitor.getViewport(), window0Rect);
+ Assert.assertEquals(monitor.getViewport(), window0ScreenRect);
} else {
List<MonitorDevice> monitorsUsed = monitors;
if( null == monitorsUsed ) {
monitorsUsed = window0.getScreen().getMonitorDevices();
}
Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed);
- Assert.assertEquals(monitorsUsedViewport, window0Rect);
+ Assert.assertEquals(monitorsUsedViewport, window0ScreenRect);
}
-
+
Thread.sleep(duration);
window0.setFullscreen(false);
-
- window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getSurfaceWidth(), window0.getSurfaceHeight());
+
+ window0ScreenRect = window0.getSurfaceBounds();
monitor = window0.getMainMonitor();
- System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getSurfaceWidth()+"x"+window0.getSurfaceHeight()+" within "+screen.getViewport());
- System.err.println("Test.2: Window monitor: "+monitor.getViewport());
-
+ System.err.println("Test.2: Window bounds : "+window0.getX()+"/"+window0.getY()+" "+window0.getWindowWidth()+"x"+window0.getWindowHeight()+" [wu] within "+screen.getViewportInWindowUnits(window0)+" [wu]");
+ System.err.println("Test.2: Window screenRect: "+window0ScreenRect+" [pixels]");
+ System.err.println("Test.2: Screen viewport : "+screen.getViewport()+" [pixels]");
+ System.err.println("Test.2: Window monitor : "+monitor.getViewport()+" [pixels]");
+
Thread.sleep(duration);
anim.stop();
destroyWindow(window0);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
index 4b16a006f..d9ea39365 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
@@ -66,13 +66,13 @@ import javax.media.nativewindow.util.RectangleImmutable;
* i.e. the original MonitorMode should get reinstated!
* </p>
* <p>
- * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.</p>
+ * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.</p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestScreenMode01dNEWT extends UITestCase {
static GLProfile glp;
static int width, height;
-
+
static int waitTimeShort = 2000; // 2 sec
static int waitTimeLong = 8000; // 8 sec
@@ -88,13 +88,13 @@ public class TestScreenMode01dNEWT extends UITestCase {
public static void releaseClass() throws InterruptedException {
Thread.sleep(waitTimeShort);
}
-
+
/**
* Following configurations results in a SIGSEGV:
* <pre>
* Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
* </pre>
- *
+ *
* Situation:
* <pre>
* 1 - Create Screen, GLWindow (w/ context)
@@ -102,19 +102,19 @@ public class TestScreenMode01dNEWT extends UITestCase {
* 3 - Destroy GLWindow (w/ context), Screen
* 4 - Create Screen, GLWindow (w/ context) (*)
* </pre>
- *
+ *
* Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call
* on the the created GL context.
- *
+ *
* Remedy:
* <pre>
* A) Releasing all resources before step 4 .. works.
* B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
* </pre>
- *
+ *
* Hence there must be some correlations with the screen randr mode
* and some of the glcontext/gldrawables.
- *
+ *
* <pre>
* Remedy A) is demonstrated here
* Remedy B) is shown in {@link TestScreenMode01bNEWT}
@@ -127,7 +127,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
GLProfile.initSingleton();
System.err.println("*** cleanupGL.DONE");
}
-
+
static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) {
Assert.assertNotNull(caps);
caps.setOnscreen(onscreen);
@@ -143,10 +143,10 @@ public class TestScreenMode01dNEWT extends UITestCase {
static void destroyWindow(Window window) throws InterruptedException {
if(null!=window) {
window.destroy();
- Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
}
}
-
+
@Test
public void test01FullscreenChange01() throws InterruptedException {
Thread.sleep(waitTimeShort);
@@ -160,40 +160,40 @@ public class TestScreenMode01dNEWT extends UITestCase {
GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
Animator animator = new Animator(window);
animator.start();
-
+
final MonitorDevice monitor = window.getMainMonitor();
-
+
Assert.assertEquals(false, window.isFullscreen());
Assert.assertEquals(width, window.getSurfaceWidth());
Assert.assertEquals(height, window.getSurfaceHeight());
-
+
window.setFullscreen(true);
- Assert.assertEquals(true, window.isFullscreen());
+ Assert.assertEquals(true, window.isFullscreen());
Assert.assertEquals(monitor.getViewport().getWidth(), window.getSurfaceWidth());
Assert.assertEquals(monitor.getViewport().getHeight(), window.getSurfaceHeight());
-
+
Thread.sleep(waitTimeShort);
window.setFullscreen(false);
Assert.assertEquals(false, window.isFullscreen());
Assert.assertEquals(width, window.getSurfaceWidth());
Assert.assertEquals(height, window.getSurfaceHeight());
-
+
Thread.sleep(waitTimeShort);
animator.stop();
Assert.assertEquals(false, animator.isAnimating());
Assert.assertEquals(false, animator.isStarted());
-
+
destroyWindow(window);
-
+
Assert.assertEquals(false,window.isVisible());
Assert.assertEquals(false,window.isRealized());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
-
+
cleanupGL();
}
@@ -210,9 +210,9 @@ public class TestScreenMode01dNEWT extends UITestCase {
GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */);
Assert.assertNotNull(window);
- final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getSurfaceWidth(), window.getSurfaceHeight());
- final MonitorDevice monitor = screen.getMainMonitor(winRect);
-
+ final RectangleImmutable screenRect = window.getSurfaceBounds();
+ final MonitorDevice monitor = screen.getMainMonitor( screenRect );
+
List<MonitorMode> monitorModes = monitor.getSupportedModes();
Assert.assertTrue(monitorModes.size()>0);
if(monitorModes.size()==1) {
@@ -245,14 +245,14 @@ public class TestScreenMode01dNEWT extends UITestCase {
monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
Assert.assertNotNull(monitorModes);
Assert.assertTrue(monitorModes.size()>0);
-
+
monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
Assert.assertNotNull(monitorModes);
Assert.assertTrue(monitorModes.size()>0);
// set mode
{
- MonitorMode sm = (MonitorMode) monitorModes.get(0);
+ MonitorMode sm = monitorModes.get(0);
System.err.println("[0] set current: "+sm);
final boolean smOk = monitor.setCurrentMode(sm);
mmCurrent = monitor.getCurrentMode();
@@ -263,7 +263,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
Assert.assertEquals(mmCurrent, monitor.queryCurrentMode());
Assert.assertTrue(smOk);
}
-
+
Thread.sleep(waitTimeLong);
Assert.assertEquals(true,display.isNativeValid());
@@ -271,10 +271,10 @@ public class TestScreenMode01dNEWT extends UITestCase {
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- animator.stop();
+ animator.stop();
Assert.assertEquals(false, animator.isAnimating());
Assert.assertEquals(false, animator.isStarted());
-
+
destroyWindow(window);
Assert.assertEquals(false,window.isVisible());
@@ -284,7 +284,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
- validateScreenModeReset(mmOrig, winRect);
+ validateScreenModeReset(mmOrig, screenRect);
cleanupGL();
}
@@ -308,8 +308,8 @@ public class TestScreenMode01dNEWT extends UITestCase {
Animator animator = new Animator(window);
animator.start();
- final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getSurfaceWidth(), window.getSurfaceHeight());
- final MonitorDevice monitor = screen.getMainMonitor(winRect);
+ final RectangleImmutable screenRect = window.getSurfaceBounds();
+ final MonitorDevice monitor = screen.getMainMonitor(screenRect);
MonitorMode mmCurrent = monitor.queryCurrentMode();
Assert.assertNotNull(mmCurrent);
MonitorMode mmOrig = monitor.getOriginalMode();
@@ -317,7 +317,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
System.err.println("[0] orig : "+mmOrig);
System.err.println("[0] current: "+mmCurrent);
Assert.assertEquals(mmCurrent, mmOrig);
-
+
List<MonitorMode> monitorModes = monitor.getSupportedModes();
if(monitorModes.size()==1) {
// no support ..
@@ -331,9 +331,9 @@ public class TestScreenMode01dNEWT extends UITestCase {
monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate());
monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
- MonitorMode monitorMode = (MonitorMode) monitorModes.get(0);
+ MonitorMode monitorMode = monitorModes.get(0);
Assert.assertNotNull(monitorMode);
-
+
if(preFS) {
System.err.println("[0] set FS pre 0: "+window.isFullscreen());
window.setFullscreen(true);
@@ -342,7 +342,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
System.err.println("[0] set FS pre X: "+window.isFullscreen());
}
Thread.sleep(waitTimeShort);
-
+
// set mode
{
System.err.println("[0] set current: "+monitorMode);
@@ -355,7 +355,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
Assert.assertEquals(mmCurrent, monitor.queryCurrentMode());
Assert.assertTrue(smOk);
}
-
+
if(!preFS) {
System.err.println("[0] set FS post 0: "+window.isFullscreen());
window.setFullscreen(true);
@@ -364,7 +364,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
}
Thread.sleep(waitTimeLong);
-
+
if(!preFS) {
System.err.println("[0] set !FS post 0: "+window.isFullscreen());
window.setFullscreen(false);
@@ -372,7 +372,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
System.err.println("[0] set !FS post X: "+window.isFullscreen());
Thread.sleep(waitTimeShort);
}
-
+
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(true,window.isNativeValid());
@@ -381,7 +381,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
animator.stop();
Assert.assertEquals(false, animator.isAnimating());
Assert.assertEquals(false, animator.isStarted());
-
+
destroyWindow(window);
Assert.assertEquals(false,window.isVisible());
@@ -391,7 +391,7 @@ public class TestScreenMode01dNEWT extends UITestCase {
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
- validateScreenModeReset(mmOrig, winRect);
+ validateScreenModeReset(mmOrig, screenRect);
cleanupGL();
}
@@ -405,15 +405,15 @@ public class TestScreenMode01dNEWT extends UITestCase {
screen.addReference();
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
-
+
final MonitorDevice monitor = screen.getMainMonitor(rect);
Assert.assertEquals(mmOrig, monitor.getCurrentMode());
-
+
screen.removeReference();
Assert.assertEquals(false,display.isNativeValid());
Assert.assertEquals(false,screen.isNativeValid());
}
-
+
public static void main(String args[]) throws IOException {
String tstname = TestScreenMode01dNEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);