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

[Impeller] Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. #45252

Merged
merged 9 commits into from
Sep 13, 2023

Conversation

chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Aug 29, 2023

Fixes flutter/flutter#133032

The issue is that when we draw a line we always try to draw a complete rectangle from point 1 to point2 before drawing the join and the next line
Untitled drawing (7)

This becomes a problem if there is a sharp turn
Untitled drawing (6)

Untitled drawing (5)

Notice there will be a slight over drawing at the bottom.

The solution then is to not draw the rect first before drawing the join. It will be the join's responsibility to draw the complete the rect from the line start to the join.

This should also save a lot of repeatedly drawing during the join
rect

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 Hixie said 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.

@chinmaygarde chinmaygarde changed the title Fixes stroke path geometry that can draw outside of path if the path … Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. Aug 29, 2023
builder.AddArc(rect, Degrees(0), Degrees(90), false);

canvas.DrawPath(builder.TakePath(), paint);
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
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 too familiar with the code, let me know if this is enough to set up golden test.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, this is the correct way to add a golden. 👍

@chunhtai chunhtai requested a review from chinmaygarde August 30, 2023 20:45
@chunhtai chunhtai marked this pull request as ready for review August 30, 2023 21:11
vtx.position = polyline.points[point_i - 1] + offset;
vtx_builder.AppendVertex(vtx);
vtx.position = polyline.points[point_i - 1] - offset;
vtx_builder.AppendVertex(vtx);
vtx.position = polyline.points[point_i] + offset;
Copy link
Contributor Author

@chunhtai chunhtai Aug 30, 2023

Choose a reason for hiding this comment

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

This was where the complete rect is drawn. This part is now handle by the join when then draw the first pair of inner miter point and outer

@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 #45252 at sha 018c24d

@chunhtai
Copy link
Contributor Author

oops looks like the golden has failed

@chunhtai chunhtai marked this pull request as draft August 30, 2023 21:15
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

@chunhtai chunhtai force-pushed the issues/133032 branch 2 times, most recently from 7b9dc01 to bff1fa2 Compare September 1, 2023 18:38
@chunhtai chunhtai marked this pull request as ready for review September 1, 2023 18:38
@chunhtai chunhtai changed the title Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. [WIP]Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. Sep 1, 2023
@chunhtai chunhtai removed the request for review from chinmaygarde September 1, 2023 18:38
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #45252 at sha bff1fa2

@chinmaygarde chinmaygarde added the Work in progress (WIP) Not ready (yet) for review! label Sep 1, 2023
@chinmaygarde chinmaygarde requested a review from bdero September 1, 2023 20:42
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #45252 at sha e273a81

@chunhtai chunhtai removed the Work in progress (WIP) Not ready (yet) for review! label Sep 1, 2023
@chunhtai chunhtai changed the title [WIP]Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. Sep 1, 2023
@chunhtai
Copy link
Contributor Author

chunhtai commented Sep 1, 2023

The circle golden is missing a tiny tiny slide of pixels which i think won't affect the real world pixel, but let me know if this is a problem

@bdero This is ready for review now

@chinmaygarde chinmaygarde changed the title Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. [Impeller] Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. Sep 5, 2023
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

LGTM but @bdero is more familiar with this code and may have thoughts.

Thanks so much!

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

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

This patch introduces regressions with most strokes (visible in EntityTest.StrokeCapAndJoinTest).

@bdero
Copy link
Member

bdero commented Sep 5, 2023

Screen.Recording.2023-09-05.at.12.01.38.PM.mov

@chunhtai
Copy link
Contributor Author

I also added a new golden test that similar to the cubic component playground

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #45252 at sha ef08968

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

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

EntityTest.StrokeCapAndJoinTest still doesn't look right. This is the line I use to build and run it:

autoninja -C ../out/host_debug_unopt/ -j 1000 flutter/impeller:impeller_unittests && ../out/host_debug_unopt/impeller_unittests --timeout=0 --gtest_filter="Play/EntityTest.StrokeCapAndJoinTest/Metal" --enable_playground

Screenshot 2023-09-13 at 10 11 29 AM

@bdero
Copy link
Member

bdero commented Sep 13, 2023

Ah hold on one sec, I think I screwed up the checkout locally.

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks a lot for your work on this! :)

@bdero
Copy link
Member

bdero commented Sep 13, 2023

The goldens are looking good and I marked them as positive.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 13, 2023
@auto-submit auto-submit bot merged commit 343dfe8 into flutter:main Sep 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 13, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 13, 2023
…134683)

flutter/engine@b71b366...154d6fd

2023-09-13 [email protected] Auto update dependencies for web_ui. (flutter/engine#45754)
2023-09-13 [email protected] Revert "[Impeller] Patch the compiler to account for subpass inputs and PSO metadata." (flutter/engine#45777)
2023-09-13 [email protected] Roll Skia from 471216072c74 to e39cf360ea93 (4 revisions) (flutter/engine#45776)
2023-09-13 [email protected] [Impeller] Remove dependency on //flutter/vulkan and use a single proc table. (flutter/engine#45741)
2023-09-13 [email protected] Roll Skia from 78d18d509475 to 471216072c74 (4 revisions) (flutter/engine#45774)
2023-09-13 [email protected] [Impeller] Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. (flutter/engine#45252)

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 [email protected],[email protected],[email protected] 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
chunhtai added a commit to chunhtai/engine that referenced this pull request Sep 27, 2023
…f path if the path ends at sharp turn. (flutter#45252)"

This reverts commit 343dfe8.
auto-submit bot pushed a commit that referenced this pull request Sep 27, 2023
#46334)

�f path if the path ends at sharp turn. (#45252)"

This reverts commit 343dfe8.

introduced a regression
flutter/flutter#135225

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…lutter#134683)

flutter/engine@b71b366...154d6fd

2023-09-13 [email protected] Auto update dependencies for web_ui. (flutter/engine#45754)
2023-09-13 [email protected] Revert "[Impeller] Patch the compiler to account for subpass inputs and PSO metadata." (flutter/engine#45777)
2023-09-13 [email protected] Roll Skia from 471216072c74 to e39cf360ea93 (4 revisions) (flutter/engine#45776)
2023-09-13 [email protected] [Impeller] Remove dependency on //flutter/vulkan and use a single proc table. (flutter/engine#45741)
2023-09-13 [email protected] Roll Skia from 78d18d509475 to 471216072c74 (4 revisions) (flutter/engine#45774)
2023-09-13 [email protected] [Impeller] Fixes stroke path geometry that can draw outside of path if the path ends at sharp turn. (flutter/engine#45252)

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 [email protected],[email protected],[email protected] 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
#46334)

�f path if the path ends at sharp turn. (#45252)"

This reverts commit 343dfe8.

introduced a regression
flutter/flutter#135225

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Impeller] When the stroke width is equal to the diameter of the circle, the result of the drawn arc is incorrect
3 participants