Skip to content

add playground to test SDF primitive rendering under transforms#185010

Merged
auto-submit[bot] merged 13 commits into
flutter:masterfrom
flar:impeller-sdf-primitive-playground-and-goldens
Apr 17, 2026
Merged

add playground to test SDF primitive rendering under transforms#185010
auto-submit[bot] merged 13 commits into
flutter:masterfrom
flar:impeller-sdf-primitive-playground-and-goldens

Conversation

@flar

@flar flar commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Adds a new (extensible) playground test that draws an SDF primitive under a configurable transform that includes rotation, (non-uniform) scaling, and skewing. If there is an anomaly detected, the values can be copied and a new golden-capable test case can be easily constructed to test just those parameters. One such example which was observed by adjusting values in the playground is included as a demonstration of a real bug in the current code.

This PR also adds a new method that will indicate if the test is being run as a golden test so that a "playground-only" test can opt out of the golden system. The main playground version of the test which contains the UI for managing the transform performs this check and opt-out.

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.

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.

@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 14, 2026
@flar flar marked this pull request as ready for review April 14, 2026 06:38
@flar flar added the CICD Run CI/CD label Apr 14, 2026
@flar flar requested review from b-luk, gaaclarke and walley892 April 14, 2026 06:38

@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 unit tests and a playground for SDF primitives in Impeller, specifically for skewed rectangles, and adds an IsGoldenTest helper to differentiate test environments. Feedback suggests using using for type aliases, improving const-correctness for function parameters and global variables, simplifying matrix transformations, and removing a demonstration test case.

Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
@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 #185010 at sha 94b43ca

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Apr 14, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 14, 2026
@flar

flar commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@flar flar added the CICD Run CI/CD label Apr 14, 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 adds SDF primitive unit tests and a playground for Impeller, including a new test file and updates to playground headers to distinguish golden tests. Review feedback suggests explicitly setting the paint draw style to stroke when a stroke width is provided, replacing an unsafe reinterpret_cast on an enum class with safe casting for ImGui compatibility, and removing a demonstration test case.

Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 14, 2026
@flar flar added the CICD Run CI/CD label Apr 14, 2026
@flar flar requested a review from b-luk April 14, 2026 20:16
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 14, 2026
@flar flar added the CICD Run CI/CD label Apr 14, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 14, 2026
@flar flar added the CICD Run CI/CD label Apr 14, 2026
@flar

flar commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 adds unit tests and a playground for SDF primitives in Impeller to verify stroke consistency under transforms. It introduces aiks_dl_sdf_primitive_unittests.cc and an IsGoldenTest helper to distinguish between playground and golden test environments. Feedback includes correcting an ImGui::ListBox signature to avoid a compilation error, initializing struct members, using float literals for consistency, and marking static methods as constexpr.

Comment on lines +176 to +194
ImGui::ListBox(
"Shape Type", &render_type_index,
[](void* data, int index) {
switch (static_cast<RenderType>(index)) {
case RenderType::kSquare:
return "Square";
case RenderType::kRectangle:
return "Rectangle";
case RenderType::kCircle:
return "Circle";
case RenderType::kOval:
return "Oval";
case RenderType::kLine:
return "Line";
case RenderType::kCount:
FML_UNREACHABLE();
}
},
nullptr, static_cast<int>(RenderType::kCount), -1);

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.

high

The current ImGui::ListBox usage with a lambda getter is incorrect because the standard ImGui signature for the getter overload is bool (*)(void* data, int idx, const char** out_text). The provided lambda returns a const char* and only takes two arguments, which will cause a compilation error. Using a static array of strings is a simpler and more idiomatic approach for a fixed list of items.

      static const char* const items[] = {"Square", "Rectangle", "Circle", "Oval", "Line"};
      ImGui::ListBox("Shape Type", &render_type_index, items, IM_ARRAYSIZE(items));

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.

You used the wrong override. This is a newer version of that function. and has different argument requirements.

Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_playground.h Outdated
Comment thread engine/src/flutter/impeller/golden_tests/golden_playground_test.h Outdated
@flar flar requested review from b-luk and walley892 April 16, 2026 07:04
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
Comment thread engine/src/flutter/impeller/display_list/aiks_dl_sdf_primitive_unittests.cc Outdated
@flar flar requested a review from b-luk April 16, 2026 21:22
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 16, 2026
@flar flar added the CICD Run CI/CD label Apr 17, 2026
@flutter-dashboard

Copy link
Copy Markdown

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

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 #185010 at sha 4d180fb

@b-luk

b-luk commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

If there is an anomaly detected, the values can be copied and a new golden-capable test case can be easily constructed to test just those parameters. One such example which was observed by adjusting values in the playground is included as a demonstration of a real bug in the current code.

@flar The example golden you added shows a hairline being too thin for the SDF renderer. But the hairline also looks wrong for the non-SDF renderers too. It is noticeably thicker than 1 pixel at the pointy ends of the skewed circle, and at the flatter sides it seems thinner than 1 pixel. Is that a current bug too?

image

@flar

flar commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@flar The example golden you added shows a hairline being too thin for the SDF renderer. But the hairline also looks wrong for the non-SDF renderers too.

