diff options
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Display.java | 12 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/NewtFactory.java | 15 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Screen.java | 10 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 12 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java | 83 |
5 files changed, 56 insertions, 76 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index f879449b9..6a0ebe14a 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -146,15 +146,15 @@ public abstract class Display { public abstract void dispatchMessages(); // Global Displays - protected static ArrayList displayList = new ArrayList(); + protected static ArrayList<Display> displayList = new ArrayList<Display>(); protected static int displaysActive = 0; public static void dumpDisplayList(String prefix) { synchronized(displayList) { - Iterator i = displayList.iterator(); + Iterator<Display> i = displayList.iterator(); System.err.println(prefix+" DisplayList[] entries: "+displayList.size()+" - "+getThreadName()); for(int j=0; i.hasNext(); j++) { - DisplayImpl d = (DisplayImpl) i.next(); + Display d = i.next(); System.err.println(" ["+j+"] : "+d); } } @@ -198,10 +198,10 @@ public abstract class Display { } /** Returns the global display collection */ - public static Collection getAllDisplays() { - ArrayList list; + public static Collection<Display> getAllDisplays() { + ArrayList<Display> list; synchronized(displayList) { - list = (ArrayList) displayList.clone(); + list = (ArrayList<Display>) displayList.clone(); } return list; } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index cd44df154..62da8c978 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -52,8 +52,8 @@ public class NewtFactory { WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); } - public static Class getCustomClass(String packageName, String classBaseName) { - Class clazz = null; + public static Class<?> getCustomClass(String packageName, String classBaseName) { + Class<?> clazz = null; if(packageName!=null || classBaseName!=null) { String clazzName = packageName + "." + classBaseName ; try { @@ -218,17 +218,6 @@ public class NewtFactory { return DisplayImpl.create(type, null, handle, false); } - private static boolean instanceOf(Object obj, String clazzName) { - Class clazz = obj.getClass(); - do { - if(clazz.getName().equals(clazzName)) { - return true; - } - clazz = clazz.getSuperclass(); - } while (clazz!=null); - return false; - } - public static boolean isScreenCompatible(NativeWindow parent, Screen childScreen) { // Get parent's NativeWindow details AbstractGraphicsConfiguration parentConfig = (AbstractGraphicsConfiguration) parent.getGraphicsConfiguration(); diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index fec3613a2..c6943ff22 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -155,7 +155,7 @@ public abstract class Screen { * @return a shallow copy of the internal immutable {@link com.jogamp.newt.ScreenMode}s, * or null if not implemented for this native type {@link com.jogamp.newt.Display#getType()}. */ - public abstract List/*<ScreenMode>*/ getScreenModes(); + public abstract List<ScreenMode> getScreenModes(); /** * Return the original {@link com.jogamp.newt.ScreenMode}, as used at NEWT initialization. @@ -180,7 +180,7 @@ public abstract class Screen { public abstract boolean setCurrentScreenMode(ScreenMode screenMode); // Global Screens - protected static ArrayList screenList = new ArrayList(); + protected static ArrayList<Screen> screenList = new ArrayList<Screen>(); protected static int screensActive = 0; /** @@ -220,10 +220,10 @@ public abstract class Screen { return null; } /** Returns the global display collection */ - public static Collection getAllScreens() { - ArrayList list; + public static Collection<Screen> getAllScreens() { + ArrayList<Screen> list; synchronized(screenList) { - list = (ArrayList) screenList.clone(); + list = (ArrayList<Screen>) screenList.clone(); } return list; } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 1cc2298ed..f477cd3fc 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -39,7 +39,6 @@ import java.util.List; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; -import com.jogamp.nativewindow.NativeWindowVersion; import com.jogamp.newt.*; import com.jogamp.newt.event.*; import jogamp.newt.WindowImpl; @@ -635,13 +634,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return fpsCounter.getTotalFPS(); } - private class SwapBuffersAction implements Runnable { - public final void run() { - drawable.swapBuffers(); - } - } - private SwapBuffersAction swapBuffersAction = new SwapBuffersAction(); - //---------------------------------------------------------------------- // GLDrawable methods // @@ -872,13 +864,11 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC public static void main(String args[]) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); - // System.err.println(NativeWindowVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(NewtVersion.getInstance()); final GLProfile glp = GLProfile.getDefault(); final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - final List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null); + final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null); for(int i=0; i<availCaps.size(); i++) { System.err.println(availCaps.get(i)); } diff --git a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java index 6986e3657..93797c5fb 100644 --- a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java @@ -66,13 +66,13 @@ public class ScreenModeUtil { */ public static final int NUM_SCREEN_MODE_PROPERTIES_ALL = 8; - public static int getIndex(List/*<ScreenMode>*/ screenModes, ScreenMode search) { + public static int getIndex(List<ScreenMode> screenModes, ScreenMode search) { return screenModes.indexOf(search); } - public static int getIndexByHashCode(List/*<ScreenMode>*/ screenModes, ScreenMode search) { + public static int getIndexByHashCode(List<ScreenMode> screenModes, ScreenMode search) { for (int i=0; null!=screenModes && i<screenModes.size(); i++) { - if ( search.hashCode() == ((ScreenMode)screenModes.get(i)).hashCode() ) { + if ( search.hashCode() == screenModes.get(i).hashCode() ) { return i; } } @@ -84,16 +84,16 @@ public class ScreenModeUtil { * @param resolution * @return modes with nearest resolution, or matching ones */ - public static List/*<ScreenMode>*/ filterByResolution(List/*<ScreenMode>*/ screenModes, DimensionImmutable resolution) { + public static List<ScreenMode> filterByResolution(List<ScreenMode> screenModes, DimensionImmutable resolution) { if(null==screenModes || screenModes.size()==0) { return null; } - List out = new ArrayList(); + List<ScreenMode> out = new ArrayList<ScreenMode>(); int resolution_sq = resolution.getHeight()*resolution.getWidth(); int sm_dsq=resolution_sq, sm_dsq_idx=0; for (int i=0; null!=screenModes && i<screenModes.size(); i++) { - ScreenMode sm = (ScreenMode)screenModes.get(i); + ScreenMode sm = screenModes.get(i); DimensionImmutable res = sm.getMonitorMode().getSurfaceSize().getResolution(); int dsq = Math.abs(resolution_sq - res.getHeight()*res.getWidth()); if(dsq<sm_dsq) { @@ -108,17 +108,17 @@ public class ScreenModeUtil { return out; } // nearest .. - resolution = ((ScreenMode)screenModes.get(sm_dsq_idx)).getMonitorMode().getSurfaceSize().getResolution(); + resolution = screenModes.get(sm_dsq_idx).getMonitorMode().getSurfaceSize().getResolution(); return filterByResolution(screenModes, resolution); } - public static List/*<ScreenMode>*/ filterBySurfaceSize(List/*<ScreenMode>*/ screenModes, SurfaceSize surfaceSize) { + public static List<ScreenMode> filterBySurfaceSize(List<ScreenMode> screenModes, SurfaceSize surfaceSize) { if(null==screenModes || screenModes.size()==0) { return null; } - List out = new ArrayList(); + List<ScreenMode> out = new ArrayList<ScreenMode>(); for (int i=0; null!=screenModes && i<screenModes.size(); i++) { - ScreenMode sm = (ScreenMode)screenModes.get(i); + ScreenMode sm = screenModes.get(i); if(sm.getMonitorMode().getSurfaceSize().equals(surfaceSize)) { out.add(sm); } @@ -126,13 +126,13 @@ public class ScreenModeUtil { return out.size()>0 ? out : null; } - public static List/*<ScreenMode>*/ filterByRotation(List/*<ScreenMode>*/ screenModes, int rotation) { + public static List<ScreenMode> filterByRotation(List<ScreenMode> screenModes, int rotation) { if(null==screenModes || screenModes.size()==0) { return null; } - List out = new ArrayList(); + List<ScreenMode> out = new ArrayList<ScreenMode>(); for (int i=0; null!=screenModes && i<screenModes.size(); i++) { - ScreenMode sm = (ScreenMode)screenModes.get(i); + ScreenMode sm = screenModes.get(i); if(sm.getRotation() == rotation) { out.add(sm); } @@ -140,13 +140,13 @@ public class ScreenModeUtil { return out.size()>0 ? out : null; } - public static List/*<ScreenMode>*/ filterByBpp(List/*<ScreenMode>*/ screenModes, int bitsPerPixel) { + public static List<ScreenMode> filterByBpp(List<ScreenMode> screenModes, int bitsPerPixel) { if(null==screenModes || screenModes.size()==0) { return null; } - List out = new ArrayList(); + List<ScreenMode> out = new ArrayList<ScreenMode>(); for (int i=0; null!=screenModes && i<screenModes.size(); i++) { - ScreenMode sm = (ScreenMode)screenModes.get(i); + ScreenMode sm = screenModes.get(i); if(sm.getMonitorMode().getSurfaceSize().getBitsPerPixel() == bitsPerPixel) { out.add(sm); } @@ -160,15 +160,15 @@ public class ScreenModeUtil { * @param refreshRate * @return modes with nearest refreshRate, or matching ones */ - public static List/*<ScreenMode>*/ filterByRate(List/*<ScreenMode>*/ screenModes, int refreshRate) { + public static List<ScreenMode> filterByRate(List<ScreenMode> screenModes, int refreshRate) { if(null==screenModes || screenModes.size()==0) { return null; } int sm_dr = refreshRate; int sm_dr_idx = -1; - List out = new ArrayList(); + List<ScreenMode> out = new ArrayList<ScreenMode>(); for (int i=0; null!=screenModes && i<screenModes.size(); i++) { - ScreenMode sm = (ScreenMode)screenModes.get(i); + ScreenMode sm = screenModes.get(i); int dr = Math.abs(refreshRate - sm.getMonitorMode().getRefreshRate()); if(dr<sm_dr) { sm_dr = dr; @@ -181,17 +181,17 @@ public class ScreenModeUtil { if(out.size()>0) { return out; } - refreshRate = ((ScreenMode)screenModes.get(sm_dr_idx)).getMonitorMode().getRefreshRate(); + refreshRate = screenModes.get(sm_dr_idx).getMonitorMode().getRefreshRate(); return filterByRate(screenModes, refreshRate); } - public static List/*<ScreenMode>*/ getHighestAvailableBpp(List/*<ScreenMode>*/ screenModes) { + public static List<ScreenMode> getHighestAvailableBpp(List<ScreenMode> 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); + ScreenMode sm = screenModes.get(i); int bpp = sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(); if (bpp > highest) { highest = bpp; @@ -200,13 +200,13 @@ public class ScreenModeUtil { return filterByBpp(screenModes, highest); } - public static List/*<ScreenMode>*/ getHighestAvailableRate(List/*<ScreenMode>*/ screenModes) { + public static List<ScreenMode> getHighestAvailableRate(List<ScreenMode> 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); + ScreenMode sm = screenModes.get(i); int rate = sm.getMonitorMode().getRefreshRate(); if (rate > highest) { highest = rate; @@ -254,7 +254,7 @@ public class ScreenModeUtil { /** * WARNING: must be synchronized with ScreenMode.h, native implementation * - * @param resolutionPool hash array of unique DimensionReadOnly resolutions, no duplicates + * @param resolutionPool hash array of unique resolutions, no duplicates * @param surfaceSizePool hash array of unique SurfaceSize, no duplicates * @param monitorModePool hash array of unique MonitorMode, no duplicates * @param screenModePool hash array of unique ScreenMode, no duplicates @@ -263,23 +263,24 @@ public class ScreenModeUtil { * @return index of the identical (old or new) ScreenMode element in <code>screenModePool</code>, * matching the input <code>modeProperties</code>, or -1 if input could not be processed. */ - public static int streamIn(ArrayHashSet resolutionPool, - ArrayHashSet surfaceSizePool, - ArrayHashSet screenSizeMMPool, - ArrayHashSet monitorModePool, - ArrayHashSet screenModePool, + public static int streamIn(ArrayHashSet<DimensionImmutable> resolutionPool, + ArrayHashSet<SurfaceSize> surfaceSizePool, + ArrayHashSet<DimensionImmutable> screenSizeMMPool, + ArrayHashSet<MonitorMode> monitorModePool, + ArrayHashSet<ScreenMode> screenModePool, int[] modeProperties, int offset) { ScreenMode screenMode = streamInImpl(resolutionPool, surfaceSizePool, screenSizeMMPool, monitorModePool, screenModePool, modeProperties, offset); return screenModePool.indexOf(screenMode); } - private static ScreenMode streamInImpl(ArrayHashSet resolutionPool, - ArrayHashSet surfaceSizePool, - ArrayHashSet screenSizeMMPool, - ArrayHashSet monitorModePool, - ArrayHashSet screenModePool, - int[] modeProperties, int offset) { + + private static ScreenMode streamInImpl(ArrayHashSet<DimensionImmutable> resolutionPool, + ArrayHashSet<SurfaceSize> surfaceSizePool, + ArrayHashSet<DimensionImmutable> screenSizeMMPool, + ArrayHashSet<MonitorMode> monitorModePool, + ArrayHashSet<ScreenMode> screenModePool, + int[] modeProperties, int offset) { int count = modeProperties[offset]; if(NUM_SCREEN_MODE_PROPERTIES_ALL != count) { throw new RuntimeException("NUM_SCREEN_MODE_PROPERTIES should be "+NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+count+", len "+(modeProperties.length-offset)); @@ -291,30 +292,30 @@ public class ScreenModeUtil { DimensionImmutable resolution = ScreenModeUtil.streamInResolution(modeProperties, offset); offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; if(null!=resolutionPool) { - resolution = (DimensionImmutable) resolutionPool.getOrAdd(resolution); + resolution = resolutionPool.getOrAdd(resolution); } SurfaceSize surfaceSize = ScreenModeUtil.streamInSurfaceSize(resolution, modeProperties, offset); offset += ScreenModeUtil.NUM_SURFACE_SIZE_PROPERTIES; if(null!=surfaceSizePool) { - surfaceSize = (SurfaceSize) surfaceSizePool.getOrAdd(surfaceSize); + surfaceSize = surfaceSizePool.getOrAdd(surfaceSize); } DimensionImmutable screenSizeMM = ScreenModeUtil.streamInResolution(modeProperties, offset); offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; if(null!=screenSizeMMPool) { - screenSizeMM = (DimensionImmutable) screenSizeMMPool.getOrAdd(screenSizeMM); + screenSizeMM = screenSizeMMPool.getOrAdd(screenSizeMM); } MonitorMode monitorMode = ScreenModeUtil.streamInMonitorMode(surfaceSize, screenSizeMM, modeProperties, offset); offset += ScreenModeUtil.NUM_MONITOR_MODE_PROPERTIES - ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; if(null!=monitorModePool) { - monitorMode = (MonitorMode) monitorModePool.getOrAdd(monitorMode); + monitorMode = monitorModePool.getOrAdd(monitorMode); } ScreenMode screenMode = ScreenModeUtil.streamInScreenMode(monitorMode, modeProperties, offset); if(null!=screenModePool) { - screenMode = (ScreenMode) screenModePool.getOrAdd(screenMode); + screenMode = screenModePool.getOrAdd(screenMode); } return screenMode; } |