Skip to content

Use contour geometry and fill rules for Path.contains - #593

Merged
piercifani merged 1 commit into
skiptools:mainfrom
shial4:codex/fix-path-containment
Nov 3, 2026
Merged

piercifani merged 1 commit into
skiptools:mainfrom
shial4:codex/fix-path-containment

Conversation

@shial4

@shial4 shial4 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Path.contains currently tests only the bounding rectangle. For example, it accepts (80, 80) in a triangle with vertices (0, 0), (100, 0), and (0, 100), and it ignores even-odd cutouts.

Use Compose's path hit tester with the requested fill rule. Materialize explicit and implicit closing edges so every contour segment participates, and leave the stored path's drawing state unchanged. SkipFuseUI already delegates containment to this implementation.

Require AndroidX graphics-path 1.1.0 for its host implementation. With the previous transitive 1.0.1 dependency, path iteration fails under Robolectric with UnsatisfiedLinkError. See the AndroidX release notes.

Validation

  • CI passed for 6b6d54b, including Swift/Robolectric, iOS, and Android emulator tests.
  • Five shared Swift regressions cover a triangle, ellipse corners, explicit closing edges, multiple implicitly closed contours, and alternating nonzero/even-odd queries.
  • All five fail with the original bounding-rectangle implementation and pass with the fix on Android API 34 ARM64 and Robolectric.
  • The nine independent drag regressions also pass with the updated dependency on both runtimes.

The broader local run combined the independent drag and path changes on upstream base 5504558. Host swift test --skip XCSkipTests completed 135 tests with 63 platform skips and no failures. The full Android run completed 228 tests: 211 passed, 14 skipped, and 3 failed. The three font-metric failures (testTextSizeHeadline, testTextSizeCaption, and testTextSizeBody) also reproduce on unchanged upstream source with its original dependencies: actual/expected values 18/19, 12/13, and 18/19 respectively. The focused regressions pass on Android and Robolectric.

Checklist

  • Signed the Contributor Agreement; the current CLA check passes.
  • Tested locally with swift test and separate Android/Gradle runs.
  • Tested on iOS through CI.
  • Tested on an Android emulator.
  • Checked Skip Fuse UI compatibility; no corresponding API change is needed.
  • Added a Showcase example (optional).
  • AI assistance: Codex assisted with implementation, regression tests, review, and automated validation.

@cla-bot cla-bot Bot added the cla-signed label Oct 24, 2026
@shial4

shial4 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Additional reproduction and verification details for 6b6d54b:

The triangle regression distinguishes contour containment from bounding-box containment. The fill-rule regression queries the same path in nonzero, even-odd, then nonzero mode, checking that each query applies the requested rule independently. Separate cases exercise an explicit closing edge and two implicitly closed contours.

From the generated Gradle root, the focused Android suite is:

gradle :SkipUI:connectedDebugAndroidTest \
  '-Pandroid.testInstrumentationRunnerArguments.class=skip.ui.PathContainmentTests'

All five cases fail with the original implementation and pass after restoration on API 34 ARM64. They also pass under Robolectric with graphics-path 1.1.0. Closing edges are materialized because the hit tester indexes geometric segments; preserving the path's original fill state is why containment uses a separate path.

The current PR CI run passed, including iOS and Android emulator jobs. The CLA check also passes. The description retains the three local font-metric failures that reproduce on unchanged upstream source.

@shial4
shial4 marked this pull request as ready for review October 24, 2026 21:02
@piercifani
piercifani merged commit 37d1ee2 into skiptools:main Nov 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants