Decrease w epsilon to avoid incorrect bounds calculations
Bug: skia:12335
Change-Id: I0106c30d875a7a88431a6e068a82d2d987fc62b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438738
Commit-Queue: Florin Malita <fmalita@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h
index 3051504..3c4172a 100644
--- a/src/core/SkPathPriv.h
+++ b/src/core/SkPathPriv.h
@@ -24,8 +24,9 @@
static const int kPathRefGenIDBitCnt = 32;
#endif
- // skbug.com/9906: Not a perfect solution for W plane clipping, but 1/1024 is a reasonable limit
- static constexpr SkScalar kW0PlaneDistance = 1.f / 1024.f;
+ // skbug.com/9906: Not a perfect solution for W plane clipping, but 1/16384 is a
+ // reasonable limit (roughly 5e-5)
+ static constexpr SkScalar kW0PlaneDistance = 1.f / (1 << 14);
static SkPathFirstDirection AsFirstDirection(SkPathDirection dir) {
// since we agree numerically for the values in Direction, we can just cast.
diff --git a/tests/M44Test.cpp b/tests/M44Test.cpp
index 5e7e814..6d0992c 100644
--- a/tests/M44Test.cpp
+++ b/tests/M44Test.cpp
@@ -312,11 +312,16 @@
// At least one of the mapped corners should have contributed to the rect
REPORTER_ASSERT(reporter, leftFound || topFound || rightFound || bottomFound);
// For any edge that came from a clipped corner, increase its error tolerance relative
- // to what SkPath::ApplyPerspectiveClip calculates
- if (!leftFound) { epsilon.fLeft = 10.f; }
- if (!topFound) { epsilon.fTop = 10.f; }
- if (!rightFound) { epsilon.fRight = 10.f; }
- if (!bottomFound) { epsilon.fBottom = 10.f; }
+ // to what SkPath::ApplyPerspectiveClip calculates.
+ // TODO(michaelludwig): skbug.com/12335 required updating the w epsilon distance which
+ // greatly increased noise for coords projecting to infinity. They aren't "wrong", since
+ // the intent was clearly to pick a big number that's definitely offscreen, but
+ // MapRect should have a more robust solution than a fixed w > epsilon and when it does,
+ // these expectations for clipped points should be more accurate.
+ if (!leftFound) { epsilon.fLeft = .01f * actual.fLeft; }
+ if (!topFound) { epsilon.fTop = .01f * actual.fTop; }
+ if (!rightFound) { epsilon.fRight = .01f * actual.fRight; }
+ if (!bottomFound) { epsilon.fBottom = .01f * actual.fBottom; }
} else {
// The mapped corners should have contributed to all four edges of the returned rect
REPORTER_ASSERT(reporter, leftFound && topFound && rightFound && bottomFound);