Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cbenhagen
Copy link
Contributor

Description

Completing the fix started in #22945

/cc @hterkelsen @yjbanov

Related Issues

Fixes flutter/flutter#61290

Tests

I added the following tests: TBD

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Reviewer Checklist

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

final Matrix4 scaleMatrix =
Matrix4.diagonal3Values(inverseScale, inverseScale, 1);
headTransform.multiply(scaleMatrix);
headTransform = scaleMatrix.multiplied(headTransform);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we initialize headTransform to Matrix4.diagonal3Values(inverseScale, inverseScale, 1) instead of applying the scaled transform at the end? This should eliminate 2 extra matrix allocations (Matrix4.identity() and scaleMatrix.multiplied).

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The headTransform was 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 :)

Copy link
Contributor Author

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.

Copy link
Contributor

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!

@chinmaygarde chinmaygarde added the platform-web Code specifically for the web engine label Jan 7, 2021
@yjbanov
Copy link
Contributor

yjbanov commented Jan 8, 2021

Closing the PR to start a new one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web] [CanvasKit] FittedBox misplaces HtmlElementView

4 participants