[go: nahoru, domu]

Skip to content
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

[Impeller] make sure to render TiledTextureContents if the geometry doesn't fit in the texture's bounds. #51393

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

gaaclarke
Copy link
Member
@gaaclarke gaaclarke commented Mar 13, 2024

fixes flutter/flutter#144836

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 and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@gaaclarke
Copy link
Member Author

@bdero @jonahwilliams friendly ping

Comment on lines +231 to +236
std::optional<Rect> geometry_coverage = GetGeometry()->GetCoverage({});
if (GetInverseEffectTransform().IsIdentity() &&
GetGeometry()->IsAxisAlignedRect()) {
GetGeometry()->IsAxisAlignedRect() &&
(!geometry_coverage.has_value() ||
Rect::MakeSize(texture_->GetSize())
.Contains(geometry_coverage.value()))) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't fully understand this, could you explain it a bit more? I know for the regular texture contents we have some src/dst checking.

Since tiled texture contents is an arbitrary geometry, we have the axis aligned rect check first. What is the additional check doing?

Copy link
Member Author

Choose a reason for hiding this comment

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

When the geometry is not contained in the texture that means we have to render texcoords outside of 0..1, so we can't take the fast pass of avoiding rendering. We need the clamping, decal, etc.

If you check out the issue this is where we could hack this conditional to give us the correct result by sending in Scale(1.001, 1.001, 1) instead of Identity() for the effect transform because the fast pass conditional was incorrectly ignoring the geometry and the full render was correct.

Copy link
Member

Choose a reason for hiding this comment

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

But isn't that expressed in the coverage and the scaling below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Demonstrably, no. If you run the golden test without this patch it will render with the incorrect texture coords, instead stretching them to fill the whole geometry. That flow through the code lacks the math the express the effect transform correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think since the effect transform was identity it was assumed it could be ignored, but it's not the case when the geometry is expanded.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I agree its not working! But, this code should be able to render a stretched rectangle right? It seems like there is a bug in the math there that we could fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

I played around with it again and I don't think so. The Snapshot flow lacks the expressivity to represent rendering texcoords outside of 0..1. It's not a bug, but a limit of the abstraction. That's why it only works when rendering a subset inside of the texture.

If you set the scale to 1.0 you can see it renders at the correct size without the halo we need and there is no lever to pull to make it appear.

We can file an issue to redesign Snapshot it will probably require having a matrix for the uvs and the vertices?

Copy link
Member

Choose a reason for hiding this comment

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

Ack. The snapshot has a transform, but it assumes a srcRect. We could add support for that, but it isn't necessary here.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #51393 at sha 47f185f

Copy link
Member
@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

Would you file a bug to add this feature to the Snapshot?

@gaaclarke
Copy link
Member Author

LGTM

Would you file a bug to add this feature to the Snapshot?

done flutter/flutter#145328

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2024
@auto-submit auto-submit bot merged commit 639d21a into flutter:main Mar 18, 2024
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 18, 2024
…145336)

flutter/engine@89fb886...9162c83

2024-03-18 68449066+zijiehe-google-com@users.noreply.github.com [Fuchsia] only download fuchsia deps when necessary (flutter/engine#51439)
2024-03-18 30870216+gaaclarke@users.noreply.github.com [Impeller] make sure to render TiledTextureContents if the geometry doesn't fit in the texture's bounds. (flutter/engine#51393)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC bdero@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
None yet
2 participants