Skip to content

Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer #185695

Merged
auto-submit[bot] merged 8 commits into
flutter:masterfrom
walley892:sdf-rect-se
Apr 30, 2026
Merged

Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer #185695
auto-submit[bot] merged 8 commits into
flutter:masterfrom
walley892:sdf-rect-se

Conversation

@walley892

Copy link
Copy Markdown
Contributor

Adds support for drawing rectangular (non-square) and elliptical (two corner radii) round superellipses in the UberSDF renderer.

Doesn't support non-symmetric corners.

Should be covered by existing golden tests.

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.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 28, 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 Apr 28, 2026
@walley892 walley892 requested a review from gaaclarke April 28, 2026 17:52
@gaaclarke gaaclarke marked this pull request as ready for review April 28, 2026 18:24

@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 enhances the RoundSuperellipse implementation in Impeller to support non-square bounds and non-circular corners. It updates the Canvas class, UberSDFParameters, and the uber_sdf.frag shader to handle separate parameters for the top and right octants of the superellipse, including degrees, semi-axes, and circular arc spans. I have no feedback to provide.

Comment on lines +1060 to +1067
paint.color, round_superellipse.GetBounds(),
Point(octant_top.se_n, octant_right.se_n),
Point(octant_top.se_a, octant_right.se_a), adjusted_radii,
Point(octant_top.circle_max_angle.radians,
octant_right.circle_max_angle.radians),
octant_top.circle_center, octant_right.circle_center,
octant_top.se_a - octant_right.se_a,
Point(round_superellipse_params.top_right.signed_scale.Abs()),

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.

argument comments would be nice at this point

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.

I see your Point. Added

Comment on lines +77 to +78
const Point& superellipse_degree,
const Point& superellipse_a,

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.

Sometimes you are passing points by reference and sometimes by value. I'd just pass them by value since they are small and unlikely to grow.

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.

Donezo

