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] Round out extreme angles between curve polyline segments. #53210

Merged
merged 5 commits into from
Jun 6, 2024

Conversation

bdero
Copy link
Member

@bdero bdero commented Jun 5, 2024

Resolves flutter/flutter#137956.

Detect when the angle between two curve segments is > 10 degrees and insert smoothing geometry if so. See this comment for the full rationale behind this change.

    Paint paint = Paint()
      ..color = Colors.white
      ..strokeWidth = 50
      ..strokeCap = StrokeCap.round
      ..strokeJoin = StrokeJoin.round
      ..style = PaintingStyle.stroke;

    Path path = Path();
    path.moveTo(0, 0);
    path.quadraticBezierTo(100, 100, 0, 0);
    canvas.drawPath(path, paint);

Before:
image

After:
image

@bdero bdero self-assigned this Jun 5, 2024
@bdero bdero marked this pull request as ready for review June 6, 2024 18:14
@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 #53210 at sha 4aea5ec

@bdero
Copy link
Member Author

bdero commented Jun 6, 2024

Hmm, looks like this fix introduces a regression with CanRenderStrokePathThatEndsAtSharpTurn

image

@bdero
Copy link
Member Author

bdero commented Jun 6, 2024

5 degrees was way too sensitive a threshold. Bumped down to 10 degrees as it was attempting to smooth out pretty much everything.

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!

/// values when generating stroke geometry. For performance reasons,
/// it's sometimes adventageous to track the direction and magnitude
/// for offsets separately.
struct Ray {
Copy link
Member

Choose a reason for hiding this comment

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

This could perhaps go in //impeller/geometry.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not opposed to throwing this in geometry. I'll do so in a follow-up. Also occurs to me that Ray is an inaccurate name for this... Should be something like SeparatedVector2.

@bdero bdero force-pushed the bdero/stroke-curve-roundout branch from 2971251 to 59adb6b Compare June 6, 2024 20:21
@flutter-dashboard
Copy link

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

Changes reported for pull request #53210 at sha 59adb6b

@bdero bdero merged commit 1230eec into flutter:main Jun 6, 2024
26 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 6, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 7, 2024
…149865)

flutter/engine@5a0a499...fea8e51

2024-06-06 [email protected] Roll Dart SDK from 8e05acb354f5 to ed2b917b266d (1 revision) (flutter/engine#53262)
2024-06-06 [email protected] [Impeller] Round out extreme angles between curve polyline segments. (flutter/engine#53210)

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://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
auto-submit bot pushed a commit that referenced this pull request Jun 8, 2024
Follow-up for #53210.

Also rename from `Ray` to `SeparatedVector2`, which is a more accurate name for what it is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Impeller] Drawing lines does not add round cap
3 participants