Skip to content

Fix destination atop rendering

Deif Lou requested to merge deiflou/krita:deiflou/destination_atop_fix into master

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):

atop_formula_1

After rearranging we get:

atop_formula_2

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:

atop_formula_3

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:

  1. Paint something in a transparent layer.
  2. Paint something else with a different color in another transparent layer on top of the previous, overlaping the two shapes.
  3. 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.

BUG:423465

Edited by Deif Lou

Merge request reports

Loading