Skip to content

Commit ffa1084

Browse files
committed
Use AutoScaleMethod "smooth" by default for fractional scaling
Currently, AutoScaleMethod "nearest" is used by default, leading to jagged image scaling results. The method "smooth" is only used on GTK with a fractional scaling value not being a multiple of 100. The reason for not using "smooth" scaling on all platform was a bug regarding icon transparency that has long been resolved. With this change, AutoScaleMethod "smooth" is used by default in fractional scaling scenarios (i.e., with deviceZoom not being an integer multiple of 100) and when using monitor-specific scaling on Windows. To still use "nearest" in these scenarios, it can be activated via system property.
1 parent 79e1308 commit ffa1084

File tree

1 file changed

+14
-7
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal

1 file changed

+14
-7
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ private static enum AutoScaleMethod { AUTO, NEAREST, SMOOTH }
7979
* <li>"nearest": nearest-neighbor interpolation, may look jagged</li>
8080
* <li>"smooth": smooth edges, may look blurry</li>
8181
* </ul>
82-
* The current default is to use "nearest", except on
83-
* GTK when the deviceZoom is not an integer multiple of 100%.
84-
* The smooth strategy currently doesn't work on Win32 and Cocoa, see
85-
* <a href="https://bugs.eclipse.org/493455">bug 493455</a>.
82+
* The current default is to use "smooth" on GTK when deviceZoom is an integer
83+
* multiple of 100% and on Windows if monitor-specific scaling is enabled, and
84+
* "nearest" otherwise..
8685
*/
8786
private static final String SWT_AUTOSCALE_METHOD = "swt.autoScale.method";
8887

@@ -605,14 +604,22 @@ public static void setDeviceZoom (int nativeDeviceZoom) {
605604
DPIUtil.deviceZoom = deviceZoom;
606605
System.setProperty("org.eclipse.swt.internal.deviceZoom", Integer.toString(deviceZoom));
607606
if (deviceZoom != 100 && autoScaleMethodSetting == AutoScaleMethod.AUTO) {
608-
if (deviceZoom / 100 * 100 == deviceZoom || !"gtk".equals(SWT.getPlatform())) {
609-
autoScaleMethod = AutoScaleMethod.NEAREST;
610-
} else {
607+
if (sholdUseSmoothScaling()) {
611608
autoScaleMethod = AutoScaleMethod.SMOOTH;
609+
} else {
610+
autoScaleMethod = AutoScaleMethod.NEAREST;
612611
}
613612
}
614613
}
615614

615+
private static boolean sholdUseSmoothScaling() {
616+
return switch (SWT.getPlatform()) {
617+
case "gtk" -> deviceZoom / 100 * 100 != deviceZoom;
618+
case "win32" -> isMonitorSpecificScalingActive();
619+
default -> false;
620+
};
621+
}
622+
616623
public static void setUseCairoAutoScale (boolean cairoAutoScale) {
617624
useCairoAutoScale = cairoAutoScale;
618625
}

0 commit comments

Comments
 (0)