Fix destination atop rendering
This MR resolves bug 423465
The code for "destination atop" compositing has an extra multiplication.
Obtained result: https://imgur.com/a/tcIngTC
Expected result: https://imgur.com/a/HwOoBLk
Proof
The Porter-Duff formula for Destination Atop is as follows (as can be read in the original paper):
After rearranging we get:
The resulting alpha is just the alpha of the source.
The resulting color is premultiplied by the resulting alpha (which is the same as the source alpha) so if we divide by that we get the resulting color un-premultiplied:
As can be seen the resulting color is just a linear interpolation of the source and destination colors with the destination alpha as a weight.
Test Plan
Just open this test file or:
- Paint something in a transparent layer.
- Paint something else with a different color in another transparent layer on top of the previous, overlaping the two shapes.
- Choose "Destination Atop" blending mode on the layer on top.
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 Deif Lou