mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
![]() This PR adds a fast blurring algorithm for `RSuperellipse`s with uniform corner radius, similar to `AttemptDrawBlurredRRect`. Fixes https://github.com/flutter/flutter/issues/163893. Fixes https://github.com/flutter/flutter/issues/167366. This approximate algorithm is implemented by adding additional retraction to RRect's algorithm. Since they share most the logic, much effort is made to ensure reasonable code share. I've also built a playground test `RoundSuperellipseShadowComparison` to compare the effect between the fast algorithm and the bruteforce algorithm, and added a macrobenchmark "rsuperellipse_blur". ### Result The following video shows the reproduction app from https://github.com/flutter/flutter/issues/167366, which shows much better framerate on RSE after the PR, almost the same as RRect. (I've verified that it was much worse without the PR.) https://github.com/user-attachments/assets/5433af91-c0a1-4b15-9161-cf2280543e27 The following video shows the `RoundSuperellipseShadowComparison` playground, which compares the fast algorithm (left) against the bruteforce algorithm (right). * Pay attention to the cases with small but non zero sigma. They should be of almost the same shape as those with zero sigma, which skips the blurring altogether. With this algorithm, the difference between the two cases are about 1~2 pixel at most. https://github.com/user-attachments/assets/e26d2d8f-d29e-4db8-9c20-67103d77891c The following images compare macrobenchmarks "rrect_blur" against the new "rsuperellipse_blur". (Notice that the avg frame time fluctuates a lot but at least it shows that they're on par.) <img width="389" alt="image" src="https://github.com/user-attachments/assets/67cf4b10-f13f-4e55-bdfd-35d358617f38" /> <img width="365" alt="image" src="https://github.com/user-attachments/assets/6869fa9c-5752-4a11-babe-b6a2d590ebc9" /> ### Open questions * Should I improve the code share of shader files? Currently they're not shared mostly because I'm not sure about its gain and cost. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md |
||
---|---|---|
.. | ||
src | ||
common.dart | ||
main.dart | ||
web_benchmarks_ddc.dart | ||
web_benchmarks.dart |