diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-09-20 17:51:59 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-20 22:30:19 +0000 |
commit | 311cc6b39a3e5f792dc9081ea19e42b930426b99 (patch) | |
tree | d0aeceaa80a232ac2d0330875703b6d489a8a869 /tests/ProxyRefTest.cpp | |
parent | 66b914c7b222035257a01875071cf5b8b68bd51b (diff) |
Another attempt to fix TSAN
Change-Id: I1d6aebcd679a406a13911f4b91f72f4198fc8dc1
Reviewed-on: https://skia-review.googlesource.com/49461
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'tests/ProxyRefTest.cpp')
-rw-r--r-- | tests/ProxyRefTest.cpp | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index 202dd6aeed..16f4f42632 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -54,10 +54,6 @@ static void check_refs(skiatest::Reporter* reporter, int32_t expectedBackingRefs, int32_t expectedNumReads, int32_t expectedNumWrites) { - REPORTER_ASSERT(reporter, proxy); - if (!proxy) { - return; - } REPORTER_ASSERT(reporter, proxy->getProxyRefCnt_TestOnly() == expectedProxyRefs); REPORTER_ASSERT(reporter, proxy->getBackingRefCnt_TestOnly() == expectedBackingRefs); REPORTER_ASSERT(reporter, proxy->getPendingReadCnt_TestOnly() == expectedNumReads); @@ -102,95 +98,102 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { // A single write { sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext())); + if (proxy.get()) { + GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get()); - GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get()); - - static const int kExpectedReads = 0; - static const int kExpectedWrites = 1; + static const int kExpectedReads = 0; + static const int kExpectedWrites = 1; - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transfered to the GrSurface + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + } } // A single read { sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext())); + if (proxy.get()) { + GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get()); - GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get()); + static const int kExpectedReads = 1; + static const int kExpectedWrites = 0; - static const int kExpectedReads = 1; - static const int kExpectedWrites = 0; + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + proxy->instantiate(provider); - proxy->instantiate(provider); - - // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transfered to the GrSurface + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + } } // A single read/write pair { sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext())); + if (proxy.get()) { + GrPendingIOResource<GrSurfaceProxy, kRW_GrIOType> fRW(proxy.get()); - GrPendingIOResource<GrSurfaceProxy, kRW_GrIOType> fRW(proxy.get()); - - static const int kExpectedReads = 1; - static const int kExpectedWrites = 1; + static const int kExpectedReads = 1; + static const int kExpectedWrites = 1; - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transferred to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transferred to the GrSurface + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + } } // Multiple normal refs { sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext())); - proxy->ref(); - proxy->ref(); + if (proxy.get()) { + proxy->ref(); + proxy->ref(); - static const int kExpectedReads = 0; - static const int kExpectedWrites = 0; + static const int kExpectedReads = 0; + static const int kExpectedWrites = 0; - check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites); + check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transferred to the GrSurface - check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transferred to the GrSurface + check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites); - proxy->unref(); - proxy->unref(); + proxy->unref(); + proxy->unref(); + } } // Continue using (reffing) proxy after instantiation { sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext())); - proxy->ref(); + if (proxy.get()) { + proxy->ref(); - GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get()); + GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get()); - static const int kExpectedWrites = 1; + static const int kExpectedWrites = 1; - check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); + check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); + // In the deferred case, this checks that the refs transfered to the GrSurface + check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); - proxy->unref(); - check_refs(reporter, proxy.get(), 1, 1, 0, kExpectedWrites); + proxy->unref(); + check_refs(reporter, proxy.get(), 1, 1, 0, kExpectedWrites); - GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get()); - check_refs(reporter, proxy.get(), 1, 1, 1, kExpectedWrites); + GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get()); + check_refs(reporter, proxy.get(), 1, 1, 1, kExpectedWrites); + } } } } |