Implement UberSDF lines to replace LineContents-based AA lines by b-luk · Pull Request #188514 · flutter/flutter · GitHub
Skip to content

Implement UberSDF lines to replace LineContents-based AA lines#188514

Open
b-luk wants to merge 2 commits into
flutter:masterfrom
b-luk:ubersdflines
Open

Implement UberSDF lines to replace LineContents-based AA lines#188514
b-luk wants to merge 2 commits into
flutter:masterfrom
b-luk:ubersdflines

Conversation

@b-luk

@b-luk b-luk commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Implements UberSDF lines, which are drawn by making an UberSDF rect or roundrect and applying a translation/rotation transform.

Fixes #188329

After this, LineContents can be removed entirely. I will do this in a follow-up to keep this PR focused on the UberSDF line implementation.

Adds a new golden test that draws lines with varying caps/angles/opacities.
Before:
Screenshot 2026-06-24 at 10 46 48 AM

After:
Screenshot 2026-06-24 at 10 47 56 AM

Pre-launch Checklist

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

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 24, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces line rendering using the UberSDF pipeline in Impeller, adding support for different stroke caps (butt, square, and round) and applying shape transforms to SDF entities. It also includes corresponding unit tests. Feedback points out a compilation issue in canvas.cc where Matrix::Invert() returns a std::optional<Matrix> but is passed directly to SetEffectTransform which expects a Matrix type.

Comment thread engine/src/flutter/impeller/display_list/canvas.cc
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 24, 2026
@b-luk b-luk added the CICD Run CI/CD label Jun 24, 2026
@b-luk b-luk requested a review from gaaclarke June 24, 2026 18:20

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks good to me. I want to see the goldens to double check what existing coverage we have for this. The test might be a duplicate. I know we have something like this but it may be lines with gradients on them?

It would be interesting to consider what difference we'd have if we used the sdOrientedBox sdf for these cases. Is this suboptimal to that?

With respect to deleting the old line renderer. We might want to consider keeping it since it has a lower bar for execution on mobile devices. The case against it is that we've never had enough motivation to switch it over. Let's look at the old issue that introduced it and the PR. If i remember correctly we had a nice before and after shot and these do look better in a meaningful way. Maybe it's worth finally promoting that (and fixing this bug for it).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does this relate to our existing line drawing tests? Seems like this should have existed but maybe it was overlooked in the line rendering change. I guess we'll potentially see when the golden results come.

Comment on lines +781 to +782
if ((renderer_.GetContext()->GetFlags().use_sdfs ||
renderer_.GetContext()->GetFlags().antialiased_lines) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no action required: The antialias line rendering is a lot more faster than the ubersdf. I wonder if we should keep it around since we could use that on mobile. We never have though and there is this bug in it.

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 24, 2026
@b-luk b-luk added the CICD Run CI/CD label Jun 24, 2026
@b-luk

b-luk commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

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

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

canvas.drawLine with opacity rendering regression on macOS and Windows

2 participants