Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

[GDI.WinForms] fix rounded rectangles #188

Merged
merged 3 commits into from
Oct 15, 2021

Conversation

swharden
Copy link
Contributor

@swharden swharden commented Oct 4, 2021

This PR improves GDI support for rounded rectangles by preventing exceptions when a radius of 0 is used. Some of the test scenarios test for this, resulting in a crash, and preventing the scenarios from completing.

Although this PR prevents the exception and allows the tests to complete, rounded rectangles still don't render properly on GDI. I may fix that in a separate PR, but for now not crashing the scenario seems like a good improvement 馃槄

EDIT: the rendering errors were pretty easy to fix, so I fixed those in this PR too. Also note that AddArc() expects a circle's bounding box size (its diameter), not its radius, so this PR fixes that too to bring the GDI images into agreement with Skia's 馃憤

Example: Radius < Height

Skia GDI before GDI after
image image image

Example: Radius > Height

Skia GDI before GDI after
skia gdi image

Adds logic so drawing or filling rounded rectangles with zero radius calls the regular rectangle methods (previously an exception was thrown)
Added (or simplified) logic to ensure the radius of a rounded rectangle is never larger than the rectangle itself, fixing rendering artifacts that previously occurred with filled rounded rectangles.
@swharden swharden changed the title [GDI.WinForms] fix rounded rectangles with 0 radius [GDI.WinForms] fix rounded rectangles Oct 4, 2021
The AddArc() call draws a circle inside a bounding rectangle, and its arguments expect the size of the rectangle (not half its size). This fix brings the GDI rectangle shapes rendered into agreement with the Skia control.
@jonlipsky
Copy link
Contributor

@swharden Thanks so much for this!!!

@jonlipsky jonlipsky merged commit 762ce90 into dotnet:main Oct 15, 2021
@swharden swharden deleted the gdi-rounded-rect branch October 15, 2021 18:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants