Bug 493462 - [HiDPI] Improve autoScale method, default deviceZoom, and system properties
Summary: [HiDPI] Improve autoScale method, default deviceZoom, and system properties
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.6 RC1   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 489466 (view as bug list)
Depends on:
Blocks: 495417 479614 489817 492312 493797
  Show dependency tree
 
Reported: 2016-05-11 16:10 EDT by Markus Keller CLA
Modified: 2016-09-21 11:15 EDT (History)
12 users (show)

See Also:
sravankumarl: review+


Attachments
visual studio @100% (279.13 KB, image/png)
2016-05-12 06:14 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
visual studio @150% (291.88 KB, image/png)
2016-05-12 06:14 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
with patch @150% (1.60 MB, image/jpeg)
2016-05-12 07:10 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
with patch @155% (1.63 MB, image/jpeg)
2016-05-12 07:11 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
with patch @175% (1.46 MB, image/jpeg)
2016-05-12 07:11 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
without patch @150% (1.58 MB, image/jpeg)
2016-05-12 07:12 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2016-05-11 16:10:40 EDT
Unfortunately, HiDPI support on GTK and Windows is not at an acceptable level for Neon.

I tried to improve image scaling via bug 97506, but the solution only works on GTK. Mac and Windows suffer from bug 493455.

Furthermore, at least on Windows, there are still problems in text editors where lines sometimes jump up or down a bit when scrolling, moving the caret, or changing the selection.

I think at this point, the best solution is to ship with defaults that only use integer scale factors. This is a common solution at least on GTK, see bug 489771 comment 40.

On GTK, we can offer the better image interpolation method for users who want to run at different scale factors.

I'll update https://git.eclipse.org/r/70415 with this solution, which is a combination of fixes discussed in bug 97506, bug 489771, and bug 489466.

The old system property swt.enable.autoScale will be removed and replaced by these two:

/**
 * System property that controls the autoScale functionality.
 * <ul>
 * <li><b>false</b>: deviceZoom is set to 100%</li>
 * <li><b>integer</b>: deviceZoom depends on the current display resolution,
 *     but only uses integer multiples of 100%. The detected native zoom is
 *     generally rounded down (e.g. 150% => 100%), unless close to the next
 *     multiple.</li>
 * <li><b>quarter</b>: deviceZoom depends on the current display resolution,
 *     but only uses integer multiples of 25%. The detected native zoom is
 *     rounded to the closest permissible value.</li>
 * <li><b>exact</b>: deviceZoom uses the native zoom (with 1% as minimal
 *     step).</li>
 * <li><i>&lt;value&gt;</i>: deviceZoom uses the given integer value in
 *     percent as zoom level.</li>
 * </ul>
 * The current default is "integer".
 */
private static final String SWT_AUTOSCALE = "swt.autoScale";

/**
 * System property that controls the method for scaling images:
 * <ul>
 * <li>"nearest": nearest-neighbor interpolation, may look jagged</li>
 * <li>"smooth": smooth edges, may look blurry</li>
 * </ul>
 * The current default is to use "nearest", except on
 * GTK when the deviceZoom is not an integer multiple of 100%.
 * The smooth strategy doesn't work on Win32 and Cocoa, see <a href="https://bugs.eclipse.org/493455">bug 493455</a>.
 */
private static final String SWT_AUTOSCALE_METHOD = "swt.autoScale.method";
Comment 1 Markus Keller CLA 2016-05-11 16:38:25 EDT
*** Bug 489466 has been marked as a duplicate of this bug. ***
Comment 2 Markus Keller CLA 2016-05-11 16:53:34 EDT
I've tested https://git.eclipse.org/r/#/c/70415/6 on all 3 platforms, and I think we should push this for RC1. SWT committers please review and comment.

