GrClipStack::contains, add fast path for axis-aligned paths
This seems to address the performance regressions seen in the new
GrClipStack for the Missouri seal svg. An alternative was to just
always transform paths to device space, but this hurt other benchmarks.
This CL leaves us with a more efficient contains and but still keeps
the lazy transformation to device space.
Bug: skia:10730
Change-Id: I4494cd24efbce767b2cc981d8942aafe8328dfb8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317858
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/GrClipStack.cpp b/src/gpu/GrClipStack.cpp
index 6711e5d..c6741b9 100644
--- a/src/gpu/GrClipStack.cpp
+++ b/src/gpu/GrClipStack.cpp
@@ -125,6 +125,15 @@
if (!mixedAAMode && aToDevice == bToDevice) {
// A and B are in the same coordinate space, so don't bother mapping
return a.conservativeContains(b);
+ } else if (bToDevice.isIdentity() && aToDevice.isScaleTranslate()) {
+ // Optimize the common case of draws (B, with identity matrix) and axis-aligned shapes,
+ // instead of checking the four corners separately.
+ SkRect bInA = b;
+ if (mixedAAMode) {
+ bInA.outset(0.5f, 0.5f);
+ }
+ SkAssertResult(deviceToA.mapRect(&bInA));
+ return a.conservativeContains(bInA);
}
// Test each corner for contains; since a is convex, if all 4 corners of b's bounds are