Commit 774eeb2
iOS Metal port: fix roundRectPath pill triangular tear
The four-corner round-rect path was tracing each corner with sweep=+pi/2
on start angles -pi/2, 0, +pi/2, pi. Because cn1's GeneralPath.arc()
internally negates the user-facing angles before feeding them to
Ellipse.getPointAtAngle (which uses cy + b*sin(theta) on screen-Y-down
coords), each corner's arc actually traversed the *opposite* quadrant of
its bbox -- top-right's arc started at the bottom of the right ellipse
instead of the top, etc.
For non-pill round-rects the bug was masked: each corner bbox sits in
its own region of the rectangle, so even an arc tracing the wrong
quadrant produced an outline that closed up around the rect interior.
The joinPath=true lineTos between corners crossed the bbox interiors
(e.g. top-right corner picked up a vertical line from (top-edge end) to
(corner-bottom)), but the winding-fill rasterizer happened to fill the
overall area the same way.
For pills (arcWidth == arcHeight == box height, so rx == ry == h/2 and
adjacent corners share a bbox because h-2ry == 0) the broken arcs
overlapped each other and the connecting lineTos cut a triangular gash
through the pill. Visible in SwitchTheme / kotlin: the right half of
the toggle track collapsed into a wedge with the thumb sitting in the
gap. The earlier fix attempts (5fb3f6a joinPath=true, 15e1d9f skip
zero-length edges) were addressing symptoms of the same wrong-quadrant
issue.
Switch to a CW screen-coord traversal where each corner's start angle
matches where the previous edge ended and sweep=-pi/2 traces the
corner's own quadrant:
top-right : start +pi/2 (top), sweep -pi/2 -> right
bottom-right : start 0 (right), sweep -pi/2 -> bottom
bottom-left : start -pi/2 (bottom), sweep -pi/2 -> left
top-left : start +pi (left), sweep -pi/2 -> top
Apply the same correction in MutableGraphics.roundRectPath and
GlobalGraphics.roundRectPath so screen and mutable rendering stay
consistent. The mutable alpha-mask pipeline now renders Switch tracks
as full pills end-to-end on Metal -- verified locally on iPhone 16 Pro
against the kotlin test golden.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1330414 commit 774eeb2
1 file changed
Lines changed: 44 additions & 25 deletions
Lines changed: 44 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4914 | 4914 | | |
4915 | 4915 | | |
4916 | 4916 | | |
4917 | | - | |
4918 | | - | |
4919 | | - | |
4920 | | - | |
4921 | | - | |
| 4917 | + | |
| 4918 | + | |
| 4919 | + | |
| 4920 | + | |
4922 | 4921 | | |
4923 | | - | |
4924 | | - | |
4925 | | - | |
4926 | | - | |
4927 | | - | |
4928 | | - | |
4929 | | - | |
| 4922 | + | |
| 4923 | + | |
| 4924 | + | |
| 4925 | + | |
| 4926 | + | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
| 4942 | + | |
| 4943 | + | |
| 4944 | + | |
| 4945 | + | |
| 4946 | + | |
| 4947 | + | |
| 4948 | + | |
4930 | 4949 | | |
4931 | 4950 | | |
4932 | 4951 | | |
4933 | 4952 | | |
4934 | 4953 | | |
4935 | 4954 | | |
4936 | | - | |
| 4955 | + | |
4937 | 4956 | | |
4938 | | - | |
| 4957 | + | |
4939 | 4958 | | |
4940 | | - | |
| 4959 | + | |
4941 | 4960 | | |
4942 | | - | |
| 4961 | + | |
4943 | 4962 | | |
4944 | 4963 | | |
4945 | 4964 | | |
| |||
5475 | 5494 | | |
5476 | 5495 | | |
5477 | 5496 | | |
5478 | | - | |
5479 | | - | |
5480 | | - | |
5481 | | - | |
5482 | | - | |
| 5497 | + | |
| 5498 | + | |
| 5499 | + | |
| 5500 | + | |
| 5501 | + | |
5483 | 5502 | | |
5484 | 5503 | | |
5485 | 5504 | | |
5486 | 5505 | | |
5487 | 5506 | | |
5488 | 5507 | | |
5489 | | - | |
| 5508 | + | |
5490 | 5509 | | |
5491 | | - | |
| 5510 | + | |
5492 | 5511 | | |
5493 | | - | |
| 5512 | + | |
5494 | 5513 | | |
5495 | | - | |
| 5514 | + | |
5496 | 5515 | | |
5497 | 5516 | | |
5498 | 5517 | | |
| |||
0 commit comments