mirror of
https://github.com/flutter/flutter.git
synced 2026-02-05 11:19:18 +08:00
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 `Contents` subclass, `CircleContents` that uses these shaders for rendering - Modifies `Canvas::DrawCircle` to use this new contents for drawing circles - Only 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 https://github.com/flutter/flutter/issues/167181 Before (Android emulator): <img width="236" height="245" alt="Screenshot 2025-10-23 at 4 26 18 PM" src="https://github.com/user-attachments/assets/566de15e-95d3-4b5d-963c-1cebba4aeb50" /> <img width="383" height="394" alt="Screenshot 2025-10-23 at 4 29 32 PM" src="https://github.com/user-attachments/assets/7ca29be6-89f4-43e6-bd9a-c4ec4179ab1c" /> After (Android emulator): <img width="383" height="394" alt="Screenshot 2025-10-23 at 8 48 17 PM" src="https://github.com/user-attachments/assets/f138bedc-edc3-4cba-a982-bd3020d9e44c" /> <img width="236" height="245" alt="Screenshot 2025-10-23 at 4 24 44 PM" src="https://github.com/user-attachments/assets/6b5bec91-e3aa-4daa-9233-3a407b1f1378" /> ## Pre-launch Checklist - [x ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x ] I signed the [CLA]. - [x ] I listed at least one issue that this PR fixes in the description above. - [x ] I updated/added relevant documentation (doc comments with `///`). - [x ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x ] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md