HiDPI in monocle

Jim Graham james.graham at oracle.com
Tue Jun 16 19:58:43 UTC 2015


The Windows code recalculates the screen bounds into DPI-virtualized 
versions before it constructs the Screen objects.  They are virtualized 
into FX coordinates such that placing a window at those bounds, when run 
through the platformScale, will result in a window of the appropriate 
pixel size to cover the screen.  Does that make sense?

On Mac, they talk "FX" coordinates for the screen bounds and window 
sizes already so there is no such translation going on.

			...jim

On 6/16/15 6:55 AM, Johan Vos wrote:
> Update:
> I have HiDPI working on Android-Monocle again, mainly by passing the
> physical width/height to the Screen constructor. (e.g. 1920, 1080). I
> had to remove some preprocessing on event detection in the Android
> layer, as this is now done in a generic way -- I'm always happy to
> remove some of my Android-specific code!
>
> The issue I still have though is that
> Screen.getPrimary().getVisualBounds() now returns the physical
> coordinates (1920, 1080) instead of the logical ones.
> Looking at the implementation of Screen.getVisualBounds, it seems to me
> this always returns the width/height from the com.sun.glass.ui.Screen.
> So in this case, I assume the width/height that need to be passed to the
> com.sun.glass.ui.Screen constructor are *not* the physical ones, but the
> logical ones? But if I do that, I get the issue described in my previous
> mail.
>
> Any help with sample dimensions on other platforms are very much
> appreciated.
>
> Thanks,
>
> - Johan
>
>
>
> 2015-06-16 13:13 GMT+02:00 Johan Vos <johan at lodgon.com
> <mailto:johan at lodgon.com>>:
>
>     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 pixels
>           * 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
>     <mailto: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