aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax/media
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-09 03:58:37 +0200
committerSven Gothel <[email protected]>2014-06-09 03:58:37 +0200
commit4686a652d821efe04045333026be79270bc19bfd (patch)
tree240ac4df0ae58c7461e7bfdfb3b438917041a3af /src/nativewindow/classes/javax/media
parent14ff638b63fc7adaa59f351891f6a38806d7fa5d (diff)
Bug 741 HiDPI: Add ScalableSurface.getNativeSurfaceScale(..) to compute surface DPI ; Add NEWT Window.getPixelsPerMM(..) to query surface DPI
With HiDPI and surface scale, we need knowledge of the native surface's pixel-scale matching the monitor's pixel-per-millimeter value. Preserving the queried native pixel-scale and exposing it via ScalableSurface.getNativeSurfaceScale(..) to compute surface DPI. Add NEWT Window.getPixelsPerMM(..) to query surface DPI. Surface DPI is demonstrated in GraphUI's GPUUISceneGLListener0A .. and TestRulerNEWT01, etc ..
Diffstat (limited to 'src/nativewindow/classes/javax/media')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java21
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java6
2 files changed, 24 insertions, 3 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
index de6ba51d7..ffd5c224c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
@@ -65,7 +65,7 @@ public interface ScalableSurface {
* Returns the requested pixel scale of the associated {@link NativeSurface}.
*
* @param result int[2] storage for the result
- * @return the passed storage containing the requested pixelSize for chaining
+ * @return the passed storage containing the requested pixelScale for chaining
*/
int[] getRequestedSurfaceScale(final int[] result);
@@ -73,8 +73,25 @@ public interface ScalableSurface {
* Returns the current pixel scale of the associated {@link NativeSurface}.
*
* @param result int[2] storage for the result
- * @return the passed storage containing the current pixelSize for chaining
+ * @return the passed storage containing the current pixelScale for chaining
*/
public int[] getCurrentSurfaceScale(final int[] result);
+
+ /**
+ * Returns the native pixel scale of the associated {@link NativeSurface}
+ * reflecting it's currently bound <i>monitor surface resolution in pixels</i>.
+ * <p>
+ * The native pixel scale maybe used to determine the proper <i>dpi</i>
+ * value of this {@link NativeSurface}:
+ * <pre>
+ * surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale,
+ * with PpMM == pixel per millimeter
+ * </pre>
+ * </p>
+ *
+ * @param result int[2] storage for the result
+ * @return the passed storage containing the native pixelScale for chaining
+ */
+ public int[] getNativeSurfaceScale(final int[] result);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
index 24ccc836a..5c9dc279d 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
@@ -37,7 +37,11 @@ public class Dimension implements Cloneable, DimensionImmutable {
this(0, 0);
}
- public Dimension(int width, int height) {
+ public Dimension(final int[] size) {
+ this(size[0], size[1]);
+ }
+
+ public Dimension(final int width, final int height) {
if(width<0 || height<0) {
throw new IllegalArgumentException("width and height must be within: ["+0+".."+Integer.MAX_VALUE+"]");
}