HiDPI scalefactor
Johan Vos
johan at lodgon.com
Thu Feb 26 09:18:37 UTC 2015
Hi,
Another one on HiDPI.
We had an issue on mobile where clicking a ComboBox showed the items on a
wrong place on HiDPI devices.
It turned out that this was due to a mismatch between logical and physical
screensize. In the ES2SwapChain, the physical width is mainly used (e.g. in
createGraphics). Hence, I made the AndroidScreen return the physical width
(i.e. 320 pixels * scaleFactor 3).
However, the getContentX() and getContentY() methods don't do that
conversion in the case of embedded. When I modify this code like below, and
take the scaling into account, it works.
Should I create an issue for this, with the attached diff? This is not in
embedded/mobile specific code, so I want to be extremely careful not to
break anything.
Thanks,
- Johan
diff -r 95ca0933010c
modules/graphics/src/main/java/com/sun/prism/es2/ES2SwapChain.java
--- a/modules/graphics/src/main/java/com/sun/prism/es2/ES2SwapChain.java Tue
Feb 24 13:53:50 2015 +0100
+++ b/modules/graphics/src/main/java/com/sun/prism/es2/ES2SwapChain.java Thu
Feb 26 10:06:33 2015 +0100
@@ -247,7 +247,7 @@
// EGL doesn't have a window manager, so we need to ask the window
for
// the x/y offset to use
if (PlatformUtil.useEGL()) {
- return pState.getWindowX();
+ return (int)(pState.getWindowX() * pixelScaleFactor);
} else {
return 0;
}
@@ -257,8 +257,8 @@
// EGL doesn't have a window manager, so we need to ask the window
// for the x/y offset to use
if (PlatformUtil.useEGL()) {
- return pState.getScreenHeight() -
- pState.getHeight() - pState.getWindowY();
+ return (int)((pState.getScreenHeight() -
+ pState.getHeight() - pState.getWindowY()) *
pixelScaleFactor);
} else {
return 0;
}
More information about the openjfx-dev
mailing list