aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-05 04:42:56 +0100
committerSven Gothel <[email protected]>2023-03-05 04:42:56 +0100
commitd87f510194ad2eead2a42b41a3cbe1077f65a695 (patch)
tree80ab2b5bcfd55674e6310ed2ba5b96cf53d71daf /src/newt
parent8d4e039dfd490d3f2290523ea75c9f51460bae41 (diff)
NEWT Screen: Allow injection of global (single) monitor size in [mm] via newt.ws.mmwidth and newt.ws.mmheight property
This is essential on bare-metal devices where the screen DRM/GBM driver does not provide the screen-size (in mm). Otherwise we would have resolution/(size_mm=0) infinity density and none of our graph font demos would work, as we compute pixel-em-size based using dpi and pixel-pt-size.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java33
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java7
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java9
8 files changed, 68 insertions, 26 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 17265a6a7..b41c28e27 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -84,8 +84,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
protected int refCount; // number of Screen references by Window
protected Rectangle virtViewportPU = new Rectangle(0, 0, 0, 0); // virtual rotated viewport in pixel units
protected Rectangle virtViewportWU = new Rectangle(0, 0, 0, 0); // virtual rotated viewport in window units
- protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight
- protected static volatile boolean usrSizeQueried = false;
+ protected static Dimension usrScreenPixelSize = null; // property values: newt.ws.swidth and newt.ws.sheight
+ protected static Dimension usrMonitorMMSize = null; // property values: newt.ws.mmwidth and newt.ws.mmheight
+ protected static volatile boolean usrValuesQueried = false;
private final ArrayList<MonitorModeListener> refMonitorModeListener = new ArrayList<MonitorModeListener>();
private long tCreated; // creationTime
@@ -97,15 +98,21 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
public static Screen create(final Display display, int idx) {
try {
- if(!usrSizeQueried) {
+ if(!usrValuesQueried) {
synchronized (Screen.class) {
- if(!usrSizeQueried) {
- usrSizeQueried = true;
- final int w = PropertyAccess.getIntProperty("newt.ws.swidth", true, 0);
- final int h = PropertyAccess.getIntProperty("newt.ws.sheight", true, 0);
- if(w>0 && h>0) {
- usrSize = new Dimension(w, h);
- System.err.println("User screen size "+usrSize);
+ if(!usrValuesQueried) {
+ usrValuesQueried = true;
+ final int px_w = PropertyAccess.getIntProperty("newt.ws.swidth", true, 0);
+ final int px_h = PropertyAccess.getIntProperty("newt.ws.sheight", true, 0);
+ if(px_w>0 && px_h>0) {
+ usrScreenPixelSize = new Dimension(px_w, px_h);
+ System.err.println("User screen size "+usrScreenPixelSize+" [pixel]");
+ }
+ final int mm_w = PropertyAccess.getIntProperty("newt.ws.mmwidth", true, 0);
+ final int mm_h = PropertyAccess.getIntProperty("newt.ws.mmheight", true, 0);
+ if(mm_w>0 && mm_h>0) {
+ usrMonitorMMSize = new Dimension(mm_w, mm_h);
+ System.err.println("User monitor size "+usrMonitorMMSize+" [mm]");
}
}
}
@@ -292,9 +299,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
* Updates the <b>rotated</b> virtual viewport, may use native impl.
*/
protected void updateVirtualScreenOriginAndSize() {
- if(null != usrSize ) {
- virtViewportPU.set(0, 0, usrSize.getWidth(), usrSize.getHeight());
- virtViewportWU.set(0, 0, usrSize.getWidth(), usrSize.getHeight());
+ if(null != usrScreenPixelSize ) {
+ virtViewportPU.set(0, 0, usrScreenPixelSize.getWidth(), usrScreenPixelSize.getHeight());
+ virtViewportWU.set(0, 0, usrScreenPixelSize.getWidth(), usrScreenPixelSize.getHeight());
if(DEBUG) {
System.err.println("Update user virtual screen viewport @ "+Thread.currentThread().getName()+": "+virtViewportPU);
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java
index fbad10c8c..99609b56f 100644
--- a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java
@@ -107,7 +107,12 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- i = getScreenSizeMM(outMetrics, props, i); // sizeMM
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ i = getScreenSizeMM(outMetrics, props, i); // sizeMM
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = outMetrics.widthPixels; // rotated viewport width pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java
index 18c60ea84..69fde6736 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java
@@ -112,8 +112,13 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
- props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
+ props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = currentMode.getRotatedWidth(); // rotated viewport width pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
index 3d2e8fc3a..3a07d38ab 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
@@ -87,8 +87,13 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
- props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
+ props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = fixedWidth; // FIXME rotated viewport width pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
index 6b4d97baa..a48b768c9 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
@@ -80,8 +80,13 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
- props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
+ props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = cachedWidth; // rotated viewport width pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
index e25a0eb22..e5ba4a960 100644
--- a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java
@@ -119,8 +119,13 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- props[i++] = connectors[scridx].getMmWidth();
- props[i++] = connectors[scridx].getMmHeight();
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ props[i++] = connectors[scridx].getMmWidth();
+ props[i++] = connectors[scridx].getMmHeight();
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = mode[scridx].getHdisplay(); // rotated viewport width pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
index 456545430..2b5e672ed 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
@@ -89,8 +89,13 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
- props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
+ props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = cachedWidth; // rotated viewport width pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
index 0b70737ac..011bfaf6e 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
@@ -85,8 +85,13 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = crt_id;
props[i++] = 0; // is-clone
props[i++] = 1; // is-primary
- props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
- props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ if( null != usrMonitorMMSize ) {
+ props[i++] = usrMonitorMMSize.getWidth();
+ props[i++] = usrMonitorMMSize.getHeight();
+ } else {
+ props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
+ props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
+ }
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
props[i++] = cachedWidth; // rotated viewport width pixel-units