Skip to content

Commit d2e9e16

Browse files
committed
Correct Cairo autoscaling setting in DPIUtil and remove setter #2031
Cairo auto-scaling was enabled in DPIUtil for every OS in a recent commit. This corrects the setting to be only applied on Linux/GTK and thus also issues arising from it. In addition, it removes the unnecessary setter for the auto-scaling and disables the tests that previously required it as they are meaningless without productive use of disabled Cairo auto-scale on Linux anyway. Fixes #2031
1 parent 111b874 commit d2e9e16

File tree

2 files changed

+6
-6
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal
  • tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit

2 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static enum AutoScaleMethod { AUTO, NEAREST, SMOOTH }
4747
private static AutoScaleMethod autoScaleMethod = AutoScaleMethod.NEAREST;
4848

4949
private static String autoScaleValue;
50-
private static boolean useCairoAutoScale = true;
50+
private static final boolean useCairoAutoScale = Platform.PLATFORM.equals("gtk");
5151

5252
/**
5353
* System property that controls the autoScale functionality.
@@ -484,7 +484,7 @@ public static Rectangle scaleUp(Drawable drawable, Rectangle rect, int zoom) {
484484
* @return float scaling factor
485485
*/
486486
private static float getScalingFactor(int zoom) {
487-
if (useCairoAutoScale) {
487+
if (useCairoAutoScale()) {
488488
return 1;
489489
}
490490
if (zoom <= 0) {
@@ -631,8 +631,8 @@ private static boolean sholdUseSmoothScaling() {
631631
};
632632
}
633633

634-
public static void setUseCairoAutoScale (boolean cairoAutoScale) {
635-
useCairoAutoScale = cairoAutoScale;
634+
public static boolean useCairoAutoScale() {
635+
return useCairoAutoScale;
636636
}
637637

638638
public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import static org.junit.Assert.assertArrayEquals;
1717
import static org.junit.Assert.assertEquals;
1818
import static org.junit.Assert.assertSame;
19+
import static org.junit.Assume.assumeFalse;
1920

2021
import org.eclipse.swt.graphics.Device;
2122
import org.eclipse.swt.graphics.Point;
@@ -37,14 +38,13 @@ public class DPIUtilTests {
3738

3839
@Before
3940
public void setup() {
41+
assumeFalse("Linux uses Cairo auto scaling, thus DPIUtil scaling is disabled", SwtTestUtil.isLinux);
4042
deviceZoom = DPIUtil.getDeviceZoom();
4143
DPIUtil.setDeviceZoom(200);
42-
DPIUtil.setUseCairoAutoScale(false);
4344
}
4445

4546
@After
4647
public void tearDown() {
47-
DPIUtil.setUseCairoAutoScale(true);
4848
DPIUtil.setDeviceZoom(deviceZoom);
4949
}
5050

0 commit comments

Comments
 (0)