Skip to content

Preset Chooser: Improve performance of rendering delegates

Across Krita there were several places which had thumbnail.scaled() method, which was invoked repeatedly. The worst case of this was ThumbnailPainter, where scaled() was called on all thumbnails for each draw call making resizing of the docker quite slow.

This change makes it so that we cache the scaled thumbnails, so it isn't a bottleneck when trying to scroll the widget. The cache is a quite naive QMap of the QImages where the key is the properties of the image and it implements no limits on how many image to store and all that.

Test Plan

Check if the rendering of thumbnails for resources works as before. And updating the resource updates the thumbnail as well.

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.

Merge request reports