Skip to content

Implement square-like round superellipses with circular corners in the SDF uber shader#185370

Merged
auto-submit[bot] merged 16 commits into
flutter:masterfrom
walley892:sdf-round-se
Apr 25, 2026
Merged

Implement square-like round superellipses with circular corners in the SDF uber shader#185370
auto-submit[bot] merged 16 commits into
flutter:masterfrom
walley892:sdf-round-se

Conversation

@walley892

@walley892 walley892 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Adds support for square like Round Superellipses in the UberSDF shader.

Implemented by switching between a superellipse SDF and circular SDF depending on the test point's location.

This PR does not handle RoundSuperellipses with different x and y semi-axes, or RoundSuperellipses with non-circular corners.

May add some more goldens after checking coverage from the CICD run.

Fixes #185422

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Apr 21, 2026
@walley892 walley892 marked this pull request as ready for review April 21, 2026 20:50
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@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 implements Signed Distance Field (SDF) rendering for round superellipses. It introduces the kRoundSuperellipse type, adds the superellipse distance function to the uber_sdf.frag shader, and updates Canvas::DrawRoundSuperellipse to use the SDF path for compatible geometries. Feedback includes a request to use triple-slash documentation for public members to comply with the style guide and a suggestion to optimize the shader logic by simplifying the transition check between circular and superellipse regions.

Comment thread engine/src/flutter/impeller/entity/contents/uber_sdf_parameters.h Outdated
Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag Outdated
@walley892 walley892 added the CICD Run CI/CD label Apr 21, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 22, 2026
@gaaclarke gaaclarke added the CICD Run CI/CD label Apr 22, 2026

@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.

nice work, I can see us maybe wanting to use this all the time for performance reasons

Comment thread engine/src/flutter/impeller/display_list/canvas.cc
Comment thread engine/src/flutter/impeller/display_list/canvas.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/canvas.cc Outdated
Comment thread engine/src/flutter/impeller/entity/contents/uber_sdf_parameters.h Outdated
Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag Outdated
Comment thread engine/src/flutter/impeller/entity/contents/uber_sdf_parameters.h Outdated
Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag Outdated
Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 22, 2026
@walley892 walley892 added the CICD Run CI/CD label Apr 22, 2026

@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.

This is looking good to me, we have existing tests that cover this? LGTM as long as we have tests and the goldens look good.

@dkwingsmt dkwingsmt 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.

LGTM except for comments.

//
// https://iquilezles.org/articles/ellipsedist/
//
// The MIT License

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.

Should we make this part a separated file, so that the license header is applied to an unambiguous range?

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.

Yea, we plan on doing that. I had a pr but the file is in such flux I haven't gotten around to landing it yet.

Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag Outdated
Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 23, 2026
@walley892 walley892 added the CICD Run CI/CD label Apr 23, 2026
dkwingsmt
dkwingsmt previously approved these changes Apr 23, 2026

@dkwingsmt dkwingsmt 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.

LGTM. Thank you for the great work!

.circle_center = circle_center,
.circle_max_angle = circle_max_angle,
.circle_start_angle = circle_start_angle,
.circle_radius = R,

@dkwingsmt dkwingsmt Apr 23, 2026

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.

Isn't circle_start_angle equal to pi/2 - circle_max_angle? And R equal to the distance between the circle center and the bounds corner. I didn't add those two values because they could be simply derived from others.

I'm not against adding them if you find them useful, just concerned that the signature for MakeRoundedSuperellipse might be cleaner if duplicate information could be reduced.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh my goodness 🤦 , it's even worse. circle_start_angle is always just pi/4. Removed circle_start_angle from everything and hardcoded it into the shader.

I think the radius can be derived from distance(circle_center, circle_start). I'm kind of worried about leaking the math into the canvas more than we already are though. I'm inclined to leave it for now, and refactor later by changing the UberSDFParameter::MakeRoundedSuperellipse signature to UberSDFParameter::MakeRoundedSuperellipse(RoundSuperEllipseParam param) and throw the mathy details in there after seeing what things look like after implementing the non-square case.

Thoughts?

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.

Sounds good. We'll need a struct eventually if the plan to support asymetrical/uneven RSEs, since the four corners will have different params.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 23, 2026
@walley892 walley892 added the CICD Run CI/CD label Apr 23, 2026
@walley892 walley892 requested a review from dkwingsmt April 23, 2026 22:05
dkwingsmt
dkwingsmt previously approved these changes Apr 24, 2026
@walley892 walley892 added the CICD Run CI/CD label Apr 24, 2026
@walley892 walley892 requested a review from gaaclarke April 24, 2026 20:54
@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 24, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 25, 2026
Merged via the queue into flutter:master with commit 1d424a3 Apr 25, 2026
200 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 25, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Apr 28, 2026
…11595)

