SUMMARY All details about this problem is available on krita-artist here: https://krita-artists.org/t/setforegroundcolor-execution-speed/18714?u=grum999 In synthesis, there's a problem with the KoDualColorButton widget. When button is visible in toolbar: - Advanced Color Selector is laggy - PyKrita calls to setForeGroundColor() and setBackGroundColor() are very slow The problem seems to be related to current main window size: - not "visible" on a FullHD monitor - clearly performances killer on a 4K monitor STEPS TO REPRODUCE 1. Create open a document 2. Execute following script: # --------------------------------------------------- from krita import * import time av=Krita.instance().activeWindow().activeView() color=QColor(Qt.black) ts=time.time() for i in range(255): color.setRed(i) mc=ManagedColor.fromQColor(color, av.canvas()) av.setForeGroundColor(mc) print(time.time()-ts) # --------------------------------------------------- OBSERVED RESULT With button in toolbar: +---------------------+------------------------------+----------------+ | Krita’s window size | Advanced color selector size | Execution time | +---------------------+------------------------------+----------------+ | 454x352 | None | ~0.50s | | 454x352 | 100x40 | ~0.65s | | 1920x1080 | None | ~0.73s | | 1920x1080 | 100x40 | ~0.90s | | 1920x1080 | 1570x875 | ~5.90s | | 3840x2094 | None | ~10.90s | | 3840x2094 | 100x40 | ~12.00s | | 3840x2094 | 3494x1885 | ~164.00s | +---------------------+------------------------------+----------------+ Note: by None, I mean deactivated in settings + removed from docker Without button in toolbar (removed from toolbar or removed toolbar): All case are ~0.5s EXPECTED RESULT Setting color should be fast in all case SOFTWARE/OS VERSIONS Windows: not tested macOS: not tested Linux/KDE Plasma: Debian 10 Qt Version: 5.11 & 5.12 ADDITIONAL INFORMATION In https://invent.kde.org/graphics/krita/-/blob/master/libs/ui/widgets/KoDualColorButton.cpp Methods: - KoDualColorButton::setForegroundColor() - KoDualColorButton::setBackgroundColor() Replace call to repaint() method with update() ==> Seems to fix the problem, execution time is ~0.5s in all case
Git commit 5d76047526d272d971e009f4348ea40b5624529e by Halla Rempt. Committed on 14/02/2021 at 12:39. Pushed by rempt into branch 'master'. Replace repaint calls with update calls M +7 -7 libs/ui/widgets/KoDualColorButton.cpp https://invent.kde.org/graphics/krita/commit/5d76047526d272d971e009f4348ea40b5624529e
Git commit 212236cbb1cd5e97453fa35b7549456ce0b26260 by Halla Rempt. Committed on 14/02/2021 at 12:40. Pushed by rempt into branch 'krita/4.3'. Replace repaint calls with update calls (cherry picked from commit 104c45aa4a56a90f431f8e4130061ba9bcf7081b) M +7 -7 libs/ui/widgets/KoDualColorButton.cpp https://invent.kde.org/graphics/krita/commit/212236cbb1cd5e97453fa35b7549456ce0b26260