Make GrSurfaceProxy ref counts thread safe.
Bug: chromium:1008312
Change-Id: I90525db25ee61aeb8f03abc7569d8e4224df1497
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250576
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index da4729e..72aad01 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -16,23 +16,10 @@
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/GrTextureProxy.h"
+#include "tests/TestUtils.h"
static const int kWidthHeight = 128;
-static void check_refs(skiatest::Reporter* reporter,
- GrTextureProxy* proxy,
- int32_t expectedProxyRefs,
- int32_t expectedBackingRefs) {
- int32_t actualProxyRefs = proxy->refCnt();
- int32_t actualBackingRefs = proxy->testingOnly_getBackingRefCnt();
-
- SkASSERT(actualProxyRefs == expectedProxyRefs);
- SkASSERT(actualBackingRefs == expectedBackingRefs);
-
- REPORTER_ASSERT(reporter, actualProxyRefs == expectedProxyRefs);
- REPORTER_ASSERT(reporter, actualBackingRefs == expectedBackingRefs);
-}
-
static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
const GrCaps* caps = context->priv().caps();
@@ -69,13 +56,13 @@
int backingRefs = proxy->isInstantiated() ? 1 : -1;
- check_refs(reporter, proxy.get(), 2, backingRefs);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 2, backingRefs);
proxy->instantiate(resourceProvider);
- check_refs(reporter, proxy.get(), 2, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 2, 1);
}
- check_refs(reporter, proxy.get(), 1, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
}
// Multiple normal refs
@@ -87,16 +74,16 @@
int backingRefs = proxy->isInstantiated() ? 1 : -1;
- check_refs(reporter, proxy.get(), 3, backingRefs);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 3, backingRefs);
proxy->instantiate(resourceProvider);
- check_refs(reporter, proxy.get(), 3, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 3, 1);
proxy->unref();
proxy->unref();
}
- check_refs(reporter, proxy.get(), 1, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
}
// Continue using (reffing) proxy after instantiation
@@ -107,16 +94,16 @@
int backingRefs = proxy->isInstantiated() ? 1 : -1;
- check_refs(reporter, proxy.get(), 2, backingRefs);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 2, backingRefs);
proxy->instantiate(resourceProvider);
- check_refs(reporter, proxy.get(), 2, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 2, 1);
sk_sp<GrTextureProxy> secondExtraRef(proxy);
- check_refs(reporter, proxy.get(), 3, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 3, 1);
}
- check_refs(reporter, proxy.get(), 1, 1);
+ check_single_threaded_proxy_refs(reporter, proxy.get(), 1, 1);
}
}
}