Draft: Port color sampler to strokes
I ported color sampler to strokes... at least partially.
I'm not sure if it helps the situation or not. I was trying to help with this: https://bugs.kde.org/show_bug.cgi?id=372906 . In my case, it's often disrupting the blending, because I do pick colors very often in between strokes and the first stroke after picking is often the old color. I think that if we put the picking into the strokes queue, then it would be executed before the next stroke, not after (but I'm not sure why it was executed after anyway - I can see there is an image lock? Why would image lock make it execute later than a stroke? Maybe I'm misunderstanding something?).
I'm not sure how to port those parts where in the old code, if the sampling was incorrect, it would ignore
the event in beginPrimaryAction and/or continutePrimaryAction(). What does it do? Is it important to keep? (I could move checking the boundaries to before the stroke, it might not be 100% correct but it would be correct enough for most cases).
Also endPrimaryAction adds the color into the Palette, I guess I should port that part to (another) stroke too - but the fact that it doesn't do picking is a bit troublesome. I mean I could make an empty stroke that would be for sure executed after all previous sampling so that the writing the color to the palette would happen afterwards, but then, can we guarantee it will be the correct color in the m_sampledColor? I think it should be, but... I'm not sure. And right now I think it is possible that the color won't be correct, because it doesn't wait for the picking to end. (Before it was all in GUI thread, so it would happen for sure after all sampling).
Test Plan
Paint normally for some time with lots of picking.
To check if it fixes the problem I wanted to fix, try this:
- take a heavy brush (but not too heavy)
- use 50% opacity to make Glazing technique for blending: https://docs.krita.org/en/general_concepts/colors/color_mixing.html#glazing
- pick colors intensively between strokes.
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.