Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer #185695
Conversation
There was a problem hiding this comment.
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.
| 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()), |
There was a problem hiding this comment.
argument comments would be nice at this point
There was a problem hiding this comment.
I see your Point. Added
| const Point& superellipse_degree, | ||
| const Point& superellipse_a, |
There was a problem hiding this comment.
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.
| 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Can the names be more descriptive or add a comment here?
There was a problem hiding this comment.
Yes and yes. Hopefully the variables are clearer now
It's speechless, bravo. |
gaaclarke
left a comment
There was a problem hiding this comment.
This looks good to me, i checked out the goldens too and there's no problems to report.
dkwingsmt
left a comment
There was a problem hiding this comment.
LGTM. Thank you very much!
| float radius) { | ||
| vec2 degree, | ||
| vec2 se_a, | ||
| vec4 radii_top, |
There was a problem hiding this comment.
It seems that radii_top only has its x used?
There was a problem hiding this comment.
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
|
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 Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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) ...
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
///).