Skip to content

Fix Mypaint mirroring

I made MyPaint brushes mirror.

I made the MR because I am unsure about some things.

  • when there are functions "renderMirrorMaskSafe", what is it safe from? I can see that if "preserveDab" or "preserveMask" variables are true, the mask or dab is recreated, but what would happen if it wasn't? What is the danger there? (If it's just overwriting,
  • I created both paint device and fixed paint device for mask, because:
    • there is no renderMirrorMask function that accepts paint device for both dab and mask, and I think bitBltWithFixedSelection doesn't allow that either
    • you cannot iterate on fixed paint device; sequential iterators asks specifically for paint device, I couldn't find an iterator for fixed paint device
    • I didn't want to just iterate on the ->data() because then it could be in a different order than the dab paint device is iterated on
    • in renderMirrorMaskSafe, readBytes() is used all the time, so I decided it's fine to use it
    • I could make a new function, probably, but they are a bit confusing anyway - they can ask for paint device or fixed paint device for a dab; they can ask for a mask or not; they can ask whether you want to preserve a dab or preserve a mask, but not in one function; they can ask for a QRect or not... but only a few of the combinations of choices are implemented. I guess only those were needed. But there is plenty of code duplication there already anyway, so I don't know if adding a new function would be a good idea.
  • the mask is strictly black & white, because if I make it grey in semi-transparent areas, the result wouldn't be correct. That makes the halo in mirroring over two different colors even uglier, but correctness in the general case is more important.

Test Plan

Try using different mypaint brushes with mirroring. It works.

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.
Edited by Agata Cacko

Merge request reports