Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New compositor pipeline for paintbrushes
I hadn't originally wanted to do this, given the complexity of PD's central compositor, but there's no escaping the performance benefits. The painting pipeline is just different enough to require some specific tweaks, particularly when it comes to compositing order (as we have to composite the paint stroke onto the target layer out-of-order), so we're gonna get better long-term performance with a dedicated paint compositor. At present, the brush stroke compositor uses a very similar strategy to the regular compositor. Specifically, it re-renders the entire brush area on every screen refresh. An obvious future optimization would be rendering only the regions of the brush layer that have changed, and when I have time, you can bet I'll tackle that! (The calculations for this are going to be a bit complicated, as we don't currently track any of this information... but the responsiveness benefits will likely be worth the trouble.) That said, performance of the current implementation is still surprisingly competitive with GIMP and Paint.NET on large multilayer images. Besides performance benefits, the new compositor pipeline correctly implements the behavior of painting on a layer with a non-standard opacity, blend mode, or alpha inheritance. The paint stroke and target layer are precomposited *first*, and the result is then blended using the current layer's settings. This gets complicated quickly as the paint brush can have its own opacity, blend mode, and alpha settings, but I believe everything is sorted. Unfortunately, PD's "merge layers" tool - which performs the final paint stroke merge when the mouse is released - does not behave identically. I'll be updating it shortly to support a "paint" mode, which has some different considerations from "normal" mode.
- Loading branch information