This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we initialize
headTransformtoMatrix4.diagonal3Values(inverseScale, inverseScale, 1)instead of applying the scaled transform at the end? This should eliminate 2 extra matrix allocations (Matrix4.identity()andscaleMatrix.multiplied).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 am not sure if I fully understand what you mean. Please feel free to take over this PR and commit changes to my branch. I must confess, I merely applied the fix applied in #22945 without deep understanding of how this all fits together.
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
headTransformwas IDENTITY x T1 x T2 x ... x Tk x inverseScale. After this change it becomes inverseScale x IDENTITY x T1 x T2 x ... x Tk, which means we can remove IDENTITY and start with inverseScale. But the devil is probably in the detail. For example, if there's a clipping transform we reset it back to IDENTITY. I'm wondering if applying the scale at the end works in the presence of clips at all. If I'm reading the code correctly, it seems it doesn't?Example: T1 > CLIP1 > T2 becomes T1 > CLIP1 > inverseScale > T2, but should probably be inverseScale > T1 > CLIP1 > T2. IIUC the inverseScale is there to undo the top-level transform that the flutter framework injects in https://github.com/flutter/flutter/blob/47bad77287effb3467f27937884036f51da6e325/packages/flutter/lib/src/rendering/view.dart#L144, so in order to undo that we should apply the inverse at the top level too.
I can take it over if you'd like, but also happy to provide guidance. I think we also need @hterkelsen's thoughts on this to make sure we're not breaking it altogether :)
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.
Yes please take it over. Feel free to close this and create a separate PR or just push to my branch.
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.
SGTM. I'll start a new PR. Thanks for discovering the bug!