Skip to content

Fix incorrect UberSDF pixelsize used for stroked shapes - #192659

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
b-luk:ubersdf-stroked-rect-pixel-size
Sep 16, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
b-luk:ubersdf-stroked-rect-pixel-size

Conversation

@b-luk

@b-luk b-luk commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

See #192267 (comment):

We get bad hairline stroking due to uber_sdf.frag calculating pixel size for stroked shapes using pixelSize(sdf) here. pixelSize(sdf) can give incorrect results when dealing with shapes/strokes with width that is close to or less than 1 pixel (due to resolution limits of the dFdx(sdf), dFdy(sdf) that it uses). For stroked shapes, we can simply use the pixel size of the base filled shape.

Fixes #192658

Added a new golden test that draws the shape from those comments.

Before:

impeller_Play_AiksTest_CanRenderTransformedRectWithNearVerticalEdgeHairline_MetalSDF

After:

impeller_Play_AiksTest_CanRenderTransformedRectWithNearVerticalEdgeHairline_MetalSDF

Zoomed in version of before/after from #192267 (comment):

image

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 Sep 11, 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 Sep 11, 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 a new unit test to verify rendering of transformed rectangles with near-vertical edge hairlines, refactors the strokedSDF function in uber_sdf.frag to simplify variable usage, and updates the Mali offline compiler performance metrics in malioc.json. Feedback suggests further simplifying the SDFStroke assignment in uber_sdf.frag by directly assigning the .x component to sdf to avoid declaring an unused temporary variable.

Comment thread engine/src/flutter/impeller/entity/shaders/uber_sdf.frag Outdated
@b-luk
b-luk requested a review from gaaclarke September 11, 2026 23:53
@b-luk

b-luk commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Golden results look good: https://flutter-gold.skia.org/search?issue=192659&crs=github&patchsets=2&corpus=flutter

A bunch of small artifacts near the corners of stroked shapes get fixed.

@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 #192659 at sha 46009e1

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Sep 12, 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.

lgtm, and goldens look good to me too

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.

UberSDF shows badly aliased segments for hairline stroked shapes

2 participants