HiDPI in monocle

Johan Vos johan at lodgon.com
Tue Jun 16 11:13:44 UTC 2015

In MonocleApplication, a Screen is created. It used to be call the
constructor with the last argument (float scale) set to 1.0f, but I changed
that to NativeScreen.getScale() which has this javadoc:
     * Return the scale factor between the physical pixels and the logical
     * e.g. hdpi = 1.5, xhdpi = 2.0

With the new Screen constructor, it seems to me both the UIScale and the
RenderScale need to be set to the NativeScreen.getScale(). If I do that on
my Nexus 5 where getScale() returns 3, however, only 1/3 of the screen is
used. It seems presentableState.width is set to 1/3 of the logical width
which is 1/3 of the physical width. I have 1080 physical pixels, 360
logical pixels, but presentableState.width is only 120.

Looking at the diff in RT-27960, there are probably changes required in
MonocleApplication and MonocleWindow as well?

- Johan

2015-06-15 22:29 GMT+02:00 Jim Graham <james.graham at oracle.com>:

> Screen.getPlatformScale() is the scaling from "FX pixels" to the pixels
> that the platform uses for events and window coordinates.
> Screen.getRenderScale() is the recommended scale for rendering - typically
> "ceil(platformScale)".
> There is also Window.getOutputScale() which defaults to
> getPlatformScale().  When rendering a scene we render at the render scale
> and then blit it to the size indicated by the output scale.  When
> "renderscale = ceil(platformScale)", as it does on Windows, we may be
> rendering at 200% for a window that is at 150% on the screen, so the
> rendering happens at an integer pixel scale and then we get the size on the
> screen appropriate for what the Windows UI guidelines suggest.
>                         ...jim
> On 6/15/15 9:37 AM, Johan Vos wrote:
>> Hi,
>> With the changes introduced in the fix for RT-27960 (
>> https://bugs.openjdk.java.net/browse/JDK-8098184), the hidpi support on
>> Android is broken.
>> As part of the changes in
>> http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/670ed25ed138, we
>> introduced a getScale method on NativeScreen, and the result of this
>> method
>> was used in the constructor of Screen (See MonocleApplication.java). As an
>> example, on a Nexus 5 the getScale() would return 3.0, as the device has
>> 1920x1080 physical pixels but we use a Scene with dimensions 640x360.
>> I'm not sure how to map this getScale() to the new getPlatformScale() and
>> getRenderScale() though?
>> - Johan

More information about the openjfx-dev mailing list