Replace rendering for solid color circles (both filled and stroked) to use SDFs#177482
Replace rendering for solid color circles (both filled and stroked) to use SDFs#177482walley892 merged 4 commits intoflutter:masterfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request introduces SDF-based rendering for solid color circles to improve anti-aliasing quality, which is a great enhancement. The changes include new vertex and fragment shaders, a CircleContents class to use these shaders, and modifications in Canvas::DrawCircle to leverage this new path. A new interactive playground test is also added. The implementation looks solid, but I've found a couple of critical duplication issues that will cause build failures, along with several opportunities to improve code clarity and remove dead code.
81c2883 to
f70ea2a
Compare
|
@walley892 you're going to have to sign the CLA. if you click that presubmit failure it should link you to getting that resolved |
|
the ci.yaml validation issue should be able to be resolved by updating your branch (either by merging main or rebasing against main) |
gaaclarke
left a comment
There was a problem hiding this comment.
This is looking really good. Thanks Mr. Walley892. The concerns are:
- Usage of fwidth
- I want to see how it behaves when scaled
- Let's get the ci happy so golden tests run
97fa29e to
eb2560a
Compare
gaaclarke
left a comment
There was a problem hiding this comment.
Okay, looks good to me. Let's just get CI happy. I think you need to copyright and the others may have been flakes.
chinmaygarde
left a comment
There was a problem hiding this comment.
I have serious misgivings about the direction here. So far, we have avoided having the fragment shaders be concerned about coverage in most cases. This is a notable departure from that approach. That it is being done for cases where there exists a broken MSAA implementation (emulators) makes me question if this is worthwhile.
I think what I am (hopefully incorrectly) concerned about is what happens when such shapes are used in operations where the coverage matters (like clipping). Won't that affect stenciling operations?
This also adds to the pipeline load which makes startup slower (again for the purpose of addressing emulators with broken MSAA).
I had those conversations with Evan already, I'll throw something on your calendar to discuss it. |
eb2560a to
61524b9
Compare
|
From the conversation, I was mistaken about the coverage geometry changing. The additional pipeline variant is unfortunate but Aaron says this is a one off. Looks good to me! Thanks for giving the additional context. |
2cea4fe to
08326c1
Compare
|
FYI I'm happy with the code right now. I'm ready to approve when we are happy with the goldens. I think there were a few that mr wally892 wanted to look at. Particularly relating to think tiny rings evaporating from the anti-aliasing. |
Changed the fragment shader to handle this case. Stroked circles that would be drawn just one pixel wide are just rendered as is with no fading. |
| @@ -51,12 +51,19 @@ void main() { | |||
|
|
|||
| float pixelDerivativeSDF = fwidth(sdfDistance); | |||
There was a problem hiding this comment.
Can you change this file to have consistent variable naming following the c++ style guide? ex pixel_deriviative_sdf
gaaclarke
left a comment
There was a problem hiding this comment.
lgtm as long as the goldens are happy
8939c3b to
8dd29b8
Compare
|
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. |
jtmcdole
left a comment
There was a problem hiding this comment.

8dd29b8 to
297b0c3
Compare
297b0c3 to
6bc009b
Compare
chinmay disregarded this review in a comment but forgot to update the status
Replace rendering for solid color circles (both filled and stroked) to use SDFs. This change improves the visual quality of circle borders, especially on platforms without MSAA support.
Adds a vertex and fragment shader that support SDF rendering for both filled and stroked circles.
Adds a
Contentssubclass,CircleContentsthat uses these shaders for renderingModifies
Canvas::DrawCircleto use this new contents for drawing circlesOnly supports circles with a solid color paint. Everything else continues to use the existing behavior
Adds a playground test that interactively scales circles to ensure fidelity at all scales.
Partially fixes [Impeller] Aliasing artifacts when rendering some SVGs on some Android emulators. #167181
Before (Android emulator):
After (Android emulator):
Pre-launch Checklist
///).