aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrCCPRTest.cpp
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-11-06 14:19:19 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-07 01:56:37 +0000
commit080baa44c50091d4e1a15550ded245c502a9ae3a (patch)
tree835191c5eef9e860f3c62e825c44850044abdbee /tests/GrCCPRTest.cpp
parent18923f9a2e83675aecba7561f5095429fb467633 (diff)
Fix dangling pointers when Ganesh culls CCPR Ops early
BUG=chromium:775868 Change-Id: I0066e34fd8ebe4b46ad72481f5bb955dc0dd5910 Reviewed-on: https://skia-review.googlesource.com/67682 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/GrCCPRTest.cpp')
-rw-r--r--tests/GrCCPRTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index f56298be5a..b8e3db9c10 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -154,6 +154,28 @@ class GrCCPRTest_cleanup : public CCPRTest {
};
DEF_CCPR_TEST(GrCCPRTest_cleanup)
+class GrCCPRTest_unregisterCulledOps : public CCPRTest {
+ void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
+ REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
+
+ // Ensure Ops get unregistered from CCPR when culled early.
+ ccpr.drawPath(fPath);
+ REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
+ ccpr.clear(); // Clear should delete the CCPR Op.
+ REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
+ ccpr.flush(); // Should not crash (DrawPathsOp should have unregistered itself).
+
+ // Ensure Op unregisters work when we delete the context without flushing.
+ ccpr.drawPath(fPath);
+ REPORTER_ASSERT(reporter, !SkPathPriv::TestingOnly_unique(fPath));
+ ccpr.clear(); // Clear should delete the CCPR DrawPathsOp.
+ REPORTER_ASSERT(reporter, SkPathPriv::TestingOnly_unique(fPath));
+ ccpr.abandonGrContext();
+ fMockContext.reset(); // Should not crash (DrawPathsOp should have unregistered itself).
+ }
+};
+DEF_CCPR_TEST(GrCCPRTest_unregisterCulledOps)
+
class CCPRRenderingTest {
public:
void run(skiatest::Reporter* reporter, GrContext* ctx) const {