Manual roll Flutter from 31001886cbe8 to 61fca76dd523 (53 revisions)

Manual roll requested by tarrinneal@google.com

flutter/flutter@3100188...61fca76

2026-04-27 30870216+gaaclarke@users.noreply.github.com Adds integration test for the FLTEnableSDFs flag for iOS (flutter/flutter#185637)
2026-04-27 97480502+b-luk@users.noreply.github.com Fix sdfs being enabled for MacOS regardless of FLTEnableSDFs value (flutter/flutter#185565)
2026-04-27 97480502+b-luk@users.noreply.github.com Don't use UberSDF for paint with incompatible blend modes (flutter/flutter#184889)
2026-04-27 engine-flutter-autoroll@skia.org Roll Dart SDK from de495e3de9a0 to 941ca325cfc9 (2 revisions) (flutter/flutter#185653)
2026-04-27 jhy03261997@gmail.com [a11y] Add CONTENT_CHANGE_TYPE_EXPANDED support on android. (flutter/flutter#185305)
2026-04-27 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#185641)
2026-04-27 1063596+reidbaker@users.noreply.github.com Modify analyze.dart to have flags to run only or exclude each verification step.  (flutter/flutter#185618)
2026-04-27 meylis@divine.video Fix debugNeedsPaint/Layout/CompositedLayerUpdate crashing in release mode (flutter/flutter#184627)
2026-04-27 kallentu@google.com Enable `var_with_no_type_annotation` lint. (flutter/flutter#185215)
2026-04-27 53523825+JhonaCodes@users.noreply.github.com Fix SelectionArea handles overlapping context menu on Android (flutter/flutter#182663)
2026-04-27 30870216+gaaclarke@users.noreply.github.com Adds debugging information to compiled metal shaders (flutter/flutter#185629)
2026-04-27 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#185638)
2026-04-27 84978733+alejandro-all-win-software@users.noreply.github.com Use null-aware elements in dev/devicelab/lib/framework/browser.dart (flutter/flutter#184778)
2026-04-27 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#185633)
2026-04-27 31591868+zawhtetnaing10@users.noreply.github.com Added useOriginalColors flag which allows ImageIcon to bypass IconTheme colorization and use the original colors (flutter/flutter#180491)
2026-04-27 engine-flutter-autoroll@skia.org Roll Packages from 8400f71 to 23280da (2 revisions) (flutter/flutter#185619)
2026-04-27 engine-flutter-autoroll@skia.org Roll Skia from f1238e0f1022 to ce82d32b3e03 (1 revision) (flutter/flutter#185616)
2026-04-27 15619084+vashworth@users.noreply.github.com [SwiftPM] Enable package resolution on xcodebuild commands (flutter/flutter#185208)
2026-04-27 chris@bracken.jp [iOS] Refactor keyboard inset logic into FlutterKeyboardInsetManager (flutter/flutter#185535)
2026-04-27 matej.knopp@gmail.com [Win32] FlutterDesktopEngineGetGraphicsAdapter should use out parameter (flutter/flutter#185590)
2026-04-27 engine-flutter-autoroll@skia.org Roll Skia from d77e3356d526 to f1238e0f1022 (4 revisions) (flutter/flutter#185604)
2026-04-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from flsn8jC4LkTn6WECf... to i6d0NoDueUiXpePfX... (flutter/flutter#185601)
2026-04-26 engine-flutter-autoroll@skia.org Roll Dart SDK from a108dfe2d227 to de495e3de9a0 (1 revision) (flutter/flutter#185599)
2026-04-26 engine-flutter-autoroll@skia.org Roll Skia from ce9aa2231292 to d77e3356d526 (1 revision) (flutter/flutter#185596)
2026-04-26 engine-flutter-autoroll@skia.org Roll Skia from 622fff4c24d2 to ce9aa2231292 (1 revision) (flutter/flutter#185588)
2026-04-25 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 9fPnyEo9PaNdXtasl... to flsn8jC4LkTn6WECf... (flutter/flutter#185585)
2026-04-25 engine-flutter-autoroll@skia.org Roll Dart SDK from 605a8faf0dda to a108dfe2d227 (1 revision) (flutter/flutter#185584)
2026-04-25 engine-flutter-autoroll@skia.org Roll Dart SDK from 6b8c39765f17 to 605a8faf0dda (1 revision) (flutter/flutter#185578)
2026-04-25 engine-flutter-autoroll@skia.org Roll Skia from 185f6b57d64f to 622fff4c24d2 (1 revision) (flutter/flutter#185573)
2026-04-25 evanwall@buffalo.edu Implement square-like round superellipses with circular corners in the SDF uber shader (flutter/flutter#185370)
2026-04-25 victorsanniay@gmail.com Add @awaitNotRequired annotation to flutter sdk (flutter/flutter#181513)
2026-04-25 engine-flutter-autoroll@skia.org Roll Dart SDK from 01228cb7af42 to 6b8c39765f17 (2 revisions) (flutter/flutter#185569)
2026-04-25 flar@google.com Adapt the DisplayList benchmarks into a primitive rendering benchmark suite (flutter/flutter#185270)
2026-04-25 okorohelijah@google.com Enable SPM for GoogleMobileAds (flutter/flutter#185548)
2026-04-25 engine-flutter-autoroll@skia.org Roll Skia from 3f467a581942 to 185f6b57d64f (1 revision) (flutter/flutter#185564)
2026-04-25 victorsanniay@gmail.com Fix Table crash when a cell child paints below the row bottom (flutter/flutter#185323)
2026-04-24 ahmedsameha1@gmail.com Make sure that an Image doesn't crash in 0x0 environment (flutter/flutter#181154)
2026-04-24 engine-flutter-autoroll@skia.org Roll Skia from 300d432048b0 to 3f467a581942 (3 revisions) (flutter/flutter#185558)
2026-04-24 engine-flutter-autoroll@skia.org Roll Dart SDK from c26627715892 to 01228cb7af42 (4 revisions) (flutter/flutter#185559)
2026-04-24 jacksongardner@google.com Reland "[web] Fix LateInitializationError in CkSurface and SkwasmSurface (#185116)" (flutter/flutter#185553)
2026-04-24 41930132+hellohuanlin@users.noreply.github.com [github]fix git ls-file glob pattern in labeler.yml instruction (flutter/flutter#185495)
2026-04-24 41930132+hellohuanlin@users.noreply.github.com [ios]update ios-reviewers tags to include more files (flutter/flutter#185490)
2026-04-24 tomac@google.com Add initial support for Cross-Origin Storage (flutter/flutter#184149)
2026-04-24 30870216+gaaclarke@users.noreply.github.com tool: Skip cached engine artifacts with local engine (flutter/flutter#185546)
...
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…lutter#11595)

Manual roll Flutter from 31001886cbe8 to 61fca76dd523 (53 revisions)

Manual roll requested by tarrinneal@google.com

flutter/flutter@3100188...61fca76

2026-04-27 30870216+gaaclarke@users.noreply.github.com Adds integration test for the FLTEnableSDFs flag for iOS (flutter/flutter#185637)
2026-04-27 97480502+b-luk@users.noreply.github.com Fix sdfs being enabled for MacOS regardless of FLTEnableSDFs value (flutter/flutter#185565)
2026-04-27 97480502+b-luk@users.noreply.github.com Don't use UberSDF for paint with incompatible blend modes (flutter/flutter#184889)
2026-04-27 engine-flutter-autoroll@skia.org Roll Dart SDK from de495e3de9a0 to 941ca325cfc9 (2 revisions) (flutter/flutter#185653)
2026-04-27 jhy03261997@gmail.com [a11y] Add CONTENT_CHANGE_TYPE_EXPANDED support on android. (flutter/flutter#185305)
2026-04-27 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#185641)
2026-04-27 1063596+reidbaker@users.noreply.github.com Modify analyze.dart to have flags to run only or exclude each verification step.  (flutter/flutter#185618)
2026-04-27 meylis@divine.video Fix debugNeedsPaint/Layout/CompositedLayerUpdate crashing in release mode (flutter/flutter#184627)
2026-04-27 kallentu@google.com Enable `var_with_no_type_annotation` lint. (flutter/flutter#185215)
2026-04-27 53523825+JhonaCodes@users.noreply.github.com Fix SelectionArea handles overlapping context menu on Android (flutter/flutter#182663)
2026-04-27 30870216+gaaclarke@users.noreply.github.com Adds debugging information to compiled metal shaders (flutter/flutter#185629)
2026-04-27 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#185638)
2026-04-27 84978733+alejandro-all-win-software@users.noreply.github.com Use null-aware elements in dev/devicelab/lib/framework/browser.dart (flutter/flutter#184778)
2026-04-27 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#185633)
2026-04-27 31591868+zawhtetnaing10@users.noreply.github.com Added useOriginalColors flag which allows ImageIcon to bypass IconTheme colorization and use the original colors (flutter/flutter#180491)
2026-04-27 engine-flutter-autoroll@skia.org Roll Packages from 8400f71 to 23280da (2 revisions) (flutter/flutter#185619)
2026-04-27 engine-flutter-autoroll@skia.org Roll Skia from f1238e0f1022 to ce82d32b3e03 (1 revision) (flutter/flutter#185616)
2026-04-27 15619084+vashworth@users.noreply.github.com [SwiftPM] Enable package resolution on xcodebuild commands (flutter/flutter#185208)
2026-04-27 chris@bracken.jp [iOS] Refactor keyboard inset logic into FlutterKeyboardInsetManager (flutter/flutter#185535)
2026-04-27 matej.knopp@gmail.com [Win32] FlutterDesktopEngineGetGraphicsAdapter should use out parameter (flutter/flutter#185590)
2026-04-27 engine-flutter-autoroll@skia.org Roll Skia from d77e3356d526 to f1238e0f1022 (4 revisions) (flutter/flutter#185604)
2026-04-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from flsn8jC4LkTn6WECf... to i6d0NoDueUiXpePfX... (flutter/flutter#185601)
2026-04-26 engine-flutter-autoroll@skia.org Roll Dart SDK from a108dfe2d227 to de495e3de9a0 (1 revision) (flutter/flutter#185599)
2026-04-26 engine-flutter-autoroll@skia.org Roll Skia from ce9aa2231292 to d77e3356d526 (1 revision) (flutter/flutter#185596)
2026-04-26 engine-flutter-autoroll@skia.org Roll Skia from 622fff4c24d2 to ce9aa2231292 (1 revision) (flutter/flutter#185588)
2026-04-25 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 9fPnyEo9PaNdXtasl... to flsn8jC4LkTn6WECf... (flutter/flutter#185585)
2026-04-25 engine-flutter-autoroll@skia.org Roll Dart SDK from 605a8faf0dda to a108dfe2d227 (1 revision) (flutter/flutter#185584)
2026-04-25 engine-flutter-autoroll@skia.org Roll Dart SDK from 6b8c39765f17 to 605a8faf0dda (1 revision) (flutter/flutter#185578)
2026-04-25 engine-flutter-autoroll@skia.org Roll Skia from 185f6b57d64f to 622fff4c24d2 (1 revision) (flutter/flutter#185573)
2026-04-25 evanwall@buffalo.edu Implement square-like round superellipses with circular corners in the SDF uber shader (flutter/flutter#185370)
2026-04-25 victorsanniay@gmail.com Add @awaitNotRequired annotation to flutter sdk (flutter/flutter#181513)
2026-04-25 engine-flutter-autoroll@skia.org Roll Dart SDK from 01228cb7af42 to 6b8c39765f17 (2 revisions) (flutter/flutter#185569)
2026-04-25 flar@google.com Adapt the DisplayList benchmarks into a primitive rendering benchmark suite (flutter/flutter#185270)
2026-04-25 okorohelijah@google.com Enable SPM for GoogleMobileAds (flutter/flutter#185548)
2026-04-25 engine-flutter-autoroll@skia.org Roll Skia from 3f467a581942 to 185f6b57d64f (1 revision) (flutter/flutter#185564)
2026-04-25 victorsanniay@gmail.com Fix Table crash when a cell child paints below the row bottom (flutter/flutter#185323)
2026-04-24 ahmedsameha1@gmail.com Make sure that an Image doesn't crash in 0x0 environment (flutter/flutter#181154)
2026-04-24 engine-flutter-autoroll@skia.org Roll Skia from 300d432048b0 to 3f467a581942 (3 revisions) (flutter/flutter#185558)
2026-04-24 engine-flutter-autoroll@skia.org Roll Dart SDK from c26627715892 to 01228cb7af42 (4 revisions) (flutter/flutter#185559)
2026-04-24 jacksongardner@google.com Reland "[web] Fix LateInitializationError in CkSurface and SkwasmSurface (#185116)" (flutter/flutter#185553)
2026-04-24 41930132+hellohuanlin@users.noreply.github.com [github]fix git ls-file glob pattern in labeler.yml instruction (flutter/flutter#185495)
2026-04-24 41930132+hellohuanlin@users.noreply.github.com [ios]update ios-reviewers tags to include more files (flutter/flutter#185490)
2026-04-24 tomac@google.com Add initial support for Cross-Origin Storage (flutter/flutter#184149)
2026-04-24 30870216+gaaclarke@users.noreply.github.com tool: Skip cached engine artifacts with local engine (flutter/flutter#185546)
...
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.

Support square-like round superellipses in the UberSDF shader

4 participants