<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>432936</bug_id>
          
          <creation_ts>2021-02-14 12:08:58 +0000</creation_ts>
          <short_desc>Performance issue related to KoDualColorButton</short_desc>
          <delta_ts>2021-02-14 12:40:23 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>krita</product>
          <component>Color Selectors</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter>grum999</reporter>
          <assigned_to name="Krita Bugs">krita-bugs-null</assigned_to>
          
          
          <cf_commitlink>https://invent.kde.org/graphics/krita/commit/212236cbb1cd5e97453fa35b7549456ce0b26260</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2002530</commentid>
    <comment_count>0</comment_count>
    <who name="">grum999</who>
    <bug_when>2021-02-14 12:08:58 +0000</bug_when>
    <thetext>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&apos;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 &quot;visible&quot; 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 &amp; 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()
==&gt; Seems to fix the problem, execution time is ~0.5s in all case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002537</commentid>
    <comment_count>1</comment_count>
    <who name="Halla Rempt">halla</who>
    <bug_when>2021-02-14 12:39:57 +0000</bug_when>
    <thetext>Git commit 5d76047526d272d971e009f4348ea40b5624529e by Halla Rempt.
Committed on 14/02/2021 at 12:39.
Pushed by rempt into branch &apos;master&apos;.

Replace repaint calls with update calls

M  +7    -7    libs/ui/widgets/KoDualColorButton.cpp

https://invent.kde.org/graphics/krita/commit/5d76047526d272d971e009f4348ea40b5624529e</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002538</commentid>
    <comment_count>2</comment_count>
    <who name="Halla Rempt">halla</who>
    <bug_when>2021-02-14 12:40:23 +0000</bug_when>
    <thetext>Git commit 212236cbb1cd5e97453fa35b7549456ce0b26260 by Halla Rempt.
Committed on 14/02/2021 at 12:40.
Pushed by rempt into branch &apos;krita/4.3&apos;.

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</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>