It turns out that there were two issues at play here: rounding errors
meant that pixmaps were almost never the same size as pagePainter
thought the tiles should be, and the tile-is-the-size-it-should-be code
path was broken (but only hit in rare cases, seemingly at random).
To help with rounding errors in the future, I added a geometryF function
to NormalizedRect that returns a QRectF. In general,
device-independent-pixel points/rects should be floating point, and
device-pixel rects should be integer.
PagePainter::paintCroppedPageOnPainter had a few calls to
QPixmap::setDevicePixelRatio on pixmaps it does not own, which detaches
the pixmap, making a deep copy. It turns out these were all unnecessary.
It also copied scaled before drawing them onto the painter.
I've tested all the changes except for the annotation stamps, which I'm
just assuming works like the others.
Also ran clang-format.
There are three reasons why scrolling happens (first two cases of scrolling are actually due to
viewport transition that is triggered by annotation being traslated/created):
1. VisiblePageRect are NormalizedRect and should be represented by four values in [0, 1] interval.
Due to rounding errors caused by using QRect, they only reach the [0, 0.999] interval.
That means that right and bottom edge of the page are never visible so if annotation
is translated along the right/bottom edge viewport transition occurs (fixed in
PageView::slotRequestVisiblePixmaps)
2. For freehand line there are some constants (dX, dY) that make a line to be drawn outside
the page borders causing viewport transition. Removing these constants solves the problem (fixed
in SmoothPathEngine::event)
3. Browse mode is activated as soon as the cursor is moved outside the viewport.
Instead, we should forward the move event to the annotation which than can ignore the event (fixed
in PageView::mouseMoveEvent)
BUG: 436742
Currently, scrolling through a document using the touchpad is quite slow compared to scrolling through the standard Qt controls. This MR increases the speed of scrolling with the touchpad by removing the "magic" divider.
CCBUG: 455014