Skip to content

Improve Perspective Assistant performance by not using drawCache

Before this commit, the grid of the Perspective Assistant was drawn in the drawCache, which caused performance issues when using the perspective assistant and zooming in a lot.

This commit does two things:

  • crops the drawn lines to the viewport
  • moves the whole drawing action to drawAssistant Note: just cropping the drawn lines, but still using the cache, didn't improve the assistants performance that much. There must be some inherent issue with this caching method.

BUG:411352 https://bugs.kde.org/show_bug.cgi?id=411352

Test Plan

(I only tested on Linux, and it might be somewhat related to the canvas acceleration, somehow).

  1. Open this file: all_assistants_big_perspective.kra
  2. Make sure you have Configure Krita -> Display -> Canvas Acceleration turned on. (Though tests with it turned off are welcome too, of course. But for it turned off, the lag is so strong in both cases that I cannot tell if this MR helps or not).
  3. Zoom in to around 1600% or the next level.
  4. Zoom in and out very very quickly using the mouse wheel. Results before: big lag Results after: no lag

Note: those results don't come just from the cropping to viewport, because I tried that before. Maybe when the viewport changes, it's being redrawn so the lag comes from remembering the cache (since it's drawn in the new version too)? Something feels fishy about the caching method there.

Note that after this, the lines are thinner, I actually find it nicer but I can change it if needed. (I highly doubt it is the reason the drawing is faster in the new version). Also it's so easy to make an option for variable grid lines, why no one ever did it?

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Agata Cacko

Merge request reports