I've included the -Dswt.autoScale=quarter method because that's what we had since bug 489771.
Comment 3 Andrey Loskutov CLA 2016-05-12 05:05:11 EDT
Is there any chance for RC2 for this bug? As far as I can see the RC1 is frozen now?
Comment 4 Sravan Kumar Lakkimsetti CLA 2016-05-12 06:14:06 EDT
Created attachment 261670 [details]
visual studio @100%
Comment 5 Sravan Kumar Lakkimsetti CLA 2016-05-12 06:14:32 EDT
Created attachment 261671 [details]
visual studio @150%
Comment 6 Dani Megert CLA 2016-05-12 06:50:27 EDT
(In reply to Andrey Loskutov from comment #3)
> Is there any chance for RC2 for this bug? As far as I can see the RC1 is
> frozen now?

We plan to ask for a respin to include this in RC1.
Comment 7 Sravan Kumar Lakkimsetti CLA 2016-05-12 07:10:24 EDT
Created attachment 261673 [details]
with patch @150%
Comment 8 Sravan Kumar Lakkimsetti CLA 2016-05-12 07:11:02 EDT
Created attachment 261674 [details]
with patch @155%
Comment 9 Sravan Kumar Lakkimsetti CLA 2016-05-12 07:11:42 EDT
Created attachment 261675 [details]
with patch @175%
Comment 10 Sravan Kumar Lakkimsetti CLA 2016-05-12 07:12:34 EDT
Created attachment 261676 [details]
without patch @150%
Comment 11 Sravan Kumar Lakkimsetti CLA 2016-05-12 07:16:12 EDT
I used my phone camera to take these pictures. With the attached patch there is a mismatch of text and icon sizes and alignment.

One problem I notice here is the icons are drawn at 100% even for a scalefactor of 155%.
Comment 12 Niraj Modi CLA 2016-05-12 08:02:47 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #11)
> I used my phone camera to take these pictures. With the attached patch there
> is a mismatch of text and icon sizes and alignment.
> 
> One problem I notice here is the icons are drawn at 100% even for a
> scalefactor of 155%.

Behavior on Windows with latest gerrit:
100 to 174% DPI settings are rounding to 100%
175 to 200% DPI settings are rounding to 200%
Comment 13 Markus Keller CLA 2016-05-12 08:13:51 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #11)
> One problem I notice here is the icons are drawn at 100% even for a
> scalefactor of 155%.

Yes, that's by design. GTK apps like gedit even use the @1x icon up to 199%.

I did some experiments and found that it's OK to use the @2x icon on 175%. But at 150%, the @2x icons are too big. And without good auto-scaling at non-integer scale factors, the @1x and @2x versions are all we have.

In the SDK, we could ship with @1.5x icons, but as said before, we cannot assume that all plug-ins will add HiDPI icons promptly, and without a good fallback, actual Eclipse installs will look broken (users rarely work with a plain SDK).

And to clarify the many options in the new system properties: These are not meant to be advertised to normal users. They are considered temporary and experimental, and they are there to:
a) allow devs and curious users to play with different options
b) allow users to disable the feature in case of new problems we're not currently aware of (e.g. Linux systems other than Ubuntu and CentOS, where we could only do limited testing)
Comment 15 Markus Keller CLA 2016-05-12 08:42:07 EDT
I fixed the Javadoc problem Niraj mentioned in the Gerrit, and I've pushed the fix to master. Will request an RC1 rebuild.
Comment 16 Niraj Modi CLA 2016-05-16 03:39:37 EDT
Verified fix in Build id: I20160512-1000 on Win7.
Comment 17 Thomas Singer CLA 2016-09-21 08:31:34 EDT
Until SWT version 4.621 (before commit 487efd11) I could disable the autoscaling feature on HiDPI monitors by setting the VM option "swt.enable.autoScale" to "false". How to disable it now?
Comment 18 Thomas Singer CLA 2016-09-21 08:39:37 EDT
Also very important: how to disable the autoscaling for the GC draw operations?
Comment 19 Sravan Kumar Lakkimsetti CLA 2016-09-21 08:43:57 EDT
(In reply to Thomas Singer from comment #17)
> Until SWT version 4.621 (before commit 487efd11) I could disable the
> autoscaling feature on HiDPI monitors by setting the VM option
> "swt.enable.autoScale" to "false". How to disable it now?

you can use -Dswt.autoScale=false now
Comment 20 Thomas Singer CLA 2016-09-21 11:15:15 EDT
Thanks. I've used in the mean-time

 DPIUtil.setDeviceZoom(100);

after creating the display instance.