Fix GrCCPerFlushResources error caused by cache eviction
By storing the cached atlas proxies in GrCCDrawPathsOp. This is
important because GrCCPathCache may evict an entry that is being used
in current flush, causing the op to lose the proxy it intended to draw
from.
Co-authored with Chris Dalton <csmartdalton@google.com>
Bug: chromium:1102117
Change-Id: I2e4b9360a84732269b6ce98f4d8adfc7e7b9735c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/326576
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index 163e287..d36d0ee 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -909,3 +909,38 @@
}
};
DEF_CCPR_RENDERING_TEST(CCPR_busyPath)
+
+// https://bugs.chromium.org/p/chromium/issues/detail?id=1102117
+class CCPR_evictCacheEntryForPendingDrawOp : public CCPRRenderingTest {
+ void onRun(skiatest::Reporter* reporter, const CCPRPathDrawer& ccpr) const override {
+ static constexpr SkRect kRect = SkRect::MakeWH(50, 50);
+ ccpr.clear();
+
+ // make sure path is cached.
+ for (int i = 0; i < 2; i++) {
+ SkPath path;
+ path.addRect(kRect);
+
+ ccpr.drawPath(path);
+ ccpr.flush();
+ }
+
+ // make enough cached draws to make DoCopies happen.
+ for (int i = 0; i <= GrCoverageCountingPathRenderer::kDoCopiesThreshold; i++) {
+ SkPath path;
+ path.addRect(kRect);
+ ccpr.drawPath(path);
+ }
+
+ // now draw the path in an incompatible matrix. Previous draw's cached atlas should
+ // not be invalidated. otherwise, this flush would render more paths than allocated for.
+ auto m = SkMatrix::Translate(0.1f, 0.1f);
+ SkPath path;
+ path.addRect(kRect);
+ ccpr.drawPath(path, m);
+ ccpr.flush();
+
+ // if this test does not crash, it is passed.
+ }
+};
+DEF_CCPR_RENDERING_TEST(CCPR_evictCacheEntryForPendingDrawOp)