Add two workarounds for the slow layer thumbnails problem
The patch adds two workarounds for BUG:510627
Automatic switch to "coarse" layer thumbnail generation
When a layer has vast areas of empty pixels, it may be slow to calculate its exactBounds(). In this case, if thumbnail generation takes more than 40ms, Krita will automatically switch the layer into "coarse thumbnail generation mode" and use extent() instead.
The status bar will also show a warning symbol and list the "slow layers" in a tooltip.
Image->Purge Unused Image Data
A new action was added to remove these areas of empty pixels. It basically iterates through all the layers and cleans-up all paint devices it could find. Just mere calling to the action fixes the slow thumbnails issue for me in my testing images.
WARNING: this action can theoretically break undo/redo functionality of the image. Please test if it doesn't!
Test plan
- Enable logging in the logging docker (or open Krita in a terminal)
- Open Undo History docker
- Open some huge image (4k+) with sparse data on the layers
- Check log for messages like this:
krita.ui: WARNING: thumbnail generation for "HSVFilter" took longer than expected: 202 (timeout: 40 ) krita.ui: This layer's thumbnail will be rendered in imprecise mode from now on - A warning icon should appear in the status bar, telling that some layers now use "coarse" thumbnail mode
- Draw something on the image, verify there is no delay before the stroke (since "slow" layers now use coarse thumbnail mode)
- Click
Image->Purge Unused Image Data - Try to paint something again
- Verify three things:
- the warning icon disappeared from the status bar
- no new warnings appeared in the log
- no delay when painting appeared
- Try to undo/redo on the image past "Purge Unused Image Data". Undo should still work.

