Fix ruler performance problem
The ruler used to draw the marks no matter if they are visible. This
causes a performance problem as under high zoom levels, a large number
(equals to or more than the number of pixels along the width or height
of the canvas) of marks will be drawn. This patch changes the behavior,
let the ruler draw only the marks that are visible or partially visible.
Regression from ba60778bd55071449c56acd78c056623ce7e7ac6
BUG: 390041
Differential Revision: https://phabricator.kde.org/D10572