* If no coverage is detected the first {@link MonitorDevice} is returned.
*
- * @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 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.
*
* 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;
/**
@@ -232,6 +233,18 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
// Modes / States
//
+ /**
+ * 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.
*
@@ -329,19 +342,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
/**
* Converts the given pixel units into window units in place.
- * @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 in place.
- * @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 filterByResolution(List 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
@@ -1896,6 +1896,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return winHeight;
}
+ @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();
@@ -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() 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()=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=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() 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 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 monitors = new ArrayList();
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 monitors) throws InterruptedException {
+
+ void testScreenFullscreenImpl(final Screen screen, final int screenXPos, final int screenYPos,
+ final boolean spanAcrossMonitors, final List 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 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 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!
*
*
- * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.
+ * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.
*/
@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:
*
* Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
*
- *
+ *
* Situation:
*
* 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) (*)
*
- *
+ *
* Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call
* on the the created GL context.
- *
+ *
* Remedy:
*
* A) Releasing all resources before step 4 .. works.
* B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
*
- *
+ *
* Hence there must be some correlations with the screen randr mode
* and some of the glcontext/gldrawables.
- *
+ *
*
* 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 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 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);
--
cgit v1.2.3