From 701cc44d7b2c9f0b7fd977ca29951c2fb779ce2f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Nov 2010 07:32:35 +0100 Subject: NEWT: ScreenModeUtil fix, misc changes ScreenModeUtil fix: - return 'null' for an empty list, check if list is null or empty. - remove 'validate' Window: TIMEOUT_NATIVEWINDOW 500 -> 1000 ms --- src/newt/classes/com/jogamp/newt/Window.java | 4 +- .../classes/com/jogamp/newt/impl/ScreenImpl.java | 2 - .../com/jogamp/newt/util/ScreenModeUtil.java | 75 +++++++--------------- 3 files changed, 26 insertions(+), 55 deletions(-) (limited to 'src/newt') diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 1be5949fe..ba7d51e67 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -49,8 +49,8 @@ public interface Window extends NativeWindow, ScreenModeListener { public static final boolean DEBUG_WINDOW_EVENT = Debug.debug("Window.WindowEvent"); public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window"); - /** A 500ms timeout while waiting for a native action response, ie {@link #setVisible(boolean)}. */ - public static final long TIMEOUT_NATIVEWINDOW = 500; + /** A 1s timeout while waiting for a native action response, ie {@link #setVisible(boolean)}. */ + public static final long TIMEOUT_NATIVEWINDOW = 1000; // // Lifecycle diff --git a/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java b/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java index 474eac31d..ebb496988 100644 --- a/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java @@ -466,8 +466,6 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { num++; } while ( null != smProps && 0 < smProps.length ); - ScreenModeUtil.validate(screenModePool, true); - if(DEBUG) { System.err.println("ScreenImpl.collectNativeScreenModes: ScreenMode number : "+screenModePool.size()); System.err.println("ScreenImpl.collectNativeScreenModes: MonitorMode number : "+monitorModePool.size()); diff --git a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java index 9cb04c2a1..3e0e3dac5 100644 --- a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java @@ -79,60 +79,15 @@ public class ScreenModeUtil { return -1; } - /** - * Validate the given list of {@link com.jogamp.newt.ScreenMode}s, testing on:
- * - * This - * @param screenModes list of {@link com.jogamp.newt.ScreenMode}s - * @param throwException if true and invalid throw IllegalArgumentException - * @return true if valid, otherwise false or throw IllegalArgumentException - * @throws IllegalArgumentException if invalid - */ - public static boolean validate(List/**/ screenModes, boolean throwException) { - for (int j=0; null!=screenModes && j0) { - if(throwException) { - throw new IllegalArgumentException("Element "+sm+" at index "+j+" is not unique (equality), duplicates: "+dups); - } else { - return false; - } - } */ - - for (int i=0; null!=screenModes && i0) { - if(throwException) { - throw new IllegalArgumentException("Element "+sm+" at index "+j+" is not unique (hash), duplicates: "+dups); - } else { - return false; - } - } - } - return true; - } - /** * @param screenModes * @param resolution * @return modes with nearest resolution, or matching ones */ public static List/**/ filterByResolution(List/**/ screenModes, DimensionReadOnly resolution) { + if(null==screenModes || screenModes.size()==0) { + return null; + } List out = new ArrayList(); int resolution_sq = resolution.getHeight()*resolution.getWidth(); int sm_dsq=resolution_sq, sm_dsq_idx=0; @@ -158,6 +113,9 @@ public class ScreenModeUtil { } public static List/**/ filterBySurfaceSize(List/**/ screenModes, SurfaceSize surfaceSize) { + if(null==screenModes || screenModes.size()==0) { + return null; + } List out = new ArrayList(); for (int i=0; null!=screenModes && i0 ? out : null; } public static List/**/ filterByRotation(List/**/ screenModes, int rotation) { + if(null==screenModes || screenModes.size()==0) { + return null; + } List out = new ArrayList(); for (int i=0; null!=screenModes && i0 ? out : null; } public static List/**/ filterByBpp(List/**/ screenModes, int bitsPerPixel) { + if(null==screenModes || screenModes.size()==0) { + return null; + } List out = new ArrayList(); for (int i=0; null!=screenModes && i0 ? out : null; } /** @@ -197,6 +161,9 @@ public class ScreenModeUtil { * @return modes with nearest refreshRate, or matching ones */ public static List/**/ filterByRate(List/**/ screenModes, int refreshRate) { + if(null==screenModes || screenModes.size()==0) { + return null; + } int sm_dr = refreshRate; int sm_dr_idx = -1; List out = new ArrayList(); @@ -219,6 +186,9 @@ public class ScreenModeUtil { } public static List/**/ getHighestAvailableBpp(List/**/ screenModes) { + if(null==screenModes || screenModes.size()==0) { + return null; + } int highest = -1; for (int i=0; null!=screenModes && i < screenModes.size(); i++) { ScreenMode sm = (ScreenMode)screenModes.get(i); @@ -231,6 +201,9 @@ public class ScreenModeUtil { } public static List/**/ getHighestAvailableRate(List/**/ screenModes) { + if(null==screenModes || screenModes.size()==0) { + return null; + } int highest = -1; for (int i=0; null!=screenModes && i < screenModes.size(); i++) { ScreenMode sm = (ScreenMode)screenModes.get(i); -- cgit v1.2.3