Comment on lines 105 to +114
float distanceFromRoundedSuperellipse(vec2 p,
vec2 ab,
float n,
float angle_span,
vec2 circle_center,
float radius) {
vec2 degree,
vec2 se_a,
vec4 radii_top,
vec2 angle_span,
vec2 circle_center_top,
vec4 radii_right,
vec2 circle_center_right,
float c,
vec2 scale) {

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.

I'd be interested to see the malioc results here. I have concerns about register pressure when we have so many arguments to the function. I wonder if we can make it easier with a struct?

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.

Malioc'd.

The work_registers haven't changed which is surprising to me. The superellipses have such specialized params that both this signature and the uniform block are u-g-l-y.

Adding the non-uniform case will add even more uniforms and arguments here 😢. Maybe we can hold off on any optimizations until that's done?

It may even end up being worth making a more opaque uniform block with packing and unpacking logic everywhere to reduce CPU<->GPU overhead.

p = p.yx;
vec2 p_norm = p / scale;

float n, span, r, a, s;

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.

Can the names be more descriptive or add a comment here?

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.

Yes and yes. Hopefully the variables are clearer now

@gaaclarke

Copy link
Copy Markdown
Member

I have no feedback to provide.

It's speechless, bravo.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 28, 2026
@walley892 walley892 added the CICD Run CI/CD label Apr 28, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 28, 2026
@walley892 walley892 added the CICD Run CI/CD label Apr 28, 2026
gaaclarke
gaaclarke previously approved these changes Apr 28, 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 looks good to me, i checked out the goldens too and there's no problems to report.

dkwingsmt
dkwingsmt previously approved these changes Apr 29, 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 very much!

float radius) {
vec2 degree,
vec2 se_a,
vec4 radii_top,

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.

It seems that radii_top only has its x used?

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.

Yeah, if you look at the caller, it was passing in radii.x. The uniform is reused from the round rect implementation. I bumped the unpacking x here to get the arguments ready for RSEs with different corner parameters

@walley892 walley892 dismissed stale reviews from dkwingsmt and gaaclarke via ea43da5 April 29, 2026 23:54
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 29, 2026
@walley892 walley892 requested a review from gaaclarke April 29, 2026 23:55
@flutter-dashboard

Copy link
Copy Markdown

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.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #185695 at sha 1c64890

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Apr 30, 2026
@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 30, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 30, 2026
Merged via the queue into flutter:master with commit 1047c96 Apr 30, 2026
207 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 30, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 1, 2026
Roll Flutter from 81bc3d69535f to 707dbc0420a3 (85 revisions)

flutter/flutter@81bc3d6...707dbc0

2026-05-01 [email protected] Removing TODOs from the WebParagraph code and addressing technical debts. (flutter/flutter#185168)
2026-05-01 [email protected] Ensure that vulkan_interface.h gets included before vk_mem_alloc.h (flutter/flutter#185777)
2026-05-01 [email protected] [flutter_tools] Bump dwds dependency to v27.1.1 (flutter/flutter#185357)
2026-05-01 [email protected] Roll Dart SDK from 6d4a319cbdac to 9aa7097f2e3e (3 revisions) (flutter/flutter#185888)
2026-05-01 [email protected] Roll Skia from fa1dcb289709 to 7ac6d42f2fd0 (1 revision) (flutter/flutter#185887)
2026-05-01 [email protected] Roll Skia from 54cc00adde38 to fa1dcb289709 (3 revisions) (flutter/flutter#185880)
2026-05-01 [email protected] [iOS] Migrate to FlutterFMLTaskRunner(s) (flutter/flutter#185815)
2026-05-01 [email protected] Remove material imports from navigator_on_did_remove_page_test and scrollable_in_overlay_test (flutter/flutter#182546)
2026-05-01 [email protected] Roll Skia from 2e279266f06a to 54cc00adde38 (3 revisions) (flutter/flutter#185872)
2026-05-01 [email protected] dev: Remove unused parameters (flutter/flutter#185345)
2026-05-01 [email protected] Roll Fuchsia Linux SDK from HN5VYzftnf_B8T-n9... to VnzuUefDQR0UhQ1L1... (flutter/flutter#185870)
2026-05-01 [email protected] Use g_free when using glib memory allocation (flutter/flutter#185519)
2026-05-01 [email protected] Roll Dart SDK from d30df3428f2e to 6d4a319cbdac (2 revisions) (flutter/flutter#185862)
2026-05-01 [email protected] Remove trivial test utility cross-imports from material and cupertino… (flutter/flutter#184295)
2026-05-01 [email protected] Inline test callback painter in tab scaffold test (flutter/flutter#184851)
2026-05-01 [email protected] [a11y] Add support for high contrast themes in the a11y assessments app  (flutter/flutter#185801)
2026-05-01 [email protected] [a11y assessment app] Use default color for banner (flutter/flutter#185804)
2026-04-30 [email protected] Added name to AUTHORS (flutter/flutter#185586)
2026-04-30 [email protected] Remove semantics_tester import from raw_material_button_test.dart (flutter/flutter#184806)
2026-04-30 [email protected] Remove semantics_tester import from user_accounts_drawer_header_test.dart (flutter/flutter#184809)
2026-04-30 [email protected] Roll Skia from 7b88c5c281e5 to 2e279266f06a (5 revisions) (flutter/flutter#185854)
2026-04-30 [email protected] Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer  (flutter/flutter#185695)
2026-04-30 [email protected] Match on process name before killing for SwiftPM (flutter/flutter#185774)
2026-04-30 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#185838)
2026-04-30 [email protected] Roll Dart SDK from 25910e31a6d2 to d30df3428f2e (5 revisions) (flutter/flutter#185839)
2026-04-30 [email protected] Check cross imports test subfolders (flutter/flutter#185493)
2026-04-30 [email protected] test: inline TestCallbackPainter in cupertino/picker_test.dart (flutter/flutter#185398)
2026-04-30 [email protected] Update customer testing version (flutter/flutter#185830)
2026-04-30 [email protected] Adapt the Metal shader library output list for debug versus release mode (flutter/flutter#185798)
2026-04-30 [email protected] [Impeller] Port a recent Vulkan swapchain fence waiting fix to the AHB version of the swapchain (flutter/flutter#185763)
2026-04-30 [email protected] Roll Skia from 26a59aa71eff to 7b88c5c281e5 (1 revision) (flutter/flutter#185821)
2026-04-30 [email protected] Roll Skia from 6b4167b4e204 to 26a59aa71eff (4 revisions) (flutter/flutter#185808)
2026-04-30 [email protected] [a11y] Mark SemanticsNode dirty when customSemanticsActions change  (flutter/flutter#185707)
2026-04-30 [email protected] Roll Skia from 1bd2f1cc2746 to 6b4167b4e204 (8 revisions) (flutter/flutter#185799)
2026-04-30 [email protected] [iOS] Extract FlutterVSyncClient from vsync_waiter_ios (flutter/flutter#185737)
2026-04-30 [email protected] Roll Fuchsia Linux SDK from nnv8-SSam6yE8dw4z... to HN5VYzftnf_B8T-n9... (flutter/flutter#185782)
2026-04-29 [email protected] [iOS] Soften TaskRunner.postTask(delay:task:) delay check (flutter/flutter#185729)
2026-04-29 [email protected] Add reportErrors to ImageStreamListener (flutter/flutter#180327)
2026-04-29 [email protected] Roll Skia from f5c781c083c7 to 1bd2f1cc2746 (5 revisions) (flutter/flutter#185761)
2026-04-29 [email protected] Update merge semantics logic to merge sibling nodes (flutter/flutter#183745)
2026-04-29 [email protected] Roll Packages from ba80f8f to cde5b36 (12 revisions) (flutter/flutter#185748)
2026-04-29 [email protected] examples: Remove unused parameters (flutter/flutter#185346)
2026-04-29 [email protected] Update TickerMode.getValuesNotifier to handle initialization during State.dispose (flutter/flutter#185248)
2026-04-29 [email protected] Update triage links (flutter/flutter#185714)
2026-04-29 [email protected] Add support for high contrast and color inversion on Android (flutter/flutter#182263)
2026-04-29 [email protected] Roll Skia from 05251260fda6 to f5c781c083c7 (2 revisions) (flutter/flutter#185743)
...
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. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants