You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Win32] Drawing produces asymmetrical results without swt.autoScale=false for 4k monitor with zooming #1596
With swt.autoScale=quarter or exact it looks even worse:
close-up:
Hence it looks like there is no way to draw symmetric elements without setting swt.autoScale=false.
The oval at 100% is also asymmetric (can be seen in different colors from anti-aliasing), it only becomes more visible at 175% because the calculation is more off. With swt.autoScale=false you just hide that as rendering just still happens at 100%, where the asymmetry is only harder to see.
Asking users, I reckon 99% would answer the 100% version looks symmetric.
Might be, but what does that change? Using the 175% version and placing users at 175% the distance of the monitor than when using the 100% version, they will probably also consider it symmetric...
It's asymmetric, so there seems to be a bug in rendering, which is more visible when using higher scale values. There is nothing better in using swt.autoScale=false than using any other scale value with respect to symmetry. Things are simply just too small to see it when using no scaling for HiDPI monitors.
How do we need to draw these elements that they look fine between 100% and 200% zoom level for 99% of the users?
My first impression is that this is a bug in SWT. So there may be no other way than looking into SWT code, finding the cause of the bug, and fixing it.
With swt.autoScale=false I have the possibility to optimize it for larger zoom levels, because I have control over all pixels, not just control over double-pixels:
Close-up:
IMHO one problem is that pixel coordinates simply are scaled. But there are draw operations like fillXxx that expect the right/lower coordinate outside the drawn area. The other problem is that for most draw operations only int coordinates are allowed, so it scales only to multiples of 2.
I wonder how other drawing APIs handle such fractional scaling.
If I look at your snippet I'm not sure you are taking the line width into account correctly, you set a line width of three but I can't find you possibly account for this.
Beside that, yes only having int coordinates (except for example Path) is a big limitation compared to e.g. AWTs Graphics2D, e.g AWT uses the concept of Shapes what is really convenient and powerful.
what exactly we can expect to happen for 100% zoom level and especially for 200% zoom level? How wide the line should be with 200% zoom (I'd expect 2 pixels), where exactly it should be drawn, should the line be fully visible if drawn at the coordinate 0?
Assuming the following code:
gc.fillRect(1, 1, 10, 5);
how wide the rect (in pixels) should be with 200% zoom? Which pixels should be covered?
Should we expect to get the same rendering result on all 3 platforms?
changed the title [-][Win32] Drawing produces unsymmetric results without swt.autoScale=false for 4k monitor with zooming[/-][+][Win32] Drawing produces asymmetrical results without swt.autoScale=false for 4k monitor with zooming[/+]on Sep 11, 2026
Activity
tmssngr commentedon Nov 15, 2024
With


swt.autoScale=quarterorexactit looks even worse:close-up:
Hence it looks like there is no way to draw symmetric elements without setting
swt.autoScale=false.HeikoKlare commentedon Nov 15, 2024
The oval at 100% is also asymmetric (can be seen in different colors from anti-aliasing), it only becomes more visible at 175% because the calculation is more off. With
swt.autoScale=falseyou just hide that as rendering just still happens at 100%, where the asymmetry is only harder to see.tmssngr commentedon Nov 15, 2024
Asking users, I reckon 99% would answer the 100% version looks symmetric.
How do we need to draw these elements that they look fine between 100% and 200% zoom level for 99% of the users?
HeikoKlare commentedon Nov 15, 2024
Might be, but what does that change? Using the 175% version and placing users at 175% the distance of the monitor than when using the 100% version, they will probably also consider it symmetric...
It's asymmetric, so there seems to be a bug in rendering, which is more visible when using higher scale values. There is nothing better in using
swt.autoScale=falsethan using any other scale value with respect to symmetry. Things are simply just too small to see it when using no scaling for HiDPI monitors.My first impression is that this is a bug in SWT. So there may be no other way than looking into SWT code, finding the cause of the bug, and fixing it.
tmssngr commentedon Nov 15, 2024
With


swt.autoScale=falseI have the possibility to optimize it for larger zoom levels, because I have control over all pixels, not just control over double-pixels:Close-up:
IMHO one problem is that pixel coordinates simply are scaled. But there are draw operations like fillXxx that expect the right/lower coordinate outside the drawn area. The other problem is that for most draw operations only int coordinates are allowed, so it scales only to multiples of 2.
I wonder how other drawing APIs handle such fractional scaling.
laeubi commentedon Nov 16, 2024
If I look at your snippet I'm not sure you are taking the line width into account correctly, you set a line width of three but I can't find you possibly account for this.
Beside that, yes only having int coordinates (except for example Path) is a big limitation compared to e.g. AWTs Graphics2D, e.g AWT uses the concept of Shapes what is really convenient and powerful.
tmssngr commentedon Nov 18, 2024
@laeubi In SmartGit we are using the zoom factor (1 or 2) to draw the lines with the correct width. The result looks correct with all zoom levels.
tmssngr commentedon Nov 19, 2024
Assuming following code:
what exactly we can expect to happen for 100% zoom level and especially for 200% zoom level? How wide the line should be with 200% zoom (I'd expect 2 pixels), where exactly it should be drawn, should the line be fully visible if drawn at the coordinate 0?
Assuming the following code:
how wide the rect (in pixels) should be with 200% zoom? Which pixels should be covered?
Should we expect to get the same rendering result on all 3 platforms?
eclipse-platform#1596: GC, Path: fix misalignment of scaled lines
eclipse-platform#1596: [Win32] Drawing produces unsymmetric results w…
tmssngr commentedon Nov 21, 2024
Please give the pull request a try.
BeckerWdf commentedon Nov 21, 2024
You mean this one: #1607 ?
tmssngr commentedon Nov 22, 2024
Yes, this the PR #1607. I know that it can't be merged right now because of feature-freeze, but I want you to give it a try.
eclipse-platform#1596: [Win32] Drawing produces unsymmetric results w…
[-][Win32] Drawing produces unsymmetric results without swt.autoScale=false for 4k monitor with zooming[/-][+][Win32] Drawing produces asymmetrical results without swt.autoScale=false for 4k monitor with zooming[/+]