Correct, that's why I included it. At the time I added it the SDF renderers were not showing anything for any of the hairlines and that was because the hairlines weren't yet implemented in most of them. The test case was for future work, but I also noticed that the non-SDF renderer was producing a bad value for that one "example" test case which is why I removed the "included just as an example" text in the Description since it actually demonstrates a bug. It's harder to fix for the non-SDF renderers but we can create a custom tessellation for this case.

@b-luk

b-luk commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Correct, that's why I included it. At the time I added it the SDF renderers were not showing anything for any of the hairlines and that was because the hairlines weren't yet implemented in most of them. The test case was for future work, but I also noticed that the non-SDF renderer was producing a bad value for that one "example" test case which is why I removed the "included just as an example" text in the Description since it actually demonstrates a bug. It's harder to fix for the non-SDF renderers but we can create a custom tessellation for this case.

SGTM. I don't think fixing the non-SDF version is a priority right now, but we should make sure there's an issue created for it so it's tracked somewhere.

@flar flar added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 17, 2026
Merged via the queue into flutter:master with commit 00b14ee Apr 17, 2026
199 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2026
@flar

flar commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

Filed #185222

We should add tests as necessary when we get done implementing hairlines across all shape types.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 19, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 19, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Apr 20, 2026
flutter/flutter@8e8a194...2844af6

2026-04-19 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from bWoigpGIb60B6C7hD... to aDbXQm6WA0wFCAUp-... (flutter/flutter#185253)
2026-04-18 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from di3JdYrdE9OFu8Iyl... to bWoigpGIb60B6C7hD... (flutter/flutter#185231)
2026-04-18 rmolivares@renzo-olivares.dev Fix: text selection context menu should reappear after a non-fling scroll on Android and iOS (flutter/flutter#185054)
2026-04-18 flar@google.com Rect constructors for circle bounds (MakeCircle/EllipseBounds) (flutter/flutter#185110)
2026-04-17 97480502+b-luk@users.noreply.github.com Change uber SDF to get pixel size (for AA) using euclidean distance rather than manhattan distance. (flutter/flutter#184984)
2026-04-17 engine-flutter-autoroll@skia.org Roll Dart SDK from 7c2564c18770 to 9648f446f131 (7 revisions) (flutter/flutter#185223)
2026-04-17 47866232+chunhtai@users.noreply.github.com Rewrites no-response workflow to work with pr as well (flutter/flutter#185163)
2026-04-17 15619084+vashworth@users.noreply.github.com Only use LLDB breakpoint in debug mode (flutter/flutter#185158)
2026-04-17 flar@google.com add playground to test SDF primitive rendering under transforms (flutter/flutter#185010)
2026-04-17 30870216+gaaclarke@users.noreply.github.com Adds sdf rrects (and fixes opacity + color source) (flutter/flutter#184999)
2026-04-17 matt.kosarek@canonical.com Implementation of popup windows for Win32 (flutter/flutter#184516)
2026-04-17 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from R2EllDf4DgBXVNuiN... to dQ4PjIJB5kZFU8Y32... (flutter/flutter#185207)
2026-04-17 chris@bracken.jp [iOS] Update previousCompositionOrder to return Obj-C type (flutter/flutter#185136)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC boetger@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11531)

flutter/flutter@8e8a194...2844af6

2026-04-19 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from bWoigpGIb60B6C7hD... to aDbXQm6WA0wFCAUp-... (flutter/flutter#185253)
2026-04-18 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from di3JdYrdE9OFu8Iyl... to bWoigpGIb60B6C7hD... (flutter/flutter#185231)
2026-04-18 rmolivares@renzo-olivares.dev Fix: text selection context menu should reappear after a non-fling scroll on Android and iOS (flutter/flutter#185054)
2026-04-18 flar@google.com Rect constructors for circle bounds (MakeCircle/EllipseBounds) (flutter/flutter#185110)
2026-04-17 97480502+b-luk@users.noreply.github.com Change uber SDF to get pixel size (for AA) using euclidean distance rather than manhattan distance. (flutter/flutter#184984)
2026-04-17 engine-flutter-autoroll@skia.org Roll Dart SDK from 7c2564c18770 to 9648f446f131 (7 revisions) (flutter/flutter#185223)
2026-04-17 47866232+chunhtai@users.noreply.github.com Rewrites no-response workflow to work with pr as well (flutter/flutter#185163)
2026-04-17 15619084+vashworth@users.noreply.github.com Only use LLDB breakpoint in debug mode (flutter/flutter#185158)
2026-04-17 flar@google.com add playground to test SDF primitive rendering under transforms (flutter/flutter#185010)
2026-04-17 30870216+gaaclarke@users.noreply.github.com Adds sdf rrects (and fixes opacity + color source) (flutter/flutter#184999)
2026-04-17 matt.kosarek@canonical.com Implementation of popup windows for Win32 (flutter/flutter#184516)
2026-04-17 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from R2EllDf4DgBXVNuiN... to dQ4PjIJB5kZFU8Y32... (flutter/flutter#185207)
2026-04-17 chris@bracken.jp [iOS] Update previousCompositionOrder to return Obj-C type (flutter/flutter#185136)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC boetger@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
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