lottie-android icon indicating copy to clipboard operation
lottie-android copied to clipboard

Improve blur effect accuracy

Open geomaster opened this issue 1 year ago • 7 comments

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 applyEffectsToLayers and without, and the same with hardware vs software implementation of blur.

geomaster avatar Nov 04 '24 19:11 geomaster

Snapshot Tests API 23: Report Diff API 31: Report Diff

github-actions[bot] avatar Nov 05 '24 00:11 github-actions[bot]

Snapshot Tests API 23: Report Diff API 31: Report Diff

github-actions[bot] avatar Nov 06 '24 17:11 github-actions[bot]

Snapshot Tests API 23: Report Diff API 31: Report Diff

github-actions[bot] avatar Nov 08 '24 04:11 github-actions[bot]

Snapshot Tests API 23: Report Diff API 31: Report Diff

github-actions[bot] avatar Nov 11 '24 20:11 github-actions[bot]

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 avatar Nov 12 '24 20:11 geomaster

@geomaster Would you like to get this across the finish line?

gpeal avatar Mar 02 '25 20:03 gpeal

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!

geomaster avatar Mar 06 '25 12:03 geomaster