Add path conversion, containment and intersection to Region - #423
Merged
Merged
Conversation
Region(IPath, IntersectionRule) scan-converts a path into the integer pixels whose centres lie inside it. Contains(Region) and Intersects(Region) compare two regions band by band. The integer clip rounds the path bounds outwards, the same rounding the library applies to clip bounds, so no pixel whose centre lies inside the path is lost.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #423 +/- ##
======================================
Coverage 79% 79%
======================================
Files 232 232
Lines 27531 27785 +254
Branches 3129 3188 +59
======================================
+ Hits 21955 22186 +231
- Misses 4537 4547 +10
- Partials 1039 1052 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
Splits the
Regionadditions out of #415 so they can land on their own, with tests.New members on
Region. They matchSkRegion::setPath,SkRegion::contains(const SkRegion&)andSkRegion::intersects(const SkRegion&).Region(IPath path, IntersectionRule intersectionRule)scan-converts a path into the integer pixels whose centres lie inside it. Rows and crossings use the same fixed-point rounding as Skia's non-antialiased scan converter.Contains(Region region)returns true when every pixel of the argument is in this region.Intersects(Region region)returns true when the two regions share at least one pixel.One change from the #415 code. The integer clip used the ceiling of the path bounds on all four sides. That dropped pixels whose centres lie inside the path when the left or top edge had a fraction of 0.5 or less. The clip now rounds outwards, the same rounding
DrawingClipDescriptorapplies to clip bounds and the same asSkIRect::roundOut. Seven of the new tests fail with the old clip.CA1517. The .NET 11 preview SDK reports CA1517 on
MoveEdgeBackward, asking forReadOnlySpan<RegionEdge>. The method writes link fields through the span indexer, and the suggested change gives CS8332 errors, so the rule is suppressed on that method with a pragma.Tests in
RegionTests:IPath.Containsat pixel centres. Vertex coordinates are chosen so no crossing lands on a pixel centre.Contains(Region)andIntersects(Region)on an L shape, empty regions, touching edges and interleaved islands, plus a pixel-membership check on path-built regions.