Remove interal use of SkRefCnt_SafeAssign.
It turns out that SkDeviceProfile is no longer used and can just be
deleted. The ResourceCacheTest and DebugGLTestContext are changed to use
smart pointers where possible. This also clarifies the squirrelly part of
the test. DebugGLTestContext is going away soon anyway.
Change-Id: I95ef24afa58aa4d356429b93d4dec0d72e3fd827
Reviewed-on: https://skia-review.googlesource.com/140577
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 113945b..dceb3e7 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -283,13 +283,12 @@
~TestResource() override {
--fNumAlive;
- SkSafeUnref(fToDelete);
}
static int NumAlive() { return fNumAlive; }
- void setUnrefWhenDestroyed(TestResource* resource) {
- SkRefCnt_SafeAssign(fToDelete, resource);
+ void setUnrefWhenDestroyed(sk_sp<TestResource> resource) {
+ fToDelete = std::move(resource);
}
static void ComputeScratchKey(SimulatedProperty property, GrScratchKey* key) {
@@ -337,7 +336,7 @@
size_t onGpuMemorySize() const override { return fSize; }
const char* getResourceType() const override { return "Test"; }
- TestResource* fToDelete;
+ sk_sp<TestResource> fToDelete;
size_t fSize;
static int fNumAlive;
SimulatedProperty fProperty;
@@ -1051,8 +1050,8 @@
make_unique_key<0>(&key1, 1);
make_unique_key<0>(&key2, 2);
- TestResource* a = new TestResource(gpu);
- TestResource* b = new TestResource(gpu);
+ sk_sp<TestResource> a(new TestResource(gpu));
+ sk_sp<TestResource> b(new TestResource(gpu));
a->resourcePriv().setUniqueKey(key1);
b->resourcePriv().setUniqueKey(key2);
@@ -1062,8 +1061,9 @@
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
- a->unref();
- b->unref();
+ TestResource* unownedA = a.release();
+ unownedA->unref();
+ b.reset();
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
@@ -1071,7 +1071,7 @@
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
// Break the cycle
- a->setUnrefWhenDestroyed(nullptr);
+ unownedA->setUnrefWhenDestroyed(nullptr);
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
cache->purgeAllUnlocked();