Improve blur effect accuracy
Analogously to drop shadows in #2548, allow blurs to be applied to composition and image layers using the new OffscreenLayer.
Rename applyShadowToLayers to applyEffectsToLayers and use it for both of these effects. Keep externally-facing applyShadowToLayers and forward to applyEffectsToLayers for backwards compat.
Undo the layer transform when computing the radius of a blur effect, similarly as we do for shadows.
Use fast hardware blur using RenderEffect if possible, and otherwise delegate to a "reasonably fast" box-blur implementation on the CPU.
This is not the final version. Still to do:
- Try to optimize FastBlur more
- Check behavior on existing testcases to ensure no regressions
- Match the scaling constants between implementations to ensure the blur appears the same as in lottie-web, the same with
applyEffectsToLayersand without, and the same with hardware vs software implementation of blur.
Thanks so much, @gpeal! Looking at some last remaining render diffs - I think I shouldn't have changed this rounding: https://github.com/airbnb/lottie-android/pull/2571/files#diff-f59159579cb60a5c96b48c67ce22f4efb9c861bac8d83d3a9361a63f5797a7a8R398, so will probably revert that back, check with another snapshot run and then I'm completely ok to merge. Thanks again for the quick eyes on this!
@geomaster Would you like to get this across the finish line?
Hey @gpeal, that would be good - I got caught up in a whirlwind of other work at the time and neglected this PR. I'll see if I can take a quick look in the following few days, I think it's pretty much ready. Thanks for reminding me!