diff options
author | Sven Gothel <[email protected]> | 2013-05-09 02:57:09 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-05-09 02:57:09 +0200 |
commit | 5e0a5049d873b5896553ee530562c28ffd3fbe0c (patch) | |
tree | a621468d7316c239e3187e22c988e99a6d83bfc2 | |
parent | ed732cddbcb979062c56e9c93534a232aaa7fa20 (diff) |
Fix NEWT MultiMonitor Regression: Use case w/o attached monitor, and NPE (Cache) in ScreenImpl.getVirtualMonitorDevice(..).
W/ RandR13, we can have a case of an Output/CRT w/o valid modes,
indicating a switched off or detached monitor.
ScreenImpl.getVirtualMonitorDevice(..) requires a Cache .. due to MonitorModeProps.streamInMonitorDevice(..)
-rwxr-xr-x | make/scripts/tests.sh | 6 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/ScreenImpl.java | 29 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java | 4 |
3 files changed, 27 insertions, 12 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index da4698a8e..73fa54f38 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Screen" + D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -516,7 +516,7 @@ function testawtswt() { # # Texture / TextureUtils # -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index d7bd326fe..7edf7b63a 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -446,7 +446,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { refMonitorModeListener.remove(sml); } - private final MonitorMode getVirtualMonitorMode(int modeId) { + /** + * + * @param cache optional .. + * @param modeId + * @return + */ + private final MonitorMode getVirtualMonitorMode(MonitorModeProps.Cache cache, int modeId) { final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -460,10 +466,17 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorMode(null, null, props, 0); + return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); } - - private final MonitorDevice getVirtualMonitorDevice(int monitorId, MonitorMode currentMode) { + + /** + * + * @param cache mandatory ! + * @param monitorId + * @param currentMode + * @return + */ + private final MonitorDevice getVirtualMonitorDevice(MonitorModeProps.Cache cache, int monitorId, MonitorMode currentMode) { int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES]; int i = 0; props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES; @@ -480,7 +493,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorDevice(null, null, this, props, 0); + return MonitorModeProps.streamInMonitorDevice(null, cache, this, props, 0); } /** @@ -498,7 +511,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( 0>=getWidth() || 0>=getHeight() ) { updateVirtualScreenOriginAndSize(); } - res = getVirtualMonitorMode(monitor.getCurrentMode().getId()); + res = getVirtualMonitorMode(null, monitor.getCurrentMode().getId()); } return res; } @@ -522,9 +535,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( 0 >= collectNativeMonitorModes(cache) ) { updateVirtualScreenOriginAndSize(); vScrnSizeUpdated = true; - final MonitorMode mode = getVirtualMonitorMode(0); + final MonitorMode mode = getVirtualMonitorMode(cache, 0); cache.monitorModes.getOrAdd(mode); - final MonitorDevice monitor = getVirtualMonitorDevice(0, mode); + final MonitorDevice monitor = getVirtualMonitorDevice(cache, 0, mode); cache.monitorDevices.getOrAdd(monitor); } if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index f2836f190..b8b13939b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -139,7 +139,9 @@ public class ScreenDriver extends ScreenImpl { if( cache.monitorModes.size() > 0 ) { for(int i = 0; i < crtCount; i++) { final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i); - if( null != monitorProps ) { // enabled + if( null != monitorProps && + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ? + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps.length ) { MonitorModeProps.streamInMonitorDevice(null, cache, this, monitorProps, 0); } } |