-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve blur effect accuracy #2571
base: master
Are you sure you want to change the base?
Conversation
Be more careful about the sigma->radius conversion, blur propagation, and don't forget to undo the pre-existing scale for the RenderEffect impl. It seems that all implementations of blur we have now - mask filter, CPU blur, and RenderEffect blur - look mostly the same.
Based on the old box blur algorithm with a running sum, write a new one that is more readable and more performant, due mostly to avoiding the use of Bitmap.getPixels() and Bitmap.setPixels(). The blur is still, well, boxy, which we will probably be able to fix by stacking two invocations of it, or trying some trickery to approximate the Guassian kernel better but still keeping the linear time complexity.
Seems to provide slightly better perf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM! We can merge through the API compat check because I don't have a good solution yet. Let me know if this is ready to merge on your end!
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! |
Analogously to drop shadows in #2548, allow blurs to be applied to composition and image layers using the new
OffscreenLayer
.Rename
applyShadowToLayers
toapplyEffectsToLayers
and use it for both of these effects. Keep externally-facingapplyShadowToLayers
and forward toapplyEffectsToLayers
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:
applyEffectsToLayers
and without, and the same with hardware vs software implementation of blur.