Skip to content

Fix Luminosity/Shine (SAI) alpha issue

Before this commit, there were issues with Luminosity/Shine (SAI) blending mode in some special cases (for example when there is no solid color background, only one layer in Normal mode with semi-transparent and soft stroke, and over that another layer in Luminosity/Shine blending mode with another semi-transparent and soft stroke overlapping the previous one). The soft strokes would make blocky edges instead of nice and smooth edges like other blending modes in such cases.

This commit should fix this issue.

BUG:410516

https://bugs.kde.org/show_bug.cgi?id=410516

NOTE:

If this MR is correct, there is no need to worry about backward compatibility, because:

  • for areas/pixels the result was buggy before, it was clearly wrong so this MR is a clear improvement (and it should be rather rare to encounter it anyway)
  • for areas/pixels that the result was correct before, it should give the exact same result.

It would be awesome if @dkazakov could check this MR and the whole channels_type composeColorChannels() function in KoCompositeOpGenericSCAlpha class. Frankly, I am still not 100% sure what every number if supposed to represent (there are what, 6 different numbers for different kinds of alpha/opacity?). I worry I could've made some silly mistakes there.

I do believe that changes in this MR are an improvement, but I am not 100% convinced it's now totally correct, or that the "no need for backward compatibility" rules are kept.

Test Plan

Test file: luminosity_sai_test_007_small.kra

  • the strokes on the bottom should have nice, smooth edges and transitions, and nothing should be "blocky" there (it would be blocky before this MR).
  • the colors on the dark blue and light brown should be the same as on the comparison above (note: they are made by placing 10%, 20%, 30% opacity circles over blue and brown using lime green over brown and orange over blue, from the color circles above).

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.

Merge request reports