aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-01 20:15:47 +0100
committerSven Gothel <[email protected]>2010-11-01 20:15:47 +0100
commiteacbe4788a3fa68e072c23fbef62855fdaa209da (patch)
tree2a1ff4e802e3e1d52887cb2e077599c5f396393d /src/newt/classes/com
parent686ab85440a3f46556c304f2d83c12608a573bd8 (diff)
Fix: Newt Rotation (Windows) - added description (CCW)
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r--src/newt/classes/com/jogamp/newt/ScreenMode.java15
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java27
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/util/MonitorMode.java12
4 files changed, 39 insertions, 21 deletions
diff --git a/src/newt/classes/com/jogamp/newt/ScreenMode.java b/src/newt/classes/com/jogamp/newt/ScreenMode.java
index c89fda597..f87c41240 100644
--- a/src/newt/classes/com/jogamp/newt/ScreenMode.java
+++ b/src/newt/classes/com/jogamp/newt/ScreenMode.java
@@ -32,8 +32,8 @@ import com.jogamp.newt.util.MonitorMode;
/** Immutable ScreenMode Class, consisting of it's read only components:<br>
* <ul>
- * <li>{@link com.jogamp.newt.util.MonitorMode}</li>
- * <li><code>rotation</code></li>
+ * <li>{@link com.jogamp.newt.util.MonitorMode}, non rotated values</li>
+ * <li><code>rotation</code>, measured counter clockwise (CCW)</li>
* </ul>
*
* <i>Aquire and filter ScreenModes</i><br>
@@ -100,9 +100,16 @@ import com.jogamp.newt.util.MonitorMode;
*
*/
public class ScreenMode implements Cloneable {
+ /** zero rotation, compared to normal settings */
public static final int ROTATE_0 = 0;
+
+ /** 90 degrees CCW rotation */
public static final int ROTATE_90 = 90;
+
+ /** 180 degrees CCW rotation */
public static final int ROTATE_180 = 180;
+
+ /** 270 degrees CCW rotation */
public static final int ROTATE_270 = 270;
MonitorMode monitorMode;
@@ -115,7 +122,7 @@ public class ScreenMode implements Cloneable {
/**
* @param monitorMode the monitor mode
- * @param rotation the screen rotation
+ * @param rotation the screen rotation, measured counter clockwise (CCW)
*/
public ScreenMode(MonitorMode monitorMode, int rotation) {
if ( !isRotationValid(rotation) ) {
@@ -133,10 +140,12 @@ public class ScreenMode implements Cloneable {
}
}
+ /** Returns the unrotated <code>MonitorMode</code> */
public final MonitorMode getMonitorMode() {
return monitorMode;
}
+ /** Returns the CCW rotation of this mode */
public final int getRotation() {
return rotation;
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java b/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java
index 8aa6f92a5..9ab9e794a 100644
--- a/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java
@@ -51,6 +51,7 @@ import java.util.ArrayList;
import java.util.List;
public abstract class ScreenImpl extends Screen implements ScreenModeListener {
+ protected static final boolean DisableScreenModeImpl = Debug.debug("Screen.DisableScreenModeImpl");
protected DisplayImpl display;
protected int screen_idx;
protected String fqname;
@@ -243,7 +244,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
public final List/*<ScreenMode>*/ getScreenModes() {
ArrayHashSet screenModes = getScreenModesOrig();
- if(null != screenModes || screenModes.size()>0) {
+ if(null != screenModes && 0 < screenModes.size()) {
return screenModes.toArrayList();
}
return null;
@@ -258,7 +259,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ScreenMode smU = null;
ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
if(null != sms) {
- ScreenMode sm0 = getCurrentScreenModeImpl();
+ ScreenMode sm0 = ( DisableScreenModeImpl ) ? null : getCurrentScreenModeImpl();
if(null == sm0) {
return null;
}
@@ -389,7 +390,6 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
/**
* To be implemented by the native specification.<br>
* Is called within a thread safe environment.<br>
- * Is called only to collect the ScreenModes, usually at startup setting up modes.<br>
*/
protected ScreenMode getCurrentScreenModeImpl() {
return null;
@@ -414,11 +414,14 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ArrayHashSet screenModes = collectNativeScreenModes(screenModesIdx2NativeIdx);
sms = new ScreenModeStatus(screenModes, screenModesIdx2NativeIdx);
if(null!=screenModes && screenModes.size()>0) {
- ScreenMode originalScreenMode = getCurrentScreenModeImpl();
- if(null == originalScreenMode) {
- throw new RuntimeException("Couldn't fetch current ScreenMode (null), but ScreenMode list size is: "+screenModes.size());
+ ScreenMode originalScreenMode = ( DisableScreenModeImpl ) ? null : getCurrentScreenModeImpl();
+ if(null != originalScreenMode) {
+ ScreenMode originalScreenMode0 = (ScreenMode) screenModes.get(originalScreenMode); // unify via value hash
+ if(null == originalScreenMode0) {
+ throw new RuntimeException(originalScreenMode+" could not be hashed from ScreenMode list");
+ }
+ sms.setOriginalScreenMode(originalScreenMode0);
}
- sms.setOriginalScreenMode(originalScreenMode);
}
ScreenModeStatus.mapScreenModeStatus(this.getFQName(), sms);
}
@@ -440,21 +443,23 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
int[] smProps = null;
int num = 0;
do {
- if(0 == num) {
+ if(DisableScreenModeImpl) {
+ smProps = null;
+ } else if(0 == num) {
smProps = getScreenModeFirstImpl();
} else {
smProps = getScreenModeNextImpl();
}
- if(null != smProps) {
+ if(null != smProps && 0 < smProps.length) {
int nativeId = smProps[0];
int screenModeIdx = ScreenModeUtil.streamIn(resolutionPool, surfaceSizePool, screenSizeMMPool,
monitorModePool, screenModePool, smProps, 1);
if(screenModeIdx >= 0) {
screenModesIdx2NativeId.put(screenModeIdx, nativeId);
}
+ num++;
}
- num++;
- } while ( null != smProps );
+ } while ( null != smProps && 0 < smProps.length );
ScreenModeUtil.validate(screenModePool, true);
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
index 23d41c21e..e15a40e7b 100644
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
@@ -65,7 +65,7 @@ public class WindowsScreen extends ScreenImpl {
if (null == modeProps || 0 == modeProps.length) {
return null;
}
- if(modeProps.length != ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL + 1) {
+ if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) {
throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length);
}
return modeProps;
@@ -80,7 +80,7 @@ public class WindowsScreen extends ScreenImpl {
protected int[] getScreenModeNextImpl() {
int[] modeProps = getScreenModeIdx(nativeModeIdx);
- if (null != modeProps && 0 != modeProps.length) {
+ if (null != modeProps && 0 < modeProps.length) {
nativeModeIdx++;
return modeProps;
}
@@ -89,7 +89,7 @@ public class WindowsScreen extends ScreenImpl {
protected ScreenMode getCurrentScreenModeImpl() {
int[] modeProps = getScreenModeIdx(-1);
- if (null != modeProps && 0 != modeProps.length) {
+ if (null != modeProps && 0 < modeProps.length) {
return ScreenModeUtil.streamIn(modeProps, 0);
}
return null;
diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java b/src/newt/classes/com/jogamp/newt/util/MonitorMode.java
index 1f4de082d..7f989e4ab 100644
--- a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java
+++ b/src/newt/classes/com/jogamp/newt/util/MonitorMode.java
@@ -79,8 +79,8 @@ public class MonitorMode implements Cloneable {
/**
* Checks whether two size objects are equal. Two instances
* of <code>MonitorMode</code> are equal if the three components
- * <code>surfaceSize</code>, <code>screenSizeMM</code> and <code>refreshRate</code>
- * are equal.
+ * <code>surfaceSize</code> and <code>refreshRate</code>
+ * are equal. <code>screenSizeMM</code> is kept out intentional to reduce the requirements for finding the current mode.
* @return <code>true</code> if the two dimensions are equal;
* otherwise <code>false</code>.
*/
@@ -88,16 +88,20 @@ public class MonitorMode implements Cloneable {
if (obj instanceof MonitorMode) {
MonitorMode p = (MonitorMode)obj;
return getSurfaceSize().equals(p.getSurfaceSize()) &&
- getScreenSizeMM().equals(p.getScreenSizeMM()) &&
+ /* getScreenSizeMM().equals(p.getScreenSizeMM()) && */
getRefreshRate() == p.getRefreshRate() ;
}
return false;
}
+ /**
+ * returns a hash code over <code>surfaceSize</code> and <code>refreshRate</code>.
+ * <code>screenSizeMM</code> is kept out intentional to reduce the requirements for finding the current mode.
+ */
public final int hashCode() {
// 31 * x == (x << 5) - x
int hash = 31 + getSurfaceSize().hashCode();
- hash = ((hash << 5) - hash) + getScreenSizeMM().hashCode();
+ /* hash = ((hash << 5) - hash) + getScreenSizeMM().hashCode(); */
hash = ((hash << 5) - hash) + getRefreshRate();
return hash;
}