[cupertino_ui] Reuse a single Paint in _CupertinoEdgeShadowPainter - #12304
[cupertino_ui] Reuse a single Paint in _CupertinoEdgeShadowPainter#12304fa0311 wants to merge 1 commit into
Paint in _CupertinoEdgeShadowPainter#12304Conversation
The edge shadow of a Cupertino page transition is drawn as ~20 1px-wide rects per frame, each allocating a fresh Paint. Hoist the Paint out of the loop and only update its color, matching the pattern used by _CupertinoActivityIndicatorPainter.
There was a problem hiding this comment.
Code Review
This pull request optimizes the _CupertinoEdgeShadowPainter in route.dart by instantiating a single Paint object outside the loop and reusing it, rather than allocating a new object for each iteration. Additionally, the package version is bumped to 0.0.3 in pubspec.yaml and the change is documented in CHANGELOG.md. There are no review comments, and I have no feedback to provide.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
Hi @fa0311 thank you for the contribution. I am going to close this for now because we are not accepting PRs in these packages currently. We are still in the middle of the migration and ensuring the packages are complete before publishing and accepting contributions. Thank you. If you would like to re-open the PR you had in flutter/flutter, we'll be helping to port these PRs over when we are ready to start accepting contributions. |
The edge shadow of a Cupertino page transition is drawn as ~20 1px-wide rects per frame, each allocating a fresh
Paint. This runs on every frame of everyCupertinoPageRoutepush/pop and back-swipe. This PR hoists thePaintout of the loop and only updates its color per iteration, matching the pattern already used by_CupertinoActivityIndicatorPainter.Canvasdraw calls snapshot paint state, so mutating and reusing a singlePaintproduces identical output.Fixes flutter/flutter#190198. (Originally submitted to flutter/flutter as flutter/flutter#190188, redirected here due to the Material/Cupertino decoupling code freeze, flutter/flutter#184093.)
This is a behavior-preserving refactor with no observable output change; existing tests in
packages/cupertino_ui/test/route_test.dartcover this code path and pass, so I believe this qualifies as test-exempt.Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2