Bug 445564 - With HiDPI scaling, rotating canvas back and forth cause offset of viewport.
Summary: With HiDPI scaling, rotating canvas back and forth cause offset of viewport.
Status: RESOLVED DUPLICATE of bug 409894
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-16 04:56 UTC by asrcpq
Modified: 2022-05-22 15:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description asrcpq 2021-11-16 04:56:19 UTC
SUMMARY

With HiDPI scaling(probably >= 175%), rotating canvas back and forth cause offset of viewport.

STEPS TO REPRODUCE
1. create image under OS 200% scaling
2. use mouse middle button + shift to rotate canvas back and forth several times.

OBSERVED RESULT

The canvas moved a little bit towards the left top corner.

EXPECTED RESULT

Canvas stays at center.

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Debian sid
Qt Version: 5.15.2

ADDITIONAL INFORMATION

This seems to be caused by snapToDevicePixel in KisCoordinatesConverter::correctOffsetToTransformation, a quick dirty fix is to add an float offset dp to the point passed in, depending on scaling factor.
Comment 1 Alvin Wong 2021-12-05 06:23:41 UTC
Can reproduce on a1f3b48. No, I don't think it is strictly limited to high-DPI scaling as I can also get the canvas to shift when using 100% scaling. Seems to me that it shifts more the slower you move the cursor while in the rotate action (which produces smaller angle deltas for each move events).

`snapToDevicePixel` in `KisCoordinatesConverter::correctOffsetToTransformation` is there to ensure that the top-left corner of the image area always aligns with the corner of a screen pixel. From my understanding, this is necessary for the QPainter (non-OpenGL) canvas to draw the pre-scaled projection correctly. For both QPainter and OpenGL canvas, this also makes sure that when the canvas is at a right angle and with a canvas scaling of power-of-two (e.g. 50%, 100%, 200%) the image pixels align with screen pixels to produce a crisp display.

The problem is that rotation is handled by delta which causes the rounding difference to accumulate. This is not even specific to rotation as just panning the canvas with the touch gesture can also produce an offset. To really eliminate such offsets, I think the canvas movements need to be handled by storing the transformation at the start of a gesture, then have the overall change caused by a gesture applied on top of that. Might need to ask Dmitry about that.
Comment 2 Alvin Wong 2022-05-22 15:17:11 UTC

*** This bug has been marked as a duplicate of bug 409894 ***