-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Magnifier cleanup #143558
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
Magnifier cleanup #143558
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
There were some other tests I forgot about that also changed a tiny bit. All the changes seem like improvements (less aggressive clipping, better antialiasing, etc). |
bleroux
left a comment
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.
Reading this for educational purposes and spotted some small nits.
This PR is a great improvement. I had never work on the magnifier, so I will let @justinmc approved it.
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.
nit: coordinate
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.
nit: redundant 'the'
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.
Consider fixing the formatting from line 26 to 30.
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.
LGTM with nits 👍 . Thanks for the cleanup.
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.
Thanks for explaining this stuff in the docs, I remember it being very tricky when implemented.
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.
Nit: Would this be any better as a "See also"?
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.
I tried both ways... I sort of felt like "see also" made it seem less immediately relevant, more of a "if you're browsing, you may also like these things" as opposed to "there's more to read on this right now, over there".
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.
Sounds good to me!
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.
You've needed these two constants in your own code?
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.
@visibleForTesting doesn't really do anything. It's just sort of a way for us to forgive ourselves exposing suboptimal public APIs. It's best to just own that the thing is a public API.
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.
Should we mention that in the styleguide? I have definitely added a few visibleForTestings into the codebase 😁 .
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.
good idea, added a section on that.
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.
Why are two pumps needed, and why 2 seconds?
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.
The first pump triggers the animations, the second ends them (two seconds is just "long enough to make sure all animations have finished"). This replaces "pumpAndSettle", which is generally a very sketchy way to do the same thing. ("pumpAndSettle" will fail to catch bugs where we require multiple frames to trigger or end an animation sequence. In general tests should never use "pumpAndSettle" unless they are verifying the return value.)
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.
Another thing to add to the styleguide? I have always tried to prefer pumpAndSettle because I thought it was actually more robust.
I feel like I'm confessing all my sins here on this review.
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.
It's already in the API docs for pumpAndSettle ("In general, it is better practice to figure out exactly why each frame is needed, and then to pump exactly as many frames as necessary. This will help catch regressions where, for instance, an animation is being started one frame later than it should."), but I'll add something to the style guide too. :-)
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.
Any value in using a macro here for deduplicating the docs on CupertinoMagnifier.shadows? If they're not subtly different.
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.
they're actually more than just subtly different, they're sort of opposites of each other (at least in terms of defaults).
(Also and this is maybe more of a dubious point but so much of what I fixed in this PR was overzealous use of templates making the docs actively worse that I'm kind of reluctant to use them at all!)
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.
I never thought of testing theses kinds of methods but I should 👍
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.
Good idea 👍
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.
I'll miss "donut" but that does sound better and more generic 🍩
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.
well also it stopped looking like a donut once i made it use an infinite rectangle instead of just growing the path to just enough to cover everything. :-)
Thanks for your comments @bleroux! Good catches! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Blocked on #144643 |
The new code path triggers a bug in Impeller in one of the golden images. Basically a part of the image is missing. edit: looks like the disabled test is unaffected by this PR |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
7ff81d0 to
3422b23
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
The problems above were caused by my misunderstanding gold. Submitted a new commit to hopefully get new results. |
This comment was marked as outdated.
This comment was marked as outdated.
- Introduces the ability to control whether RawMagnifier uses a clip on its decoration. (It still has to use a clip for its magnified image.) - Uses `BlurStyle.outer` to remove the clip for CupertinoMagnifier. - Many changes to the documentation around magnifiers and shadows. - Implements `BoxShadow.copyWith` which somehow we had never needed before. - Makes `debugDisableShadows` handle `BlurStyle.outer` correctly. - Adds `MagnifierInfo.toString`. - Aligns various `operator ==`s with the style guide. - Makes MagnifierDecoration a separate concept from Decoration, since it's not actually compatible anywhere. - Removes some dead code and makes other minor code simplifications. - Uses double syntax rather than integer syntax for various double literals for clarity.
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| top: magnifierPosition.dy + magnifierFocalPoint.dy, | ||
| child: Container( | ||
| color: Colors.pink, | ||
| color: Colors.black, |
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.
Were these color changes just for better visibility?
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.
yeah. i was fighting this particular golden image test for weeks and needed to sanity check that the image was actually updating (it wasn't! until it was).
flutter/flutter@e868e2b...ac2ca93 2024-04-04 [email protected] Roll Flutter Engine from aadf522e3c98 to 4303dc0d7a73 (1 revision) (flutter/flutter#146262) 2024-04-04 [email protected] Roll Flutter Engine from c57c8665b4eb to aadf522e3c98 (1 revision) (flutter/flutter#146261) 2024-04-04 [email protected] Roll Flutter Engine from ca7596642cfd to c57c8665b4eb (1 revision) (flutter/flutter#146259) 2024-04-04 [email protected] Roll Flutter Engine from 83c037c449b5 to ca7596642cfd (1 revision) (flutter/flutter#146258) 2024-04-04 [email protected] Roll Flutter Engine from 614154012e93 to 83c037c449b5 (1 revision) (flutter/flutter#146255) 2024-04-04 [email protected] Roll Flutter Engine from 41da00ac46bc to 614154012e93 (1 revision) (flutter/flutter#146250) 2024-04-04 [email protected] Roll Flutter Engine from 18fdcad40332 to 41da00ac46bc (6 revisions) (flutter/flutter#146246) 2024-04-04 [email protected] Roll pub packages (flutter/flutter#146245) 2024-04-03 [email protected] Add tests for theme_extension.1.dart API example. (flutter/flutter#145819) 2024-04-03 [email protected] Roll Flutter Engine from 349608d2b008 to 18fdcad40332 (6 revisions) (flutter/flutter#146240) 2024-04-03 [email protected] Add `missing_code_block_language_in_doc_comment` lint. (flutter/flutter#145354) 2024-04-03 [email protected] Magnifier cleanup (flutter/flutter#143558) 2024-04-03 [email protected] Set up Kotlin linting step in ci with ktlint (flutter/flutter#143478) 2024-04-03 [email protected] Roll Flutter Engine from 1a9e48ab1c9a to 349608d2b008 (1 revision) (flutter/flutter#146230) 2024-04-03 [email protected] Update ownership to GitHub handles (flutter/flutter#146221) 2024-04-03 [email protected] Roll Flutter Engine from d065763b1a63 to 1a9e48ab1c9a (1 revision) (flutter/flutter#146226) 2024-04-03 [email protected] Refactor fuchsia_precache (flutter/flutter#145978) 2024-04-03 [email protected] Roll Flutter Engine from b1c23addaec5 to d065763b1a63 (1 revision) (flutter/flutter#146218) 2024-04-03 [email protected] `computeDryBaseline` for rendering / widgets RenderBoxes (flutter/flutter#146143) 2024-04-03 [email protected] Roll Flutter Engine from 7b28ae1d15cb to b1c23addaec5 (1 revision) (flutter/flutter#146214) 2024-04-03 [email protected] Fix TextStyle.lerp() to properly interpolate text shadows (flutter/flutter#145666) 2024-04-03 [email protected] Renderflex cross intrinsic size with baseline alignment (flutter/flutter#146185) 2024-04-03 [email protected] Roll Flutter Engine from 56fa2c33a5f7 to 7b28ae1d15cb (1 revision) (flutter/flutter#146208) 2024-04-03 [email protected] Refactor customer_testing (flutter/flutter#145911) 2024-04-03 [email protected] Add `DropdownMenu` cursor behavior sample (flutter/flutter#146133) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/flutter@e868e2b...ac2ca93 2024-04-04 [email protected] Roll Flutter Engine from aadf522e3c98 to 4303dc0d7a73 (1 revision) (flutter/flutter#146262) 2024-04-04 [email protected] Roll Flutter Engine from c57c8665b4eb to aadf522e3c98 (1 revision) (flutter/flutter#146261) 2024-04-04 [email protected] Roll Flutter Engine from ca7596642cfd to c57c8665b4eb (1 revision) (flutter/flutter#146259) 2024-04-04 [email protected] Roll Flutter Engine from 83c037c449b5 to ca7596642cfd (1 revision) (flutter/flutter#146258) 2024-04-04 [email protected] Roll Flutter Engine from 614154012e93 to 83c037c449b5 (1 revision) (flutter/flutter#146255) 2024-04-04 [email protected] Roll Flutter Engine from 41da00ac46bc to 614154012e93 (1 revision) (flutter/flutter#146250) 2024-04-04 [email protected] Roll Flutter Engine from 18fdcad40332 to 41da00ac46bc (6 revisions) (flutter/flutter#146246) 2024-04-04 [email protected] Roll pub packages (flutter/flutter#146245) 2024-04-03 [email protected] Add tests for theme_extension.1.dart API example. (flutter/flutter#145819) 2024-04-03 [email protected] Roll Flutter Engine from 349608d2b008 to 18fdcad40332 (6 revisions) (flutter/flutter#146240) 2024-04-03 [email protected] Add `missing_code_block_language_in_doc_comment` lint. (flutter/flutter#145354) 2024-04-03 [email protected] Magnifier cleanup (flutter/flutter#143558) 2024-04-03 [email protected] Set up Kotlin linting step in ci with ktlint (flutter/flutter#143478) 2024-04-03 [email protected] Roll Flutter Engine from 1a9e48ab1c9a to 349608d2b008 (1 revision) (flutter/flutter#146230) 2024-04-03 [email protected] Update ownership to GitHub handles (flutter/flutter#146221) 2024-04-03 [email protected] Roll Flutter Engine from d065763b1a63 to 1a9e48ab1c9a (1 revision) (flutter/flutter#146226) 2024-04-03 [email protected] Refactor fuchsia_precache (flutter/flutter#145978) 2024-04-03 [email protected] Roll Flutter Engine from b1c23addaec5 to d065763b1a63 (1 revision) (flutter/flutter#146218) 2024-04-03 [email protected] `computeDryBaseline` for rendering / widgets RenderBoxes (flutter/flutter#146143) 2024-04-03 [email protected] Roll Flutter Engine from 7b28ae1d15cb to b1c23addaec5 (1 revision) (flutter/flutter#146214) 2024-04-03 [email protected] Fix TextStyle.lerp() to properly interpolate text shadows (flutter/flutter#145666) 2024-04-03 [email protected] Renderflex cross intrinsic size with baseline alignment (flutter/flutter#146185) 2024-04-03 [email protected] Roll Flutter Engine from 56fa2c33a5f7 to 7b28ae1d15cb (1 revision) (flutter/flutter#146208) 2024-04-03 [email protected] Refactor customer_testing (flutter/flutter#145911) 2024-04-03 [email protected] Add `DropdownMenu` cursor behavior sample (flutter/flutter#146133) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
|
Thanks for this PR, and thanks for reverse engineering some of the details I didn't understand. I must confess that some of my sins in the loupe haunt me - in two-year retrospect, I would have done a lot differently - I guess they call that "learning" 😄. |
|
No worries! The magnifier has served us pretty well over the last few years. If it weren't for you, it would probably still be in my backlog. |
BlurStyle.outerto remove the clip for CupertinoMagnifier.BoxShadow.copyWithwhich somehow we had never needed before.debugDisableShadowshandleBlurStyle.outercorrectly.MagnifierInfo.toString.operator ==s with the style guide.I expect one minor golden image change (antialiasing change on Cupertino's magnifier test).